[mod] ver:0.0.28 #4
					 21 changed files with 1129 additions and 1253 deletions
				
			
		
							
								
								
									
										20
									
								
								.eslintrc.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								.eslintrc.json
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,20 @@
 | 
			
		|||
{
 | 
			
		||||
    "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": {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -2,3 +2,4 @@ out
 | 
			
		|||
node_modules
 | 
			
		||||
.vscode-test/
 | 
			
		||||
/*.vsix
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										3
									
								
								.vscode/launch.json
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.vscode/launch.json
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -2,13 +2,14 @@
 | 
			
		|||
{
 | 
			
		||||
    "version": "0.1.0",
 | 
			
		||||
    "configurations": [
 | 
			
		||||
    
 | 
			
		||||
        {
 | 
			
		||||
            "name": "Extension",
 | 
			
		||||
            "type": "extensionHost",
 | 
			
		||||
            "request": "launch",
 | 
			
		||||
            "runtimeExecutable": "${execPath}",
 | 
			
		||||
            "args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
 | 
			
		||||
            "stopOnEntry": false,
 | 
			
		||||
            "stopOnEntry": true,
 | 
			
		||||
            "sourceMaps": true,
 | 
			
		||||
            "outFiles": [ "${workspaceRoot}/out/**/*.js" ],
 | 
			
		||||
            "preLaunchTask": "npm: watch"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,7 @@
 | 
			
		|||
node_modules
 | 
			
		||||
out/
 | 
			
		||||
src/
 | 
			
		||||
tsconfig.json
 | 
			
		||||
vsc-extension-quickstart.md
 | 
			
		||||
.github
 | 
			
		||||
.gitignore
 | 
			
		||||
.vscode
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +1,4 @@
 | 
			
		|||
Detailed release notes are available [here](https://github.com/DotJoshJohnson/vscode-xml/releases).
 | 
			
		||||
 | 
			
		||||
0.0.27 doc format
 | 
			
		||||
0.0.4 [add] treat schematron (.sch) as XML
 | 
			
		||||
							
								
								
									
										23
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								README.md
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,6 +1,9 @@
 | 
			
		|||
# BaseX Tools for Visual Studio Code
 | 
			
		||||
This project was originally a fork of https://github.com/DotJoshJohnson/vscode-xml
 | 
			
		||||
 | 
			
		||||
This extension adds features to support BaseX development on VSCode.
 | 
			
		||||
* XQuery 3.1, XQuery update, Full text syntax support 
 | 
			
		||||
* XQuery code format
 | 
			
		||||
 | 
			
		||||
## Features
 | 
			
		||||
* [XML Formatting](https://github.com/DotJoshJohnson/vscode-xml/wiki/xml-formatting)
 | 
			
		||||
| 
						 | 
				
			
			@ -11,21 +14,7 @@ This project was originally a fork of https://github.com/DotJoshJohnson/vscode-x
 | 
			
		|||
* [XQuery Code Completion](https://github.com/DotJoshJohnson/vscode-xml/wiki/xquery-code-completion)
 | 
			
		||||
 | 
			
		||||
## Requirements
 | 
			
		||||
* VS Code `1.22.2` or higher
 | 
			
		||||
 | 
			
		||||
## Extension Settings
 | 
			
		||||
* **`basexTools.enableXmlTreeView`:** Enables the XML Tree View for XML documents.
 | 
			
		||||
* **`basexTools.enableXmlTreeViewMetadata`:** Enables attribute and child element counts in the XML Document view.
 | 
			
		||||
* **`basexTools.enableXmlTreeViewCursorSync`:** Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.
 | 
			
		||||
* **`basexTools.enforcePrettySelfClosingTagOnFormat`:** Ensures a space is added before the forward slash at the end of a self-closing tag.
 | 
			
		||||
* **`basexTools.ignoreDefaultNamespace`:** Ignore default xmlns attributes when evaluating XPath.
 | 
			
		||||
* **`basexTools.persistXPathQuery`:** Remember the last XPath query used.
 | 
			
		||||
* **`basexTools.removeCommentsOnMinify`:** Remove XML comments during minification.
 | 
			
		||||
* **`basexTools.splitAttributesOnFormat`:** Put each attribute on a new line when formatting XML. Overrides `basexTools.splitXmlnsOnFormat` if set to `true`. (V2 Formatter Only)
 | 
			
		||||
* **`basexTools.splitXmlnsOnFormat`:** Put each xmlns attribute on a new line when formatting XML.
 | 
			
		||||
* **`basexTools.xmlFormatterImplementation`:** Supported XML Formatters: `classic`, `v2`.
 | 
			
		||||
* **`basexTools.xqueryExecutionArguments`:** Arguments to be passed to the XQuery execution engine.
 | 
			
		||||
* **`basexTools.xqueryExecutionEngine`:** The full path to the executable to run when executing XQuery scripts.
 | 
			
		||||
* VS Code `1.63.0` or higher
 | 
			
		||||
 | 
			
		||||
## Release Notes
 | 
			
		||||
Detailed release notes are available [here](https://github.com/DotJoshJohnson/vscode-xml/releases).
 | 
			
		||||
| 
						 | 
				
			
			@ -37,3 +26,7 @@ Run into a bug? Report it [here](https://github.com/DotJoshJohnson/vscode-xml/is
 | 
			
		|||
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
 | 
			
		||||
 | 
			
		||||
## Inspiration
 | 
			
		||||
 | 
			
		||||
This is a fork of [DotJoshJohnson/vscode-xml](https://github.com/DotJoshJohnson/vscode-xml). DotJoshJohnson did the intial work, but I want to go in a different direction.
 | 
			
		||||
							
								
								
									
										57
									
								
								notes.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								notes.md
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,57 @@
 | 
			
		|||
# 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}
 | 
			
		||||
 ```
 | 
			
		||||
							
								
								
									
										1594
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										1594
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										37
									
								
								package.json
									
										
									
									
									
								
							
							
						
						
									
										37
									
								
								package.json
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -2,13 +2,10 @@
 | 
			
		|||
  "name": "vscode-basex",
 | 
			
		||||
  "displayName": "BaseX tools",
 | 
			
		||||
  "description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code",
 | 
			
		||||
    "version": "0.0.6",
 | 
			
		||||
    "preview": false,
 | 
			
		||||
  "version": "0.0.28",
 | 
			
		||||
  "preview": true,
 | 
			
		||||
  "publisher": "quodatum",
 | 
			
		||||
    "author": {
 | 
			
		||||
        "name": "Andy Bunce",
 | 
			
		||||
        "url": "https://github.com/Quodatum"
 | 
			
		||||
    },
 | 
			
		||||
  "author": "Andy Bunce (https://github.com/Quodatum)",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "galleryBanner": {
 | 
			
		||||
    "color": "#FFFFFF",
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +15,7 @@
 | 
			
		|||
  "homepage": "https://github.com/Quodatum/vscode-xml",
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
        "url": "https://github.com/Quodatum/vscode-xml.git"
 | 
			
		||||
    "url": "git+https://github.com/Quodatum/vscode-xml.git"
 | 
			
		||||
  },
 | 
			
		||||
  "bugs": {
 | 
			
		||||
    "url": "https://github.com/Quodatum/vscode-xml/issues"
 | 
			
		||||
| 
						 | 
				
			
			@ -76,7 +73,7 @@
 | 
			
		|||
      }
 | 
			
		||||
    ],
 | 
			
		||||
    "configuration": {
 | 
			
		||||
            "title": "XML Tools Configuration",
 | 
			
		||||
      "title": "BaseX Tools Configuration",
 | 
			
		||||
      "type": "object",
 | 
			
		||||
      "properties": {
 | 
			
		||||
        "basexTools.enableXmlTreeView": {
 | 
			
		||||
| 
						 | 
				
			
			@ -262,7 +259,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "vscode:prepublish": "npm run esbuild-base -- --minify",
 | 
			
		||||
        "esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node",
 | 
			
		||||
    "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 ./",
 | 
			
		||||
| 
						 | 
				
			
			@ -275,21 +272,21 @@
 | 
			
		|||
  "devDependencies": {
 | 
			
		||||
    "@types/glob": "^7.2.0",
 | 
			
		||||
    "@types/mocha": "^9.0.0",
 | 
			
		||||
        "@types/node": "14.x",
 | 
			
		||||
    "@types/node": "^14.18.12",
 | 
			
		||||
    "@types/vscode": "^1.63.0",
 | 
			
		||||
        "@types/xmldom": "^0.1.13",
 | 
			
		||||
        "@typescript-eslint/eslint-plugin": "^5.9.1",
 | 
			
		||||
        "@typescript-eslint/parser": "^5.9.1",
 | 
			
		||||
        "@vscode/test-electron": "^2.0.3",
 | 
			
		||||
        "esbuild": "^0.14.18",
 | 
			
		||||
        "eslint": "^8.6.0",
 | 
			
		||||
    "@types/xmldom": "^0.1.31",
 | 
			
		||||
    "@typescript-eslint/eslint-plugin": "^5.12.0",
 | 
			
		||||
    "@typescript-eslint/parser": "^5.12.0",
 | 
			
		||||
    "@vscode/test-electron": "^2.1.2",
 | 
			
		||||
    "esbuild": "^0.14.23",
 | 
			
		||||
    "eslint": "^8.9.0",
 | 
			
		||||
    "glob": "^7.2.0",
 | 
			
		||||
        "mocha": "^9.1.3",
 | 
			
		||||
    "mocha": "^9.2.1",
 | 
			
		||||
    "typescript": "^4.5.4"
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
        "xmldom": "^0.1.27",
 | 
			
		||||
        "xpath": "0.0.27",
 | 
			
		||||
        "xqlint": "^0.4.1"
 | 
			
		||||
    "@quodatum/xqlint": "^0.0.8",
 | 
			
		||||
    "@xmldom/xmldom": "^0.8.1",
 | 
			
		||||
    "xpath": "0.0.32"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										13
									
								
								scripts/test.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								scripts/test.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
/* 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);
 | 
			
		||||
							
								
								
									
										8
									
								
								src/@quodatum/xqlint.d.ts
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/@quodatum/xqlint.d.ts
									
										
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
declare module '@quodatum/xqlint'{
 | 
			
		||||
    export function  XQLint(source :string, opts :object) :any;
 | 
			
		||||
    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;
 | 
			
		||||
 | 
			
		||||
} 
 | 
			
		||||
| 
						 | 
				
			
			@ -3,3 +3,4 @@ export * from "./create-document-selector";
 | 
			
		|||
export * from "./extension-state";
 | 
			
		||||
export * from "./native-commands";
 | 
			
		||||
export * from "./xml-traverser";
 | 
			
		||||
export * from "./logger";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										23
									
								
								src/common/logger.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/common/logger.ts
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,23 @@
 | 
			
		|||
// debug messages
 | 
			
		||||
import { OutputChannel, window } from "vscode";
 | 
			
		||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
 | 
			
		||||
const XQLint = require("@quodatum/xqlint").XQLint;
 | 
			
		||||
 | 
			
		||||
const _channel:OutputChannel = window.createOutputChannel("BaseX log");
 | 
			
		||||
function logdate(){
 | 
			
		||||
    return (new Date()).toISOString().slice(0, 19).replace(/-/g, "/").replace("T", " ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export class channel {
 | 
			
		||||
    static log(msg: string) :void{
 | 
			
		||||
        _channel.appendLine("["+logdate()+"] "+msg) 
 | 
			
		||||
    }
 | 
			
		||||
    static appendLine(msg: string) :void{
 | 
			
		||||
        _channel.appendLine(msg)
 | 
			
		||||
    }
 | 
			
		||||
    static show() :void{
 | 
			
		||||
        _channel.show
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
channel.log("started, XQLint version: "+XQLint.version);
 | 
			
		||||
_channel.show
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
import { CompletionItem, CompletionItemKind, CompletionItemProvider, Position, TextDocument } from "vscode";
 | 
			
		||||
 | 
			
		||||
const XQLint = require("xqlint").XQLint;
 | 
			
		||||
const XQLint = require("@quodatum/xqlint").XQLint;
 | 
			
		||||
 | 
			
		||||
export class XQueryCompletionItemProvider implements CompletionItemProvider {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,8 @@
 | 
			
		|||
import {
 | 
			
		||||
    commands, languages, window, workspace, ExtensionContext, Memento,
 | 
			
		||||
    TextEditor, TextEditorSelectionChangeEvent, TextEditorSelectionChangeKind, DiagnosticCollection
 | 
			
		||||
    TextEditor, TextEditorSelectionChangeEvent, TextEditorSelectionChangeKind, DiagnosticCollection, TextDocument, TextEdit,Range
 | 
			
		||||
    } from "vscode";
 | 
			
		||||
import { channel } from "./common/logger";
 | 
			
		||||
 | 
			
		||||
import { createDocumentSelector, ExtensionState, Configuration } from "./common";
 | 
			
		||||
import { XQueryCompletionItemProvider } from "./completion";
 | 
			
		||||
| 
						 | 
				
			
			@ -13,10 +14,12 @@ import { evaluateXPath, getCurrentXPath } from "./xpath/commands";
 | 
			
		|||
import { executeXQuery } from "./xquery-execution/commands";
 | 
			
		||||
 | 
			
		||||
import * as constants from "./constants";
 | 
			
		||||
import { XQueryFormatter } from "./formatting/XQueryFormatter";
 | 
			
		||||
 | 
			
		||||
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)];
 | 
			
		||||
| 
						 | 
				
			
			@ -39,6 +42,20 @@ export function activate(context: ExtensionContext) {
 | 
			
		|||
        languages.registerDocumentRangeFormattingEditProvider(xmlXsdDocSelector, xmlFormattingEditProvider)
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // 👍 XQuery formatter implemented using API
 | 
			
		||||
    languages.registerDocumentFormattingEditProvider(constants.languageIds.xquery, {
 | 
			
		||||
        async provideDocumentFormattingEdits(document: TextDocument): Promise<TextEdit[]> {
 | 
			
		||||
            
 | 
			
		||||
            try {
 | 
			
		||||
                const text =  XQueryFormatter.format(document.getText())
 | 
			
		||||
                const entireDocRange = document.validateRange(new Range(0, 0, document.lineCount, 0));
 | 
			
		||||
                return [TextEdit.replace(entireDocRange, text)];
 | 
			
		||||
            } catch (e) {
 | 
			
		||||
                window.showInformationMessage('Format failed -syntax error')
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
  
 | 
			
		||||
    /* Linting Features */
 | 
			
		||||
    diagnosticCollectionXQuery = languages.createDiagnosticCollection(constants.diagnosticCollections.xquery);
 | 
			
		||||
    context.subscriptions.push(
 | 
			
		||||
| 
						 | 
				
			
			@ -75,12 +92,12 @@ 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];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										18
									
								
								src/formatting/XQueryFormatter.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/formatting/XQueryFormatter.ts
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,18 @@
 | 
			
		|||
// format xquery
 | 
			
		||||
import { channel } from "../common/logger";
 | 
			
		||||
import { XQLint, CodeFormatter } from "@quodatum/xqlint";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export class XQueryFormatter {
 | 
			
		||||
    static format(xquery: string): string {
 | 
			
		||||
        channel.log("XQueryFormatter");
 | 
			
		||||
        const linter = new (XQLint as any)(xquery, { "styleCheck": false });
 | 
			
		||||
        channel.appendLine("got linter: " + 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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,12 +1,9 @@
 | 
			
		|||
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,6 +1,6 @@
 | 
			
		|||
import { Diagnostic, DiagnosticSeverity, Position, Range } from "vscode";
 | 
			
		||||
 | 
			
		||||
const XQLint = require("xqlint").XQLint;
 | 
			
		||||
const XQLint = require("@quodatum/xqlint").XQLint;
 | 
			
		||||
 | 
			
		||||
export class XQueryLinter {
 | 
			
		||||
    static SEVERITY_WARNING = 1;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@ import {
 | 
			
		|||
} from "vscode";
 | 
			
		||||
 | 
			
		||||
import * as path from "path";
 | 
			
		||||
import { DOMParser } from "xmldom";
 | 
			
		||||
import { DOMParser } from "@xmldom/xmldom";
 | 
			
		||||
 | 
			
		||||
import { Configuration, NativeCommands, XmlTraverser } from "../common";
 | 
			
		||||
import * as constants from "../constants";
 | 
			
		||||
| 
						 | 
				
			
			@ -15,6 +15,7 @@ export class XmlTreeDataProvider implements TreeDataProvider<any> {
 | 
			
		|||
    private _xmlDocument: Document;
 | 
			
		||||
    private _xmlTraverser: XmlTraverser;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    constructor(private _context: ExtensionContext) {
 | 
			
		||||
        window.onDidChangeActiveTextEditor(() => {
 | 
			
		||||
            this._refreshTree();
 | 
			
		||||
| 
						 | 
				
			
			@ -134,7 +135,7 @@ export class XmlTreeDataProvider implements TreeDataProvider<any> {
 | 
			
		|||
            NativeCommands.setContext(constants.contextKeys.xmlTreeViewEnabled, false);
 | 
			
		||||
 | 
			
		||||
            this._xmlDocument = null;
 | 
			
		||||
            this._onDidChangeTreeData.fire(0);
 | 
			
		||||
            this._onDidChangeTreeData.fire(null);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -162,7 +163,7 @@ export class XmlTreeDataProvider implements TreeDataProvider<any> {
 | 
			
		|||
            this._xmlTraverser.xmlDocument = this._xmlDocument;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        this._onDidChangeTreeData.fire(0);
 | 
			
		||||
        this._onDidChangeTreeData.fire(this.activeEditor.document.uri);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
import { window } from "vscode";
 | 
			
		||||
import { TextEditor, TextEditorEdit } from "vscode";
 | 
			
		||||
import { DOMParser } from "xmldom";
 | 
			
		||||
import { DOMParser } from "@xmldom/xmldom";
 | 
			
		||||
 | 
			
		||||
import { XPathBuilder } from "../xpath-builder";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
import * as xpath from "xpath";
 | 
			
		||||
import { SelectedValue, XPathSelect } from "xpath";
 | 
			
		||||
import { DOMParser } from "xmldom";
 | 
			
		||||
import { DOMParser } from "@xmldom/xmldom";
 | 
			
		||||
 | 
			
		||||
export class EvaluatorResult {
 | 
			
		||||
    type: EvaluatorResultType;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue