diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 8007b02..010f293 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -1,6 +1,6 @@ --- name: Bug Report -About: Something is not working +about: Something (aside from the formatter) isn't working right! --- **Description** @@ -10,7 +10,7 @@ What seems to be the problem? If applicable, add screenshots to help explain your problem. **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** What version of VS Code are you using? diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md index b647998..02afe90 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.md +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -5,7 +5,7 @@ about: Suggest a New Feature --- **Description** -What would you like to see added to BaseX Tools? +What would you like to see added to XML Tools? **Current Workarounds** Are you using a workaround in the meantime? diff --git a/.github/ISSUE_TEMPLATE/xml-formatter.md b/.github/ISSUE_TEMPLATE/xml-formatter.md index ac4d148..fe55151 100644 --- a/.github/ISSUE_TEMPLATE/xml-formatter.md +++ b/.github/ISSUE_TEMPLATE/xml-formatter.md @@ -7,10 +7,10 @@ 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.xml.FormatterImplementation` setting). +Which XML Formatter implementation are you using (the value of your `basexTools.xmlFormatterImplementation` setting). -#### BaseX Tools Version -What version of BaseX Tools are you using? +#### XML Tools Version +What version of XML Tools are you using? #### VS Code Version What version of VS Code are you using? diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bb4d2eb..8410891 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,13 +10,11 @@ jobs: runs-on: "ubuntu-latest" steps: - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v2" - name: "Setup NodeJS" - uses: "actions/setup-node@v3" - with: - node-version: 16 - + uses: "actions/setup-node@v2.1.0" + - name: "Install Dependencies" run: "npm install" diff --git a/.vscode/settings.json b/.vscode/settings.json index 254012f..d137133 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,5 @@ }, "search.exclude": { "out": true // set this to false to include "out" folder in search results - }, - "basexTools.xquery.showHovers": false + } } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c535205..ca0e087 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,12 @@ -# 0.1.1 (2023-02-21) -* Add Hover show option # 0.1.0 (2023-02-19) -* Update xqlint to 0.2.0 +Update xqlint to 0.2.0 # 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 # 0.0.58 -* Use xqlint 0.0.14 +* use xqlint 0.0.14 # 0.0.48 * Fix xmlToText #6 diff --git a/package.json b/package.json index 97f216e..9ff22e8 100644 --- a/package.json +++ b/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.1.1", + "version": "0.1.0", "preview": true, "publisher": "quodatum", "author": "Andy Bunce (https://github.com/Quodatum)", @@ -15,7 +15,7 @@ "homepage": "https://github.com/Quodatum/vscode-basex", "repository": { "type": "git", - "url": "https://github.com/Quodatum/vscode-basex.git" + "url": "git+https://github.com/Quodatum/vscode-basex.git" }, "bugs": { "url": "https://github.com/Quodatum/vscode-basex/issues" @@ -31,6 +31,15 @@ "Other" ], "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" ], "main": "./out/extension.js", @@ -116,11 +125,6 @@ "id": "xquery", "title": "XQuery ", "properties": { - "basexTools.xquery.showHovers": { - "type": "boolean", - "default": false, - "description": "Show hovers in xquery." - }, "basexTools.xquery.executionArguments": { "type": "array", "default": [ @@ -155,34 +159,34 @@ } }, { - "title": "XML edit ", + "title": "BaseX Tools ", "type": "object", "properties": { - "basexTools.xml.enforcePrettySelfClosingTagOnFormat": { + "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.xml.removeCommentsOnMinify": { + "basexTools.removeCommentsOnMinify": { "type": "boolean", "default": false, "description": "Remove XML comments during minification.", "scope": "resource" }, - "basexTools.xml.splitAttributesOnFormat": { + "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.xml.splitXmlnsOnFormat": { + "basexTools.splitXmlnsOnFormat": { "type": "boolean", "default": true, "description": "Put each xmlns attribute on a new line when formatting XML.", "scope": "resource" }, - "basexTools.xml.FormatterImplementation": { + "basexTools.xmlFormatterImplementation": { "type": "string", "enum": [ "classic", diff --git a/src/common/configuration.ts b/src/common/configuration.ts index e6c3ffb..fbca6b2 100644 --- a/src/common/configuration.ts +++ b/src/common/configuration.ts @@ -24,7 +24,7 @@ export class Configuration { } static get xmlFormatterImplementation(): string { - return this._getForWindow("xml.FormatterImplementation"); + return this._getForWindow("xmlFormatterImplementation"); } static get xqueryExecutionArguments(): string[] { @@ -43,24 +43,20 @@ export class Configuration { return this._getForWindow("xquery.executionInputSearchPattern"); } - static xqueryShowHovers(resource: Uri): boolean { - return this._getForResource("xquery.showHovers", resource); - } - static enforcePrettySelfClosingTagOnFormat(resource: Uri): boolean { - return this._getForResource("xml.enforcePrettySelfClosingTagOnFormat", resource); + return this._getForResource("enforcePrettySelfClosingTagOnFormat", resource); } static removeCommentsOnMinify(resource: Uri): boolean { - return this._getForResource("xml.removeCommentsOnMinify", resource); + return this._getForResource("removeCommentsOnMinify", resource); } static splitAttributesOnFormat(resource: Uri): boolean { - return this._getForResource("xml.splitAttributesOnFormat", resource); + return this._getForResource("splitAttributesOnFormat", resource); } static splitXmlnsOnFormat(resource: Uri): boolean { - return this._getForResource("xml.splitXmlnsOnFormat", resource); + return this._getForResource("splitXmlnsOnFormat", resource); } private static _getForResource(section: string, resource: Uri): T { diff --git a/src/formatting/formatters/classic-xml-formatter.ts b/src/formatting/formatters/classic-xml-formatter.ts index 6b18548..970e35e 100644 --- a/src/formatting/formatters/classic-xml-formatter.ts +++ b/src/formatting/formatters/classic-xml-formatter.ts @@ -32,7 +32,7 @@ export class ClassicXmlFormatter implements XmlFormatter { output += parts[i]; inComment = false; } 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]; if (!inComment) { level--; } @@ -48,7 +48,7 @@ export class ClassicXmlFormatter implements XmlFormatter { output = (!inComment) ? output += this._getIndent(options, level--, parts[i]) : output += parts[i]; } else if (parts[i].search(/<\?/) > -1) { 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]); } else { output += parts[i]; @@ -67,7 +67,7 @@ export class ClassicXmlFormatter implements XmlFormatter { minifyXml(xml: string, options: XmlFormattingOptions): string { xml = this._stripLineBreaks(options, xml); // all line breaks outside of CDATA elements and comments - xml = (options.removeCommentsOnMinify) ? xml.replace(//g, "") : xml; + xml = (options.removeCommentsOnMinify) ? xml.replace(/\/g, "") : xml; xml = xml.replace(/>\s{0,}<"); // insignificant whitespace between tags xml = xml.replace(/"\s+(?=[^\s]+=)/g, "\" "); // spaces between attributes xml = xml.replace(/"\s+(?=>)/g, "\""); // spaces between the last attribute and tag close (>) diff --git a/src/hover/hover.ts b/src/hover/hover.ts index af6ed27..84150b5 100644 --- a/src/hover/hover.ts +++ b/src/hover/hover.ts @@ -1,32 +1,28 @@ // xquery hover import { CancellationToken, Hover, HoverProvider, Position, TextDocument } from "vscode"; -import { XQLint } from "@quodatum/xqlint"; -import { Configuration } from "../common"; +import { XQLint} from "@quodatum/xqlint"; export class XQueryHoverProvider implements HoverProvider { public provideHover( - document: TextDocument, - position: Position, + document: TextDocument, + position: Position, token: CancellationToken ): Hover | null { const linter = new XQLint(document.getText()); - const node = linter.getAST(position); + 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); - - if (Configuration.xqueryShowHovers(document.uri)) { - return new Hover(`XQuery Hover info: ${word} at ${position.line}: ${position.character} - 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 } -} \ No newline at end of file +}