From 841e6e6f00ca10991f296f052af588a62b0296f0 Mon Sep 17 00:00:00 2001 From: kingwl Date: Thu, 14 May 2020 02:00:42 +0800 Subject: [PATCH 01/15] Add ts/js deprecated support --- extensions/search-result/src/extension.ts | 2 +- extensions/types/lib.textEncoder.d.ts | 4 ++-- .../src/features/completions.ts | 1 + .../src/features/diagnostics.ts | 2 +- .../src/features/documentSymbol.ts | 1 + .../src/features/workspaceSymbols.ts | 17 +++++++++++++++-- .../src/languageProvider.ts | 9 +++++++-- .../src/typeScriptServiceClientHost.ts | 18 +++++++++++++----- .../api/common/extHostLanguageFeatures.ts | 2 +- .../api/common/extHostTypeConverters.ts | 4 ++-- src/vs/workbench/api/common/extHostTypes.ts | 2 +- 11 files changed, 45 insertions(+), 17 deletions(-) diff --git a/extensions/search-result/src/extension.ts b/extensions/search-result/src/extension.ts index abb85dac20123..cccc337a4b947 100644 --- a/extensions/search-result/src/extension.ts +++ b/extensions/search-result/src/extension.ts @@ -91,7 +91,7 @@ export function activate(context: vscode.ExtensionContext) { }), vscode.languages.registerDocumentLinkProvider(SEARCH_RESULT_SELECTOR, { - async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { + async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { return parseSearchResults(document, token) .filter(({ type }) => type === 'file') .map(({ location }) => ({ range: location.originSelectionRange!, target: location.targetUri })); diff --git a/extensions/types/lib.textEncoder.d.ts b/extensions/types/lib.textEncoder.d.ts index 99a5b2271d630..02e1b4890af9a 100644 --- a/extensions/types/lib.textEncoder.d.ts +++ b/extensions/types/lib.textEncoder.d.ts @@ -7,5 +7,5 @@ // // Proper fix: https://github.com/microsoft/TypeScript/issues/31535 -declare var TextDecoder: typeof import('util').TextDecoder; -declare var TextEncoder: typeof import('util').TextEncoder; +declare let TextDecoder: typeof import('util').TextDecoder; +declare let TextEncoder: typeof import('util').TextEncoder; diff --git a/extensions/typescript-language-features/src/features/completions.ts b/extensions/typescript-language-features/src/features/completions.ts index 97051395de99e..8cc6dd3ca0231 100644 --- a/extensions/typescript-language-features/src/features/completions.ts +++ b/extensions/typescript-language-features/src/features/completions.ts @@ -64,6 +64,7 @@ class MyCompletionItem extends vscode.CompletionItem { this.sortText = tsEntry.sortText; } + this.tags = tsEntry.tags as any; this.preselect = tsEntry.isRecommended; this.position = position; this.useCodeSnippet = completionContext.useCodeSnippetsOnMethodSuggest && (this.kind === vscode.CompletionItemKind.Function || this.kind === vscode.CompletionItemKind.Method); diff --git a/extensions/typescript-language-features/src/features/diagnostics.ts b/extensions/typescript-language-features/src/features/diagnostics.ts index 327573e8c1859..ec0566d67cb69 100644 --- a/extensions/typescript-language-features/src/features/diagnostics.ts +++ b/extensions/typescript-language-features/src/features/diagnostics.ts @@ -78,7 +78,7 @@ class FileDiagnostics { return this.get(DiagnosticKind.Suggestion).filter(x => { if (!enableSuggestions) { // Still show unused - return x.tags && x.tags.includes(vscode.DiagnosticTag.Unnecessary); + return x.tags && (x.tags.includes(vscode.DiagnosticTag.Unnecessary) || x.tags.includes(vscode.DiagnosticTag.Deprecated)); } return true; }); diff --git a/extensions/typescript-language-features/src/features/documentSymbol.ts b/extensions/typescript-language-features/src/features/documentSymbol.ts index e119b005babd1..3c48a628563a1 100644 --- a/extensions/typescript-language-features/src/features/documentSymbol.ts +++ b/extensions/typescript-language-features/src/features/documentSymbol.ts @@ -78,6 +78,7 @@ class TypeScriptDocumentSymbolProvider implements vscode.DocumentSymbolProvider getSymbolKind(item.kind), range, range.contains(selectionRange) ? selectionRange : range); + symbolInfo.tags = item.tags; for (const child of children) { if (child.spans.some(span => !!range.intersection(typeConverters.Range.fromTextSpan(span)))) { diff --git a/extensions/typescript-language-features/src/features/workspaceSymbols.ts b/extensions/typescript-language-features/src/features/workspaceSymbols.ts index fb548abf85448..031477ee5f00e 100644 --- a/extensions/typescript-language-features/src/features/workspaceSymbols.ts +++ b/extensions/typescript-language-features/src/features/workspaceSymbols.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import type * as Proto from '../protocol'; +import * as Proto from '../protocol'; import * as PConst from '../protocol.const'; import { ITypeScriptServiceClient } from '../typescriptService'; import API from '../utils/api'; @@ -93,11 +93,24 @@ class TypeScriptWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvide private toSymbolInformation(item: Proto.NavtoItem) { const label = TypeScriptWorkspaceSymbolProvider.getLabel(item); - return new vscode.SymbolInformation( + const info = new vscode.SymbolInformation( label, getSymbolKind(item), item.containerName || '', typeConverters.Location.fromTextSpan(this.client.toResource(item.file), item)); + info.tags = TypeScriptWorkspaceSymbolProvider.getSymbolTags(item); + return info; + } + + private static getSymbolTags (item: Proto.NavtoItem): vscode.SymbolTag[] | undefined { + return item.tags?.map(tag => { + switch (tag) { + case Proto.SymbolTag.Deprecated: + return vscode.SymbolTag.Deprecated; + default: + throw new Error('Unknown'); + } + }); } private static getLabel(item: Proto.NavtoItem) { diff --git a/extensions/typescript-language-features/src/languageProvider.ts b/extensions/typescript-language-features/src/languageProvider.ts index 644eed4044196..b3bb76984e076 100644 --- a/extensions/typescript-language-features/src/languageProvider.ts +++ b/extensions/typescript-language-features/src/languageProvider.ts @@ -122,16 +122,21 @@ export default class LanguageProvider extends Disposable { this.client.bufferSyncSupport.requestAllDiagnostics(); } - public diagnosticsReceived(diagnosticsKind: DiagnosticKind, file: vscode.Uri, diagnostics: (vscode.Diagnostic & { reportUnnecessary: any })[]): void { + public diagnosticsReceived(diagnosticsKind: DiagnosticKind, file: vscode.Uri, diagnostics: (vscode.Diagnostic & { reportUnnecessary: any, reportDeprecated: any })[]): void { const config = vscode.workspace.getConfiguration(this.id, file); const reportUnnecessary = config.get('showUnused', true); + const reportDeprecated = config.get('showDeprecated', true); this.client.diagnosticsManager.updateDiagnostics(file, this._diagnosticLanguage, diagnosticsKind, diagnostics.filter(diag => { if (!reportUnnecessary) { - diag.tags = undefined; if (diag.reportUnnecessary && diag.severity === vscode.DiagnosticSeverity.Hint) { return false; } } + if (!reportDeprecated) { + if (diag.reportDeprecated && diag.severity === vscode.DiagnosticSeverity.Hint) { + return false; + } + } return true; })); } diff --git a/extensions/typescript-language-features/src/typeScriptServiceClientHost.ts b/extensions/typescript-language-features/src/typeScriptServiceClientHost.ts index 0be49c3113bbe..a51865789958d 100644 --- a/extensions/typescript-language-features/src/typeScriptServiceClientHost.ts +++ b/extensions/typescript-language-features/src/typeScriptServiceClientHost.ts @@ -233,11 +233,11 @@ export default class TypeScriptServiceClientHost extends Disposable { private createMarkerDatas( diagnostics: Proto.Diagnostic[], source: string - ): (vscode.Diagnostic & { reportUnnecessary: any })[] { + ): (vscode.Diagnostic & { reportUnnecessary: any, reportDeprecated: any })[] { return diagnostics.map(tsDiag => this.tsDiagnosticToVsDiagnostic(tsDiag, source)); } - private tsDiagnosticToVsDiagnostic(diagnostic: Proto.Diagnostic, source: string): vscode.Diagnostic & { reportUnnecessary: any } { + private tsDiagnosticToVsDiagnostic(diagnostic: Proto.Diagnostic, source: string): vscode.Diagnostic & { reportUnnecessary: any, reportDeprecated: any } { const { start, end, text } = diagnostic; const range = new vscode.Range(typeConverters.Position.fromLocation(start), typeConverters.Position.fromLocation(end)); const converted = new vscode.Diagnostic(range, text, this.getDiagnosticSeverity(diagnostic)); @@ -255,11 +255,19 @@ export default class TypeScriptServiceClientHost extends Disposable { return new vscode.DiagnosticRelatedInformation(typeConverters.Location.fromTextSpan(this.client.toResource(span.file), span), info.message); })); } + const tags: vscode.DiagnosticTag[] = []; if (diagnostic.reportsUnnecessary) { - converted.tags = [vscode.DiagnosticTag.Unnecessary]; + tags.push(vscode.DiagnosticTag.Unnecessary); } - (converted as vscode.Diagnostic & { reportUnnecessary: any }).reportUnnecessary = diagnostic.reportsUnnecessary; - return converted as vscode.Diagnostic & { reportUnnecessary: any }; + if (diagnostic.reportsDeprecated) { + tags.push(vscode.DiagnosticTag.Deprecated); + } + converted.tags = tags.length ? tags : undefined; + + const resultConverted = converted as vscode.Diagnostic & { reportUnnecessary: any, reportDeprecated: any }; + resultConverted.reportUnnecessary = diagnostic.reportsUnnecessary; + resultConverted.reportDeprecated = diagnostic.reportsDeprecated; + return resultConverted; } private getDiagnosticSeverity(diagnostic: Proto.Diagnostic): vscode.DiagnosticSeverity { diff --git a/src/vs/workbench/api/common/extHostLanguageFeatures.ts b/src/vs/workbench/api/common/extHostLanguageFeatures.ts index 13697b1e1eda5..dfbc3d325abf1 100644 --- a/src/vs/workbench/api/common/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/common/extHostLanguageFeatures.ts @@ -73,7 +73,7 @@ class DocumentSymbolAdapter { const element: modes.DocumentSymbol = { name: info.name || '!!MISSING: name!!', kind: typeConvert.SymbolKind.from(info.kind), - tags: info.tags ? info.tags.map(typeConvert.SymbolTag.from) : [], + tags: info.tags?.map(typeConvert.SymbolTag.from) || [], detail: '', containerName: info.containerName, range: typeConvert.Range.from(info.location.range), diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index b24be8d20a0c4..54473b8781c79 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -10,7 +10,7 @@ import { ITextEditorOptions } from 'vs/platform/editor/common/editor'; import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor'; import { IDecorationOptions, IThemeDecorationRenderOptions, IDecorationRenderOptions, IContentDecorationRenderOptions } from 'vs/editor/common/editorCommon'; import { EndOfLineSequence, TrackedRangeStickiness } from 'vs/editor/common/model'; -import type * as vscode from 'vscode'; +import * as vscode from 'vscode'; import { URI, UriComponents } from 'vs/base/common/uri'; import { ProgressLocation as MainProgressLocation } from 'vs/platform/progress/common/progress'; import { SaveReason } from 'vs/workbench/common/editor'; @@ -635,7 +635,7 @@ export namespace DocumentSymbol { range: Range.from(info.range), selectionRange: Range.from(info.selectionRange), kind: SymbolKind.from(info.kind), - tags: info.tags ? info.tags.map(SymbolTag.from) : [] + tags: info.tags?.map(SymbolTag.from) ?? [] }; if (info.children) { result.children = info.children.map(from); diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index 4894d276e4648..ac43c35514c03 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -1012,7 +1012,7 @@ export class SymbolInformation { name: string; location!: Location; kind: SymbolKind; - tags?: SymbolTag[]; + tags?: readonly SymbolTag[]; containerName: string | undefined; constructor(name: string, kind: SymbolKind, containerName: string | undefined, location: Location); From e1a9c1ed818b2bf074cf0d38df06c3305aa64045 Mon Sep 17 00:00:00 2001 From: kingwl Date: Thu, 14 May 2020 13:01:48 +0800 Subject: [PATCH 02/15] Support callhierarchy --- .../src/features/callHierarchy.ts | 4 +++- src/vs/workbench/api/common/extHostLanguageFeatures.ts | 1 + .../contrib/callHierarchy/browser/callHierarchyTree.ts | 5 +++-- .../workbench/contrib/callHierarchy/common/callHierarchy.ts | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/extensions/typescript-language-features/src/features/callHierarchy.ts b/extensions/typescript-language-features/src/features/callHierarchy.ts index a76d8a6bea846..e1d46146093b1 100644 --- a/extensions/typescript-language-features/src/features/callHierarchy.ts +++ b/extensions/typescript-language-features/src/features/callHierarchy.ts @@ -79,7 +79,7 @@ function fromProtocolCallHierarchyItem(item: Proto.CallHierarchyItem): vscode.Ca const useFileName = isSourceFileItem(item); const name = useFileName ? path.basename(item.file) : item.name; const detail = useFileName ? vscode.workspace.asRelativePath(path.dirname(item.file)) : ''; - return new vscode.CallHierarchyItem( + const result = new vscode.CallHierarchyItem( typeConverters.SymbolKind.fromProtocolScriptElementKind(item.kind), name, detail, @@ -87,6 +87,8 @@ function fromProtocolCallHierarchyItem(item: Proto.CallHierarchyItem): vscode.Ca typeConverters.Range.fromTextSpan(item.span), typeConverters.Range.fromTextSpan(item.selectionSpan) ); + result.tags = item.tags as any + return result; } function fromProtocolCallHierchyIncomingCall(item: Proto.CallHierarchyIncomingCall): vscode.CallHierarchyIncomingCall { diff --git a/src/vs/workbench/api/common/extHostLanguageFeatures.ts b/src/vs/workbench/api/common/extHostLanguageFeatures.ts index dfbc3d325abf1..c57ad789e839e 100644 --- a/src/vs/workbench/api/common/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/common/extHostLanguageFeatures.ts @@ -1360,6 +1360,7 @@ class CallHierarchyAdapter { uri: item.uri, range: typeConvert.Range.from(item.range), selectionRange: typeConvert.Range.from(item.selectionRange), + tags: item.tags?.map(typeConvert.SymbolTag.from) }; map.set(dto._itemId, item); return dto; diff --git a/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.ts b/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.ts index 2387788c3bf0e..a78bfa19ce043 100644 --- a/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.ts +++ b/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.ts @@ -9,7 +9,7 @@ import { CancellationToken } from 'vs/base/common/cancellation'; import { IIdentityProvider, IListVirtualDelegate } from 'vs/base/browser/ui/list/list'; import { FuzzyScore, createMatches } from 'vs/base/common/filters'; import { IconLabel } from 'vs/base/browser/ui/iconLabel/iconLabel'; -import { SymbolKinds, Location } from 'vs/editor/common/modes'; +import { SymbolKinds, Location, SymbolTag } from 'vs/editor/common/modes'; import { compare } from 'vs/base/common/strings'; import { Range } from 'vs/editor/common/core/range'; import { IListAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget'; @@ -117,11 +117,12 @@ export class CallRenderer implements ITreeRenderer, _index: number, template: CallRenderingTemplate): void { const { element, filterData } = node; + const deprecated = element.item.tags?.includes(SymbolTag.Deprecated) template.icon.className = SymbolKinds.toCssClassName(element.item.kind, true); template.label.setLabel( element.item.name, element.item.detail, - { labelEscapeNewLines: true, matches: createMatches(filterData) } + { labelEscapeNewLines: true, matches: createMatches(filterData), strikethrough: deprecated } ); } disposeTemplate(template: CallRenderingTemplate): void { diff --git a/src/vs/workbench/contrib/callHierarchy/common/callHierarchy.ts b/src/vs/workbench/contrib/callHierarchy/common/callHierarchy.ts index c82d0a7739ddf..771cfa5ee9437 100644 --- a/src/vs/workbench/contrib/callHierarchy/common/callHierarchy.ts +++ b/src/vs/workbench/contrib/callHierarchy/common/callHierarchy.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { IRange } from 'vs/editor/common/core/range'; -import { SymbolKind, ProviderResult } from 'vs/editor/common/modes'; +import { SymbolKind, ProviderResult, SymbolTag } from 'vs/editor/common/modes'; import { ITextModel } from 'vs/editor/common/model'; import { CancellationToken } from 'vs/base/common/cancellation'; import { LanguageFeatureRegistry } from 'vs/editor/common/modes/languageFeatureRegistry'; @@ -32,6 +32,8 @@ export interface CallHierarchyItem { uri: URI; range: IRange; selectionRange: IRange; + + tags?: readonly SymbolTag[] } export interface IncomingCall { From 5d5df000b6af80754273c72c8457eb6dbb540b0c Mon Sep 17 00:00:00 2001 From: kingwl Date: Sun, 17 May 2020 15:26:13 +0800 Subject: [PATCH 03/15] avoid tags --- .../src/features/callHierarchy.ts | 5 ++++- .../src/features/completions.ts | 13 ++++++++----- .../src/features/documentSymbol.ts | 8 +++++++- .../src/features/workspaceSymbols.ts | 17 +++++------------ .../src/protocol.const.ts | 1 + .../src/utils/modifiers.ts | 3 +++ 6 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 extensions/typescript-language-features/src/utils/modifiers.ts diff --git a/extensions/typescript-language-features/src/features/callHierarchy.ts b/extensions/typescript-language-features/src/features/callHierarchy.ts index e1d46146093b1..1c0662bbca38c 100644 --- a/extensions/typescript-language-features/src/features/callHierarchy.ts +++ b/extensions/typescript-language-features/src/features/callHierarchy.ts @@ -11,6 +11,7 @@ import { VersionDependentRegistration } from '../utils/dependentRegistration'; import type * as Proto from '../protocol'; import * as path from 'path'; import * as PConst from '../protocol.const'; +import { parseKindModifier } from '../utils/modifiers'; class TypeScriptCallHierarchySupport implements vscode.CallHierarchyProvider { public static readonly minVersion = API.v380; @@ -87,7 +88,9 @@ function fromProtocolCallHierarchyItem(item: Proto.CallHierarchyItem): vscode.Ca typeConverters.Range.fromTextSpan(item.span), typeConverters.Range.fromTextSpan(item.selectionSpan) ); - result.tags = item.tags as any + + const kindModifiers = item.kindModifiers ? parseKindModifier(item.kindModifiers) : undefined; + result.tags = kindModifiers?.has(PConst.KindModifiers.depreacted) ? [vscode.SymbolTag.Deprecated] : undefined; return result; } diff --git a/extensions/typescript-language-features/src/features/completions.ts b/extensions/typescript-language-features/src/features/completions.ts index 8cc6dd3ca0231..79f617ba4d734 100644 --- a/extensions/typescript-language-features/src/features/completions.ts +++ b/extensions/typescript-language-features/src/features/completions.ts @@ -19,6 +19,7 @@ import { TelemetryReporter } from '../utils/telemetry'; import * as typeConverters from '../utils/typeConverters'; import TypingsStatus from '../utils/typingsStatus'; import FileConfigurationManager from './fileConfigurationManager'; +import { parseKindModifier } from '../utils/modifiers'; const localize = nls.loadMessageBundle(); @@ -64,7 +65,6 @@ class MyCompletionItem extends vscode.CompletionItem { this.sortText = tsEntry.sortText; } - this.tags = tsEntry.tags as any; this.preselect = tsEntry.isRecommended; this.position = position; this.useCodeSnippet = completionContext.useCodeSnippetsOnMethodSuggest && (this.kind === vscode.CompletionItemKind.Function || this.kind === vscode.CompletionItemKind.Method); @@ -91,8 +91,8 @@ class MyCompletionItem extends vscode.CompletionItem { } if (tsEntry.kindModifiers) { - const kindModifiers = tsEntry.kindModifiers.split(/,|\s+/g); - if (kindModifiers.includes(PConst.KindModifiers.optional)) { + const kindModifiers = parseKindModifier(tsEntry.kindModifiers); + if (kindModifiers.has(PConst.KindModifiers.optional)) { if (!this.insertText) { this.insertText = this.label; } @@ -102,14 +102,17 @@ class MyCompletionItem extends vscode.CompletionItem { } this.label += '?'; } + if (kindModifiers.has(PConst.KindModifiers.depreacted)) { + this.tags = [vscode.CompletionItemTag.Deprecated]; + } - if (kindModifiers.includes(PConst.KindModifiers.color)) { + if (kindModifiers.has(PConst.KindModifiers.color)) { this.kind = vscode.CompletionItemKind.Color; } if (tsEntry.kind === PConst.Kind.script) { for (const extModifier of PConst.KindModifiers.fileExtensionKindModifiers) { - if (kindModifiers.includes(extModifier)) { + if (kindModifiers.has(extModifier)) { if (tsEntry.name.toLowerCase().endsWith(extModifier)) { this.detail = tsEntry.name; } else { diff --git a/extensions/typescript-language-features/src/features/documentSymbol.ts b/extensions/typescript-language-features/src/features/documentSymbol.ts index 3c48a628563a1..8b44581c6de0d 100644 --- a/extensions/typescript-language-features/src/features/documentSymbol.ts +++ b/extensions/typescript-language-features/src/features/documentSymbol.ts @@ -9,6 +9,7 @@ import * as PConst from '../protocol.const'; import { ITypeScriptServiceClient } from '../typescriptService'; import * as typeConverters from '../utils/typeConverters'; import { CachedResponse } from '../tsServer/cachedResponse'; +import { parseKindModifier } from '../utils/modifiers'; const getSymbolKind = (kind: string): vscode.SymbolKind => { switch (kind) { @@ -78,7 +79,12 @@ class TypeScriptDocumentSymbolProvider implements vscode.DocumentSymbolProvider getSymbolKind(item.kind), range, range.contains(selectionRange) ? selectionRange : range); - symbolInfo.tags = item.tags; + + + const kindModifiers = parseKindModifier(item.kindModifiers); + if (kindModifiers.has(PConst.KindModifiers.depreacted)) { + symbolInfo.tags = [vscode.SymbolTag.Deprecated]; + } for (const child of children) { if (child.spans.some(span => !!range.intersection(typeConverters.Range.fromTextSpan(span)))) { diff --git a/extensions/typescript-language-features/src/features/workspaceSymbols.ts b/extensions/typescript-language-features/src/features/workspaceSymbols.ts index 031477ee5f00e..6954c119a064e 100644 --- a/extensions/typescript-language-features/src/features/workspaceSymbols.ts +++ b/extensions/typescript-language-features/src/features/workspaceSymbols.ts @@ -11,6 +11,7 @@ import API from '../utils/api'; import * as fileSchemes from '../utils/fileSchemes'; import { doesResourceLookLikeAJavaScriptFile, doesResourceLookLikeATypeScriptFile } from '../utils/languageDescription'; import * as typeConverters from '../utils/typeConverters'; +import { parseKindModifier } from '../utils/modifiers'; function getSymbolKind(item: Proto.NavtoItem): vscode.SymbolKind { switch (item.kind) { @@ -98,21 +99,13 @@ class TypeScriptWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvide getSymbolKind(item), item.containerName || '', typeConverters.Location.fromTextSpan(this.client.toResource(item.file), item)); - info.tags = TypeScriptWorkspaceSymbolProvider.getSymbolTags(item); + const kindModifiers = item.kindModifiers ? parseKindModifier(item.kindModifiers) : undefined; + if (kindModifiers?.has(PConst.KindModifiers.depreacted)) { + info.tags = [vscode.SymbolTag.Deprecated]; + } return info; } - private static getSymbolTags (item: Proto.NavtoItem): vscode.SymbolTag[] | undefined { - return item.tags?.map(tag => { - switch (tag) { - case Proto.SymbolTag.Deprecated: - return vscode.SymbolTag.Deprecated; - default: - throw new Error('Unknown'); - } - }); - } - private static getLabel(item: Proto.NavtoItem) { const label = item.name; if (item.kind === 'method' || item.kind === 'function') { diff --git a/extensions/typescript-language-features/src/protocol.const.ts b/extensions/typescript-language-features/src/protocol.const.ts index 37fe42fd8304c..136e997f6279c 100644 --- a/extensions/typescript-language-features/src/protocol.const.ts +++ b/extensions/typescript-language-features/src/protocol.const.ts @@ -45,6 +45,7 @@ export class DiagnosticCategory { export class KindModifiers { public static readonly optional = 'optional'; + public static readonly depreacted = 'deprecated'; public static readonly color = 'color'; public static readonly dtsFile = '.d.ts'; diff --git a/extensions/typescript-language-features/src/utils/modifiers.ts b/extensions/typescript-language-features/src/utils/modifiers.ts new file mode 100644 index 0000000000000..d015e0569dbe3 --- /dev/null +++ b/extensions/typescript-language-features/src/utils/modifiers.ts @@ -0,0 +1,3 @@ +export function parseKindModifier(kindModifiers: string): Set { + return new Set(kindModifiers.split(/,|\s+/g)); +} From 9cdfa00a9c8331a9334589c05f9cb564625822b1 Mon Sep 17 00:00:00 2001 From: kingwl Date: Tue, 19 May 2020 21:57:02 +0800 Subject: [PATCH 04/15] fix lint --- .../typescript-language-features/src/utils/modifiers.ts | 5 +++++ src/vs/workbench/api/common/extHostTypeConverters.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/typescript-language-features/src/utils/modifiers.ts b/extensions/typescript-language-features/src/utils/modifiers.ts index d015e0569dbe3..589b5da3d52c9 100644 --- a/extensions/typescript-language-features/src/utils/modifiers.ts +++ b/extensions/typescript-language-features/src/utils/modifiers.ts @@ -1,3 +1,8 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + export function parseKindModifier(kindModifiers: string): Set { return new Set(kindModifiers.split(/,|\s+/g)); } diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index 54473b8781c79..cadf891f6bc0d 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -900,7 +900,7 @@ export namespace CompletionItem { result.insertText = suggestion.insertText; result.kind = CompletionItemKind.to(suggestion.kind); - result.tags = suggestion.tags && suggestion.tags.map(CompletionItemTag.to); + result.tags = suggestion.tags?.map(CompletionItemTag.to); result.detail = suggestion.detail; result.documentation = htmlContent.isMarkdownString(suggestion.documentation) ? MarkdownString.to(suggestion.documentation) : suggestion.documentation; result.sortText = suggestion.sortText; From faa29c094af4b7636774c894f3a7aa28827974a1 Mon Sep 17 00:00:00 2001 From: kingwl Date: Tue, 19 May 2020 21:59:39 +0800 Subject: [PATCH 05/15] fix lint --- .../contrib/callHierarchy/browser/callHierarchyTree.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.ts b/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.ts index a78bfa19ce043..6b23468d9ec1b 100644 --- a/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.ts +++ b/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.ts @@ -117,7 +117,7 @@ export class CallRenderer implements ITreeRenderer, _index: number, template: CallRenderingTemplate): void { const { element, filterData } = node; - const deprecated = element.item.tags?.includes(SymbolTag.Deprecated) + const deprecated = element.item.tags?.includes(SymbolTag.Deprecated); template.icon.className = SymbolKinds.toCssClassName(element.item.kind, true); template.label.setLabel( element.item.name, From 93bc5717b60023e5a43728e7ed2514baf70641f2 Mon Sep 17 00:00:00 2001 From: kingwl Date: Tue, 19 May 2020 22:05:40 +0800 Subject: [PATCH 06/15] Avoid changes --- extensions/search-result/src/extension.ts | 2 +- extensions/types/lib.textEncoder.d.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/search-result/src/extension.ts b/extensions/search-result/src/extension.ts index cccc337a4b947..abb85dac20123 100644 --- a/extensions/search-result/src/extension.ts +++ b/extensions/search-result/src/extension.ts @@ -91,7 +91,7 @@ export function activate(context: vscode.ExtensionContext) { }), vscode.languages.registerDocumentLinkProvider(SEARCH_RESULT_SELECTOR, { - async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { + async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { return parseSearchResults(document, token) .filter(({ type }) => type === 'file') .map(({ location }) => ({ range: location.originSelectionRange!, target: location.targetUri })); diff --git a/extensions/types/lib.textEncoder.d.ts b/extensions/types/lib.textEncoder.d.ts index 02e1b4890af9a..99a5b2271d630 100644 --- a/extensions/types/lib.textEncoder.d.ts +++ b/extensions/types/lib.textEncoder.d.ts @@ -7,5 +7,5 @@ // // Proper fix: https://github.com/microsoft/TypeScript/issues/31535 -declare let TextDecoder: typeof import('util').TextDecoder; -declare let TextEncoder: typeof import('util').TextEncoder; +declare var TextDecoder: typeof import('util').TextDecoder; +declare var TextEncoder: typeof import('util').TextEncoder; From f5e3a3b1d35c69fbb543e78f145688c38cb4d4f2 Mon Sep 17 00:00:00 2001 From: kingwl Date: Tue, 19 May 2020 22:07:43 +0800 Subject: [PATCH 07/15] Avoid assign --- .../src/features/callHierarchy.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/typescript-language-features/src/features/callHierarchy.ts b/extensions/typescript-language-features/src/features/callHierarchy.ts index 1c0662bbca38c..414acce720de9 100644 --- a/extensions/typescript-language-features/src/features/callHierarchy.ts +++ b/extensions/typescript-language-features/src/features/callHierarchy.ts @@ -90,7 +90,9 @@ function fromProtocolCallHierarchyItem(item: Proto.CallHierarchyItem): vscode.Ca ); const kindModifiers = item.kindModifiers ? parseKindModifier(item.kindModifiers) : undefined; - result.tags = kindModifiers?.has(PConst.KindModifiers.depreacted) ? [vscode.SymbolTag.Deprecated] : undefined; + if (kindModifiers?.has(PConst.KindModifiers.depreacted)) { + result.tags = [vscode.SymbolTag.Deprecated]; + } return result; } From e71cbf5654334ed02c36be2c6661de575ab1175a Mon Sep 17 00:00:00 2001 From: kingwl Date: Tue, 19 May 2020 22:09:17 +0800 Subject: [PATCH 08/15] Avoid changes --- .../src/features/workspaceSymbols.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/typescript-language-features/src/features/workspaceSymbols.ts b/extensions/typescript-language-features/src/features/workspaceSymbols.ts index 6954c119a064e..7118709ddd782 100644 --- a/extensions/typescript-language-features/src/features/workspaceSymbols.ts +++ b/extensions/typescript-language-features/src/features/workspaceSymbols.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import * as Proto from '../protocol'; +import type * as Proto from '../protocol'; import * as PConst from '../protocol.const'; import { ITypeScriptServiceClient } from '../typescriptService'; import API from '../utils/api'; From b516be9b5bb906b795ec6aad6d8f35fc48a644f5 Mon Sep 17 00:00:00 2001 From: kingwl Date: Tue, 19 May 2020 22:12:37 +0800 Subject: [PATCH 09/15] Avoid styles --- src/vs/workbench/api/common/extHostTypeConverters.ts | 2 +- src/vs/workbench/api/common/extHostTypes.ts | 2 +- src/vs/workbench/contrib/callHierarchy/common/callHierarchy.ts | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index cadf891f6bc0d..06703c03c1f78 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -10,7 +10,7 @@ import { ITextEditorOptions } from 'vs/platform/editor/common/editor'; import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor'; import { IDecorationOptions, IThemeDecorationRenderOptions, IDecorationRenderOptions, IContentDecorationRenderOptions } from 'vs/editor/common/editorCommon'; import { EndOfLineSequence, TrackedRangeStickiness } from 'vs/editor/common/model'; -import * as vscode from 'vscode'; +import type * as vscode from 'vscode'; import { URI, UriComponents } from 'vs/base/common/uri'; import { ProgressLocation as MainProgressLocation } from 'vs/platform/progress/common/progress'; import { SaveReason } from 'vs/workbench/common/editor'; diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index ac43c35514c03..4894d276e4648 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -1012,7 +1012,7 @@ export class SymbolInformation { name: string; location!: Location; kind: SymbolKind; - tags?: readonly SymbolTag[]; + tags?: SymbolTag[]; containerName: string | undefined; constructor(name: string, kind: SymbolKind, containerName: string | undefined, location: Location); diff --git a/src/vs/workbench/contrib/callHierarchy/common/callHierarchy.ts b/src/vs/workbench/contrib/callHierarchy/common/callHierarchy.ts index 771cfa5ee9437..28a295485118f 100644 --- a/src/vs/workbench/contrib/callHierarchy/common/callHierarchy.ts +++ b/src/vs/workbench/contrib/callHierarchy/common/callHierarchy.ts @@ -32,8 +32,7 @@ export interface CallHierarchyItem { uri: URI; range: IRange; selectionRange: IRange; - - tags?: readonly SymbolTag[] + tags?: SymbolTag[] } export interface IncomingCall { From f83949be5ebca7e21446e086c8aaf1c0d7287763 Mon Sep 17 00:00:00 2001 From: kingwl Date: Tue, 19 May 2020 22:33:17 +0800 Subject: [PATCH 10/15] Add temp deps for build --- extensions/package.json | 2 +- extensions/yarn.lock | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/extensions/package.json b/extensions/package.json index 8744f4dff9082..96857425fdc69 100644 --- a/extensions/package.json +++ b/extensions/package.json @@ -3,7 +3,7 @@ "version": "0.0.1", "description": "Dependencies shared by all extensions", "dependencies": { - "typescript": "^3.9.2-insiders.20200509" + "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/74212/artifacts?artifactName=tgz&fileId=2056AC579024F64F4D733979778E0700E6D317EE140EA5F9D238E4B88C38090F02&fileName=/typescript-4.0.0-insiders.20200518.tgz" }, "scripts": { "postinstall": "node ./postinstall" diff --git a/extensions/yarn.lock b/extensions/yarn.lock index 4e0ca82acd1d9..33f59136a7476 100644 --- a/extensions/yarn.lock +++ b/extensions/yarn.lock @@ -2,7 +2,6 @@ # yarn lockfile v1 -typescript@^3.9.2-insiders.20200509: - version "3.9.2-insiders.20200509" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.2-insiders.20200509.tgz#8c90ed86a91f9692f10f5ac9c1fd6cb241419e6c" - integrity sha512-AAbhs55BZMbyHGfJd0pNfO3+B6jjPpa38zgaIb9MRExkRGLkIUpbUetoh+HgmM5LAtg128sHGiwhLc49pOcgFw== +"typescript@https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/74212/artifacts?artifactName=tgz&fileId=2056AC579024F64F4D733979778E0700E6D317EE140EA5F9D238E4B88C38090F02&fileName=/typescript-4.0.0-insiders.20200518.tgz": + version "4.0.0-insiders.20200518" + resolved "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/74212/artifacts?artifactName=tgz&fileId=2056AC579024F64F4D733979778E0700E6D317EE140EA5F9D238E4B88C38090F02&fileName=/typescript-4.0.0-insiders.20200518.tgz#a584afdae5a83f0d4a2d177ad1c6f9435a2293c5" From 6e1438b139d3bdd7e24cffe3286a4496e1f5e302 Mon Sep 17 00:00:00 2001 From: kingwl Date: Fri, 19 Jun 2020 11:01:31 +0800 Subject: [PATCH 11/15] update version --- extensions/package.json | 6 +----- extensions/yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/extensions/package.json b/extensions/package.json index a964899c24b25..a76c666c66bbc 100644 --- a/extensions/package.json +++ b/extensions/package.json @@ -3,11 +3,7 @@ "version": "0.0.1", "description": "Dependencies shared by all extensions", "dependencies": { -<<<<<<< HEAD - "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/74212/artifacts?artifactName=tgz&fileId=2056AC579024F64F4D733979778E0700E6D317EE140EA5F9D238E4B88C38090F02&fileName=/typescript-4.0.0-insiders.20200518.tgz" -======= - "typescript": "3.9.4" ->>>>>>> master + "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/76276/artifacts?artifactName=tgz&fileId=78E053053EC04273CA27295F7B8557AA75922D9BBBB3576EC2256F647AD5273202&fileName=/typescript-4.0.0-insiders.20200612.tgz" }, "scripts": { "postinstall": "node ./postinstall" diff --git a/extensions/yarn.lock b/extensions/yarn.lock index 33f59136a7476..0705f0ae65bd4 100644 --- a/extensions/yarn.lock +++ b/extensions/yarn.lock @@ -2,6 +2,6 @@ # yarn lockfile v1 -"typescript@https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/74212/artifacts?artifactName=tgz&fileId=2056AC579024F64F4D733979778E0700E6D317EE140EA5F9D238E4B88C38090F02&fileName=/typescript-4.0.0-insiders.20200518.tgz": - version "4.0.0-insiders.20200518" - resolved "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/74212/artifacts?artifactName=tgz&fileId=2056AC579024F64F4D733979778E0700E6D317EE140EA5F9D238E4B88C38090F02&fileName=/typescript-4.0.0-insiders.20200518.tgz#a584afdae5a83f0d4a2d177ad1c6f9435a2293c5" +"typescript@https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/76276/artifacts?artifactName=tgz&fileId=78E053053EC04273CA27295F7B8557AA75922D9BBBB3576EC2256F647AD5273202&fileName=/typescript-4.0.0-insiders.20200612.tgz": + version "4.0.0-insiders.20200612" + resolved "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/76276/artifacts?artifactName=tgz&fileId=78E053053EC04273CA27295F7B8557AA75922D9BBBB3576EC2256F647AD5273202&fileName=/typescript-4.0.0-insiders.20200612.tgz#56d14a37a058bab28c83620c99ba4167170edc7b" From f93df8cd8106e2a9770602e4c8cb48d711acac87 Mon Sep 17 00:00:00 2001 From: kingwl Date: Fri, 19 Jun 2020 11:41:05 +0800 Subject: [PATCH 12/15] add config item --- extensions/search-result/src/extension.ts | 2 +- src/vs/editor/common/config/editorOptions.ts | 9 +++++++++ .../editor/common/standalone/standaloneEnums.ts | 11 ++++++----- src/vs/monaco.d.ts | 16 +++++++++++----- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/extensions/search-result/src/extension.ts b/extensions/search-result/src/extension.ts index abb85dac20123..cccc337a4b947 100644 --- a/extensions/search-result/src/extension.ts +++ b/extensions/search-result/src/extension.ts @@ -91,7 +91,7 @@ export function activate(context: vscode.ExtensionContext) { }), vscode.languages.registerDocumentLinkProvider(SEARCH_RESULT_SELECTOR, { - async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { + async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { return parseSearchResults(document, token) .filter(({ type }) => type === 'file') .map(({ location }) => ({ range: location.originSelectionRange!, target: location.targetUri })); diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 90511cd1879df..272f16429a1e7 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -594,6 +594,10 @@ export interface IEditorOptions { * Defaults to false. */ definitionLinkOpensInPeek?: boolean; + /** + * Controls strikethrough deprecated variables. + */ + showDeprecated?: boolean; } export interface IEditorConstructionOptions extends IEditorOptions { @@ -3591,6 +3595,7 @@ export const enum EditorOption { wordWrapMinified, wrappingIndent, wrappingStrategy, + showDeprecated, // Leave these at the end (because they have dependencies!) editorClassName, @@ -4077,6 +4082,10 @@ export const EditorOptions = { EditorOption.showUnused, 'showUnused', true, { description: nls.localize('showUnused', "Controls fading out of unused code.") } )), + showDeprecated: register(new EditorBooleanOption( + EditorOption.showDeprecated, 'showDeprecated', true, + { description: nls.localize('showDeprecated', "Controls strikethrough deprecated variables.") } + )), snippetSuggestions: register(new EditorStringEnumOption( EditorOption.snippetSuggestions, 'snippetSuggestions', 'inline' as 'top' | 'bottom' | 'inline' | 'none', diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index 49e24e9eac5cd..b1832df3859af 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -279,11 +279,12 @@ export enum EditorOption { wordWrapMinified = 109, wrappingIndent = 110, wrappingStrategy = 111, - editorClassName = 112, - pixelRatio = 113, - tabFocusMode = 114, - layoutInfo = 115, - wrappingInfo = 116 + showDeprecated = 112, + editorClassName = 113, + pixelRatio = 114, + tabFocusMode = 115, + layoutInfo = 116, + wrappingInfo = 117 } /** diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 947bdf93a470e..8407dfa7ab72b 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -3129,6 +3129,10 @@ declare namespace monaco.editor { * Defaults to false. */ definitionLinkOpensInPeek?: boolean; + /** + * Controls strikethrough deprecated variables. + */ + showDeprecated?: boolean; } export interface IEditorConstructionOptions extends IEditorOptions { @@ -3945,11 +3949,12 @@ declare namespace monaco.editor { wordWrapMinified = 109, wrappingIndent = 110, wrappingStrategy = 111, - editorClassName = 112, - pixelRatio = 113, - tabFocusMode = 114, - layoutInfo = 115, - wrappingInfo = 116 + showDeprecated = 112, + editorClassName = 113, + pixelRatio = 114, + tabFocusMode = 115, + layoutInfo = 116, + wrappingInfo = 117 } export const EditorOptions: { acceptSuggestionOnCommitCharacter: IEditorOption; @@ -4045,6 +4050,7 @@ declare namespace monaco.editor { selectOnLineNumbers: IEditorOption; showFoldingControls: IEditorOption; showUnused: IEditorOption; + showDeprecated: IEditorOption; snippetSuggestions: IEditorOption; smoothScrolling: IEditorOption; stopRenderingLineAfter: IEditorOption; From 3f8ba30995bf1466783122ce6d91a149a5e49e03 Mon Sep 17 00:00:00 2001 From: kingwl Date: Fri, 19 Jun 2020 11:41:21 +0800 Subject: [PATCH 13/15] fix type --- extensions/search-result/src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/search-result/src/extension.ts b/extensions/search-result/src/extension.ts index cccc337a4b947..abb85dac20123 100644 --- a/extensions/search-result/src/extension.ts +++ b/extensions/search-result/src/extension.ts @@ -91,7 +91,7 @@ export function activate(context: vscode.ExtensionContext) { }), vscode.languages.registerDocumentLinkProvider(SEARCH_RESULT_SELECTOR, { - async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { + async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { return parseSearchResults(document, token) .filter(({ type }) => type === 'file') .map(({ location }) => ({ range: location.originSelectionRange!, target: location.targetUri })); From a371e46780f0b8a8c4a132f9e6c21414fbe6f850 Mon Sep 17 00:00:00 2001 From: kingwl Date: Sat, 20 Jun 2020 16:12:23 +0800 Subject: [PATCH 14/15] Use expiremental namepsace --- extensions/package.json | 2 +- extensions/search-result/src/extension.ts | 2 +- .../src/features/callHierarchy.ts | 8 +++++++- .../src/typeScriptServiceClientHost.ts | 8 +++++++- extensions/yarn.lock | 9 +++++---- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/extensions/package.json b/extensions/package.json index 6996127a495be..e54ff1794b2e8 100644 --- a/extensions/package.json +++ b/extensions/package.json @@ -3,7 +3,7 @@ "version": "0.0.1", "description": "Dependencies shared by all extensions", "dependencies": { - "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/76276/artifacts?artifactName=tgz&fileId=78E053053EC04273CA27295F7B8557AA75922D9BBBB3576EC2256F647AD5273202&fileName=/typescript-4.0.0-insiders.20200612.tgz" + "typescript": "3.9.5" }, "scripts": { "postinstall": "node ./postinstall" diff --git a/extensions/search-result/src/extension.ts b/extensions/search-result/src/extension.ts index abb85dac20123..43c7b28a6431f 100644 --- a/extensions/search-result/src/extension.ts +++ b/extensions/search-result/src/extension.ts @@ -91,7 +91,7 @@ export function activate(context: vscode.ExtensionContext) { }), vscode.languages.registerDocumentLinkProvider(SEARCH_RESULT_SELECTOR, { - async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { + async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { return parseSearchResults(document, token) .filter(({ type }) => type === 'file') .map(({ location }) => ({ range: location.originSelectionRange!, target: location.targetUri })); diff --git a/extensions/typescript-language-features/src/features/callHierarchy.ts b/extensions/typescript-language-features/src/features/callHierarchy.ts index 414acce720de9..3e84d255ee553 100644 --- a/extensions/typescript-language-features/src/features/callHierarchy.ts +++ b/extensions/typescript-language-features/src/features/callHierarchy.ts @@ -13,6 +13,12 @@ import * as path from 'path'; import * as PConst from '../protocol.const'; import { parseKindModifier } from '../utils/modifiers'; +namespace Experimental { + export interface CallHierarchyItem extends Proto.CallHierarchyItem { + readonly kindModifiers?: string; + } +} + class TypeScriptCallHierarchySupport implements vscode.CallHierarchyProvider { public static readonly minVersion = API.v380; @@ -76,7 +82,7 @@ function isSourceFileItem(item: Proto.CallHierarchyItem) { return item.kind === PConst.Kind.script || item.kind === PConst.Kind.module && item.selectionSpan.start.line === 1 && item.selectionSpan.start.offset === 1; } -function fromProtocolCallHierarchyItem(item: Proto.CallHierarchyItem): vscode.CallHierarchyItem { +function fromProtocolCallHierarchyItem(item: Experimental.CallHierarchyItem): vscode.CallHierarchyItem { const useFileName = isSourceFileItem(item); const name = useFileName ? path.basename(item.file) : item.name; const detail = useFileName ? vscode.workspace.asRelativePath(path.dirname(item.file)) : ''; diff --git a/extensions/typescript-language-features/src/typeScriptServiceClientHost.ts b/extensions/typescript-language-features/src/typeScriptServiceClientHost.ts index 788884f27e29b..1f1beaa382a17 100644 --- a/extensions/typescript-language-features/src/typeScriptServiceClientHost.ts +++ b/extensions/typescript-language-features/src/typeScriptServiceClientHost.ts @@ -26,6 +26,12 @@ import * as typeConverters from './utils/typeConverters'; import TypingsStatus, { AtaProgressReporter } from './utils/typingsStatus'; import VersionStatus from './utils/versionStatus'; +namespace Experimental { + export interface Diagnostic extends Proto.Diagnostic { + readonly reportsDeprecated?: {} + } +} + // Style check diagnostics that can be reported as warnings const styleCheckDiagnostics = new Set([ ...errorCodes.variableDeclaredButNeverUsed, @@ -237,7 +243,7 @@ export default class TypeScriptServiceClientHost extends Disposable { return diagnostics.map(tsDiag => this.tsDiagnosticToVsDiagnostic(tsDiag, source)); } - private tsDiagnosticToVsDiagnostic(diagnostic: Proto.Diagnostic, source: string): vscode.Diagnostic & { reportUnnecessary: any, reportDeprecated: any } { + private tsDiagnosticToVsDiagnostic(diagnostic: Experimental.Diagnostic, source: string): vscode.Diagnostic & { reportUnnecessary: any, reportDeprecated: any } { const { start, end, text } = diagnostic; const range = new vscode.Range(typeConverters.Position.fromLocation(start), typeConverters.Position.fromLocation(end)); const converted = new vscode.Diagnostic(range, text, this.getDiagnosticSeverity(diagnostic)); diff --git a/extensions/yarn.lock b/extensions/yarn.lock index b441fe1cb8d84..e0f5c7c4dd07e 100644 --- a/extensions/yarn.lock +++ b/extensions/yarn.lock @@ -2,10 +2,6 @@ # yarn lockfile v1 -"typescript@https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/76276/artifacts?artifactName=tgz&fileId=78E053053EC04273CA27295F7B8557AA75922D9BBBB3576EC2256F647AD5273202&fileName=/typescript-4.0.0-insiders.20200612.tgz": - version "4.0.0-insiders.20200612" - resolved "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/76276/artifacts?artifactName=tgz&fileId=78E053053EC04273CA27295F7B8557AA75922D9BBBB3576EC2256F647AD5273202&fileName=/typescript-4.0.0-insiders.20200612.tgz#56d14a37a058bab28c83620c99ba4167170edc7b" - balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" @@ -80,6 +76,11 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" +typescript@3.9.5: + version "3.9.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.5.tgz#586f0dba300cde8be52dd1ac4f7e1009c1b13f36" + integrity sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ== + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" From 72b6d1979a9590af5d7c7b185e59d565012cb059 Mon Sep 17 00:00:00 2001 From: kingwl Date: Sat, 20 Jun 2020 16:13:18 +0800 Subject: [PATCH 15/15] fix types --- extensions/search-result/src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/search-result/src/extension.ts b/extensions/search-result/src/extension.ts index 43c7b28a6431f..abb85dac20123 100644 --- a/extensions/search-result/src/extension.ts +++ b/extensions/search-result/src/extension.ts @@ -91,7 +91,7 @@ export function activate(context: vscode.ExtensionContext) { }), vscode.languages.registerDocumentLinkProvider(SEARCH_RESULT_SELECTOR, { - async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { + async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { return parseSearchResults(document, token) .filter(({ type }) => type === 'file') .map(({ location }) => ({ range: location.originSelectionRange!, target: location.targetUri }));