Skip to content

Commit

Permalink
Remove gating for TS < 2.2.0 features
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mjbvz committed Sep 11, 2019
1 parent f93f19d commit f452455
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }
Expand All @@ -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);
Expand All @@ -50,4 +47,4 @@ export function register(
) {
return vscode.languages.registerReferenceProvider(selector,
new TypeScriptReferenceSupport(client));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 { CachedResponse } from '../tsServer/cachedResponse';
import { ITypeScriptServiceClient } from '../typescriptService';
import API from '../utils/api';
import { ConfigurationDependentRegistration, VersionDependentRegistration } from '../utils/dependentRegistration';
import { ConfigurationDependentRegistration } from '../utils/dependentRegistration';
import * as typeConverters from '../utils/typeConverters';
import { ReferencesCodeLens, TypeScriptBaseCodeLensProvider, getSymbolRange } from './baseCodeLensProvider';
import { CachedResponse } from '../tsServer/cachedResponse';
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);
Expand Down Expand Up @@ -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));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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));
}
20 changes: 9 additions & 11 deletions extensions/typescript-language-features/src/tsServer/spawner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (apiVersion.gte(API.v250)) {
args.push('--useInferredProjectPerProjectRoot');
} else {
args.push('--useSingleInferredProject');
}

if (configuration.disableAutomaticTypeAcquisition || kind === 'syntax') {
args.push('--disableAutomaticTypingAcquisition');
}
if (configuration.disableAutomaticTypeAcquisition || kind === 'syntax') {
args.push('--disableAutomaticTypingAcquisition');
}

if (apiVersion.gte(API.v208) && kind !== 'syntax') {
if (kind !== 'syntax') {
args.push('--enableTelemetry');
}

Expand Down Expand Up @@ -226,4 +224,4 @@ class ChildServerProcess implements TsServerProcess {
kill(): void {
this._process.kill();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 1 addition & 5 deletions extensions/typescript-language-features/src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -66,4 +62,4 @@ export default class API {
public lt(other: API): boolean {
return !this.gte(other);
}
}
}

0 comments on commit f452455

Please sign in to comment.