mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 19:44:25 +01:00
Merge branch 'master' into ben/workspace-api
This commit is contained in:
@@ -541,7 +541,13 @@ export function createApiFactory(
|
||||
},
|
||||
registerDebugConfigurationProvider(debugType: string, provider: vscode.DebugConfigurationProvider) {
|
||||
return extHostDebugService.registerDebugConfigurationProvider(debugType, provider);
|
||||
}
|
||||
},
|
||||
addBreakpoints: proposedApiFunction(extension, (breakpoints: vscode.Breakpoint[]) => {
|
||||
return extHostDebugService.addBreakpoints(breakpoints);
|
||||
}),
|
||||
removeBreakpoints: proposedApiFunction(extension, (breakpoints: vscode.Breakpoint[]) => {
|
||||
return extHostDebugService.removeBreakpoints(breakpoints);
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -4,13 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {
|
||||
createMainContextProxyIdentifier as createMainId,
|
||||
createExtHostContextProxyIdentifier as createExtId,
|
||||
ProxyIdentifier,
|
||||
IRPCProtocol,
|
||||
ProxyType
|
||||
} from 'vs/workbench/services/extensions/node/proxyIdentifier';
|
||||
import { createMainContextProxyIdentifier as createMainId, createExtHostContextProxyIdentifier as createExtId, ProxyIdentifier, IRPCProtocol } from 'vs/workbench/services/extensions/node/proxyIdentifier';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
@@ -375,8 +369,8 @@ export interface MainThreadFileSystemShape extends IDisposable {
|
||||
}
|
||||
|
||||
export interface MainThreadTaskShape extends IDisposable {
|
||||
$registerTaskProvider(handle: number): TPromise<any>;
|
||||
$unregisterTaskProvider(handle: number): TPromise<any>;
|
||||
$registerTaskProvider(handle: number): TPromise<void>;
|
||||
$unregisterTaskProvider(handle: number): TPromise<void>;
|
||||
}
|
||||
|
||||
export interface MainThreadExtensionServiceShape extends IDisposable {
|
||||
@@ -449,6 +443,8 @@ export interface MainThreadDebugServiceShape extends IDisposable {
|
||||
$customDebugAdapterRequest(id: DebugSessionUUID, command: string, args: any): TPromise<any>;
|
||||
$appendDebugConsole(value: string): TPromise<any>;
|
||||
$startBreakpointEvents(): TPromise<any>;
|
||||
$registerBreakpoints(breakpoints: (ISourceMultiBreakpointDto | IFunctionBreakpointDto)[]): TPromise<IBreakpointIndexDto[]>;
|
||||
$unregisterBreakpoints(breakpointIds: string[], functionBreakpointIds: string[]): TPromise<void>;
|
||||
}
|
||||
|
||||
export interface MainThreadWindowShape extends IDisposable {
|
||||
@@ -703,30 +699,49 @@ export interface ExtHostTaskShape {
|
||||
$provideTasks(handle: number): TPromise<TaskSet>;
|
||||
}
|
||||
|
||||
export interface IBreakpointData {
|
||||
type: 'source' | 'function';
|
||||
id: string;
|
||||
export interface IFunctionBreakpointDto {
|
||||
type: 'function';
|
||||
index: number;
|
||||
id?: string;
|
||||
enabled: boolean;
|
||||
condition?: string;
|
||||
hitCondition?: string;
|
||||
functionName: string;
|
||||
}
|
||||
|
||||
export interface ISourceBreakpointData extends IBreakpointData {
|
||||
export interface ISourceBreakpointDto {
|
||||
type: 'source';
|
||||
id?: string;
|
||||
enabled: boolean;
|
||||
condition?: string;
|
||||
hitCondition?: string;
|
||||
uri: UriComponents;
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
|
||||
export interface IFunctionBreakpointData extends IBreakpointData {
|
||||
type: 'function';
|
||||
functionName: string;
|
||||
export interface IBreakpointsDeltaDto {
|
||||
added?: (ISourceBreakpointDto | IFunctionBreakpointDto)[];
|
||||
removed?: string[];
|
||||
changed?: (ISourceBreakpointDto | IFunctionBreakpointDto)[];
|
||||
}
|
||||
|
||||
export interface IBreakpointsDelta {
|
||||
added?: (ISourceBreakpointData | IFunctionBreakpointData)[];
|
||||
removed?: string[];
|
||||
changed?: (ISourceBreakpointData | IFunctionBreakpointData)[];
|
||||
export interface ISourceMultiBreakpointDto {
|
||||
type: 'sourceMulti';
|
||||
uri: UriComponents;
|
||||
lines: {
|
||||
index: number;
|
||||
enabled: boolean;
|
||||
condition?: string;
|
||||
hitCondition?: string;
|
||||
line: number;
|
||||
character: number;
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface IBreakpointIndexDto {
|
||||
index: number;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface ExtHostDebugServiceShape {
|
||||
@@ -736,7 +751,7 @@ export interface ExtHostDebugServiceShape {
|
||||
$acceptDebugSessionTerminated(id: DebugSessionUUID, type: string, name: string): void;
|
||||
$acceptDebugSessionActiveChanged(id: DebugSessionUUID | undefined, type?: string, name?: string): void;
|
||||
$acceptDebugSessionCustomEvent(id: DebugSessionUUID, type: string, name: string, event: any): void;
|
||||
$acceptBreakpointsDelta(delat: IBreakpointsDelta): void;
|
||||
$acceptBreakpointsDelta(delat: IBreakpointsDeltaDto): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -789,7 +804,7 @@ export const MainContext = {
|
||||
MainThreadFileSystem: createMainId<MainThreadFileSystemShape>('MainThreadFileSystem'),
|
||||
MainThreadExtensionService: createMainId<MainThreadExtensionServiceShape>('MainThreadExtensionService'),
|
||||
MainThreadSCM: createMainId<MainThreadSCMShape>('MainThreadSCM'),
|
||||
MainThreadTask: createMainId<MainThreadTaskShape>('MainThreadTask', ProxyType.CustomMarshaller),
|
||||
MainThreadTask: createMainId<MainThreadTaskShape>('MainThreadTask'),
|
||||
MainThreadWindow: createMainId<MainThreadWindowShape>('MainThreadWindow'),
|
||||
};
|
||||
|
||||
@@ -814,7 +829,7 @@ export const ExtHostContext = {
|
||||
ExtHostLogService: createExtId<ExtHostLogServiceShape>('ExtHostLogService'),
|
||||
ExtHostTerminalService: createExtId<ExtHostTerminalServiceShape>('ExtHostTerminalService'),
|
||||
ExtHostSCM: createExtId<ExtHostSCMShape>('ExtHostSCM'),
|
||||
ExtHostTask: createExtId<ExtHostTaskShape>('ExtHostTask', ProxyType.CustomMarshaller),
|
||||
ExtHostTask: createExtId<ExtHostTaskShape>('ExtHostTask'),
|
||||
ExtHostWorkspace: createExtId<ExtHostWorkspaceShape>('ExtHostWorkspace'),
|
||||
ExtHostWindow: createExtId<ExtHostWindowShape>('ExtHostWindow'),
|
||||
};
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { asWinJsPromise } from 'vs/base/common/async';
|
||||
import { MainContext, MainThreadDebugServiceShape, ExtHostDebugServiceShape, DebugSessionUUID, IMainContext, IBreakpointsDelta, ISourceBreakpointData, IFunctionBreakpointData } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import {
|
||||
MainContext, MainThreadDebugServiceShape, ExtHostDebugServiceShape, DebugSessionUUID,
|
||||
IMainContext, IBreakpointsDeltaDto, ISourceMultiBreakpointDto, IFunctionBreakpointDto
|
||||
} from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
@@ -95,51 +98,162 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
return result;
|
||||
}
|
||||
|
||||
public $acceptBreakpointsDelta(delta: IBreakpointsDelta): void {
|
||||
public $acceptBreakpointsDelta(delta: IBreakpointsDeltaDto): void {
|
||||
|
||||
let a: vscode.Breakpoint[] = [];
|
||||
let r: vscode.Breakpoint[] = [];
|
||||
let c: vscode.Breakpoint[] = [];
|
||||
|
||||
if (delta.added) {
|
||||
a = delta.added.map(bpd => {
|
||||
const bp = this.fromWire(bpd);
|
||||
for (const bpd of delta.added) {
|
||||
let bp: vscode.Breakpoint;
|
||||
if (bpd.type === 'function') {
|
||||
bp = new FunctionBreakpoint(bpd.functionName, bpd.enabled, bpd.condition, bpd.hitCondition);
|
||||
} else {
|
||||
const uri = URI.revive(bpd.uri);
|
||||
bp = new SourceBreakpoint(new Location(uri, new Position(bpd.line, bpd.character)), bpd.enabled, bpd.condition, bpd.hitCondition);
|
||||
}
|
||||
bp['_id'] = bpd.id;
|
||||
this._breakpoints.set(bpd.id, bp);
|
||||
return bp;
|
||||
});
|
||||
a.push(bp);
|
||||
}
|
||||
}
|
||||
|
||||
if (delta.removed) {
|
||||
r = delta.removed.map(id => {
|
||||
for (const id of delta.removed) {
|
||||
const bp = this._breakpoints.get(id);
|
||||
if (bp) {
|
||||
this._breakpoints.delete(id);
|
||||
r.push(bp);
|
||||
}
|
||||
return bp;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (delta.changed) {
|
||||
c = delta.changed.map(bpd => {
|
||||
const bp = this.fromWire(bpd);
|
||||
this._breakpoints.set(bpd.id, bp);
|
||||
return bp;
|
||||
});
|
||||
for (const bpd of delta.changed) {
|
||||
let bp = this._breakpoints.get(bpd.id);
|
||||
if (bp) {
|
||||
if (bpd.type === 'function') {
|
||||
const fbp = <any>bp;
|
||||
fbp.enabled = bpd.enabled;
|
||||
fbp.condition = bpd.condition;
|
||||
fbp.hitCondition = bpd.hitCondition;
|
||||
fbp.functionName = bpd.functionName;
|
||||
} else {
|
||||
const sbp = <any>bp;
|
||||
sbp.enabled = bpd.enabled;
|
||||
sbp.condition = bpd.condition;
|
||||
sbp.hitCondition = bpd.hitCondition;
|
||||
}
|
||||
c.push(bp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._onDidChangeBreakpoints.fire(Object.freeze({
|
||||
added: Object.freeze<vscode.Breakpoint[]>(a || []),
|
||||
removed: Object.freeze<vscode.Breakpoint[]>(r || []),
|
||||
changed: Object.freeze<vscode.Breakpoint[]>(c || [])
|
||||
}));
|
||||
this.fireBreakpointChanges(a, r, c);
|
||||
}
|
||||
|
||||
private fromWire(bp: ISourceBreakpointData | IFunctionBreakpointData): vscode.Breakpoint {
|
||||
if (bp.type === 'function') {
|
||||
return new FunctionBreakpoint(bp.enabled, bp.condition, bp.hitCondition, bp.functionName);
|
||||
public addBreakpoints(breakpoints0: vscode.Breakpoint[]): TPromise<void> {
|
||||
|
||||
this.startBreakpoints();
|
||||
|
||||
// assign temporary ids for brand new breakpoints
|
||||
const breakpoints: vscode.Breakpoint[] = [];
|
||||
for (const bp of breakpoints0) {
|
||||
let id = bp['_id'];
|
||||
if (id) { // has already id
|
||||
if (!this._breakpoints.has(id)) {
|
||||
breakpoints.push(bp);
|
||||
}
|
||||
} else {
|
||||
// no id -> assign temp id
|
||||
breakpoints.push(bp);
|
||||
}
|
||||
}
|
||||
|
||||
// convert to DTOs
|
||||
const dtos: (ISourceMultiBreakpointDto | IFunctionBreakpointDto)[] = [];
|
||||
const map = new Map<string, ISourceMultiBreakpointDto>();
|
||||
for (let i = 0; i < breakpoints.length; i++) {
|
||||
const bp = breakpoints[i];
|
||||
if (bp instanceof SourceBreakpoint) {
|
||||
let dto = map.get(bp.location.uri.toString());
|
||||
if (!dto) {
|
||||
dto = <ISourceMultiBreakpointDto>{
|
||||
type: 'sourceMulti',
|
||||
uri: bp.location.uri,
|
||||
lines: []
|
||||
};
|
||||
map.set(bp.location.uri.toString(), dto);
|
||||
dtos.push(dto);
|
||||
}
|
||||
dto.lines.push({
|
||||
index: i,
|
||||
enabled: bp.enabled,
|
||||
condition: bp.condition,
|
||||
hitCondition: bp.hitCondition,
|
||||
line: bp.location.range.start.line,
|
||||
character: bp.location.range.start.character
|
||||
});
|
||||
} else if (bp instanceof FunctionBreakpoint) {
|
||||
dtos.push({
|
||||
type: 'function',
|
||||
index: i,
|
||||
enabled: bp.enabled,
|
||||
functionName: bp.functionName,
|
||||
hitCondition: bp.hitCondition,
|
||||
condition: bp.condition
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// register with VS Code
|
||||
return this._debugServiceProxy.$registerBreakpoints(dtos).then(ids => {
|
||||
|
||||
// assign VS Code ids to breakpoints and store them in map
|
||||
ids.forEach(id => {
|
||||
const bp = breakpoints[id.index];
|
||||
bp['_id'] = id.id;
|
||||
this._breakpoints.set(id.id, bp);
|
||||
});
|
||||
|
||||
// send notification
|
||||
this.fireBreakpointChanges(breakpoints, [], []);
|
||||
|
||||
return void 0;
|
||||
});
|
||||
}
|
||||
|
||||
public removeBreakpoints(breakpoints0: vscode.Breakpoint[]): TPromise<void> {
|
||||
|
||||
this.startBreakpoints();
|
||||
|
||||
// remove from array
|
||||
const breakpoints: vscode.Breakpoint[] = [];
|
||||
for (const b of breakpoints0) {
|
||||
let id = b['_id'];
|
||||
if (id && this._breakpoints.delete(id)) {
|
||||
breakpoints.push(b);
|
||||
}
|
||||
}
|
||||
|
||||
// send notification
|
||||
this.fireBreakpointChanges([], breakpoints, []);
|
||||
|
||||
// unregister with VS Code
|
||||
const ids = breakpoints.filter(bp => bp instanceof SourceBreakpoint).map(bp => bp['_id']);
|
||||
const fids = breakpoints.filter(bp => bp instanceof FunctionBreakpoint).map(bp => bp['_id']);
|
||||
return this._debugServiceProxy.$unregisterBreakpoints(ids, fids);
|
||||
}
|
||||
|
||||
private fireBreakpointChanges(added: vscode.Breakpoint[], removed: vscode.Breakpoint[], changed: vscode.Breakpoint[]) {
|
||||
if (added.length > 0 || removed.length > 0 || changed.length > 0) {
|
||||
this._onDidChangeBreakpoints.fire(Object.freeze({
|
||||
added: Object.freeze<vscode.Breakpoint[]>(added),
|
||||
removed: Object.freeze<vscode.Breakpoint[]>(removed),
|
||||
changed: Object.freeze<vscode.Breakpoint[]>(changed)
|
||||
}));
|
||||
}
|
||||
const uri = URI.revive(bp.uri);
|
||||
return new SourceBreakpoint(bp.enabled, bp.condition, bp.hitCondition, new Location(uri, new Position(bp.line, bp.character)));
|
||||
}
|
||||
|
||||
public registerDebugConfigurationProvider(type: string, provider: vscode.DebugConfigurationProvider): vscode.Disposable {
|
||||
|
||||
@@ -294,11 +294,11 @@ namespace ShellConfiguration {
|
||||
|
||||
namespace Tasks {
|
||||
|
||||
export function from(tasks: vscode.Task[], rootFolder: vscode.WorkspaceFolder, extension: IExtensionDescription): TaskSystem.Task[] {
|
||||
export function from(tasks: vscode.Task[], rootFolder: vscode.WorkspaceFolder, extension: IExtensionDescription): TaskSystem.ContributedTask[] {
|
||||
if (tasks === void 0 || tasks === null) {
|
||||
return [];
|
||||
}
|
||||
let result: TaskSystem.Task[] = [];
|
||||
let result: TaskSystem.ContributedTask[] = [];
|
||||
for (let task of tasks) {
|
||||
let converted = fromSingle(task, rootFolder, extension);
|
||||
if (converted) {
|
||||
@@ -351,7 +351,7 @@ namespace Tasks {
|
||||
// We can't transfer a workspace folder object from the extension host to main since they differ
|
||||
// in shape and we don't have backwards converting function. So transfer the URI and resolve the
|
||||
// workspace folder on the main side.
|
||||
(source as any).__workspaceFolder = workspaceFolder ? workspaceFolder.uri as URI : undefined;
|
||||
(source as any as TaskSystem.ExtensionTaskSourceTransfer).__workspaceFolder = workspaceFolder ? workspaceFolder.uri as URI : undefined;
|
||||
let label = nls.localize('task.label', '{0}: {1}', source.label, task.name);
|
||||
let key = (task as types.Task).definitionKey;
|
||||
let kind = (task as types.Task).definition;
|
||||
|
||||
@@ -114,7 +114,7 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
}
|
||||
return null;
|
||||
})
|
||||
))).then(extTreeItems => extTreeItems.map((({ element, extTreeItem }) => this.createTreeItem(element, extTreeItem, parentHandle))));
|
||||
))).then(extTreeItems => coalesce(extTreeItems).map((({ element, extTreeItem }) => this.createTreeItem(element, extTreeItem, parentHandle))));
|
||||
}
|
||||
|
||||
getExtensionElement(treeItemHandle: TreeItemHandle): T {
|
||||
|
||||
@@ -1581,19 +1581,21 @@ export class Breakpoint {
|
||||
readonly condition?: string;
|
||||
readonly hitCondition?: string;
|
||||
|
||||
protected constructor(enabled: boolean, condition: string, hitCondition: string) {
|
||||
this.enabled = enabled;
|
||||
this.condition = condition;
|
||||
this.hitCondition = hitCondition;
|
||||
this.condition = condition;
|
||||
this.hitCondition = hitCondition;
|
||||
protected constructor(enabled?: boolean, condition?: string, hitCondition?: string) {
|
||||
this.enabled = typeof enabled === 'boolean' ? enabled : true;
|
||||
if (typeof condition === 'string') {
|
||||
this.condition = condition;
|
||||
}
|
||||
if (typeof hitCondition === 'string') {
|
||||
this.hitCondition = hitCondition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class SourceBreakpoint extends Breakpoint {
|
||||
readonly location: Location;
|
||||
|
||||
constructor(enabled: boolean, condition: string, hitCondition: string, location: Location) {
|
||||
constructor(location: Location, enabled?: boolean, condition?: string, hitCondition?: string) {
|
||||
super(enabled, condition, hitCondition);
|
||||
this.location = location;
|
||||
}
|
||||
@@ -1602,7 +1604,7 @@ export class SourceBreakpoint extends Breakpoint {
|
||||
export class FunctionBreakpoint extends Breakpoint {
|
||||
readonly functionName: string;
|
||||
|
||||
constructor(enabled: boolean, condition: string, hitCondition: string, functionName: string) {
|
||||
constructor(functionName: string, enabled?: boolean, condition?: string, hitCondition?: string) {
|
||||
super(enabled, condition, hitCondition);
|
||||
this.functionName = functionName;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user