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