mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 06:38:23 +00:00
Use VersionDependentRegistration for update paths on rename
Avoids registering class on unsupported ts versions
This commit is contained in:
parent
d5855b35b2
commit
f97c743507
2 changed files with 12 additions and 9 deletions
|
@ -15,6 +15,7 @@ import { isTypeScriptDocument } from '../utils/languageModeIds';
|
|||
import { escapeRegExp } from '../utils/regexp';
|
||||
import * as typeConverters from '../utils/typeConverters';
|
||||
import FileConfigurationManager from './fileConfigurationManager';
|
||||
import { VersionDependentRegistration } from '../utils/dependentRegistration';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
|
@ -26,7 +27,7 @@ enum UpdateImportsOnFileMoveSetting {
|
|||
Never = 'never',
|
||||
}
|
||||
|
||||
export class UpdateImportsOnFileRenameHandler {
|
||||
class UpdateImportsOnFileRenameHandler {
|
||||
private readonly _onDidRenameSub: vscode.Disposable;
|
||||
|
||||
public constructor(
|
||||
|
@ -47,10 +48,6 @@ export class UpdateImportsOnFileRenameHandler {
|
|||
oldResource: vscode.Uri,
|
||||
newResource: vscode.Uri,
|
||||
): Promise<void> {
|
||||
if (!this.client.apiVersion.gte(API.v290)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const targetResource = await this.getTargetResource(newResource);
|
||||
if (!targetResource) {
|
||||
return;
|
||||
|
@ -304,3 +301,11 @@ export class UpdateImportsOnFileRenameHandler {
|
|||
}
|
||||
}
|
||||
|
||||
export function register(
|
||||
client: ITypeScriptServiceClient,
|
||||
fileConfigurationManager: FileConfigurationManager,
|
||||
handles: (uri: vscode.Uri) => Promise<boolean>,
|
||||
) {
|
||||
return new VersionDependentRegistration(client, API.v290, () =>
|
||||
new UpdateImportsOnFileRenameHandler(client, fileConfigurationManager, handles));
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
import { Diagnostic, DiagnosticRelatedInformation, DiagnosticSeverity, DiagnosticTag, Disposable, Memento, Range, Uri, workspace } from 'vscode';
|
||||
import { DiagnosticKind } from './features/diagnostics';
|
||||
import FileConfigurationManager from './features/fileConfigurationManager';
|
||||
import { UpdateImportsOnFileRenameHandler } from './features/updatePathsOnRename';
|
||||
import { register as registerUpdatePathsOnRename } from './features/updatePathsOnRename';
|
||||
import LanguageProvider from './languageProvider';
|
||||
import * as Proto from './protocol';
|
||||
import * as PConst from './protocol.const';
|
||||
|
@ -45,7 +45,6 @@ export default class TypeScriptServiceClientHost {
|
|||
private readonly disposables: Disposable[] = [];
|
||||
private readonly versionStatus: VersionStatus;
|
||||
private readonly fileConfigurationManager: FileConfigurationManager;
|
||||
private readonly updateImportsOnFileRenameHandler: UpdateImportsOnFileRenameHandler;
|
||||
|
||||
private reportStyleCheckAsWarnings: boolean = true;
|
||||
|
||||
|
@ -101,7 +100,7 @@ export default class TypeScriptServiceClientHost {
|
|||
this.languagePerId.set(description.id, manager);
|
||||
}
|
||||
|
||||
this.updateImportsOnFileRenameHandler = new UpdateImportsOnFileRenameHandler(this.client, this.fileConfigurationManager, uri => this.handles(uri));
|
||||
this.disposables.push(registerUpdatePathsOnRename(this.client, this.fileConfigurationManager, uri => this.handles(uri)));
|
||||
|
||||
this.client.ensureServiceStarted();
|
||||
this.client.onReady(() => {
|
||||
|
@ -152,7 +151,6 @@ export default class TypeScriptServiceClientHost {
|
|||
this.typingsStatus.dispose();
|
||||
this.ataProgressReporter.dispose();
|
||||
this.fileConfigurationManager.dispose();
|
||||
this.updateImportsOnFileRenameHandler.dispose();
|
||||
}
|
||||
|
||||
public get serviceClient(): TypeScriptServiceClient {
|
||||
|
|
Loading…
Reference in a new issue