mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
More plugin -> extension
This commit is contained in:
@@ -132,14 +132,14 @@ export class ExtHostAPIImplementation {
|
||||
this.TextEditorRevealType = <any>TextEditorRevealType;
|
||||
|
||||
errors.setUnexpectedErrorHandler((err) => {
|
||||
this._proxy.onUnexpectedPluginHostError(errors.transformErrorForSerialization(err));
|
||||
this._proxy.onUnexpectedExtHostError(errors.transformErrorForSerialization(err));
|
||||
});
|
||||
|
||||
const pluginHostCommands = this._threadService.getRemotable(ExtHostCommands);
|
||||
const pluginHostEditors = this._threadService.getRemotable(ExtHostEditors);
|
||||
const pluginHostMessageService = new ExtHostMessageService(this._threadService, this.commands);
|
||||
const pluginHostQuickOpen = this._threadService.getRemotable(ExtHostQuickOpen);
|
||||
const pluginHostStatusBar = new ExtHostStatusBar(this._threadService);
|
||||
const extHostCommands = this._threadService.getRemotable(ExtHostCommands);
|
||||
const extHostEditors = this._threadService.getRemotable(ExtHostEditors);
|
||||
const extHostMessageService = new ExtHostMessageService(this._threadService, this.commands);
|
||||
const extHostQuickOpen = this._threadService.getRemotable(ExtHostQuickOpen);
|
||||
const extHostStatusBar = new ExtHostStatusBar(this._threadService);
|
||||
const extHostOutputService = new ExtHostOutputService(this._threadService);
|
||||
|
||||
// env namespace
|
||||
@@ -154,12 +154,12 @@ export class ExtHostAPIImplementation {
|
||||
// commands namespace
|
||||
this.commands = {
|
||||
registerCommand<T>(id: string, command: <T>(...args: any[]) => T | Thenable<T>, thisArgs?: any): vscode.Disposable {
|
||||
return pluginHostCommands.registerCommand(id, command, thisArgs);
|
||||
return extHostCommands.registerCommand(id, command, thisArgs);
|
||||
},
|
||||
registerTextEditorCommand(id: string, callback: (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit) => void, thisArg?: any): vscode.Disposable {
|
||||
let actualCallback: typeof callback = thisArg ? callback.bind(thisArg) : callback;
|
||||
return pluginHostCommands.registerCommand(id, () => {
|
||||
let activeTextEditor = pluginHostEditors.getActiveTextEditor();
|
||||
return extHostCommands.registerCommand(id, () => {
|
||||
let activeTextEditor = extHostEditors.getActiveTextEditor();
|
||||
if (!activeTextEditor) {
|
||||
console.warn('Cannot execute ' + id + ' because there is no active text editor.');
|
||||
return;
|
||||
@@ -177,55 +177,55 @@ export class ExtHostAPIImplementation {
|
||||
});
|
||||
},
|
||||
executeCommand<T>(id: string, ...args: any[]): Thenable<T> {
|
||||
return pluginHostCommands.executeCommand(id, ...args);
|
||||
return extHostCommands.executeCommand(id, ...args);
|
||||
},
|
||||
getCommands(filterInternal: boolean = false): Thenable<string[]> {
|
||||
return pluginHostCommands.getCommands(filterInternal);
|
||||
return extHostCommands.getCommands(filterInternal);
|
||||
}
|
||||
};
|
||||
|
||||
this.window = {
|
||||
get activeTextEditor() {
|
||||
return pluginHostEditors.getActiveTextEditor();
|
||||
return extHostEditors.getActiveTextEditor();
|
||||
},
|
||||
get visibleTextEditors() {
|
||||
return pluginHostEditors.getVisibleTextEditors();
|
||||
return extHostEditors.getVisibleTextEditors();
|
||||
},
|
||||
showTextDocument(document: vscode.TextDocument, column?: vscode.ViewColumn, preserveFocus?: boolean): TPromise<vscode.TextEditor> {
|
||||
return pluginHostEditors.showTextDocument(document, column, preserveFocus);
|
||||
return extHostEditors.showTextDocument(document, column, preserveFocus);
|
||||
},
|
||||
createTextEditorDecorationType(options:vscode.DecorationRenderOptions): vscode.TextEditorDecorationType {
|
||||
return pluginHostEditors.createTextEditorDecorationType(options);
|
||||
return extHostEditors.createTextEditorDecorationType(options);
|
||||
},
|
||||
onDidChangeActiveTextEditor: pluginHostEditors.onDidChangeActiveTextEditor.bind(pluginHostEditors),
|
||||
onDidChangeActiveTextEditor: extHostEditors.onDidChangeActiveTextEditor.bind(extHostEditors),
|
||||
onDidChangeTextEditorSelection: (listener: (e: vscode.TextEditorSelectionChangeEvent) => any, thisArgs?: any, disposables?: extHostTypes.Disposable[]) => {
|
||||
return pluginHostEditors.onDidChangeTextEditorSelection(listener, thisArgs, disposables);
|
||||
return extHostEditors.onDidChangeTextEditorSelection(listener, thisArgs, disposables);
|
||||
},
|
||||
onDidChangeTextEditorOptions: (listener: (e: vscode.TextEditorOptionsChangeEvent) => any, thisArgs?: any, disposables?: extHostTypes.Disposable[]) => {
|
||||
return pluginHostEditors.onDidChangeTextEditorOptions(listener, thisArgs, disposables);
|
||||
return extHostEditors.onDidChangeTextEditorOptions(listener, thisArgs, disposables);
|
||||
},
|
||||
onDidChangeTextEditorViewColumn(listener, thisArg?, disposables?) {
|
||||
return pluginHostEditors.onDidChangeTextEditorViewColumn(listener, thisArg, disposables);
|
||||
return extHostEditors.onDidChangeTextEditorViewColumn(listener, thisArg, disposables);
|
||||
},
|
||||
showInformationMessage: (message, ...items) => {
|
||||
return pluginHostMessageService.showMessage(Severity.Info, message, items);
|
||||
return extHostMessageService.showMessage(Severity.Info, message, items);
|
||||
},
|
||||
showWarningMessage: (message, ...items) => {
|
||||
return pluginHostMessageService.showMessage(Severity.Warning, message, items);
|
||||
return extHostMessageService.showMessage(Severity.Warning, message, items);
|
||||
},
|
||||
showErrorMessage: (message, ...items) => {
|
||||
return pluginHostMessageService.showMessage(Severity.Error, message, items);
|
||||
return extHostMessageService.showMessage(Severity.Error, message, items);
|
||||
},
|
||||
showQuickPick: (items: any, options: vscode.QuickPickOptions) => {
|
||||
return pluginHostQuickOpen.show(items, options);
|
||||
return extHostQuickOpen.show(items, options);
|
||||
},
|
||||
showInputBox: pluginHostQuickOpen.input.bind(pluginHostQuickOpen),
|
||||
showInputBox: extHostQuickOpen.input.bind(extHostQuickOpen),
|
||||
|
||||
createStatusBarItem(position?: vscode.StatusBarAlignment, priority?: number): vscode.StatusBarItem {
|
||||
return pluginHostStatusBar.createStatusBarEntry(<number>position, priority);
|
||||
return extHostStatusBar.createStatusBarEntry(<number>position, priority);
|
||||
},
|
||||
setStatusBarMessage(text: string, timeoutOrThenable?: number | Thenable<any>): vscode.Disposable {
|
||||
return pluginHostStatusBar.setStatusBarMessage(text, timeoutOrThenable);
|
||||
return extHostStatusBar.setStatusBarMessage(text, timeoutOrThenable);
|
||||
},
|
||||
createOutputChannel(name: string): vscode.OutputChannel {
|
||||
return extHostOutputService.createOutputChannel(name);
|
||||
@@ -234,33 +234,33 @@ export class ExtHostAPIImplementation {
|
||||
|
||||
//
|
||||
const workspacePath = contextService.getWorkspace() ? contextService.getWorkspace().resource.fsPath : undefined;
|
||||
const pluginHostFileSystemEvent = threadService.getRemotable(ExtHostFileSystemEventService);
|
||||
const pluginHostWorkspace = new ExtHostWorkspace(this._threadService, workspacePath);
|
||||
const pluginHostDocuments = this._threadService.getRemotable(ExtHostModelService);
|
||||
const extHostFileSystemEvent = threadService.getRemotable(ExtHostFileSystemEventService);
|
||||
const extHostWorkspace = new ExtHostWorkspace(this._threadService, workspacePath);
|
||||
const extHostDocuments = this._threadService.getRemotable(ExtHostModelService);
|
||||
this.workspace = Object.freeze({
|
||||
get rootPath() {
|
||||
return pluginHostWorkspace.getPath();
|
||||
return extHostWorkspace.getPath();
|
||||
},
|
||||
set rootPath(value) {
|
||||
throw errors.readonly();
|
||||
},
|
||||
asRelativePath: (pathOrUri) => {
|
||||
return pluginHostWorkspace.getRelativePath(pathOrUri);
|
||||
return extHostWorkspace.getRelativePath(pathOrUri);
|
||||
},
|
||||
findFiles: (include, exclude, maxResults?, token?) => {
|
||||
return pluginHostWorkspace.findFiles(include, exclude, maxResults, token);
|
||||
return extHostWorkspace.findFiles(include, exclude, maxResults, token);
|
||||
},
|
||||
saveAll: (includeUntitled?) => {
|
||||
return pluginHostWorkspace.saveAll(includeUntitled);
|
||||
return extHostWorkspace.saveAll(includeUntitled);
|
||||
},
|
||||
applyEdit(edit: vscode.WorkspaceEdit): TPromise<boolean> {
|
||||
return pluginHostWorkspace.appyEdit(edit);
|
||||
return extHostWorkspace.appyEdit(edit);
|
||||
},
|
||||
createFileSystemWatcher: (pattern, ignoreCreate, ignoreChange, ignoreDelete): vscode.FileSystemWatcher => {
|
||||
return pluginHostFileSystemEvent.createFileSystemWatcher(pattern, ignoreCreate, ignoreChange, ignoreDelete);
|
||||
return extHostFileSystemEvent.createFileSystemWatcher(pattern, ignoreCreate, ignoreChange, ignoreDelete);
|
||||
},
|
||||
get textDocuments() {
|
||||
return pluginHostDocuments.getAllDocumentData().map(data => data.document);
|
||||
return extHostDocuments.getAllDocumentData().map(data => data.document);
|
||||
},
|
||||
set textDocuments(value) {
|
||||
throw errors.readonly();
|
||||
@@ -274,31 +274,31 @@ export class ExtHostAPIImplementation {
|
||||
} else {
|
||||
throw new Error('illegal argument - uriOrFileName');
|
||||
}
|
||||
return pluginHostDocuments.ensureDocumentData(uri).then(() => {
|
||||
const data = pluginHostDocuments.getDocumentData(uri);
|
||||
return extHostDocuments.ensureDocumentData(uri).then(() => {
|
||||
const data = extHostDocuments.getDocumentData(uri);
|
||||
return data && data.document;
|
||||
});
|
||||
},
|
||||
registerTextDocumentContentProvider(scheme: string, provider: vscode.TextDocumentContentProvider) {
|
||||
return pluginHostDocuments.registerTextDocumentContentProvider(scheme, provider);
|
||||
return extHostDocuments.registerTextDocumentContentProvider(scheme, provider);
|
||||
},
|
||||
onDidOpenTextDocument: (listener, thisArgs?, disposables?) => {
|
||||
return pluginHostDocuments.onDidAddDocument(listener, thisArgs, disposables);
|
||||
return extHostDocuments.onDidAddDocument(listener, thisArgs, disposables);
|
||||
},
|
||||
onDidCloseTextDocument: (listener, thisArgs?, disposables?) => {
|
||||
return pluginHostDocuments.onDidRemoveDocument(listener, thisArgs, disposables);
|
||||
return extHostDocuments.onDidRemoveDocument(listener, thisArgs, disposables);
|
||||
},
|
||||
onDidChangeTextDocument: (listener, thisArgs?, disposables?) => {
|
||||
return pluginHostDocuments.onDidChangeDocument(listener, thisArgs, disposables);
|
||||
return extHostDocuments.onDidChangeDocument(listener, thisArgs, disposables);
|
||||
},
|
||||
onDidSaveTextDocument: (listener, thisArgs?, disposables?) => {
|
||||
return pluginHostDocuments.onDidSaveDocument(listener, thisArgs, disposables);
|
||||
return extHostDocuments.onDidSaveDocument(listener, thisArgs, disposables);
|
||||
},
|
||||
onDidChangeConfiguration: (listener: () => any, thisArgs?: any, disposables?: extHostTypes.Disposable[]) => {
|
||||
return pluginHostConfiguration.onDidChangeConfiguration(listener, thisArgs, disposables);
|
||||
return extHostConfiguration.onDidChangeConfiguration(listener, thisArgs, disposables);
|
||||
},
|
||||
getConfiguration: (section?: string):vscode.WorkspaceConfiguration => {
|
||||
return pluginHostConfiguration.getConfiguration(section);
|
||||
return extHostConfiguration.getConfiguration(section);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -307,12 +307,12 @@ export class ExtHostAPIImplementation {
|
||||
|
||||
//
|
||||
const languages = new ExtHostLanguages(this._threadService);
|
||||
const pluginHostDiagnostics = new ExtHostDiagnostics(this._threadService);
|
||||
const extHostDiagnostics = new ExtHostDiagnostics(this._threadService);
|
||||
const languageFeatures = threadService.getRemotable(ExtHostLanguageFeatures);
|
||||
|
||||
this.languages = {
|
||||
createDiagnosticCollection(name?: string): vscode.DiagnosticCollection {
|
||||
return pluginHostDiagnostics.createDiagnosticCollection(name);
|
||||
return extHostDiagnostics.createDiagnosticCollection(name);
|
||||
},
|
||||
getLanguages(): TPromise<string[]> {
|
||||
return languages.getLanguages();
|
||||
@@ -367,7 +367,7 @@ export class ExtHostAPIImplementation {
|
||||
}
|
||||
};
|
||||
|
||||
var pluginHostConfiguration = threadService.getRemotable(ExtHostConfiguration);
|
||||
var extHostConfiguration = threadService.getRemotable(ExtHostConfiguration);
|
||||
|
||||
//
|
||||
this.extensions = {
|
||||
@@ -465,7 +465,7 @@ export class MainProcessVSCodeAPIHelper {
|
||||
this._token2Dispose = {};
|
||||
}
|
||||
|
||||
public onUnexpectedPluginHostError(err: any): void {
|
||||
public onUnexpectedExtHostError(err: any): void {
|
||||
errors.onUnexpectedError(err);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user