Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)

* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998

* fix pipelines

* fix strict-null-checks

* add missing files
This commit is contained in:
Anthony Dresser
2019-10-21 22:12:22 -07:00
committed by GitHub
parent 7c9be74970
commit 1e22f47304
913 changed files with 18898 additions and 16536 deletions

View File

@@ -12,6 +12,7 @@ import { IWebviewService, WebviewElement } from 'vs/workbench/contrib/webview/br
import { DisposableStore } from 'vs/base/common/lifecycle';
import { IActiveCodeEditor, IViewZone } from 'vs/editor/browser/editorBrowser';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { isEqual } from 'vs/base/common/resources';
// todo@joh move these things back into something like contrib/insets
class EditorWebviewZone implements IViewZone {
@@ -75,7 +76,7 @@ export class MainThreadEditorInsets implements MainThreadEditorInsetsShape {
id = id.substr(0, id.indexOf(',')); //todo@joh HACK
for (const candidate of this._editorService.listCodeEditors()) {
if (candidate.getId() === id && candidate.hasModel() && candidate.getModel()!.uri.toString() === URI.revive(uri).toString()) {
if (candidate.getId() === id && candidate.hasModel() && isEqual(candidate.getModel().uri, URI.revive(uri))) {
editor = candidate;
break;
}

View File

@@ -16,6 +16,7 @@ import { SnippetController2 } from 'vs/editor/contrib/snippet/snippetController2
import { IApplyEditsOptions, IEditorPropertiesChangeData, IResolvedTextEditorConfiguration, ITextEditorConfigurationUpdate, IUndoStopOptions, TextEditorRevealType } from 'vs/workbench/api/common/extHost.protocol';
import { IEditor } from 'vs/workbench/common/editor';
import { withNullAsUndefined } from 'vs/base/common/types';
import { equals } from 'vs/base/common/arrays';
export interface IFocusTracker {
onGainedFocus(): void;
@@ -124,28 +125,12 @@ export class MainThreadTextEditorProperties {
return null;
}
private static _selectionsEqual(a: Selection[], b: Selection[]): boolean {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (!a[i].equalsSelection(b[i])) {
return false;
}
}
return true;
private static _selectionsEqual(a: readonly Selection[], b: readonly Selection[]): boolean {
return equals(a, b, (aValue, bValue) => aValue.equalsSelection(bValue));
}
private static _rangesEqual(a: Range[], b: Range[]): boolean {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (!a[i].equalsRange(b[i])) {
return false;
}
}
return true;
private static _rangesEqual(a: readonly Range[], b: readonly Range[]): boolean {
return equals(a, b, (aValue, bValue) => aValue.equalsRange(bValue));
}
private static _optionsEqual(a: IResolvedTextEditorConfiguration, b: IResolvedTextEditorConfiguration): boolean {

View File

@@ -500,10 +500,10 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
if (!outgoing) {
return undefined; // {{SQL CARBON EDIT}} strict-null-check
}
return outgoing.map(([item, sourceRanges]): callh.OutgoingCall => {
return outgoing.map(([item, fromRanges]): callh.OutgoingCall => {
return {
target: MainThreadLanguageFeatures._reviveCallHierarchyItemDto(item),
sourceRanges
to: MainThreadLanguageFeatures._reviveCallHierarchyItemDto(item),
fromRanges
};
});
},
@@ -512,10 +512,10 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
if (!incoming) {
return undefined; // {{SQL CARBON EDIT}} strict-null-check
}
return incoming.map(([item, sourceRanges]): callh.IncomingCall => {
return incoming.map(([item, fromRanges]): callh.IncomingCall => {
return {
source: MainThreadLanguageFeatures._reviveCallHierarchyItemDto(item),
sourceRanges
from: MainThreadLanguageFeatures._reviveCallHierarchyItemDto(item),
fromRanges
};
});
}

View File

@@ -114,7 +114,7 @@ class MainThreadSCMProvider implements ISCMProvider {
get rootUri(): URI | undefined { return this._rootUri; }
get contextValue(): string { return this._contextValue; }
get commitTemplate(): string | undefined { return this.features.commitTemplate; }
get commitTemplate(): string { return this.features.commitTemplate || ''; }
get acceptInputCommand(): Command | undefined { return this.features.acceptInputCommand; }
get statusBarCommands(): Command[] | undefined { return this.features.statusBarCommands; }
get count(): number | undefined { return this.features.count; }

View File

@@ -75,7 +75,7 @@ class TrimWhitespaceParticipant implements ISaveParticipantParticipant {
// Nothing
}
async participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason; }): Promise<void> {
if (this.configurationService.getValue('files.trimTrailingWhitespace', { overrideIdentifier: model.textEditorModel.getLanguageIdentifier().language, resource: model.getResource() })) {
this.doTrimTrailingWhitespace(model.textEditorModel, env.reason === SaveReason.AUTO);
}
@@ -137,7 +137,7 @@ export class FinalNewLineParticipant implements ISaveParticipantParticipant {
// Nothing
}
async participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason; }): Promise<void> {
if (this.configurationService.getValue('files.insertFinalNewline', { overrideIdentifier: model.textEditorModel.getLanguageIdentifier().language, resource: model.getResource() })) {
this.doInsertFinalNewLine(model.textEditorModel);
}
@@ -171,7 +171,7 @@ export class TrimFinalNewLinesParticipant implements ISaveParticipantParticipant
// Nothing
}
async participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason; }): Promise<void> {
if (this.configurationService.getValue('files.trimFinalNewlines', { overrideIdentifier: model.textEditorModel.getLanguageIdentifier().language, resource: model.getResource() })) {
this.doTrimFinalNewLines(model.textEditorModel, env.reason === SaveReason.AUTO);
}
@@ -241,7 +241,7 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant {
// Nothing
}
async participate(editorModel: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(editorModel: IResolvedTextFileEditorModel, env: { reason: SaveReason; }): Promise<void> {
const model = editorModel.textEditorModel;
const overrides = { overrideIdentifier: model.getLanguageIdentifier().language, resource: model.uri };
@@ -275,7 +275,7 @@ class CodeActionOnSaveParticipant implements ISaveParticipant {
@IInstantiationService private readonly _instantiationService: IInstantiationService,
) { }
async participate(editorModel: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(editorModel: IResolvedTextFileEditorModel, env: { reason: SaveReason; }): Promise<void> {
if (env.reason === SaveReason.AUTO) {
return undefined;
}
@@ -358,7 +358,7 @@ class ExtHostSaveParticipant implements ISaveParticipantParticipant {
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostDocumentSaveParticipant);
}
async participate(editorModel: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(editorModel: IResolvedTextFileEditorModel, env: { reason: SaveReason; }): Promise<void> {
if (!shouldSynchronizeModel(editorModel.textEditorModel)) {
// the model never made it to the extension
@@ -369,10 +369,8 @@ class ExtHostSaveParticipant implements ISaveParticipantParticipant {
return new Promise<any>((resolve, reject) => {
setTimeout(() => reject(localize('timeout.onWillSave', "Aborted onWillSaveTextDocument-event after 1750ms")), 1750);
this._proxy.$participateInSave(editorModel.getResource(), env.reason).then(values => {
for (const success of values) {
if (!success) {
return Promise.reject(new Error('listener failed'));
}
if (!values.every(success => success)) {
return Promise.reject(new Error('listener failed'));
}
return undefined;
}).then(resolve, reject);
@@ -411,7 +409,7 @@ export class SaveParticipant implements ISaveParticipant {
this._saveParticipants.dispose();
}
async participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason; }): Promise<void> {
return this._progressService.withProgress({ location: ProgressLocation.Window }, progress => {
progress.report({ message: localize('saveParticipants', "Running Save Participants...") });
const promiseFactory = this._saveParticipants.getValue().map(p => () => {

View File

@@ -24,9 +24,13 @@ export class MainThreadStatusBar implements MainThreadStatusBarShape {
this.entries.clear();
}
$setEntry(id: number, statusId: string, statusName: string, text: string, tooltip: string, command: string, color: string | ThemeColor, alignment: MainThreadStatusBarAlignment, priority: number): void {
$setEntry(id: number, statusId: string, statusName: string, text: string, tooltip: string | undefined, command: string | undefined, color: string | ThemeColor | undefined, alignment: MainThreadStatusBarAlignment, priority: number | undefined): void {
const entry: IStatusbarEntry = { text, tooltip, command, color };
if (typeof priority === 'undefined') {
priority = 0;
}
// Reset existing entry if alignment or priority changed
let existingEntry = this.entries.get(id);
if (existingEntry && (existingEntry.alignment !== alignment || existingEntry.priority !== priority)) {

View File

@@ -29,7 +29,7 @@ import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { ExtHostContext, MainThreadTaskShape, ExtHostTaskShape, MainContext, IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
import {
TaskDefinitionDTO, TaskExecutionDTO, ProcessExecutionOptionsDTO, TaskPresentationOptionsDTO,
ProcessExecutionDTO, ShellExecutionDTO, ShellExecutionOptionsDTO, CustomExecution2DTO, TaskDTO, TaskSourceDTO, TaskHandleDTO, TaskFilterDTO, TaskProcessStartedDTO, TaskProcessEndedDTO, TaskSystemInfoDTO,
ProcessExecutionDTO, ShellExecutionDTO, ShellExecutionOptionsDTO, CustomExecutionDTO, TaskDTO, TaskSourceDTO, TaskHandleDTO, TaskFilterDTO, TaskProcessStartedDTO, TaskProcessEndedDTO, TaskSystemInfoDTO,
RunOptionsDTO
} from 'vs/workbench/api/common/shared/tasks';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
@@ -131,7 +131,7 @@ namespace ProcessExecutionOptionsDTO {
}
namespace ProcessExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CustomExecution2DTO): value is ProcessExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CustomExecutionDTO): value is ProcessExecutionDTO {
const candidate = value as ProcessExecutionDTO;
return candidate && !!candidate.process;
}
@@ -199,7 +199,7 @@ namespace ShellExecutionOptionsDTO {
}
namespace ShellExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CustomExecution2DTO): value is ShellExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CustomExecutionDTO): value is ShellExecutionDTO {
const candidate = value as ShellExecutionDTO;
return candidate && (!!candidate.commandLine || !!candidate.command);
}
@@ -230,21 +230,21 @@ namespace ShellExecutionDTO {
}
}
namespace CustomExecution2DTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CustomExecution2DTO): value is CustomExecution2DTO {
const candidate = value as CustomExecution2DTO;
return candidate && candidate.customExecution === 'customExecution2';
namespace CustomExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO | CustomExecutionDTO): value is CustomExecutionDTO {
const candidate = value as CustomExecutionDTO;
return candidate && candidate.customExecution === 'customExecution';
}
export function from(value: CommandConfiguration): CustomExecution2DTO {
export function from(value: CommandConfiguration): CustomExecutionDTO {
return {
customExecution: 'customExecution2'
customExecution: 'customExecution'
};
}
export function to(value: CustomExecution2DTO): CommandConfiguration {
export function to(value: CustomExecutionDTO): CommandConfiguration {
return {
runtime: RuntimeType.CustomExecution2,
runtime: RuntimeType.CustomExecution,
presentation: undefined
};
}
@@ -264,7 +264,7 @@ namespace TaskSourceDTO {
}
} else if (value.kind === TaskSourceKind.Workspace) {
result.extensionId = '$core';
result.scope = value.config.workspaceFolder.uri;
result.scope = value.config.workspaceFolder ? value.config.workspaceFolder.uri : TaskScope.Global;
}
return result;
}
@@ -311,7 +311,7 @@ namespace TaskDTO {
const result: TaskDTO = {
_id: task._id,
name: task.configurationProperties.name,
definition: TaskDefinitionDTO.from(task.getDefinition()),
definition: TaskDefinitionDTO.from(task.getDefinition(true)),
source: TaskSourceDTO.from(task._source),
execution: undefined,
presentationOptions: !ConfiguringTask.is(task) && task.command ? TaskPresentationOptionsDTO.from(task.command.presentation) : undefined,
@@ -351,8 +351,8 @@ namespace TaskDTO {
command = ShellExecutionDTO.to(task.execution);
} else if (ProcessExecutionDTO.is(task.execution)) {
command = ProcessExecutionDTO.to(task.execution);
} else if (CustomExecution2DTO.is(task.execution)) {
command = CustomExecution2DTO.to(task.execution);
} else if (CustomExecutionDTO.is(task.execution)) {
command = CustomExecutionDTO.to(task.execution);
}
}

View File

@@ -5,7 +5,7 @@
import { ExtHostContext, IExtHostContext, MainContext, MainThreadUrlsShape, ExtHostUrlsShape } from 'vs/workbench/api/common/extHost.protocol';
import { extHostNamedCustomer } from '../common/extHostCustomers';
import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
import { IURLService, IURLHandler, IOpenURLOptions } from 'vs/platform/url/common/url';
import { URI, UriComponents } from 'vs/base/common/uri';
import { IDisposable } from 'vs/base/common/lifecycle';
import { IExtensionUrlHandler } from 'vs/workbench/services/extensions/browser/extensionUrlHandler';
@@ -19,7 +19,7 @@ class ExtensionUrlHandler implements IURLHandler {
readonly extensionId: ExtensionIdentifier
) { }
handleURL(uri: URI): Promise<boolean> {
handleURL(uri: URI, options?: IOpenURLOptions): Promise<boolean> {
if (!ExtensionIdentifier.equals(this.extensionId, uri.authority)) {
return Promise.resolve(false);
}

View File

@@ -5,6 +5,7 @@
import { onUnexpectedError } from 'vs/base/common/errors';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { Schemas } from 'vs/base/common/network';
import { isWeb } from 'vs/base/common/platform';
import { startsWith } from 'vs/base/common/strings';
import { URI, UriComponents } from 'vs/base/common/uri';
@@ -14,13 +15,14 @@ import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IProductService } from 'vs/platform/product/common/productService';
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 * as extHostProtocol from 'vs/workbench/api/common/extHost.protocol';
import { editorGroupToViewColumn, EditorViewColumn, viewColumnToEditorGroup } from 'vs/workbench/api/common/shared/editor';
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 { WebviewExtensionDescription } from 'vs/workbench/contrib/webview/browser/webview';
import { WebviewInput } from 'vs/workbench/contrib/webview/browser/webviewEditorInput';
import { ICreateWebViewShowOptions, IWebviewEditorService, WebviewInputOptions } from 'vs/workbench/contrib/webview/browser/webviewEditorService';
import { ICreateWebViewShowOptions, IWebviewWorkbenchService, WebviewInputOptions } from 'vs/workbench/contrib/webview/browser/webviewWorkbenchService';
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';
@@ -29,7 +31,7 @@ import { extHostNamedCustomer } from '../common/extHostCustomers';
/**
* Bi-directional map between webview handles and inputs.
*/
class WebviewHandleStore {
class WebviewInputStore {
private readonly _handlesToInputs = new Map<string, WebviewInput>();
private readonly _inputsToHandles = new Map<WebviewInput, string>();
@@ -59,47 +61,66 @@ class WebviewHandleStore {
}
}
@extHostNamedCustomer(MainContext.MainThreadWebviews)
export class MainThreadWebviews extends Disposable implements MainThreadWebviewsShape {
class WebviewViewTypeTransformer {
public constructor(
public readonly prefix: string,
) { }
public fromExternal(viewType: string): string {
return this.prefix + viewType;
}
public toExternal(viewType: string): string | undefined {
return startsWith(viewType, this.prefix)
? viewType.substr(this.prefix.length)
: undefined;
}
}
const webviewPanelViewType = new WebviewViewTypeTransformer('mainThreadWebview-');
@extHostNamedCustomer(extHostProtocol.MainContext.MainThreadWebviews)
export class MainThreadWebviews extends Disposable implements extHostProtocol.MainThreadWebviewsShape {
private static readonly standardSupportedLinkSchemes = new Set([
'http',
'https',
'mailto',
'vscode',
Schemas.http,
Schemas.https,
Schemas.mailto,
Schemas.vscode,
'vscode-insider',
]);
private readonly _proxy: ExtHostWebviewsShape;
private readonly _webviewEditorInputs = new WebviewHandleStore();
private readonly _proxy: extHostProtocol.ExtHostWebviewsShape;
private readonly _webviewInputs = new WebviewInputStore();
private readonly _revivers = new Map<string, IDisposable>();
private readonly _editorProviders = new Map<string, IDisposable>();
constructor(
context: IExtHostContext,
context: extHostProtocol.IExtHostContext,
@IExtensionService extensionService: IExtensionService,
@IEditorGroupsService private readonly _editorGroupService: IEditorGroupsService,
@IEditorService private readonly _editorService: IEditorService,
@IWebviewEditorService private readonly _webviewEditorService: IWebviewEditorService,
@IOpenerService private readonly _openerService: IOpenerService,
@ITelemetryService private readonly _telemetryService: ITelemetryService,
@IProductService private readonly _productService: IProductService,
@ITelemetryService private readonly _telemetryService: ITelemetryService,
@IWebviewWorkbenchService private readonly _webviewWorkbenchService: IWebviewWorkbenchService,
) {
super();
this._proxy = context.getProxy(ExtHostContext.ExtHostWebviews);
this._proxy = context.getProxy(extHostProtocol.ExtHostContext.ExtHostWebviews);
this._register(_editorService.onDidActiveEditorChange(this.updateWebviewViewStates, this));
this._register(_editorService.onDidVisibleEditorsChange(this.updateWebviewViewStates, this));
// 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({
this._register(_webviewWorkbenchService.registerResolver({
canResolve: (webview: WebviewInput) => {
if (webview.getTypeId() === CustomFileEditorInput.typeId) {
if (webview instanceof CustomFileEditorInput) {
extensionService.activateByEvent(`onWebviewEditor:${webview.viewType}`);
return false;
}
const viewType = this.fromInternalWebviewViewType(webview.viewType);
const viewType = webviewPanelViewType.toExternal(webview.viewType);
if (typeof viewType === 'string') {
extensionService.activateByEvent(`onWebviewPanel:${viewType}`);
}
@@ -110,13 +131,12 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
}
public $createWebviewPanel(
handle: WebviewPanelHandle,
extensionData: extHostProtocol.WebviewExtensionDescription,
handle: extHostProtocol.WebviewPanelHandle,
viewType: string,
title: string,
showOptions: { viewColumn?: EditorViewColumn, preserveFocus?: boolean },
options: WebviewInputOptions,
extensionId: ExtensionIdentifier,
extensionLocation: UriComponents
showOptions: { viewColumn?: EditorViewColumn, preserveFocus?: boolean; },
options: WebviewInputOptions
): void {
const mainThreadShowOptions: ICreateWebViewShowOptions = Object.create(null);
if (showOptions) {
@@ -124,73 +144,66 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
mainThreadShowOptions.group = viewColumnToEditorGroup(this._editorGroupService, showOptions.viewColumn);
}
const webview = this._webviewEditorService.createWebview(handle, this.getInternalWebviewViewType(viewType), title, mainThreadShowOptions, reviveWebviewOptions(options), {
location: URI.revive(extensionLocation),
id: extensionId
});
const extension = reviveWebviewExtension(extensionData);
const webview = this._webviewWorkbenchService.createWebview(handle, webviewPanelViewType.fromExternal(viewType), title, mainThreadShowOptions, reviveWebviewOptions(options), extension);
this.hookupWebviewEventDelegate(handle, webview);
this._webviewEditorInputs.add(handle, webview);
this._webviewInputs.add(handle, webview);
/* __GDPR__
"webviews:createWebviewPanel" : {
"extensionId" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
this._telemetryService.publicLog('webviews:createWebviewPanel', { extensionId: extensionId.value });
this._telemetryService.publicLog('webviews:createWebviewPanel', { extensionId: extension.id.value });
}
public $disposeWebview(handle: WebviewPanelHandle): void {
const webview = this.getWebviewEditorInput(handle);
public $disposeWebview(handle: extHostProtocol.WebviewPanelHandle): void {
const webview = this.getWebviewInput(handle);
webview.dispose();
}
public $setTitle(handle: WebviewPanelHandle, value: string): void {
const webview = this.getWebviewEditorInput(handle);
public $setTitle(handle: extHostProtocol.WebviewPanelHandle, value: string): void {
const webview = this.getWebviewInput(handle);
webview.setName(value);
}
public $setState(handle: WebviewPanelHandle, state: modes.WebviewContentState): void {
const webview = this.getWebviewEditorInput(handle);
public $setState(handle: extHostProtocol.WebviewPanelHandle, state: modes.WebviewContentState): void {
const webview = this.getWebviewInput(handle);
if (webview instanceof CustomFileEditorInput) {
webview.setState(state);
}
}
public $setIconPath(handle: WebviewPanelHandle, value: { light: UriComponents, dark: UriComponents } | undefined): void {
const webview = this.getWebviewEditorInput(handle);
public $setIconPath(handle: extHostProtocol.WebviewPanelHandle, value: { light: UriComponents, dark: UriComponents; } | undefined): void {
const webview = this.getWebviewInput(handle);
webview.iconPath = reviveWebviewIcon(value);
}
public $setHtml(handle: WebviewPanelHandle, value: string): void {
const webview = this.getWebviewEditorInput(handle);
public $setHtml(handle: extHostProtocol.WebviewPanelHandle, value: string): void {
const webview = this.getWebviewInput(handle);
webview.webview.html = value;
}
public $setOptions(handle: WebviewPanelHandle, options: modes.IWebviewOptions): void {
const webview = this.getWebviewEditorInput(handle);
webview.webview.contentOptions = reviveWebviewOptions(options as any /*todo@mat */);
public $setOptions(handle: extHostProtocol.WebviewPanelHandle, options: modes.IWebviewOptions): void {
const webview = this.getWebviewInput(handle);
webview.webview.contentOptions = reviveWebviewOptions(options);
}
public $setExtension(handle: WebviewPanelHandle, extensionId: ExtensionIdentifier, extensionLocation: UriComponents): void {
const webview = this.getWebviewEditorInput(handle);
webview.webview.extension = { id: extensionId, location: URI.revive(extensionLocation) };
}
public $reveal(handle: WebviewPanelHandle, showOptions: WebviewPanelShowOptions): void {
const webview = this.getWebviewEditorInput(handle);
public $reveal(handle: extHostProtocol.WebviewPanelHandle, showOptions: extHostProtocol.WebviewPanelShowOptions): void {
const webview = this.getWebviewInput(handle);
if (webview.isDisposed()) {
return;
}
const targetGroup = this._editorGroupService.getGroup(viewColumnToEditorGroup(this._editorGroupService, showOptions.viewColumn)) || this._editorGroupService.getGroup(webview.group || 0);
if (targetGroup) {
this._webviewEditorService.revealWebview(webview, targetGroup, !!showOptions.preserveFocus);
this._webviewWorkbenchService.revealWebview(webview, targetGroup, !!showOptions.preserveFocus);
}
}
public async $postMessage(handle: WebviewPanelHandle, message: any): Promise<boolean> {
const webview = this.getWebviewEditorInput(handle);
public async $postMessage(handle: extHostProtocol.WebviewPanelHandle, message: any): Promise<boolean> {
const webview = this.getWebviewInput(handle);
webview.webview.sendMessage(message);
return true;
}
@@ -200,35 +213,35 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
throw new Error(`Reviver for ${viewType} already registered`);
}
this._revivers.set(viewType, this._webviewEditorService.registerResolver({
canResolve: (webviewEditorInput) => {
return webviewEditorInput.viewType === this.getInternalWebviewViewType(viewType);
this._revivers.set(viewType, this._webviewWorkbenchService.registerResolver({
canResolve: (webviewInput) => {
return webviewInput.viewType === webviewPanelViewType.fromExternal(viewType);
},
resolveWebview: async (webviewEditorInput): Promise<void> => {
const viewType = this.fromInternalWebviewViewType(webviewEditorInput.viewType);
resolveWebview: async (webviewInput): Promise<void> => {
const viewType = webviewPanelViewType.toExternal(webviewInput.viewType);
if (!viewType) {
webviewEditorInput.webview.html = MainThreadWebviews.getDeserializationFailedContents(webviewEditorInput.viewType);
webviewInput.webview.html = MainThreadWebviews.getDeserializationFailedContents(webviewInput.viewType);
return;
}
const handle = webviewEditorInput.id;
this._webviewEditorInputs.add(handle, webviewEditorInput);
this.hookupWebviewEventDelegate(handle, webviewEditorInput);
const handle = webviewInput.id;
this._webviewInputs.add(handle, webviewInput);
this.hookupWebviewEventDelegate(handle, webviewInput);
let state = undefined;
if (webviewEditorInput.webview.state) {
if (webviewInput.webview.state) {
try {
state = JSON.parse(webviewEditorInput.webview.state);
state = JSON.parse(webviewInput.webview.state);
} catch {
// noop
}
}
try {
await this._proxy.$deserializeWebviewPanel(handle, viewType, webviewEditorInput.getTitle(), state, editorGroupToViewColumn(this._editorGroupService, webviewEditorInput.group || 0), webviewEditorInput.webview.options);
await this._proxy.$deserializeWebviewPanel(handle, viewType, webviewInput.getTitle(), state, editorGroupToViewColumn(this._editorGroupService, webviewInput.group || 0), webviewInput.webview.options);
} catch (error) {
onUnexpectedError(error);
webviewEditorInput.webview.html = MainThreadWebviews.getDeserializationFailedContents(viewType);
webviewInput.webview.html = MainThreadWebviews.getDeserializationFailedContents(viewType);
}
}
}));
@@ -244,39 +257,43 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
this._revivers.delete(viewType);
}
public $registerEditorProvider(viewType: string): void {
public $registerEditorProvider(extensionData: extHostProtocol.WebviewExtensionDescription, viewType: string, options: modes.IWebviewPanelOptions): void {
if (this._editorProviders.has(viewType)) {
throw new Error(`Provider for ${viewType} already registered`);
}
this._editorProviders.set(viewType, this._webviewEditorService.registerResolver({
canResolve: (webviewEditorInput) => {
return webviewEditorInput.getTypeId() !== WebviewInput.typeId && webviewEditorInput.viewType === viewType;
},
resolveWebview: async (webview) => {
const handle = webview.id;
this._webviewEditorInputs.add(handle, webview);
this.hookupWebviewEventDelegate(handle, webview);
const extension = reviveWebviewExtension(extensionData);
if (webview instanceof CustomFileEditorInput) {
webview.onWillSave(e => {
this._editorProviders.set(viewType, this._webviewWorkbenchService.registerResolver({
canResolve: (webviewInput) => {
return webviewInput instanceof CustomFileEditorInput && webviewInput.viewType === viewType;
},
resolveWebview: async (webviewInput) => {
const handle = webviewInput.id;
this._webviewInputs.add(handle, webviewInput);
this.hookupWebviewEventDelegate(handle, webviewInput);
webviewInput.webview.options = options;
webviewInput.webview.extension = extension;
if (webviewInput instanceof CustomFileEditorInput) {
webviewInput.onWillSave(e => {
e.waitUntil(this._proxy.$save(handle));
});
}
try {
await this._proxy.$resolveWebviewEditor(
webview.getResource(),
webviewInput.getResource(),
handle,
viewType,
webview.getTitle(),
webview.webview.state,
editorGroupToViewColumn(this._editorGroupService, webview.group || 0),
webview.webview.options
webviewInput.getTitle(),
editorGroupToViewColumn(this._editorGroupService, webviewInput.group || 0),
webviewInput.webview.options
);
} catch (error) {
onUnexpectedError(error);
webview.webview.html = MainThreadWebviews.getDeserializationFailedContents(viewType);
webviewInput.webview.html = MainThreadWebviews.getDeserializationFailedContents(viewType);
}
}
}));
@@ -292,42 +309,24 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
this._editorProviders.delete(viewType);
}
private getInternalWebviewViewType(viewType: string): string {
return `mainThreadWebview-${viewType}`;
}
private fromInternalWebviewViewType(viewType: string): string | undefined {
if (!startsWith(viewType, 'mainThreadWebview-')) {
return undefined;
}
return viewType.replace(/^mainThreadWebview-/, '');
}
private hookupWebviewEventDelegate(handle: WebviewPanelHandle, input: WebviewInput) {
private hookupWebviewEventDelegate(handle: extHostProtocol.WebviewPanelHandle, input: WebviewInput) {
input.webview.onDidClickLink((uri: URI) => this.onDidClickLink(handle, uri));
input.webview.onMessage((message: any) => this._proxy.$onMessage(handle, message));
input.onDispose(() => {
this._proxy.$onDidDisposeWebviewPanel(handle).finally(() => {
this._webviewEditorInputs.delete(handle);
this._webviewInputs.delete(handle);
});
});
input.webview.onDidUpdateState((newState: any) => {
const webview = this.tryGetWebviewEditorInput(handle);
if (!webview || webview.isDisposed()) {
return;
}
webview.webview.state = newState;
});
input.webview.onMissingCsp((extension: ExtensionIdentifier) => this._proxy.$onMissingCsp(handle, extension.value));
}
private updateWebviewViewStates() {
if (!this._webviewEditorInputs.size) {
if (!this._webviewInputs.size) {
return;
}
const activeInput = this._editorService.activeControl && this._editorService.activeControl.input;
const viewStates: WebviewPanelViewStateData = {};
const viewStates: extHostProtocol.WebviewPanelViewStateData = {};
const updateViewStatesForInput = (group: IEditorGroup, topLevelInput: IEditorInput, editorInput: IEditorInput) => {
if (!(editorInput instanceof WebviewInput)) {
@@ -336,11 +335,11 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
editorInput.updateGroup(group.id);
const handle = this._webviewEditorInputs.getHandleForInput(editorInput);
const handle = this._webviewInputs.getHandleForInput(editorInput);
if (handle) {
viewStates[handle] = {
visible: topLevelInput.matches(group.activeEditor),
active: topLevelInput.matches(activeInput),
visible: topLevelInput === group.activeEditor,
active: topLevelInput === activeInput,
position: editorGroupToViewColumn(this._editorGroupService, group.id),
};
}
@@ -362,10 +361,10 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
}
}
private onDidClickLink(handle: WebviewPanelHandle, link: URI): void {
const webview = this.getWebviewEditorInput(handle);
private onDidClickLink(handle: extHostProtocol.WebviewPanelHandle, link: URI): void {
const webview = this.getWebviewInput(handle);
if (this.isSupportedLink(webview, link)) {
this._openerService.open(link);
this._openerService.open(link, { fromUserGesture: true });
}
}
@@ -376,19 +375,19 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
if (!isWeb && this._productService.urlProtocol === link.scheme) {
return true;
}
return !!webview.webview.contentOptions.enableCommandUris && link.scheme === 'command';
return !!webview.webview.contentOptions.enableCommandUris && link.scheme === Schemas.command;
}
private getWebviewEditorInput(handle: WebviewPanelHandle): WebviewInput {
const webview = this.tryGetWebviewEditorInput(handle);
private getWebviewInput(handle: extHostProtocol.WebviewPanelHandle): WebviewInput {
const webview = this.tryGetWebviewInput(handle);
if (!webview) {
throw new Error('Unknown webview handle:' + handle);
}
return webview;
}
private tryGetWebviewEditorInput(handle: WebviewPanelHandle): WebviewInput | undefined {
return this._webviewEditorInputs.getInputForHandle(handle);
private tryGetWebviewInput(handle: extHostProtocol.WebviewPanelHandle): WebviewInput | undefined {
return this._webviewInputs.getInputForHandle(handle);
}
private static getDeserializationFailedContents(viewType: string) {
@@ -403,6 +402,10 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
}
}
function reviveWebviewExtension(extensionData: extHostProtocol.WebviewExtensionDescription): WebviewExtensionDescription {
return { id: extensionData.id, location: URI.revive(extensionData.location) };
}
function reviveWebviewOptions(options: modes.IWebviewOptions): WebviewInputOptions {
return {
...options,
@@ -411,10 +414,9 @@ function reviveWebviewOptions(options: modes.IWebviewOptions): WebviewInputOptio
};
}
function reviveWebviewIcon(
value: { light: UriComponents, dark: UriComponents } | undefined
): { light: URI, dark: URI } | undefined {
value: { light: UriComponents, dark: UriComponents; } | undefined
): { light: URI, dark: URI; } | undefined {
if (!value) {
return undefined;
}

View File

@@ -1,10 +1,3 @@
<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="Canvas" fill="none">
<g id="beaker">
<g id="Shape">
<path fill-rule="evenodd" clip-rule="evenodd" d="M 20.7596 21.885L 15.6896 10.5L 15.6896 4.5L 17.1896 4.5L 17.1896 3L 3.68959 3L 3.68959 4.5L 5.18959 4.5L 5.18959 10.5L 0.134588 21.885C -0.315412 22.875 0.419588 24 1.49959 24L 19.4096 24C 20.4896 24 21.2096 22.875 20.7746 21.885L 20.7596 21.885ZM 4.81458 15L 6.68958 10.5L 6.68958 4.5L 14.1896 4.5L 14.1896 10.5L 16.0646 15L 4.81458 15ZM 11.1896 12L 12.6896 12L 12.6896 13.5L 11.1896 13.5L 11.1896 12ZM 9.68958 10.5L 8.18958 10.5L 8.18958 9L 9.68958 9L 9.68958 10.5ZM 9.68958 6L 11.1896 6L 11.1896 7.5L 9.68958 7.5L 9.68958 6ZM 9.68958 1.5L 8.18958 1.5L 8.18958 0L 9.68958 0L 9.68958 1.5Z" transform="translate(0.810059 0)" fill="white"/>
</g>
</g>
</g>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M20.8394 20.337L14.9999 9.009V3.009H16.4999V1.509H14.9909V1.5L14.3069 1.5075H7.4999V3H8.9999V8.928L3.1589 20.3415C3.04535 20.57 2.99197 20.8237 3.00381 21.0786C3.01566 21.3335 3.09234 21.5812 3.22659 21.7982C3.36085 22.0152 3.54825 22.1944 3.77106 22.3187C3.99387 22.4431 4.24473 22.5086 4.4999 22.509H19.4999C19.7556 22.5087 20.0069 22.4431 20.2301 22.3184C20.4533 22.1937 20.6409 22.014 20.7751 21.7964C20.9093 21.5788 20.9856 21.3305 20.9969 21.075C21.0082 20.8196 20.9539 20.5656 20.8394 20.337ZM10.3394 9.612L10.4999 9.2895V3.054L13.4999 3.018V9.0105V9.3735L13.6664 9.696L16.4054 15.009H7.5734L10.3394 9.612ZM4.4999 21.0255L6.8114 16.509H17.1839L19.5044 21.009L4.4999 21.0255Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 913 B

After

Width:  |  Height:  |  Size: 810 B

View File

@@ -39,7 +39,7 @@ interface IOpenFolderAPICommandOptions {
}
export class OpenFolderAPICommand {
public static ID = 'vscode.openFolder';
public static readonly ID = 'vscode.openFolder';
public static execute(executor: ICommandsExecutor, uri?: URI, forceNewWindow?: boolean): Promise<any>;
public static execute(executor: ICommandsExecutor, uri?: URI, options?: IOpenFolderAPICommandOptions): Promise<any>;
public static execute(executor: ICommandsExecutor, uri?: URI, arg: boolean | IOpenFolderAPICommandOptions = {}): Promise<any> {
@@ -73,7 +73,7 @@ interface INewWindowAPICommandOptions {
}
export class NewWindowAPICommand {
public static ID = 'vscode.newWindow';
public static readonly ID = 'vscode.newWindow';
public static execute(executor: ICommandsExecutor, options?: INewWindowAPICommandOptions): Promise<any> {
const commandOptions: IOpenEmptyWindowOptions = {
forceReuseWindow: options && options.reuseWindow,
@@ -94,7 +94,7 @@ CommandsRegistry.registerCommand({
});
export class DiffAPICommand {
public static ID = 'vscode.diff';
public static readonly ID = 'vscode.diff';
public static execute(executor: ICommandsExecutor, left: URI, right: URI, label: string, options?: vscode.TextDocumentShowOptions): Promise<any> {
return executor.executeCommand('_workbench.diff', [
left, right,
@@ -108,7 +108,7 @@ export class DiffAPICommand {
CommandsRegistry.registerCommand(DiffAPICommand.ID, adjustHandler(DiffAPICommand.execute));
export class OpenAPICommand {
public static ID = 'vscode.open';
public static readonly ID = 'vscode.open';
public static execute(executor: ICommandsExecutor, resource: URI, columnOrOptions?: vscode.ViewColumn | vscode.TextDocumentShowOptions, label?: string): Promise<any> {
let options: ITextEditorOptions | undefined;
let position: EditorViewColumn | undefined;
@@ -138,7 +138,7 @@ CommandsRegistry.registerCommand('_workbench.removeFromRecentlyOpened', function
});
export class RemoveFromRecentlyOpenedAPICommand {
public static ID = 'vscode.removeFromRecentlyOpened';
public static readonly ID = 'vscode.removeFromRecentlyOpened';
public static execute(executor: ICommandsExecutor, path: string | URI): Promise<any> {
if (typeof path === 'string') {
path = path.match(/^[^:/?#]+:\/\//) ? URI.parse(path) : URI.file(path);
@@ -151,7 +151,7 @@ export class RemoveFromRecentlyOpenedAPICommand {
CommandsRegistry.registerCommand(RemoveFromRecentlyOpenedAPICommand.ID, adjustHandler(RemoveFromRecentlyOpenedAPICommand.execute));
export class OpenIssueReporter {
public static ID = 'vscode.openIssueReporter';
public static readonly ID = 'vscode.openIssueReporter';
public static execute(executor: ICommandsExecutor, extensionId: string): Promise<void> {
return executor.executeCommand('workbench.action.openIssueReporter', [extensionId]);
}
@@ -185,7 +185,7 @@ CommandsRegistry.registerCommand('_workbench.getRecentlyOpened', async function
});
export class SetEditorLayoutAPICommand {
public static ID = 'vscode.setEditorLayout';
public static readonly ID = 'vscode.setEditorLayout';
public static execute(executor: ICommandsExecutor, layout: EditorGroupLayout): Promise<any> {
return executor.executeCommand('layoutEditorGroups', layout);
}

View File

@@ -10,7 +10,7 @@ import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { ExtensionsRegistry, IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry';
import { IConfigurationNode, IConfigurationRegistry, Extensions, editorConfigurationSchemaId, IDefaultConfigurationExtension, validateProperty, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
import { IJSONContributionRegistry, Extensions as JSONExtensions } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
import { workspaceSettingsSchemaId, launchSchemaId } from 'vs/workbench/services/configuration/common/configuration';
import { workspaceSettingsSchemaId, launchSchemaId, tasksSchemaId } from 'vs/workbench/services/configuration/common/configuration';
import { isObject } from 'vs/base/common/types';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
@@ -296,6 +296,12 @@ jsonRegistry.registerSchema('vscode://schemas/workspaceConfig', {
description: nls.localize('workspaceConfig.launch.description', "Workspace launch configurations"),
$ref: launchSchemaId
},
'tasks': {
type: 'object',
default: { version: '2.0.0', tasks: [] },
description: nls.localize('workspaceConfig.tasks.description', "Workspace task configurations"),
$ref: tasksSchemaId
},
'extensions': {
type: 'object',
default: {},

View File

@@ -105,7 +105,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const extHostOutputService = rpcProtocol.set(ExtHostContext.ExtHostOutputService, accessor.get(IExtHostOutputService));
// manually create and register addressable instances
const extHostWebviews = rpcProtocol.set(ExtHostContext.ExtHostWebviews, new ExtHostWebviews(rpcProtocol, initData.environment));
const extHostWebviews = rpcProtocol.set(ExtHostContext.ExtHostWebviews, new ExtHostWebviews(rpcProtocol, initData.environment, extHostWorkspace));
const extHostUrls = rpcProtocol.set(ExtHostContext.ExtHostUrls, new ExtHostUrls(rpcProtocol));
const extHostDocuments = rpcProtocol.set(ExtHostContext.ExtHostDocuments, new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors));
const extHostDocumentContentProviders = rpcProtocol.set(ExtHostContext.ExtHostDocumentContentProviders, new ExtHostDocumentContentProvider(rpcProtocol, extHostDocumentsAndEditors, extHostLogService));
@@ -250,14 +250,12 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostWindow.openUri(uri, { allowTunneling: !!initData.remote.isRemote });
},
asExternalUri(uri: URI) {
checkProposedApiEnabled(extension);
return extHostWindow.asExternalUri(uri, { allowTunneling: !!initData.remote.isRemote });
},
get remoteName() {
return getRemoteName(initData.remote.authority);
},
get uiKind() {
checkProposedApiEnabled(extension);
return initData.uiKind;
}
};
@@ -533,11 +531,11 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostTreeViews.createTreeView(viewId, options, extension);
},
registerWebviewPanelSerializer: (viewType: string, serializer: vscode.WebviewPanelSerializer) => {
return extHostWebviews.registerWebviewPanelSerializer(viewType, serializer);
return extHostWebviews.registerWebviewPanelSerializer(extension, viewType, serializer);
},
registerWebviewEditorProvider: (viewType: string, provider: vscode.WebviewEditorProvider) => {
registerWebviewEditorProvider: (viewType: string, provider: vscode.WebviewEditorProvider, options?: vscode.WebviewPanelOptions) => {
checkProposedApiEnabled(extension);
return extHostWebviews.registerWebviewEditorProvider(extension, viewType, provider);
return extHostWebviews.registerWebviewEditorProvider(extension, viewType, provider, options);
},
registerDecorationProvider(provider: vscode.DecorationProvider) {
checkProposedApiEnabled(extension);
@@ -635,7 +633,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const options = uriOrFileNameOrOptions as { language?: string; content?: string; };
if (typeof uriOrFileNameOrOptions === 'string') {
uriPromise = Promise.resolve(URI.file(uriOrFileNameOrOptions));
} else if (uriOrFileNameOrOptions instanceof URI) {
} else if (URI.isUri(uriOrFileNameOrOptions)) {
uriPromise = Promise.resolve(uriOrFileNameOrOptions);
} else if (!options || typeof options === 'object') {
uriPromise = extHostDocuments.createDocumentData(options);
@@ -850,7 +848,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
EndOfLine: extHostTypes.EndOfLine,
EventEmitter: Emitter,
ExtensionKind: extHostTypes.ExtensionKind,
CustomExecution2: extHostTypes.CustomExecution2,
CustomExecution: extHostTypes.CustomExecution,
FileChangeType: extHostTypes.FileChangeType,
FileSystemError: extHostTypes.FileSystemError,
FileType: files.FileType,

View File

@@ -509,7 +509,7 @@ export interface MainThreadQuickOpenShape extends IDisposable {
}
export interface MainThreadStatusBarShape extends IDisposable {
$setEntry(id: number, statusId: string, statusName: string, text: string, tooltip: string, command: string, color: string | ThemeColor, alignment: statusbar.StatusbarAlignment, priority: number | undefined): void;
$setEntry(id: number, statusId: string, statusName: string, text: string, tooltip: string | undefined, command: string | undefined, color: string | ThemeColor | undefined, alignment: statusbar.StatusbarAlignment, priority: number | undefined): void;
$dispose(id: number): void;
}
@@ -544,8 +544,13 @@ export interface WebviewPanelShowOptions {
readonly preserveFocus?: boolean;
}
export interface WebviewExtensionDescription {
readonly id: ExtensionIdentifier;
readonly location: UriComponents;
}
export interface MainThreadWebviewsShape extends IDisposable {
$createWebviewPanel(handle: WebviewPanelHandle, viewType: string, title: string, showOptions: WebviewPanelShowOptions, options: modes.IWebviewPanelOptions & modes.IWebviewOptions, extensionId: ExtensionIdentifier, extensionLocation: UriComponents): void;
$createWebviewPanel(extension: WebviewExtensionDescription, handle: WebviewPanelHandle, viewType: string, title: string, showOptions: WebviewPanelShowOptions, options: modes.IWebviewPanelOptions & modes.IWebviewOptions): void;
$disposeWebview(handle: WebviewPanelHandle): void;
$reveal(handle: WebviewPanelHandle, showOptions: WebviewPanelShowOptions): void;
$setTitle(handle: WebviewPanelHandle, value: string): void;
@@ -554,14 +559,13 @@ export interface MainThreadWebviewsShape extends IDisposable {
$setHtml(handle: WebviewPanelHandle, value: string): void;
$setOptions(handle: WebviewPanelHandle, options: modes.IWebviewOptions): void;
$setExtension(handle: WebviewPanelHandle, extensionId: ExtensionIdentifier, extensionLocation: UriComponents): void;
$postMessage(handle: WebviewPanelHandle, value: any): Promise<boolean>;
$registerSerializer(viewType: string): void;
$unregisterSerializer(viewType: string): void;
$registerEditorProvider(viewType: string): void;
$registerEditorProvider(extension: WebviewExtensionDescription, viewType: string, options: modes.IWebviewPanelOptions): void;
$unregisterEditorProvider(viewType: string): void;
}
@@ -579,7 +583,7 @@ export interface ExtHostWebviewsShape {
$onDidChangeWebviewPanelViewStates(newState: WebviewPanelViewStateData): void;
$onDidDisposeWebviewPanel(handle: WebviewPanelHandle): Promise<void>;
$deserializeWebviewPanel(newWebviewHandle: WebviewPanelHandle, viewType: string, title: string, state: any, position: EditorViewColumn, options: modes.IWebviewOptions & modes.IWebviewPanelOptions): Promise<void>;
$resolveWebviewEditor(resource: UriComponents, newWebviewHandle: WebviewPanelHandle, viewType: string, title: string, state: any, position: EditorViewColumn, options: modes.IWebviewOptions & modes.IWebviewPanelOptions): Promise<void>;
$resolveWebviewEditor(resource: UriComponents, newWebviewHandle: WebviewPanelHandle, viewType: string, title: string, position: EditorViewColumn, options: modes.IWebviewOptions & modes.IWebviewPanelOptions): Promise<void>;
$save(handle: WebviewPanelHandle): Promise<boolean>;
}

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { URI } from 'vs/base/common/uri';
import { IDisposable } from 'vs/base/common/lifecycle';
import { DisposableStore } from 'vs/base/common/lifecycle';
import * as vscode from 'vscode';
import * as typeConverters from 'vs/workbench/api/common/extHostTypeConverters';
import * as types from 'vs/workbench/api/common/extHostTypes';
@@ -27,7 +27,7 @@ export class ExtHostApiCommands {
}
private _commands: ExtHostCommands;
private _disposables: IDisposable[] = [];
private readonly _disposables = new DisposableStore();
private constructor(commands: ExtHostCommands) {
this._commands = commands;
@@ -239,7 +239,7 @@ export class ExtHostApiCommands {
this._register(OpenFolderAPICommand.ID, adjustHandler(OpenFolderAPICommand.execute), {
description: 'Open a folder or workspace in the current window or new window depending on the newWindow argument. Note that opening in the same window will shutdown the current extension host process and start a new one on the given folder/workspace unless the newWindow parameter is set to true.',
args: [
{ name: 'uri', description: '(optional) Uri of the folder or workspace file to open. If not provided, a native dialog will ask the user for the folder', constraint: (value: any) => value === undefined || value instanceof URI },
{ name: 'uri', description: '(optional) Uri of the folder or workspace file to open. If not provided, a native dialog will ask the user for the folder', constraint: (value: any) => value === undefined || URI.isUri(value) },
{ name: 'options', description: '(optional) Options. Object with the following properties: `forceNewWindow `: Whether to open the folder/workspace in a new window or the same. Defaults to opening in the same window. `noRecentEntry`: Whether the opened URI will appear in the \'Open Recent\' list. Defaults to true. Note, for backward compatibility, options can also be of type boolean, representing the `forceNewWindow` setting.', constraint: (value: any) => value === undefined || typeof value === 'object' || typeof value === 'boolean' }
]
});
@@ -288,7 +288,7 @@ export class ExtHostApiCommands {
private _register(id: string, handler: (...args: any[]) => any, description?: ICommandHandlerDescription): void {
const disposable = this._commands.registerCommand(false, id, handler, this, description);
this._disposables.push(disposable);
this._disposables.add(disposable);
}
/**
@@ -576,30 +576,30 @@ export class ExtHostApiCommands {
private async _executeCallHierarchyIncomingCallsProvider(resource: URI, position: types.Position): Promise<vscode.CallHierarchyIncomingCall[]> {
type IncomingCallDto = {
source: ICallHierarchyItemDto;
sourceRanges: IRange[];
from: ICallHierarchyItemDto;
fromRanges: IRange[];
};
const args = { resource, position: typeConverters.Position.from(position) };
const calls = await this._commands.executeCommand<IncomingCallDto[]>('_executeCallHierarchyIncomingCalls', args);
const result: vscode.CallHierarchyIncomingCall[] = [];
for (const call of calls) {
result.push(new types.CallHierarchyIncomingCall(typeConverters.CallHierarchyItem.to(call.source), <vscode.Range[]>call.sourceRanges.map(typeConverters.Range.to)));
result.push(new types.CallHierarchyIncomingCall(typeConverters.CallHierarchyItem.to(call.from), <vscode.Range[]>call.fromRanges.map(typeConverters.Range.to)));
}
return result;
}
private async _executeCallHierarchyOutgoingCallsProvider(resource: URI, position: types.Position): Promise<vscode.CallHierarchyOutgoingCall[]> {
type OutgoingCallDto = {
sourceRanges: IRange[];
target: ICallHierarchyItemDto;
fromRanges: IRange[];
to: ICallHierarchyItemDto;
};
const args = { resource, position: typeConverters.Position.from(position) };
const calls = await this._commands.executeCommand<OutgoingCallDto[]>('_executeCallHierarchyOutgoingCalls', args);
const result: vscode.CallHierarchyOutgoingCall[] = [];
for (const call of calls) {
result.push(new types.CallHierarchyOutgoingCall(typeConverters.CallHierarchyItem.to(call.target), <vscode.Range[]>call.sourceRanges.map(typeConverters.Range.to)));
result.push(new types.CallHierarchyOutgoingCall(typeConverters.CallHierarchyItem.to(call.to), <vscode.Range[]>call.fromRanges.map(typeConverters.Range.to)));
}
return result;
}

View File

@@ -64,7 +64,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
this._checkDisposed();
let toSync: vscode.Uri[] = [];
if (first instanceof URI) {
if (URI.isUri(first)) {
if (!diagnostics) {
// remove this entry

View File

@@ -12,6 +12,7 @@ import { ensureValidWordDefinition, getWordAtText } from 'vs/editor/common/model
import { MainThreadDocumentsShape } from 'vs/workbench/api/common/extHost.protocol';
import { EndOfLine, Position, Range } from 'vs/workbench/api/common/extHostTypes';
import * as vscode from 'vscode';
import { equals } from 'vs/base/common/arrays';
const _modeId2WordDefinition = new Map<string, RegExp>();
export function setWordDefinitionFor(modeId: string, wordDefinition: RegExp | undefined): void {
@@ -48,17 +49,8 @@ export class ExtHostDocumentData extends MirrorTextModel {
this._isDirty = false;
}
equalLines(lines: string[]): boolean {
const len = lines.length;
if (len !== this._lines.length) {
return false;
}
for (let i = 0; i < len; i++) {
if (lines[i] !== this._lines[i]) {
return false;
}
}
return true;
equalLines(lines: readonly string[]): boolean {
return equals(this._lines, lines);
}
get document(): vscode.TextDocument {

View File

@@ -1021,7 +1021,7 @@ class CallHierarchyAdapter {
if (!calls) {
return undefined;
}
return calls.map(call => (<[extHostProtocol.ICallHierarchyItemDto, IRange[]]>[typeConvert.CallHierarchyItem.from(call.source), call.sourceRanges.map(typeConvert.Range.from)]));
return calls.map(call => (<[extHostProtocol.ICallHierarchyItemDto, IRange[]]>[typeConvert.CallHierarchyItem.from(call.from), call.fromRanges.map(typeConvert.Range.from)]));
}
async provideCallsFrom(uri: URI, position: IPosition, token: CancellationToken): Promise<[extHostProtocol.ICallHierarchyItemDto, IRange[]][] | undefined> {
@@ -1031,7 +1031,7 @@ class CallHierarchyAdapter {
if (!calls) {
return undefined;
}
return calls.map(call => (<[extHostProtocol.ICallHierarchyItemDto, IRange[]]>[typeConvert.CallHierarchyItem.from(call.target), call.sourceRanges.map(typeConvert.Range.from)]));
return calls.map(call => (<[extHostProtocol.ICallHierarchyItemDto, IRange[]]>[typeConvert.CallHierarchyItem.from(call.to), call.fromRanges.map(typeConvert.Range.from)]));
}
}

View File

@@ -234,16 +234,16 @@ class ExtHostQuickInput implements QuickInput {
private static _nextId = 1;
_id = ExtHostQuickPick._nextId++;
private _title: string;
private _steps: number;
private _totalSteps: number;
private _title: string | undefined;
private _steps: number | undefined;
private _totalSteps: number | undefined;
private _visible = false;
private _expectingHide = false;
private _enabled = true;
private _busy = false;
private _ignoreFocusOut = true;
private _value = '';
private _placeholder: string;
private _placeholder: string | undefined;
private _buttons: QuickInputButton[] = [];
private _handlesToButtons = new Map<number, QuickInputButton>();
private readonly _onDidAcceptEmitter = new Emitter<void>();
@@ -268,7 +268,7 @@ class ExtHostQuickInput implements QuickInput {
return this._title;
}
set title(title: string) {
set title(title: string | undefined) {
this._title = title;
this.update({ title });
}
@@ -277,7 +277,7 @@ class ExtHostQuickInput implements QuickInput {
return this._steps;
}
set step(step: number) {
set step(step: number | undefined) {
this._steps = step;
this.update({ step });
}
@@ -286,7 +286,7 @@ class ExtHostQuickInput implements QuickInput {
return this._totalSteps;
}
set totalSteps(totalSteps: number) {
set totalSteps(totalSteps: number | undefined) {
this._totalSteps = totalSteps;
this.update({ totalSteps });
}
@@ -331,7 +331,7 @@ class ExtHostQuickInput implements QuickInput {
return this._placeholder;
}
set placeholder(placeholder: string) {
set placeholder(placeholder: string | undefined) {
this._placeholder = placeholder;
this.update({ placeholder });
}
@@ -398,7 +398,7 @@ class ExtHostQuickInput implements QuickInput {
}
}
public dispose(): void {
dispose(): void {
if (this._disposed) {
return;
}
@@ -455,7 +455,7 @@ function getIconUris(iconPath: QuickInputButton['iconPath']): { dark: URI, light
function getLightIconUri(iconPath: QuickInputButton['iconPath']) {
if (iconPath && !(iconPath instanceof ThemeIcon)) {
if (typeof iconPath === 'string'
|| iconPath instanceof URI) {
|| URI.isUri(iconPath)) {
return getIconUri(iconPath);
}
return getIconUri((iconPath as any).light);
@@ -471,7 +471,7 @@ function getDarkIconUri(iconPath: QuickInputButton['iconPath']) {
}
function getIconUri(iconPath: string | URI) {
if (iconPath instanceof URI) {
if (URI.isUri(iconPath)) {
return iconPath;
}
return URI.file(iconPath);
@@ -587,9 +587,9 @@ class ExtHostQuickPick<T extends QuickPickItem> extends ExtHostQuickInput implem
class ExtHostInputBox extends ExtHostQuickInput implements InputBox {
private _password: boolean;
private _prompt: string;
private _validationMessage: string;
private _password = false;
private _prompt: string | undefined;
private _validationMessage: string | undefined;
constructor(proxy: MainThreadQuickOpenShape, extensionId: ExtensionIdentifier, onDispose: () => void) {
super(proxy, extensionId, onDispose);
@@ -609,7 +609,7 @@ class ExtHostInputBox extends ExtHostQuickInput implements InputBox {
return this._prompt;
}
set prompt(prompt: string) {
set prompt(prompt: string | undefined) {
this._prompt = prompt;
this.update({ prompt });
}
@@ -618,7 +618,7 @@ class ExtHostInputBox extends ExtHostQuickInput implements InputBox {
return this._validationMessage;
}
set validationMessage(validationMessage: string) {
set validationMessage(validationMessage: string | undefined) {
this._validationMessage = validationMessage;
this.update({ validationMessage });
}

View File

@@ -10,7 +10,7 @@ import { DisposableStore, MutableDisposable } from 'vs/base/common/lifecycle';
import { asPromise } from 'vs/base/common/async';
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
import { MainContext, MainThreadSCMShape, SCMRawResource, SCMRawResourceSplice, SCMRawResourceSplices, IMainContext, ExtHostSCMShape, ICommandDto } from './extHost.protocol';
import { sortedDiff } from 'vs/base/common/arrays';
import { sortedDiff, equals } from 'vs/base/common/arrays';
import { comparePaths } from 'vs/base/common/comparers';
import * as vscode from 'vscode';
import { ISplice } from 'vs/base/common/sequence';
@@ -126,18 +126,8 @@ function commandEquals(a: vscode.Command, b: vscode.Command): boolean {
&& (a.arguments && b.arguments ? compareArgs(a.arguments, b.arguments) : a.arguments === b.arguments);
}
function commandListEquals(a: vscode.Command[], b: vscode.Command[]): boolean {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (!commandEquals(a[i], b[i])) {
return false;
}
}
return true;
function commandListEquals(a: readonly vscode.Command[], b: readonly vscode.Command[]): boolean {
return equals(a, b, commandEquals);
}
export interface IValidateInput {
@@ -174,9 +164,9 @@ export class ExtHostSCMInputBox implements vscode.SourceControlInputBox {
this._placeholder = placeholder;
}
private _validateInput: IValidateInput;
private _validateInput: IValidateInput | undefined;
get validateInput(): IValidateInput {
get validateInput(): IValidateInput | undefined {
if (!this._extension.enableProposedApi) {
throw new Error(`[${this._extension.identifier.value}]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ${this._extension.identifier.value}`);
}
@@ -184,7 +174,7 @@ export class ExtHostSCMInputBox implements vscode.SourceControlInputBox {
return this._validateInput;
}
set validateInput(fn: IValidateInput) {
set validateInput(fn: IValidateInput | undefined) {
if (!this._extension.enableProposedApi) {
throw new Error(`[${this._extension.identifier.value}]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ${this._extension.identifier.value}`);
}
@@ -405,6 +395,10 @@ class ExtHostSourceControl implements vscode.SourceControl {
}
set commitTemplate(commitTemplate: string | undefined) {
if (commitTemplate === this._commitTemplate) {
return;
}
this._commitTemplate = commitTemplate;
this._proxy.$updateSourceControl(this.handle, { commitTemplate });
}
@@ -667,7 +661,7 @@ export class ExtHostSCM implements ExtHostSCMShape {
return Promise.resolve(undefined);
}
return asPromise(() => sourceControl.inputBox.validateInput(value, cursorPosition)).then(result => {
return asPromise(() => sourceControl.inputBox.validateInput!(value, cursorPosition)).then(result => {
if (!result) {
return Promise.resolve(undefined);
}

View File

@@ -15,16 +15,16 @@ export class ExtHostStatusBarEntry implements StatusBarItem {
private _id: number;
private _alignment: number;
private _priority?: number;
private _disposed: boolean;
private _visible: boolean;
private _disposed: boolean = false;
private _visible: boolean = false;
private _statusId: string;
private _statusName: string;
private _text: string;
private _tooltip: string;
private _color: string | ThemeColor;
private _command: string;
private _text: string = '';
private _tooltip?: string;
private _color?: string | ThemeColor;
private _command?: string;
private _timeoutHandle: any;
private _proxy: MainThreadStatusBarShape;
@@ -54,15 +54,15 @@ export class ExtHostStatusBarEntry implements StatusBarItem {
return this._text;
}
public get tooltip(): string {
public get tooltip(): string | undefined {
return this._tooltip;
}
public get color(): string | ThemeColor {
public get color(): string | ThemeColor | undefined {
return this._color;
}
public get command(): string {
public get command(): string | undefined {
return this._command;
}
@@ -71,17 +71,17 @@ export class ExtHostStatusBarEntry implements StatusBarItem {
this.update();
}
public set tooltip(tooltip: string) {
public set tooltip(tooltip: string | undefined) {
this._tooltip = tooltip;
this.update();
}
public set color(color: string | ThemeColor) {
public set color(color: string | ThemeColor | undefined) {
this._color = color;
this.update();
}
public set command(command: string) {
public set command(command: string | undefined) {
this._command = command;
this.update();
}

View File

@@ -88,7 +88,7 @@ export namespace ProcessExecutionOptionsDTO {
}
export namespace ProcessExecutionDTO {
export function is(value: tasks.ShellExecutionDTO | tasks.ProcessExecutionDTO | tasks.CustomExecution2DTO | undefined): value is tasks.ProcessExecutionDTO {
export function is(value: tasks.ShellExecutionDTO | tasks.ProcessExecutionDTO | tasks.CustomExecutionDTO | undefined): value is tasks.ProcessExecutionDTO {
if (value) {
const candidate = value as tasks.ProcessExecutionDTO;
return candidate && !!candidate.process;
@@ -133,7 +133,7 @@ export namespace ShellExecutionOptionsDTO {
}
export namespace ShellExecutionDTO {
export function is(value: tasks.ShellExecutionDTO | tasks.ProcessExecutionDTO | tasks.CustomExecution2DTO | undefined): value is tasks.ShellExecutionDTO {
export function is(value: tasks.ShellExecutionDTO | tasks.ProcessExecutionDTO | tasks.CustomExecutionDTO | undefined): value is tasks.ShellExecutionDTO {
if (value) {
const candidate = value as tasks.ShellExecutionDTO;
return candidate && (!!candidate.commandLine || !!candidate.command);
@@ -170,19 +170,19 @@ export namespace ShellExecutionDTO {
}
}
export namespace CustomExecution2DTO {
export function is(value: tasks.ShellExecutionDTO | tasks.ProcessExecutionDTO | tasks.CustomExecution2DTO | undefined): value is tasks.CustomExecution2DTO {
export namespace CustomExecutionDTO {
export function is(value: tasks.ShellExecutionDTO | tasks.ProcessExecutionDTO | tasks.CustomExecutionDTO | undefined): value is tasks.CustomExecutionDTO {
if (value) {
let candidate = value as tasks.CustomExecution2DTO;
return candidate && candidate.customExecution === 'customExecution2';
let candidate = value as tasks.CustomExecutionDTO;
return candidate && candidate.customExecution === 'customExecution';
} else {
return false;
}
}
export function from(value: vscode.CustomExecution2): tasks.CustomExecution2DTO {
export function from(value: vscode.CustomExecution): tasks.CustomExecutionDTO {
return {
customExecution: 'customExecution2'
customExecution: 'customExecution'
};
}
}
@@ -220,13 +220,13 @@ export namespace TaskDTO {
if (value === undefined || value === null) {
return undefined;
}
let execution: tasks.ShellExecutionDTO | tasks.ProcessExecutionDTO | tasks.CustomExecution2DTO | undefined;
let execution: tasks.ShellExecutionDTO | tasks.ProcessExecutionDTO | tasks.CustomExecutionDTO | undefined;
if (value.execution instanceof types.ProcessExecution) {
execution = ProcessExecutionDTO.from(value.execution);
} else if (value.execution instanceof types.ShellExecution) {
execution = ShellExecutionDTO.from(value.execution);
} else if ((<vscode.Task2>value).execution2 && (<vscode.Task2>value).execution2 instanceof types.CustomExecution2) {
execution = CustomExecution2DTO.from(<types.CustomExecution2>(<vscode.Task2>value).execution2);
} else if ((<vscode.Task2>value).execution2 && (<vscode.Task2>value).execution2 instanceof types.CustomExecution) {
execution = CustomExecutionDTO.from(<types.CustomExecution>(<vscode.Task2>value).execution2);
}
const definition: tasks.TaskDefinitionDTO | undefined = TaskDefinitionDTO.from(value.definition);
@@ -373,9 +373,9 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
protected _handleCounter: number;
protected _handlers: Map<number, HandlerData>;
protected _taskExecutions: Map<string, TaskExecutionImpl>;
protected _providedCustomExecutions2: Map<string, types.CustomExecution2>;
protected _providedCustomExecutions2: Map<string, types.CustomExecution>;
private _notProvidedCustomExecutions: Set<string>; // Used for custom executions tasks that are created and run through executeTask.
protected _activeCustomExecutions2: Map<string, types.CustomExecution2>;
protected _activeCustomExecutions2: Map<string, types.CustomExecution>;
private _lastStartedTask: string | undefined;
protected readonly _onDidExecuteTask: Emitter<vscode.TaskStartEvent> = new Emitter<vscode.TaskStartEvent>();
protected readonly _onDidTerminateTask: Emitter<vscode.TaskEndEvent> = new Emitter<vscode.TaskEndEvent>();
@@ -399,9 +399,9 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
this._handleCounter = 0;
this._handlers = new Map<number, HandlerData>();
this._taskExecutions = new Map<string, TaskExecutionImpl>();
this._providedCustomExecutions2 = new Map<string, types.CustomExecution2>();
this._providedCustomExecutions2 = new Map<string, types.CustomExecution>();
this._notProvidedCustomExecutions = new Set<string>();
this._activeCustomExecutions2 = new Map<string, types.CustomExecution2>();
this._activeCustomExecutions2 = new Map<string, types.CustomExecution>();
}
public registerTaskProvider(extension: IExtensionDescription, type: string, provider: vscode.TaskProvider): vscode.Disposable {
@@ -454,15 +454,15 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
}
public async $onDidStartTask(execution: tasks.TaskExecutionDTO, terminalId: number): Promise<void> {
const execution2: types.CustomExecution2 | undefined = this._providedCustomExecutions2.get(execution.id);
if (execution2) {
const customExecution: types.CustomExecution | undefined = this._providedCustomExecutions2.get(execution.id);
if (customExecution) {
if (this._activeCustomExecutions2.get(execution.id) !== undefined) {
throw new Error('We should not be trying to start the same custom task executions twice.');
}
// Clone the custom execution to keep the original untouched. This is important for multiple runs of the same task.
this._activeCustomExecutions2.set(execution.id, execution2);
this._terminalService.attachPtyToTerminal(terminalId, await execution2.callback());
this._activeCustomExecutions2.set(execution.id, customExecution);
this._terminalService.attachPtyToTerminal(terminalId, await customExecution.callback());
}
this._lastStartedTask = execution.id;
@@ -573,8 +573,8 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
throw new Error('Unexpected: The resolved task definition must be the same object as the original task definition. The task definition cannot be changed.');
}
if (CustomExecution2DTO.is(resolvedTaskDTO.execution)) {
await this.addCustomExecution2(resolvedTaskDTO, <vscode.Task2>resolvedTask, true);
if (CustomExecutionDTO.is(resolvedTaskDTO.execution)) {
await this.addCustomExecution(resolvedTaskDTO, <vscode.Task2>resolvedTask, true);
}
return await this.resolveTaskInternal(resolvedTaskDTO);
@@ -588,12 +588,12 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
return this._handleCounter++;
}
protected async addCustomExecution2(taskDTO: tasks.TaskDTO, task: vscode.Task2, isProvided: boolean): Promise<void> {
protected async addCustomExecution(taskDTO: tasks.TaskDTO, task: vscode.Task2, isProvided: boolean): Promise<void> {
const taskId = await this._proxy.$createTaskId(taskDTO);
if (!isProvided && !this._providedCustomExecutions2.has(taskId)) {
this._notProvidedCustomExecutions.add(taskId);
}
this._providedCustomExecutions2.set(taskId, <types.CustomExecution2>(<vscode.Task2>task).execution2);
this._providedCustomExecutions2.set(taskId, <types.CustomExecution>(<vscode.Task2>task).execution2);
}
protected async getTaskExecution(execution: tasks.TaskExecutionDTO | string, task?: vscode.Task): Promise<TaskExecutionImpl> {
@@ -619,7 +619,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape {
}
private customExecutionComplete(execution: tasks.TaskExecutionDTO): void {
const extensionCallback2: vscode.CustomExecution2 | undefined = this._activeCustomExecutions2.get(execution.id);
const extensionCallback2: vscode.CustomExecution | undefined = this._activeCustomExecutions2.get(execution.id);
if (extensionCallback2) {
this._activeCustomExecutions2.delete(execution.id);
}
@@ -674,8 +674,8 @@ export class WorkerExtHostTask extends ExtHostTaskBase {
// If this task is a custom execution, then we need to save it away
// in the provided custom execution map that is cleaned up after the
// task is executed.
if (CustomExecution2DTO.is(dto.execution)) {
await this.addCustomExecution2(dto, <vscode.Task2>task, false);
if (CustomExecutionDTO.is(dto.execution)) {
await this.addCustomExecution(dto, <vscode.Task2>task, false);
} else {
throw new Error('Not implemented');
}
@@ -692,12 +692,12 @@ export class WorkerExtHostTask extends ExtHostTaskBase {
}
const taskDTO: tasks.TaskDTO | undefined = TaskDTO.from(task, handler.extension);
if (taskDTO && CustomExecution2DTO.is(taskDTO.execution)) {
if (taskDTO && CustomExecutionDTO.is(taskDTO.execution)) {
taskDTOs.push(taskDTO);
// The ID is calculated on the main thread task side, so, let's call into it here.
// We need the task id's pre-computed for custom task executions because when OnDidStartTask
// is invoked, we have to be able to map it back to our data.
taskIdPromises.push(this.addCustomExecution2(taskDTO, <vscode.Task2>task, true));
taskIdPromises.push(this.addCustomExecution(taskDTO, <vscode.Task2>task, true));
} else {
console.warn('Only custom execution tasks supported.');
}
@@ -710,7 +710,7 @@ export class WorkerExtHostTask extends ExtHostTaskBase {
}
protected async resolveTaskInternal(resolvedTaskDTO: tasks.TaskDTO): Promise<tasks.TaskDTO | undefined> {
if (CustomExecution2DTO.is(resolvedTaskDTO.execution)) {
if (CustomExecutionDTO.is(resolvedTaskDTO.execution)) {
return resolvedTaskDTO;
} else {
console.warn('Only custom execution tasks supported.');

View File

@@ -170,8 +170,8 @@ export interface TreeNode extends IDisposable { // {{SQL CARBON EDIT}} export in
// {{SQL CARBON EDIT}}
export class ExtHostTreeView<T> extends Disposable {
private static LABEL_HANDLE_PREFIX = '0';
private static ID_HANDLE_PREFIX = '1';
private static readonly LABEL_HANDLE_PREFIX = '0';
private static readonly ID_HANDLE_PREFIX = '1';
private readonly dataProvider: vscode.TreeDataProvider<T>;
@@ -557,7 +557,7 @@ export class ExtHostTreeView<T> extends Disposable {
private getLightIconPath(extensionTreeItem: vscode.TreeItem): URI | undefined {
if (extensionTreeItem.iconPath && !(extensionTreeItem.iconPath instanceof ThemeIcon)) {
if (typeof extensionTreeItem.iconPath === 'string'
|| extensionTreeItem.iconPath instanceof URI) {
|| URI.isUri(extensionTreeItem.iconPath)) {
return this.getIconPath(extensionTreeItem.iconPath);
}
return this.getIconPath((<{ light: string | URI; dark: string | URI }>extensionTreeItem.iconPath).light);
@@ -573,7 +573,7 @@ export class ExtHostTreeView<T> extends Disposable {
}
private getIconPath(iconPath: string | URI): URI {
if (iconPath instanceof URI) {
if (URI.isUri(iconPath)) {
return iconPath;
}
return URI.file(iconPath);

View File

@@ -255,12 +255,12 @@ export namespace MarkdownString {
}
// extract uris into a separate object
const resUris: { [href: string]: UriComponents } = Object.create(null);
const resUris: { [href: string]: UriComponents; } = Object.create(null);
res.uris = resUris;
const collectUri = (href: string): string => {
try {
let uri = URI.parse(href, true);
let uri = URI.parse(href);
uri = uri.with({ query: _uriMassage(uri.query, resUris) });
resUris[href] = uri;
} catch (e) {
@@ -277,13 +277,13 @@ export namespace MarkdownString {
return res;
}
function _uriMassage(part: string, bucket: { [n: string]: UriComponents }): string {
function _uriMassage(part: string, bucket: { [n: string]: UriComponents; }): string {
if (!part) {
return part;
}
let data: any;
try {
data = parse(decodeURIComponent(part));
data = parse(part);
} catch (e) {
// ignore
}
@@ -291,7 +291,7 @@ export namespace MarkdownString {
return part;
}
data = cloneAndChange(data, value => {
if (value instanceof URI) {
if (URI.isUri(value)) {
const key = `__uri_${Math.random().toString(16).slice(2, 8)}`;
bucket[key] = value;
return key;
@@ -303,9 +303,7 @@ export namespace MarkdownString {
}
export function to(value: htmlContent.IMarkdownString): vscode.MarkdownString {
const ret = new htmlContent.MarkdownString(value.value);
ret.isTrusted = value.isTrusted;
return ret;
return new htmlContent.MarkdownString(value.value, value.isTrusted);
}
export function fromStrict(value: string | types.MarkdownString): undefined | string | htmlContent.IMarkdownString {
@@ -515,7 +513,7 @@ export namespace WorkspaceEdit {
export namespace SymbolKind {
const _fromMapping: { [kind: number]: modes.SymbolKind } = Object.create(null);
const _fromMapping: { [kind: number]: modes.SymbolKind; } = Object.create(null);
_fromMapping[types.SymbolKind.File] = modes.SymbolKind.File;
_fromMapping[types.SymbolKind.Module] = modes.SymbolKind.Module;
_fromMapping[types.SymbolKind.Namespace] = modes.SymbolKind.Namespace;
@@ -905,7 +903,7 @@ export namespace DocumentLink {
let target: URI | undefined = undefined;
if (link.url) {
try {
target = typeof link.url === 'string' ? URI.parse(link.url, true) : URI.revive(link.url);
target = typeof link.url === 'string' ? URI.parse(link.url) : URI.revive(link.url);
} catch (err) {
// ignore
}

View File

@@ -614,12 +614,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
}
has(uri: URI): boolean {
for (const edit of this._edits) {
if (edit._type === 2 && edit.uri.toString() === uri.toString()) {
return true;
}
}
return false;
return this._edits.some(edit => edit._type === 2 && edit.uri.toString() === uri.toString());
}
set(uri: URI, edits: TextEdit[]): void {
@@ -1166,22 +1161,22 @@ export class CallHierarchyItem {
export class CallHierarchyIncomingCall {
source: vscode.CallHierarchyItem;
sourceRanges: vscode.Range[];
from: vscode.CallHierarchyItem;
fromRanges: vscode.Range[];
constructor(item: vscode.CallHierarchyItem, sourceRanges: vscode.Range[]) {
this.sourceRanges = sourceRanges;
this.source = item;
constructor(item: vscode.CallHierarchyItem, fromRanges: vscode.Range[]) {
this.fromRanges = fromRanges;
this.from = item;
}
}
export class CallHierarchyOutgoingCall {
target: vscode.CallHierarchyItem;
sourceRanges: vscode.Range[];
to: vscode.CallHierarchyItem;
fromRanges: vscode.Range[];
constructor(item: vscode.CallHierarchyItem, sourceRanges: vscode.Range[]) {
this.sourceRanges = sourceRanges;
this.target = item;
constructor(item: vscode.CallHierarchyItem, fromRanges: vscode.Range[]) {
this.fromRanges = fromRanges;
this.to = item;
}
}
@@ -1227,7 +1222,9 @@ export class MarkdownString {
appendText(value: string): MarkdownString {
// escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
this.value += value.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&');
this.value += value
.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&')
.replace('\n', '\n\n');
return this;
}
@@ -1472,7 +1469,7 @@ export class DocumentLink {
tooltip?: string;
constructor(range: Range, target: URI | undefined) {
if (target && !(target instanceof URI)) {
if (target && !(URI.isUri(target))) {
throw illegalArgument('target');
}
if (!Range.isRange(range) || range.isEmpty) {
@@ -1624,6 +1621,7 @@ export class ProcessExecution implements vscode.ProcessExecution {
if (typeof process !== 'string') {
throw illegalArgument('process');
}
this._args = [];
this._process = process;
if (varg1 !== undefined) {
if (Array.isArray(varg1)) {
@@ -1633,9 +1631,6 @@ export class ProcessExecution implements vscode.ProcessExecution {
this._options = varg1;
}
}
if (this._args === undefined) {
this._args = [];
}
}
@@ -1687,9 +1682,9 @@ export class ProcessExecution implements vscode.ProcessExecution {
@es5ClassCompat
export class ShellExecution implements vscode.ShellExecution {
private _commandLine: string;
private _command: string | vscode.ShellQuotedString;
private _args: (string | vscode.ShellQuotedString)[];
private _commandLine: string | undefined;
private _command: string | vscode.ShellQuotedString | undefined;
private _args: (string | vscode.ShellQuotedString)[] = [];
private _options: vscode.ShellExecutionOptions | undefined;
constructor(commandLine: string, options?: vscode.ShellExecutionOptions);
@@ -1714,11 +1709,11 @@ export class ShellExecution implements vscode.ShellExecution {
}
}
get commandLine(): string {
get commandLine(): string | undefined {
return this._commandLine;
}
set commandLine(value: string) {
set commandLine(value: string | undefined) {
if (typeof value !== 'string') {
throw illegalArgument('commandLine');
}
@@ -1726,7 +1721,7 @@ export class ShellExecution implements vscode.ShellExecution {
}
get command(): string | vscode.ShellQuotedString {
return this._command;
return this._command ? this._command : '';
}
set command(value: string | vscode.ShellQuotedString) {
@@ -1781,7 +1776,7 @@ export enum TaskScope {
Workspace = 2
}
export class CustomExecution2 implements vscode.CustomExecution2 {
export class CustomExecution implements vscode.CustomExecution {
private _callback: () => Thenable<vscode.Pseudoterminal>;
constructor(callback: () => Thenable<vscode.Pseudoterminal>) {
this._callback = callback;
@@ -1812,7 +1807,7 @@ export class Task implements vscode.Task2 {
private _definition: vscode.TaskDefinition;
private _scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder | undefined;
private _name: string;
private _execution: ProcessExecution | ShellExecution | CustomExecution2 | undefined;
private _execution: ProcessExecution | ShellExecution | CustomExecution | undefined;
private _problemMatchers: string[];
private _hasDefinedMatchers: boolean;
private _isBackground: boolean;
@@ -1821,26 +1816,26 @@ export class Task implements vscode.Task2 {
private _presentationOptions: vscode.TaskPresentationOptions;
private _runOptions: vscode.RunOptions;
constructor(definition: vscode.TaskDefinition, name: string, source: string, execution?: ProcessExecution | ShellExecution | CustomExecution2, problemMatchers?: string | string[]);
constructor(definition: vscode.TaskDefinition, scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder, name: string, source: string, execution?: ProcessExecution | ShellExecution | CustomExecution2, problemMatchers?: string | string[]);
constructor(definition: vscode.TaskDefinition, name: string, source: string, execution?: ProcessExecution | ShellExecution | CustomExecution, problemMatchers?: string | string[]);
constructor(definition: vscode.TaskDefinition, scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder, name: string, source: string, execution?: ProcessExecution | ShellExecution | CustomExecution, problemMatchers?: string | string[]);
constructor(definition: vscode.TaskDefinition, arg2: string | (vscode.TaskScope.Global | vscode.TaskScope.Workspace) | vscode.WorkspaceFolder, arg3: any, arg4?: any, arg5?: any, arg6?: any) {
this.definition = definition;
this._definition = this.definition = definition;
let problemMatchers: string | string[];
if (typeof arg2 === 'string') {
this.name = arg2;
this.source = arg3;
this._name = this.name = arg2;
this._source = this.source = arg3;
this.execution = arg4;
problemMatchers = arg5;
} else if (arg2 === TaskScope.Global || arg2 === TaskScope.Workspace) {
this.target = arg2;
this.name = arg3;
this.source = arg4;
this._name = this.name = arg3;
this._source = this.source = arg4;
this.execution = arg5;
problemMatchers = arg6;
} else {
this.target = arg2;
this.name = arg3;
this.source = arg4;
this._name = this.name = arg3;
this._source = this.source = arg4;
this.execution = arg5;
problemMatchers = arg6;
}
@@ -1887,7 +1882,7 @@ export class Task implements vscode.Task2 {
type: Task.ShellType,
id: this._execution.computeId()
};
} else if (this._execution instanceof CustomExecution2) {
} else if (this._execution instanceof CustomExecution) {
this._definition = {
type: Task.ExtensionCallbackType,
id: this._execution.computeId()
@@ -1934,18 +1929,18 @@ export class Task implements vscode.Task2 {
}
get execution(): ProcessExecution | ShellExecution | undefined {
return (this._execution instanceof CustomExecution2) ? undefined : this._execution;
return (this._execution instanceof CustomExecution) ? undefined : this._execution;
}
set execution(value: ProcessExecution | ShellExecution | undefined) {
this.execution2 = value;
}
get execution2(): ProcessExecution | ShellExecution | CustomExecution2 | undefined {
get execution2(): ProcessExecution | ShellExecution | CustomExecution | undefined {
return this._execution;
}
set execution2(value: ProcessExecution | ShellExecution | CustomExecution2 | undefined) {
set execution2(value: ProcessExecution | ShellExecution | CustomExecution | undefined) {
if (value === null) {
value = undefined;
}
@@ -2059,7 +2054,7 @@ export class TreeItem {
constructor(label: string | vscode.TreeItemLabel, collapsibleState?: vscode.TreeItemCollapsibleState)
constructor(resourceUri: URI, collapsibleState?: vscode.TreeItemCollapsibleState)
constructor(arg1: string | vscode.TreeItemLabel | URI, public collapsibleState: vscode.TreeItemCollapsibleState = TreeItemCollapsibleState.None) {
if (arg1 instanceof URI) {
if (URI.isUri(arg1)) {
this.resourceUri = arg1;
} else {
this.label = arg1;

View File

@@ -7,8 +7,9 @@ import { Emitter, Event } from 'vs/base/common/event';
import { URI, UriComponents } from 'vs/base/common/uri';
import { generateUuid } from 'vs/base/common/uuid';
import * as modes from 'vs/editor/common/modes';
import { IExtensionDescription, ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import * as typeConverters from 'vs/workbench/api/common/extHostTypeConverters';
import { IExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace';
import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
import { asWebviewUri, WebviewInitData } from 'vs/workbench/api/common/shared/webview';
import * as vscode from 'vscode';
@@ -18,7 +19,7 @@ import { Disposable } from './extHostTypes';
type IconPath = URI | { light: URI, dark: URI };
export class ExtHostWebview implements vscode.Webview {
private _html: string;
private _html: string = '';
private _isDisposed: boolean = false;
private _hasCalledAsWebviewUri = false;
@@ -30,7 +31,8 @@ export class ExtHostWebview implements vscode.Webview {
private readonly _proxy: MainThreadWebviewsShape,
private _options: vscode.WebviewOptions,
private readonly _initData: WebviewInitData,
private readonly _extensionId: ExtensionIdentifier | undefined,
private readonly _workspace: IExtHostWorkspace | undefined,
private readonly _extension: IExtensionDescription,
) { }
public dispose() {
@@ -56,10 +58,10 @@ export class ExtHostWebview implements vscode.Webview {
this.assertNotDisposed();
if (this._html !== value) {
this._html = value;
if (this._initData.isExtensionDevelopmentDebug && this._extensionId && !this._hasCalledAsWebviewUri) {
if (this._initData.isExtensionDevelopmentDebug && !this._hasCalledAsWebviewUri) {
if (/(["'])vscode-resource:([^\s'"]+?)(["'])/i.test(value)) {
this._hasCalledAsWebviewUri = true;
console.warn(`${this._extensionId.value} created a webview that appears to use the vscode-resource scheme directly. Please migrate to use the 'webview.asWebviewUri' api instead: https://aka.ms/vscode-webview-use-aswebviewuri`);
console.warn(`${this._extension.identifier.value} created a webview that appears to use the vscode-resource scheme directly. Please migrate to use the 'webview.asWebviewUri' api instead: https://aka.ms/vscode-webview-use-aswebviewuri`);
}
}
this._proxy.$setHtml(this._handle, value);
@@ -73,7 +75,7 @@ export class ExtHostWebview implements vscode.Webview {
public set options(newOptions: vscode.WebviewOptions) {
this.assertNotDisposed();
this._proxy.$setOptions(this._handle, convertWebviewOptions(newOptions));
this._proxy.$setOptions(this._handle, convertWebviewOptions(this._extension, this._workspace, newOptions));
this._options = newOptions;
}
@@ -261,12 +263,13 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
private readonly _proxy: MainThreadWebviewsShape;
private readonly _webviewPanels = new Map<WebviewPanelHandle, ExtHostWebviewEditor>();
private readonly _serializers = new Map<string, vscode.WebviewPanelSerializer>();
private readonly _serializers = new Map<string, { readonly serializer: vscode.WebviewPanelSerializer, readonly extension: IExtensionDescription }>();
private readonly _editorProviders = new Map<string, { readonly provider: vscode.WebviewEditorProvider, readonly extension: IExtensionDescription }>();
constructor(
mainContext: IMainContext,
private readonly initData: WebviewInitData
private readonly initData: WebviewInitData,
private readonly workspace: IExtHostWorkspace | undefined,
) {
this._proxy = mainContext.getProxy(MainContext.MainThreadWebviews);
}
@@ -285,15 +288,16 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
};
const handle = ExtHostWebviews.newHandle();
this._proxy.$createWebviewPanel(handle, viewType, title, webviewShowOptions, convertWebviewOptions(options), extension.identifier, extension.extensionLocation);
this._proxy.$createWebviewPanel({ id: extension.identifier, location: extension.extensionLocation }, handle, viewType, title, webviewShowOptions, convertWebviewOptions(extension, this.workspace, options));
const webview = new ExtHostWebview(handle, this._proxy, options, this.initData, extension.identifier);
const webview = new ExtHostWebview(handle, this._proxy, options, this.initData, this.workspace, extension);
const panel = new ExtHostWebviewEditor(handle, this._proxy, viewType, title, viewColumn, options, webview);
this._webviewPanels.set(handle, panel);
return panel;
}
public registerWebviewPanelSerializer(
extension: IExtensionDescription,
viewType: string,
serializer: vscode.WebviewPanelSerializer
): vscode.Disposable {
@@ -301,7 +305,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
throw new Error(`Serializer for '${viewType}' already registered`);
}
this._serializers.set(viewType, serializer);
this._serializers.set(viewType, { serializer, extension });
this._proxy.$registerSerializer(viewType);
return new Disposable(() => {
@@ -314,13 +318,14 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
extension: IExtensionDescription,
viewType: string,
provider: vscode.WebviewEditorProvider,
options?: vscode.WebviewPanelOptions,
): vscode.Disposable {
if (this._editorProviders.has(viewType)) {
throw new Error(`Editor provider for '${viewType}' already registered`);
}
this._editorProviders.set(viewType, { extension, provider, });
this._proxy.$registerEditorProvider(viewType);
this._proxy.$registerEditorProvider({ id: extension.identifier, location: extension.extensionLocation }, viewType, options || {});
return new Disposable(() => {
this._editorProviders.delete(viewType);
@@ -397,12 +402,13 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
position: EditorViewColumn,
options: modes.IWebviewOptions & modes.IWebviewPanelOptions
): Promise<void> {
const serializer = this._serializers.get(viewType);
if (!serializer) {
const entry = this._serializers.get(viewType);
if (!entry) {
return Promise.reject(new Error(`No serializer found for '${viewType}'`));
}
const { serializer, extension } = entry;
const webview = new ExtHostWebview(webviewHandle, this._proxy, options, this.initData, undefined);
const webview = new ExtHostWebview(webviewHandle, this._proxy, options, this.initData, this.workspace, extension);
const revivedPanel = new ExtHostWebviewEditor(webviewHandle, this._proxy, viewType, title, typeof position === 'number' && position >= 0 ? typeConverters.ViewColumn.to(position) : undefined, options, webview);
this._webviewPanels.set(webviewHandle, revivedPanel);
return Promise.resolve(serializer.deserializeWebviewPanel(revivedPanel, state));
@@ -417,7 +423,6 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
handle: WebviewPanelHandle,
viewType: string,
title: string,
state: any,
position: EditorViewColumn,
options: modes.IWebviewOptions & modes.IWebviewPanelOptions
): Promise<void> {
@@ -426,10 +431,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
return Promise.reject(new Error(`No provider found for '${viewType}'`));
}
const { provider, extension } = entry;
this._proxy.$setExtension(handle, extension.identifier, extension.extensionLocation);
const webview = new ExtHostWebview(handle, this._proxy, options, this.initData, extension.identifier);
const webview = new ExtHostWebview(handle, this._proxy, options, this.initData, this.workspace, extension);
const revivedPanel = new ExtHostWebviewEditor(handle, this._proxy, viewType, title, typeof position === 'number' && position >= 0 ? typeConverters.ViewColumn.to(position) : undefined, options, webview);
this._webviewPanels.set(handle, revivedPanel);
return Promise.resolve(provider.resolveWebviewEditor(URI.revive(resource), revivedPanel));
@@ -445,18 +447,22 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
}
function convertWebviewOptions(
options: vscode.WebviewPanelOptions & vscode.WebviewOptions
extension: IExtensionDescription,
workspace: IExtHostWorkspace | undefined,
options: vscode.WebviewPanelOptions & vscode.WebviewOptions,
): modes.IWebviewOptions {
return {
...options,
portMapping: options.portMapping
? options.portMapping.map((x): modes.IWebviewPortMapping => {
// Handle old proposed api
if ('port' in x) {
return { webviewPort: (x as any).port, extensionHostPort: (x as any).resolvedPort };
}
return { webviewPort: x.webviewPort, extensionHostPort: x.extensionHostPort };
})
: undefined,
localResourceRoots: options.localResourceRoots || getDefaultLocalResourceRoots(extension, workspace)
};
}
function getDefaultLocalResourceRoots(
extension: IExtensionDescription,
workspace: IExtHostWorkspace | undefined,
): URI[] {
return [
...(workspace && workspace.getWorkspaceFolders() || []).map(x => x.uri),
extension.extensionLocation,
];
}

View File

@@ -12,7 +12,7 @@ import { IExtensionPointUser, ExtensionMessageCollector, ExtensionsRegistry } fr
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { MenuId, MenuRegistry, ILocalizedString, IMenuItem } from 'vs/platform/actions/common/actions';
import { URI } from 'vs/base/common/uri';
import { IDisposable, dispose, DisposableStore } from 'vs/base/common/lifecycle';
import { DisposableStore } from 'vs/base/common/lifecycle';
namespace schema {
@@ -392,7 +392,7 @@ commandsExtensionPoint.setHandler(extensions => {
}
});
let _menuRegistrations: IDisposable[] = [];
const _menuRegistrations = new DisposableStore();
ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: schema.IUserFriendlyMenuItem[] }>({
extensionPoint: 'menus',
@@ -400,7 +400,7 @@ ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: schema.IUserFriendlyM
}).setHandler(extensions => {
// remove all previous menu registrations
_menuRegistrations = dispose(_menuRegistrations);
_menuRegistrations.clear();
for (let extension of extensions) {
const { value, collector } = extension;
@@ -455,7 +455,7 @@ ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: schema.IUserFriendlyM
order,
when: ContextKeyExpr.deserialize(item.when)
} as IMenuItem);
_menuRegistrations.push(registration);
_menuRegistrations.add(registration);
}
});
}

View File

@@ -66,8 +66,8 @@ export interface ShellExecutionDTO {
options?: ShellExecutionOptionsDTO;
}
export interface CustomExecution2DTO {
customExecution: 'customExecution2';
export interface CustomExecutionDTO {
customExecution: 'customExecution';
}
export interface TaskSourceDTO {
@@ -84,7 +84,7 @@ export interface TaskHandleDTO {
export interface TaskDTO {
_id: string;
name?: string;
execution: ProcessExecutionDTO | ShellExecutionDTO | CustomExecution2DTO | undefined;
execution: ProcessExecutionDTO | ShellExecutionDTO | CustomExecutionDTO | undefined;
definition: TaskDefinitionDTO;
isBackground?: boolean;
source: TaskSourceDTO;

View File

@@ -82,12 +82,12 @@ export class ExtHostDebugService implements IExtHostDebugService, ExtHostDebugSe
private _debugAdapters: Map<number, IDebugAdapter>;
private _debugAdaptersTrackers: Map<number, vscode.DebugAdapterTracker>;
private _variableResolver: IConfigurationResolverService;
private _variableResolver: IConfigurationResolverService | undefined;
private _integratedTerminalInstance?: vscode.Terminal;
private _terminalDisposedListener: IDisposable;
private _terminalDisposedListener: IDisposable | undefined;
private _signService: ISignService;
private _signService: ISignService | undefined;
constructor(
@@ -1070,10 +1070,8 @@ interface IDapTransport {
class DirectDebugAdapter extends AbstractDebugAdapter implements IDapTransport {
readonly onError: Event<Error>;
readonly onExit: Event<number>;
private _sendUp: (msg: DebugProtocol.ProtocolMessage) => void;
private _sendUp!: (msg: DebugProtocol.ProtocolMessage) => void;
constructor(implementation: any) {
super();

View File

@@ -19,7 +19,7 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'
import { IExtHostTerminalService } from 'vs/workbench/api/common/extHostTerminalService';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
import { ExtHostTaskBase, TaskHandleDTO, TaskDTO, CustomExecution2DTO, HandlerData } from 'vs/workbench/api/common/extHostTask';
import { ExtHostTaskBase, TaskHandleDTO, TaskDTO, CustomExecutionDTO, HandlerData } from 'vs/workbench/api/common/extHostTask';
import { Schemas } from 'vs/base/common/network';
export class ExtHostTask extends ExtHostTaskBase {
@@ -56,8 +56,8 @@ export class ExtHostTask extends ExtHostTaskBase {
// If this task is a custom execution, then we need to save it away
// in the provided custom execution map that is cleaned up after the
// task is executed.
if (CustomExecution2DTO.is(dto.execution)) {
await this.addCustomExecution2(dto, <vscode.Task2>task, false);
if (CustomExecutionDTO.is(dto.execution)) {
await this.addCustomExecution(dto, <vscode.Task2>task, false);
}
return this._proxy.$executeTask(dto).then(value => this.getTaskExecution(value, task));
@@ -76,11 +76,11 @@ export class ExtHostTask extends ExtHostTaskBase {
if (taskDTO) {
taskDTOs.push(taskDTO);
if (CustomExecution2DTO.is(taskDTO.execution)) {
if (CustomExecutionDTO.is(taskDTO.execution)) {
// The ID is calculated on the main thread task side, so, let's call into it here.
// We need the task id's pre-computed for custom task executions because when OnDidStartTask
// is invoked, we have to be able to map it back to our data.
taskIdPromises.push(this.addCustomExecution2(taskDTO, <vscode.Task2>task, true));
taskIdPromises.push(this.addCustomExecution(taskDTO, <vscode.Task2>task, true));
}
}
}

View File

@@ -32,7 +32,7 @@ class WorkerRequireInterceptor extends RequireInterceptor {
export class ExtHostExtensionService extends AbstractExtHostExtensionService {
private _fakeModules: WorkerRequireInterceptor;
private _fakeModules?: WorkerRequireInterceptor;
protected async _beforeAlmostReadyToRunExtensions(): Promise<void> {
// initialize API and register actors
@@ -57,7 +57,7 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
const _exports = {};
const _module = { exports: _exports };
const _require = (request: string) => {
const result = this._fakeModules.getModule(request, module);
const result = this._fakeModules!.getModule(request, module);
if (result === undefined) {
throw new Error(`Cannot load module '${request}'`);
}