Compare commits
No commits in common. "master" and "19a57fe6ca344a1de9c6537ad15806ebcb2bbe4a" have entirely different histories.
master
...
19a57fe6ca
46 changed files with 3021 additions and 5893 deletions
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"env": {
|
||||
"es2021": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
2
.github/ISSUE_TEMPLATE/xml-formatter.md
vendored
2
.github/ISSUE_TEMPLATE/xml-formatter.md
vendored
|
|
@ -7,7 +7,7 @@ about: Report an issue with the XML formatter.
|
|||
What seems to be the problem?
|
||||
|
||||
#### Formatter Implementation
|
||||
Which XML Formatter implementation are you using (the value of your `basexTools.xmlFormatterImplementation` setting).
|
||||
Which XML Formatter implementation are you using (the value of your `xmlTools.xmlFormatterImplementation` setting).
|
||||
|
||||
#### XML Tools Version
|
||||
What version of XML Tools are you using?
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,4 +2,3 @@ out
|
|||
node_modules
|
||||
.vscode-test/
|
||||
/*.vsix
|
||||
|
||||
|
|
|
|||
5
.vscode/extensions.json
vendored
5
.vscode/extensions.json
vendored
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"recommendations": [
|
||||
|
||||
]
|
||||
}
|
||||
3
.vscode/launch.json
vendored
3
.vscode/launch.json
vendored
|
|
@ -2,14 +2,13 @@
|
|||
{
|
||||
"version": "0.1.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"name": "Extension",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
|
||||
"stopOnEntry": true,
|
||||
"stopOnEntry": false,
|
||||
"sourceMaps": true,
|
||||
"outFiles": [ "${workspaceRoot}/out/**/*.js" ],
|
||||
"preLaunchTask": "npm: watch"
|
||||
|
|
|
|||
11
.vscode/sftp.json
vendored
Normal file
11
.vscode/sftp.json
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "My Server",
|
||||
"host": "localhost",
|
||||
"protocol": "sftp",
|
||||
"port": 22,
|
||||
"username": "username",
|
||||
"remotePath": "/",
|
||||
"uploadOnSave": true,
|
||||
"useTempFile": false,
|
||||
"openSsh": false
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
node_modules
|
||||
#out/
|
||||
src/
|
||||
tsconfig.json
|
||||
.github
|
||||
.vscode/**
|
||||
.vscode-test/**
|
||||
out/test/**
|
||||
out/**/*.map
|
||||
src/**
|
||||
.gitignore
|
||||
.vscode
|
||||
|
||||
tsconfig.json
|
||||
vsc-extension-quickstart.md
|
||||
|
|
|
|||
15
CHANGELOG.md
15
CHANGELOG.md
|
|
@ -1,14 +1 @@
|
|||
# 0.1.0 (2023-02-19)
|
||||
Update xqlint to 0.2.0
|
||||
|
||||
# 0.0.64 (2023-01-26)
|
||||
* add simple hover display
|
||||
* Update `xqlint.d.ts` to support newer `tsc.exe`. This reduces size of vsix from 600kb to 300kb
|
||||
|
||||
# 0.0.58
|
||||
* use xqlint 0.0.14
|
||||
|
||||
# 0.0.48
|
||||
* Fix xmlToText #6
|
||||
* FIX outline all vars
|
||||
|
||||
Detailed release notes are available [here](https://github.com/DotJoshJohnson/vscode-xml/releases).
|
||||
30
CONTRIBUTING.md
Normal file
30
CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Contributing to XML Tools
|
||||
Welcome and thank you for contributing to **XML Tools for Visual Studio Code**! This document aims to provide an overview of standards and expectations for those interested in contributing to the project.
|
||||
|
||||
## Asking Questions
|
||||
If you have any questions, please ask on Gitter or Twitter instead of submitting an issue.
|
||||
|
||||
## Reporting Issues
|
||||
Before submitting a new issue, please be sure to check for an existing issue that matches yours first. Issues that are waiting for information for more than 30 days will be closed, so please be sure to follow your issues!
|
||||
|
||||
## Writing Code
|
||||
If you would like to contribute code to the project, please follow these conventions:
|
||||
|
||||
* Use spaces over tabs (4 spaces per tab is preferred).
|
||||
* Use double quotes whenever possible instead of single quotes.
|
||||
* Use **snake-case** for file names.
|
||||
* Use **PascalCase** for class and interface names.
|
||||
* Use **camelCase** for all other identifiers unless otherwise specified.
|
||||
* Prefix private members with an underscore.
|
||||
* Implement and maintain barrels (`index.ts` files) when creating new folders or files.
|
||||
* Use constants when referencing a static value more than once in your code.
|
||||
* Place `else` and `else if` on their own lines.
|
||||
* Never put opening braces (`{`) on their own line.
|
||||
* Always use semicolons.
|
||||
* Always prefer `const` whenever possible and fall back to `let` only if absolutely necessary.
|
||||
|
||||
### Branches and Pull Requests
|
||||
Always develop on a new feature branch in your fork and submit pull requests from that branch to our master branch. Don't worry about changing any version numbers - that happens in its own PR before a release.
|
||||
|
||||
### Formatter Changes
|
||||
For small bug fixes or feature additions, always add a new test case to accompany your change. If you are making large sweeping changes to how the formatter works or leveraging an external dependency for formatting XML, please create a new XmlFormatter implementation.
|
||||
2
LICENSE
2
LICENSE
|
|
@ -1,6 +1,6 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2022 Andy Bunce
|
||||
Copyright (c) 2015 Josh Johnson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
|||
70
README.md
70
README.md
|
|
@ -1,55 +1,43 @@
|
|||
# BaseX Tools for Visual Studio Code
|
||||
# XML Tools for Visual Studio Code
|
||||
[](https://marketplace.visualstudio.com/items?itemName=DotJoshJohnson.xml)
|
||||
[](https://marketplace.visualstudio.com/items?itemName=DotJoshJohnson.xml)
|
||||
|
||||
|
||||
The vscode-basex extension adds features to support [BaseX](https://basex.org/) development on VSCode.
|
||||
For XQuery
|
||||
* Grammar support for:XQuery 3.1, XQuery update, Full text syntax
|
||||
* code format
|
||||
* code completion
|
||||
* code snippets
|
||||
* outline symbol view
|
||||
[](https://twitter.com/DotJoshJohnson)
|
||||
[](https://gitter.im/vscode-xml/vscode-xml)
|
||||
[](https://beerpay.io/DotJoshJohnson/vscode-xml)
|
||||
|
||||
## Features
|
||||
* [XQuery Linting](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xquery-linting)
|
||||
* [XQuery Code Completion](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xquery-code-completion)
|
||||
* [XQuery Execution](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xquery-script-execution)
|
||||
* [XQuery source formating](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xquery-source-formating)
|
||||
|
||||
* [XML Formatting](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xml-formatting)
|
||||
* [XML Tree View](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xml-tree-view)
|
||||
* [XPath Evaluation](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xpath-evaluation)
|
||||
|
||||
* [XML Formatting](https://github.com/DotJoshJohnson/vscode-xml/wiki/xml-formatting)
|
||||
* [XML Tree View](https://github.com/DotJoshJohnson/vscode-xml/wiki/xml-tree-view)
|
||||
* [XPath Evaluation](https://github.com/DotJoshJohnson/vscode-xml/wiki/xpath-evaluation)
|
||||
* [XQuery Linting](https://github.com/DotJoshJohnson/vscode-xml/wiki/xquery-linting)
|
||||
* [XQuery Execution](https://github.com/DotJoshJohnson/vscode-xml/wiki/xquery-script-execution)
|
||||
* [XQuery Code Completion](https://github.com/DotJoshJohnson/vscode-xml/wiki/xquery-code-completion)
|
||||
|
||||
## Requirements
|
||||
* VS Code `1.63.0` or higher
|
||||
* VS Code `1.22.2` or higher
|
||||
|
||||
## Extension Settings
|
||||
* **`xmlTools.enableXmlTreeView`:** Enables the XML Tree View for XML documents.
|
||||
* **`xmlTools.enableXmlTreeViewMetadata`:** Enables attribute and child element counts in the XML Document view.
|
||||
* **`xmlTools.enableXmlTreeViewCursorSync`:** Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.
|
||||
* **`xmlTools.enforcePrettySelfClosingTagOnFormat`:** Ensures a space is added before the forward slash at the end of a self-closing tag.
|
||||
* **`xmlTools.ignoreDefaultNamespace`:** Ignore default xmlns attributes when evaluating XPath.
|
||||
* **`xmlTools.persistXPathQuery`:** Remember the last XPath query used.
|
||||
* **`xmlTools.removeCommentsOnMinify`:** Remove XML comments during minification.
|
||||
* **`xmlTools.splitAttributesOnFormat`:** Put each attribute on a new line when formatting XML. Overrides `xmlTools.splitXmlnsOnFormat` if set to `true`. (V2 Formatter Only)
|
||||
* **`xmlTools.splitXmlnsOnFormat`:** Put each xmlns attribute on a new line when formatting XML.
|
||||
* **`xmlTools.xmlFormatterImplementation`:** Supported XML Formatters: `classic`, `v2`.
|
||||
* **`xmlTools.xqueryExecutionArguments`:** Arguments to be passed to the XQuery execution engine.
|
||||
* **`xmlTools.xqueryExecutionEngine`:** The full path to the executable to run when executing XQuery scripts.
|
||||
|
||||
## Release Notes
|
||||
Detailed release notes are available [here](https://git.quodatum.duckdns.org/apb/vscode-basex/releases).
|
||||
Detailed release notes are available [here](https://github.com/DotJoshJohnson/vscode-xml/releases).
|
||||
|
||||
## Issues
|
||||
Run into a bug? Report it [here](https://git.quodatum.duckdns.org/apb/vscode-basex/issues).
|
||||
## Development
|
||||
|
||||
## build
|
||||
|
||||
```
|
||||
npm install
|
||||
npm install -g typescript #maybe
|
||||
npm install --global vsce
|
||||
#
|
||||
npm run compile
|
||||
vsce package
|
||||
```
|
||||
|
||||
## Inspiration
|
||||
|
||||
This project was created from a fork of [DotJoshJohnson/vscode-xml](https://github.com/DotJoshJohnson/vscode-xml). Much of `DotJoshJohnson/vscode-xml` code dealing with XML has been removed and additional XQuery features added.
|
||||
|
||||
The code parsing uses [quodatum/xqlint] which is based on [wcandillon/xqlint]
|
||||
Run into a bug? Report it [here](https://github.com/DotJoshJohnson/vscode-xml/issues).
|
||||
|
||||
## Icon Credits
|
||||
Icons used in the XML Tree View are used under the Creative Commons 3.0 BY license.
|
||||
* "Code" icon by Dave Gandy from www.flaticon.com
|
||||
* "At" icon by FreePik from www.flaticon.com
|
||||
|
||||
|
||||
|
|
|
|||
32
azure-pipelines.yml
Normal file
32
azure-pipelines.yml
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
name: "$(Build.SourceBranchName)-$(Build.SourceVersion)$(Rev:.r)"
|
||||
pr:
|
||||
- master
|
||||
|
||||
trigger:
|
||||
- "refs/tags/*"
|
||||
|
||||
pool:
|
||||
vmImage: "windows-2019"
|
||||
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: "10.x"
|
||||
displayName: "Install NodeJS"
|
||||
|
||||
- script: |
|
||||
npm install -g vsce
|
||||
displayName: "Install VSCE"
|
||||
|
||||
- script: |
|
||||
npm install
|
||||
displayName: "NPM Install"
|
||||
|
||||
- script: |
|
||||
vsce package --out "$(Build.ArtifactStagingDirectory)/xml-$(Build.SourceBranchName)-$(Build.SourceVersion).vsix"
|
||||
displayName: "VSCE Package"
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
pathtoPublish: $(Build.ArtifactStagingDirectory)
|
||||
artifactName: drop
|
||||
|
|
@ -1,19 +1,20 @@
|
|||
{
|
||||
"comments": {
|
||||
"lineComment": ["(:", ":)"],
|
||||
"blockComment": [ "(:", ":)"]
|
||||
"blockComment": [ "(:~", "~:)"]
|
||||
},
|
||||
"brackets": [
|
||||
[ "{", "}" ],
|
||||
[ "[", "]" ],
|
||||
[ "(", ")" ]
|
||||
[
|
||||
"{",
|
||||
"}"
|
||||
],
|
||||
"surroundingPairs": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"],
|
||||
["'", "'"],
|
||||
["\"", "\""],
|
||||
["`", "`"]
|
||||
[
|
||||
"[",
|
||||
"]"
|
||||
],
|
||||
[
|
||||
"(",
|
||||
")"
|
||||
]
|
||||
]
|
||||
}
|
||||
|
|
|
|||
57
notes.md
57
notes.md
|
|
@ -1,57 +0,0 @@
|
|||
# Debugging 2022-02-12...
|
||||
## apb.js
|
||||
```javascript
|
||||
var XQLint = require('../lib/xqlint').XQLint;
|
||||
var source = 'let $v1 := 1\nlet $foo := $v1\nreturn $v1 + $';
|
||||
var linter = new XQLint(source);
|
||||
var lines = source.split('\n');
|
||||
var pos = { line: lines.length -1 , col: lines[lines.length - 1].length };
|
||||
var proposals = linter.getCompletions(pos);
|
||||
console.log(proposals);
|
||||
```
|
||||
------
|
||||
|
||||
## completer.js/getCompletions
|
||||
|
||||
### wcandillon /xqlint
|
||||
```javascript
|
||||
ast.pos={sl: 0, sc: 0, el: 2, ec: 14}
|
||||
pos={col:14,line:2}
|
||||
|
||||
node=TreeOps.findNode(ast, pos);
|
||||
// node{name: 'token', value: "$"}
|
||||
|
||||
sctx = TreeOps.findNode(rootSctx, pos);
|
||||
```
|
||||
### quodatum
|
||||
```javascript
|
||||
pos={col:14,line:2}
|
||||
ast.pos={sl: 0, sc: 0, el: 2, ec: **10**}
|
||||
ast.name=XQuery
|
||||
```
|
||||
Therefore error is in XQlint
|
||||
## XQLint
|
||||
```javascript
|
||||
// save source, ast=null
|
||||
var h = new JSONParseTreeHandler(source);
|
||||
|
||||
// set source and handler
|
||||
var parser = new XQueryParser(source, h);
|
||||
try {
|
||||
// attempt to parse startNonterminal "XQuery"
|
||||
parser.parse_XQuery();
|
||||
}catch(e){
|
||||
syntaxError = true;
|
||||
h.closeParseTree();
|
||||
}
|
||||
ast = h.getParseTree();
|
||||
```
|
||||
|
||||
### wcandillon /xqlint
|
||||
```javascript
|
||||
ast.pos={sl: 0, sc: 0, el: 2, ec: 14}
|
||||
```
|
||||
### quodatum
|
||||
```javascript
|
||||
pos={col:14,line:2}
|
||||
```
|
||||
4795
package-lock.json
generated
4795
package-lock.json
generated
File diff suppressed because it is too large
Load diff
239
package.json
239
package.json
|
|
@ -1,131 +1,149 @@
|
|||
{
|
||||
"name": "vscode-basex",
|
||||
"displayName": "BaseX tools",
|
||||
"description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code",
|
||||
"version": "0.1.0",
|
||||
"preview": true,
|
||||
"displayName": "XML Tools for BaseX",
|
||||
"description": "XML Formatting, XQuery, and XPath Tools for Visual Studio Code",
|
||||
"version": "0.0.1",
|
||||
"preview": false,
|
||||
"publisher": "quodatum",
|
||||
"author": "Andy Bunce (https://github.com/Quodatum)",
|
||||
"author": {
|
||||
"name": "Andy Bunce",
|
||||
"url": "https://github.com/DotJoshJohnson"
|
||||
},
|
||||
"license": "MIT",
|
||||
"galleryBanner": {
|
||||
"color": "#FFFFFF",
|
||||
"theme": "light"
|
||||
},
|
||||
"icon": "resources/basex.png",
|
||||
"homepage": "https://github.com/Quodatum/vscode-basex",
|
||||
"icon": "resources/xml.png",
|
||||
"homepage": "https://github.com/DotJoshJohnson/vscode-xml",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Quodatum/vscode-basex.git"
|
||||
"url": "https://github.com/DotJoshJohnson/vscode-xml.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Quodatum/vscode-basex/issues"
|
||||
"url": "https://github.com/DotJoshJohnson/vscode-xml/issues"
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.73.0"
|
||||
"vscode": "^1.63.0"
|
||||
},
|
||||
"categories": [
|
||||
"Formatters",
|
||||
"Programming Languages",
|
||||
"Linters",
|
||||
"Snippets",
|
||||
"Other"
|
||||
],
|
||||
"activationEvents": [
|
||||
"onCommand:basexTools.evaluateXPath",
|
||||
"onCommand:basexTools.executeXQuery",
|
||||
"onCommand:basexTools.formatAsXml",
|
||||
"onCommand:basexTools.textToXml",
|
||||
"onCommand:basexTools.xmlToText",
|
||||
"onCommand:basexTools.minifyXml",
|
||||
"onCommand:basexTools.xqLintReport",
|
||||
"onCommand:xmlTools.evaluateXPath",
|
||||
"onCommand:xmlTools.executeXQuery",
|
||||
"onCommand:xmlTools.formatAsXml",
|
||||
"onCommand:xmlTools.textToXml",
|
||||
"onCommand:xmlTools.xmlToText",
|
||||
"onCommand:xmlTools.minifyXml",
|
||||
"onLanguage:xml",
|
||||
"onLanguage:xquery",
|
||||
"onLanguage:xsl"
|
||||
],
|
||||
"main": "./out/extension.js",
|
||||
"main": "./out/extension",
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"command": "basexTools.evaluateXPath",
|
||||
"title": "BaseX Tools: Evaluate XPath"
|
||||
"command": "xmlTools.evaluateXPath",
|
||||
"title": "XML Tools: Evaluate XPath"
|
||||
},
|
||||
{
|
||||
"command": "basexTools.executeXQuery",
|
||||
"title": "BaseX Tools: Execute XQuery"
|
||||
"command": "xmlTools.executeXQuery",
|
||||
"title": "XML Tools: Execute XQuery"
|
||||
},
|
||||
{
|
||||
"command": "basexTools.formatAsXml",
|
||||
"title": "BaseX Tools: Format as XML"
|
||||
"command": "xmlTools.formatAsXml",
|
||||
"title": "XML Tools: Format as XML"
|
||||
},
|
||||
{
|
||||
"command": "basexTools.textToXml",
|
||||
"title": "BaseX Tools: Convert text to XML (<> -> <>)"
|
||||
"command": "xmlTools.textToXml",
|
||||
"title": "XML Tools: Convert text to XML (<> -> <>)"
|
||||
},
|
||||
{
|
||||
"command": "basexTools.xmlToText",
|
||||
"title": "BaseX Tools: Convert XML to text (<> -> <>)"
|
||||
"command": "xmlTools.xmlToText",
|
||||
"title": "XML Tools: Convert XML to text (<> -> <>)"
|
||||
},
|
||||
{
|
||||
"command": "basexTools.getCurrentXPath",
|
||||
"title": "BaseX Tools: Get Current XPath"
|
||||
"command": "xmlTools.getCurrentXPath",
|
||||
"title": "XML Tools: Get Current XPath"
|
||||
},
|
||||
{
|
||||
"command": "basexTools.minifyXml",
|
||||
"title": "BaseX Tools: Minify XML"
|
||||
},
|
||||
{
|
||||
"command": "basexTools.xqLintReport",
|
||||
"title": "BaseX Tools: Analysis of current location in Xquery source"
|
||||
"command": "xmlTools.minifyXml",
|
||||
"title": "XML Tools: Minify XML"
|
||||
}
|
||||
],
|
||||
"configuration": [
|
||||
{
|
||||
"id": "xmltree",
|
||||
"title": "XML tree view ",
|
||||
"configuration": {
|
||||
"title": "XML Tools Configuration",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"basexTools.xmlTree.enableTreeView": {
|
||||
"xmlTools.enableXmlTreeView": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"default": true,
|
||||
"description": "Enables the XML Document view in the explorer for XML documents.",
|
||||
"scope": "window"
|
||||
},
|
||||
"basexTools.xmlTree.enableViewMetadata": {
|
||||
"xmlTools.enableXmlTreeViewMetadata": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Enables attribute and child element counts in the XML Document view.",
|
||||
"scope": "window"
|
||||
},
|
||||
"basexTools.xmlTree.enableViewCursorSync": {
|
||||
"xmlTools.enableXmlTreeViewCursorSync": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.",
|
||||
"scope": "window"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "xpath",
|
||||
"title": "XPath ",
|
||||
"properties": {
|
||||
"basexTools.xpath.ignoreDefaultNamespace": {
|
||||
"xmlTools.enforcePrettySelfClosingTagOnFormat": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Enforces a space before the forward slash at the end of a self-closing XML tag.",
|
||||
"scope": "resource"
|
||||
},
|
||||
"xmlTools.ignoreDefaultNamespace": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Ignore default xmlns attributes when evaluating XPath.",
|
||||
"scope": "window"
|
||||
},
|
||||
"basexTools.xpath.persistXPathQuery": {
|
||||
"xmlTools.persistXPathQuery": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Remember the last XPath query used.",
|
||||
"scope": "window"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "xquery",
|
||||
"title": "XQuery ",
|
||||
"properties": {
|
||||
"basexTools.xquery.executionArguments": {
|
||||
"xmlTools.removeCommentsOnMinify": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Remove XML comments during minification.",
|
||||
"scope": "resource"
|
||||
},
|
||||
"xmlTools.splitAttributesOnFormat": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Put each attribute on a new line when formatting XML. Overrides `xmlTools.splitXmlnsOnFormat` if set to `true`.",
|
||||
"scope": "resource"
|
||||
},
|
||||
"xmlTools.splitXmlnsOnFormat": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Put each xmlns attribute on a new line when formatting XML.",
|
||||
"scope": "resource"
|
||||
},
|
||||
"xmlTools.xmlFormatterImplementation": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"classic",
|
||||
"v2"
|
||||
],
|
||||
"default": "v2",
|
||||
"description": "Supported XML Formatters: classic",
|
||||
"scope": "window"
|
||||
},
|
||||
"xmlTools.xqueryExecutionArguments": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
"-xquery",
|
||||
|
|
@ -138,19 +156,19 @@
|
|||
"description": "Arguments to be passed to the XQuery execution engine.",
|
||||
"scope": "window"
|
||||
},
|
||||
"basexTools.xquery.executionEngine": {
|
||||
"xmlTools.xqueryExecutionEngine": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"description": "The full path to the executable to run when executing XQuery scripts.",
|
||||
"scope": "window"
|
||||
},
|
||||
"basexTools.xquery.executionInputLimit": {
|
||||
"xmlTools.xqueryExecutionInputLimit": {
|
||||
"type": "integer",
|
||||
"default": 100,
|
||||
"description": "The maximum number of input files to enumerate when executing XQuery scripts.",
|
||||
"scope": "window"
|
||||
},
|
||||
"basexTools.xquery.executionInputSearchPattern": {
|
||||
"xmlTools.xqueryExecutionInputSearchPattern": {
|
||||
"type": "string",
|
||||
"default": "**/*.xml",
|
||||
"description": "The pattern used to search for input XML files when executing XQuery scripts.",
|
||||
|
|
@ -158,47 +176,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "BaseX Tools ",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"basexTools.enforcePrettySelfClosingTagOnFormat": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Enforces a space before the forward slash at the end of a self-closing XML tag.",
|
||||
"scope": "resource"
|
||||
},
|
||||
"basexTools.removeCommentsOnMinify": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Remove XML comments during minification.",
|
||||
"scope": "resource"
|
||||
},
|
||||
"basexTools.splitAttributesOnFormat": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Put each attribute on a new line when formatting XML. Overrides `basexTools.splitXmlnsOnFormat` if set to `true`.",
|
||||
"scope": "resource"
|
||||
},
|
||||
"basexTools.splitXmlnsOnFormat": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Put each xmlns attribute on a new line when formatting XML.",
|
||||
"scope": "resource"
|
||||
},
|
||||
"basexTools.xmlFormatterImplementation": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"classic",
|
||||
"v2"
|
||||
],
|
||||
"default": "v2",
|
||||
"description": "Supported XML Formatters: classic",
|
||||
"scope": "window"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"grammars": [
|
||||
{
|
||||
"language": "xquery",
|
||||
|
|
@ -206,20 +183,14 @@
|
|||
"scopeName": "source.xquery"
|
||||
}
|
||||
],
|
||||
"snippets": [
|
||||
{
|
||||
"language": "xquery",
|
||||
"path": "./snippets.jsonc"
|
||||
}
|
||||
],
|
||||
"keybindings": [
|
||||
{
|
||||
"key": "ctrl+shift+alt+x",
|
||||
"command": "basexTools.evaluateXPath"
|
||||
"command": "xmlTools.evaluateXPath"
|
||||
},
|
||||
{
|
||||
"key": "ctrl+shift+alt+b",
|
||||
"command": "basexTools.formatAsXml"
|
||||
"command": "xmlTools.formatAsXml"
|
||||
}
|
||||
],
|
||||
"languages": [
|
||||
|
|
@ -232,8 +203,7 @@
|
|||
".xsd",
|
||||
".xsl",
|
||||
".plist",
|
||||
".mobileconfig",
|
||||
".sch"
|
||||
".mobileconfig"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -255,25 +225,25 @@
|
|||
"menus": {
|
||||
"commandPalette": [
|
||||
{
|
||||
"command": "basexTools.evaluateXPath",
|
||||
"command": "xmlTools.evaluateXPath",
|
||||
"when": "editorLangId == xml"
|
||||
},
|
||||
{
|
||||
"command": "basexTools.executeXQuery",
|
||||
"command": "xmlTools.executeXQuery",
|
||||
"when": "editorLangId == xquery"
|
||||
},
|
||||
{
|
||||
"command": "basexTools.getCurrentXPath",
|
||||
"command": "xmlTools.getCurrentXPath",
|
||||
"when": "editorLangId == xml"
|
||||
},
|
||||
{
|
||||
"command": "basexTools.minifyXml",
|
||||
"command": "xmlTools.minifyXml",
|
||||
"when": "editorLangId == xml"
|
||||
}
|
||||
],
|
||||
"editor/context": [
|
||||
{
|
||||
"command": "basexTools.minifyXml",
|
||||
"command": "xmlTools.minifyXml",
|
||||
"group": "1_modification@100",
|
||||
"when": "editorLangId == 'xml'"
|
||||
}
|
||||
|
|
@ -290,11 +260,7 @@
|
|||
}
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "npm run esbuild-base -- --minify",
|
||||
"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node",
|
||||
"esbuild": "npm run esbuild-base -- --sourcemap",
|
||||
"esbuild-watch": "npm run esbuild-base -- --sourcemap --watch",
|
||||
"test-compile": "tsc -p ./",
|
||||
"vscode:prepublish": "npm run compile",
|
||||
"compile": "tsc -p ./",
|
||||
"watch": "tsc -watch -p ./",
|
||||
"pretest": "npm run compile && npm run lint",
|
||||
|
|
@ -302,23 +268,22 @@
|
|||
"test": "node ./out/test/runTest.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/vscode": "^1.63.0",
|
||||
"@types/glob": "^7.2.0",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"@types/node": "^14.18.12",
|
||||
"@types/vscode": "^1.73.0",
|
||||
"@types/xmldom": "^0.1.31",
|
||||
"@typescript-eslint/eslint-plugin": "^5.13.0",
|
||||
"@typescript-eslint/parser": "^5.13.0",
|
||||
"@vscode/test-electron": "^2.1.3",
|
||||
"esbuild": "^0.14.25",
|
||||
"eslint": "^8.10.0",
|
||||
"@types/node": "14.x",
|
||||
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
||||
"@typescript-eslint/parser": "^5.9.1",
|
||||
"@types/xmldom": "^0.1.13",
|
||||
"eslint": "^8.6.0",
|
||||
"glob": "^7.2.0",
|
||||
"mocha": "^9.2.1",
|
||||
"typescript": "^4.7.3"
|
||||
"mocha": "^9.1.3",
|
||||
"typescript": "^4.5.4",
|
||||
"@vscode/test-electron": "^2.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@quodatum/xqlint": "^0.2.0",
|
||||
"@xmldom/xmldom": "^0.8.1",
|
||||
"xpath": "0.0.32"
|
||||
"xmldom": "^0.1.27",
|
||||
"xpath": "0.0.27",
|
||||
"xqlint": "^0.4.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 2.8 KiB |
BIN
resources/xml.png
Normal file
BIN
resources/xml.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
|
|
@ -1,13 +0,0 @@
|
|||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
const XQLint =require("@quodatum/xqlint").XQLint;
|
||||
const CodeFormatter=require( "@quodatum/xqlint").CodeFormatter;
|
||||
console.log("....");
|
||||
const xquery="2 +4 ";
|
||||
const linter = new XQLint(xquery, { "styleCheck": false }) ;
|
||||
|
||||
//if(linter.hasSyntaxError()+linter.hasSyntaxError()) throw new Error("XQuery syntax error")
|
||||
const ast=linter.getAST()
|
||||
const formatter = new CodeFormatter(ast);
|
||||
const formatted = formatter.format().trim();
|
||||
console.log(formatted);
|
||||
120
snippets.jsonc
120
snippets.jsonc
|
|
@ -1,120 +0,0 @@
|
|||
{
|
||||
|
||||
"for": {
|
||||
"prefix": "for",
|
||||
"body": "for $${1:item} in ${2:expr}"
|
||||
},
|
||||
"return": {
|
||||
"prefix": "ret",
|
||||
"body": "return ${1:expr}"
|
||||
},
|
||||
"import": {
|
||||
"prefix": "import",
|
||||
"body": "import module namespace ${1:ns} = '${2:http://www.example.com/}';",
|
||||
"description": "Import module"
|
||||
},
|
||||
"module": {
|
||||
"prefix": "module",
|
||||
"body": "module namespace ${1:ns} = '${2:http://www.example.com}';"
|
||||
},
|
||||
"every": {
|
||||
"prefix": "every",
|
||||
"body": "every $${1:varname} in ${2:expr} satisfies ${3:expr}"
|
||||
},
|
||||
"some": {
|
||||
"prefix": "some",
|
||||
"body": "some $${1:varname} in ${2:expr} satisfies ${3:expr}"
|
||||
},
|
||||
"function": {
|
||||
"prefix": "df",
|
||||
"body": [
|
||||
"(:~ $${2:name} :)",
|
||||
"declare function ${1:ns}:${2:name}(){",
|
||||
"${3:expr}",
|
||||
"};"
|
||||
],
|
||||
"description": "declare a function"
|
||||
},
|
||||
"declare variable": {
|
||||
"prefix": "dv",
|
||||
"body": [
|
||||
"(:~ $${1:varname} :)",
|
||||
"declare variable $${1:varname} := ${2:expr};",
|
||||
""
|
||||
],
|
||||
"description": "declare variable"
|
||||
},
|
||||
"switch": {
|
||||
"prefix": "sw",
|
||||
"body": [
|
||||
"switch(${1:foo})",
|
||||
"case ${2:foo} return ${3:true}",
|
||||
"default return ${4:false}"
|
||||
],
|
||||
"description": "switch statement"
|
||||
},
|
||||
"typeswitch": {
|
||||
"prefix": "type",
|
||||
"body": [
|
||||
"typeswitch(${1:foo})",
|
||||
"case ${2:foo} return ${3:true}",
|
||||
"default return ${4:false}"
|
||||
],
|
||||
"description": "typeswitch statement"
|
||||
},
|
||||
"try": {
|
||||
"prefix": "try",
|
||||
"body": [
|
||||
"try { ${1:expr} } ",
|
||||
"catch ${2:*} { ${3:expr} }"
|
||||
],
|
||||
"description": "switch statement"
|
||||
},
|
||||
"tumbling": {
|
||||
"prefix": "tumbling",
|
||||
"body": [
|
||||
"for tumbling window $${1:varname} in ${2:expr}",
|
||||
"start at $${3:start} when ${4:expr}",
|
||||
"end at $${5:end} when ${6:expr}",
|
||||
"return ${7:expr}"
|
||||
],
|
||||
"description": "tumbling window"
|
||||
},
|
||||
"sliding": {
|
||||
"prefix": "sliding",
|
||||
"body": [
|
||||
"for sliding window $${1:varname} in ${2:expr}",
|
||||
"start at $${3:start} when ${4:expr}",
|
||||
"end at $${5:end} when ${6:expr}",
|
||||
"return ${7:expr}"
|
||||
],
|
||||
"description": "sliding window"
|
||||
}
|
||||
}
|
||||
//snippet if
|
||||
// if(${1:true}) then ${2:expr} else ${3:true}
|
||||
|
||||
// default return ${4:false}
|
||||
|
||||
|
||||
//snippet let
|
||||
// let $${1:varname} := ${2:expr}
|
||||
//snippet group
|
||||
// group by $${1:varname} := ${2:expr}
|
||||
//snippet order
|
||||
// order by ${1:expr} ${2:descending}
|
||||
//snippet stable
|
||||
// stable order by ${1:expr}
|
||||
//snippet count
|
||||
// count $${1:varname}
|
||||
//snippet ordered
|
||||
// ordered { ${1:expr} }
|
||||
//snippet unordered
|
||||
// unordered { ${1:expr} }
|
||||
//snippet treat
|
||||
// treat as ${1:expr}
|
||||
//snippet castable
|
||||
// castable as ${1:atomicType}
|
||||
//snippet cast
|
||||
// cast as ${1:atomicType}
|
||||
|
||||
46
src/@quodatum/xqlint.d.ts
vendored
46
src/@quodatum/xqlint.d.ts
vendored
|
|
@ -1,46 +0,0 @@
|
|||
|
||||
declare module '@quodatum/xqlint'{
|
||||
import { Position } from "vscode";
|
||||
export class XQLint{
|
||||
constructor(source :string, opts? :object);
|
||||
public getCompletions(pos :object): [object];
|
||||
public getXQDoc() :XQDoc;
|
||||
public getAST(pos? :Position) :any;
|
||||
public getSctx(pos? :Position) :any;
|
||||
public getErrors() :[Marker];
|
||||
public getWarnings() :[Marker];
|
||||
}
|
||||
export class Marker{
|
||||
pos: Position;
|
||||
type: string;
|
||||
level: string;
|
||||
message: string;
|
||||
}
|
||||
export class XQDoc{
|
||||
moduleNamespace: string;
|
||||
description: string;
|
||||
variables: [VarDecl];
|
||||
functions: [FunDecl];
|
||||
}
|
||||
export interface VarDecl {
|
||||
name: string;
|
||||
type: string;
|
||||
occurrence?: string;
|
||||
description: string;
|
||||
pos: any;
|
||||
}
|
||||
|
||||
export interface FunDecl {
|
||||
name: string;
|
||||
arity: number;
|
||||
params: string[]; // name
|
||||
description: string;
|
||||
pos: boolean;
|
||||
}
|
||||
|
||||
export function XQueryLexer() :any;
|
||||
export function createStaticContext(processor :string) :any;
|
||||
export function CodeFormatter(ast :object) :any;
|
||||
export function CodeFormatter(ast :object, newLinesEnabled :boolean, DEBUG :any) :any;
|
||||
|
||||
}
|
||||
|
|
@ -1,26 +1,26 @@
|
|||
import { workspace, Uri } from "vscode";
|
||||
|
||||
const ExtensionTopLevelSection = "basexTools";
|
||||
const ExtensionTopLevelSection = "xmlTools";
|
||||
|
||||
export class Configuration {
|
||||
static get enableXmlTreeView(): boolean {
|
||||
return this._getForWindow<boolean>("xmlTree.enableTreeView");
|
||||
return this._getForWindow<boolean>("enableXmlTreeView");
|
||||
}
|
||||
|
||||
static get enableXmlTreeViewMetadata(): boolean {
|
||||
return this._getForWindow<boolean>("xmlTree.enableViewMetadata");
|
||||
return this._getForWindow<boolean>("enableXmlTreeViewMetadata");
|
||||
}
|
||||
|
||||
static get enableXmlTreeViewCursorSync(): boolean {
|
||||
return this._getForWindow<boolean>("xmlTree.enableViewCursorSync");
|
||||
return this._getForWindow<boolean>("enableXmlTreeViewCursorSync");
|
||||
}
|
||||
|
||||
static get ignoreDefaultNamespace(): boolean {
|
||||
return this._getForWindow<boolean>("xpath.ignoreDefaultNamespace");
|
||||
return this._getForWindow<boolean>("ignoreDefaultNamespace");
|
||||
}
|
||||
|
||||
static get persistXPathQuery(): boolean {
|
||||
return this._getForWindow<boolean>("xpath.persistXPathQuery");
|
||||
return this._getForWindow<boolean>("persistXPathQuery");
|
||||
}
|
||||
|
||||
static get xmlFormatterImplementation(): string {
|
||||
|
|
@ -28,19 +28,19 @@ export class Configuration {
|
|||
}
|
||||
|
||||
static get xqueryExecutionArguments(): string[] {
|
||||
return this._getForWindow<string[]>("xquery.executionArguments");
|
||||
return this._getForWindow<string[]>("xqueryExecutionArguments");
|
||||
}
|
||||
|
||||
static get xqueryExecutionEngine(): string {
|
||||
return this._getForWindow<string>("xquery.executionEngine");
|
||||
return this._getForWindow<string>("xqueryExecutionEngine");
|
||||
}
|
||||
|
||||
static get xqueryExecutionInputLimit(): number {
|
||||
return this._getForWindow<number>("xquery.executionInputLimit");
|
||||
return this._getForWindow<number>("xqueryExecutionInputLimit");
|
||||
}
|
||||
|
||||
static get xqueryExecutionInputSearchPattern(): string {
|
||||
return this._getForWindow<string>("xquery.executionInputSearchPattern");
|
||||
return this._getForWindow<string>("xqueryExecutionInputSearchPattern");
|
||||
}
|
||||
|
||||
static enforcePrettySelfClosingTagOnFormat(resource: Uri): boolean {
|
||||
|
|
|
|||
|
|
@ -3,4 +3,3 @@ export * from "./create-document-selector";
|
|||
export * from "./extension-state";
|
||||
export * from "./native-commands";
|
||||
export * from "./xml-traverser";
|
||||
export * from "./logger";
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
// debug messages
|
||||
import { OutputChannel, window } from "vscode";
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const ver = require("@quodatum/xqlint").version;
|
||||
|
||||
const _channel:OutputChannel = window.createOutputChannel("BaseX");
|
||||
|
||||
function logdate(){
|
||||
return (new Date()).toISOString().slice(0, 19).replace(/-/g, "/").replace("T", " ");
|
||||
}
|
||||
const replacerFunc = () => {
|
||||
const visited = new WeakSet();
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (key :any, value :any) => {
|
||||
if (typeof value === "object" && value !== null) {
|
||||
if (visited.has(value)) {
|
||||
return;
|
||||
}
|
||||
visited.add(value);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
};
|
||||
|
||||
export function dump(obj :object) {
|
||||
return JSON.stringify(obj,replacerFunc(),1)
|
||||
}
|
||||
|
||||
export class channel {
|
||||
static log(msg: string) :void{
|
||||
_channel.appendLine("["+logdate()+"] "+msg)
|
||||
}
|
||||
static appendLine(msg: string) :void{
|
||||
_channel.appendLine(msg)
|
||||
}
|
||||
static dir(obj: object) :void{
|
||||
_channel.appendLine(dump(obj))
|
||||
}
|
||||
static show() :void{
|
||||
_channel.show
|
||||
}
|
||||
}
|
||||
channel.log("started, XQLint version: "+ver);
|
||||
_channel.show
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { CompletionItem, CompletionItemKind, CompletionItemProvider, Position, TextDocument } from "vscode";
|
||||
import { XQLint} from "@quodatum/xqlint";
|
||||
|
||||
const XQLint = require("xqlint").XQLint;
|
||||
|
||||
export class XQueryCompletionItemProvider implements CompletionItemProvider {
|
||||
|
||||
|
|
@ -24,9 +24,7 @@ export class XQueryCompletionItemProvider implements CompletionItemProvider {
|
|||
case "function":
|
||||
completionItem.kind = CompletionItemKind.Function;
|
||||
|
||||
// eslint-disable-next-line no-case-declarations
|
||||
const funcStart = (xqLintCompletionItem.value.indexOf(":") + 1);
|
||||
// eslint-disable-next-line no-case-declarations
|
||||
const funcEnd = xqLintCompletionItem.value.indexOf("(");
|
||||
|
||||
completionItem.insertText = xqLintCompletionItem.value.substring(funcStart, funcEnd);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
export namespace commands {
|
||||
export const evaluateXPath = "basexTools.evaluateXPath";
|
||||
export const executeXQuery = "basexTools.executeXQuery";
|
||||
export const formatAsXml = "basexTools.formatAsXml";
|
||||
export const xmlToText = "basexTools.xmlToText";
|
||||
export const textToXml = "basexTools.textToXml";
|
||||
export const getCurrentXPath = "basexTools.getCurrentXPath";
|
||||
export const minifyXml = "basexTools.minifyXml";
|
||||
export const xqLintReport = "basexTools.xqLintReport";
|
||||
export const evaluateXPath = "xmlTools.evaluateXPath";
|
||||
export const executeXQuery = "xmlTools.executeXQuery";
|
||||
export const formatAsXml = "xmlTools.formatAsXml";
|
||||
export const xmlToText = "xmlTools.xmlToText";
|
||||
export const textToXml = "xmlTools.textToXml";
|
||||
export const getCurrentXPath = "xmlTools.getCurrentXPath";
|
||||
export const minifyXml = "xmlTools.minifyXml";
|
||||
}
|
||||
|
||||
export namespace contextKeys {
|
||||
|
|
|
|||
|
|
@ -1,27 +1,22 @@
|
|||
import {
|
||||
commands, languages, window, ExtensionContext,
|
||||
commands, languages, window, workspace, ExtensionContext, Memento,
|
||||
TextEditor, TextEditorSelectionChangeEvent, TextEditorSelectionChangeKind, DiagnosticCollection
|
||||
} from "vscode";
|
||||
import { channel } from "./common/logger";
|
||||
|
||||
import { createDocumentSelector, ExtensionState, Configuration } from "./common";
|
||||
import { XQueryCompletionItemProvider } from "./completion";
|
||||
import { XmlFormatterFactory, XmlFormattingEditProvider } from "./formatting";
|
||||
import { formatAsXml, minifyXml, xmlToText, textToXml } from "./formatting/commands";
|
||||
import { XQueryLinter,xqLintReport } from "./linting";
|
||||
import { XQueryLinter } from "./linting";
|
||||
import { XmlTreeDataProvider } from "./tree-view";
|
||||
import { evaluateXPath, getCurrentXPath } from "./xpath/commands";
|
||||
import { executeXQuery } from "./xquery-execution/commands";
|
||||
|
||||
import * as constants from "./constants";
|
||||
import { XQueryFormatter } from "./formatting/xquery-formatting-provider";
|
||||
import { Symbols } from './symbols/symbols';
|
||||
import { XQueryHoverProvider } from './hover/hover';
|
||||
|
||||
let diagnosticCollectionXQuery: DiagnosticCollection;
|
||||
|
||||
export function activate(context: ExtensionContext) {
|
||||
channel.log("Extension activate");
|
||||
ExtensionState.configure(context);
|
||||
|
||||
const xmlXsdDocSelector = [...createDocumentSelector(constants.languageIds.xml), ...createDocumentSelector(constants.languageIds.xsd)];
|
||||
|
|
@ -34,30 +29,16 @@ export function activate(context: ExtensionContext) {
|
|||
|
||||
/* Formatting Features */
|
||||
const xmlFormattingEditProvider = new XmlFormattingEditProvider(XmlFormatterFactory.getXmlFormatter());
|
||||
const xqueryFormattingEditProvider = new XQueryFormatter();
|
||||
|
||||
context.subscriptions.push(
|
||||
commands.registerTextEditorCommand(constants.commands.formatAsXml, formatAsXml),
|
||||
commands.registerTextEditorCommand(constants.commands.xmlToText, xmlToText),
|
||||
commands.registerTextEditorCommand(constants.commands.textToXml, textToXml),
|
||||
commands.registerTextEditorCommand(constants.commands.minifyXml, minifyXml),
|
||||
commands.registerTextEditorCommand(constants.commands.xqLintReport, xqLintReport),
|
||||
|
||||
languages.registerDocumentFormattingEditProvider(xmlXsdDocSelector, xmlFormattingEditProvider),
|
||||
languages.registerDocumentRangeFormattingEditProvider(xmlXsdDocSelector, xmlFormattingEditProvider),
|
||||
|
||||
languages.registerDocumentFormattingEditProvider(xqueryDocSelector, xqueryFormattingEditProvider),
|
||||
languages.registerDocumentRangeFormattingEditProvider(xqueryDocSelector, xqueryFormattingEditProvider)
|
||||
languages.registerDocumentRangeFormattingEditProvider(xmlXsdDocSelector, xmlFormattingEditProvider)
|
||||
);
|
||||
|
||||
|
||||
|
||||
// symbols
|
||||
const symbols = new Symbols();
|
||||
context.subscriptions.push(languages.registerDocumentSymbolProvider(constants.languageIds.xquery, symbols));
|
||||
// hover
|
||||
const hover = new XQueryHoverProvider();
|
||||
context.subscriptions.push(languages.registerHoverProvider(constants.languageIds.xquery, hover));
|
||||
|
||||
/* Linting Features */
|
||||
diagnosticCollectionXQuery = languages.createDiagnosticCollection(constants.diagnosticCollections.xquery);
|
||||
context.subscriptions.push(
|
||||
|
|
@ -94,13 +75,13 @@ export function activate(context: ExtensionContext) {
|
|||
context.subscriptions.push(
|
||||
commands.registerTextEditorCommand(constants.commands.executeXQuery, executeXQuery)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
export function deactivate() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
function _handleContextChange(editor: TextEditor): void {
|
||||
const supportedSchemes = [constants.uriSchemes.file, constants.uriSchemes.untitled];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
import { workspace } from "vscode";
|
||||
import { ProviderResult, Range, TextEdit, TextEditor, TextEditorEdit } from "vscode";
|
||||
|
||||
import { NativeCommands } from "../../common";
|
||||
import * as constants from "../../constants";
|
||||
|
||||
import { XmlFormatterFactory } from "../xml-formatter";
|
||||
import { XmlFormattingEditProvider } from "../xml-formatting-edit-provider";
|
||||
import { XmlFormattingOptionsFactory } from "../xml-formatting-options";
|
||||
|
||||
export function formatAsXml(editor: TextEditor, edit: TextEditorEdit): void {
|
||||
const xmlFormattingEditProvider = new XmlFormattingEditProvider(XmlFormatterFactory.getXmlFormatter());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
export * from "./formatAsXml";
|
||||
export * from "./minifyXml";
|
||||
export * from "./xmlToText";
|
||||
|
||||
|
||||
export * from "./textToXml";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
import { Range, TextEditor, TextEditorEdit } from "vscode";
|
||||
import { workspace } from "vscode";
|
||||
import { ProviderResult, Range, TextEdit, TextEditor, TextEditorEdit } from "vscode";
|
||||
|
||||
import * as constants from "../../constants";
|
||||
|
||||
import { XmlFormatterFactory } from "../xml-formatter";
|
||||
import { XmlFormattingEditProvider } from "../xml-formatting-edit-provider";
|
||||
import { XmlFormattingOptionsFactory } from "../xml-formatting-options";
|
||||
|
||||
export function minifyXml(editor: TextEditor, edit: TextEditorEdit): void {
|
||||
|
|
|
|||
33
src/formatting/commands/textToXml.ts
Normal file
33
src/formatting/commands/textToXml.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { workspace } from "vscode";
|
||||
import { ProviderResult, Range, TextEdit, TextEditor, Selection } from "vscode";
|
||||
|
||||
import { NativeCommands } from "../../common";
|
||||
import * as constants from "../../constants";
|
||||
|
||||
import { XmlFormatterFactory } from "../xml-formatter";
|
||||
import { XmlFormattingEditProvider } from "../xml-formatting-edit-provider";
|
||||
import { XmlFormattingOptionsFactory } from "../xml-formatting-options";
|
||||
|
||||
export function textToXml(textEditor: TextEditor): void {
|
||||
textEditor.edit(textEdit => {
|
||||
const selections = textEditor.selections;
|
||||
selections.forEach(selection => {
|
||||
if (selection.isEmpty) {
|
||||
selection = new Selection(
|
||||
textEditor.document.positionAt(0),
|
||||
textEditor.document.positionAt(textEditor.document.getText().length)
|
||||
);
|
||||
}
|
||||
const txt = textEditor.document.getText(new Range(selection.start, selection.end));
|
||||
const transformed = txt
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/&/g, "&")
|
||||
// tslint:disable-next-line
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, "'");
|
||||
|
||||
textEdit.replace(selection, transformed);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -1,7 +1,12 @@
|
|||
import { workspace } from "vscode";
|
||||
import { ProviderResult, Range, TextEdit, TextEditor, Selection } from "vscode";
|
||||
|
||||
import { Range, TextEditor, Selection } from "vscode";
|
||||
|
||||
import { NativeCommands } from "../../common";
|
||||
import * as constants from "../../constants";
|
||||
|
||||
import { XmlFormatterFactory } from "../xml-formatter";
|
||||
import { XmlFormattingEditProvider } from "../xml-formatting-edit-provider";
|
||||
import { XmlFormattingOptionsFactory } from "../xml-formatting-options";
|
||||
|
||||
export function xmlToText(textEditor: TextEditor): void {
|
||||
textEditor.edit(textEdit => {
|
||||
|
|
@ -15,9 +20,9 @@ export function xmlToText(textEditor: TextEditor): void {
|
|||
}
|
||||
const txt = textEditor.document.getText(new Range(selection.start, selection.end));
|
||||
const transformed = txt
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/&/g, "&")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
|
||||
|
|
@ -25,27 +30,3 @@ export function xmlToText(textEditor: TextEditor): void {
|
|||
});
|
||||
});
|
||||
}
|
||||
export function textToXml(textEditor: TextEditor): void {
|
||||
textEditor.edit(textEdit => {
|
||||
const selections = textEditor.selections;
|
||||
selections.forEach(selection => {
|
||||
if (selection.isEmpty) {
|
||||
selection = new Selection(
|
||||
textEditor.document.positionAt(0),
|
||||
textEditor.document.positionAt(textEditor.document.getText().length)
|
||||
);
|
||||
}
|
||||
const txt = textEditor.document.getText(new Range(selection.start, selection.end));
|
||||
const transformed = txt
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/&/g, "&")
|
||||
// tslint:disable-next-line
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, "'");
|
||||
|
||||
textEdit.replace(selection, transformed);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ export class ClassicXmlFormatter implements XmlFormatter {
|
|||
|
||||
if (options.splitXmlnsOnFormat) {
|
||||
xml = xml
|
||||
.replace(/xmlns:/g, "~::~xmlns:")
|
||||
.replace(/xmlns=/g, "~::~xmlns=");
|
||||
.replace(/xmlns\:/g, "~::~xmlns:")
|
||||
.replace(/xmlns\=/g, "~::~xmlns=");
|
||||
}
|
||||
|
||||
const parts: string[] = xml.split("~::~");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
export * from "./xml-formatter";
|
||||
export * from "./xml-formatting-edit-provider";
|
||||
export * from "./xml-formatting-options";
|
||||
export * from "./xquery-formatting-provider";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { window, workspace } from "vscode";
|
||||
|
||||
|
||||
import { Configuration } from "../common";
|
||||
import { Configuration, ExtensionState } from "../common";
|
||||
import * as constants from "../constants";
|
||||
import { ClassicXmlFormatter } from "./formatters/classic-xml-formatter";
|
||||
import { V2XmlFormatter } from "./formatters/v2-xml-formatter";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { EndOfLine, FormattingOptions, TextDocument } from "vscode";
|
||||
|
||||
import { Configuration } from "../common";
|
||||
import * as constants from "../constants";
|
||||
|
||||
export interface XmlFormattingOptions {
|
||||
editorOptions: FormattingOptions;
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
// format xquery
|
||||
import { XQLint, CodeFormatter } from "@quodatum/xqlint";
|
||||
import { CancellationToken, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider,
|
||||
FormattingOptions, ProviderResult,Range,
|
||||
TextDocument, TextEdit} from "vscode";
|
||||
|
||||
import { channel } from "../common/logger";
|
||||
|
||||
function format(xquery: string,document: TextDocument): string {
|
||||
channel.log("XQueryFormatter" + document.uri);
|
||||
const linter = new (XQLint as any)(xquery, { "styleCheck": false });
|
||||
channel.appendLine(" linter hasSyntaxError: " + linter.hasSyntaxError());
|
||||
//if(linter.hasSyntaxError()+linter.hasSyntaxError()) throw new Error("XQuery syntax error")
|
||||
const ast = linter.getAST()
|
||||
const formatter = new (CodeFormatter as any)(ast);
|
||||
const formatted = formatter.format().trim();
|
||||
channel.log("XQueryFormatter done");
|
||||
return formatted;
|
||||
}
|
||||
export class XQueryFormatter implements DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider{
|
||||
provideDocumentFormattingEdits(document: TextDocument, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]> {
|
||||
const lastLine = document.lineAt(document.lineCount - 1);
|
||||
const documentRange = new Range(document.positionAt(0), lastLine.range.end);
|
||||
return this.provideDocumentRangeFormattingEdits(document, documentRange, options, token);
|
||||
}
|
||||
|
||||
provideDocumentRangeFormattingEdits(document: TextDocument, range: Range, _options: FormattingOptions, _token: CancellationToken): ProviderResult<TextEdit[]> {
|
||||
const selected = document.getText(range);
|
||||
const result = format(selected, document);
|
||||
return [TextEdit.replace(range, result)];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
// xquery hover
|
||||
|
||||
import { CancellationToken, Hover, HoverProvider, Position, TextDocument } from "vscode";
|
||||
import { XQLint} from "@quodatum/xqlint";
|
||||
|
||||
export class XQueryHoverProvider implements HoverProvider {
|
||||
public provideHover(
|
||||
document: TextDocument,
|
||||
position: Position,
|
||||
token: CancellationToken
|
||||
): Hover | null {
|
||||
const linter = new XQLint(document.getText());
|
||||
|
||||
const node=linter.getAST(position);
|
||||
//const sctx=linter.getCompletions(position);
|
||||
//channel.log("Hover: " + node.name);
|
||||
//const dx=dump(node);
|
||||
//channel.appendLine(dx);
|
||||
const range = document.getWordRangeAtPosition(position);
|
||||
|
||||
const word = document.getText(range);
|
||||
return new Hover(`XQuery Hover info: ${word} at ${position.line}: ${position.character}
|
||||
value: ${ node.value }, name: ${ node.name }
|
||||
`);
|
||||
|
||||
return null; //if there is no information to show
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +1 @@
|
|||
export * from "./xquery-linter";
|
||||
export * from "./report";
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
|
||||
import { TextEditor } from "vscode";
|
||||
import { XQLint} from "@quodatum/xqlint";
|
||||
import { channel,dump } from "../common/logger";
|
||||
|
||||
|
||||
export function xqLintReport(textEditor: TextEditor): void {
|
||||
const linter = new XQLint(textEditor.document.getText());
|
||||
textEditor.edit(textEdit => {
|
||||
const selections = textEditor.selections;
|
||||
selections.forEach(selection => {
|
||||
const pos=selection.start.translate(1,1); //@TODO
|
||||
const node=linter.getAST(pos);
|
||||
const sctx=linter.getCompletions(pos);
|
||||
const dx=dump(node);
|
||||
channel.appendLine(dx);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { Diagnostic, DiagnosticSeverity, Position, Range } from "vscode";
|
||||
import { XQLint} from "@quodatum/xqlint";
|
||||
|
||||
const XQLint = require("xqlint").XQLint;
|
||||
|
||||
export class XQueryLinter {
|
||||
static SEVERITY_WARNING = 1;
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import { VarDecl, FunDecl, XQLint } from '@quodatum/xqlint';
|
||||
import {SymbolKind, DocumentSymbol, DocumentSymbolProvider,
|
||||
Range, Position, TextDocument,CancellationToken} from 'vscode';
|
||||
import { channel } from "../common/logger";
|
||||
//
|
||||
// This class handles XQuery Symbols
|
||||
//
|
||||
function makeSymbol(name: string, description: string, icon: SymbolKind, pos: any) {
|
||||
const spos = new Position(pos.sl, pos.sc);
|
||||
const epos = new Position(pos.el, pos.ec);
|
||||
const fullrange = new Range(spos, epos);
|
||||
const selrange = new Range(spos, spos);
|
||||
return new DocumentSymbol(name, description, icon, fullrange, selrange);
|
||||
}
|
||||
|
||||
|
||||
export class Symbols implements DocumentSymbolProvider {
|
||||
provideDocumentSymbols = async (
|
||||
document: TextDocument,
|
||||
token: CancellationToken
|
||||
): Promise<DocumentSymbol[]> => {
|
||||
|
||||
channel.log("Symbols: " + document.uri);
|
||||
const symbols: DocumentSymbol[] = [];
|
||||
const text = document.getText();
|
||||
const linter = new XQLint(text, { "styleCheck": false });
|
||||
|
||||
const xqdoc = linter.getXQDoc();
|
||||
channel.log("got xqdoc");
|
||||
|
||||
// type: type,
|
||||
// pos: pos,
|
||||
// qname: qname,
|
||||
// annotations: {}
|
||||
xqdoc.variables.forEach(function (v: VarDecl): void {
|
||||
const name = "$" + v.name;
|
||||
const description="about this variable, some doc here";
|
||||
channel.log(name + v);
|
||||
const info = makeSymbol(name, description, SymbolKind.Variable, v.pos);
|
||||
symbols.push(info);
|
||||
});
|
||||
|
||||
xqdoc.functions.forEach(function (f: FunDecl) {
|
||||
const name = f.name + "#" + f.params.length;
|
||||
const description="about this function, some doc here";
|
||||
channel.log(name + f);
|
||||
const info = makeSymbol(name, description, SymbolKind.Function, f.pos);
|
||||
// info.children=[];
|
||||
// f.params.forEach(function(paramName: string){
|
||||
// info.children.push(makeSymbol(paramName, "", SymbolKind.Variable, f.pos))
|
||||
// });
|
||||
symbols.push(info);
|
||||
});
|
||||
|
||||
channel.log("Symbols done " + document.uri);
|
||||
return symbols;
|
||||
};
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ import {
|
|||
} from "vscode";
|
||||
|
||||
import * as path from "path";
|
||||
import { DOMParser } from "@xmldom/xmldom";
|
||||
import { DOMParser } from "xmldom";
|
||||
|
||||
import { Configuration, NativeCommands, XmlTraverser } from "../common";
|
||||
import * as constants from "../constants";
|
||||
|
|
@ -15,7 +15,6 @@ export class XmlTreeDataProvider implements TreeDataProvider<any> {
|
|||
private _xmlDocument: Document;
|
||||
private _xmlTraverser: XmlTraverser;
|
||||
|
||||
|
||||
constructor(private _context: ExtensionContext) {
|
||||
window.onDidChangeActiveTextEditor(() => {
|
||||
this._refreshTree();
|
||||
|
|
@ -135,7 +134,7 @@ export class XmlTreeDataProvider implements TreeDataProvider<any> {
|
|||
NativeCommands.setContext(constants.contextKeys.xmlTreeViewEnabled, false);
|
||||
|
||||
this._xmlDocument = null;
|
||||
this._onDidChangeTreeData.fire(null);
|
||||
this._onDidChangeTreeData.fire(0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +162,7 @@ export class XmlTreeDataProvider implements TreeDataProvider<any> {
|
|||
this._xmlTraverser.xmlDocument = this._xmlDocument;
|
||||
}
|
||||
|
||||
this._onDidChangeTreeData.fire(this.activeEditor.document.uri);
|
||||
this._onDidChangeTreeData.fire(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { window } from "vscode";
|
||||
import { TextEditor, TextEditorEdit } from "vscode";
|
||||
import { DOMParser } from "@xmldom/xmldom";
|
||||
import { DOMParser } from "xmldom";
|
||||
|
||||
import { XPathBuilder } from "../xpath-builder";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import * as xpath from "xpath";
|
||||
import { SelectedValue, XPathSelect } from "xpath";
|
||||
import { DOMParser } from "@xmldom/xmldom";
|
||||
import { DOMParser } from "xmldom";
|
||||
|
||||
export class EvaluatorResult {
|
||||
type: EvaluatorResultType;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import child_process = require("child_process");
|
||||
const child_process = require("child_process");
|
||||
|
||||
export class ChildProcess {
|
||||
static async spawn(executable: string, args: string[]): Promise<void> {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue