diff --git a/package.json b/package.json index d286c4f..c4ec2b2 100644 --- a/package.json +++ b/package.json @@ -68,160 +68,58 @@ "title": "XML Tools Configuration", "type": "object", "properties": { - "xmlTools.core.useNewSettings": { - "type": "boolean", - "default": false, - "description": "Enables use of the new 'nested' settings instead of the current 'flattened' settings." - }, - "xmlTools.formatter.addSpaceBeforeSelfClose": { - "type": "boolean", - "default": true, - "description": "Ensures a space exists before the '/>' in self-closing tags.", - "scope": "resource" - }, - "xmlTools.formatter.implementation": { - "type": "string", - "default": "v2", - "description": "Defines the XML formatter implementation used for formatting and minification.", - "enum": [ - "classic", - "v2" - ], - "scope": "application" - }, - "xmlTools.formatter.splitAttributes": { - "type": "boolean", - "default": false, - "description": "Places each attribute (except the first) on a new line. Includes xmlns attributes.", - "scope": "resource" - }, - "xmlTools.formatter.splitXmlnsAttributes": { - "type": "boolean", - "default": false, - "description": "Places each xmlns attribute on a new line.", - "scope": "resource" - }, - "xmlTools.formatter.stripCommentsOnMinify": { - "type": "boolean", - "default": false, - "description": "Removes comments from XML during minification.", - "scope": "resource" - }, - "xmlTools.treeView.enabled": { - "type": "boolean", - "default": true, - "description": "Enables the XML Tree View feature.", - "scope": "application" - }, - "xmlTools.treeView.showMetadata": { - "type": "boolean", - "default": true, - "description": "Displays attributes such as 'children' and 'attributes' counts in the XML tree view.", - "scope": "application" - }, - "xmlTools.treeView.syncCursor": { - "type": "boolean", - "default": false, - "description": "Reveals an element or atribute in the tree view when clicked in the editor.", - "scope": "application" - }, - "xmlTools.xpath.ignoreDefaultNamespace": { - "type": "boolean", - "default": true, - "description": "Ignores default xmlns attributes.", - "scope": "application" - }, - "xmlTools.xpath.rememberLastQuery": { - "type": "boolean", - "default": true, - "description": "Remembers the last query you executed for the current file.", - "scope": "application" - }, - "xmlTools.xquery.executable": { - "type": "string", - "default": true, - "description": "The full path to the executable to use for executing scripts.", - "scope": "application" - }, - "xmlTools.xquery.executableArgs": { - "type": "array", - "default": [ - "-xquery", - "$(script)", - "-in", - "$(input)", - "-out", - "$(input).output.xml" - ], - "description": "Command-line arguments to pass to the executable.", - "scope": "application" - }, - "xmlTools.xquery.inputFilesLimit": { - "type": "integer", - "default": 100, - "description": "The maximum number of input files to enumerate.", - "scope": "application" - }, - "xmlTools.xquery.inputFilesSearchPattern": { - "type": "string", - "default": "**/*.xml", - "description": "The pattern used to search for input XML files.", - "scope": "application" - }, - - "xmlTools.enableXmlTreeView": { "type": "boolean", "default": true, - "description": "Deprecated. Use 'xmlTools.treeView.enabled' instead.", + "description": "Enables the XML Document view in the explorer for XML documents.", "scope": "window" }, "xmlTools.enableXmlTreeViewMetadata": { "type": "boolean", "default": true, - "description": "Deprecated. Use 'xmlTools.treeView.showMetadata' instead.", + "description": "Enables attribute and child element counts in the XML Document view.", "scope": "window" }, "xmlTools.enableXmlTreeViewCursorSync": { "type": "boolean", "default": false, - "description": "Deprecated. Use 'xmlTools.treeView.syncCursor' instead.", + "description": "Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.", "scope": "window" }, "xmlTools.enforcePrettySelfClosingTagOnFormat": { "type": "boolean", "default": false, - "description": "Deprecated. Use 'xmlTools.formatter.addSpaceBeforeSelfClose' instead.", + "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": "Deprecated. Use 'xmlTools.xpath.ignoreDefaultNamespace' instead.", + "description": "Ignore default xmlns attributes when evaluating XPath.", "scope": "window" }, "xmlTools.persistXPathQuery": { "type": "boolean", "default": true, - "description": "Deprecated. Use 'xmlTools.xpath.rememberLastQuery' instead.", + "description": "Remember the last XPath query used.", "scope": "window" }, "xmlTools.removeCommentsOnMinify": { "type": "boolean", "default": false, - "description": "Deprecated. Use 'xmlTools.formatter.removeCommentsOnMinify' instead.", + "description": "Remove XML comments during minification.", "scope": "resource" }, "xmlTools.splitAttributesOnFormat": { "type": "boolean", "default": false, - "description": "Deprecated. Use 'xmlTools.formatter.splitAttributes' instead.", + "description": "Put each attribute on a new line when formatting XML. Overrides `xmlTools.splitXmlsOnFormat` if set to `true`.", "scope": "resource" }, "xmlTools.splitXmlnsOnFormat": { "type": "boolean", "default": true, - "description": "Deprecated. Use 'xmlTools.formatter.splitXmlnsAttributes' instead.", + "description": "Put each xmlns attribute on a new line when formatting XML.", "scope": "resource" }, "xmlTools.xmlFormatterImplementation": { @@ -231,7 +129,7 @@ "v2" ], "default": "v2", - "description": "Deprecated. Use 'xmlTools.formatter.implementation' instead.", + "description": "Supported XML Formatters: classic", "scope": "window" }, "xmlTools.xqueryExecutionArguments": { @@ -242,27 +140,27 @@ "-in", "$(input)", "-out", - "$(input).output.xml" + "$(input.output.xml" ], - "description": "Deprecated. Use 'xmlTools.xquery.executableArgs' instead.", + "description": "Arguments to be passed to the XQuery execution engine.", "scope": "window" }, "xmlTools.xqueryExecutionEngine": { "type": "string", "default": "", - "description": "Deprecated. Use 'xmlTools.xquery.executable' instead.", + "description": "The full path to the executable to run when executing XQuery scripts.", "scope": "window" }, "xmlTools.xqueryExecutionInputLimit": { "type": "integer", "default": 100, - "description": "Deprecated. Use 'xmlTools.xquery.inputFileLimit' instead.", + "description": "The maximum number of input files to enumerate when executing XQuery scripts.", "scope": "window" }, "xmlTools.xqueryExecutionInputSearchPattern": { "type": "string", "default": "**/*.xml", - "description": "Deprecated. Use 'xmlTools.xquery.inputFileSearchPattern' instead.", + "description": "The pattern used to search for input XML files when executing XQuery scripts.", "scope": "window" } } diff --git a/src/common/configuration.ts b/src/common/configuration.ts index 95cdf52..b1461d0 100644 --- a/src/common/configuration.ts +++ b/src/common/configuration.ts @@ -1,78 +1,69 @@ import { workspace, Uri } from "vscode"; const ExtensionTopLevelSection = "xmlTools"; -const UseNewSettingsSection = "core.useNewSettings"; export class Configuration { - static get treeViewEnabled(): boolean { - return this._getForWindow("treeView.enabled", "enableXmlTreeView"); + static get enableXmlTreeView(): boolean { + return this._getForWindow("enableXmlTreeView"); } - static get treeViewShowMetadata(): boolean { - return this._getForWindow("treeView.showMetadata", "enableXmlTreeViewMetadata"); + static get enableXmlTreeViewMetadata(): boolean { + return this._getForWindow("enableXmlTreeViewMetadata"); } - static get treeViewSyncCursor(): boolean { - return this._getForWindow("treeView.syncCursor", "enableXmlTreeViewCursorSync"); + static get enableXmlTreeViewCursorSync(): boolean { + return this._getForWindow("enableXmlTreeViewCursorSync"); } - static get xpathIgnoreDefaultNamespace(): boolean { - return this._getForWindow("xpath.ignoreDefaultNamespace", "ignoreDefaultNamespace"); + static get ignoreDefaultNamespace(): boolean { + return this._getForWindow("ignoreDefaultNamespace"); } - static get xpathRememberLastQuery(): boolean { - return this._getForWindow("xpath.rememberLastQuery", "persistXPathQuery"); + static get persistXPathQuery(): boolean { + return this._getForWindow("persistXPathQuery"); } - static get formatterImplementation(): string { - return this._getForWindow("formatter.implementation", "xmlFormatterImplementation"); + static get xmlFormatterImplementation(): string { + return this._getForWindow("xmlFormatterImplementation"); } - static get xqueryExecutableArgs(): string[] { - return this._getForWindow("xquery.executableArgs", "xqueryExecutionArguments"); + static get xqueryExecutionArguments(): string[] { + return this._getForWindow("xqueryExecutionArguments"); } - static get xqueryExecutable(): string { - return this._getForWindow("xquery.executable", "xqueryExecutionEngine"); + static get xqueryExecutionEngine(): string { + return this._getForWindow("xqueryExecutionEngine"); } - static get xqueryInputFilesLimit(): number { - return this._getForWindow("xquery.inputFilesLimit", "xqueryExecutionInputLimit"); + static get xqueryExecutionInputLimit(): number { + return this._getForWindow("xqueryExecutionInputLimit"); } - static get xqueryInputFilesSearchPattern(): string { - return this._getForWindow("xquery.inputFilesSearchPattern", "xqueryExecutionInputSearchPattern"); + static get xqueryExecutionInputSearchPattern(): string { + return this._getForWindow("xqueryExecutionInputSearchPattern"); } - static formatterAddSpaceBeforeSelfClose(resource: Uri): boolean { - return this._getForResource("formatter.addSpaceBeforeSelfClose", resource, "enforcePrettySelfClosingTagOnFormat"); + static enforcePrettySelfClosingTagOnFormat(resource: Uri): boolean { + return this._getForResource("enforcePrettySelfClosingTagOnFormat", resource); } - static formatterRemoveCommentsOnMinify(resource: Uri): boolean { - return this._getForResource("formatter.removeCommentsOnMinify", resource, "removeCommentsOnMinify"); + static removeCommentsOnMinify(resource: Uri): boolean { + return this._getForResource("removeCommentsOnMinify", resource); } - static formatterSplitAttributes(resource: Uri): boolean { - return this._getForResource("formatter.splitAttributes", resource, "splitAttributesOnFormat"); + static splitAttributesOnFormat(resource: Uri): boolean { + return this._getForResource("splitAttributesOnFormat", resource); } - static formatterSplitXmlnsAttributes(resource: Uri): boolean { - return this._getForResource("formatter.splitXmlnsAttributes", resource, "splitXmlnsOnFormat"); + static splitXmlnsOnFormat(resource: Uri): boolean { + return this._getForResource("splitXmlnsOnFormat", resource); } - private static _getForResource(section: string, resource: Uri, oldSection?: string): T { - if (oldSection && !workspace.getConfiguration(ExtensionTopLevelSection).get(UseNewSettingsSection)) { - section = oldSection; - } - + private static _getForResource(section: string, resource: Uri): T { return workspace.getConfiguration(ExtensionTopLevelSection, resource).get(section); } - private static _getForWindow(section: string, oldSection?: string): T { - if (oldSection && !workspace.getConfiguration(ExtensionTopLevelSection).get(UseNewSettingsSection)) { - section = oldSection; - } - + private static _getForWindow(section: string): T { return workspace.getConfiguration(ExtensionTopLevelSection).get(section); } } diff --git a/src/extension.ts b/src/extension.ts index e7a30a3..ee975af 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -47,7 +47,7 @@ export function activate(context: ExtensionContext) { treeDataProvider: treeViewDataProvider }); - if (Configuration.treeViewSyncCursor) { + if (Configuration.enableXmlTreeViewCursorSync) { window.onDidChangeTextEditorSelection(x => { if (x.kind === TextEditorSelectionChangeKind.Mouse && x.selections.length > 0) { treeView.reveal(treeViewDataProvider.getNodeAtPosition(x.selections[0].start)); diff --git a/src/formatting/xml-formatter.ts b/src/formatting/xml-formatter.ts index c32fc33..01fb9ae 100644 --- a/src/formatting/xml-formatter.ts +++ b/src/formatting/xml-formatter.ts @@ -20,7 +20,7 @@ export class XmlFormatterFactory { return XmlFormatterFactory._xmlFormatter; } - const xmlFormatterImplementationSetting = Configuration.formatterImplementation; + const xmlFormatterImplementationSetting = Configuration.xmlFormatterImplementation; let xmlFormatterImplementation: XmlFormatter; switch (xmlFormatterImplementationSetting) { diff --git a/src/formatting/xml-formatting-options.ts b/src/formatting/xml-formatting-options.ts index f7fa9c1..06782a1 100644 --- a/src/formatting/xml-formatting-options.ts +++ b/src/formatting/xml-formatting-options.ts @@ -16,11 +16,11 @@ export class XmlFormattingOptionsFactory { static getXmlFormattingOptions(formattingOptions: FormattingOptions, document: TextDocument): XmlFormattingOptions { return { editorOptions: formattingOptions, - enforcePrettySelfClosingTagOnFormat: Configuration.formatterAddSpaceBeforeSelfClose(document.uri), + enforcePrettySelfClosingTagOnFormat: Configuration.enforcePrettySelfClosingTagOnFormat(document.uri), newLine: (document.eol === EndOfLine.CRLF) ? "\r\n" : "\n", - removeCommentsOnMinify: Configuration.formatterRemoveCommentsOnMinify(document.uri), - splitAttributesOnFormat: Configuration.formatterSplitAttributes(document.uri), - splitXmlnsOnFormat: Configuration.formatterSplitXmlnsAttributes(document.uri) + removeCommentsOnMinify: Configuration.removeCommentsOnMinify(document.uri), + splitAttributesOnFormat: Configuration.splitAttributesOnFormat(document.uri), + splitXmlnsOnFormat: Configuration.splitXmlnsOnFormat(document.uri) }; } } diff --git a/src/tree-view/xml-tree-data-provider.ts b/src/tree-view/xml-tree-data-provider.ts index 5526c31..106d0a1 100644 --- a/src/tree-view/xml-tree-data-provider.ts +++ b/src/tree-view/xml-tree-data-provider.ts @@ -34,8 +34,8 @@ export class XmlTreeDataProvider implements TreeDataProvider { } getTreeItem(element: Node): TreeItem | Thenable { - const enableMetadata = Configuration.treeViewShowMetadata; - const enableSync = Configuration.treeViewSyncCursor; + const enableMetadata = Configuration.enableXmlTreeViewMetadata; + const enableSync = Configuration.enableXmlTreeViewCursorSync; const treeItem = new TreeItem(element.localName); @@ -138,7 +138,7 @@ export class XmlTreeDataProvider implements TreeDataProvider { return; } - const enableTreeView = Configuration.treeViewEnabled; + const enableTreeView = Configuration.enableXmlTreeView; NativeCommands.setContext(constants.contextKeys.xmlTreeViewEnabled, enableTreeView); diff --git a/src/xpath/commands/evaluateXPath.ts b/src/xpath/commands/evaluateXPath.ts index fcb5e5a..bc22d97 100644 --- a/src/xpath/commands/evaluateXPath.ts +++ b/src/xpath/commands/evaluateXPath.ts @@ -21,7 +21,7 @@ export async function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): P const memento = ExtensionState.workspace || ExtensionState.global; // get the xpath persistence setting - const persistQueries = Configuration.xpathRememberLastQuery; + const persistQueries = Configuration.persistXPathQuery; // get the last query if there is one for this document // if not, try pulling the last query ran, regardless of document @@ -47,7 +47,7 @@ export async function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): P return; } - const ignoreDefaultNamespace = Configuration.xpathIgnoreDefaultNamespace; + const ignoreDefaultNamespace = Configuration.ignoreDefaultNamespace; // run the query const xml = editor.document.getText(); diff --git a/src/xquery-execution/commands/executeXQuery.ts b/src/xquery-execution/commands/executeXQuery.ts index 7f295cb..a74ed0e 100644 --- a/src/xquery-execution/commands/executeXQuery.ts +++ b/src/xquery-execution/commands/executeXQuery.ts @@ -15,8 +15,8 @@ export async function executeXQuery(editor: TextEditor, edit: TextEditorEdit): P return; } - const executable = Configuration.xqueryExecutable; - let args = Configuration.xqueryExecutableArgs || []; + const executable = Configuration.xqueryExecutionEngine; + let args = Configuration.xqueryExecutionArguments || []; if (!executable || executable === "") { const action = await window.showWarningMessage("An XQuery execution engine has not been defined.", "Define Now"); @@ -31,8 +31,8 @@ export async function executeXQuery(editor: TextEditor, edit: TextEditorEdit): P let inputFile: Uri; disposable = window.setStatusBarMessage("Searching for XML files in folder..."); - const searchPattern = Configuration.xqueryInputFilesSearchPattern; - const inputLimit = Configuration.xqueryInputFilesLimit; + const searchPattern = Configuration.xqueryExecutionInputSearchPattern; + const inputLimit = Configuration.xqueryExecutionInputLimit; const files = await workspace.findFiles(searchPattern, "", inputLimit);