vscode-typescript-languageservice
Advanced tools
Comparing version 0.28.4 to 0.28.5
@@ -21,4 +21,4 @@ import * as vscode from 'vscode-languageserver'; | ||
findDocumentHighlights: (uri: string, position: vscode.Position) => vscode.DocumentHighlight[]; | ||
findDocumentSymbols: (uri: string) => vscode.DocumentSymbol[]; | ||
findWorkspaceSymbols: (uri: string) => vscode.SymbolInformation[]; | ||
findDocumentSymbols: (uri: string) => vscode.SymbolInformation[]; | ||
findWorkspaceSymbols: (query: string) => vscode.SymbolInformation[]; | ||
doComplete: (uri: string, position: vscode.Position, options?: ts.GetCompletionsAtPositionOptions | undefined) => Promise<vscode.CompletionList | undefined>; | ||
@@ -25,0 +25,0 @@ doCompletionResolve: (item: vscode.CompletionItem, newPosition?: vscode.Position | undefined) => Promise<vscode.CompletionItem>; |
@@ -46,3 +46,3 @@ "use strict"; | ||
findDocumentSymbols: documentSymbol.register(languageService, getValidTextDocument), | ||
findWorkspaceSymbols: workspaceSymbols.register(languageService, getValidTextDocument), | ||
findWorkspaceSymbols: workspaceSymbols.register(languageService, getTextDocument), | ||
doComplete: completions2.register(languageService, getValidTextDocument, host, ts), | ||
@@ -49,0 +49,0 @@ doCompletionResolve: completionResolve.register(languageService, getValidTextDocument, getTextDocument, host), |
import type * as ts from 'typescript/lib/tsserverlibrary'; | ||
import * as vscode from 'vscode-languageserver'; | ||
import type { TextDocument } from 'vscode-languageserver-textdocument'; | ||
export declare function register(languageService: ts.LanguageService, getTextDocument: (uri: string) => TextDocument | undefined): (uri: string) => vscode.DocumentSymbol[]; | ||
export declare function register(languageService: ts.LanguageService, getTextDocument: (uri: string) => TextDocument | undefined): (uri: string) => vscode.SymbolInformation[]; |
@@ -35,6 +35,11 @@ "use strict"; | ||
const barItems = languageService.getNavigationTree(fileName); | ||
// The root represents the file. Ignore this when showing in the UI | ||
const result = []; | ||
convertNavTree(document, barItems); | ||
if (barItems.childItems) { | ||
for (const item of barItems.childItems) { | ||
convertNavTree(document, item, undefined); | ||
} | ||
} | ||
return result; | ||
function convertNavTree(document, item) { | ||
function convertNavTree(document, item, parent) { | ||
var _a; | ||
@@ -47,4 +52,8 @@ let shouldInclude = shouldInclueEntry(item); | ||
const range = vscode.Range.create(document.positionAt(span.start), document.positionAt(span.start + span.length)); | ||
const selectionRange = item.nameSpan ? vscode.Range.create(document.positionAt(item.nameSpan.start), document.positionAt(item.nameSpan.start + item.nameSpan.length)) : range; | ||
const symbolInfo = vscode.DocumentSymbol.create(item.text, '', getSymbolKind(item.kind), range, selectionRange); | ||
const symbolInfo = vscode.SymbolInformation.create(item.text, getSymbolKind(item.kind), range, undefined, parent === null || parent === void 0 ? void 0 : parent.text); | ||
if (item.childItems) { | ||
for (const child of item.childItems) { | ||
convertNavTree(document, child, item); | ||
} | ||
} | ||
const kindModifiers = (0, modifiers_1.parseKindModifier)(item.kindModifiers); | ||
@@ -51,0 +60,0 @@ if (kindModifiers.has(PConst.KindModifiers.deprecated)) { |
import type * as ts from 'typescript/lib/tsserverlibrary'; | ||
import * as vscode from 'vscode-languageserver'; | ||
import type { TextDocument } from 'vscode-languageserver-textdocument'; | ||
export declare function register(languageService: ts.LanguageService, getTextDocument: (uri: string) => TextDocument | undefined): (uri: string) => vscode.SymbolInformation[]; | ||
export declare function register(languageService: ts.LanguageService, getTextDocument2: (uri: string) => TextDocument | undefined): (query: string) => vscode.SymbolInformation[]; |
@@ -10,3 +10,2 @@ "use strict"; | ||
switch (item.kind) { | ||
case PConst.Kind.module: return vscode.SymbolKind.Module; | ||
case PConst.Kind.method: return vscode.SymbolKind.Method; | ||
@@ -26,35 +25,24 @@ case PConst.Kind.enum: return vscode.SymbolKind.Enum; | ||
} | ||
function register(languageService, getTextDocument) { | ||
return (uri) => { | ||
const document = getTextDocument(uri); | ||
if (!document) | ||
return []; | ||
const fileName = shared.uriToFsPath(document.uri); | ||
const barItems = languageService.getNavigationBarItems(fileName); | ||
const output = []; | ||
barItemsWorker(document, barItems); | ||
return output; | ||
function barItemsWorker(document, barItems, parentName) { | ||
for (const barItem of barItems) { | ||
barItemWorker(document, barItem, parentName); | ||
} | ||
} | ||
function barItemWorker(document, barItem, parentName) { | ||
for (const span of barItem.spans) { | ||
const item = toSymbolInformation(document, barItem, span, parentName); | ||
output.push(item); | ||
barItemsWorker(document, barItem.childItems, barItem.text); | ||
} | ||
} | ||
function toSymbolInformation(document, item, span, containerName) { | ||
function register(languageService, getTextDocument2) { | ||
return (query) => { | ||
return languageService.getNavigateToItems(query) | ||
.filter(item => item.containerName || item.kind !== 'alias') | ||
.map(toSymbolInformation) | ||
.filter(shared.notEmpty); | ||
function toSymbolInformation(item) { | ||
const label = getLabel(item); | ||
const info = vscode.SymbolInformation.create(label, getSymbolKind(item), vscode.Range.create(document.positionAt(span.start), document.positionAt(span.start + span.length)), document.uri, containerName); | ||
const kindModifiers = item.kindModifiers ? (0, modifiers_1.parseKindModifier)(item.kindModifiers) : undefined; | ||
if (kindModifiers === null || kindModifiers === void 0 ? void 0 : kindModifiers.has(PConst.KindModifiers.deprecated)) { | ||
info.deprecated = true; | ||
const uri = shared.fsPathToUri(item.fileName); | ||
const document = getTextDocument2(uri); | ||
if (document) { | ||
const range = vscode.Range.create(document.positionAt(item.textSpan.start), document.positionAt(item.textSpan.start + item.textSpan.length)); | ||
const info = vscode.SymbolInformation.create(label, getSymbolKind(item), range, uri, item.containerName || ''); | ||
const kindModifiers = item.kindModifiers ? (0, modifiers_1.parseKindModifier)(item.kindModifiers) : undefined; | ||
if (kindModifiers === null || kindModifiers === void 0 ? void 0 : kindModifiers.has(PConst.KindModifiers.deprecated)) { | ||
info.tags = [vscode.SymbolTag.Deprecated]; | ||
} | ||
return info; | ||
} | ||
return info; | ||
} | ||
function getLabel(item) { | ||
const label = item.text; | ||
const label = item.name; | ||
if (item.kind === 'method' || item.kind === 'function') { | ||
@@ -61,0 +49,0 @@ return label + '()'; |
{ | ||
"name": "vscode-typescript-languageservice", | ||
"version": "0.28.4", | ||
"version": "0.28.5", | ||
"main": "out/index.js", | ||
@@ -20,3 +20,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@volar/shared": "0.28.4", | ||
"@volar/shared": "0.28.5", | ||
"semver": "^7.3.5", | ||
@@ -27,3 +27,3 @@ "upath": "^2.0.1", | ||
}, | ||
"gitHead": "d0676ee00065d6c6a79893d2c4fd49a12bad4d1c" | ||
"gitHead": "fbfe320fec237a169d217a868345c3da6410d46b" | ||
} |
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
119965
2344
+ Added@volar/shared@0.28.5(transitive)
- Removed@volar/shared@0.28.4(transitive)
Updated@volar/shared@0.28.5