parent
751e7a7e07
commit
939569a5d2
@ -156,13 +156,13 @@
|
|||||||
"description": "Command-line arguments to pass to the executable.",
|
"description": "Command-line arguments to pass to the executable.",
|
||||||
"scope": "application"
|
"scope": "application"
|
||||||
},
|
},
|
||||||
"xmlTools.xquery.inputFileLimit": {
|
"xmlTools.xquery.inputFilesLimit": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"default": 100,
|
"default": 100,
|
||||||
"description": "The maximum number of input files to enumerate.",
|
"description": "The maximum number of input files to enumerate.",
|
||||||
"scope": "application"
|
"scope": "application"
|
||||||
},
|
},
|
||||||
"xmlTools.xquery.inputFileSearchPattern": {
|
"xmlTools.xquery.inputFilesSearchPattern": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "**/*.xml",
|
"default": "**/*.xml",
|
||||||
"description": "The pattern used to search for input XML files.",
|
"description": "The pattern used to search for input XML files.",
|
||||||
|
@ -1,69 +1,78 @@
|
|||||||
import { workspace, Uri } from "vscode";
|
import { workspace, Uri } from "vscode";
|
||||||
|
|
||||||
const ExtensionTopLevelSection = "xmlTools";
|
const ExtensionTopLevelSection = "xmlTools";
|
||||||
|
const UseNewSettingsSection = "core.useNewSettings";
|
||||||
|
|
||||||
export class Configuration {
|
export class Configuration {
|
||||||
static get enableXmlTreeView(): boolean {
|
static get treeViewEnabled(): boolean {
|
||||||
return this._getForWindow<boolean>("enableXmlTreeView");
|
return this._getForWindow<boolean>("treeView.enabled", "enableXmlTreeView");
|
||||||
}
|
}
|
||||||
|
|
||||||
static get enableXmlTreeViewMetadata(): boolean {
|
static get treeViewShowMetadata(): boolean {
|
||||||
return this._getForWindow<boolean>("enableXmlTreeViewMetadata");
|
return this._getForWindow<boolean>("treeView.showMetadata", "enableXmlTreeViewMetadata");
|
||||||
}
|
}
|
||||||
|
|
||||||
static get enableXmlTreeViewCursorSync(): boolean {
|
static get treeViewSyncCursor(): boolean {
|
||||||
return this._getForWindow<boolean>("enableXmlTreeViewCursorSync");
|
return this._getForWindow<boolean>("treeView.syncCursor", "enableXmlTreeViewCursorSync");
|
||||||
}
|
}
|
||||||
|
|
||||||
static get ignoreDefaultNamespace(): boolean {
|
static get xpathIgnoreDefaultNamespace(): boolean {
|
||||||
return this._getForWindow<boolean>("ignoreDefaultNamespace");
|
return this._getForWindow<boolean>("xpath.ignoreDefaultNamespace", "ignoreDefaultNamespace");
|
||||||
}
|
}
|
||||||
|
|
||||||
static get persistXPathQuery(): boolean {
|
static get xpathRememberLastQuery(): boolean {
|
||||||
return this._getForWindow<boolean>("persistXPathQuery");
|
return this._getForWindow<boolean>("xpath.rememberLastQuery", "persistXPathQuery");
|
||||||
}
|
}
|
||||||
|
|
||||||
static get xmlFormatterImplementation(): string {
|
static get formatterImplementation(): string {
|
||||||
return this._getForWindow<string>("xmlFormatterImplementation");
|
return this._getForWindow<string>("formatter.implementation", "xmlFormatterImplementation");
|
||||||
}
|
}
|
||||||
|
|
||||||
static get xqueryExecutionArguments(): string[] {
|
static get xqueryExecutableArgs(): string[] {
|
||||||
return this._getForWindow<string[]>("xqueryExecutionArguments");
|
return this._getForWindow<string[]>("xquery.executableArgs", "xqueryExecutionArguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
static get xqueryExecutionEngine(): string {
|
static get xqueryExecutable(): string {
|
||||||
return this._getForWindow<string>("xqueryExecutionEngine");
|
return this._getForWindow<string>("xquery.executable", "xqueryExecutionEngine");
|
||||||
}
|
}
|
||||||
|
|
||||||
static get xqueryExecutionInputLimit(): number {
|
static get xqueryInputFilesLimit(): number {
|
||||||
return this._getForWindow<number>("xqueryExecutionInputLimit");
|
return this._getForWindow<number>("xquery.inputFilesLimit", "xqueryExecutionInputLimit");
|
||||||
}
|
}
|
||||||
|
|
||||||
static get xqueryExecutionInputSearchPattern(): string {
|
static get xqueryInputFilesSearchPattern(): string {
|
||||||
return this._getForWindow<string>("xqueryExecutionInputSearchPattern");
|
return this._getForWindow<string>("xquery.inputFilesSearchPattern", "xqueryExecutionInputSearchPattern");
|
||||||
}
|
}
|
||||||
|
|
||||||
static enforcePrettySelfClosingTagOnFormat(resource: Uri): boolean {
|
static formatterAddSpaceBeforeSelfClose(resource: Uri): boolean {
|
||||||
return this._getForResource<boolean>("enforcePrettySelfClosingTagOnFormat", resource);
|
return this._getForResource<boolean>("formatter.addSpaceBeforeSelfClose", resource, "enforcePrettySelfClosingTagOnFormat");
|
||||||
}
|
}
|
||||||
|
|
||||||
static removeCommentsOnMinify(resource: Uri): boolean {
|
static formatterRemoveCommentsOnMinify(resource: Uri): boolean {
|
||||||
return this._getForResource<boolean>("removeCommentsOnMinify", resource);
|
return this._getForResource<boolean>("formatter.removeCommentsOnMinify", resource, "removeCommentsOnMinify");
|
||||||
}
|
}
|
||||||
|
|
||||||
static splitAttributesOnFormat(resource: Uri): boolean {
|
static formatterSplitAttributes(resource: Uri): boolean {
|
||||||
return this._getForResource<boolean>("splitAttributesOnFormat", resource);
|
return this._getForResource<boolean>("formatter.splitAttributes", resource, "splitAttributesOnFormat");
|
||||||
}
|
}
|
||||||
|
|
||||||
static splitXmlnsOnFormat(resource: Uri): boolean {
|
static formatterSplitXmlnsAttributes(resource: Uri): boolean {
|
||||||
return this._getForResource<boolean>("splitXmlnsOnFormat", resource);
|
return this._getForResource<boolean>("formatter.splitXmlnsAttributes", resource, "splitXmlnsOnFormat");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static _getForResource<T>(section: string, resource: Uri): T {
|
private static _getForResource<T>(section: string, resource: Uri, oldSection?: string): T {
|
||||||
|
if (oldSection && !workspace.getConfiguration(ExtensionTopLevelSection).get<boolean>(UseNewSettingsSection)) {
|
||||||
|
section = oldSection;
|
||||||
|
}
|
||||||
|
|
||||||
return workspace.getConfiguration(ExtensionTopLevelSection, resource).get<T>(section);
|
return workspace.getConfiguration(ExtensionTopLevelSection, resource).get<T>(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static _getForWindow<T>(section: string): T {
|
private static _getForWindow<T>(section: string, oldSection?: string): T {
|
||||||
|
if (oldSection && !workspace.getConfiguration(ExtensionTopLevelSection).get<boolean>(UseNewSettingsSection)) {
|
||||||
|
section = oldSection;
|
||||||
|
}
|
||||||
|
|
||||||
return workspace.getConfiguration(ExtensionTopLevelSection).get<T>(section);
|
return workspace.getConfiguration(ExtensionTopLevelSection).get<T>(section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ export function activate(context: ExtensionContext) {
|
|||||||
treeDataProvider: treeViewDataProvider
|
treeDataProvider: treeViewDataProvider
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Configuration.enableXmlTreeViewCursorSync) {
|
if (Configuration.treeViewSyncCursor) {
|
||||||
window.onDidChangeTextEditorSelection(x => {
|
window.onDidChangeTextEditorSelection(x => {
|
||||||
if (x.kind === TextEditorSelectionChangeKind.Mouse && x.selections.length > 0) {
|
if (x.kind === TextEditorSelectionChangeKind.Mouse && x.selections.length > 0) {
|
||||||
treeView.reveal(treeViewDataProvider.getNodeAtPosition(x.selections[0].start));
|
treeView.reveal(treeViewDataProvider.getNodeAtPosition(x.selections[0].start));
|
||||||
|
@ -20,7 +20,7 @@ export class XmlFormatterFactory {
|
|||||||
return XmlFormatterFactory._xmlFormatter;
|
return XmlFormatterFactory._xmlFormatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
const xmlFormatterImplementationSetting = Configuration.xmlFormatterImplementation;
|
const xmlFormatterImplementationSetting = Configuration.formatterImplementation;
|
||||||
let xmlFormatterImplementation: XmlFormatter;
|
let xmlFormatterImplementation: XmlFormatter;
|
||||||
|
|
||||||
switch (xmlFormatterImplementationSetting) {
|
switch (xmlFormatterImplementationSetting) {
|
||||||
|
@ -16,11 +16,11 @@ export class XmlFormattingOptionsFactory {
|
|||||||
static getXmlFormattingOptions(formattingOptions: FormattingOptions, document: TextDocument): XmlFormattingOptions {
|
static getXmlFormattingOptions(formattingOptions: FormattingOptions, document: TextDocument): XmlFormattingOptions {
|
||||||
return {
|
return {
|
||||||
editorOptions: formattingOptions,
|
editorOptions: formattingOptions,
|
||||||
enforcePrettySelfClosingTagOnFormat: Configuration.enforcePrettySelfClosingTagOnFormat(document.uri),
|
enforcePrettySelfClosingTagOnFormat: Configuration.formatterAddSpaceBeforeSelfClose(document.uri),
|
||||||
newLine: (document.eol === EndOfLine.CRLF) ? "\r\n" : "\n",
|
newLine: (document.eol === EndOfLine.CRLF) ? "\r\n" : "\n",
|
||||||
removeCommentsOnMinify: Configuration.removeCommentsOnMinify(document.uri),
|
removeCommentsOnMinify: Configuration.formatterRemoveCommentsOnMinify(document.uri),
|
||||||
splitAttributesOnFormat: Configuration.splitAttributesOnFormat(document.uri),
|
splitAttributesOnFormat: Configuration.formatterSplitAttributes(document.uri),
|
||||||
splitXmlnsOnFormat: Configuration.splitXmlnsOnFormat(document.uri)
|
splitXmlnsOnFormat: Configuration.formatterSplitXmlnsAttributes(document.uri)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,8 @@ export class XmlTreeDataProvider implements TreeDataProvider<any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTreeItem(element: Node): TreeItem | Thenable<TreeItem> {
|
getTreeItem(element: Node): TreeItem | Thenable<TreeItem> {
|
||||||
const enableMetadata = Configuration.enableXmlTreeViewMetadata;
|
const enableMetadata = Configuration.treeViewShowMetadata;
|
||||||
const enableSync = Configuration.enableXmlTreeViewCursorSync;
|
const enableSync = Configuration.treeViewSyncCursor;
|
||||||
|
|
||||||
const treeItem = new TreeItem(element.localName);
|
const treeItem = new TreeItem(element.localName);
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ export class XmlTreeDataProvider implements TreeDataProvider<any> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const enableTreeView = Configuration.enableXmlTreeView;
|
const enableTreeView = Configuration.treeViewEnabled;
|
||||||
|
|
||||||
NativeCommands.setContext(constants.contextKeys.xmlTreeViewEnabled, enableTreeView);
|
NativeCommands.setContext(constants.contextKeys.xmlTreeViewEnabled, enableTreeView);
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ export async function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): P
|
|||||||
const memento = ExtensionState.workspace || ExtensionState.global;
|
const memento = ExtensionState.workspace || ExtensionState.global;
|
||||||
|
|
||||||
// get the xpath persistence setting
|
// get the xpath persistence setting
|
||||||
const persistQueries = Configuration.persistXPathQuery;
|
const persistQueries = Configuration.xpathRememberLastQuery;
|
||||||
|
|
||||||
// get the last query if there is one for this document
|
// get the last query if there is one for this document
|
||||||
// if not, try pulling the last query ran, regardless of 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ignoreDefaultNamespace = Configuration.ignoreDefaultNamespace;
|
const ignoreDefaultNamespace = Configuration.xpathIgnoreDefaultNamespace;
|
||||||
|
|
||||||
// run the query
|
// run the query
|
||||||
const xml = editor.document.getText();
|
const xml = editor.document.getText();
|
||||||
|
@ -15,8 +15,8 @@ export async function executeXQuery(editor: TextEditor, edit: TextEditorEdit): P
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const executable = Configuration.xqueryExecutionEngine;
|
const executable = Configuration.xqueryExecutable;
|
||||||
let args = Configuration.xqueryExecutionArguments || [];
|
let args = Configuration.xqueryExecutableArgs || [];
|
||||||
|
|
||||||
if (!executable || executable === "") {
|
if (!executable || executable === "") {
|
||||||
const action = await window.showWarningMessage("An XQuery execution engine has not been defined.", "Define Now");
|
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;
|
let inputFile: Uri;
|
||||||
disposable = window.setStatusBarMessage("Searching for XML files in folder...");
|
disposable = window.setStatusBarMessage("Searching for XML files in folder...");
|
||||||
|
|
||||||
const searchPattern = Configuration.xqueryExecutionInputSearchPattern;
|
const searchPattern = Configuration.xqueryInputFilesSearchPattern;
|
||||||
const inputLimit = Configuration.xqueryExecutionInputLimit;
|
const inputLimit = Configuration.xqueryInputFilesLimit;
|
||||||
|
|
||||||
const files = await workspace.findFiles(searchPattern, "", inputLimit);
|
const files = await workspace.findFiles(searchPattern, "", inputLimit);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user