mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 20:13:32 +01:00
Bundle TS 4.4
This commit is contained in:
@@ -58,7 +58,7 @@ export function activate(
|
||||
new TypeScriptVersion(
|
||||
TypeScriptVersionSource.Bundled,
|
||||
vscode.Uri.joinPath(context.extensionUri, 'dist/browser/typescript/tsserver.web.js').toString(),
|
||||
API.fromSimpleString('4.3.5')));
|
||||
API.fromSimpleString('4.4.1')));
|
||||
|
||||
const lazyClientHost = createLazyClientHost(context, false, {
|
||||
pluginManager,
|
||||
|
||||
@@ -685,7 +685,6 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider<
|
||||
includeExternalModuleExports: completionConfiguration.autoImportSuggestions,
|
||||
includeInsertTextCompletions: true,
|
||||
triggerCharacter: this.getTsTriggerCharacter(context),
|
||||
// @ts-expect-error
|
||||
triggerKind: typeConverters.CompletionTriggerKind.toProtocolCompletionTriggerKind(context.triggerKind),
|
||||
};
|
||||
|
||||
|
||||
@@ -199,7 +199,6 @@ export default class FileConfigurationManager extends Disposable {
|
||||
generateReturnInDocTemplate: config.get<boolean>('suggest.jsdoc.generateReturns', true),
|
||||
includeCompletionsForImportStatements: config.get<boolean>('suggest.includeCompletionsForImportStatements', true),
|
||||
includeCompletionsWithSnippetText: config.get<boolean>('suggest.includeCompletionsWithSnippetText', true),
|
||||
// @ts-expect-error until 4.4
|
||||
allowIncompleteCompletions: true,
|
||||
displayPartsForJSDoc: true,
|
||||
...getInlayHintsPreferences(config),
|
||||
|
||||
@@ -4,82 +4,15 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as Proto from '../protocol';
|
||||
import { DocumentSelector } from '../utils/documentSelector';
|
||||
import { ClientCapability, ITypeScriptServiceClient, ServerResponse, ExecConfig } from '../typescriptService';
|
||||
import type * as Proto from '../protocol';
|
||||
import { ClientCapability, ITypeScriptServiceClient } from '../typescriptService';
|
||||
import API from '../utils/api';
|
||||
import { Condition, conditionalRegistration, requireMinVersion, requireSomeCapability } from '../utils/dependentRegistration';
|
||||
import { Disposable } from '../utils/dispose';
|
||||
import { DocumentSelector } from '../utils/documentSelector';
|
||||
import { Position } from '../utils/typeConverters';
|
||||
import FileConfigurationManager, { getInlayHintsPreferences, InlayHintSettingNames } from './fileConfigurationManager';
|
||||
import API from '../utils/api';
|
||||
import { Disposable } from '../utils/dispose';
|
||||
|
||||
namespace ExperimentalProto {
|
||||
export const enum CommandTypes {
|
||||
ProvideInlineHints = 'ProvideInlayHints'
|
||||
}
|
||||
|
||||
export interface InlayHintsArgs extends Proto.FileRequestArgs {
|
||||
/**
|
||||
* Start position of the span.
|
||||
*/
|
||||
start: number;
|
||||
/**
|
||||
* Length of the span.
|
||||
*/
|
||||
length: number;
|
||||
}
|
||||
|
||||
export interface InlineHintsRequest extends Proto.Request {
|
||||
command: CommandTypes.ProvideInlineHints;
|
||||
arguments: InlayHintsArgs;
|
||||
}
|
||||
|
||||
export enum InlayHintKind {
|
||||
Type = 'Type',
|
||||
Parameter = 'Parameter',
|
||||
Enum = 'Enum'
|
||||
}
|
||||
|
||||
interface InlayHintItem {
|
||||
text: string;
|
||||
position: Proto.Location;
|
||||
kind?: InlayHintKind;
|
||||
whitespaceBefore?: boolean;
|
||||
whitespaceAfter?: boolean;
|
||||
}
|
||||
|
||||
export interface InlayHintsResponse extends Proto.Response {
|
||||
body?: InlayHintItem[];
|
||||
}
|
||||
|
||||
export interface IExtendedTypeScriptServiceClient {
|
||||
execute<K extends keyof ExtendedTsServerRequests>(
|
||||
command: K,
|
||||
args: ExtendedTsServerRequests[K][0],
|
||||
token: vscode.CancellationToken,
|
||||
config?: ExecConfig
|
||||
): Promise<ServerResponse.Response<ExtendedTsServerRequests[K][1]>>;
|
||||
}
|
||||
|
||||
export interface ExtendedTsServerRequests {
|
||||
'provideInlayHints': [InlayHintsArgs, InlayHintsResponse];
|
||||
}
|
||||
|
||||
export namespace InlayHintKind {
|
||||
export function fromProtocolInlayHintKind(kind: InlayHintKind): vscode.InlayHintKind {
|
||||
switch (kind) {
|
||||
case InlayHintKind.Parameter:
|
||||
return vscode.InlayHintKind.Parameter;
|
||||
case InlayHintKind.Type:
|
||||
return vscode.InlayHintKind.Type;
|
||||
case InlayHintKind.Enum:
|
||||
return vscode.InlayHintKind.Other;
|
||||
default:
|
||||
return vscode.InlayHintKind.Other;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const inlayHintSettingNames = [
|
||||
InlayHintSettingNames.parameterNamesSuppressWhenArgumentMatchesName,
|
||||
@@ -122,7 +55,7 @@ class TypeScriptInlayHintsProvider extends Disposable implements vscode.InlayHin
|
||||
|
||||
await this.fileConfigurationManager.ensureConfigurationForDocument(model, token);
|
||||
|
||||
const response = await (this.client as ExperimentalProto.IExtendedTypeScriptServiceClient).execute('provideInlayHints', { file: filepath, start, length }, token);
|
||||
const response = await this.client.execute('provideInlayHints', { file: filepath, start, length }, token);
|
||||
if (response.type !== 'response' || !response.success || !response.body) {
|
||||
return [];
|
||||
}
|
||||
@@ -131,7 +64,7 @@ class TypeScriptInlayHintsProvider extends Disposable implements vscode.InlayHin
|
||||
const result = new vscode.InlayHint(
|
||||
hint.text,
|
||||
Position.fromLocation(hint.position),
|
||||
hint.kind && ExperimentalProto.InlayHintKind.fromProtocolInlayHintKind(hint.kind)
|
||||
hint.kind && fromProtocolInlayHintKind(hint.kind)
|
||||
);
|
||||
result.whitespaceBefore = hint.whitespaceBefore;
|
||||
result.whitespaceAfter = hint.whitespaceAfter;
|
||||
@@ -140,6 +73,16 @@ class TypeScriptInlayHintsProvider extends Disposable implements vscode.InlayHin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function fromProtocolInlayHintKind(kind: Proto.InlayHintKind): vscode.InlayHintKind {
|
||||
switch (kind) {
|
||||
case 'Parameter': return vscode.InlayHintKind.Parameter;
|
||||
case 'Type': return vscode.InlayHintKind.Type;
|
||||
case 'Enum': return vscode.InlayHintKind.Other;
|
||||
default: return vscode.InlayHintKind.Other;
|
||||
}
|
||||
}
|
||||
|
||||
export function requireInlayHintsConfiguration(
|
||||
language: string
|
||||
) {
|
||||
|
||||
@@ -69,6 +69,7 @@ interface StandardTsServerRequests {
|
||||
'provideCallHierarchyIncomingCalls': [Proto.FileLocationRequestArgs, Proto.ProvideCallHierarchyIncomingCallsResponse];
|
||||
'provideCallHierarchyOutgoingCalls': [Proto.FileLocationRequestArgs, Proto.ProvideCallHierarchyOutgoingCallsResponse];
|
||||
'fileReferences': [Proto.FileRequestArgs, Proto.FileReferencesResponse];
|
||||
'provideInlayHints': [Proto.InlayHintsRequestArgs, Proto.InlayHintsResponse];
|
||||
}
|
||||
|
||||
interface NoResponseTsServerRequests {
|
||||
|
||||
@@ -128,7 +128,6 @@ export namespace SymbolKind {
|
||||
}
|
||||
|
||||
export namespace CompletionTriggerKind {
|
||||
// @ts-expect-error until 4.4
|
||||
// TODO: once 4.4 protocol is available, replace number literals in return statements.
|
||||
export function toProtocolCompletionTriggerKind(kind: vscode.CompletionTriggerKind): Proto.CompletionTriggerKind {
|
||||
switch (kind) {
|
||||
|
||||
Reference in New Issue
Block a user