[add] basexTools.xqLintReport
This commit is contained in:
parent
2b717e39e6
commit
b2f40425e3
13 changed files with 369 additions and 293 deletions
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
export * from "./xquery-linter";
|
||||
export * from "./getAST";
|
||||
export * from "./report";
|
||||
|
|
|
|||
19
src/linting/report.ts
Normal file
19
src/linting/report.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
import { TextEditor } from "vscode";
|
||||
import { XQLint} from "@quodatum/xqlint";
|
||||
import { channel,dump } from "../common/logger";
|
||||
|
||||
|
||||
export function xqLintReport(textEditor: TextEditor): void {
|
||||
const linter = new XQLint(textEditor.document.getText());
|
||||
textEditor.edit(textEdit => {
|
||||
const selections = textEditor.selections;
|
||||
selections.forEach(selection => {
|
||||
const pos=selection.start.translate(1,1); //@TODO
|
||||
const node=linter.getAST(pos);
|
||||
const sctx=linter.getCompletions(pos);
|
||||
const dx=dump(node);
|
||||
channel.appendLine(dx);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { Diagnostic, DiagnosticSeverity, Position, Range } from "vscode";
|
||||
import { XQLint} from "@quodatum/xqlint";
|
||||
|
||||
const XQLint = require("@quodatum/xqlint").XQLint;
|
||||
|
||||
export class XQueryLinter {
|
||||
static SEVERITY_WARNING = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue