Merge branch 'splitview' into scm-viewlet

This commit is contained in:
Joao Moreno
2017-09-18 11:32:04 +02:00
239 changed files with 5624 additions and 3555 deletions

View File

@@ -97,7 +97,7 @@ export function createApiFactory(
const extHostQuickOpen = threadService.set(ExtHostContext.ExtHostQuickOpen, new ExtHostQuickOpen(threadService));
const extHostTerminalService = threadService.set(ExtHostContext.ExtHostTerminalService, new ExtHostTerminalService(threadService));
const extHostSCM = threadService.set(ExtHostContext.ExtHostSCM, new ExtHostSCM(threadService, extHostCommands));
const extHostTask = threadService.set(ExtHostContext.ExtHostTask, new ExtHostTask(threadService));
const extHostTask = threadService.set(ExtHostContext.ExtHostTask, new ExtHostTask(threadService, extHostWorkspace));
const extHostCredentials = threadService.set(ExtHostContext.ExtHostCredentials, new ExtHostCredentials(threadService));
const extHostWindow = threadService.set(ExtHostContext.ExtHostWindow, new ExtHostWindow(threadService));
threadService.set(ExtHostContext.ExtHostExtensionService, extensionService);
@@ -599,6 +599,7 @@ export function createApiFactory(
TaskGroup: extHostTypes.TaskGroup,
ProcessExecution: extHostTypes.ProcessExecution,
ShellExecution: extHostTypes.ShellExecution,
TaskScope: extHostTypes.TaskScope,
Task: extHostTypes.Task,
ConfigurationTarget: extHostTypes.ConfigurationTarget
};

View File

@@ -64,7 +64,7 @@ export interface IEnvironment {
export interface IWorkspaceData {
id: string;
name: string;
roots: URI[];
folders: URI[];
}
export interface IInitData {

View File

@@ -6,7 +6,7 @@
import Event, { Emitter } from 'vs/base/common/event';
import { Disposable } from './extHostTypes';
import { match } from 'vs/base/common/glob';
import { parse } from 'vs/base/common/glob';
import { Uri, FileSystemWatcher as _FileSystemWatcher } from 'vscode';
import { FileSystemEvents, ExtHostFileSystemEventServiceShape } from './extHost.protocol';
@@ -43,24 +43,26 @@ class FileSystemWatcher implements _FileSystemWatcher {
this._config += 0b100;
}
const parsedPattern = parse(globPattern);
let subscription = dispatcher(events => {
if (!ignoreCreateEvents) {
for (let created of events.created) {
if (match(globPattern, created.fsPath)) {
if (parsedPattern(created.fsPath)) {
this._onDidCreate.fire(created);
}
}
}
if (!ignoreChangeEvents) {
for (let changed of events.changed) {
if (match(globPattern, changed.fsPath)) {
if (parsedPattern(changed.fsPath)) {
this._onDidChange.fire(changed);
}
}
}
if (!ignoreDeleteEvents) {
for (let deleted of events.deleted) {
if (match(globPattern, deleted.fsPath)) {
if (parsedPattern(deleted.fsPath)) {
this._onDidDelete.fire(deleted);
}
}

View File

@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import URI from 'vs/base/common/uri';
import * as nls from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
import * as Objects from 'vs/base/common/objects';
@@ -15,6 +16,7 @@ import * as TaskSystem from 'vs/workbench/parts/tasks/common/tasks';
import { MainContext, MainThreadTaskShape, ExtHostTaskShape, IMainContext } from 'vs/workbench/api/node/extHost.protocol';
import * as types from 'vs/workbench/api/node/extHostTypes';
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
import * as vscode from 'vscode';
interface StringMap<V> {
@@ -295,13 +297,13 @@ namespace ShellConfiguration {
namespace Tasks {
export function from(tasks: vscode.Task[], extension: IExtensionDescription): TaskSystem.Task[] {
export function from(tasks: vscode.Task[], rootFolder: vscode.WorkspaceFolder, extension: IExtensionDescription): TaskSystem.Task[] {
if (tasks === void 0 || tasks === null) {
return [];
}
let result: TaskSystem.Task[] = [];
for (let task of tasks) {
let converted = fromSingle(task, extension);
let converted = fromSingle(task, rootFolder, extension);
if (converted) {
result.push(converted);
}
@@ -309,7 +311,7 @@ namespace Tasks {
return result;
}
function fromSingle(task: vscode.Task, extension: IExtensionDescription): TaskSystem.ContributedTask {
function fromSingle(task: vscode.Task, rootFolder: vscode.WorkspaceFolder, extension: IExtensionDescription): TaskSystem.ContributedTask {
if (typeof task.name !== 'string') {
return undefined;
}
@@ -326,10 +328,27 @@ namespace Tasks {
return undefined;
}
command.presentation = PresentationOptions.from(task.presentationOptions);
let source = {
let taskScope: types.TaskScope.Global | types.TaskScope.Workspace | vscode.WorkspaceFolder | undefined = task.scope;
let workspaceFolder: vscode.WorkspaceFolder | undefined;
let scope: TaskSystem.TaskScope;
// For backwards compatibility
if (taskScope === void 0) {
scope = TaskSystem.TaskScope.Folder;
workspaceFolder = rootFolder;
} else if (taskScope === types.TaskScope.Global) {
scope = TaskSystem.TaskScope.Global;
} else if (taskScope === types.TaskScope.Workspace) {
scope = TaskSystem.TaskScope.Workspace;
} else {
workspaceFolder = taskScope;
}
let source: TaskSystem.ExtensionTaskSource = {
kind: TaskSystem.TaskSourceKind.Extension,
label: typeof task.source === 'string' ? task.source : extension.name,
extension: extension.id
extension: extension.id,
scope: scope,
workspaceFolder: workspaceFolder ? { uri: workspaceFolder.uri as URI } : undefined
};
let label = nls.localize('task.label', '{0}: {1}', source.label, task.name);
let key = (task as types.Task).definitionKey;
@@ -398,11 +417,13 @@ interface HandlerData {
export class ExtHostTask implements ExtHostTaskShape {
private _proxy: MainThreadTaskShape;
private _extHostWorkspace: ExtHostWorkspace;
private _handleCounter: number;
private _handlers: Map<number, HandlerData>;
constructor(mainContext: IMainContext) {
constructor(mainContext: IMainContext, extHostWorkspace: ExtHostWorkspace) {
this._proxy = mainContext.get(MainContext.MainThreadTask);
this._extHostWorkspace = extHostWorkspace;
this._handleCounter = 0;
this._handlers = new Map<number, HandlerData>();
};
@@ -426,8 +447,9 @@ export class ExtHostTask implements ExtHostTaskShape {
return TPromise.wrapError<TaskSystem.TaskSet>(new Error('no handler found'));
}
return asWinJsPromise(token => handler.provider.provideTasks(token)).then(value => {
let workspaceFolders = this._extHostWorkspace.getWorkspaceFolders();
return {
tasks: Tasks.from(value, handler.extension),
tasks: Tasks.from(value, workspaceFolders && workspaceFolders.length > 0 ? workspaceFolders[0] : undefined, handler.extension),
extension: handler.extension
};
});

View File

@@ -1214,10 +1214,16 @@ export class ShellExecution implements vscode.ShellExecution {
}
}
export enum TaskScope {
Global = 1,
Workspace = 2
}
export class Task implements vscode.Task {
private _definition: vscode.TaskDefinition;
private _definitionKey: string;
private _scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder;
private _name: string;
private _execution: ProcessExecution | ShellExecution;
private _problemMatchers: string[];
@@ -1227,11 +1233,29 @@ export class Task implements vscode.Task {
private _group: TaskGroup;
private _presentationOptions: vscode.TaskPresentationOptions;
constructor(definition: vscode.TaskDefinition, name: string, source: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]) {
constructor(definition: vscode.TaskDefinition, name: string, source: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
constructor(definition: vscode.TaskDefinition, scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder, name: string, source: string, execution?: ProcessExecution | ShellExecution, 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.name = name;
this.source = source;
this.execution = execution;
let problemMatchers: string | string[];
if (typeof arg2 === 'string') {
this.name = arg2;
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.execution = arg5;
problemMatchers = arg6;
} else {
this.target = arg2;
this.name = arg3;
this.source = arg4;
this.execution = arg5;
problemMatchers = arg6;
}
if (typeof problemMatchers === 'string') {
this._problemMatchers = [problemMatchers];
this._hasDefinedMatchers = true;
@@ -1266,6 +1290,14 @@ export class Task implements vscode.Task {
return this._definitionKey;
}
get scope(): vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder {
return this._scope;
}
set target(value: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder) {
this._scope = value;
}
get name(): string {
return this._name;
}

View File

@@ -32,10 +32,10 @@ class Workspace2 extends Workspace {
private readonly _structure = new TrieMap<vscode.WorkspaceFolder>(s => s.split('/'));
private constructor(data: IWorkspaceData) {
super(data.id, data.name, data.roots);
super(data.id, data.name, data.folders);
// setup the workspace folder data structure
this.roots.forEach((uri, index) => {
this.folders.forEach((uri, index) => {
const folder = {
name: basename(uri.fsPath),
uri,
@@ -46,7 +46,7 @@ class Workspace2 extends Workspace {
});
}
get folders(): vscode.WorkspaceFolder[] {
get workspaceFolders(): vscode.WorkspaceFolder[] {
return this._folder.slice(0);
}
@@ -92,7 +92,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
if (!this._workspace) {
return undefined;
} else {
return this._workspace.folders.slice(0);
return this._workspace.workspaceFolders.slice(0);
}
}
@@ -110,11 +110,11 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
if (!this._workspace) {
return undefined;
}
const { roots } = this._workspace;
if (roots.length === 0) {
const { folders } = this._workspace;
if (folders.length === 0) {
return undefined;
}
return roots[0].fsPath;
return folders[0].fsPath;
}
getRelativePath(pathOrUri: string | vscode.Uri, includeWorkspace?: boolean): string {
@@ -140,7 +140,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
}
if (typeof includeWorkspace === 'undefined') {
includeWorkspace = this.workspace.roots.length > 1;
includeWorkspace = this.workspace.folders.length > 1;
}
let result = relative(folder.uri.fsPath, path);
@@ -155,10 +155,10 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
// keep old workspace folder, build new workspace, and
// capture new workspace folders. Compute delta between
// them send that as event
const oldRoots = this._workspace ? this._workspace.folders.sort(ExtHostWorkspace._compareWorkspaceFolder) : [];
const oldRoots = this._workspace ? this._workspace.workspaceFolders.sort(ExtHostWorkspace._compareWorkspaceFolder) : [];
this._workspace = Workspace2.fromData(data);
const newRoots = this._workspace ? this._workspace.folders.sort(ExtHostWorkspace._compareWorkspaceFolder) : [];
const newRoots = this._workspace ? this._workspace.workspaceFolders.sort(ExtHostWorkspace._compareWorkspaceFolder) : [];
const { added, removed } = delta(oldRoots, newRoots, ExtHostWorkspace._compareWorkspaceFolder);
this._onDidChangeWorkspace.fire(Object.freeze({