Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-4814 Looking at Gulp/Jake/Grunt plugins extensions. #4926

Merged
merged 1 commit into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/main/browser/tasks-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class TasksMainImpl implements TasksMain {
const taskResolver = this.createTaskResolver(handle);

const disposable = new DisposableCollection();
disposable.push(this.taskProviderRegistry.register(type, taskProvider));
disposable.push(this.taskProviderRegistry.register(type, taskProvider, handle));
disposable.push(this.taskResolverRegistry.register(type, taskResolver));
this.disposables.set(handle, disposable);
}
Expand Down
47 changes: 44 additions & 3 deletions packages/plugin-ext/src/plugin/types-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1550,13 +1550,51 @@ export class Task {
private taskSource: string;
private taskGroup: TaskGroup | undefined;
private taskPresentationOptions: theia.TaskPresentationOptions | undefined;

constructor(taskDefinition: theia.TaskDefinition,
constructor(
taskDefinition: theia.TaskDefinition,
scope: theia.WorkspaceFolder | theia.TaskScope.Global | theia.TaskScope.Workspace,
name: string,
source: string,
execution?: ProcessExecution | ShellExecution,
problemMatchers?: string | string[]) {
problemMatchers?: string | string[]
);

// Deprecated constructor used by Jake vscode built-in
constructor(
taskDefinition: theia.TaskDefinition,
name: string,
source: string,
execution?: ProcessExecution | ShellExecution,
problemMatchers?: string | string[],
);

// tslint:disable-next-line:no-any
constructor(...args: any[]) {
let taskDefinition: theia.TaskDefinition;
let scope: theia.WorkspaceFolder | theia.TaskScope.Global | theia.TaskScope.Workspace | undefined;
let name: string;
let source: string;
let execution: ProcessExecution | ShellExecution | undefined;
let problemMatchers: string | string[] | undefined;

if (typeof args[1] === 'string') {
[
taskDefinition,
name,
source,
execution,
problemMatchers,
] = args;
} else {
[
taskDefinition,
scope,
name,
source,
execution,
problemMatchers,
] = args;
}

this.definition = taskDefinition;
this.scope = scope;
Expand Down Expand Up @@ -1593,6 +1631,9 @@ export class Task {
}

set scope(value: theia.TaskScope.Global | theia.TaskScope.Workspace | theia.WorkspaceFolder | undefined) {
if (value === null) {
value = undefined;
}
this.taskScope = value;
}

Expand Down
47 changes: 32 additions & 15 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ declare module '@theia/plugin' {
export let all: Plugin<any>[];
}


/**
* A command is a unique identifier of a function
* which can be executed by a user via a keyboard shortcut,
Expand Down Expand Up @@ -3672,53 +3671,53 @@ declare module '@theia/plugin' {
size: number;
}

/**
/**
* A type that filesystem providers should use to signal errors.
*
* This class has factory methods for common error-cases, like `EntryNotFound` when
* a file or folder doesn't exist, use them like so: `throw vscode.FileSystemError.EntryNotFound(someUri);`
*/
export class FileSystemError extends Error {

/**
/**
* Create an error to signal that a file or folder wasn't found.
* @param messageOrUri Message or uri.
*/
static FileNotFound(messageOrUri?: string | Uri): FileSystemError;

/**
/**
* Create an error to signal that a file or folder already exists, e.g. when
* creating but not overwriting a file.
* @param messageOrUri Message or uri.
*/
static FileExists(messageOrUri?: string | Uri): FileSystemError;

/**
/**
* Create an error to signal that a file is not a folder.
* @param messageOrUri Message or uri.
*/
static FileNotADirectory(messageOrUri?: string | Uri): FileSystemError;

/**
/**
* Create an error to signal that a file is a folder.
* @param messageOrUri Message or uri.
*/
static FileIsADirectory(messageOrUri?: string | Uri): FileSystemError;

/**
/**
* Create an error to signal that an operation lacks required permissions.
* @param messageOrUri Message or uri.
*/
static NoPermissions(messageOrUri?: string | Uri): FileSystemError;

/**
/**
* Create an error to signal that the file system is unavailable or too busy to
* complete a request.
* @param messageOrUri Message or uri.
*/
static Unavailable(messageOrUri?: string | Uri): FileSystemError;

/**
/**
* Creates a new filesystem error.
*
* @param messageOrUri Message or uri.
Expand Down Expand Up @@ -4121,7 +4120,6 @@ declare module '@theia/plugin' {
*/
export function applyEdit(edit: WorkspaceEdit): PromiseLike<boolean>;


/**
* Register a filesystem provider for a given scheme, e.g. `ftp`.
*
Expand Down Expand Up @@ -5060,7 +5058,6 @@ declare module '@theia/plugin' {
constructor(range: Range, newText: string);
}


/**
* Completion item kinds.
*/
Expand Down Expand Up @@ -5773,9 +5770,9 @@ declare module '@theia/plugin' {

/**
* Check if this code action kind intersects `other`.
* The kind "refactor.extract" for example intersects refactor, "refactor.extract" and
* The kind "refactor.extract" for example intersects refactor, "refactor.extract" and
* `"refactor.extract.function", but not "unicorn.refactor.extract", or "refactor.extractAll".
*
*
* @param other Kind to check.
*/
intersects(other: CodeActionKind): boolean;
Expand Down Expand Up @@ -6050,7 +6047,6 @@ declare module '@theia/plugin' {
resolveDocumentLink?(link: DocumentLink, token: CancellationToken | undefined): ProviderResult<DocumentLink>;
}


/**
* The rename provider interface defines the contract between extensions and
* the [rename](https://code.visualstudio.com/docs/editor/editingevolved#_rename-symbol)-feature.
Expand Down Expand Up @@ -7160,13 +7156,34 @@ declare module '@theia/plugin' {
* or '$eslint'. Problem matchers can be contributed by an extension using
* the `problemMatchers` extension point.
*/
constructor(taskDefinition: TaskDefinition,
constructor(
taskDefinition: TaskDefinition,
scope: WorkspaceFolder | TaskScope.Global | TaskScope.Workspace,
name: string,
source?: string,
execution?: ProcessExecution | ShellExecution,
problemMatchers?: string | string[]);

/**
* ~~Creates a new task.~~
*
* @deprecated Use the new constructors that allow specifying a scope for the task.
*
* @param definition The task definition as defined in the taskDefinitions extension point.
* @param name The task's name. Is presented in the user interface.
* @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
* @param execution The process or shell execution.
* @param problemMatchers the names of problem matchers to use, like '$tsc'
* or '$eslint'. Problem matchers can be contributed by an extension using
* the `problemMatchers` extension point.
*/
constructor(
taskDefinition: TaskDefinition,
name: string,
source: string,
execution?: ProcessExecution | ShellExecution,
problemMatchers?: string | string[]);

/** The task's name */
name: string;

Expand Down
8 changes: 2 additions & 6 deletions packages/task/src/browser/provided-task-configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ export class ProvidedTaskConfigurations {
if (task) {
return task;
} else {
const provider = this.taskProviderRegistry.getProvider(source);
if (provider) {
const tasks = await provider.provideTasks();
this.cacheTasks(tasks);
return this.getCachedTask(source, taskLabel);
}
await this.getTasks();
return this.getCachedTask(source, taskLabel);
}
}

Expand Down
7 changes: 4 additions & 3 deletions packages/task/src/browser/task-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ export class TaskProviderRegistry {
}

/** Registers the given Task Provider to return Task Configurations of the specified type. */
register(type: string, provider: TaskProvider): Disposable {
this.providers.set(type, provider);
register(type: string, provider: TaskProvider, handle?: number): Disposable {
const key = handle === undefined ? type : `${type}::${handle}`;
this.providers.set(key, provider);
return {
dispose: () => this.providers.delete(type)
dispose: () => this.providers.delete(key)
};
}

Expand Down