[mod] release 0.5.2

This commit is contained in:
Andy Bunce 2022-06-07 16:29:12 +01:00
parent cfc8ba3817
commit 47baf6f2b9
13 changed files with 243 additions and 66 deletions

View file

@ -11,7 +11,7 @@ export class Configuration {
return this._getForWindow<boolean>("xmlTree.enableViewMetadata");
}
static get enableViewCursorSync(): boolean {
static get enableXmlTreeViewCursorSync(): boolean {
return this._getForWindow<boolean>("xmlTree.enableViewCursorSync");
}
@ -28,19 +28,19 @@ export class Configuration {
}
static get xqueryExecutionArguments(): string[] {
return this._getForWindow<string[]>("xqueryExecutionArguments");
return this._getForWindow<string[]>("xquery.executionArguments");
}
static get xqueryExecutionEngine(): string {
return this._getForWindow<string>("xqueryExecutionEngine");
return this._getForWindow<string>("xquery.executionEngine");
}
static get xqueryExecutionInputLimit(): number {
return this._getForWindow<number>("xqueryExecutionInputLimit");
return this._getForWindow<number>("xquery.executionInputLimit");
}
static get xqueryExecutionInputSearchPattern(): string {
return this._getForWindow<string>("xqueryExecutionInputSearchPattern");
return this._getForWindow<string>("xquery.executionInputSearchPattern");
}
static enforcePrettySelfClosingTagOnFormat(resource: Uri): boolean {

View file

@ -4,6 +4,7 @@ import { OutputChannel, window } from "vscode";
const ver = require("@quodatum/xqlint").version;
const _channel:OutputChannel = window.createOutputChannel("BaseX");
function logdate(){
return (new Date()).toISOString().slice(0, 19).replace(/-/g, "/").replace("T", " ");
}

View file

@ -7,6 +7,7 @@ export namespace commands {
export const textToXml = "basexTools.textToXml";
export const getCurrentXPath = "basexTools.getCurrentXPath";
export const minifyXml = "basexTools.minifyXml";
export const getAST = "basexTools.getAST";
}
export namespace contextKeys {

View file

@ -7,8 +7,8 @@ import { channel } from "./common/logger";
import { createDocumentSelector, ExtensionState, Configuration } from "./common";
import { XQueryCompletionItemProvider } from "./completion";
import { XmlFormatterFactory, XmlFormattingEditProvider } from "./formatting";
import { formatAsXml, minifyXml, xmlToText, textToXml } from "./formatting/commands";
import { XQueryLinter } from "./linting";
import { formatAsXml, minifyXml, xmlToText, textToXml } from "./formatting/commands";
import { XQueryLinter,getAst } from "./linting";
import { XmlTreeDataProvider } from "./tree-view";
import { evaluateXPath, getCurrentXPath } from "./xpath/commands";
import { executeXQuery } from "./xquery-execution/commands";
@ -39,6 +39,7 @@ export function activate(context: ExtensionContext) {
commands.registerTextEditorCommand(constants.commands.xmlToText, xmlToText),
commands.registerTextEditorCommand(constants.commands.textToXml, textToXml),
commands.registerTextEditorCommand(constants.commands.minifyXml, minifyXml),
commands.registerTextEditorCommand(constants.commands.getAST, getAst),
languages.registerDocumentFormattingEditProvider(xmlXsdDocSelector, xmlFormattingEditProvider),
languages.registerDocumentRangeFormattingEditProvider(xmlXsdDocSelector, xmlFormattingEditProvider),

View file

@ -2,3 +2,4 @@ export * from "./formatAsXml";
export * from "./minifyXml";
export * from "./xmlToText";

View file

@ -27,7 +27,7 @@ export class XQueryFormatter implements DocumentFormattingEditProvider, Document
provideDocumentRangeFormattingEdits(document: TextDocument, range: Range, _options: FormattingOptions, _token: CancellationToken): ProviderResult<TextEdit[]> {
const selected = document.getText(range);
const result = format(selected);
const result = format(selected, document);
return [TextEdit.replace(range, result)];
}
}

23
src/linting/getAST.ts Normal file
View file

@ -0,0 +1,23 @@
import { Range, TextEditor, Selection } from "vscode";
import { channel } from "../common/logger";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const XQLint = require("@quodatum/xqlint").XQLint;
export function getAst(textEditor: TextEditor): void {
textEditor.edit(textEdit => {
const selections = textEditor.selections;
selections.forEach(selection => {
if (selection.isEmpty) {
selection = new Selection(
textEditor.document.positionAt(0),
textEditor.document.positionAt(textEditor.document.getText().length)
);
}
const text = textEditor.document.getText(new Range(selection.start, selection.end));
const linter = new XQLint(text);
const ast=linter.getAST();
channel.appendLine(ast);
});
});
}

View file

@ -1 +1,2 @@
export * from "./xquery-linter";
export * from "./getAST";

View file

@ -1,44 +1,56 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { XQLint } from '@quodatum/xqlint';
import * as vscode from 'vscode';
import {SymbolKind, DocumentSymbol, DocumentSymbolProvider,
Range, Position, TextDocument,CancellationToken} from 'vscode';
import { channel } from "../common/logger";
//
// This class handles Symbols
//
function makeSymbol(name: string, description: string, icon: vscode.SymbolKind, pos: any) {
const spos = new vscode.Position(pos.sl, pos.sc);
const epos = new vscode.Position(pos.el, pos.ec);
const fullrange = new vscode.Range(spos, epos);
const selrange = new vscode.Range(spos, spos);
return new vscode.DocumentSymbol(name, description, icon, fullrange, selrange);
function makeSymbol(name: string, description: string, icon: SymbolKind, pos: any) {
const spos = new Position(pos.sl, pos.sc);
const epos = new Position(pos.el, pos.ec);
const fullrange = new Range(spos, epos);
const selrange = new Range(spos, spos);
return new DocumentSymbol(name, description, icon, fullrange, selrange);
}
export class Symbols implements vscode.DocumentSymbolProvider {
export class Symbols implements DocumentSymbolProvider {
provideDocumentSymbols = async (
document: vscode.TextDocument,
token: vscode.CancellationToken
): Promise<vscode.DocumentSymbol[]> => {
document: TextDocument,
token: CancellationToken
): Promise<DocumentSymbol[]> => {
channel.log("Symbols: " + document.uri);
const symbols: vscode.DocumentSymbol[] = [];
const symbols: DocumentSymbol[] = [];
const text = document.getText();
const linter = new (XQLint as any)(text, { "styleCheck": false });
const xqdoc = linter.getXQDoc();
channel.log("got xqdoc");
const prolog=new Range(0,0,0,0)
symbols.push(makeSymbol(xqdoc.moduleNamespace || "Main", xqdoc.description, SymbolKind.Module, prolog))
let vars=makeSymbol("Variables", "", SymbolKind.Variable, prolog)
vars.children=[]
// type: type,
// pos: pos,
// qname: qname,
// annotations: {}
xqdoc.variables.forEach(v => {
const name = v.name;
const info = makeSymbol(name, "var", vscode.SymbolKind.Variable, v.pos)
symbols.push(info);
const info = makeSymbol(name, "", SymbolKind.Variable, v.pos)
vars.children.push(info);
});
const funs=makeSymbol("Variables", "", SymbolKind.Function, prolog)
funs.children=[]
xqdoc.functions.forEach(v => {
const name = v.name;
const info = makeSymbol(name, "Fu", vscode.SymbolKind.Function, v.pos)
symbols.push(info);
const name = v.name +"#" + v.params.length;
const info = makeSymbol(name, "", SymbolKind.Function, v.pos)
funs.children.push(info);
});
symbols.push(vars)
symbols.push(funs)
channel.log("Symbols done " + document.uri);
return symbols;
};

View file

@ -1,4 +1,4 @@
const child_process = require("child_process");
import child_process = require("child_process");
export class ChildProcess {
static async spawn(executable: string, args: string[]): Promise<void> {