Add two alternative language-changing interface functions

This commit is contained in:
mechatroner
2018-08-03 00:48:14 -04:00
parent 2582f425b6
commit 2eabbee449
11 changed files with 76 additions and 10 deletions

View File

@@ -258,6 +258,9 @@ export function createApiFactory(
getLanguages(): TPromise<string[]> {
return extHostLanguages.getLanguages();
},
setLanguageById(documentUri: vscode.Uri, languageId: string): TPromise<void> {
return extHostLanguages.setLanguageById(documentUri, languageId);
},
match(selector: vscode.DocumentSelector, document: vscode.TextDocument): number {
return score(typeConverters.LanguageSelector.from(selector), document.uri, document.languageId, true);
},

View File

@@ -194,6 +194,7 @@ export interface MainThreadTextEditorsShape extends IDisposable {
$tryHideEditor(id: string): TPromise<void>;
$trySetOptions(id: string, options: ITextEditorConfigurationUpdate): TPromise<void>;
$trySetLanguageById(id: string, languageId: string): TPromise<void>;
$trySetLanguageByName(id: string, languageName: string): TPromise<void>;
$trySetDecorations(id: string, key: string, ranges: editorCommon.IDecorationOptions[]): TPromise<void>;
$trySetDecorationsFast(id: string, key: string, ranges: number[]): TPromise<void>;
$tryRevealRange(id: string, range: IRange, revealType: TextEditorRevealType): TPromise<void>;
@@ -288,6 +289,7 @@ export interface MainThreadLanguageFeaturesShape extends IDisposable {
export interface MainThreadLanguagesShape extends IDisposable {
$getLanguages(): TPromise<string[]>;
$setLanguageById(resource: UriComponents, languageId: string): TPromise<void>;
}
export interface MainThreadMessageOptions {

View File

@@ -6,6 +6,7 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { MainContext, MainThreadLanguagesShape, IMainContext } from './extHost.protocol';
import * as vscode from 'vscode';
export class ExtHostLanguages {
@@ -20,4 +21,7 @@ export class ExtHostLanguages {
getLanguages(): TPromise<string[]> {
return this._proxy.$getLanguages();
}
setLanguageById(documentUri: vscode.Uri, languageId: string): TPromise<void> {
return this._proxy.$setLanguageById(documentUri, languageId);
}
}

View File

@@ -435,8 +435,12 @@ export class ExtHostTextEditor implements vscode.TextEditor {
this._trySetSelection();
}
setLanguageById(language_id: string): void {
this._runOnProxy(() => this._proxy.$trySetLanguageById(this._id, language_id));
setLanguageById(languageId: string): void {
this._runOnProxy(() => this._proxy.$trySetLanguageById(this._id, languageId));
}
setLanguageByName(languageName: string): void {
this._runOnProxy(() => this._proxy.$trySetLanguageByName(this._id, languageName));
}
setDecorations(decorationType: vscode.TextEditorDecorationType, ranges: Range[] | vscode.DecorationOptions[]): void {