[mod] downgrade errors from current xqlint defects
This commit is contained in:
parent
cad09a9e3f
commit
e590fabce1
11 changed files with 129 additions and 66 deletions
.vscode
CHANGELOG.mdpackage.jsonscripts
snippets.jsoncsrc
@quodatum
common
completion
linting
test/test-data
xquery-execution/commands
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -5,6 +5,5 @@
|
||||||
},
|
},
|
||||||
"search.exclude": {
|
"search.exclude": {
|
||||||
"out": true // set this to false to include "out" folder in search results
|
"out": true // set this to false to include "out" folder in search results
|
||||||
},
|
}
|
||||||
"basexTools.xquery.showHovers": false
|
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
# 0.1.1 (2023-02-21)
|
# 0.1.1 (2023-02-24)
|
||||||
* Add Hover show option
|
* Add setting to control "Hover show"
|
||||||
|
* Add setting to filter out matching diagnostic messages
|
||||||
|
|
||||||
# 0.1.0 (2023-02-19)
|
# 0.1.0 (2023-02-19)
|
||||||
* Update xqlint to 0.2.0
|
* Update xqlint to 0.2.0
|
||||||
|
|
||||||
|
|
111
package.json
111
package.json
|
@ -70,57 +70,32 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"configuration": [
|
"configuration": [
|
||||||
|
|
||||||
{
|
{
|
||||||
"id": "xmltree",
|
"id": "xqueryui",
|
||||||
"title": "XML tree view ",
|
"order": 1,
|
||||||
"properties": {
|
"title": "XQuery UI",
|
||||||
"basexTools.xmlTree.enableTreeView": {
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false,
|
|
||||||
"description": "Enables the XML Document view in the explorer for XML documents.",
|
|
||||||
"scope": "window"
|
|
||||||
},
|
|
||||||
"basexTools.xmlTree.enableViewMetadata": {
|
|
||||||
"type": "boolean",
|
|
||||||
"default": true,
|
|
||||||
"description": "Enables attribute and child element counts in the XML Document view.",
|
|
||||||
"scope": "window"
|
|
||||||
},
|
|
||||||
"basexTools.xmlTree.enableViewCursorSync": {
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false,
|
|
||||||
"description": "Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.",
|
|
||||||
"scope": "window"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "xpath",
|
|
||||||
"title": "XPath ",
|
|
||||||
"properties": {
|
|
||||||
"basexTools.xpath.ignoreDefaultNamespace": {
|
|
||||||
"type": "boolean",
|
|
||||||
"default": true,
|
|
||||||
"description": "Ignore default xmlns attributes when evaluating XPath.",
|
|
||||||
"scope": "window"
|
|
||||||
},
|
|
||||||
"basexTools.xpath.persistXPathQuery": {
|
|
||||||
"type": "boolean",
|
|
||||||
"default": true,
|
|
||||||
"description": "Remember the last XPath query used.",
|
|
||||||
"scope": "window"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "xquery",
|
|
||||||
"title": "XQuery ",
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"basexTools.xquery.showHovers": {
|
"basexTools.xquery.showHovers": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Show hovers in xquery."
|
"description": "Show hovers in xquery. Currently these show just Diagnostic info"
|
||||||
},
|
},
|
||||||
|
"basexTools.xquery.suppressErrors": {
|
||||||
|
"type": "array",
|
||||||
|
"default": [
|
||||||
|
"[XQST0059]",
|
||||||
|
"[XPST0008]"
|
||||||
|
],
|
||||||
|
"description": "Error messages including these strings are marked as info rather than error. TEMP HACK! "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "xqueryexec",
|
||||||
|
"order": 2,
|
||||||
|
"title": "XQuery Execute",
|
||||||
|
"properties": {
|
||||||
"basexTools.xquery.executionArguments": {
|
"basexTools.xquery.executionArguments": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"default": [
|
"default": [
|
||||||
|
@ -154,8 +129,29 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "xpath",
|
||||||
|
"order": 3,
|
||||||
|
"title": "XPath ",
|
||||||
|
"properties": {
|
||||||
|
"basexTools.xpath.ignoreDefaultNamespace": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true,
|
||||||
|
"description": "Ignore default xmlns attributes when evaluating XPath.",
|
||||||
|
"scope": "window"
|
||||||
|
},
|
||||||
|
"basexTools.xpath.persistXPathQuery": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true,
|
||||||
|
"description": "Remember the last XPath query used.",
|
||||||
|
"scope": "window"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"title": "XML edit ",
|
"title": "XML edit ",
|
||||||
|
"order": 4,
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"basexTools.xml.enforcePrettySelfClosingTagOnFormat": {
|
"basexTools.xml.enforcePrettySelfClosingTagOnFormat": {
|
||||||
|
@ -193,6 +189,31 @@
|
||||||
"scope": "window"
|
"scope": "window"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "xmltree",
|
||||||
|
"order": 5,
|
||||||
|
"title": "XML tree view ",
|
||||||
|
"properties": {
|
||||||
|
"basexTools.xmlTree.enableTreeView": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Enables the XML Document view in the explorer for XML documents.",
|
||||||
|
"scope": "window"
|
||||||
|
},
|
||||||
|
"basexTools.xmlTree.enableViewMetadata": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true,
|
||||||
|
"description": "Enables attribute and child element counts in the XML Document view.",
|
||||||
|
"scope": "window"
|
||||||
|
},
|
||||||
|
"basexTools.xmlTree.enableViewCursorSync": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.",
|
||||||
|
"scope": "window"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"grammars": [
|
"grammars": [
|
||||||
|
|
20
scripts/spawn.js
Normal file
20
scripts/spawn.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
function Process() {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
|
const process = require('child_process');
|
||||||
|
var output='';
|
||||||
|
var ls = process.spawn('basex.bat',["current-dateTime()"]);
|
||||||
|
ls.stdout.on('data', function (data) {
|
||||||
|
output+=data;
|
||||||
|
});
|
||||||
|
ls.stderr.on('data', function (data) {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
ls.on('close', function (code) {
|
||||||
|
if (code == 0)
|
||||||
|
console.log(output);
|
||||||
|
else
|
||||||
|
console.log('Error',code);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Process();
|
|
@ -33,7 +33,7 @@
|
||||||
"${3:expr}",
|
"${3:expr}",
|
||||||
"};"
|
"};"
|
||||||
],
|
],
|
||||||
"description": "declare a function"
|
"description": "declare function"
|
||||||
},
|
},
|
||||||
"declare variable": {
|
"declare variable": {
|
||||||
"prefix": "dv",
|
"prefix": "dv",
|
||||||
|
|
20
src/@quodatum/xqlint.d.ts
vendored
20
src/@quodatum/xqlint.d.ts
vendored
|
@ -1,20 +1,28 @@
|
||||||
|
|
||||||
declare module '@quodatum/xqlint'{
|
declare module '@quodatum/xqlint'{
|
||||||
import { Position } from "vscode";
|
import { Position, Range } from "vscode";
|
||||||
export class XQLint{
|
export class XQLint{
|
||||||
constructor(source :string, opts? :object);
|
constructor(source :string, opts? :object);
|
||||||
public getCompletions(pos :object): [object];
|
public getCompletions(pos :Position): [object];
|
||||||
public getXQDoc() :XQDoc;
|
public getXQDoc() :XQDoc;
|
||||||
public getAST(pos? :Position) :any;
|
public getAST(pos? :Position) :any;
|
||||||
public getSctx(pos? :Position) :any;
|
public getSctx(pos? :Position) :any;
|
||||||
public getErrors() :[Marker];
|
public getErrors() :[Marker];
|
||||||
public getWarnings() :[Marker];
|
public getWarnings() :[Marker];
|
||||||
}
|
}
|
||||||
|
//
|
||||||
export class Marker{
|
export class Marker{
|
||||||
pos: Position;
|
pos: LintRange;
|
||||||
type: string;
|
type: string; // error,warning
|
||||||
level: string;
|
level: string; //same as type??
|
||||||
message: string;
|
message: string; // '[code] ...'
|
||||||
|
}
|
||||||
|
|
||||||
|
export class LintRange{
|
||||||
|
sl: number;
|
||||||
|
sc: number;
|
||||||
|
el: number;
|
||||||
|
ec: number;
|
||||||
}
|
}
|
||||||
export class XQDoc{
|
export class XQDoc{
|
||||||
moduleNamespace: string;
|
moduleNamespace: string;
|
||||||
|
|
|
@ -31,6 +31,10 @@ export class Configuration {
|
||||||
return this._getForWindow<string[]>("xquery.executionArguments");
|
return this._getForWindow<string[]>("xquery.executionArguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get xquerySuppressErrors(): string[] {
|
||||||
|
return this._getForWindow<string[]>("xquery.suppressErrors");
|
||||||
|
}
|
||||||
|
|
||||||
static get xqueryExecutionEngine(): string {
|
static get xqueryExecutionEngine(): string {
|
||||||
return this._getForWindow<string>("xquery.executionEngine");
|
return this._getForWindow<string>("xquery.executionEngine");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ export class XQueryCompletionItemProvider implements CompletionItemProvider {
|
||||||
const completionItems = new Array<CompletionItem>();
|
const completionItems = new Array<CompletionItem>();
|
||||||
const linter = new XQLint(document.getText());
|
const linter = new XQLint(document.getText());
|
||||||
|
|
||||||
linter.getCompletions({ line: position.line, col: position.character }).forEach((x: any) => {
|
linter.getCompletions(position).forEach((x: any) => {
|
||||||
completionItems.push(this._getCompletionItem(x));
|
completionItems.push(this._getCompletionItem(x));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,29 @@
|
||||||
|
// convert xqlint markers
|
||||||
import { Diagnostic, DiagnosticSeverity, Position, Range } from "vscode";
|
import { Diagnostic, DiagnosticSeverity, Position, Range } from "vscode";
|
||||||
import { XQLint} from "@quodatum/xqlint";
|
import { Marker, XQLint } from "@quodatum/xqlint";
|
||||||
|
import { Configuration } from "../common";
|
||||||
|
|
||||||
|
// [XQST0059] module "http://www.rave-tech.com/bloomsbury/config" not found
|
||||||
|
// [XPST0008] "list-details#0": undeclared function
|
||||||
|
function isSuppressed(msg: string): boolean {
|
||||||
|
const errs = Configuration.xquerySuppressErrors;
|
||||||
|
return errs.some((x) => msg.includes(x));
|
||||||
|
}
|
||||||
|
|
||||||
export class XQueryLinter {
|
export class XQueryLinter {
|
||||||
static SEVERITY_WARNING = 1;
|
|
||||||
static SEVERITY_ERROR = 2;
|
|
||||||
|
|
||||||
lint(text: string): Diagnostic[] {
|
lint(text: string): Diagnostic[] {
|
||||||
const linter = new XQLint(text);
|
const linter = new XQLint(text);
|
||||||
const diagnostics = new Array<Diagnostic>();
|
const diagnostics = new Array<Diagnostic>();
|
||||||
|
|
||||||
linter.getErrors().forEach((error: any) => {
|
linter.getErrors().forEach((error: Marker) => {
|
||||||
diagnostics.push(new Diagnostic(
|
diagnostics.push(new Diagnostic(
|
||||||
new Range(
|
new Range(
|
||||||
new Position(error.pos.sl, error.pos.sc),
|
new Position(error.pos.sl, error.pos.sc),
|
||||||
new Position(error.pos.el, error.pos.ec)
|
new Position(error.pos.el, error.pos.ec)
|
||||||
),
|
),
|
||||||
error.message,
|
error.message,
|
||||||
DiagnosticSeverity.Error
|
isSuppressed(error.message) ? DiagnosticSeverity.Information : DiagnosticSeverity.Error
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -31,7 +37,7 @@ export class XQueryLinter {
|
||||||
DiagnosticSeverity.Warning
|
DiagnosticSeverity.Warning
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
return diagnostics;
|
return diagnostics;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
src/test/test-data/simple-execute.xq
Normal file
2
src/test/test-data/simple-execute.xq
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
(: https://stackoverflow.com/questions/21557461/execute-a-batch-file-from-nodejs :)
|
||||||
|
fn:current-dateTime()
|
|
@ -2,14 +2,14 @@ import { window, workspace } from "vscode";
|
||||||
import { Disposable, Range, TextEditor, TextEditorEdit, Uri } from "vscode";
|
import { Disposable, Range, TextEditor, TextEditorEdit, Uri } from "vscode";
|
||||||
|
|
||||||
import * as constants from "../../constants";
|
import * as constants from "../../constants";
|
||||||
|
import { channel } from "../../common/logger";
|
||||||
import { ChildProcess } from "../child-process";
|
import { ChildProcess } from "../child-process";
|
||||||
import { Configuration, NativeCommands } from "../../common";
|
import { Configuration, NativeCommands } from "../../common";
|
||||||
|
|
||||||
export async function executeXQuery(editor: TextEditor, edit: TextEditorEdit): Promise<void> {
|
export async function executeXQuery(editor: TextEditor, edit: TextEditorEdit): Promise<void> {
|
||||||
// this disposable will be used for creating status bar messages
|
// this disposable will be used for creating status bar messages
|
||||||
let disposable: Disposable;
|
let disposable: Disposable;
|
||||||
|
channel.log("executeXQuery");
|
||||||
if (editor.document.languageId !== constants.languageIds.xquery) {
|
if (editor.document.languageId !== constants.languageIds.xquery) {
|
||||||
window.showErrorMessage("This action can only be performed on an XQuery file.");
|
window.showErrorMessage("This action can only be performed on an XQuery file.");
|
||||||
return;
|
return;
|
||||||
|
@ -103,7 +103,8 @@ export async function executeXQuery(editor: TextEditor, edit: TextEditorEdit): P
|
||||||
.replace("$(input)", inputFile.fsPath)
|
.replace("$(input)", inputFile.fsPath)
|
||||||
.replace("$(project)", (workspace.workspaceFolders) ? workspace.workspaceFolders[0].uri.fsPath : "");
|
.replace("$(project)", (workspace.workspaceFolders) ? workspace.workspaceFolders[0].uri.fsPath : "");
|
||||||
});
|
});
|
||||||
|
channel.log(executable);
|
||||||
|
channel.log(args.toString());
|
||||||
try {
|
try {
|
||||||
await ChildProcess.spawn(executable, args);
|
await ChildProcess.spawn(executable, args);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue