This commit is contained in:
Andy Bunce 2022-03-07 16:37:26 +00:00
parent 475943053c
commit cfc8ba3817
6 changed files with 164 additions and 158 deletions

View file

@ -5,12 +5,12 @@ import { channel } from "../common/logger";
//
// This class handles Symbols
//
function makeSymbol (name :string,desc :string,icon :vscode.SymbolKind,pos :any) {
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,"var", vscode.SymbolKind.Variable, fullrange, selrange);
const fullrange = new vscode.Range(spos, epos);
const selrange = new vscode.Range(spos, spos);
return new vscode.DocumentSymbol(name, description, icon, fullrange, selrange);
}
export class Symbols implements vscode.DocumentSymbolProvider {
@ -23,23 +23,23 @@ export class Symbols implements vscode.DocumentSymbolProvider {
const symbols: vscode.DocumentSymbol[] = [];
const text = document.getText();
const linter = new (XQLint as any)(text, { "styleCheck": false });
const xqdoc= linter.getXQDoc();
channel.log(xqdoc.variables);
const xqdoc = linter.getXQDoc();
channel.log("got xqdoc");
// 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);
xqdoc.variables.forEach(v => {
const name = v.name;
const info = makeSymbol(name, "var", vscode.SymbolKind.Variable, v.pos)
symbols.push(info);
});
xqdoc.functions.forEach(v => {
const name = v.name;
const info =makeSymbol(name,"Fu", vscode.SymbolKind.Function,v.pos)
symbols.push(info);
xqdoc.functions.forEach(v => {
const name = v.name;
const info = makeSymbol(name, "Fu", vscode.SymbolKind.Function, v.pos)
symbols.push(info);
});
channel.log("Symbols done" + document.uri);
channel.log("Symbols done " + document.uri);
return symbols;
};
}