Compare commits

..

No commits in common. "93e6b0a1d6b45ade6a99dffac3b1570d134f476c" and "85fc61edb3785b65be13077aad190d8f3395c851" have entirely different histories.

10 changed files with 48 additions and 57 deletions

View file

@ -1,6 +1,6 @@
--- ---
name: Bug Report name: Bug Report
About: Something is not working about: Something (aside from the formatter) isn't working right!
--- ---
**Description** **Description**
@ -10,7 +10,7 @@ What seems to be the problem?
If applicable, add screenshots to help explain your problem. If applicable, add screenshots to help explain your problem.
**Extension Version** **Extension Version**
What version of the Basex-Tools extension are you using? What version of the XML Tools extension are you using?
**VS Code Version** **VS Code Version**
What version of VS Code are you using? What version of VS Code are you using?

View file

@ -5,7 +5,7 @@ about: Suggest a New Feature
--- ---
**Description** **Description**
What would you like to see added to BaseX Tools? What would you like to see added to XML Tools?
**Current Workarounds** **Current Workarounds**
Are you using a workaround in the meantime? Are you using a workaround in the meantime?

View file

@ -7,10 +7,10 @@ about: Report an issue with the XML formatter.
What seems to be the problem? What seems to be the problem?
#### Formatter Implementation #### Formatter Implementation
Which XML Formatter implementation are you using (the value of your `basexTools.xml.FormatterImplementation` setting). Which XML Formatter implementation are you using (the value of your `basexTools.xmlFormatterImplementation` setting).
#### BaseX Tools Version #### XML Tools Version
What version of BaseX Tools are you using? What version of XML Tools are you using?
#### VS Code Version #### VS Code Version
What version of VS Code are you using? What version of VS Code are you using?

View file

@ -10,13 +10,11 @@ jobs:
runs-on: "ubuntu-latest" runs-on: "ubuntu-latest"
steps: steps:
- name: "Checkout" - name: "Checkout"
uses: "actions/checkout@v3" uses: "actions/checkout@v2"
- name: "Setup NodeJS" - name: "Setup NodeJS"
uses: "actions/setup-node@v3" uses: "actions/setup-node@v2.1.0"
with:
node-version: 16
- name: "Install Dependencies" - name: "Install Dependencies"
run: "npm install" run: "npm install"

View file

@ -5,6 +5,5 @@
}, },
"search.exclude": { "search.exclude": {
"out": true // set this to false to include "out" folder in search results "out": true // set this to false to include "out" folder in search results
}, }
"basexTools.xquery.showHovers": false
} }

View file

@ -1,14 +1,12 @@
# 0.1.1 (2023-02-21)
* Add Hover show option
# 0.1.0 (2023-02-19) # 0.1.0 (2023-02-19)
* Update xqlint to 0.2.0 Update xqlint to 0.2.0
# 0.0.64 (2023-01-26) # 0.0.64 (2023-01-26)
* Add simple hover display * add simple hover display
* Update `xqlint.d.ts` to support newer `tsc.exe`. This reduces size of vsix from 600kb to 300kb * Update `xqlint.d.ts` to support newer `tsc.exe`. This reduces size of vsix from 600kb to 300kb
# 0.0.58 # 0.0.58
* Use xqlint 0.0.14 * use xqlint 0.0.14
# 0.0.48 # 0.0.48
* Fix xmlToText #6 * Fix xmlToText #6

View file

