[mod] release 0.5.2
This commit is contained in:
parent
cfc8ba3817
commit
47baf6f2b9
13 changed files with 243 additions and 66 deletions
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue