mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Renames
This commit is contained in:
parent
dddea4442c
commit
5df48870b7
|
@ -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 {
|
||||
|
|
|
@ -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[];
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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 [];
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -32,7 +32,7 @@ suite('TextResourceConfigurationService - Update', () => {
|
|||
setup(() => {
|
||||
const instantiationService = new TestInstantiationService();
|
||||
instantiationService.stub(IModelService, <Partial<IModelService>>{ getModel() { return null; } });
|
||||
instantiationService.stub(ILanguageService, <Partial<ILanguageService>>{ getModeIdByFilepathOrFirstLine() { return language; } });
|
||||
instantiationService.stub(ILanguageService, <Partial<ILanguageService>>{ getLanguageIdByFilepathOrFirstLine() { return language; } });
|
||||
instantiationService.stub(IConfigurationService, configurationService);
|
||||
testObject = instantiationService.createInstance(TextResourceConfigurationService);
|
||||
});
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ export class ResourceContextKey implements IContextKey<URI> {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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}"` : '';
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ class Snapper {
|
|||
}
|
||||
|
||||
public captureSyntaxTokens(fileName: string, content: string): Promise<IToken[]> {
|
||||
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 [];
|
||||
|
|
|
@ -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<string | undefined> {
|
||||
|
|
Loading…
Reference in a new issue