Compare commits

...

2 commits

Author SHA1 Message Date
6e5d06b871 [mod] tidy 2023-02-20 10:17:47 +00:00
8d47e56dfa [mod] use xqlint 0.2.0 2023-02-19 18:07:31 +00:00
5 changed files with 211 additions and 1667 deletions

View file

@ -1,5 +1,5 @@
# 0.0.67 (2023-02-09) # 0.1.0 (2023-02-19)
Update xqlint 0.1.2 Update xqlint to 0.2.0
# 0.0.64 (2023-01-26) # 0.0.64 (2023-01-26)
* add simple hover display * add simple hover display

View file

@ -1,7 +1,7 @@
# BaseX Tools for Visual Studio Code # BaseX Tools for Visual Studio Code
The vscode-basex extension adds features to support BaseX development on VSCode. The vscode-basex extension adds features to support [BaseX](https://basex.org/) development on VSCode.
For XQuery For XQuery
* Grammar support for:XQuery 3.1, XQuery update, Full text syntax * Grammar support for:XQuery 3.1, XQuery update, Full text syntax
* code format * code format
@ -10,12 +10,15 @@ For XQuery
* outline symbol view * outline symbol view
## Features ## Features
* [XQuery Linting](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xquery-linting)
* [XQuery Code Completion](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xquery-code-completion)
* [XQuery Execution](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xquery-script-execution)
* [XQuery source formating](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xquery-source-formating)
* [XML Formatting](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xml-formatting) * [XML Formatting](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xml-formatting)
* [XML Tree View](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xml-tree-view) * [XML Tree View](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xml-tree-view)
* [XPath Evaluation](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xpath-evaluation) * [XPath Evaluation](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xpath-evaluation)
* [XQuery Linting](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xquery-linting)
* [XQuery Execution](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xquery-script-execution)
* [XQuery Code Completion](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xquery-code-completion)
## Requirements ## Requirements
* VS Code `1.63.0` or higher * VS Code `1.63.0` or higher
@ -37,11 +40,16 @@ npm install --global vsce
npm run compile npm run compile
vsce package vsce package
``` ```
## Inspiration
This project was created from a fork of [DotJoshJohnson/vscode-xml](https://github.com/DotJoshJohnson/vscode-xml). Much of `DotJoshJohnson/vscode-xml` code dealing with XML has been removed and additional XQuery features added.
The code parsing uses [quodatum/xqlint] which is based on [wcandillon/xqlint]
## Icon Credits ## Icon Credits
Icons used in the XML Tree View are used under the Creative Commons 3.0 BY license. Icons used in the XML Tree View are used under the Creative Commons 3.0 BY license.
* "Code" icon by Dave Gandy from www.flaticon.com * "Code" icon by Dave Gandy from www.flaticon.com
* "At" icon by FreePik from www.flaticon.com * "At" icon by FreePik from www.flaticon.com
## Inspiration
This project was created from a fork of [DotJoshJohnson/vscode-xml](https://github.com/DotJoshJohnson/vscode-xml). Much of `DotJoshJohnson/vscode-xml` code dealing with XML has been removed and additional XQuery features added.

1839
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,7 @@
"name": "vscode-basex", "name": "vscode-basex",
"displayName": "BaseX tools", "displayName": "BaseX tools",
"description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code", "description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code",
"version": "0.0.68", "version": "0.1.0",
"preview": true, "preview": true,
"publisher": "quodatum", "publisher": "quodatum",
"author": "Andy Bunce (https://github.com/Quodatum)", "author": "Andy Bunce (https://github.com/Quodatum)",
@ -317,7 +317,7 @@
"typescript": "^4.7.3" "typescript": "^4.7.3"
}, },
"dependencies": { "dependencies": {
"@quodatum/xqlint": "^0.1.2", "@quodatum/xqlint": "^0.2.0",
"@xmldom/xmldom": "^0.8.1", "@xmldom/xmldom": "^0.8.1",
"xpath": "0.0.32" "xpath": "0.0.32"
} }

View file

@ -2,7 +2,6 @@
import { CancellationToken, Hover, HoverProvider, Position, TextDocument } from "vscode"; import { CancellationToken, Hover, HoverProvider, Position, TextDocument } from "vscode";
import { XQLint} from "@quodatum/xqlint"; import { XQLint} from "@quodatum/xqlint";
import { channel,dump } from "../common/logger";
export class XQueryHoverProvider implements HoverProvider { export class XQueryHoverProvider implements HoverProvider {
public provideHover( public provideHover(
@ -11,16 +10,16 @@ export class XQueryHoverProvider implements HoverProvider {
token: CancellationToken token: CancellationToken
): Hover | null { ): Hover | null {
const linter = new XQLint(document.getText()); const linter = new XQLint(document.getText());
const posx=position.translate(1,1); //@TODO
const node=linter.getAST(posx); const node=linter.getAST(position);
const sctx=linter.getCompletions(posx); //const sctx=linter.getCompletions(position);
channel.log("Hover: " + node.name); //channel.log("Hover: " + node.name);
//const dx=dump(node); //const dx=dump(node);
//channel.appendLine(dx); //channel.appendLine(dx);
const range = document.getWordRangeAtPosition(position); const range = document.getWordRangeAtPosition(position);
const word = document.getText(range); const word = document.getText(range);
return new Hover(`XQuery Hover info: ${word} at ${posx.line}: ${posx.character} return new Hover(`XQuery Hover info: ${word} at ${position.line}: ${position.character}
value: ${ node.value }, name: ${ node.name } value: ${ node.value }, name: ${ node.name }
`); `);