Remove gating for TS < 2.2.0 features

Based on telemetry, these versions have pretty much zero usage in the past 30 days. Removing the extra gating code since we can now assume users are on TS > 2.2.
This commit is contained in:
Matt Bierner
2019-09-11 15:50:33 -07:00
parent f93f19d23c
commit f4524551e9
8 changed files with 45 additions and 76 deletions

View File

@@ -177,11 +177,9 @@ class SyncedBuffer {
fileContent: this.document.getText(),
};
if (this.client.apiVersion.gte(API.v203)) {
const scriptKind = mode2ScriptKind(this.document.languageId);
if (scriptKind) {
args.scriptKindName = scriptKind;
}
const scriptKind = mode2ScriptKind(this.document.languageId);
if (scriptKind) {
args.scriptKindName = scriptKind;
}
if (this.client.apiVersion.gte(API.v230)) {

View File

@@ -11,7 +11,6 @@ import API from '../utils/api';
import { nulToken } from '../utils/cancellation';
import { applyCodeActionCommands, getEditForCodeAction } from '../utils/codeAction';
import { Command, CommandManager } from '../utils/commandManager';
import { VersionDependentRegistration } from '../utils/dependentRegistration';
import { memoize } from '../utils/memoize';
import TelemetryReporter from '../utils/telemetry';
import * as typeConverters from '../utils/typeConverters';
@@ -174,7 +173,6 @@ class SupportedCodeActionProvider {
}
class TypeScriptQuickFixProvider implements vscode.CodeActionProvider {
public static readonly minVersion = API.v213;
public static readonly metadata: vscode.CodeActionProviderMetadata = {
providedCodeActionKinds: [vscode.CodeActionKind.QuickFix]
@@ -343,8 +341,7 @@ export function register(
diagnosticsManager: DiagnosticsManager,
telemetryReporter: TelemetryReporter
) {
return new VersionDependentRegistration(client, TypeScriptQuickFixProvider.minVersion, () =>
vscode.languages.registerCodeActionsProvider(selector,
new TypeScriptQuickFixProvider(client, fileConfigurationManager, commandManager, diagnosticsManager, telemetryReporter),
TypeScriptQuickFixProvider.metadata));
return vscode.languages.registerCodeActionsProvider(selector,
new TypeScriptQuickFixProvider(client, fileConfigurationManager, commandManager, diagnosticsManager, telemetryReporter),
TypeScriptQuickFixProvider.metadata);
}

View File

@@ -5,10 +5,8 @@
import * as vscode from 'vscode';
import { ITypeScriptServiceClient } from '../typescriptService';
import API from '../utils/api';
import * as typeConverters from '../utils/typeConverters';
class TypeScriptReferenceSupport implements vscode.ReferenceProvider {
public constructor(
private readonly client: ITypeScriptServiceClient) { }
@@ -31,9 +29,8 @@ class TypeScriptReferenceSupport implements vscode.ReferenceProvider {
}
const result: vscode.Location[] = [];
const has203Features = this.client.apiVersion.gte(API.v203);
for (const ref of response.body.refs) {
if (!options.includeDeclaration && has203Features && ref.isDefinition) {
if (!options.includeDeclaration && ref.isDefinition) {
continue;
}
const url = this.client.toResource(ref.file);
@@ -50,4 +47,4 @@ export function register(
) {
return vscode.languages.registerReferenceProvider(selector,
new TypeScriptReferenceSupport(client));
}
}

View File

@@ -7,18 +7,15 @@ import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import * as Proto from '../protocol';
import * as PConst from '../protocol.const';
import { ITypeScriptServiceClient } from '../typescriptService';
import API from '../utils/api';
import { ConfigurationDependentRegistration, VersionDependentRegistration } from '../utils/dependentRegistration';
import * as typeConverters from '../utils/typeConverters';
import { ReferencesCodeLens, TypeScriptBaseCodeLensProvider, getSymbolRange } from './baseCodeLensProvider';
import { CachedResponse } from '../tsServer/cachedResponse';
import { ITypeScriptServiceClient } from '../typescriptService';
import { ConfigurationDependentRegistration } from '../utils/dependentRegistration';
import * as typeConverters from '../utils/typeConverters';
import { getSymbolRange, ReferencesCodeLens, TypeScriptBaseCodeLensProvider } from './baseCodeLensProvider';
const localize = nls.loadMessageBundle();
class TypeScriptReferencesCodeLensProvider extends TypeScriptBaseCodeLensProvider {
public static readonly minVersion = API.v206;
public async resolveCodeLens(inputCodeLens: vscode.CodeLens, token: vscode.CancellationToken): Promise<vscode.CodeLens> {
const codeLens = inputCodeLens as ReferencesCodeLens;
const args = typeConverters.Position.toFileLocationRequestArgs(codeLens.file, codeLens.range.start);
@@ -99,9 +96,8 @@ export function register(
client: ITypeScriptServiceClient,
cachedResponse: CachedResponse<Proto.NavTreeResponse>,
) {
return new VersionDependentRegistration(client, TypeScriptReferencesCodeLensProvider.minVersion, () =>
new ConfigurationDependentRegistration(modeId, 'referencesCodeLens.enabled', () => {
return vscode.languages.registerCodeLensProvider(selector,
new TypeScriptReferencesCodeLensProvider(client, cachedResponse));
}));
}
return new ConfigurationDependentRegistration(modeId, 'referencesCodeLens.enabled', () => {
return vscode.languages.registerCodeLensProvider(selector,
new TypeScriptReferencesCodeLensProvider(client, cachedResponse));
});
}

View File

@@ -5,13 +5,9 @@
import * as vscode from 'vscode';
import { ITypeScriptServiceClient } from '../typescriptService';
import API from '../utils/api';
import { VersionDependentRegistration } from '../utils/dependentRegistration';
import DefinitionProviderBase from './definitionProviderBase';
export default class TypeScriptTypeDefinitionProvider extends DefinitionProviderBase implements vscode.TypeDefinitionProvider {
public static readonly minVersion = API.v213;
public provideTypeDefinition(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Promise<vscode.Definition | undefined> {
return this.getSymbolLocations('typeDefinition', document, position, token);
}
@@ -21,8 +17,6 @@ export function register(
selector: vscode.DocumentSelector,
client: ITypeScriptServiceClient,
) {
return new VersionDependentRegistration(client, TypeScriptTypeDefinitionProvider.minVersion, () => {
return vscode.languages.registerTypeDefinitionProvider(selector,
new TypeScriptTypeDefinitionProvider(client));
});
}
return vscode.languages.registerTypeDefinitionProvider(selector,
new TypeScriptTypeDefinitionProvider(client));
}

View File

@@ -108,19 +108,17 @@ export class TypeScriptServerSpawner {
args.push('--syntaxOnly');
}
if (apiVersion.gte(API.v206)) {
if (apiVersion.gte(API.v250)) {
args.push('--useInferredProjectPerProjectRoot');
} else {
args.push('--useSingleInferredProject');
}
if (configuration.disableAutomaticTypeAcquisition || kind === 'syntax') {
args.push('--disableAutomaticTypingAcquisition');
}
if (apiVersion.gte(API.v250)) {
args.push('--useInferredProjectPerProjectRoot');
} else {
args.push('--useSingleInferredProject');
}
if (apiVersion.gte(API.v208) && kind !== 'syntax') {
if (configuration.disableAutomaticTypeAcquisition || kind === 'syntax') {
args.push('--disableAutomaticTypingAcquisition');
}
if (kind !== 'syntax') {
args.push('--enableTelemetry');
}
@@ -226,4 +224,4 @@ class ChildServerProcess implements TsServerProcess {
kill(): void {
this._process.kill();
}
}
}

View File

@@ -454,10 +454,6 @@ export default class TypeScriptServiceClient extends Disposable implements IType
}
private setCompilerOptionsForInferredProjects(configuration: TypeScriptServiceConfiguration): void {
if (this.apiVersion.lt(API.v206)) {
return;
}
const args: Proto.SetCompilerOptionsForInferredProjectsArgs = {
options: this.getCompilerOptionsForInferredProjects(configuration)
};
@@ -534,12 +530,10 @@ export default class TypeScriptServiceClient extends Disposable implements IType
}
public normalizedPath(resource: vscode.Uri): string | undefined {
if (this.apiVersion.gte(API.v213)) {
if (resource.scheme === fileSchemes.walkThroughSnippet || resource.scheme === fileSchemes.untitled) {
const dirName = path.dirname(resource.path);
const fileName = this.inMemoryResourcePrefix + path.basename(resource.path);
return resource.with({ path: path.posix.join(dirName, fileName) }).toString(true);
}
if (resource.scheme === fileSchemes.walkThroughSnippet || resource.scheme === fileSchemes.untitled) {
const dirName = path.dirname(resource.path);
const fileName = this.inMemoryResourcePrefix + path.basename(resource.path);
return resource.with({ path: path.posix.join(dirName, fileName) }).toString(true);
}
if (resource.scheme !== fileSchemes.file) {
@@ -572,20 +566,19 @@ export default class TypeScriptServiceClient extends Disposable implements IType
}
public toResource(filepath: string): vscode.Uri {
if (this.apiVersion.gte(API.v213)) {
if (filepath.startsWith(TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME_COLON) || (filepath.startsWith(fileSchemes.untitled + ':'))
) {
let resource = vscode.Uri.parse(filepath);
if (this.inMemoryResourcePrefix) {
const dirName = path.dirname(resource.path);
const fileName = path.basename(resource.path);
if (fileName.startsWith(this.inMemoryResourcePrefix)) {
resource = resource.with({ path: path.posix.join(dirName, fileName.slice(this.inMemoryResourcePrefix.length)) });
}
if (filepath.startsWith(TypeScriptServiceClient.WALK_THROUGH_SNIPPET_SCHEME_COLON) || (filepath.startsWith(fileSchemes.untitled + ':'))
) {
let resource = vscode.Uri.parse(filepath);
if (this.inMemoryResourcePrefix) {
const dirName = path.dirname(resource.path);
const fileName = path.basename(resource.path);
if (fileName.startsWith(this.inMemoryResourcePrefix)) {
resource = resource.with({ path: path.posix.join(dirName, fileName.slice(this.inMemoryResourcePrefix.length)) });
}
return resource;
}
return resource;
}
return this.bufferSyncSupport.toResource(filepath);
}

View File

@@ -13,10 +13,6 @@ export default class API {
}
public static readonly defaultVersion = API.fromSimpleString('1.0.0');
public static readonly v203 = API.fromSimpleString('2.0.3');
public static readonly v206 = API.fromSimpleString('2.0.6');
public static readonly v208 = API.fromSimpleString('2.0.8');
public static readonly v213 = API.fromSimpleString('2.1.3');
public static readonly v220 = API.fromSimpleString('2.2.0');
public static readonly v222 = API.fromSimpleString('2.2.2');
public static readonly v230 = API.fromSimpleString('2.3.0');
@@ -66,4 +62,4 @@ export default class API {
public lt(other: API): boolean {
return !this.gte(other);
}
}
}