log ext host commands, ext hsot scm

This commit is contained in:
Joao Moreno
2017-11-29 14:22:38 +01:00
parent 2b5d14e446
commit 4e78a42abf
14 changed files with 66 additions and 31 deletions

View File

@@ -56,6 +56,7 @@ import { ExtHostFileSystem } from 'vs/workbench/api/node/extHostFileSystem';
import { FileChangeType, FileType } from 'vs/platform/files/common/files';
import { ExtHostDecorations } from 'vs/workbench/api/node/extHostDecorations';
import { toGlobPattern, toLanguageSelector } from 'vs/workbench/api/node/extHostTypeConverters';
import { ILogService } from 'vs/platform/log/common/log';
export interface IExtensionApiFactory {
(extension: IExtensionDescription): typeof vscode;
@@ -79,7 +80,8 @@ export function createApiFactory(
threadService: ExtHostThreadService,
extHostWorkspace: ExtHostWorkspace,
extHostConfiguration: ExtHostConfiguration,
extensionService: ExtHostExtensionService
extensionService: ExtHostExtensionService,
logService: ILogService
): IExtensionApiFactory {
// Addressable instances
@@ -90,7 +92,7 @@ export function createApiFactory(
const extHostDocumentContentProviders = threadService.set(ExtHostContext.ExtHostDocumentContentProviders, new ExtHostDocumentContentProvider(threadService, extHostDocumentsAndEditors));
const extHostDocumentSaveParticipant = threadService.set(ExtHostContext.ExtHostDocumentSaveParticipant, new ExtHostDocumentSaveParticipant(extHostDocuments, threadService.get(MainContext.MainThreadEditors)));
const extHostEditors = threadService.set(ExtHostContext.ExtHostEditors, new ExtHostEditors(threadService, extHostDocumentsAndEditors));
const extHostCommands = threadService.set(ExtHostContext.ExtHostCommands, new ExtHostCommands(threadService, extHostHeapService));
const extHostCommands = threadService.set(ExtHostContext.ExtHostCommands, new ExtHostCommands(threadService, extHostHeapService, logService));
const extHostTreeViews = threadService.set(ExtHostContext.ExtHostTreeViews, new ExtHostTreeViews(threadService.get(MainContext.MainThreadTreeViews), extHostCommands));
threadService.set(ExtHostContext.ExtHostWorkspace, extHostWorkspace);
const extHostDebugService = threadService.set(ExtHostContext.ExtHostDebugService, new ExtHostDebugService(threadService, extHostWorkspace));
@@ -101,7 +103,7 @@ export function createApiFactory(
const extHostFileSystemEvent = threadService.set(ExtHostContext.ExtHostFileSystemEventService, new ExtHostFileSystemEventService());
const extHostQuickOpen = threadService.set(ExtHostContext.ExtHostQuickOpen, new ExtHostQuickOpen(threadService, extHostWorkspace, extHostCommands));
const extHostTerminalService = threadService.set(ExtHostContext.ExtHostTerminalService, new ExtHostTerminalService(threadService));
const extHostSCM = threadService.set(ExtHostContext.ExtHostSCM, new ExtHostSCM(threadService, extHostCommands));
const extHostSCM = threadService.set(ExtHostContext.ExtHostSCM, new ExtHostSCM(threadService, extHostCommands, logService));
const extHostTask = threadService.set(ExtHostContext.ExtHostTask, new ExtHostTask(threadService, extHostWorkspace));
const extHostWindow = threadService.set(ExtHostContext.ExtHostWindow, new ExtHostWindow(threadService));
threadService.set(ExtHostContext.ExtHostExtensionService, extensionService);

View File

@@ -49,6 +49,7 @@ import { SerializedError } from 'vs/base/common/errors';
import { IWorkspaceFolderData } from 'vs/platform/workspace/common/workspace';
import { IStat, IFileChange } from 'vs/platform/files/common/files';
import { ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
import { ParsedArgs } from 'vs/platform/environment/common/environment';
export interface IEnvironment {
isExtensionDevelopmentDebug: boolean;
@@ -75,6 +76,8 @@ export interface IInitData {
extensions: IExtensionDescription[];
configuration: IConfigurationInitData;
telemetryInfo: ITelemetryInfo;
args: ParsedArgs;
execPath: string;
}
export interface IConfigurationInitData extends IConfigurationData {

View File

@@ -15,6 +15,7 @@ import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService';
import { isFalsyOrEmpty } from 'vs/base/common/arrays';
import * as modes from 'vs/editor/common/modes';
import * as vscode from 'vscode';
import { ILogService, log, LogLevel } from 'vs/platform/log/common/log';
interface CommandHandler {
callback: Function;
@@ -35,7 +36,9 @@ export class ExtHostCommands implements ExtHostCommandsShape {
constructor(
mainContext: IMainContext,
heapService: ExtHostHeapService
heapService: ExtHostHeapService,
// @ts-ignore
@ILogService private logService: ILogService
) {
this._proxy = mainContext.get(MainContext.MainThreadCommands);
this._converter = new CommandsConverter(this, heapService);
@@ -49,6 +52,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
this._argumentProcessors.push(processor);
}
@log(LogLevel.TRACE, 'ExtHostCommands', (msg, id) => `${msg}(${id})`)
registerCommand(id: string, callback: <T>(...args: any[]) => T | Thenable<T>, thisArg?: any, description?: ICommandHandlerDescription): extHostTypes.Disposable {
if (!id.trim().length) {
@@ -69,6 +73,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
});
}
@log(LogLevel.TRACE, 'ExtHostCommands', (msg, id) => `${msg}(${id})`)
executeCommand<T>(id: string, ...args: any[]): Thenable<T> {
if (this._commands.has(id)) {
@@ -133,6 +138,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
}
}
@log(LogLevel.TRACE, 'ExtHostCommands', (msg, filterUnderscoreCommands) => `${msg}(${filterUnderscoreCommands})`)
getCommands(filterUnderscoreCommands: boolean = false): Thenable<string[]> {
return this._proxy.$getCommands().then(result => {
if (filterUnderscoreCommands) {

View File

@@ -21,6 +21,7 @@ import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
import { realpath } from 'fs';
import { TernarySearchTree } from 'vs/base/common/map';
import { Barrier } from 'vs/base/common/async';
import { ILogService } from 'vs/platform/log/common/log';
class ExtensionMemento implements IExtensionMemento {
@@ -125,7 +126,8 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
constructor(initData: IInitData,
threadService: ExtHostThreadService,
extHostWorkspace: ExtHostWorkspace,
extHostConfiguration: ExtHostConfiguration
extHostConfiguration: ExtHostConfiguration,
logService: ILogService
) {
this._barrier = new Barrier();
this._registry = new ExtensionDescriptionRegistry(initData.extensions);
@@ -137,7 +139,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
this._activator = null;
// initialize API first (i.e. do not release barrier until the API is initialized)
const apiFactory = createApiFactory(initData, threadService, extHostWorkspace, extHostConfiguration, this);
const apiFactory = createApiFactory(initData, threadService, extHostWorkspace, extHostConfiguration, this, logService);
initializeExtensionApi(this, apiFactory).then(() => {

View File

@@ -17,6 +17,7 @@ import { sortedDiff } from 'vs/base/common/arrays';
import { comparePaths } from 'vs/base/common/comparers';
import * as vscode from 'vscode';
import { ISplice } from 'vs/base/common/sequence';
import { log, LogLevel, ILogService } from 'vs/platform/log/common/log';
type ProviderHandle = number;
type GroupHandle = number;
@@ -443,7 +444,9 @@ export class ExtHostSCM {
constructor(
mainContext: IMainContext,
private _commands: ExtHostCommands
private _commands: ExtHostCommands,
// @ts-ignore
@ILogService private logService: ILogService
) {
this._proxy = mainContext.get(MainContext.MainThreadSCM);
@@ -486,6 +489,7 @@ export class ExtHostSCM {
});
}
@log(LogLevel.TRACE, 'ExtHostSCM', (msg, extension, id, label, rootUri) => `${msg}(${extension.id}, ${id}, ${label}, ${rootUri})`)
createSourceControl(extension: IExtensionDescription, id: string, label: string, rootUri: vscode.Uri | undefined): vscode.SourceControl {
const handle = ExtHostSCM._handlePool++;
const sourceControl = new ExtHostSourceControl(this._proxy, this._commands, id, label, rootUri);
@@ -499,6 +503,7 @@ export class ExtHostSCM {
}
// Deprecated
@log(LogLevel.TRACE, 'ExtHostSCM', (msg, extension) => `${msg}(${extension.id})`)
getLastInputBox(extension: IExtensionDescription): ExtHostSCMInputBox {
const sourceControls = this._sourceControlsByExtension.get(extension.id);
const sourceControl = sourceControls && sourceControls[sourceControls.length - 1];
@@ -507,6 +512,7 @@ export class ExtHostSCM {
return inputBox;
}
@log(LogLevel.TRACE, 'ExtHostSCM', (msg, handle, uri) => `${msg}(${handle}, ${uri})`)
$provideOriginalResource(sourceControlHandle: number, uri: URI): TPromise<URI> {
const sourceControl = this._sourceControls.get(sourceControlHandle);
@@ -520,6 +526,7 @@ export class ExtHostSCM {
});
}
@log(LogLevel.TRACE, 'ExtHostSCM', (msg, handle) => `${msg}(${handle})`)
$onInputBoxValueChange(sourceControlHandle: number, value: string): TPromise<void> {
const sourceControl = this._sourceControls.get(sourceControlHandle);
@@ -531,6 +538,7 @@ export class ExtHostSCM {
return TPromise.as(null);
}
@log(LogLevel.TRACE, 'ExtHostSCM', (msg, h1, h2, h3) => `${msg}(${h1}, ${h2}, ${h3})`)
async $executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): TPromise<void> {
const sourceControl = this._sourceControls.get(sourceControlHandle);