提交 badd8d18 编写于 作者: A Alex Dima

Remove model.getModeId()

上级 bb49af33
......@@ -741,7 +741,7 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom
this.cursor = null;
if (this.model) {
this.domElement.setAttribute('data-mode-id', this.model.getModeId());
this.domElement.setAttribute('data-mode-id', this.model.getLanguageIdentifier().language);
this._configuration.setIsDominatedByLongLines(this.model.isDominatedByLongLines());
this.model.onBeforeAttached();
......@@ -878,7 +878,7 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom
break;
case editorCommon.EventType.ModelModeChanged:
this.domElement.setAttribute('data-mode-id', this.model.getModeId());
this.domElement.setAttribute('data-mode-id', this.model.getLanguageIdentifier().language);
this.emit(editorCommon.EventType.ModelModeChanged, e);
break;
......
......@@ -1816,13 +1816,6 @@ export interface IReadOnlyModel extends ITextModel {
*/
readonly uri: URI;
/**
* Get the language associated with this model.
* TODO@tokenization
* @deprecated
*/
getModeId(): string;
/**
* Get the language associated with this model.
*/
......@@ -1868,13 +1861,6 @@ export interface ITokenizedModel extends ITextModel {
*/
getLineTokens(lineNumber: number, inaccurateTokensAcceptable?: boolean): LineTokens;
/**
* Get the language associated with this model.
* TODO@tokenization
* @deprecated
*/
getModeId(): string;
/**
* Get the language associated with this model.
*/
......
......@@ -203,10 +203,6 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
return this._lines[lineNumber - 1].getTokens(this._languageIdentifier.id, this._colorMap);
}
public getModeId(): string {
return this._languageIdentifier.language;
}
public getLanguageIdentifier(): LanguageIdentifier {
return this._languageIdentifier;
}
......
......@@ -95,7 +95,7 @@ export class EditorModeContext {
this.reset();
return;
}
this._langId.set(model.getModeId());
this._langId.set(model.getLanguageIdentifier().language);
this._hasCompletionItemProvider.set(modes.SuggestRegistry.has(model));
this._hasCodeActionsProvider.set(modes.CodeActionProviderRegistry.has(model));
this._hasCodeLensProvider.set(modes.CodeLensProviderRegistry.has(model));
......
......@@ -126,7 +126,7 @@ export default class LanguageFeatureRegistry<T> {
let candidate = {
uri: model.uri.toString(),
language: model.getModeId()
language: model.getLanguageIdentifier().language
};
if (this._lastCandidate
......@@ -140,7 +140,7 @@ export default class LanguageFeatureRegistry<T> {
this._lastCandidate = candidate;
for (let entry of this._entries) {
entry._score = score(entry.selector, model.uri, model.getModeId());
entry._score = score(entry.selector, model.uri, model.getLanguageIdentifier().language);
}
// needs sorting
......
......@@ -401,7 +401,7 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
};
const detectVisible = new RunOnceScheduler(() => {
this._onViewportChanged(model.getModeId());
this._onViewportChanged(model.getLanguageIdentifier().language);
}, 500);
const scheduler = new RunOnceScheduler(() => {
......
......@@ -255,7 +255,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
// it is possible no alias is given in which case we fall back to the current editor lang
const modeId = languageAlias
? this._modeService.getModeIdForLanguageName(languageAlias)
: this._editor.getModel().getModeId();
: this._editor.getModel().getLanguageIdentifier().language;
return this._modeService.getOrCreateMode(modeId).then(_ => {
return `<div class="code">${tokenizeToString(value, modeId)}</div>`;
......
......@@ -188,7 +188,7 @@ export class ReferencesController implements editorCommon.IEditorContribution {
onDone(duration => this._telemetryService.publicLog('findReferences', {
duration,
mode: this._editor.getModel().getModeId()
mode: this._editor.getModel().getLanguageIdentifier().language
}));
}
......
......@@ -2073,12 +2073,6 @@ declare module monaco.editor {
* Gets the resource associated with this editor model.
*/
readonly uri: Uri;
/**
* Get the language associated with this model.
* TODO@tokenization
* @deprecated
*/
getModeId(): string;
/**
* Get the language associated with this model.
*/
......@@ -2103,12 +2097,6 @@ declare module monaco.editor {
* A model that is tokenized.
*/
export interface ITokenizedModel extends ITextModel {
/**
* Get the language associated with this model.
* TODO@tokenization
* @deprecated
*/
getModeId(): string;
/**
* Get the language associated with this model.
*/
......
......@@ -106,7 +106,7 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
url: model.uri,
versionId: model.getVersionId(),
value: model.toRawText(),
modeId: model.getModeId(),
modeId: model.getLanguageIdentifier().language,
isDirty: this._textFileService.isDirty(modelUrl)
});
}
......@@ -117,7 +117,7 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
if (!this._modelIsSynced[modelUrl.toString()]) {
return;
}
this._proxy.$acceptModelModeChanged(model.uri.toString(), oldModeId, model.getModeId());
this._proxy.$acceptModelModeChanged(model.uri.toString(), oldModeId, model.getLanguageIdentifier().language);
}
private _onModelRemoved(model: editorCommon.IModel): void {
......
......@@ -215,7 +215,7 @@ function getConfiguredLangId(modelService: IModelService, resource: uri): string
if (resource) {
const model = modelService.getModel(resource);
if (model) {
const modeId = model.getModeId();
const modeId = model.getLanguageIdentifier().language;
if (modeId && modeId !== PLAINTEXT_MODE_ID) {
configuredLangId = modeId; // only take if the mode is specific (aka no just plain text)
}
......
......@@ -526,7 +526,7 @@ export class EditorStatus implements IStatusbarItem {
const textModel = getTextModel(editorWidget);
if (textModel) {
// Compute mode
const modeId = textModel.getModeId();
const modeId = textModel.getLanguageIdentifier().language;
info = { mode: this.modeService.getLanguageName(modeId) };
}
}
......@@ -736,7 +736,7 @@ export class ChangeModeAction extends Action {
// Compute mode
let currentModeId: string;
if (textModel) {
const modeId = textModel.getModeId();
const modeId = textModel.getLanguageIdentifier().language;
currentModeId = this.modeService.getLanguageName(modeId);
}
......
......@@ -111,7 +111,7 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
public getModeId(): string {
if (this.textEditorModel) {
return this.textEditorModel.getModeId();
return this.textEditorModel.getLanguageIdentifier().language;
}
return null;
......
......@@ -275,7 +275,7 @@ export class DebugEditorModelManager implements IWorkbenchContribution {
return DebugEditorModelManager.BREAKPOINT_UNSUPPORTED_DECORATION;
}
const modeId = modelData ? modelData.model.getModeId() : '';
const modeId = modelData ? modelData.model.getLanguageIdentifier().language : '';
let condition: string;
if (breakpoint.condition && breakpoint.hitCondition) {
condition = `Expression: ${breakpoint.condition}\nHitCount: ${breakpoint.hitCondition}`;
......
......@@ -383,7 +383,7 @@ export class ConfigurationManager implements debug.IConfigurationManager {
return true;
}
const modeId = model ? model.getModeId() : null;
const modeId = model ? model.getLanguageIdentifier().language : null;
return !!this.allModeIdsForBreakpoints[modeId];
}
......
......@@ -420,7 +420,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
model = (<IDiffEditorModel>model).modified; // Support for diff editor models
}
if (model && types.isFunction((<ITokenizedModel>model).getModeId)) {
if (model && types.isFunction((<ITokenizedModel>model).getLanguageIdentifier)) {
canRun = DocumentSymbolProviderRegistry.has(<IModel>model);
}
}
......@@ -476,7 +476,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
model = (<IDiffEditorModel>model).modified; // Support for diff editor models
}
if (model && types.isFunction((<ITokenizedModel>model).getModeId)) {
if (model && types.isFunction((<ITokenizedModel>model).getLanguageIdentifier)) {
// Ask cache first
const modelId = (<IModel>model).id;
......
......@@ -63,7 +63,7 @@ class ReplacePreviewModel extends Disposable {
return this.textModelResolverService.createModelReference(fileResource).then(ref => {
ref = this._register(ref);
const sourceModel = ref.object.textEditorModel;
const sourceModelModeId = sourceModel.getModeId();
const sourceModelModeId = sourceModel.getLanguageIdentifier().language;
const replacePreviewModel = this.modelService.createModel(sourceModel.getValue(), this.modeService.getOrCreateMode(sourceModelModeId), replacePreviewUri);
this._register(fileMatch.onChange(modelChange => this.update(sourceModel, replacePreviewModel, fileMatch, modelChange)));
this._register(this.searchWorkbenchService.searchModel.onReplaceTermChanged(() => this.update(sourceModel, replacePreviewModel, fileMatch)));
......
......@@ -92,7 +92,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
extHostDocuments.$acceptModelAdd({
isDirty: false,
versionId: model.getVersionId(),
modeId: model.getModeId(),
modeId: model.getLanguageIdentifier().language,
url: model.uri,
value: {
EOL: model.getEOL(),
......
......@@ -85,7 +85,7 @@ suite('ExtHostLanguageFeatures', function () {
extHostDocuments.$acceptModelAdd({
isDirty: false,
versionId: model.getVersionId(),
modeId: model.getModeId(),
modeId: model.getLanguageIdentifier().language,
url: model.uri,
value: {
EOL: model.getEOL(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册