提交 ed2b9d0e 编写于 作者: D Dirk Baeumer

Make problem matcher work in multi folder setup

上级 c6176160
......@@ -1180,13 +1180,13 @@ export class ProblemMatcherParser extends Parser {
let kind: FileLocationKind;
if (Types.isUndefined(description.fileLocation)) {
fileLocation = FileLocationKind.Relative;
filePrefix = '${cwd}';
filePrefix = '${workspaceFolder}';
} else if (Types.isString(description.fileLocation)) {
kind = FileLocationKind.fromString(<string>description.fileLocation);
if (kind) {
fileLocation = kind;
if (kind === FileLocationKind.Relative) {
filePrefix = '${cwd}';
filePrefix = '${workspaceFolder}';
}
}
} else if (Types.isStringArray(description.fileLocation)) {
......@@ -1601,7 +1601,7 @@ class ProblemMatcherRegistryImpl implements IProblemMatcherRegistry {
owner: 'typescript',
applyTo: ApplyToKind.closedDocuments,
fileLocation: FileLocationKind.Relative,
filePrefix: '${cwd}',
filePrefix: '${workspaceFolder}',
pattern: ProblemPatternRegistry.get('gulp-tsc')
});
......@@ -1629,7 +1629,7 @@ class ProblemMatcherRegistryImpl implements IProblemMatcherRegistry {
owner: 'eslint',
applyTo: ApplyToKind.allDocuments,
fileLocation: FileLocationKind.Relative,
filePrefix: '${cwd}',
filePrefix: '${workspaceFolder}',
pattern: ProblemPatternRegistry.get('eslint-compact')
});
......@@ -1648,7 +1648,7 @@ class ProblemMatcherRegistryImpl implements IProblemMatcherRegistry {
owner: 'go',
applyTo: ApplyToKind.allDocuments,
fileLocation: FileLocationKind.Relative,
filePrefix: '${cwd}',
filePrefix: '${workspaceFolder}',
pattern: ProblemPatternRegistry.get('go')
});
}
......
......@@ -7,6 +7,7 @@
import URI from 'vs/base/common/uri';
import * as Types from 'vs/base/common/types';
import { IJSONSchemaMap } from 'vs/base/common/jsonSchema';
import * as Objects from 'vs/base/common/objects';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { ProblemMatcher } from 'vs/platform/markers/common/problemMatcher';
......@@ -435,6 +436,10 @@ export namespace Task {
}
}
export function clone(task: Task): Task {
return Objects.assign({}, task);
}
export function getTelemetryKind(task: Task): string {
if (ContributedTask.is(task)) {
return 'extension';
......
......@@ -1019,7 +1019,7 @@ class TaskService extends EventEmitter implements ITaskService {
this.customize(task, { problemMatcher: [] }, true);
return task;
} else if (selected.matcher) {
let newTask = Objects.deepClone(task);
let newTask = Task.clone(task);
let matcherReference = `$${selected.matcher.name}`;
newTask.problemMatchers = [matcherReference];
this.customize(task, { problemMatcher: [matcherReference] }, true);
......
......@@ -285,7 +285,7 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem {
let promise: TPromise<ITaskSummary> = undefined;
if (task.isBackground) {
promise = new TPromise<ITaskSummary>((resolve, reject) => {
const problemMatchers = this.resolveMatchers(task.problemMatchers);
const problemMatchers = this.resolveMatchers(task, task.problemMatchers);
let watchingProblemMatcher = new WatchingProblemCollector(problemMatchers, this.markerService, this.modelService);
let toUnbind: IDisposable[] = [];
let event: TaskEvent = { taskId: task._id, taskName: task.name, type: TaskType.Watching, group: task.group, __task: task };
......@@ -354,7 +354,7 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem {
let event: TaskEvent = { taskId: task._id, taskName: task.name, type: TaskType.SingleRun, group: task.group, __task: task };
this.emit(TaskSystemEvents.Active, event);
let decoder = new TerminalDecoder();
let problemMatchers = this.resolveMatchers(task.problemMatchers);
let problemMatchers = this.resolveMatchers(task, task.problemMatchers);
let startStopProblemMatcher = new StartStopProblemCollector(problemMatchers, this.markerService, this.modelService);
const registeredLinkMatchers = this.registerLinkMatchers(terminal, problemMatchers);
const onData = terminal.onData((data: string) => {
......@@ -428,7 +428,7 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem {
}
private createTerminal(task: CustomTask | ContributedTask): [ITerminalInstance, string] {
let options = this.resolveOptions(task.command.options);
let options = this.resolveOptions(task, task.command.options);
let { command, args } = this.resolveCommandAndArgs(task);
let terminalName = nls.localize('TerminalTaskSystem.terminalName', 'Task - {0}', task.name);
let waitOnExit: boolean | string = false;
......@@ -566,8 +566,8 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem {
private resolveCommandAndArgs(task: CustomTask | ContributedTask): { command: string, args: string[] } {
// First we need to use the command args:
let args: string[] = task.command.args ? task.command.args.slice() : [];
args = this.resolveVariables(args);
let command: string = this.resolveVariable(task.command.name);
args = this.resolveVariables(task, args);
let command: string = this.resolveVariable(task, task.command.name);
return { command, args };
}
......@@ -610,11 +610,11 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem {
return command;
}
private resolveVariables(value: string[]): string[] {
return value.map(s => this.resolveVariable(s));
private resolveVariables(task: CustomTask | ContributedTask, value: string[]): string[] {
return value.map(s => this.resolveVariable(task, s));
}
private resolveMatchers(values: (string | ProblemMatcher)[]): ProblemMatcher[] {
private resolveMatchers(task: CustomTask | ContributedTask, values: (string | ProblemMatcher)[]): ProblemMatcher[] {
if (values === void 0 || values === null || values.length === 0) {
return [];
}
......@@ -638,31 +638,30 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem {
result.push(matcher);
} else {
let copy = Objects.clone(matcher);
copy.filePrefix = this.resolveVariable(copy.filePrefix);
copy.filePrefix = this.resolveVariable(task, copy.filePrefix);
result.push(copy);
}
});
return result;
}
private resolveVariable(value: string): string {
// TODO@Dirk adopt new configuration resolver service https://github.com/Microsoft/vscode/issues/31365
return this.configurationResolverService.resolve(this.contextService.getWorkspace().folders[0], value);
private resolveVariable(task: CustomTask | ContributedTask, value: string): string {
return this.configurationResolverService.resolve(Task.getWorkspaceFolder(task).uri, value);
}
private resolveOptions(options: CommandOptions): CommandOptions {
private resolveOptions(task: CustomTask | ContributedTask, options: CommandOptions): CommandOptions {
if (options === void 0 || options === null) {
return { cwd: this.resolveVariable('${cwd}') };
return { cwd: this.resolveVariable(task, '${workspaceFolder}') };
}
let result: CommandOptions = Types.isString(options.cwd)
? { cwd: this.resolveVariable(options.cwd) }
: { cwd: this.resolveVariable('${cwd}') };
? { cwd: this.resolveVariable(task, options.cwd) }
: { cwd: this.resolveVariable(task, '${workspaceFolder}') };
if (options.env) {
result.env = Object.create(null);
Object.keys(options.env).forEach((key) => {
let value: any = options.env[key];
if (Types.isString(value)) {
result.env[key] = this.resolveVariable(value);
result.env[key] = this.resolveVariable(task, value);
} else {
result.env[key] = value.toString();
}
......
......@@ -617,7 +617,7 @@ namespace ShellConfiguration {
namespace CommandOptions {
const properties: MetaData<Tasks.CommandOptions, Tasks.ShellConfiguration>[] = [{ property: 'cwd' }, { property: 'env' }, { property: 'shell', type: ShellConfiguration }];
const defaults: CommandOptions = { cwd: '${workspaceRoot}' };
const defaults: CommandOptions = { cwd: '${workspaceFolder}' };
export function from(this: void, options: CommandOptions, context: ParseContext): Tasks.CommandOptions {
let result: Tasks.CommandOptions = {};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册