@elastic/ctags-langserver
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -5,4 +5,4 @@ import { RequestType, RequestHandler } from 'vscode-jsonrpc'; | ||
export declare namespace EDefinitionRequest { | ||
const type: RequestType<TextDocumentPositionParams, SymbolLocator, void, void>; | ||
type HandlerSignature = RequestHandler<TextDocumentPositionParams, SymbolLocator | null, void>; | ||
const type: RequestType<TextDocumentPositionParams, SymbolLocator[], void, void>; | ||
type HandlerSignature = RequestHandler<TextDocumentPositionParams, SymbolLocator[] | null, void>; | ||
} | ||
@@ -9,0 +9,0 @@ export declare namespace FullRequest { |
@@ -21,3 +21,3 @@ import { InitializeParams, InitializeResult, DidChangeWorkspaceFoldersParams, DocumentSymbolParams, TextDocumentPositionParams, Hover, Location, ReferenceParams, DocumentSymbol } from 'vscode-languageserver-protocol'; | ||
hover(params: TextDocumentPositionParams): Promise<Hover>; | ||
eDefinition(params: TextDocumentPositionParams): Promise<SymbolLocator>; | ||
eDefinition(params: TextDocumentPositionParams): Promise<SymbolLocator[]>; | ||
reference(params: ReferenceParams): Promise<Location[]>; | ||
@@ -24,0 +24,0 @@ findBelongedRootPath(filePath: string): string; |
@@ -144,3 +144,3 @@ "use strict"; | ||
if (!rootPath) { | ||
return {}; | ||
return []; | ||
} | ||
@@ -156,10 +156,14 @@ const contents = fs_1.readFileSync(fileName, 'utf8'); | ||
ctags.findTags(path.resolve(rootPath, this.tagFileName), symbol, (error, tags) => { | ||
if (tags.length > 0) { | ||
const tag = this.findClosestTag(tags, path.relative(rootPath, fileName), params.position.line + 1); | ||
if (tags.length === 0) { | ||
resolve([]); | ||
} | ||
let result = []; | ||
// @ts-ignore | ||
tags.forEach(tag => { | ||
const destURI = url_1.pathToFileURL(path.resolve(rootPath, tag.file)); | ||
resolve({ | ||
result.push({ | ||
location: vscode_languageserver_protocol_1.Location.create(destURI.toString(), vscode_languageserver_protocol_1.Range.create(vscode_languageserver_protocol_1.Position.create(tag.lineNumber - 1, 0), vscode_languageserver_protocol_1.Position.create(tag.lineNumber - 1, 0))) | ||
}); | ||
} | ||
resolve(undefined); | ||
}); | ||
resolve(result); | ||
}); | ||
@@ -166,0 +170,0 @@ }); |
@@ -121,5 +121,5 @@ "use strict"; | ||
}); | ||
expect(def).toEqual({ | ||
location: vscode_languageserver_protocol_1.Location.create(sourceFileUrl, vscode_languageserver_protocol_1.Range.create(vscode_languageserver_protocol_1.Position.create(0, 0), vscode_languageserver_protocol_1.Position.create(0, 0))) | ||
}); | ||
expect(def).toEqual([{ | ||
location: vscode_languageserver_protocol_1.Location.create(sourceFileUrl, vscode_languageserver_protocol_1.Range.create(vscode_languageserver_protocol_1.Position.create(0, 0), vscode_languageserver_protocol_1.Position.create(0, 0))) | ||
}]); | ||
})); | ||
@@ -126,0 +126,0 @@ test('test hover', () => __awaiter(this, void 0, void 0, function* () { |
@@ -143,3 +143,4 @@ "use strict"; | ||
children: [], | ||
parent: symbol.containerName | ||
// for c/c++ parser of ctags, it constructs enum in struct as anonymous like 'structName::__anon{HASH}' | ||
parent: symbol.containerName.includes('::') ? symbol.containerName.replace('::', '.') : symbol.containerName | ||
}; | ||
@@ -151,3 +152,9 @@ map.set(documentSymbolwithParent.name, i++); | ||
if (symbol.parent !== sourceFile) { | ||
tmpResult[map.get(symbol.parent)].children.push(symbol); | ||
if (tmpResult[map.get(symbol.parent)] !== undefined) { | ||
// from qualified name to simple name | ||
if (symbol.name.includes('.')) { | ||
symbol.name = symbol.name.substr(symbol.name.lastIndexOf('.') + 1); | ||
} | ||
tmpResult[map.get(symbol.parent)].children.push(symbol); | ||
} | ||
} | ||
@@ -154,0 +161,0 @@ else { |
@@ -81,6 +81,6 @@ "use strict"; | ||
const expectedData = '[{"name":"Elasticsearch","kind":2,"range":{"start":{"line":17,"character":0},"end":{"line":17,"character":0}},"selectionRange":' + | ||
'{"start":{"line":17,"character":0},"end":{"line":17,"character":0}},"children":[{"name":"Elasticsearch.API","kind":2,"range":{"start":{"line":18,"character":' + | ||
'0},"end":{"line":18,"character":0}},"selectionRange":{"start":{"line":18,"character":0},"end":{"line":18,"character":0}},"children":[{"name":"Elasticsearch.API.' + | ||
'Utils","kind":2,"range":{"start":{"line":22,"character":0},"end":{"line":22,"character":0}},"selectionRange":{"start":{"line":22,"' + | ||
'character":0},"end":{"line":22,"character":0}},"children":[{"name":"Elasticsearch.API.Utils.__bulkify","kind":6,"range":{"start":{"line":99,"character":0},' + | ||
'{"start":{"line":17,"character":0},"end":{"line":17,"character":0}},"children":[{"name":"API","kind":2,"range":{"start":{"line":18,"character":' + | ||
'0},"end":{"line":18,"character":0}},"selectionRange":{"start":{"line":18,"character":0},"end":{"line":18,"character":0}},"children":[{"name":' + | ||
'"Utils","kind":2,"range":{"start":{"line":22,"character":0},"end":{"line":22,"character":0}},"selectionRange":{"start":{"line":22,"' + | ||
'character":0},"end":{"line":22,"character":0}},"children":[{"name":"__bulkify","kind":6,"range":{"start":{"line":99,"character":0},' + | ||
'"end":{"line":99,"character":0}},"selectionRange":{"start":{"line":99,"character":0},"end":{"line":99,"character":0}},"children":[]}]}]}]}]'; | ||
@@ -87,0 +87,0 @@ test("test toHierarchicalDocumentSymbol", () => __awaiter(this, void 0, void 0, function* () { |
{ | ||
"name": "@elastic/ctags-langserver", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "An all-languages language server built on top of ctags", | ||
@@ -5,0 +5,0 @@ "author": "Elastic", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15017946
1067