Merge branch 'master' into sandy081/userDataProvider

This commit is contained in:
Sandeep Somavarapu
2019-09-15 19:52:27 +02:00
281 changed files with 7541 additions and 5362 deletions

View File

@@ -8,6 +8,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import { ExtHostContext, MainThreadCommandsShape, ExtHostCommandsShape, MainContext, IExtHostContext } from '../common/extHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { revive } from 'vs/base/common/marshalling';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
@extHostNamedCustomer(MainContext.MainThreadCommands)
export class MainThreadCommands implements MainThreadCommandsShape {
@@ -19,6 +20,7 @@ export class MainThreadCommands implements MainThreadCommandsShape {
constructor(
extHostContext: IExtHostContext,
@ICommandService private readonly _commandService: ICommandService,
@IExtensionService private readonly _extensionService: IExtensionService,
) {
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostCommands);
@@ -70,10 +72,14 @@ export class MainThreadCommands implements MainThreadCommandsShape {
}
}
$executeCommand<T>(id: string, args: any[]): Promise<T | undefined> {
async $executeCommand<T>(id: string, args: any[], retry: boolean): Promise<T | undefined> {
for (let i = 0; i < args.length; i++) {
args[i] = revive(args[i], 0);
}
if (retry && args.length > 0 && !CommandsRegistry.getCommand(id)) {
await this._extensionService.activateByEvent(`onCommand:${id}`);
throw new Error('$executeCommand:retry');
}
return this._commandService.executeCommand<T>(id, ...args);
}

View File

@@ -361,23 +361,24 @@ class ExtensionHostDebugAdapter extends AbstractDebugAdapter {
super();
}
public fireError(handle: number, err: Error) {
fireError(handle: number, err: Error) {
this._onError.fire(err);
}
public fireExit(handle: number, code: number, signal: string) {
fireExit(handle: number, code: number, signal: string) {
this._onExit.fire(code);
}
public startSession(): Promise<void> {
startSession(): Promise<void> {
return Promise.resolve(this._proxy.$startDASession(this._handle, this._ds.getSessionDto(this._session)));
}
public sendMessage(message: DebugProtocol.ProtocolMessage): void {
sendMessage(message: DebugProtocol.ProtocolMessage): void {
this._proxy.$sendDAMessage(this._handle, convertToDAPaths(message, true));
}
public stopSession(): Promise<void> {
async stopSession(): Promise<void> {
await this.cancelPendingRequests();
return Promise.resolve(this._proxy.$stopDASession(this._handle));
}
}

View File

@@ -11,7 +11,7 @@ import * as search from 'vs/workbench/contrib/search/common/search';
import { CancellationToken } from 'vs/base/common/cancellation';
import { Position as EditorPosition } from 'vs/editor/common/core/position';
import { Range as EditorRange, IRange } from 'vs/editor/common/core/range';
import { ExtHostContext, MainThreadLanguageFeaturesShape, ExtHostLanguageFeaturesShape, MainContext, IExtHostContext, ILanguageConfigurationDto, IRegExpDto, IIndentationRuleDto, IOnEnterRuleDto, ILocationDto, IWorkspaceSymbolDto, reviveWorkspaceEditDto, IDocumentFilterDto, IDefinitionLinkDto, ISignatureHelpProviderMetadataDto, ILinkDto, ICallHierarchyDto, ISuggestDataDto, ICodeActionDto } from '../common/extHost.protocol';
import { ExtHostContext, MainThreadLanguageFeaturesShape, ExtHostLanguageFeaturesShape, MainContext, IExtHostContext, ILanguageConfigurationDto, IRegExpDto, IIndentationRuleDto, IOnEnterRuleDto, ILocationDto, IWorkspaceSymbolDto, reviveWorkspaceEditDto, IDocumentFilterDto, IDefinitionLinkDto, ISignatureHelpProviderMetadataDto, ILinkDto, ICallHierarchyItemDto, ISuggestDataDto, ICodeActionDto } from '../common/extHost.protocol';
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
import { LanguageConfiguration, IndentationRule, OnEnterRule } from 'vs/editor/common/modes/languageConfiguration';
import { IModeService } from 'vs/editor/common/services/modeService';
@@ -19,7 +19,7 @@ import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { URI } from 'vs/base/common/uri';
import { Selection } from 'vs/editor/common/core/selection';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import * as callh from 'vs/workbench/contrib/callHierarchy/common/callHierarchy';
import * as callh from 'vs/workbench/contrib/callHierarchy/browser/callHierarchy';
import { mixin } from 'vs/base/common/objects';
@extHostNamedCustomer(MainContext.MainThreadLanguageFeatures)
@@ -111,7 +111,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
return <modes.ILink>data;
}
private static _reviveCallHierarchyItemDto(data: ICallHierarchyDto | undefined): callh.CallHierarchyItem {
private static _reviveCallHierarchyItemDto(data: ICallHierarchyItemDto | undefined): callh.CallHierarchyItem {
if (data) {
data.uri = URI.revive(data.uri);
}
@@ -494,21 +494,28 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
$registerCallHierarchyProvider(handle: number, selector: IDocumentFilterDto[]): void {
this._registrations.set(handle, callh.CallHierarchyProviderRegistry.register(selector, {
provideCallHierarchyItem: (document, position, token) => {
return this._proxy.$provideCallHierarchyItem(handle, document.uri, position, token).then(MainThreadLanguageFeatures._reviveCallHierarchyItemDto);
provideOutgoingCalls: async (model, position, token) => {
const outgoing = await this._proxy.$provideCallHierarchyOutgoingCalls(handle, model.uri, position, token);
if (!outgoing) {
return outgoing;
}
return outgoing.map(([item, sourceRanges]): callh.OutgoingCall => {
return {
target: MainThreadLanguageFeatures._reviveCallHierarchyItemDto(item),
sourceRanges
};
});
},
resolveCallHierarchyItem: (item, direction, token) => {
return this._proxy.$resolveCallHierarchyItem(handle, item, direction, token).then(data => {
if (data) {
for (let i = 0; i < data.length; i++) {
const [item, locations] = data[i];
data[i] = [
MainThreadLanguageFeatures._reviveCallHierarchyItemDto(item),
MainThreadLanguageFeatures._reviveLocationDto(locations)
];
}
}
return data as [callh.CallHierarchyItem, modes.Location[]][];
provideIncomingCalls: async (model, position, token) => {
const incoming = await this._proxy.$provideCallHierarchyIncomingCalls(handle, model.uri, position, token);
if (!incoming) {
return incoming;
}
return incoming.map(([item, sourceRanges]): callh.IncomingCall => {
return {
source: MainThreadLanguageFeatures._reviveCallHierarchyItemDto(item),
sourceRanges
};
});
}
}));

View File

@@ -97,7 +97,7 @@ export class MainThreadMessageService implements MainThreadMessageServiceShape {
});
}
private _showModalMessage(severity: Severity, message: string, commands: { title: string; isCloseAffordance: boolean; handle: number; }[]): Promise<number | undefined> {
private async _showModalMessage(severity: Severity, message: string, commands: { title: string; isCloseAffordance: boolean; handle: number; }[]): Promise<number | undefined> {
let cancelId: number | undefined = undefined;
const buttons = commands.map((command, index) => {
@@ -118,7 +118,7 @@ export class MainThreadMessageService implements MainThreadMessageServiceShape {
cancelId = buttons.length - 1;
}
return this._dialogService.show(severity, message, buttons, { cancelId })
.then(result => result === commands.length ? undefined : commands[result].handle);
const { choice } = await this._dialogService.show(severity, message, buttons, { cancelId });
return choice === commands.length ? undefined : commands[choice].handle;
}
}

View File

@@ -3,13 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IDisposable, DisposableStore, Disposable } from 'vs/base/common/lifecycle';
import { ITerminalService, ITerminalInstance, IShellLaunchConfig, ITerminalProcessExtHostProxy, ISpawnExtHostProcessRequest, ITerminalDimensions, EXT_HOST_CREATION_DELAY, IAvailableShellsRequest, IDefaultShellAndArgsRequest, IStartExtensionTerminalRequest } from 'vs/workbench/contrib/terminal/common/terminal';
import { DisposableStore, Disposable } from 'vs/base/common/lifecycle';
import { IShellLaunchConfig, ITerminalProcessExtHostProxy, ISpawnExtHostProcessRequest, ITerminalDimensions, EXT_HOST_CREATION_DELAY, IAvailableShellsRequest, IDefaultShellAndArgsRequest, IStartExtensionTerminalRequest } from 'vs/workbench/contrib/terminal/common/terminal';
import { ExtHostContext, ExtHostTerminalServiceShape, MainThreadTerminalServiceShape, MainContext, IExtHostContext, IShellLaunchConfigDto, TerminalLaunchConfig, ITerminalDimensionsDto } from 'vs/workbench/api/common/extHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { URI } from 'vs/base/common/uri';
import { StopWatch } from 'vs/base/common/stopwatch';
import { ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminal';
import { ITerminalInstanceService, ITerminalService, ITerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminal';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -21,7 +21,6 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
private readonly _toDispose = new DisposableStore();
private readonly _terminalProcesses = new Map<number, Promise<ITerminalProcessExtHostProxy>>();
private readonly _terminalProcessesReady = new Map<number, (proxy: ITerminalProcessExtHostProxy) => void>();
private readonly _terminalOnDidWriteDataListeners = new Map<number, IDisposable>();
private _dataEventTracker: TerminalDataEventTracker | undefined;
constructor(
@@ -131,30 +130,10 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
}
}
/** @deprecated */
public $registerOnDataListener(terminalId: number): void {
const terminalInstance = this._terminalService.getInstanceFromId(terminalId);
if (!terminalInstance) {
return;
}
// Listener already registered
if (this._terminalOnDidWriteDataListeners.has(terminalId)) {
return;
}
// Register
const listener = terminalInstance.onData(data => {
this._onTerminalData(terminalId, data);
});
this._terminalOnDidWriteDataListeners.set(terminalId, listener);
terminalInstance.addDisposable(listener);
}
public $startSendingDataEvents(): void {
if (!this._dataEventTracker) {
this._dataEventTracker = this._instantiationService.createInstance(TerminalDataEventTracker, (id, data) => {
this._onTerminalData2(id, data);
this._onTerminalData(id, data);
});
}
}
@@ -170,15 +149,10 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
this._proxy.$acceptActiveTerminalChanged(terminalId);
}
/** @deprecated */
private _onTerminalData(terminalId: number, data: string): void {
this._proxy.$acceptTerminalProcessData(terminalId, data);
}
private _onTerminalData2(terminalId: number, data: string): void {
this._proxy.$acceptTerminalProcessData2(terminalId, data);
}
private _onTitleChanged(terminalId: number, name: string): void {
this._proxy.$acceptTerminalTitleChange(terminalId, name);
}

View File

@@ -8,6 +8,7 @@ import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { isWeb } from 'vs/base/common/platform';
import { startsWith } from 'vs/base/common/strings';
import { URI, UriComponents } from 'vs/base/common/uri';
import { generateUuid } from 'vs/base/common/uuid';
import * as modes from 'vs/editor/common/modes';
import { localize } from 'vs/nls';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
@@ -16,35 +17,33 @@ import { IProductService } from 'vs/platform/product/common/product';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ExtHostContext, ExtHostWebviewsShape, IExtHostContext, MainContext, MainThreadWebviewsShape, WebviewPanelHandle, WebviewPanelShowOptions, WebviewPanelViewStateData } from 'vs/workbench/api/common/extHost.protocol';
import { editorGroupToViewColumn, EditorViewColumn, viewColumnToEditorGroup } from 'vs/workbench/api/common/shared/editor';
import { WebviewEditorInput } from 'vs/workbench/contrib/webview/browser/webviewEditorInput';
import { IEditorInput } from 'vs/workbench/common/editor';
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
import { CustomFileEditorInput } from 'vs/workbench/contrib/customEditor/browser/customEditorInput';
import { WebviewInput } from 'vs/workbench/contrib/webview/browser/webviewEditorInput';
import { ICreateWebViewShowOptions, IWebviewEditorService, WebviewInputOptions } from 'vs/workbench/contrib/webview/browser/webviewEditorService';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { extHostNamedCustomer } from '../common/extHostCustomers';
interface OldMainThreadWebviewState {
readonly viewType: string;
state: any;
}
/**
* Bi-directional map between webview handles and inputs.
*/
class WebviewHandleStore {
private readonly _handlesToInputs = new Map<string, WebviewEditorInput>();
private readonly _inputsToHandles = new Map<WebviewEditorInput, string>();
private readonly _handlesToInputs = new Map<string, WebviewInput>();
private readonly _inputsToHandles = new Map<WebviewInput, string>();
public add(handle: string, input: WebviewEditorInput): void {
public add(handle: string, input: WebviewInput): void {
this._handlesToInputs.set(handle, input);
this._inputsToHandles.set(input, handle);
}
public getHandleForInput(input: WebviewEditorInput): string | undefined {
public getHandleForInput(input: WebviewInput): string | undefined {
return this._inputsToHandles.get(input);
}
public getInputForHandle(handle: string): WebviewEditorInput | undefined {
public getInputForHandle(handle: string): WebviewInput | undefined {
return this._handlesToInputs.get(handle);
}
@@ -72,8 +71,6 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
'vscode-insider',
]);
private static revivalPool = 0;
private readonly _proxy: ExtHostWebviewsShape;
private readonly _webviewEditorInputs = new WebviewHandleStore();
private readonly _revivers = new Map<string, IDisposable>();
@@ -98,8 +95,8 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
// This reviver's only job is to activate webview panel extensions
// This should trigger the real reviver to be registered from the extension host side.
this._register(_webviewEditorService.registerResolver({
canResolve: (webview: WebviewEditorInput) => {
if (!webview.webview.state && webview.getTypeId() === WebviewEditorInput.typeId) { // TODO: The typeid check is a workaround for the CustomFileEditorInput case
canResolve: (webview: WebviewInput) => {
if (!webview.webview.state && webview.getTypeId() === WebviewInput.typeId) { // TODO: The typeid check is a workaround for the CustomFileEditorInput case
return false;
}
@@ -154,6 +151,13 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
webview.setName(value);
}
public $setState(handle: WebviewPanelHandle, state: modes.WebviewEditorState): void {
const webview = this.getWebviewEditorInput(handle);
if (webview instanceof CustomFileEditorInput) {
webview.setState(state);
}
}
public $setIconPath(handle: WebviewPanelHandle, value: { light: UriComponents, dark: UriComponents } | undefined): void {
const webview = this.getWebviewEditorInput(handle);
webview.iconPath = reviveWebviewIcon(value);
@@ -203,23 +207,14 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
return;
}
const handle = `revival-${MainThreadWebviews.revivalPool++}`;
const handle = generateUuid();
this._webviewEditorInputs.add(handle, webviewEditorInput);
this.hookupWebviewEventDelegate(handle, webviewEditorInput);
let state = undefined;
if (webviewEditorInput.webview.state) {
try {
// Check for old-style webview state first which stored state inside another state object
// TODO: remove this after 1.37 ships.
if (
typeof (webviewEditorInput.webview.state as unknown as OldMainThreadWebviewState).viewType === 'string' &&
'state' in (webviewEditorInput.webview.state as unknown as OldMainThreadWebviewState)
) {
state = JSON.parse((webviewEditorInput.webview.state as any).state);
} else {
state = JSON.parse(webviewEditorInput.webview.state);
}
state = JSON.parse(webviewEditorInput.webview.state);
} catch {
// noop
}
@@ -252,13 +247,19 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
this._editorProviders.set(viewType, this._webviewEditorService.registerResolver({
canResolve: (webviewEditorInput) => {
return webviewEditorInput.getTypeId() !== WebviewEditorInput.typeId && webviewEditorInput.viewType === viewType;
return webviewEditorInput.getTypeId() !== WebviewInput.typeId && webviewEditorInput.viewType === viewType;
},
resolveWebview: async (webview) => {
const handle = `resolved-${MainThreadWebviews.revivalPool++}`;
const handle = generateUuid();
this._webviewEditorInputs.add(handle, webview);
this.hookupWebviewEventDelegate(handle, webview);
if (webview instanceof CustomFileEditorInput) {
webview.onWillSave(e => {
e.waitUntil(this._proxy.$save(handle));
});
}
try {
await this._proxy.$resolveWebviewEditor(
webview.getResource(),
@@ -298,7 +299,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
return viewType.replace(/^mainThreadWebview-/, '');
}
private hookupWebviewEventDelegate(handle: WebviewPanelHandle, input: WebviewEditorInput) {
private hookupWebviewEventDelegate(handle: WebviewPanelHandle, input: WebviewInput) {
input.webview.onDidClickLink((uri: URI) => this.onDidClickLink(handle, uri));
input.webview.onMessage((message: any) => this._proxy.$onMessage(handle, message));
input.onDispose(() => {
@@ -323,21 +324,31 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
const activeInput = this._editorService.activeControl && this._editorService.activeControl.input;
const viewStates: WebviewPanelViewStateData = {};
const updateViewStatesForInput = (group: IEditorGroup, topLevelInput: IEditorInput, editorInput: IEditorInput) => {
if (!(editorInput instanceof WebviewInput)) {
return;
}
editorInput.updateGroup(group.id);
const handle = this._webviewEditorInputs.getHandleForInput(editorInput);
if (handle) {
viewStates[handle] = {
visible: topLevelInput.matches(group.activeEditor),
active: topLevelInput.matches(activeInput),
position: editorGroupToViewColumn(this._editorGroupService, group.id),
};
}
};
for (const group of this._editorGroupService.groups) {
for (const input of group.editors) {
if (!(input instanceof WebviewEditorInput)) {
continue;
}
input.updateGroup(group.id);
const handle = this._webviewEditorInputs.getHandleForInput(input);
if (handle) {
viewStates[handle] = {
visible: input === group.activeEditor,
active: input === activeInput,
position: editorGroupToViewColumn(this._editorGroupService, group.id),
};
if (input instanceof DiffEditorInput) {
updateViewStatesForInput(group, input, input.master);
updateViewStatesForInput(group, input, input.details);
} else {
updateViewStatesForInput(group, input, input);
}
}
}
@@ -354,7 +365,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
}
}
private isSupportedLink(webview: WebviewEditorInput, link: URI): boolean {
private isSupportedLink(webview: WebviewInput, link: URI): boolean {
if (MainThreadWebviews.standardSupportedLinkSchemes.has(link.scheme)) {
return true;
}
@@ -364,7 +375,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
return !!webview.webview.contentOptions.enableCommandUris && link.scheme === 'command';
}
private getWebviewEditorInput(handle: WebviewPanelHandle): WebviewEditorInput {
private getWebviewEditorInput(handle: WebviewPanelHandle): WebviewInput {
const webview = this.tryGetWebviewEditorInput(handle);
if (!webview) {
throw new Error('Unknown webview handle:' + handle);
@@ -372,7 +383,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
return webview;
}
private tryGetWebviewEditorInput(handle: WebviewPanelHandle): WebviewEditorInput | undefined {
private tryGetWebviewEditorInput(handle: WebviewPanelHandle): WebviewInput | undefined {
return this._webviewEditorInputs.getInputForHandle(handle);
}