@ -2,7 +2,7 @@
"name": "vscode-basex", "name": "vscode-basex",
"displayName": "BaseX tools", "displayName": "BaseX tools",
"description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code", "description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code",
"version": "0.1.1", "version": "0.1.0",
"preview": true, "preview": true,
"publisher": "quodatum", "publisher": "quodatum",
"author": "Andy Bunce (https://github.com/Quodatum)", "author": "Andy Bunce (https://github.com/Quodatum)",
@ -15,7 +15,7 @@
"homepage": "https://github.com/Quodatum/vscode-basex", "homepage": "https://github.com/Quodatum/vscode-basex",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/Quodatum/vscode-basex.git" "url": "git+https://github.com/Quodatum/vscode-basex.git"
}, },
"bugs": { "bugs": {
"url": "https://github.com/Quodatum/vscode-basex/issues" "url": "https://github.com/Quodatum/vscode-basex/issues"
@ -31,6 +31,15 @@
"Other" "Other"
], ],
"activationEvents": [ "activationEvents": [
"onCommand:basexTools.evaluateXPath",
"onCommand:basexTools.executeXQuery",
"onCommand:basexTools.formatAsXml",
"onCommand:basexTools.textToXml",
"onCommand:basexTools.xmlToText",
"onCommand:basexTools.minifyXml",
"onCommand:basexTools.xqLintReport",
"onLanguage:xml",
"onLanguage:xquery",
"onLanguage:xsl" "onLanguage:xsl"
], ],
"main": "./out/extension.js", "main": "./out/extension.js",
@ -116,11 +125,6 @@
"id": "xquery", "id": "xquery",
"title": "XQuery ", "title": "XQuery ",
"properties": { "properties": {
"basexTools.xquery.showHovers": {
"type": "boolean",
"default": false,
"description": "Show hovers in xquery."
},
"basexTools.xquery.executionArguments": { "basexTools.xquery.executionArguments": {
"type": "array", "type": "array",
"default": [ "default": [
@ -155,34 +159,34 @@
} }
}, },
{ {
"title": "XML edit ", "title": "BaseX Tools ",
"type": "object", "type": "object",
"properties": { "properties": {
"basexTools.xml.enforcePrettySelfClosingTagOnFormat": { "basexTools.enforcePrettySelfClosingTagOnFormat": {
"type": "boolean", "type": "boolean",
"default": false, "default": false,
"description": "Enforces a space before the forward slash at the end of a self-closing XML tag.", "description": "Enforces a space before the forward slash at the end of a self-closing XML tag.",
"scope": "resource" "scope": "resource"
}, },
"basexTools.xml.removeCommentsOnMinify": { "basexTools.removeCommentsOnMinify": {
"type": "boolean", "type": "boolean",
"default": false, "default": false,
"description": "Remove XML comments during minification.", "description": "Remove XML comments during minification.",
"scope": "resource" "scope": "resource"
}, },
"basexTools.xml.splitAttributesOnFormat": { "basexTools.splitAttributesOnFormat": {
"type": "boolean", "type": "boolean",
"default": false, "default": false,
"description": "Put each attribute on a new line when formatting XML. Overrides `basexTools.splitXmlnsOnFormat` if set to `true`.", "description": "Put each attribute on a new line when formatting XML. Overrides `basexTools.splitXmlnsOnFormat` if set to `true`.",
"scope": "resource" "scope": "resource"
}, },
"basexTools.xml.splitXmlnsOnFormat": { "basexTools.splitXmlnsOnFormat": {
"type": "boolean", "type": "boolean",
"default": true, "default": true,
"description": "Put each xmlns attribute on a new line when formatting XML.", "description": "Put each xmlns attribute on a new line when formatting XML.",
"scope": "resource" "scope": "resource"
}, },
"basexTools.xml.FormatterImplementation": { "basexTools.xmlFormatterImplementation": {
"type": "string", "type": "string",
"enum": [ "enum": [
"classic", "classic",

View file

@ -24,7 +24,7 @@ export class Configuration {
} }
static get xmlFormatterImplementation(): string { static get xmlFormatterImplementation(): string {
return this._getForWindow<string>("xml.FormatterImplementation"); return this._getForWindow<string>("xmlFormatterImplementation");
} }
static get xqueryExecutionArguments(): string[] { static get xqueryExecutionArguments(): string[] {
@ -43,24 +43,20 @@ export class Configuration {
return this._getForWindow<string>("xquery.executionInputSearchPattern"); return this._getForWindow<string>("xquery.executionInputSearchPattern");
} }
static xqueryShowHovers(resource: Uri): boolean {
return this._getForResource<boolean>("xquery.showHovers", resource);
}
static enforcePrettySelfClosingTagOnFormat(resource: Uri): boolean { static enforcePrettySelfClosingTagOnFormat(resource: Uri): boolean {
return this._getForResource<boolean>("xml.enforcePrettySelfClosingTagOnFormat", resource); return this._getForResource<boolean>("enforcePrettySelfClosingTagOnFormat", resource);
} }
static removeCommentsOnMinify(resource: Uri): boolean { static removeCommentsOnMinify(resource: Uri): boolean {
return this._getForResource<boolean>("xml.removeCommentsOnMinify", resource); return this._getForResource<boolean>("removeCommentsOnMinify", resource);
} }
static splitAttributesOnFormat(resource: Uri): boolean { static splitAttributesOnFormat(resource: Uri): boolean {
return this._getForResource<boolean>("xml.splitAttributesOnFormat", resource); return this._getForResource<boolean>("splitAttributesOnFormat", resource);
} }
static splitXmlnsOnFormat(resource: Uri): boolean { static splitXmlnsOnFormat(resource: Uri): boolean {
return this._getForResource<boolean>("xml.splitXmlnsOnFormat", resource); return this._getForResource<boolean>("splitXmlnsOnFormat", resource);
} }
private static _getForResource<T>(section: string, resource: Uri): T { private static _getForResource<T>(section: string, resource: Uri): T {

View file

@ -32,7 +32,7 @@ export class ClassicXmlFormatter implements XmlFormatter {
output += parts[i]; output += parts[i];
inComment = false; inComment = false;
} else if (/^<(\w|:)/.test(parts[i - 1]) && /^<\/(\w|:)/.test(parts[i]) } else if (/^<(\w|:)/.test(parts[i - 1]) && /^<\/(\w|:)/.test(parts[i])
&& /^<[\w:\-.,/]+/.exec(parts[i - 1])[0] === /^<\/[\w:\-.,]+/.exec(parts[i])[0].replace("/", "")) { && /^<[\w:\-\.\,\/]+/.exec(parts[i - 1])[0] === /^<\/[\w:\-\.\,]+/.exec(parts[i])[0].replace("/", "")) {
output += parts[i]; output += parts[i];
if (!inComment) { level--; } if (!inComment) { level--; }
@ -48,7 +48,7 @@ export class ClassicXmlFormatter implements XmlFormatter {
output = (!inComment) ? output += this._getIndent(options, level--, parts[i]) : output += parts[i]; output = (!inComment) ? output += this._getIndent(options, level--, parts[i]) : output += parts[i];
} else if (parts[i].search(/<\?/) > -1) { } else if (parts[i].search(/<\?/) > -1) {
output += this._getIndent(options, level, parts[i]); output += this._getIndent(options, level, parts[i]);
} else if (options.splitXmlnsOnFormat && (parts[i].search(/xmlns:/) > -1 || parts[i].search(/xmlns=/) > -1)) { } else if (options.splitXmlnsOnFormat && (parts[i].search(/xmlns\:/) > -1 || parts[i].search(/xmlns\=/) > -1)) {
output += this._getIndent(options, level, parts[i]); output += this._getIndent(options, level, parts[i]);
} else { } else {
output += parts[i]; output += parts[i];
@ -67,7 +67,7 @@ export class ClassicXmlFormatter implements XmlFormatter {
minifyXml(xml: string, options: XmlFormattingOptions): string { minifyXml(xml: string, options: XmlFormattingOptions): string {
xml = this._stripLineBreaks(options, xml); // all line breaks outside of CDATA elements and comments xml = this._stripLineBreaks(options, xml); // all line breaks outside of CDATA elements and comments
xml = (options.removeCommentsOnMinify) ? xml.replace(/<![ \r\n\t]*(--([^-]|[\r\n]|-[^-])*--[ \r\n\t]*)>/g, "") : xml; xml = (options.removeCommentsOnMinify) ? xml.replace(/\<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>/g, "") : xml;
xml = xml.replace(/>\s{0,}</g, "><"); // insignificant whitespace between tags xml = xml.replace(/>\s{0,}</g, "><"); // insignificant whitespace between tags
xml = xml.replace(/"\s+(?=[^\s]+=)/g, "\" "); // spaces between attributes xml = xml.replace(/"\s+(?=[^\s]+=)/g, "\" "); // spaces between attributes
xml = xml.replace(/"\s+(?=>)/g, "\""); // spaces between the last attribute and tag close (>) xml = xml.replace(/"\s+(?=>)/g, "\""); // spaces between the last attribute and tag close (>)

View file

@ -1,32 +1,28 @@
// xquery hover // xquery hover
import { CancellationToken, Hover, HoverProvider, Position, TextDocument } from "vscode"; import { CancellationToken, Hover, HoverProvider, Position, TextDocument } from "vscode";
import { XQLint } from "@quodatum/xqlint"; import { XQLint} from "@quodatum/xqlint";
import { Configuration } from "../common";
export class XQueryHoverProvider implements HoverProvider { export class XQueryHoverProvider implements HoverProvider {
public provideHover( public provideHover(
document: TextDocument, document: TextDocument,
position: Position, position: Position,
token: CancellationToken token: CancellationToken
): Hover | null { ): Hover | null {
const linter = new XQLint(document.getText()); const linter = new XQLint(document.getText());
const node = linter.getAST(position); const node=linter.getAST(position);
//const sctx=linter.getCompletions(position); //const sctx=linter.getCompletions(position);
//channel.log("Hover: " + node.name); //channel.log("Hover: " + node.name);
//const dx=dump(node); //const dx=dump(node);
//channel.appendLine(dx); //channel.appendLine(dx);
const range = document.getWordRangeAtPosition(position); const range = document.getWordRangeAtPosition(position);
const word = document.getText(range); const word = document.getText(range);
return new Hover(`XQuery Hover info: ${word} at ${position.line}: ${position.character}
if (Configuration.xqueryShowHovers(document.uri)) { value: ${ node.value }, name: ${ node.name }
return new Hover(`XQuery Hover info: ${word} at ${position.line}: ${position.character}
value: ${node.value}, name: ${node.name}
`); `);
} else {
return null; //if there is no information to show return null; //if there is no information to show
}
} }
} }