From 5df48870b7bbfaf4ee705485d078af71b5a2c910 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Wed, 8 Dec 2021 15:46:06 +0100 Subject: [PATCH] Renames --- .../editor/common/services/getIconClasses.ts | 2 +- .../editor/common/services/languageService.ts | 2 +- .../common/services/languageServiceImpl.ts | 6 ++--- .../common/services/languagesRegistry.ts | 2 +- .../textResourceConfigurationServiceImpl.ts | 2 +- .../link/goToDefinitionAtPosition.ts | 2 +- .../textResourceConfigurationService.test.ts | 2 +- .../browser/parts/editor/editorStatus.ts | 4 +-- .../parts/editor/textResourceEditor.ts | 26 +++++++++---------- src/vs/workbench/common/resources.ts | 2 +- .../browser/extensionsWorkbenchService.ts | 2 +- .../browser/themes.test.contribution.ts | 2 +- .../languageDetectionWorkerServiceImpl.ts | 2 +- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/vs/editor/common/services/getIconClasses.ts b/src/vs/editor/common/services/getIconClasses.ts index 0d570c27b9f..d54c82f9f33 100644 --- a/src/vs/editor/common/services/getIconClasses.ts +++ b/src/vs/editor/common/services/getIconClasses.ts @@ -95,7 +95,7 @@ function detectModeId(modelService: IModelService, languageService: ILanguageSer } // otherwise fallback to path based detection - return languageService.getModeIdByFilepathOrFirstLine(resource); + return languageService.getLanguageIdByFilepathOrFirstLine(resource); } export function cssEscape(str: string): string { diff --git a/src/vs/editor/common/services/languageService.ts b/src/vs/editor/common/services/languageService.ts index f800fb8fdfd..43af74b9c0f 100644 --- a/src/vs/editor/common/services/languageService.ts +++ b/src/vs/editor/common/services/languageService.ts @@ -44,7 +44,7 @@ export interface ILanguageService { getLanguageName(languageId: string): string | null; getLanguageIdForLanguageName(languageName: string): string | null; getLanguageIdForMimeType(mimeType: string): string | null; - getModeIdByFilepathOrFirstLine(resource: URI, firstLine?: string): string | null; + getLanguageIdByFilepathOrFirstLine(resource: URI, firstLine?: string): string | null; validateLanguageId(languageId: string): string | null; getConfigurationFiles(languageId: string): URI[]; diff --git a/src/vs/editor/common/services/languageServiceImpl.ts b/src/vs/editor/common/services/languageServiceImpl.ts index 60f3c706d07..6370bce874f 100644 --- a/src/vs/editor/common/services/languageServiceImpl.ts +++ b/src/vs/editor/common/services/languageServiceImpl.ts @@ -112,8 +112,8 @@ export class LanguageService extends Disposable implements ILanguageService { return this._registry.getLanguageIdForMimeType(mimeType); } - public getModeIdByFilepathOrFirstLine(resource: URI | null, firstLine?: string): string | null { - const modeIds = this._registry.getModeIdsFromFilepathOrFirstLine(resource, firstLine); + public getLanguageIdByFilepathOrFirstLine(resource: URI | null, firstLine?: string): string | null { + const modeIds = this._registry.getLanguageIdByFilepathOrFirstLine(resource, firstLine); return firstOrDefault(modeIds, null); } @@ -148,7 +148,7 @@ export class LanguageService extends Disposable implements ILanguageService { public createByFilepathOrFirstLine(resource: URI | null, firstLine?: string): ILanguageSelection { return new LanguageSelection(this.onLanguagesMaybeChanged, () => { - const languageId = this.getModeIdByFilepathOrFirstLine(resource, firstLine); + const languageId = this.getLanguageIdByFilepathOrFirstLine(resource, firstLine); return this._createModeAndGetLanguageIdentifier(languageId); }); } diff --git a/src/vs/editor/common/services/languagesRegistry.ts b/src/vs/editor/common/services/languagesRegistry.ts index 668f0c7e099..554acb2758f 100644 --- a/src/vs/editor/common/services/languagesRegistry.ts +++ b/src/vs/editor/common/services/languagesRegistry.ts @@ -348,7 +348,7 @@ export class LanguagesRegistry extends Disposable { return null; } - public getModeIdsFromFilepathOrFirstLine(resource: URI | null, firstLine?: string): string[] { + public getLanguageIdByFilepathOrFirstLine(resource: URI | null, firstLine?: string): string[] { if (!resource && !firstLine) { return []; } diff --git a/src/vs/editor/common/services/textResourceConfigurationServiceImpl.ts b/src/vs/editor/common/services/textResourceConfigurationServiceImpl.ts index b5fcd62bb9c..feb6c12cd94 100644 --- a/src/vs/editor/common/services/textResourceConfigurationServiceImpl.ts +++ b/src/vs/editor/common/services/textResourceConfigurationServiceImpl.ts @@ -111,7 +111,7 @@ export class TextResourceConfigurationService extends Disposable implements ITex if (model) { return position ? model.getLanguageIdAtPosition(position.lineNumber, position.column) : model.getLanguageId(); } - return this.languageService.getModeIdByFilepathOrFirstLine(resource); + return this.languageService.getLanguageIdByFilepathOrFirstLine(resource); } private toResourceConfigurationChangeEvent(configurationChangeEvent: IConfigurationChangeEvent): ITextResourceConfigurationChangeEvent { diff --git a/src/vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition.ts b/src/vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition.ts index 2b1b37fd19d..116305d9c8a 100644 --- a/src/vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition.ts +++ b/src/vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition.ts @@ -204,7 +204,7 @@ export class GotoDefinitionAtPositionEditorContribution implements IEditorContri wordRange = new Range(position.lineNumber, word.startColumn, position.lineNumber, word.endColumn); } - const languageId = this.languageService.getModeIdByFilepathOrFirstLine(textEditorModel.uri); + const languageId = this.languageService.getLanguageIdByFilepathOrFirstLine(textEditorModel.uri); this.addDecoration( wordRange, new MarkdownString().appendCodeblock(languageId ? languageId : '', previewValue) diff --git a/src/vs/editor/test/common/services/textResourceConfigurationService.test.ts b/src/vs/editor/test/common/services/textResourceConfigurationService.test.ts index 91f82ab4897..f4e6182b3d2 100644 --- a/src/vs/editor/test/common/services/textResourceConfigurationService.test.ts +++ b/src/vs/editor/test/common/services/textResourceConfigurationService.test.ts @@ -32,7 +32,7 @@ suite('TextResourceConfigurationService - Update', () => { setup(() => { const instantiationService = new TestInstantiationService(); instantiationService.stub(IModelService, >{ getModel() { return null; } }); - instantiationService.stub(ILanguageService, >{ getModeIdByFilepathOrFirstLine() { return language; } }); + instantiationService.stub(ILanguageService, >{ getLanguageIdByFilepathOrFirstLine() { return language; } }); instantiationService.stub(IConfigurationService, configurationService); testObject = instantiationService.createInstance(TextResourceConfigurationService); }); diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index e731ae64b91..5da4fd7598a 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -1201,7 +1201,7 @@ export class ChangeModeAction extends Action { const resource = EditorResourceAccessor.getOriginalUri(activeEditor, { supportSideBySide: SideBySideEditor.PRIMARY }); if (resource) { // Detect languages since we are in an untitled file - let languageId: string | undefined = withNullAsUndefined(this.languageService.getModeIdByFilepathOrFirstLine(resource, textModel.getLineContent(1))); + let languageId: string | undefined = withNullAsUndefined(this.languageService.getLanguageIdByFilepathOrFirstLine(resource, textModel.getLineContent(1))); if (!languageId) { detectedLanguage = await this.languageDetectionService.detectLanguage(resource); languageId = detectedLanguage; @@ -1247,7 +1247,7 @@ export class ChangeModeAction extends Action { private configureFileAssociation(resource: URI): void { const extension = extname(resource); const base = basename(resource); - const currentAssociation = this.languageService.getModeIdByFilepathOrFirstLine(URI.file(base)); + const currentAssociation = this.languageService.getLanguageIdByFilepathOrFirstLine(URI.file(base)); const languages = this.languageService.getRegisteredLanguageNames(); const picks: IQuickPickItem[] = languages.sort().map((lang, index) => { diff --git a/src/vs/workbench/browser/parts/editor/textResourceEditor.ts b/src/vs/workbench/browser/parts/editor/textResourceEditor.ts index 7ce3a573889..c852fca8abc 100644 --- a/src/vs/workbench/browser/parts/editor/textResourceEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textResourceEditor.ts @@ -181,29 +181,29 @@ export class TextResourceEditor extends AbstractTextResourceEditor { return; // require a live model } - const currentMode = textModel.getLanguageId(); - if (currentMode !== PLAINTEXT_MODE_ID) { - return; // require current mode to be unspecific + const currentLanguageId = textModel.getLanguageId(); + if (currentLanguageId !== PLAINTEXT_MODE_ID) { + return; // require current languageId to be unspecific } - let candidateMode: string | undefined = undefined; + let candidateLanguageId: string | undefined = undefined; - // A mode is provided via the paste event so text was copied using - // VSCode. As such we trust this mode and use it if specific + // A languageId is provided via the paste event so text was copied using + // VSCode. As such we trust this languageId and use it if specific if (e.languageId) { - candidateMode = e.languageId; + candidateLanguageId = e.languageId; } - // A mode was not provided, so the data comes from outside VSCode - // We can still try to guess a good mode from the first line if + // A languageId was not provided, so the data comes from outside VSCode + // We can still try to guess a good languageId from the first line if // the paste changed the first line else { - candidateMode = withNullAsUndefined(this.languageService.getModeIdByFilepathOrFirstLine(textModel.uri, textModel.getLineContent(1).substr(0, ModelConstants.FIRST_LINE_DETECTION_LENGTH_LIMIT))); + candidateLanguageId = withNullAsUndefined(this.languageService.getLanguageIdByFilepathOrFirstLine(textModel.uri, textModel.getLineContent(1).substr(0, ModelConstants.FIRST_LINE_DETECTION_LENGTH_LIMIT))); } - // Finally apply mode to model if specified - if (candidateMode !== PLAINTEXT_MODE_ID) { - this.modelService.setMode(textModel, this.languageService.create(candidateMode)); + // Finally apply languageId to model if specified + if (candidateLanguageId !== PLAINTEXT_MODE_ID) { + this.modelService.setMode(textModel, this.languageService.create(candidateLanguageId)); } } } diff --git a/src/vs/workbench/common/resources.ts b/src/vs/workbench/common/resources.ts index 806b4293886..1e52e04c5a8 100644 --- a/src/vs/workbench/common/resources.ts +++ b/src/vs/workbench/common/resources.ts @@ -89,7 +89,7 @@ export class ResourceContextKey implements IContextKey { this._langIdKey.set(null); return; } - const langId = this._modelService.getModel(value)?.getLanguageId() ?? this._languageService.getModeIdByFilepathOrFirstLine(value); + const langId = this._modelService.getModel(value)?.getLanguageId() ?? this._languageService.getLanguageIdByFilepathOrFirstLine(value); this._langIdKey.set(langId); } diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts b/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts index 412e9a93142..d69af8409e3 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts @@ -805,7 +805,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension const keywords = lookup[ext] || []; // Get mode name - const languageId = this.languageService.getModeIdByFilepathOrFirstLine(URI.file(`.${ext}`)); + const languageId = this.languageService.getLanguageIdByFilepathOrFirstLine(URI.file(`.${ext}`)); const languageName = languageId && this.languageService.getLanguageName(languageId); const languageTag = languageName ? ` tag:"${languageName}"` : ''; diff --git a/src/vs/workbench/contrib/themes/browser/themes.test.contribution.ts b/src/vs/workbench/contrib/themes/browser/themes.test.contribution.ts index d877b697925..d1713161ec4 100644 --- a/src/vs/workbench/contrib/themes/browser/themes.test.contribution.ts +++ b/src/vs/workbench/contrib/themes/browser/themes.test.contribution.ts @@ -216,7 +216,7 @@ class Snapper { } public captureSyntaxTokens(fileName: string, content: string): Promise { - const languageId = this.languageService.getModeIdByFilepathOrFirstLine(URI.file(fileName)); + const languageId = this.languageService.getLanguageIdByFilepathOrFirstLine(URI.file(fileName)); return this.textMateService.createGrammar(languageId!).then((grammar) => { if (!grammar) { return []; diff --git a/src/vs/workbench/services/languageDetection/browser/languageDetectionWorkerServiceImpl.ts b/src/vs/workbench/services/languageDetection/browser/languageDetectionWorkerServiceImpl.ts index b3676c3b3c7..811f5654182 100644 --- a/src/vs/workbench/services/languageDetection/browser/languageDetectionWorkerServiceImpl.ts +++ b/src/vs/workbench/services/languageDetection/browser/languageDetectionWorkerServiceImpl.ts @@ -59,7 +59,7 @@ export class LanguageDetectionService extends Disposable implements ILanguageDet if (!language) { return undefined; } - return this._languageService.getModeIdByFilepathOrFirstLine(URI.file(`file.${language}`)) ?? undefined; + return this._languageService.getLanguageIdByFilepathOrFirstLine(URI.file(`file.${language}`)) ?? undefined; } async detectLanguage(resource: URI): Promise {