mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
Merge remote-tracking branch 'origin/master' into alex/interval-tree
This commit is contained in:
@@ -55,6 +55,7 @@ import { ProxyIdentifier } from 'vs/workbench/services/thread/common/threadServi
|
||||
import { ExtHostDialogs } from 'vs/workbench/api/node/extHostDialogs';
|
||||
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';
|
||||
|
||||
export interface IExtensionApiFactory {
|
||||
(extension: IExtensionDescription): typeof vscode;
|
||||
@@ -83,6 +84,7 @@ export function createApiFactory(
|
||||
|
||||
// Addressable instances
|
||||
const extHostHeapService = threadService.set(ExtHostContext.ExtHostHeapService, new ExtHostHeapService());
|
||||
const extHostDecorations = threadService.set(ExtHostContext.ExtHostDecorations, new ExtHostDecorations(threadService));
|
||||
const extHostDocumentsAndEditors = threadService.set(ExtHostContext.ExtHostDocumentsAndEditors, new ExtHostDocumentsAndEditors(threadService));
|
||||
const extHostDocuments = threadService.set(ExtHostContext.ExtHostDocuments, new ExtHostDocuments(threadService, extHostDocumentsAndEditors));
|
||||
const extHostDocumentContentProviders = threadService.set(ExtHostContext.ExtHostDocumentContentProviders, new ExtHostDocumentContentProvider(threadService, extHostDocumentsAndEditors));
|
||||
@@ -269,13 +271,12 @@ export function createApiFactory(
|
||||
registerDocumentLinkProvider(selector: vscode.DocumentSelector, provider: vscode.DocumentLinkProvider): vscode.Disposable {
|
||||
return languageFeatures.registerDocumentLinkProvider(selector, provider);
|
||||
},
|
||||
registerColorProvider(selector: vscode.DocumentSelector, provider: vscode.DocumentColorProvider): vscode.Disposable {
|
||||
return languageFeatures.registerColorProvider(selector, provider);
|
||||
},
|
||||
setLanguageConfiguration: (language: string, configuration: vscode.LanguageConfiguration): vscode.Disposable => {
|
||||
return languageFeatures.setLanguageConfiguration(language, configuration);
|
||||
},
|
||||
// proposed API
|
||||
registerColorProvider: proposedApiFunction(extension, (selector: vscode.DocumentSelector, provider: vscode.DocumentColorProvider) => {
|
||||
return languageFeatures.registerColorProvider(selector, provider);
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: window
|
||||
@@ -377,6 +378,9 @@ export function createApiFactory(
|
||||
sampleFunction: proposedApiFunction(extension, () => {
|
||||
return extHostMessageService.showMessage(extension, Severity.Info, 'Hello Proposed Api!', {}, []);
|
||||
}),
|
||||
registerDecorationProvider: proposedApiFunction(extension, (provider: vscode.DecorationProvider) => {
|
||||
return extHostDecorations.registerDecorationProvider(provider, extension.id);
|
||||
})
|
||||
};
|
||||
|
||||
// namespace: workspace
|
||||
|
||||
@@ -28,8 +28,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { ITextSource } from 'vs/editor/common/model/textSource';
|
||||
|
||||
import { ConfigurationTarget } from 'vs/workbench/services/configuration/common/configurationEditing';
|
||||
import { IConfigurationData } from 'vs/platform/configuration/common/configuration';
|
||||
import { IConfigurationData, ConfigurationTarget, IConfigurationModel } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
import { IPickOpenEntry, IPickOptions } from 'vs/platform/quickOpen/common/quickOpen';
|
||||
import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
@@ -74,10 +73,15 @@ export interface IInitData {
|
||||
environment: IEnvironment;
|
||||
workspace: IWorkspaceData;
|
||||
extensions: IExtensionDescription[];
|
||||
configuration: IConfigurationData<any>;
|
||||
configuration: IConfigurationData;
|
||||
telemetryInfo: ITelemetryInfo;
|
||||
}
|
||||
|
||||
export interface IWorkspaceConfigurationChangeEventData {
|
||||
changedConfiguration: IConfigurationModel;
|
||||
changedConfigurationByResource: { [folder: string]: IConfigurationModel };
|
||||
}
|
||||
|
||||
export interface IExtHostContext {
|
||||
/**
|
||||
* Returns a proxy to an object addressable/named in the extension host process.
|
||||
@@ -136,6 +140,12 @@ export interface MainThreadDiaglogsShape extends IDisposable {
|
||||
$showSaveDialog(options: MainThreadDialogSaveOptions): TPromise<string>;
|
||||
}
|
||||
|
||||
export interface MainThreadDecorationsShape extends IDisposable {
|
||||
$registerDecorationProvider(handle: number, label: string): void;
|
||||
$unregisterDecorationProvider(handle: number): void;
|
||||
$onDidChange(handle: number, resources: URI[]): void;
|
||||
}
|
||||
|
||||
export interface MainThreadDocumentContentProvidersShape extends IDisposable {
|
||||
$registerTextContentProvider(handle: number, scheme: string): void;
|
||||
$unregisterTextContentProvider(handle: number): void;
|
||||
@@ -358,8 +368,7 @@ export type SCMRawResource = [
|
||||
string[] /*icons: light, dark*/,
|
||||
string /*tooltip*/,
|
||||
boolean /*strike through*/,
|
||||
boolean /*faded*/,
|
||||
{ id: string } /*ThemeColor*/
|
||||
boolean /*faded*/
|
||||
];
|
||||
|
||||
export type SCMRawResourceSplice = [
|
||||
@@ -394,7 +403,6 @@ export interface MainThreadDebugServiceShape extends IDisposable {
|
||||
$registerDebugConfigurationProvider(type: string, hasProvideMethod: boolean, hasResolveMethod: boolean, handle: number): TPromise<any>;
|
||||
$unregisterDebugConfigurationProvider(handle: number): TPromise<any>;
|
||||
$startDebugging(folder: URI | undefined, nameOrConfig: string | vscode.DebugConfiguration): TPromise<boolean>;
|
||||
$startDebugSession(folder: URI | undefined, config: vscode.DebugConfiguration): TPromise<DebugSessionUUID>;
|
||||
$customDebugAdapterRequest(id: DebugSessionUUID, command: string, args: any): TPromise<any>;
|
||||
}
|
||||
|
||||
@@ -416,7 +424,7 @@ export interface ExtHostCommandsShape {
|
||||
}
|
||||
|
||||
export interface ExtHostConfigurationShape {
|
||||
$acceptConfigurationChanged(data: IConfigurationData<any>): void;
|
||||
$acceptConfigurationChanged(data: IConfigurationData, eventData: IWorkspaceConfigurationChangeEventData): void;
|
||||
}
|
||||
|
||||
export interface ExtHostDiagnosticsShape {
|
||||
@@ -599,6 +607,13 @@ export interface ExtHostDebugServiceShape {
|
||||
$acceptDebugSessionCustomEvent(id: DebugSessionUUID, type: string, name: string, event: any): void;
|
||||
}
|
||||
|
||||
|
||||
export type DecorationData = [number, boolean, string, string, ThemeColor];
|
||||
|
||||
export interface ExtHostDecorationsShape {
|
||||
$providerDecorations(handle: number, uri: URI): TPromise<DecorationData>;
|
||||
}
|
||||
|
||||
export interface ExtHostCredentialsShape {
|
||||
}
|
||||
|
||||
@@ -612,6 +627,7 @@ export const MainContext = {
|
||||
MainThreadCommands: createMainId<MainThreadCommandsShape>('MainThreadCommands'),
|
||||
MainThreadConfiguration: createMainId<MainThreadConfigurationShape>('MainThreadConfiguration'),
|
||||
MainThreadDebugService: createMainId<MainThreadDebugServiceShape>('MainThreadDebugService'),
|
||||
MainThreadDecorations: createMainId<MainThreadDecorationsShape>('MainThreadDecorations'),
|
||||
MainThreadDiagnostics: createMainId<MainThreadDiagnosticsShape>('MainThreadDiagnostics'),
|
||||
MainThreadDialogs: createMainId<MainThreadDiaglogsShape>('MainThreadDiaglogs'),
|
||||
MainThreadDocuments: createMainId<MainThreadDocumentsShape>('MainThreadDocuments'),
|
||||
@@ -643,6 +659,7 @@ export const ExtHostContext = {
|
||||
ExtHostConfiguration: createExtId<ExtHostConfigurationShape>('ExtHostConfiguration'),
|
||||
ExtHostDiagnostics: createExtId<ExtHostDiagnosticsShape>('ExtHostDiagnostics'),
|
||||
ExtHostDebugService: createExtId<ExtHostDebugServiceShape>('ExtHostDebugService'),
|
||||
ExtHostDecorations: createExtId<ExtHostDecorationsShape>('ExtHostDecorations'),
|
||||
ExtHostDocumentsAndEditors: createExtId<ExtHostDocumentsAndEditorsShape>('ExtHostDocumentsAndEditors'),
|
||||
ExtHostDocuments: createExtId<ExtHostDocumentsShape>('ExtHostDocuments'),
|
||||
ExtHostDocumentContentProviders: createExtId<ExtHostDocumentContentProvidersShape>('ExtHostDocumentContentProviders'),
|
||||
|
||||
@@ -7,12 +7,14 @@
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { WorkspaceConfiguration } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
|
||||
import { ExtHostConfigurationShape, MainThreadConfigurationShape } from './extHost.protocol';
|
||||
import { ExtHostConfigurationShape, MainThreadConfigurationShape, IWorkspaceConfigurationChangeEventData } from './extHost.protocol';
|
||||
import { ConfigurationTarget as ExtHostConfigurationTarget } from './extHostTypes';
|
||||
import { IConfigurationData, Configuration } from 'vs/platform/configuration/common/configuration';
|
||||
import { ConfigurationTarget } from 'vs/workbench/services/configuration/common/configurationEditing';
|
||||
import { IConfigurationData, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { Configuration, ConfigurationModel, ConfigurationChangeEvent } from 'vs/platform/configuration/common/configurationModels';
|
||||
import { WorkspaceConfigurationChangeEvent } from 'vs/workbench/services/configuration/common/configurationModels';
|
||||
import { StrictResourceMap } from 'vs/base/common/map';
|
||||
|
||||
function lookUp(tree: any, key: string) {
|
||||
if (key) {
|
||||
@@ -38,9 +40,9 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
|
||||
private readonly _onDidChangeConfiguration = new Emitter<void>();
|
||||
private readonly _proxy: MainThreadConfigurationShape;
|
||||
private readonly _extHostWorkspace: ExtHostWorkspace;
|
||||
private _configuration: Configuration<any>;
|
||||
private _configuration: Configuration;
|
||||
|
||||
constructor(proxy: MainThreadConfigurationShape, extHostWorkspace: ExtHostWorkspace, data: IConfigurationData<any>) {
|
||||
constructor(proxy: MainThreadConfigurationShape, extHostWorkspace: ExtHostWorkspace, data: IConfigurationData) {
|
||||
this._proxy = proxy;
|
||||
this._extHostWorkspace = extHostWorkspace;
|
||||
this._configuration = Configuration.parse(data, extHostWorkspace.workspace);
|
||||
@@ -50,15 +52,15 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
|
||||
return this._onDidChangeConfiguration && this._onDidChangeConfiguration.event;
|
||||
}
|
||||
|
||||
$acceptConfigurationChanged(data: IConfigurationData<any>) {
|
||||
$acceptConfigurationChanged(data: IConfigurationData, eventData: IWorkspaceConfigurationChangeEventData) {
|
||||
this._configuration = Configuration.parse(data, this._extHostWorkspace.workspace);
|
||||
this._onDidChangeConfiguration.fire(undefined);
|
||||
}
|
||||
|
||||
getConfiguration(section?: string, resource?: URI): WorkspaceConfiguration {
|
||||
getConfiguration(section?: string, resource?: URI): vscode.WorkspaceConfiguration {
|
||||
const config = section
|
||||
? lookUp(this._configuration.getValue(null, { resource }), section)
|
||||
: this._configuration.getValue(null, { resource });
|
||||
? lookUp(this._configuration.getSection(null, { resource }), section)
|
||||
: this._configuration.getSection(null, { resource });
|
||||
|
||||
function parseConfigurationTarget(arg: boolean | ExtHostConfigurationTarget): ConfigurationTarget {
|
||||
if (arg === void 0 || arg === null) {
|
||||
@@ -71,11 +73,11 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
|
||||
switch (arg) {
|
||||
case ExtHostConfigurationTarget.Global: return ConfigurationTarget.USER;
|
||||
case ExtHostConfigurationTarget.Workspace: return ConfigurationTarget.WORKSPACE;
|
||||
case ExtHostConfigurationTarget.WorkspaceFolder: return ConfigurationTarget.FOLDER;
|
||||
case ExtHostConfigurationTarget.WorkspaceFolder: return ConfigurationTarget.WORKSPACE_FOLDER;
|
||||
}
|
||||
}
|
||||
|
||||
const result: WorkspaceConfiguration = {
|
||||
const result: vscode.WorkspaceConfiguration = {
|
||||
has(key: string): boolean {
|
||||
return typeof lookUp(config, key) !== 'undefined';
|
||||
},
|
||||
@@ -104,7 +106,7 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
|
||||
defaultValue: config.default,
|
||||
globalValue: config.user,
|
||||
workspaceValue: config.workspace,
|
||||
workspaceFolderValue: config.folder
|
||||
workspaceFolderValue: config.workspaceFolder
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
@@ -115,6 +117,18 @@ export class ExtHostConfiguration implements ExtHostConfigurationShape {
|
||||
mixin(result, config, false);
|
||||
}
|
||||
|
||||
return <WorkspaceConfiguration>Object.freeze(result);
|
||||
return <vscode.WorkspaceConfiguration>Object.freeze(result);
|
||||
}
|
||||
|
||||
protected toConfigurationChangeEvent(data: IWorkspaceConfigurationChangeEventData): WorkspaceConfigurationChangeEvent {
|
||||
const changedConfiguration = new ConfigurationModel(data.changedConfiguration.contents, data.changedConfiguration.keys, data.changedConfiguration.overrides);
|
||||
const changedConfigurationByResource: StrictResourceMap<ConfigurationModel> = new StrictResourceMap<ConfigurationModel>();
|
||||
for (const key of Object.keys(data.changedConfigurationByResource)) {
|
||||
const resource = URI.parse(key);
|
||||
const model = data.changedConfigurationByResource[key];
|
||||
changedConfigurationByResource.set(resource, new ConfigurationModel(model.contents, model.keys, model.overrides));
|
||||
}
|
||||
const event = new ConfigurationChangeEvent(changedConfiguration, changedConfigurationByResource);
|
||||
return new WorkspaceConfigurationChangeEvent(event, this._extHostWorkspace.workspace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,14 +98,6 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
return this._debugServiceProxy.$startDebugging(folder ? folder.uri : undefined, nameOrConfig);
|
||||
}
|
||||
|
||||
public startDebugSession(folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration): TPromise<vscode.DebugSession> {
|
||||
return this._debugServiceProxy.$startDebugSession(folder ? folder.uri : undefined, config).then((id: DebugSessionUUID) => {
|
||||
const debugSession = new ExtHostDebugSession(this._debugServiceProxy, id, config.type, config.name);
|
||||
this._debugSessions.set(id, debugSession);
|
||||
return debugSession;
|
||||
});
|
||||
}
|
||||
|
||||
public $acceptDebugSessionStarted(id: DebugSessionUUID, type: string, name: string): void {
|
||||
|
||||
let debugSession = this._debugSessions.get(id);
|
||||
|
||||
47
src/vs/workbench/api/node/extHostDecorations.ts
Normal file
47
src/vs/workbench/api/node/extHostDecorations.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { MainContext, IMainContext, ExtHostDecorationsShape, MainThreadDecorationsShape, DecorationData } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Disposable } from 'vs/workbench/api/node/extHostTypes';
|
||||
import { asWinJsPromise } from 'vs/base/common/async';
|
||||
|
||||
export class ExtHostDecorations implements ExtHostDecorationsShape {
|
||||
|
||||
private static _handlePool = 0;
|
||||
|
||||
private readonly _provider = new Map<number, vscode.DecorationProvider>();
|
||||
private readonly _proxy: MainThreadDecorationsShape;
|
||||
|
||||
constructor(mainContext: IMainContext) {
|
||||
this._proxy = mainContext.get(MainContext.MainThreadDecorations);
|
||||
}
|
||||
|
||||
registerDecorationProvider(provider: vscode.DecorationProvider, label: string): vscode.Disposable {
|
||||
const handle = ExtHostDecorations._handlePool++;
|
||||
this._provider.set(handle, provider);
|
||||
this._proxy.$registerDecorationProvider(handle, label);
|
||||
|
||||
const listener = provider.onDidChangeDecorations(e => {
|
||||
this._proxy.$onDidChange(handle, !e ? null : Array.isArray(e) ? e : [e]);
|
||||
});
|
||||
|
||||
return new Disposable(() => {
|
||||
listener.dispose();
|
||||
this._proxy.$unregisterDecorationProvider(handle);
|
||||
this._provider.delete(handle);
|
||||
});
|
||||
}
|
||||
|
||||
$providerDecorations(handle: number, uri: URI): TPromise<DecorationData> {
|
||||
const provider = this._provider.get(handle);
|
||||
return asWinJsPromise(token => provider.provideDecoration(uri, token)).then(data => {
|
||||
return data && <DecorationData>[data.priority, data.bubble, data.title, data.abbreviation, data.color];
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
import * as vscode from 'vscode';
|
||||
import * as TypeConverters from 'vs/workbench/api/node/extHostTypeConverters';
|
||||
import { Range, Disposable, CompletionList, SnippetString } from 'vs/workbench/api/node/extHostTypes';
|
||||
import { Range, Disposable, CompletionList, SnippetString, Color } from 'vs/workbench/api/node/extHostTypes';
|
||||
import { ISingleEditOperation } from 'vs/editor/common/editorCommon';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService';
|
||||
@@ -721,19 +721,12 @@ class ColorProviderAdapter {
|
||||
});
|
||||
}
|
||||
|
||||
provideColorPresentations(resource: URI, rawColorInfo: IRawColorInfo): TPromise<modes.IColorPresentation[]> {
|
||||
let colorInfo: vscode.ColorInformation = {
|
||||
range: TypeConverters.toRange(rawColorInfo.range),
|
||||
color: {
|
||||
red: rawColorInfo.color[0],
|
||||
green: rawColorInfo.color[1],
|
||||
blue: rawColorInfo.color[2],
|
||||
alpha: rawColorInfo.color[3]
|
||||
}
|
||||
};
|
||||
const doc = this._documents.getDocumentData(resource).document;
|
||||
return asWinJsPromise(token => this._provider.provideColorPresentations(doc, colorInfo, token)).then(value => {
|
||||
return value.map(v => TypeConverters.ColorPresentation.from(v));
|
||||
provideColorPresentations(resource: URI, raw: IRawColorInfo): TPromise<modes.IColorPresentation[]> {
|
||||
const document = this._documents.getDocumentData(resource).document;
|
||||
const range = TypeConverters.toRange(raw.range);
|
||||
const color = new Color(raw.color[0], raw.color[1], raw.color[2], raw.color[3]);
|
||||
return asWinJsPromise(token => this._provider.provideColorPresentations(color, { document, range }, token)).then(value => {
|
||||
return value.map(TypeConverters.ColorPresentation.from);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
|
||||
return;
|
||||
}
|
||||
|
||||
this._commands.executeCommand(command.command, ...command.arguments);
|
||||
await this._commands.executeCommand(command.command, ...command.arguments);
|
||||
}
|
||||
|
||||
_takeResourceStateSnapshot(): SCMRawResourceSplice[] {
|
||||
@@ -243,9 +243,8 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
|
||||
const tooltip = (r.decorations && r.decorations.tooltip) || '';
|
||||
const strikeThrough = r.decorations && !!r.decorations.strikeThrough;
|
||||
const faded = r.decorations && !!r.decorations.faded;
|
||||
const color = r.decorations && r.decorations.color;
|
||||
|
||||
return [handle, sourceUri, icons, tooltip, strikeThrough, faded, color] as SCMRawResource;
|
||||
return [handle, sourceUri, icons, tooltip, strikeThrough, faded] as SCMRawResource;
|
||||
});
|
||||
|
||||
handlesToDelete.push(...this._handlesSnapshot.splice(start, deleteCount, ...handles));
|
||||
@@ -532,6 +531,6 @@ export class ExtHostSCM {
|
||||
return;
|
||||
}
|
||||
|
||||
group.$executeResourceCommand(handle);
|
||||
await group.$executeResourceCommand(handle);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user