mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 15:01:57 +01:00
Remove TS 3.x feature gates
We see very, very low usage of these old TS versions. We also don't actively test them or fix bugs for them
This commit is contained in:
@@ -751,55 +751,40 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider<
|
||||
triggerKind: typeConverters.CompletionTriggerKind.toProtocolCompletionTriggerKind(context.triggerKind),
|
||||
};
|
||||
|
||||
let isNewIdentifierLocation = true;
|
||||
let isIncomplete = false;
|
||||
let isMemberCompletion = false;
|
||||
let dotAccessorContext: DotAccessorContext | undefined;
|
||||
let entries: ReadonlyArray<Proto.CompletionEntry>;
|
||||
let metadata: any | undefined;
|
||||
let response: ServerResponse.Response<Proto.CompletionInfoResponse> | undefined;
|
||||
let duration: number | undefined;
|
||||
let optionalReplacementRange: vscode.Range | undefined;
|
||||
let defaultCommitCharacters: string[] | undefined;
|
||||
if (this.client.apiVersion.gte(API.v300)) {
|
||||
const startTime = Date.now();
|
||||
try {
|
||||
response = await this.client.interruptGetErr(() => this.client.execute('completionInfo', args, token));
|
||||
} finally {
|
||||
duration = Date.now() - startTime;
|
||||
}
|
||||
|
||||
if (response.type !== 'response' || !response.body) {
|
||||
this.logCompletionsTelemetry(duration, response);
|
||||
return undefined;
|
||||
}
|
||||
isNewIdentifierLocation = response.body.isNewIdentifierLocation;
|
||||
isMemberCompletion = response.body.isMemberCompletion;
|
||||
if (isMemberCompletion) {
|
||||
const dotMatch = line.text.slice(0, position.character).match(/\??\.\s*$/) || undefined;
|
||||
if (dotMatch) {
|
||||
const range = new vscode.Range(position.translate({ characterDelta: -dotMatch[0].length }), position);
|
||||
const text = document.getText(range);
|
||||
dotAccessorContext = { range, text };
|
||||
}
|
||||
}
|
||||
isIncomplete = !!response.body.isIncomplete || (response.metadata as any)?.isIncomplete;
|
||||
entries = response.body.entries;
|
||||
metadata = response.metadata;
|
||||
// @ts-expect-error until TS 5.6
|
||||
defaultCommitCharacters = response.body.defaultCommitCharacters;
|
||||
const startTime = Date.now();
|
||||
try {
|
||||
response = await this.client.interruptGetErr(() => this.client.execute('completionInfo', args, token));
|
||||
} finally {
|
||||
duration = Date.now() - startTime;
|
||||
}
|
||||
|
||||
if (response.body.optionalReplacementSpan) {
|
||||
optionalReplacementRange = typeConverters.Range.fromTextSpan(response.body.optionalReplacementSpan);
|
||||
}
|
||||
} else {
|
||||
const response = await this.client.interruptGetErr(() => this.client.execute('completions', args, token));
|
||||
if (response.type !== 'response' || !response.body) {
|
||||
return undefined;
|
||||
if (response.type !== 'response' || !response.body) {
|
||||
this.logCompletionsTelemetry(duration, response);
|
||||
return undefined;
|
||||
}
|
||||
const isNewIdentifierLocation = response.body.isNewIdentifierLocation;
|
||||
const isMemberCompletion = response.body.isMemberCompletion;
|
||||
if (isMemberCompletion) {
|
||||
const dotMatch = line.text.slice(0, position.character).match(/\??\.\s*$/) || undefined;
|
||||
if (dotMatch) {
|
||||
const range = new vscode.Range(position.translate({ characterDelta: -dotMatch[0].length }), position);
|
||||
const text = document.getText(range);
|
||||
dotAccessorContext = { range, text };
|
||||
}
|
||||
}
|
||||
const isIncomplete = !!response.body.isIncomplete || (response.metadata as any)?.isIncomplete;
|
||||
const entries = response.body.entries;
|
||||
const metadata = response.metadata;
|
||||
// @ts-expect-error until TS 5.6
|
||||
const defaultCommitCharacters = response.body.defaultCommitCharacters;
|
||||
|
||||
entries = response.body;
|
||||
metadata = response.metadata;
|
||||
if (response.body.optionalReplacementSpan) {
|
||||
optionalReplacementRange = typeConverters.Range.fromTextSpan(response.body.optionalReplacementSpan);
|
||||
}
|
||||
|
||||
const completionContext: CompletionContext = {
|
||||
@@ -882,11 +867,11 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider<
|
||||
|
||||
private getTsTriggerCharacter(context: vscode.CompletionContext): Proto.CompletionsTriggerCharacter | undefined {
|
||||
switch (context.triggerCharacter) {
|
||||
case '@': { // Workaround for https://github.com/microsoft/TypeScript/issues/27321
|
||||
return this.client.apiVersion.gte(API.v310) && this.client.apiVersion.lt(API.v320) ? undefined : '@';
|
||||
case '@': {
|
||||
return '@';
|
||||
}
|
||||
case '#': { // Workaround for https://github.com/microsoft/TypeScript/issues/36367
|
||||
return this.client.apiVersion.lt(API.v381) ? undefined : '#';
|
||||
case '#': {
|
||||
return '#';
|
||||
}
|
||||
case ' ': {
|
||||
return this.client.apiVersion.gte(API.v430) ? ' ' : undefined;
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import type * as Proto from '../tsServer/protocol/protocol';
|
||||
import { API } from '../tsServer/api';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import { Disposable } from '../utils/dispose';
|
||||
import * as fileSchemes from '../configuration/fileSchemes';
|
||||
import { isTypeScriptDocument } from '../configuration/languageIds';
|
||||
import { API } from '../tsServer/api';
|
||||
import type * as Proto from '../tsServer/protocol/protocol';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import { Disposable } from '../utils/dispose';
|
||||
import { equals } from '../utils/objects';
|
||||
import { ResourceMap } from '../utils/resourceMap';
|
||||
|
||||
@@ -208,7 +208,7 @@ export default class FileConfigurationManager extends Disposable {
|
||||
switch (config.get<string>('quoteStyle')) {
|
||||
case 'single': return 'single';
|
||||
case 'double': return 'double';
|
||||
default: return this.client.apiVersion.gte(API.v333) ? 'auto' : undefined;
|
||||
default: return 'auto';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { DocumentSelector } from '../configuration/documentSelector';
|
||||
import { API } from '../tsServer/api';
|
||||
import * as errorCodes from '../tsServer/protocol/errorCodes';
|
||||
import * as fixNames from '../tsServer/protocol/fixNames';
|
||||
import type * as Proto from '../tsServer/protocol/protocol';
|
||||
@@ -13,7 +12,7 @@ import * as typeConverters from '../typeConverters';
|
||||
import { ClientCapability, ITypeScriptServiceClient } from '../typescriptService';
|
||||
import { DiagnosticsManager } from './diagnostics';
|
||||
import FileConfigurationManager from './fileConfigurationManager';
|
||||
import { conditionalRegistration, requireMinVersion, requireSomeCapability } from './util/dependentRegistration';
|
||||
import { conditionalRegistration, requireSomeCapability } from './util/dependentRegistration';
|
||||
|
||||
|
||||
interface AutoFix {
|
||||
@@ -250,7 +249,6 @@ export function register(
|
||||
diagnosticsManager: DiagnosticsManager,
|
||||
) {
|
||||
return conditionalRegistration([
|
||||
requireMinVersion(client, API.v300),
|
||||
requireSomeCapability(client, ClientCapability.Semantic),
|
||||
], () => {
|
||||
const provider = new TypeScriptAutoFixProvider(client, fileConfigurationManager, diagnosticsManager);
|
||||
|
||||
@@ -36,10 +36,6 @@ class TypeScriptRenameProvider implements vscode.RenameProvider {
|
||||
position: vscode.Position,
|
||||
token: vscode.CancellationToken
|
||||
): Promise<vscode.Range | undefined> {
|
||||
if (this.client.apiVersion.lt(API.v310)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const response = await this.execRename(document, position, token);
|
||||
if (!response) {
|
||||
return undefined;
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as Proto from '../tsServer/protocol/protocol';
|
||||
import { API } from '../tsServer/api';
|
||||
import { ClientCapability, ITypeScriptServiceClient } from '../typescriptService';
|
||||
import { conditionalRegistration, requireMinVersion, requireSomeCapability } from './util/dependentRegistration';
|
||||
import { DocumentSelector } from '../configuration/documentSelector';
|
||||
import * as Proto from '../tsServer/protocol/protocol';
|
||||
import { ClientCapability, ITypeScriptServiceClient } from '../typescriptService';
|
||||
import { conditionalRegistration, requireSomeCapability } from './util/dependentRegistration';
|
||||
|
||||
// as we don't do deltas, for performance reasons, don't compute semantic tokens for documents above that limit
|
||||
const CONTENT_LENGTH_LIMIT = 100000;
|
||||
@@ -18,7 +17,6 @@ export function register(
|
||||
client: ITypeScriptServiceClient,
|
||||
) {
|
||||
return conditionalRegistration([
|
||||
requireMinVersion(client, API.v370),
|
||||
requireSomeCapability(client, ClientCapability.Semantic),
|
||||
], () => {
|
||||
const provider = new DocumentSemanticTokensProvider(client);
|
||||
|
||||
@@ -5,14 +5,11 @@
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { DocumentSelector } from '../configuration/documentSelector';
|
||||
import { API } from '../tsServer/api';
|
||||
import type * as Proto from '../tsServer/protocol/protocol';
|
||||
import * as typeConverters from '../typeConverters';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import { conditionalRegistration, requireMinVersion } from './util/dependentRegistration';
|
||||
|
||||
class SmartSelection implements vscode.SelectionRangeProvider {
|
||||
public static readonly minVersion = API.v350;
|
||||
|
||||
public constructor(
|
||||
private readonly client: ITypeScriptServiceClient
|
||||
@@ -53,9 +50,5 @@ export function register(
|
||||
selector: DocumentSelector,
|
||||
client: ITypeScriptServiceClient,
|
||||
) {
|
||||
return conditionalRegistration([
|
||||
requireMinVersion(client, SmartSelection.minVersion),
|
||||
], () => {
|
||||
return vscode.languages.registerSelectionRangeProvider(selector.syntax, new SmartSelection(client));
|
||||
});
|
||||
return vscode.languages.registerSelectionRangeProvider(selector.syntax, new SmartSelection(client));
|
||||
}
|
||||
|
||||
@@ -4,17 +4,15 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import type * as Proto from '../tsServer/protocol/protocol';
|
||||
import { API } from '../tsServer/api';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import { Condition, conditionalRegistration, requireMinVersion } from './util/dependentRegistration';
|
||||
import { Disposable } from '../utils/dispose';
|
||||
import { DocumentSelector } from '../configuration/documentSelector';
|
||||
import { LanguageDescription } from '../configuration/languageDescription';
|
||||
import type * as Proto from '../tsServer/protocol/protocol';
|
||||
import * as typeConverters from '../typeConverters';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import { Disposable } from '../utils/dispose';
|
||||
import { Condition, conditionalRegistration } from './util/dependentRegistration';
|
||||
|
||||
class TagClosing extends Disposable {
|
||||
public static readonly minVersion = API.v300;
|
||||
|
||||
private _disposed = false;
|
||||
private _timeout: NodeJS.Timeout | undefined = undefined;
|
||||
@@ -167,7 +165,6 @@ export function register(
|
||||
client: ITypeScriptServiceClient,
|
||||
) {
|
||||
return conditionalRegistration([
|
||||
requireMinVersion(client, TagClosing.minVersion),
|
||||
requireActiveDocumentSetting(selector.syntax, language)
|
||||
], () => new TagClosing(client));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import * as fileSchemes from '../configuration/fileSchemes';
|
||||
import { doesResourceLookLikeATypeScriptFile } from '../configuration/languageDescription';
|
||||
import { API } from '../tsServer/api';
|
||||
import type * as Proto from '../tsServer/protocol/protocol';
|
||||
import * as typeConverters from '../typeConverters';
|
||||
import { ClientCapability, ITypeScriptServiceClient } from '../typescriptService';
|
||||
@@ -15,7 +14,7 @@ import { Delayer } from '../utils/async';
|
||||
import { nulToken } from '../utils/cancellation';
|
||||
import { Disposable } from '../utils/dispose';
|
||||
import FileConfigurationManager from './fileConfigurationManager';
|
||||
import { conditionalRegistration, requireMinVersion, requireSomeCapability } from './util/dependentRegistration';
|
||||
import { conditionalRegistration, requireSomeCapability } from './util/dependentRegistration';
|
||||
|
||||
|
||||
const updateImportsOnFileMoveName = 'updateImportsOnFileMove.enabled';
|
||||
@@ -43,7 +42,6 @@ interface RenameAction {
|
||||
}
|
||||
|
||||
class UpdateImportsOnFileRenameHandler extends Disposable {
|
||||
public static readonly minVersion = API.v300;
|
||||
|
||||
private readonly _delayer = new Delayer(50);
|
||||
private readonly _pendingRenames = new Set<RenameAction>();
|
||||
@@ -289,7 +287,6 @@ export function register(
|
||||
handles: (uri: vscode.Uri) => Promise<boolean>,
|
||||
) {
|
||||
return conditionalRegistration([
|
||||
requireMinVersion(client, UpdateImportsOnFileRenameHandler.minVersion),
|
||||
requireSomeCapability(client, ClientCapability.Semantic),
|
||||
], () => {
|
||||
return new UpdateImportsOnFileRenameHandler(client, fileConfigurationManager, handles);
|
||||
|
||||
@@ -13,16 +13,7 @@ export class API {
|
||||
}
|
||||
|
||||
public static readonly defaultVersion = API.fromSimpleString('1.0.0');
|
||||
public static readonly v300 = API.fromSimpleString('3.0.0');
|
||||
public static readonly v310 = API.fromSimpleString('3.1.0');
|
||||
public static readonly v314 = API.fromSimpleString('3.1.4');
|
||||
public static readonly v320 = API.fromSimpleString('3.2.0');
|
||||
public static readonly v333 = API.fromSimpleString('3.3.3');
|
||||
public static readonly v340 = API.fromSimpleString('3.4.0');
|
||||
public static readonly v350 = API.fromSimpleString('3.5.0');
|
||||
public static readonly v370 = API.fromSimpleString('3.7.0');
|
||||
public static readonly v380 = API.fromSimpleString('3.8.0');
|
||||
public static readonly v381 = API.fromSimpleString('3.8.1');
|
||||
public static readonly v390 = API.fromSimpleString('3.9.0');
|
||||
public static readonly v400 = API.fromSimpleString('4.0.0');
|
||||
public static readonly v401 = API.fromSimpleString('4.0.1');
|
||||
|
||||
@@ -78,24 +78,14 @@ class BufferSynchronizer {
|
||||
}
|
||||
|
||||
public open(resource: vscode.Uri, args: Proto.OpenRequestArgs) {
|
||||
if (this.supportsBatching) {
|
||||
this.updatePending(resource, new OpenOperation(args, args.scriptKindName));
|
||||
} else {
|
||||
this.client.executeWithoutWaitingForResponse('open', args);
|
||||
}
|
||||
this.updatePending(resource, new OpenOperation(args, args.scriptKindName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Was the buffer open?
|
||||
*/
|
||||
public close(resource: vscode.Uri, filepath: string, scriptKind: ScriptKind | undefined): boolean {
|
||||
if (this.supportsBatching) {
|
||||
return this.updatePending(resource, new CloseOperation(filepath, scriptKind));
|
||||
} else {
|
||||
const args: Proto.FileRequestArgs = { file: filepath };
|
||||
this.client.executeWithoutWaitingForResponse('close', args);
|
||||
return true;
|
||||
}
|
||||
return this.updatePending(resource, new CloseOperation(filepath, scriptKind));
|
||||
}
|
||||
|
||||
public change(resource: vscode.Uri, filepath: string, events: readonly vscode.TextDocumentContentChangeEvent[]) {
|
||||
@@ -103,24 +93,14 @@ class BufferSynchronizer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.supportsBatching) {
|
||||
this.updatePending(resource, new ChangeOperation({
|
||||
fileName: filepath,
|
||||
textChanges: events.map((change): Proto.CodeEdit => ({
|
||||
newText: change.text,
|
||||
start: typeConverters.Position.toLocation(change.range.start),
|
||||
end: typeConverters.Position.toLocation(change.range.end),
|
||||
})).reverse(), // Send the edits end-of-document to start-of-document order
|
||||
}));
|
||||
} else {
|
||||
for (const { range, text } of events) {
|
||||
const args: Proto.ChangeRequestArgs = {
|
||||
insertString: text,
|
||||
...typeConverters.Range.toFormattingRequestArgs(filepath, range)
|
||||
};
|
||||
this.client.executeWithoutWaitingForResponse('change', args);
|
||||
}
|
||||
}
|
||||
this.updatePending(resource, new ChangeOperation({
|
||||
fileName: filepath,
|
||||
textChanges: events.map((change): Proto.CodeEdit => ({
|
||||
newText: change.text,
|
||||
start: typeConverters.Position.toLocation(change.range.start),
|
||||
end: typeConverters.Position.toLocation(change.range.end),
|
||||
})).reverse(), // Send the edits end-of-document to start-of-document order
|
||||
}));
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
@@ -136,12 +116,6 @@ class BufferSynchronizer {
|
||||
}
|
||||
|
||||
private flush() {
|
||||
if (!this.supportsBatching) {
|
||||
// We've already eagerly synchronized
|
||||
this._pending.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._pending.size > 0) {
|
||||
const closedFiles: string[] = [];
|
||||
const openFiles: Proto.OpenRequestArgs[] = [];
|
||||
@@ -158,10 +132,6 @@ class BufferSynchronizer {
|
||||
}
|
||||
}
|
||||
|
||||
private get supportsBatching(): boolean {
|
||||
return this.client.apiVersion.gte(API.v340);
|
||||
}
|
||||
|
||||
private updatePending(resource: vscode.Uri, op: BufferOperation): boolean {
|
||||
switch (op.type) {
|
||||
case BufferOperationType.Close: {
|
||||
|
||||
@@ -116,12 +116,9 @@ export class TypeScriptServerSpawner {
|
||||
return CompositeServerType.Single;
|
||||
|
||||
case SyntaxServerConfiguration.Auto:
|
||||
if (version.apiVersion?.gte(API.v340)) {
|
||||
return version.apiVersion?.gte(API.v400)
|
||||
? CompositeServerType.DynamicSeparateSyntax
|
||||
: CompositeServerType.SeparateSyntax;
|
||||
}
|
||||
return CompositeServerType.Single;
|
||||
return version.apiVersion?.gte(API.v400)
|
||||
? CompositeServerType.DynamicSeparateSyntax
|
||||
: CompositeServerType.SeparateSyntax;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1232,9 +1232,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
}
|
||||
|
||||
private configurePlugin(pluginName: string, configuration: {}): any {
|
||||
if (this.apiVersion.gte(API.v314)) {
|
||||
this.executeWithoutWaitingForResponse('configurePlugin', { pluginName, configuration });
|
||||
}
|
||||
this.executeWithoutWaitingForResponse('configurePlugin', { pluginName, configuration });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user