From 1c0807c5cfd46836be7e5dc80115a62e6d72a0fe Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Mon, 30 Oct 2017 22:15:19 -0700 Subject: [PATCH] Support for multi root --- package.json | 20 +++++++++++++------- src/Commands.ts | 2 +- src/providers/Execution.ts | 10 ++++++---- src/providers/Formatting.ts | 2 +- src/providers/XPath.ts | 4 ++-- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index fbb6e8b..f39f06a 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "url": "https://github.com/DotJoshJohnson/vscode-xml/issues" }, "engines": { - "vscode": "^1.13.0", + "vscode": "^1.17.0", "node": "^0.12.0" }, "categories": [ @@ -58,32 +58,38 @@ "xmlTools.persistXPathQuery": { "type": "boolean", "default": true, - "description": "Remember the last XPath query used." + "description": "Remember the last XPath query used.", + "scope": "resource" }, "xmlTools.removeCommentsOnMinify": { "type": "boolean", "default": false, - "description": "Remove XML comments when XML is minified." + "description": "Remove XML comments when XML is minified.", + "scope": "resource" }, "xmlTools.splitXmlnsOnFormat": { "type": "boolean", "default": true, - "description": "Put each xmlns attribute on a new line when fromatting XML." + "description": "Put each xmlns attribute on a new line when fromatting XML.", + "scope": "resource" }, "xmlTools.xqueryExecutionEngine": { "type": "string", "default": "", - "description": "The full path to the execution engine executable." + "description": "The full path to the execution engine executable.", + "scope": "resource" }, "xmlTools.xqueryExecutionArguments": { "type": "array", "default": ["-xquery", "$(script)", "-in", "$(input)", "-out", "$(input).output.xml"], - "description": "Arguments to be passed to the execution engine. '$(script)' and '$(input)' refer to the XQuery script and input XML file, respectively." + "description": "Arguments to be passed to the execution engine. '$(script)' and '$(input)' refer to the XQuery script and input XML file, respectively.", + "scope": "resource" }, "xmlTools.ignoreDefaultNamespace": { "type": "boolean", "default": true, - "description": "Ignores default xmlns attribute when evaluating XPath." + "description": "Ignores default xmlns attribute when evaluating XPath.", + "scope": "resource" } } }, diff --git a/src/Commands.ts b/src/Commands.ts index f09705f..483659c 100644 --- a/src/Commands.ts +++ b/src/Commands.ts @@ -12,7 +12,7 @@ const CFG_REMOVE_COMMENTS: string = "removeCommentsOnMinify"; export class TextEditorCommands { static minifyXml(editor: vsc.TextEditor, edit: vsc.TextEditorEdit): void { - let removeComments: boolean = vsc.workspace.getConfiguration(CFG_SECTION).get(CFG_REMOVE_COMMENTS, false); + let removeComments: boolean = vsc.workspace.getConfiguration(CFG_SECTION, editor.document.uri).get(CFG_REMOVE_COMMENTS, false); let range: vsc.Range = RangeUtil.getRangeForDocument(editor.document); diff --git a/src/providers/Execution.ts b/src/providers/Execution.ts index 1ac3dee..3a95aa8 100644 --- a/src/providers/Execution.ts +++ b/src/providers/Execution.ts @@ -15,8 +15,8 @@ export class XQueryExecutionProvider { return; } - let executable = vsc.workspace.getConfiguration(CFG_SECTION).get(CFG_XQEXEC, null); - let args = vsc.workspace.getConfiguration(CFG_SECTION).get(CFG_XQARGS, []); + let executable = vsc.workspace.getConfiguration(CFG_SECTION, editor.document.uri).get(CFG_XQEXEC, null); + let args = vsc.workspace.getConfiguration(CFG_SECTION, editor.document.uri).get(CFG_XQARGS, []); if (!executable || executable == "") { let action = await vsc.window.showWarningMessage("An XQuery execution engine has not been defined.", "Define Now"); @@ -89,14 +89,16 @@ export class XQueryExecutionProvider { args[outputPathPos] = outputPath; } - + + const project = vsc.workspace.getWorkspaceFolder(editor.document.uri) ? vsc.workspace.getWorkspaceFolder(editor.document.uri).uri.fsPath : ''; + // call out to the execution engine disposable = vsc.window.setStatusBarMessage("Executing XQuery Script..."); args = args.map((value: string) => { return value .replace("$(script)", editor.document.uri.fsPath) .replace("$(input)", inputFile.fsPath) - .replace("$(project)", vsc.workspace.rootPath); + .replace("$(project)", project); }); try { diff --git a/src/providers/Formatting.ts b/src/providers/Formatting.ts index 5bc3faf..0d12da4 100644 --- a/src/providers/Formatting.ts +++ b/src/providers/Formatting.ts @@ -17,7 +17,7 @@ export class XmlFormattingEditProvider implements vsc.DocumentFormattingEditProv } private _provideFormattingEdits(document: vsc.TextDocument, range: vsc.Range, options: vsc.FormattingOptions): vsc.TextEdit[] { - let splitNamespaces: boolean = vsc.workspace.getConfiguration(CFG_SECTION).get(CFG_SPLIT_NAMESPACES, true); + let splitNamespaces: boolean = vsc.workspace.getConfiguration(CFG_SECTION, document.uri).get(CFG_SPLIT_NAMESPACES, true); let formatterOptions: IXmlFormatterOptions = { preferSpaces: options.insertSpaces, diff --git a/src/providers/XPath.ts b/src/providers/XPath.ts index b5ddd5e..b0c9f77 100644 --- a/src/providers/XPath.ts +++ b/src/providers/XPath.ts @@ -15,7 +15,7 @@ export class XPathFeatureProvider { let memento: vsc.Memento = ext.WorkspaceState || ext.GlobalState; // get the xpath persistence setting - let persistQueries: boolean = vsc.workspace.getConfiguration(CFG_SECTION).get(CFG_PERSIST_QUERY, true); + let persistQueries: boolean = vsc.workspace.getConfiguration(CFG_SECTION, editor.document.uri).get(CFG_PERSIST_QUERY, true); // get the last query if there is one for this document // if not, try pulling the last query ran, regardless of document @@ -53,7 +53,7 @@ export class XPathFeatureProvider { // showInputBox() will return undefined if the user dimissed the prompt if (query) { - let ignoreDefaultNamespace: boolean = vsc.workspace.getConfiguration(CFG_SECTION).get(CFG_IGNORE_DEFAULT_XMLNS, true); + let ignoreDefaultNamespace: boolean = vsc.workspace.getConfiguration(CFG_SECTION, editor.document.uri).get(CFG_IGNORE_DEFAULT_XMLNS, true); // run the query let xml: string = editor.document.getText();