Merge from vscode 718331d6f3ebd1b571530ab499edb266ddd493d5

This commit is contained in:
ADS Merger
2020-02-08 04:50:58 +00:00
parent 8c61538a27
commit 2af13c18d2
752 changed files with 16458 additions and 10063 deletions

View File

@@ -60,6 +60,7 @@ import './mainThreadComments';
import './mainThreadLabelService';
import './mainThreadTunnelService';
import './mainThreadAuthentication';
import './mainThreadTimeline';
import 'vs/workbench/api/common/apiCommands';
export class ExtensionPoints implements IWorkbenchContribution {

View File

@@ -20,12 +20,24 @@ export class MainThreadAuthenticationProvider {
public readonly displayName: string
) { }
getSessions(): Promise<ReadonlyArray<modes.Session>> {
return this._proxy.$getSessions(this.id);
async getSessions(): Promise<ReadonlyArray<modes.AuthenticationSession>> {
return (await this._proxy.$getSessions(this.id)).map(session => {
return {
id: session.id,
accountName: session.accountName,
accessToken: () => this._proxy.$getSessionAccessToken(this.id, session.id)
};
});
}
login(scopes: string[]): Promise<modes.Session> {
return this._proxy.$login(this.id, scopes);
login(scopes: string[]): Promise<modes.AuthenticationSession> {
return this._proxy.$login(this.id, scopes).then(session => {
return {
id: session.id,
accountName: session.accountName,
accessToken: () => this._proxy.$getSessionAccessToken(this.id, session.id)
};
});
}
logout(accountId: string): Promise<void> {

View File

@@ -77,7 +77,7 @@ export class MainThreadConfiguration implements MainThreadConfigurationShape {
: scopeToLanguage === false ? { resource: overrides.resource }
: overrides.overrideIdentifier && overriddenValue !== undefined ? overrides
: { resource: overrides.resource };
return this.configurationService.updateValue(key, value, overrides, configurationTarget);
return this.configurationService.updateValue(key, value, overrides, configurationTarget, true);
}
private deriveConfigurationTarget(key: string, overrides: IConfigurationOverrides): ConfigurationTarget {

View File

@@ -4,15 +4,14 @@
*--------------------------------------------------------------------------------------------*/
import { Registry } from 'vs/platform/registry/common/platform';
import { IOutputService, IOutputChannel, OUTPUT_PANEL_ID } from 'vs/workbench/contrib/output/common/output';
import { IOutputService, IOutputChannel, OUTPUT_VIEW_ID } from 'vs/workbench/contrib/output/common/output';
import { Extensions, IOutputChannelRegistry } from 'vs/workbench/services/output/common/output';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { MainThreadOutputServiceShape, MainContext, IExtHostContext, ExtHostOutputServiceShape, ExtHostContext } from '../common/extHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { UriComponents, URI } from 'vs/base/common/uri';
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
import { Event } from 'vs/base/common/event';
import { IViewsService } from 'vs/workbench/common/views';
@extHostNamedCustomer(MainContext.MainThreadOutputService)
export class MainThreadOutputService extends Disposable implements MainThreadOutputServiceShape {
@@ -21,28 +20,24 @@ export class MainThreadOutputService extends Disposable implements MainThreadOut
private readonly _proxy: ExtHostOutputServiceShape;
private readonly _outputService: IOutputService;
private readonly _layoutService: IWorkbenchLayoutService;
private readonly _panelService: IPanelService;
private readonly _viewsService: IViewsService;
constructor(
extHostContext: IExtHostContext,
@IOutputService outputService: IOutputService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
@IPanelService panelService: IPanelService
@IViewsService viewsService: IViewsService
) {
super();
this._outputService = outputService;
this._layoutService = layoutService;
this._panelService = panelService;
this._viewsService = viewsService;
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostOutputService);
const setVisibleChannel = () => {
const panel = this._panelService.getActivePanel();
const visibleChannel = panel && panel.getId() === OUTPUT_PANEL_ID ? this._outputService.getActiveChannel() : undefined;
const visibleChannel = this._viewsService.isViewVisible(OUTPUT_VIEW_ID) ? this._outputService.getActiveChannel() : undefined;
this._proxy.$setVisibleChannel(visibleChannel ? visibleChannel.id : null);
};
this._register(Event.any<any>(this._outputService.onActiveOutputChannel, this._panelService.onDidPanelOpen, this._panelService.onDidPanelClose)(() => setVisibleChannel()));
this._register(Event.any<any>(this._outputService.onActiveOutputChannel, Event.filter(this._viewsService.onDidChangeViewVisibility, ({ id }) => id === OUTPUT_VIEW_ID))(() => setVisibleChannel()));
setVisibleChannel();
}
@@ -86,11 +81,10 @@ export class MainThreadOutputService extends Disposable implements MainThreadOut
}
public $close(channelId: string): Promise<void> | undefined {
const panel = this._panelService.getActivePanel();
if (panel && panel.getId() === OUTPUT_PANEL_ID) {
if (this._viewsService.isViewVisible(OUTPUT_VIEW_ID)) {
const activeChannel = this._outputService.getActiveChannel();
if (activeChannel && channelId === activeChannel.id) {
this._layoutService.setPanelHidden(true);
this._viewsService.closeView(OUTPUT_VIEW_ID);
}
}

View File

@@ -202,8 +202,8 @@ class MainThreadSCMProvider implements ISCMProvider {
const icon = icons[0];
const iconDark = icons[1] || icon;
const decorations = {
icon: icon ? URI.parse(icon) : undefined,
iconDark: iconDark ? URI.parse(iconDark) : undefined,
icon: icon ? URI.revive(icon) : undefined,
iconDark: iconDark ? URI.revive(iconDark) : undefined,
tooltip,
strikeThrough,
faded

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IdleValue } from 'vs/base/common/async';
import { IdleValue, raceCancellation } from 'vs/base/common/async';
import { CancellationTokenSource, CancellationToken } from 'vs/base/common/cancellation';
import * as strings from 'vs/base/common/strings';
import { IActiveCodeEditor } from 'vs/editor/browser/editorBrowser';
@@ -22,25 +22,20 @@ import { CodeActionKind } from 'vs/editor/contrib/codeAction/types';
import { formatDocumentWithSelectedProvider, FormattingMode } from 'vs/editor/contrib/format/format';
import { SnippetController2 } from 'vs/editor/contrib/snippet/snippetController2';
import { localize } from 'vs/nls';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
import { IProgressService, ProgressLocation, IProgressStep, IProgress } from 'vs/platform/progress/common/progress';
import { extHostCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
import { ISaveParticipant, IResolvedTextFileEditorModel, ITextFileEditorModel } from 'vs/workbench/services/textfile/common/textfiles';
import { ISaveParticipant, IResolvedTextFileEditorModel, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { SaveReason } from 'vs/workbench/common/editor';
import { ExtHostContext, ExtHostDocumentSaveParticipantShape, IExtHostContext } from '../common/extHost.protocol';
import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService'; // {{SQL CARBON EDIT}}
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { SettingsEditor2 } from 'vs/workbench/contrib/preferences/browser/settingsEditor2';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { ILabelService } from 'vs/platform/label/common/label';
import { canceled } from 'vs/base/common/errors';
import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService';
export interface ICodeActionsOnSaveOptions {
[kind: string]: boolean;
export interface ISaveParticipantParticipant {
participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason }, progress: IProgress<IProgressStep>, token: CancellationToken): Promise<void>;
}
/*
@@ -57,7 +52,7 @@ class NotebookUpdateParticipant implements ISaveParticipantParticipant { // {{SQ
// Nothing
}
public participate(model: ITextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
public participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
let uri = model.resource;
let notebookEditor = this.notebookService.findNotebookEditor(uri);
if (notebookEditor) {
@@ -67,10 +62,6 @@ class NotebookUpdateParticipant implements ISaveParticipantParticipant { // {{SQ
}
}
export interface ISaveParticipantParticipant {
participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason }, progress: IProgress<IProgressStep>, token: CancellationToken): Promise<void>;
}
class TrimWhitespaceParticipant implements ISaveParticipantParticipant {
constructor(
@@ -272,11 +263,10 @@ class CodeActionOnSaveParticipant implements ISaveParticipantParticipant {
if (env.reason === SaveReason.AUTO) {
return undefined;
}
const model = editorModel.textEditorModel;
const settingsOverrides = { overrideIdentifier: model.getLanguageIdentifier().language, resource: editorModel.resource };
const setting = this._configurationService.getValue<ICodeActionsOnSaveOptions>('editor.codeActionsOnSave', settingsOverrides);
const setting = this._configurationService.getValue<{ [kind: string]: boolean }>('editor.codeActionsOnSave', settingsOverrides);
if (!setting) {
return undefined;
}
@@ -381,6 +371,7 @@ export class SaveParticipant implements ISaveParticipant {
@IProgressService private readonly _progressService: IProgressService,
@ILogService private readonly _logService: ILogService,
@ILabelService private readonly _labelService: ILabelService,
@ITextFileService private readonly _textFileService: ITextFileService
) {
this._saveParticipants = new IdleValue(() => [
instantiationService.createInstance(TrimWhitespaceParticipant),
@@ -392,12 +383,12 @@ export class SaveParticipant implements ISaveParticipant {
instantiationService.createInstance(NotebookUpdateParticipant),
instantiationService.createInstance(ExtHostSaveParticipant, extHostContext),
]);
// Hook into model
TextFileEditorModel.setSaveParticipant(this);
// Set as save participant for all text files
this._textFileService.saveParticipant = this;
}
dispose(): void {
TextFileEditorModel.setSaveParticipant(null);
this._textFileService.saveParticipant = undefined;
this._saveParticipants.dispose();
}
@@ -411,32 +402,26 @@ export class SaveParticipant implements ISaveParticipant {
cancellable: true,
delay: model.isDirty() ? 3000 : 5000
}, async progress => {
// undoStop before participation
model.textEditorModel.pushStackElement();
for (let p of this._saveParticipants.getValue()) {
if (cts.token.isCancellationRequested) {
break;
}
try {
await p.participate(model, env, progress, cts.token);
const promise = p.participate(model, env, progress, cts.token);
await raceCancellation(promise, cts.token);
} catch (err) {
this._logService.warn(err);
}
}
// undoStop after participation
model.textEditorModel.pushStackElement();
}, () => {
// user cancel
cts.dispose(true);
});
}
}
CommandsRegistry.registerCommand('_showSettings', (accessor, ...args: any[]) => {
const [setting] = args;
const control = accessor.get(IEditorService).activeControl as SettingsEditor2;
if (control instanceof SettingsEditor2) {
control.focusSearch(`@tag:usesOnlineServices`);
} else {
accessor.get(IPreferencesService).openSettings(false, setting);
}
});

View File

@@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Emitter } from 'vs/base/common/event';
import { CancellationToken } from 'vs/base/common/cancellation';
import { URI } from 'vs/base/common/uri';
import { ILogService } from 'vs/platform/log/common/log';
import { MainContext, MainThreadTimelineShape, IExtHostContext, ExtHostTimelineShape, ExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { ITimelineService, TimelineItem, TimelineProviderDescriptor, TimelineChangeEvent } from 'vs/workbench/contrib/timeline/common/timeline';
@extHostNamedCustomer(MainContext.MainThreadTimeline)
export class MainThreadTimeline implements MainThreadTimelineShape {
private readonly _proxy: ExtHostTimelineShape;
private readonly _providerEmitters = new Map<string, Emitter<TimelineChangeEvent>>();
constructor(
context: IExtHostContext,
@ILogService private readonly logService: ILogService,
@ITimelineService private readonly _timelineService: ITimelineService
) {
this._proxy = context.getProxy(ExtHostContext.ExtHostTimeline);
}
$getTimeline(uri: URI, token: CancellationToken): Promise<TimelineItem[]> {
return this._timelineService.getTimeline(uri, token);
}
$registerTimelineProvider(provider: TimelineProviderDescriptor): void {
this.logService.trace(`MainThreadTimeline#registerTimelineProvider: id=${provider.id}`);
const proxy = this._proxy;
const emitters = this._providerEmitters;
let onDidChange = emitters.get(provider.id);
if (onDidChange === undefined) {
onDidChange = new Emitter<TimelineChangeEvent>();
emitters.set(provider.id, onDidChange);
}
this._timelineService.registerTimelineProvider({
...provider,
onDidChange: onDidChange.event,
provideTimeline(uri: URI, token: CancellationToken) {
return proxy.$getTimeline(provider.id, uri, token);
},
dispose() {
emitters.delete(provider.id);
onDidChange?.dispose();
}
});
}
$unregisterTimelineProvider(id: string): void {
this.logService.trace(`MainThreadTimeline#unregisterTimelineProvider: id=${id}`);
this._timelineService.unregisterTimelineProvider(id);
}
$emitTimelineChangeEvent(e: TimelineChangeEvent): void {
this.logService.trace(`MainThreadTimeline#emitChangeEvent: id=${e.id}, uri=${e.uri?.toString(true)}`);
const emitter = this._providerEmitters.get(e.id!);
emitter?.fire(e);
}
dispose(): void {
// noop
}
}

View File

@@ -235,7 +235,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
for (const viewContainer of viewContainersRegistry.all) {
if (viewContainer.extensionId && removedExtensions.has(ExtensionIdentifier.toKey(viewContainer.extensionId))) {
// move only those views that do not belong to the removed extension
const views = this.viewsRegistry.getViews(viewContainer).filter((view: ICustomViewDescriptor) => !removedExtensions.has(ExtensionIdentifier.toKey(view.extensionId)));
const views = this.viewsRegistry.getViews(viewContainer).filter(view => !removedExtensions.has(ExtensionIdentifier.toKey((view as ICustomViewDescriptor).extensionId)));
if (views.length) {
this.viewsRegistry.moveViews(views, this.getDefaultViewContainer());
}
@@ -290,7 +290,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
const viewsToMove: IViewDescriptor[] = [];
for (const existingViewContainer of existingViewContainers) {
if (viewContainer !== existingViewContainer) {
viewsToMove.push(...this.viewsRegistry.getViews(existingViewContainer).filter((view: ICustomViewDescriptor) => view.originalContainerId === descriptor.id));
viewsToMove.push(...this.viewsRegistry.getViews(existingViewContainer).filter(view => (view as ICustomViewDescriptor).originalContainerId === descriptor.id));
}
}
if (viewsToMove.length) {
@@ -314,6 +314,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
[id, `${id}.state`, { mergeViewWithContainerWhenSingleView: true }]
),
hideIfEmpty: true,
order,
icon,
}, ViewContainerLocation.Sidebar);
@@ -399,8 +400,9 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
ctorDescriptor: new SyncDescriptor(CustomTreeViewPane),
when: ContextKeyExpr.deserialize(item.when),
canToggleVisibility: true,
canMoveView: true,
treeView: this.instantiationService.createInstance(CustomTreeView, item.id, item.name),
collapsed: this.showCollapsed(container),
treeView: this.instantiationService.createInstance(CustomTreeView, item.id, item.name, container),
order: order,
extensionId: extension.description.identifier,
originalContainerId: entry.key,
@@ -423,7 +425,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
private removeViews(extensions: readonly IExtensionPointUser<ViewExtensionPointType>[]): void {
const removedExtensions: Set<string> = extensions.reduce((result, e) => { result.add(ExtensionIdentifier.toKey(e.description.identifier)); return result; }, new Set<string>());
for (const viewContainer of this.viewContainersRegistry.all) {
const removedViews = this.viewsRegistry.getViews(viewContainer).filter((v: ICustomViewDescriptor) => v.extensionId && removedExtensions.has(ExtensionIdentifier.toKey(v.extensionId)));
const removedViews = this.viewsRegistry.getViews(viewContainer).filter(v => (v as ICustomViewDescriptor).extensionId && removedExtensions.has(ExtensionIdentifier.toKey((v as ICustomViewDescriptor).extensionId)));
if (removedViews.length) {
this.viewsRegistry.deregisterViews(removedViews, viewContainer);
}

View File

@@ -158,7 +158,7 @@ CommandsRegistry.registerCommand(OpenWithAPICommand.ID, adjustHandler(OpenWithAP
CommandsRegistry.registerCommand('_workbench.removeFromRecentlyOpened', function (accessor: ServicesAccessor, uri: URI) {
const workspacesService = accessor.get(IWorkspacesService);
return workspacesService.removeFromRecentlyOpened([uri]);
return workspacesService.removeRecentlyOpened([uri]);
});
export class RemoveFromRecentlyOpenedAPICommand {

View File

@@ -317,6 +317,5 @@ jsonRegistry.registerSchema('vscode://schemas/workspaceConfig', {
description: nls.localize('workspaceConfig.remoteAuthority', "The remote server where the workspace is located. Only used by unsaved remote workspaces."),
}
},
additionalProperties: false,
errorMessage: nls.localize('unknownWorkspaceProperty', "Unknown workspace configuration property")
});

View File

@@ -72,6 +72,7 @@ import { ExtHostTheming } from 'vs/workbench/api/common/extHostTheming';
import { IExtHostTunnelService } from 'vs/workbench/api/common/extHostTunnelService';
import { IExtHostApiDeprecationService } from 'vs/workbench/api/common/extHostApiDeprecationService';
import { ExtHostAuthentication } from 'vs/workbench/api/common/extHostAuthentication';
import { ExtHostTimeline } from 'vs/workbench/api/common/extHostTimeline';
export interface IExtensionApiFactory {
(extension: IExtensionDescription, registry: ExtensionDescriptionRegistry, configProvider: ExtHostConfigProvider): typeof vscode;
@@ -133,6 +134,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const extHostLabelService = rpcProtocol.set(ExtHostContext.ExtHostLabelService, new ExtHostLabelService(rpcProtocol));
const extHostTheming = rpcProtocol.set(ExtHostContext.ExtHostTheming, new ExtHostTheming(rpcProtocol));
const extHostAuthentication = rpcProtocol.set(ExtHostContext.ExtHostAuthentication, new ExtHostAuthentication(rpcProtocol));
const extHostTimeline = rpcProtocol.set(ExtHostContext.ExtHostTimeline, new ExtHostTimeline(rpcProtocol));
// Check that no named customers are missing
// {{SQL CARBON EDIT}} filter out the services we don't expose
@@ -189,11 +191,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
get providers() {
return extHostAuthentication.providers(extension);
},
get onDidRegisterAuthenticationProvider() {
return extHostAuthentication.onDidRegisterAuthenticationProvider;
},
get onDidUnregisterAuthenticationProvider() {
return extHostAuthentication.onDidUnregisterAuthenticationProvider;
get onDidChangeAuthenticationProviders(): Event<vscode.AuthenticationProvidersChangeEvent> {
return extHostAuthentication.onDidChangeAuthenticationProviders;
}
};
@@ -761,9 +760,19 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
checkProposedApiEnabled(extension);
return extHostTunnelService.getTunnels();
},
onDidChangeTunnels: (listener, thisArg?, disposables?) => {
checkProposedApiEnabled(extension);
return extHostTunnelService.onDidChangeTunnels(listener, thisArg, disposables);
},
onDidTunnelsChange: (listener, thisArg?, disposables?) => {
checkProposedApiEnabled(extension);
return extHostTunnelService.onDidTunnelsChange(listener, thisArg, disposables);
return extHostTunnelService.onDidChangeTunnels(listener, thisArg, disposables);
},
registerTimelineProvider: (scheme: string, provider: vscode.TimelineProvider) => {
checkProposedApiEnabled(extension);
return extHostTimeline.registerTimelineProvider(provider, extension.identifier, extHostCommands.converter);
}
};
@@ -986,7 +995,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
Decoration: extHostTypes.Decoration,
WebviewContentState: extHostTypes.WebviewContentState,
UIKind: UIKind,
ColorThemeKind: extHostTypes.ColorThemeKind
ColorThemeKind: extHostTypes.ColorThemeKind,
TimelineItem: extHostTypes.TimelineItem
};
};
}

View File

@@ -49,6 +49,7 @@ import { SaveReason } from 'vs/workbench/common/editor';
import { ExtensionActivationReason } from 'vs/workbench/api/common/extHostExtensionActivator';
import { TunnelDto } from 'vs/workbench/api/common/extHostTunnelService';
import { TunnelOptions } from 'vs/platform/remote/common/tunnel';
import { TimelineItem, TimelineProviderDescriptor, TimelineChangeEvent, TimelineItemWithSource } from 'vs/workbench/contrib/timeline/common/timeline';
// {{SQL CARBON EDIT}}
import { ITreeItem as sqlITreeItem } from 'sql/workbench/common/views';
@@ -714,7 +715,7 @@ export interface SCMGroupFeatures {
export type SCMRawResource = [
number /*handle*/,
UriComponents /*resourceUri*/,
string[] /*icons: light, dark*/,
UriComponents[] /*icons: light, dark*/,
string /*tooltip*/,
boolean /*strike through*/,
boolean /*faded*/
@@ -801,6 +802,14 @@ export interface MainThreadTunnelServiceShape extends IDisposable {
$setCandidateFilter(): Promise<void>;
}
export interface MainThreadTimelineShape extends IDisposable {
$registerTimelineProvider(provider: TimelineProviderDescriptor): void;
$unregisterTimelineProvider(source: string): void;
$emitTimelineChangeEvent(e: TimelineChangeEvent): void;
$getTimeline(uri: UriComponents, token: CancellationToken): Promise<TimelineItem[]>;
}
// -- extension host
export interface ExtHostCommandsShape {
@@ -914,8 +923,9 @@ export interface ExtHostLabelServiceShape {
}
export interface ExtHostAuthenticationShape {
$getSessions(id: string): Promise<ReadonlyArray<modes.Session>>;
$login(id: string, scopes: string[]): Promise<modes.Session>;
$getSessions(id: string): Promise<ReadonlyArray<modes.AuthenticationSession>>;
$getSessionAccessToken(id: string, sessionId: string): Promise<string>;
$login(id: string, scopes: string[]): Promise<modes.AuthenticationSession>;
$logout(id: string, sessionId: string): Promise<void>;
}
@@ -1445,6 +1455,10 @@ export interface ExtHostTunnelServiceShape {
$onDidTunnelsChange(): Promise<void>;
}
export interface ExtHostTimelineShape {
$getTimeline(source: string, uri: UriComponents, token: CancellationToken): Promise<TimelineItemWithSource[]>;
}
// --- proxy identifiers
export const MainContext = {
@@ -1488,7 +1502,8 @@ export const MainContext = {
MainThreadWindow: createMainId<MainThreadWindowShape>('MainThreadWindow'),
MainThreadLabelService: createMainId<MainThreadLabelServiceShape>('MainThreadLabelService'),
MainThreadTheming: createMainId<MainThreadThemingShape>('MainThreadTheming'),
MainThreadTunnelService: createMainId<MainThreadTunnelServiceShape>('MainThreadTunnelService')
MainThreadTunnelService: createMainId<MainThreadTunnelServiceShape>('MainThreadTunnelService'),
MainThreadTimeline: createMainId<MainThreadTimelineShape>('MainThreadTimeline')
};
export const ExtHostContext = {
@@ -1525,5 +1540,6 @@ export const ExtHostContext = {
ExtHostLabelService: createMainId<ExtHostLabelServiceShape>('ExtHostLabelService'),
ExtHostTheming: createMainId<ExtHostThemingShape>('ExtHostTheming'),
ExtHostTunnelService: createMainId<ExtHostTunnelServiceShape>('ExtHostTunnelService'),
ExtHostAuthentication: createMainId<ExtHostAuthenticationShape>('ExtHostAuthentication')
ExtHostAuthentication: createMainId<ExtHostAuthenticationShape>('ExtHostAuthentication'),
ExtHostTimeline: createMainId<ExtHostTimelineShape>('ExtHostTimeline')
};

View File

@@ -142,7 +142,7 @@ const newCommands: ApiCommand[] = [
),
// -- go to symbol (definition, type definition, declaration, impl, references)
new ApiCommand(
'vscode.executeDefinitionProvider', '_executeDefinitionProvider', 'Execute all definition provider.',
'vscode.executeDefinitionProvider', '_executeDefinitionProvider', 'Execute all definition providers.',
[ApiCommandArgument.Uri, ApiCommandArgument.Position],
new ApiCommandResult<modes.Location[], types.Location[] | undefined>('A promise that resolves to an array of Location-instances.', tryMapWith(typeConverters.location.to))
),
@@ -168,7 +168,7 @@ const newCommands: ApiCommand[] = [
),
// -- hover
new ApiCommand(
'vscode.executeHoverProvider', '_executeHoverProvider', 'Execute all hover provider.',
'vscode.executeHoverProvider', '_executeHoverProvider', 'Execute all hover providers.',
[ApiCommandArgument.Uri, ApiCommandArgument.Position],
new ApiCommandResult<modes.Hover[], types.Hover[] | undefined>('A promise that resolves to an array of Hover-instances.', tryMapWith(typeConverters.Hover.to))
),
@@ -188,7 +188,7 @@ const newCommands: ApiCommand[] = [
),
// -- symbol search
new ApiCommand(
'vscode.executeWorkspaceSymbolProvider', '_executeWorkspaceSymbolProvider', 'Execute all workspace symbol provider.',
'vscode.executeWorkspaceSymbolProvider', '_executeWorkspaceSymbolProvider', 'Execute all workspace symbol providers.',
[new ApiCommandArgument('query', 'Search string', v => typeof v === 'string', v => v)],
new ApiCommandResult<[search.IWorkspaceSymbolProvider, search.IWorkspaceSymbol[]][], types.SymbolInformation[]>('A promise that resolves to an array of SymbolInformation-instances.', value => {
const result: types.SymbolInformation[] = [];

View File

@@ -28,16 +28,30 @@ export class AuthenticationProviderWrapper implements vscode.AuthenticationProvi
return this._provider.displayName;
}
async getSessions(): Promise<ReadonlyArray<vscode.Session>> {
const isAllowed = await this._proxy.$getSessionsPrompt(this._provider.id, this.displayName, ExtensionIdentifier.toKey(this._requestingExtension.identifier), this._requestingExtension.displayName || this._requestingExtension.name);
if (!isAllowed) {
throw new Error('User did not consent to session access.');
}
async getSessions(): Promise<ReadonlyArray<vscode.AuthenticationSession>> {
return (await this._provider.getSessions()).map(session => {
return {
id: session.id,
accountName: session.accountName,
scopes: session.scopes,
accessToken: async () => {
const isAllowed = await this._proxy.$getSessionsPrompt(
this._provider.id,
this.displayName,
ExtensionIdentifier.toKey(this._requestingExtension.identifier),
this._requestingExtension.displayName || this._requestingExtension.name);
return this._provider.getSessions();
if (!isAllowed) {
throw new Error('User did not consent to token access.');
}
return session.accessToken();
}
};
});
}
async login(scopes: string[]): Promise<vscode.Session> {
async login(scopes: string[]): Promise<vscode.AuthenticationSession> {
const isAllowed = await this._proxy.$loginPrompt(this._provider.id, this.displayName, ExtensionIdentifier.toKey(this._requestingExtension.identifier), this._requestingExtension.displayName || this._requestingExtension.name);
if (!isAllowed) {
throw new Error('User did not consent to login.');
@@ -55,11 +69,8 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
private _proxy: MainThreadAuthenticationShape;
private _authenticationProviders: Map<string, vscode.AuthenticationProvider> = new Map<string, vscode.AuthenticationProvider>();
private _onDidRegisterAuthenticationProvider = new Emitter<string>();
readonly onDidRegisterAuthenticationProvider: Event<string> = this._onDidRegisterAuthenticationProvider.event;
private _onDidUnregisterAuthenticationProvider = new Emitter<string>();
readonly onDidUnregisterAuthenticationProvider: Event<string> = this._onDidUnregisterAuthenticationProvider.event;
private _onDidChangeAuthenticationProviders = new Emitter<vscode.AuthenticationProvidersChangeEvent>();
readonly onDidChangeAuthenticationProviders: Event<vscode.AuthenticationProvidersChangeEvent> = this._onDidChangeAuthenticationProviders.event;
constructor(mainContext: IMainContext) {
this._proxy = mainContext.getProxy(MainContext.MainThreadAuthentication);
@@ -83,23 +94,23 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
});
this._proxy.$registerAuthenticationProvider(provider.id, provider.displayName);
this._onDidRegisterAuthenticationProvider.fire(provider.id);
this._onDidChangeAuthenticationProviders.fire({ added: [provider.id], removed: [] });
return new Disposable(() => {
listener.dispose();
this._authenticationProviders.delete(provider.id);
this._proxy.$unregisterAuthenticationProvider(provider.id);
this._onDidUnregisterAuthenticationProvider.fire(provider.id);
this._onDidChangeAuthenticationProviders.fire({ added: [], removed: [provider.id] });
});
}
$login(providerId: string, scopes: string[]): Promise<modes.Session> {
$login(providerId: string, scopes: string[]): Promise<modes.AuthenticationSession> {
const authProvider = this._authenticationProviders.get(providerId);
if (authProvider) {
return Promise.resolve(authProvider.login(scopes));
}
throw new Error(`Unable to find authentication provider with handle: ${0}`);
throw new Error(`Unable to find authentication provider with handle: ${providerId}`);
}
$logout(providerId: string, sessionId: string): Promise<void> {
@@ -108,15 +119,30 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
return Promise.resolve(authProvider.logout(sessionId));
}
throw new Error(`Unable to find authentication provider with handle: ${0}`);
throw new Error(`Unable to find authentication provider with handle: ${providerId}`);
}
$getSessions(providerId: string): Promise<ReadonlyArray<modes.Session>> {
$getSessions(providerId: string): Promise<ReadonlyArray<modes.AuthenticationSession>> {
const authProvider = this._authenticationProviders.get(providerId);
if (authProvider) {
return Promise.resolve(authProvider.getSessions());
}
throw new Error(`Unable to find authentication provider with handle: ${0}`);
throw new Error(`Unable to find authentication provider with handle: ${providerId}`);
}
async $getSessionAccessToken(providerId: string, sessionId: string): Promise<string> {
const authProvider = this._authenticationProviders.get(providerId);
if (authProvider) {
const sessions = await authProvider.getSessions();
const session = sessions.find(session => session.id === sessionId);
if (session) {
return session.accessToken();
}
throw new Error(`Unable to find session with id: ${sessionId}`);
}
throw new Error(`Unable to find authentication provider with handle: ${providerId}`);
}
}

View File

@@ -20,7 +20,6 @@ import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { ILogService } from 'vs/platform/log/common/log';
import { Workspace } from 'vs/platform/workspace/common/workspace';
import { URI } from 'vs/base/common/uri';
import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
function lookUp(tree: any, key: string) {
if (key) {
@@ -42,7 +41,7 @@ type ConfigurationInspect<T> = {
workspaceFolderValue?: T,
defaultLanguageValue?: T;
userLanguageValue?: T;
globalLanguageValue?: T;
workspaceLanguageValue?: T;
workspaceFolderLanguageValue?: T;
@@ -157,9 +156,6 @@ export class ExtHostConfigProvider {
getConfiguration(section?: string, scope?: vscode.ConfigurationScope | null, extensionDescription?: IExtensionDescription): vscode.WorkspaceConfiguration {
const overrides = scopeToOverrides(scope) || {};
if (overrides.overrideIdentifier && extensionDescription) {
checkProposedApiEnabled(extensionDescription);
}
const config = this._toReadonlyValue(section
? lookUp(this._configuration.getValue(undefined, overrides, this._extHostWorkspace.workspace), section)
: this._configuration.getValue(undefined, overrides, this._extHostWorkspace.workspace));
@@ -260,13 +256,13 @@ export class ExtHostConfigProvider {
return {
key,
defaultValue: config.defaultValue,
globalValue: config.userValue,
workspaceValue: config.workspaceValue,
workspaceFolderValue: config.workspaceFolderValue,
defaultValue: config.default?.value,
globalValue: config.user?.value,
workspaceValue: config.workspace?.value,
workspaceFolderValue: config.workspaceFolder?.value,
defaultLanguageValue: config.default?.override,
userLanguageValue: config.user?.override,
globalLanguageValue: config.user?.override,
workspaceLanguageValue: config.workspace?.override,
workspaceFolderLanguageValue: config.workspaceFolder?.override,

View File

@@ -369,7 +369,8 @@ export abstract class AbstractExtHostExtensionService implements ExtHostExtensio
get extensionPath() { return extensionDescription.extensionLocation.fsPath; },
get storagePath() { return that._storagePath.workspaceValue(extensionDescription); },
get globalStoragePath() { return that._storagePath.globalValue(extensionDescription); },
asAbsolutePath: (relativePath: string) => { return path.join(extensionDescription.extensionLocation.fsPath, relativePath); },
asAbsolutePath(relativePath: string) { return path.join(extensionDescription.extensionLocation.fsPath, relativePath); },
asExtensionUri(relativePath: string) { return joinPath(extensionDescription.extensionLocation, relativePath); },
get logPath() { return path.join(that._initData.logsLocation.fsPath, extensionDescription.identifier.value); }
});
});

View File

@@ -22,15 +22,14 @@ type ProviderHandle = number;
type GroupHandle = number;
type ResourceStateHandle = number;
function getIconPath(decorations?: vscode.SourceControlResourceThemableDecorations): string | undefined {
function getIconResource(decorations?: vscode.SourceControlResourceThemableDecorations): vscode.Uri | undefined {
if (!decorations) {
return undefined;
} else if (typeof decorations.iconPath === 'string') {
return URI.file(decorations.iconPath).toString();
} else if (decorations.iconPath) {
return `${decorations.iconPath}`;
return URI.file(decorations.iconPath);
} else {
return decorations.iconPath;
}
return undefined;
}
function compareResourceThemableDecorations(a: vscode.SourceControlResourceThemableDecorations, b: vscode.SourceControlResourceThemableDecorations): number {
@@ -287,28 +286,28 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
this._resourceStatesMap.set(handle, r);
const sourceUri = r.resourceUri;
const iconPath = getIconPath(r.decorations);
const lightIconPath = r.decorations && getIconPath(r.decorations.light) || iconPath;
const darkIconPath = r.decorations && getIconPath(r.decorations.dark) || iconPath;
const icons: string[] = [];
const iconUri = getIconResource(r.decorations);
const lightIconUri = r.decorations && getIconResource(r.decorations.light) || iconUri;
const darkIconUri = r.decorations && getIconResource(r.decorations.dark) || iconUri;
const icons: UriComponents[] = [];
if (r.command) {
this._resourceStatesCommandsMap.set(handle, r.command);
}
if (lightIconPath) {
icons.push(lightIconPath);
if (lightIconUri) {
icons.push(lightIconUri);
}
if (darkIconPath && (darkIconPath !== lightIconPath)) {
icons.push(darkIconPath);
if (darkIconUri && (darkIconUri.toString() !== lightIconUri?.toString())) {
icons.push(darkIconUri);
}
const tooltip = (r.decorations && r.decorations.tooltip) || '';
const strikeThrough = r.decorations && !!r.decorations.strikeThrough;
const faded = r.decorations && !!r.decorations.faded;
const rawResource = [handle, <UriComponents>sourceUri, icons, tooltip, strikeThrough, faded] as SCMRawResource;
const rawResource = [handle, sourceUri, icons, tooltip, strikeThrough, faded] as SCMRawResource;
return { rawResource, handle };
});

View File

@@ -278,6 +278,7 @@ export class ExtHostPseudoterminal implements ITerminalChildProcess {
}
this._pty.open(initialDimensions ? initialDimensions : undefined);
this._onProcessReady.fire({ pid: -1, cwd: '' });
}
}

View File

@@ -0,0 +1,129 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { UriComponents, URI } from 'vs/base/common/uri';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ExtHostTimelineShape, MainThreadTimelineShape, IMainContext, MainContext } from 'vs/workbench/api/common/extHost.protocol';
import { TimelineItemWithSource, TimelineProvider } from 'vs/workbench/contrib/timeline/common/timeline';
import { IDisposable, toDisposable, DisposableStore } from 'vs/base/common/lifecycle';
import { CancellationToken } from 'vs/base/common/cancellation';
import { CommandsConverter } from 'vs/workbench/api/common/extHostCommands';
import { ThemeIcon } from 'vs/workbench/api/common/extHostTypes';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
export interface IExtHostTimeline extends ExtHostTimelineShape {
readonly _serviceBrand: undefined;
$getTimeline(id: string, uri: UriComponents, token: vscode.CancellationToken): Promise<TimelineItemWithSource[]>;
}
export const IExtHostTimeline = createDecorator<IExtHostTimeline>('IExtHostTimeline');
export class ExtHostTimeline implements IExtHostTimeline {
_serviceBrand: undefined;
private _proxy: MainThreadTimelineShape;
private _providers = new Map<string, TimelineProvider>();
constructor(
mainContext: IMainContext,
) {
this._proxy = mainContext.getProxy(MainContext.MainThreadTimeline);
}
async $getTimeline(id: string, uri: UriComponents, token: vscode.CancellationToken): Promise<TimelineItemWithSource[]> {
const provider = this._providers.get(id);
return provider?.provideTimeline(URI.revive(uri), token) ?? [];
}
registerTimelineProvider(provider: vscode.TimelineProvider, extensionId: ExtensionIdentifier, commandConverter: CommandsConverter): IDisposable {
const timelineDisposables = new DisposableStore();
const convertTimelineItem = this.convertTimelineItem(provider.id, commandConverter, timelineDisposables);
let disposable: IDisposable | undefined;
if (provider.onDidChange) {
disposable = provider.onDidChange(this.emitTimelineChangeEvent(provider.id), this);
}
return this.registerTimelineProviderCore({
...provider,
onDidChange: undefined,
async provideTimeline(uri: URI, token: CancellationToken) {
timelineDisposables.clear();
const results = await provider.provideTimeline(uri, token);
// Intentional == we don't know how a provider will respond
// eslint-disable-next-line eqeqeq
return results != null
? results.map(item => convertTimelineItem(item))
: [];
},
dispose() {
disposable?.dispose();
timelineDisposables.dispose();
}
});
}
private convertTimelineItem(source: string, commandConverter: CommandsConverter, disposables: DisposableStore): (item: vscode.TimelineItem) => TimelineItemWithSource {
return (item: vscode.TimelineItem) => {
const { iconPath, ...props } = item;
let icon;
let iconDark;
let themeIcon;
if (item.iconPath) {
if (iconPath instanceof ThemeIcon) {
themeIcon = { id: iconPath.id };
}
else if (URI.isUri(iconPath)) {
icon = iconPath;
iconDark = iconPath;
}
else {
({ light: icon, dark: iconDark } = iconPath as { light: URI; dark: URI });
}
}
return {
...props,
source: source,
command: item.command ? commandConverter.toInternal(item.command, disposables) : undefined,
icon: icon,
iconDark: iconDark,
themeIcon: themeIcon
};
};
}
private emitTimelineChangeEvent(id: string) {
return (e: vscode.TimelineChangeEvent) => {
this._proxy.$emitTimelineChangeEvent({ ...e, id: id });
};
}
private registerTimelineProviderCore(provider: TimelineProvider): IDisposable {
// console.log(`ExtHostTimeline#registerTimelineProvider: id=${provider.id}`);
const existing = this._providers.get(provider.id);
if (existing) {
throw new Error(`Timeline Provider ${provider.id} already exists.`);
}
this._proxy.$registerTimelineProvider({
id: provider.id,
label: provider.label
});
this._providers.set(provider.id, provider);
return toDisposable(() => {
this._providers.delete(provider.id);
this._proxy.$unregisterTimelineProvider(provider.id);
provider.dispose();
});
}
}

View File

@@ -5,7 +5,7 @@
import { ExtHostTunnelServiceShape } from 'vs/workbench/api/common/extHost.protocol';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import type * as vscode from 'vscode';
import * as vscode from 'vscode';
import { RemoteTunnel, TunnelOptions } from 'vs/platform/remote/common/tunnel';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Emitter } from 'vs/base/common/event';
@@ -33,7 +33,7 @@ export interface IExtHostTunnelService extends ExtHostTunnelServiceShape {
readonly _serviceBrand: undefined;
openTunnel(forward: TunnelOptions): Promise<vscode.Tunnel | undefined>;
getTunnels(): Promise<vscode.TunnelDescription[]>;
onDidTunnelsChange: vscode.Event<void>;
onDidChangeTunnels: vscode.Event<void>;
setTunnelExtensionFunctions(provider: vscode.RemoteAuthorityResolver | undefined): Promise<IDisposable>;
}
@@ -41,7 +41,7 @@ export const IExtHostTunnelService = createDecorator<IExtHostTunnelService>('IEx
export class ExtHostTunnelService implements IExtHostTunnelService {
_serviceBrand: undefined;
onDidTunnelsChange: vscode.Event<void> = (new Emitter<void>()).event;
onDidChangeTunnels: vscode.Event<void> = (new Emitter<void>()).event;
async openTunnel(forward: TunnelOptions): Promise<vscode.Tunnel | undefined> {
return undefined;

View File

@@ -2544,3 +2544,12 @@ export enum ColorThemeKind {
}
//#endregion Theming
//#region Timeline
@es5ClassCompat
export class TimelineItem implements vscode.TimelineItem {
constructor(public label: string, public timestamp: number) { }
}
//#endregion Timeline

View File

@@ -25,7 +25,7 @@ import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { Range, RelativePattern } from 'vs/workbench/api/common/extHostTypes';
import { ITextQueryBuilderOptions } from 'vs/workbench/contrib/search/common/queryBuilder';
import { IRawFileMatch2, resultIsMatch } from 'vs/workbench/services/search/common/search';
import type * as vscode from 'vscode';
import * as vscode from 'vscode';
import { ExtHostWorkspaceShape, IWorkspaceData, MainContext, MainThreadMessageServiceShape, MainThreadWorkspaceShape } from './extHost.protocol';
export interface IExtHostWorkspaceProvider {

View File

@@ -309,7 +309,7 @@ namespace schema {
type: 'string'
},
icon: {
description: localize('vscode.extension.contributes.commandType.icon', '(Optional) Icon which is used to represent the command in the UI. Either a file path or a themable configuration'),
description: localize('vscode.extension.contributes.commandType.icon', '(Optional) Icon which is used to represent the command in the UI. Either a file path, an object with file paths for dark and light themes, or a theme icon references, like `$(zap)`'),
anyOf: [{
type: 'string'
},
@@ -419,7 +419,7 @@ ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: schema.IUserFriendlyM
}
const menu = schema.parseMenuId(entry.key);
if (typeof menu !== 'number') {
if (typeof menu === 'undefined') {
collector.warn(localize('menuId.invalid', "`{0}` is not a valid menu identifier", entry.key));
return;
}

View File

@@ -39,8 +39,8 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe
private _forwardPortProvider: ((tunnelOptions: TunnelOptions) => Thenable<vscode.Tunnel> | undefined) | undefined;
private _showCandidatePort: (host: string, port: number, detail: string) => Thenable<boolean> = () => { return Promise.resolve(true); };
private _extensionTunnels: Map<string, Map<number, vscode.Tunnel>> = new Map();
private _onDidTunnelsChange: Emitter<void> = new Emitter<void>();
onDidTunnelsChange: vscode.Event<void> = this._onDidTunnelsChange.event;
private _onDidChangeTunnels: Emitter<void> = new Emitter<void>();
onDidChangeTunnels: vscode.Event<void> = this._onDidChangeTunnels.event;
constructor(
@IExtHostRpcService extHostRpc: IExtHostRpcService,
@@ -107,7 +107,7 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe
}
async $onDidTunnelsChange(): Promise<void> {
this._onDidTunnelsChange.fire();
this._onDidChangeTunnels.fire();
}
$forwardPort(tunnelOptions: TunnelOptions): Promise<TunnelDto> | undefined {