vscode-basex #9
					 6 changed files with 164 additions and 158 deletions
				
			
		
							
								
								
									
										217
									
								
								package.json
									
										
									
									
									
								
							
							
						
						
									
										217
									
								
								package.json
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
  "name": "vscode-basex",
 | 
			
		||||
  "displayName": "BaseX tools",
 | 
			
		||||
  "description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code",
 | 
			
		||||
  "version": "0.0.47",
 | 
			
		||||
  "version": "0.0.48",
 | 
			
		||||
  "preview": true,
 | 
			
		||||
  "publisher": "quodatum",
 | 
			
		||||
  "author": "Andy Bunce (https://github.com/Quodatum)",
 | 
			
		||||
| 
						 | 
				
			
			@ -72,107 +72,122 @@
 | 
			
		|||
        "title": "BaseX Tools: Minify XML"
 | 
			
		||||
      }
 | 
			
		||||
    ],
 | 
			
		||||
    "configuration": {
 | 
			
		||||
      "title": "BaseX Tools Configuration",
 | 
			
		||||
      "type": "object",
 | 
			
		||||
      "properties": {
 | 
			
		||||
        "basexTools.xmlTree.enableTreeView": {
 | 
			
		||||
          "type": "boolean",
 | 
			
		||||
          "default": true,
 | 
			
		||||
          "description": "Enables the XML Document view in the explorer for XML documents.",
 | 
			
		||||
          "scope": "window"
 | 
			
		||||
        },
 | 
			
		||||
        "basexTools.xmlTree.enableViewMetadata": {
 | 
			
		||||
          "type": "boolean",
 | 
			
		||||
          "default": true,
 | 
			
		||||
          "description": "Enables attribute and child element counts in the XML Document view.",
 | 
			
		||||
          "scope": "window"
 | 
			
		||||
        },
 | 
			
		||||
        "basexTools.xmlTree.enableViewCursorSync": {
 | 
			
		||||
          "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"
 | 
			
		||||
        },
 | 
			
		||||
        "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.xpath.ignoreDefaultNamespace": {
 | 
			
		||||
          "type": "boolean",
 | 
			
		||||
          "default": true,
 | 
			
		||||
          "description": "Ignore default xmlns attributes when evaluating XPath.",
 | 
			
		||||
          "scope": "window"
 | 
			
		||||
        },
 | 
			
		||||
        "basexTools.xpath.persistXPathQuery": {
 | 
			
		||||
          "type": "boolean",
 | 
			
		||||
          "default": true,
 | 
			
		||||
          "description": "Remember the last XPath query used.",
 | 
			
		||||
          "scope": "window"
 | 
			
		||||
        },
 | 
			
		||||
        "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"
 | 
			
		||||
        },
 | 
			
		||||
        "basexTools.xqueryExecutionArguments": {
 | 
			
		||||
          "type": "array",
 | 
			
		||||
          "default": [
 | 
			
		||||
            "-xquery",
 | 
			
		||||
            "$(script)",
 | 
			
		||||
            "-in",
 | 
			
		||||
            "$(input)",
 | 
			
		||||
            "-out",
 | 
			
		||||
            "$(input).output.xml"
 | 
			
		||||
          ],
 | 
			
		||||
          "description": "Arguments to be passed to the XQuery execution engine.",
 | 
			
		||||
          "scope": "window"
 | 
			
		||||
        },
 | 
			
		||||
        "basexTools.xqueryExecutionEngine": {
 | 
			
		||||
          "type": "string",
 | 
			
		||||
          "default": "",
 | 
			
		||||
          "description": "The full path to the executable to run when executing XQuery scripts.",
 | 
			
		||||
          "scope": "window"
 | 
			
		||||
        },
 | 
			
		||||
        "basexTools.xqueryExecutionInputLimit": {
 | 
			
		||||
          "type": "integer",
 | 
			
		||||
          "default": 100,
 | 
			
		||||
          "description": "The maximum number of input files to enumerate when executing XQuery scripts.",
 | 
			
		||||
          "scope": "window"
 | 
			
		||||
        },
 | 
			
		||||
        "basexTools.xqueryExecutionInputSearchPattern": {
 | 
			
		||||
          "type": "string",
 | 
			
		||||
          "default": "**/*.xml",
 | 
			
		||||
          "description": "The pattern used to search for input XML files when executing XQuery scripts.",
 | 
			
		||||
          "scope": "window"
 | 
			
		||||
    "configuration": [
 | 
			
		||||
      {
 | 
			
		||||
        "id": "xmltree",
 | 
			
		||||
        "title": "XML tree view ",
 | 
			
		||||
        "properties": {
 | 
			
		||||
          "basexTools.xmlTree.enableTreeView": {
 | 
			
		||||
            "type": "boolean",
 | 
			
		||||
            "default": true,
 | 
			
		||||
            "description": "Enables the XML Document view in the explorer for XML documents.",
 | 
			
		||||
            "scope": "window"
 | 
			
		||||
          },
 | 
			
		||||
          "basexTools.xmlTree.enableViewMetadata": {
 | 
			
		||||
            "type": "boolean",
 | 
			
		||||
            "default": true,
 | 
			
		||||
            "description": "Enables attribute and child element counts in the XML Document view.",
 | 
			
		||||
            "scope": "window"
 | 
			
		||||
          },
 | 
			
		||||
          "basexTools.xmlTree.enableViewCursorSync": {
 | 
			
		||||
            "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": {
 | 
			
		||||
            "type": "boolean",
 | 
			
		||||
            "default": true,
 | 
			
		||||
            "description": "Ignore default xmlns attributes when evaluating XPath.",
 | 
			
		||||
            "scope": "window"
 | 
			
		||||
          },
 | 
			
		||||
          "basexTools.xpath.persistXPathQuery": {
 | 
			
		||||
            "type": "boolean",
 | 
			
		||||
            "default": true,
 | 
			
		||||
            "description": "Remember the last XPath query used.",
 | 
			
		||||
            "scope": "window"
 | 
			
		||||
          }
 | 
			
		||||
        } 
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        "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"
 | 
			
		||||
          },
 | 
			
		||||
          "basexTools.xqueryExecutionArguments": {
 | 
			
		||||
            "type": "array",
 | 
			
		||||
            "default": [
 | 
			
		||||
              "-xquery",
 | 
			
		||||
              "$(script)",
 | 
			
		||||
              "-in",
 | 
			
		||||
              "$(input)",
 | 
			
		||||
              "-out",
 | 
			
		||||
              "$(input).output.xml"
 | 
			
		||||
            ],
 | 
			
		||||
            "description": "Arguments to be passed to the XQuery execution engine.",
 | 
			
		||||
            "scope": "window"
 | 
			
		||||
          },
 | 
			
		||||
          "basexTools.xqueryExecutionEngine": {
 | 
			
		||||
            "type": "string",
 | 
			
		||||
            "default": "",
 | 
			
		||||
            "description": "The full path to the executable to run when executing XQuery scripts.",
 | 
			
		||||
            "scope": "window"
 | 
			
		||||
          },
 | 
			
		||||
          "basexTools.xqueryExecutionInputLimit": {
 | 
			
		||||
            "type": "integer",
 | 
			
		||||
            "default": 100,
 | 
			
		||||
            "description": "The maximum number of input files to enumerate when executing XQuery scripts.",
 | 
			
		||||
            "scope": "window"
 | 
			
		||||
          },
 | 
			
		||||
          "basexTools.xqueryExecutionInputSearchPattern": {
 | 
			
		||||
            "type": "string",
 | 
			
		||||
            "default": "**/*.xml",
 | 
			
		||||
            "description": "The pattern used to search for input XML files when executing XQuery scripts.",
 | 
			
		||||
            "scope": "window"
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    ],
 | 
			
		||||
    "grammars": [
 | 
			
		||||
      {
 | 
			
		||||
        "language": "xquery",
 | 
			
		||||
| 
						 | 
				
			
			@ -289,4 +304,4 @@
 | 
			
		|||
    "@xmldom/xmldom": "^0.8.1",
 | 
			
		||||
    "xpath": "0.0.32"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										5
									
								
								src/CHANGELOG.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/CHANGELOG.md
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
# 0.0.48
 | 
			
		||||
* Fix xmlToText #6
 | 
			
		||||
* FIX outline all vars
 | 
			
		||||
 | 
			
		||||
# 0.0.47 
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
export * from "./formatAsXml";
 | 
			
		||||
export * from "./minifyXml";
 | 
			
		||||
export * from "./xmlToText";
 | 
			
		||||
export * from "./textToXml";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,33 +0,0 @@
 | 
			
		|||
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,12 +1,7 @@
 | 
			
		|||
import { workspace } from "vscode";
 | 
			
		||||
import { ProviderResult, Range, TextEdit, TextEditor, Selection } from "vscode";
 | 
			
		||||
 | 
			
		||||
import { NativeCommands } from "../../common";
 | 
			
		||||
import * as constants from "../../constants";
 | 
			
		||||
import {  Range,  TextEditor, Selection } from "vscode";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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 => {
 | 
			
		||||
| 
						 | 
				
			
			@ -20,9 +15,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, "'");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -30,3 +25,27 @@ 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);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,12 +5,12 @@ import { channel } from "../common/logger";
 | 
			
		|||
//
 | 
			
		||||
// This class handles Symbols
 | 
			
		||||
//
 | 
			
		||||
function makeSymbol (name :string,desc :string,icon :vscode.SymbolKind,pos :any) {
 | 
			
		||||
function makeSymbol(name: string, description: string, icon: vscode.SymbolKind, pos: any) {
 | 
			
		||||
  const spos = new vscode.Position(pos.sl, pos.sc);
 | 
			
		||||
  const epos = new vscode.Position(pos.el, pos.ec);
 | 
			
		||||
  const fullrange=new vscode.Range(spos,epos);
 | 
			
		||||
  const selrange=new vscode.Range(spos,spos);
 | 
			
		||||
  return new vscode.DocumentSymbol(name,"var", vscode.SymbolKind.Variable, fullrange, selrange); 
 | 
			
		||||
  const fullrange = new vscode.Range(spos, epos);
 | 
			
		||||
  const selrange = new vscode.Range(spos, spos);
 | 
			
		||||
  return new vscode.DocumentSymbol(name, description, icon, fullrange, selrange);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export class Symbols implements vscode.DocumentSymbolProvider {
 | 
			
		||||
| 
						 | 
				
			
			@ -23,23 +23,23 @@ export class Symbols implements vscode.DocumentSymbolProvider {
 | 
			
		|||
    const symbols: vscode.DocumentSymbol[] = [];
 | 
			
		||||
    const text = document.getText();
 | 
			
		||||
    const linter = new (XQLint as any)(text, { "styleCheck": false });
 | 
			
		||||
    const xqdoc= linter.getXQDoc();
 | 
			
		||||
    channel.log(xqdoc.variables);
 | 
			
		||||
    const xqdoc = linter.getXQDoc();
 | 
			
		||||
    channel.log("got xqdoc");
 | 
			
		||||
    // type: type,
 | 
			
		||||
    // pos: pos,
 | 
			
		||||
    // qname: qname,
 | 
			
		||||
    // annotations: {}
 | 
			
		||||
    xqdoc.variables.forEach(v  => {
 | 
			
		||||
        const name = v.name;
 | 
			
		||||
        const info =makeSymbol(name,"var", vscode.SymbolKind.Variable,v.pos)
 | 
			
		||||
        symbols.push(info);
 | 
			
		||||
    xqdoc.variables.forEach(v => {
 | 
			
		||||
      const name = v.name;
 | 
			
		||||
      const info = makeSymbol(name, "var", vscode.SymbolKind.Variable, v.pos)
 | 
			
		||||
      symbols.push(info);
 | 
			
		||||
    });
 | 
			
		||||
    xqdoc.functions.forEach(v  => {
 | 
			
		||||
        const name = v.name;
 | 
			
		||||
        const info =makeSymbol(name,"Fu", vscode.SymbolKind.Function,v.pos)
 | 
			
		||||
        symbols.push(info);
 | 
			
		||||
    xqdoc.functions.forEach(v => {
 | 
			
		||||
      const name = v.name;
 | 
			
		||||
      const info = makeSymbol(name, "Fu", vscode.SymbolKind.Function, v.pos)
 | 
			
		||||
      symbols.push(info);
 | 
			
		||||
    });
 | 
			
		||||
    channel.log("Symbols done" + document.uri);
 | 
			
		||||
    channel.log("Symbols done " + document.uri);
 | 
			
		||||
    return symbols;
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue