From 6d074b29c921f2899ebd8a03c3b5c8e430b4ba50 Mon Sep 17 00:00:00 2001 From: andy bunce Date: Thu, 26 Jan 2023 11:32:14 +0000 Subject: [PATCH] [mod] v0.0.64 --- CHANGELOG.md | 13 ++++++++++--- README.md | 14 +++++++++----- languages/xquery/xquery.json | 17 ++++------------- package.json | 2 +- src/@quodatum/xqlint.d.ts | 18 ++++++++++++++---- src/CHANGELOG.md | 7 ------- src/extension.ts | 4 ++++ .../formatters/classic-xml-formatter.ts | 4 ++-- src/hover/hover.ts | 17 +++++++++++++++++ src/symbols/symbols.ts | 14 +++----------- 10 files changed, 64 insertions(+), 46 deletions(-) delete mode 100644 src/CHANGELOG.md create mode 100644 src/hover/hover.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 166dc6e..38165c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ -Detailed release notes are available [here](https://git.quodatum.duckdns.org/apb/vscode-basex/releases). +# 0.0.64 (2023-01-26) +* add simple hover display +* Update `xqlint.d.ts` to support newer `tsc.exe`. This reduces size of vsix from 600kb to 300kb + +# 0.0.58 +* use xqlint 0.0.14 + +# 0.0.48 +* Fix xmlToText #6 +* FIX outline all vars -* 0.0.54 -* 0.0.52 typescript fixes \ No newline at end of file diff --git a/README.md b/README.md index 60241a4..904333e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,13 @@ # BaseX Tools for Visual Studio Code -This project was originally a fork of https://github.com/DotJoshJohnson/vscode-xml -This extension adds features to support BaseX development on VSCode. -* XQuery 3.1, XQuery update, Full text syntax support -* XQuery code format + +The vscode-basex extension adds features to support BaseX development on VSCode. +For XQuery +* Grammar support for:XQuery 3.1, XQuery update, Full text syntax +* code format +* code completion +* code snippets +* outline symbol view ## Features * [XML Formatting](https://git.quodatum.duckdns.org/apb/vscode-basex/wiki/xml-formatting) @@ -40,4 +44,4 @@ Icons used in the XML Tree View are used under the Creative Commons 3.0 BY licen ## Inspiration -This is built on a fork of [DotJoshJohnson/vscode-xml](https://github.com/DotJoshJohnson/vscode-xml). \ No newline at end of file +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. \ No newline at end of file diff --git a/languages/xquery/xquery.json b/languages/xquery/xquery.json index 1ce9409..e4c37eb 100644 --- a/languages/xquery/xquery.json +++ b/languages/xquery/xquery.json @@ -1,20 +1,11 @@ { "comments": { "lineComment": ["(:", ":)"], - "blockComment": [ "(:~", "~:)"] + "blockComment": [ "(:", ":)"] }, "brackets": [ - [ - "{", - "}" - ], - [ - "[", - "]" - ], - [ - "(", - ")" - ] + [ "{", "}" ], + [ "[", "]" ], + [ "(", ")" ] ] } diff --git a/package.json b/package.json index 6dd526f..40baf46 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-basex", "displayName": "BaseX tools", "description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code", - "version": "0.0.63", + "version": "0.0.64", "preview": true, "publisher": "quodatum", "author": "Andy Bunce (https://github.com/Quodatum)", diff --git a/src/@quodatum/xqlint.d.ts b/src/@quodatum/xqlint.d.ts index 087041e..293868a 100644 --- a/src/@quodatum/xqlint.d.ts +++ b/src/@quodatum/xqlint.d.ts @@ -2,15 +2,25 @@ declare module '@quodatum/xqlint'{ export class XQLint{ constructor(source :string, opts? :object); public getCompletions(pos :object): [object]; - public getXQDoc() :XQdoc; + public getXQDoc() :XQDoc; } + export interface VarType { + name: string; + pos: any; + } + + export interface FunType { + name: string; + params: string[]; // name + pos: boolean; + } export class XQDoc{ moduleNamespace: string; description: string; - variables: [object]; - functions: [object]; + variables: [VarType]; + functions: [FunType]; } - export function XQueryLexer() :any; + export function XQueryLexer() :any; export function createStaticContext(processor :string) :any; export function CodeFormatter(ast :object) :any; export function CodeFormatter(ast :object, newLinesEnabled :boolean, DEBUG :any) :any; diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md deleted file mode 100644 index fa8a961..0000000 --- a/src/CHANGELOG.md +++ /dev/null @@ -1,7 +0,0 @@ -# 0.0.58 -* use xqlint 0.0.14 -# 0.0.48 -* Fix xmlToText #6 -* FIX outline all vars - -# 0.0.47 diff --git a/src/extension.ts b/src/extension.ts index 6efe5f9..77df272 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -16,6 +16,7 @@ import { executeXQuery } from "./xquery-execution/commands"; import * as constants from "./constants"; import { XQueryFormatter } from "./formatting/xquery-formatting-provider"; import { Symbols } from './symbols/symbols'; +import { XQueryHoverProvider } from './hover/hover'; let diagnosticCollectionXQuery: DiagnosticCollection; @@ -53,6 +54,9 @@ export function activate(context: ExtensionContext) { // symbols const symbols = new Symbols(); context.subscriptions.push(languages.registerDocumentSymbolProvider(constants.languageIds.xquery, symbols)); + // hover + const hover = new XQueryHoverProvider(); + context.subscriptions.push(languages.registerHoverProvider(constants.languageIds.xquery, hover)); /* Linting Features */ diagnosticCollectionXQuery = languages.createDiagnosticCollection(constants.diagnosticCollections.xquery); diff --git a/src/formatting/formatters/classic-xml-formatter.ts b/src/formatting/formatters/classic-xml-formatter.ts index d5bc8d0..970e35e 100644 --- a/src/formatting/formatters/classic-xml-formatter.ts +++ b/src/formatting/formatters/classic-xml-formatter.ts @@ -9,8 +9,8 @@ export class ClassicXmlFormatter implements XmlFormatter { if (options.splitXmlnsOnFormat) { xml = xml - .replace(/xmlns\:/g, "~::~xmlns:") - .replace(/xmlns\=/g, "~::~xmlns="); + .replace(/xmlns:/g, "~::~xmlns:") + .replace(/xmlns=/g, "~::~xmlns="); } const parts: string[] = xml.split("~::~"); diff --git a/src/hover/hover.ts b/src/hover/hover.ts new file mode 100644 index 0000000..cc7fc69 --- /dev/null +++ b/src/hover/hover.ts @@ -0,0 +1,17 @@ +// xquery hover + +import { CancellationToken, Hover, HoverProvider, Position, TextDocument } from "vscode"; +import { channel } from "../common/logger"; + +export class XQueryHoverProvider implements HoverProvider { + public provideHover( + document: TextDocument, + position: Position, + token: CancellationToken + ): Hover | null { + const range = document.getWordRangeAtPosition(position); + const word = document.getText(range); + return new Hover(`Hover info: ${word} at ${position.line}: ${position.character}`); + // return null; if there is no information to show + } +} diff --git a/src/symbols/symbols.ts b/src/symbols/symbols.ts index ffc655e..be032a4 100644 --- a/src/symbols/symbols.ts +++ b/src/symbols/symbols.ts @@ -1,10 +1,10 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import { XQLint } from '@quodatum/xqlint'; +import { VarType, FunType, XQLint } from '@quodatum/xqlint'; import {SymbolKind, DocumentSymbol, DocumentSymbolProvider, Range, Position, TextDocument,CancellationToken} from 'vscode'; import { channel } from "../common/logger"; // -// This class handles Symbols +// This class handles XQuery Symbols // function makeSymbol(name: string, description: string, icon: SymbolKind, pos: any) { const spos = new Position(pos.sl, pos.sc); @@ -13,15 +13,7 @@ function makeSymbol(name: string, description: string, icon: SymbolKind, pos: an const selrange = new Range(spos, spos); return new DocumentSymbol(name, description, icon, fullrange, selrange); } -export type VarType = { - name: string; - pos: any; -}; -export type FunType = { - name: string; - params: string[]; // name - pos: boolean; -}; + export class Symbols implements DocumentSymbolProvider { provideDocumentSymbols = async (