typescript-language-server
Advanced tools
Comparing version 0.3.3 to 0.3.4
import * as lsp from 'vscode-languageserver'; | ||
import * as tsp from 'typescript/lib/protocol'; | ||
export declare function collectDocumentSymbols(parent: tsp.NavigationTree, symbols: lsp.DocumentSymbol[]): boolean; | ||
export declare function collectSymbolInformations(uri: string, parent: tsp.NavigationTree, symbols: lsp.SymbolInformation[]): boolean; | ||
export declare function collectSymbolInformations(uri: string, current: tsp.NavigationTree, symbols: lsp.SymbolInformation[], containerName?: string): boolean; | ||
export declare function shouldInclueEntry(item: tsp.NavigationTree | tsp.NavigationBarItem): boolean; | ||
//# sourceMappingURL=document-symbol.d.ts.map |
@@ -38,11 +38,12 @@ "use strict"; | ||
exports.collectDocumentSymbols = collectDocumentSymbols; | ||
function collectSymbolInformations(uri, parent, symbols) { | ||
let shouldInclude = shouldInclueEntry(parent); | ||
for (const span of parent.spans) { | ||
function collectSymbolInformations(uri, current, symbols, containerName) { | ||
let shouldInclude = shouldInclueEntry(current); | ||
const name = current.text; | ||
for (const span of current.spans) { | ||
const range = protocol_translation_1.asRange(span); | ||
const children = []; | ||
if (parent.childItems) { | ||
for (const child of parent.childItems) { | ||
if (current.childItems) { | ||
for (const child of current.childItems) { | ||
if (child.spans.some(span => !!protocol_translation_1.Range.intersection(range, protocol_translation_1.asRange(span)))) { | ||
const includedChild = collectSymbolInformations(uri, child, children); | ||
const includedChild = collectSymbolInformations(uri, child, children, name); | ||
shouldInclude = shouldInclude || includedChild; | ||
@@ -54,8 +55,9 @@ } | ||
symbols.push({ | ||
name: parent.text, | ||
kind: protocol_translation_1.toSymbolKind(parent.kind), | ||
name, | ||
kind: protocol_translation_1.toSymbolKind(current.kind), | ||
location: { | ||
uri, | ||
range | ||
} | ||
}, | ||
containerName | ||
}); | ||
@@ -62,0 +64,0 @@ symbols.push(...children); |
@@ -116,5 +116,12 @@ "use strict"; | ||
let result = '\n' + indentation + symbol.name; | ||
if (lsp.DocumentSymbol.is(symbol) && symbol.children) { | ||
result = result + symbolsAsString(symbol.children, indentation + ' '); | ||
if (lsp.DocumentSymbol.is(symbol)) { | ||
if (symbol.children) { | ||
result = result + symbolsAsString(symbol.children, indentation + ' '); | ||
} | ||
} | ||
else { | ||
if (symbol.containerName) { | ||
result = result + ` in ${symbol.containerName}`; | ||
} | ||
} | ||
return result; | ||
@@ -121,0 +128,0 @@ }).join(''); |
{ | ||
"name": "typescript-language-server", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Language Server Protocol (LSP) implementation for TypeScript using tsserver", | ||
@@ -37,3 +37,3 @@ "author": "TypeFox and others", | ||
}, | ||
"gitHead": "63f32be6157c5d064c6a500ad693554fc41095bf" | ||
"gitHead": "5ca4b0bf5beb7ac8aac5a03a84022e86092b46fb" | ||
} |
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
249711
3252