提交 127e136d 编写于 作者: D Dirk Baeumer

Merge branch 'dbaeumer/10676'

......@@ -14,8 +14,12 @@ import * as UUID from 'vs/base/common/uuid';
import { Config as ProcessConfig } from 'vs/base/common/processes';
import { ValidationStatus, ValidationState, ILogger } from 'vs/base/common/parsers';
import { NamedProblemMatcher, ProblemMatcher, ProblemMatcherParser, Config as ProblemMatcherConfig, registry as ProblemMatcherRegistry, isNamedProblemMatcher } from 'vs/platform/markers/common/problemMatcher';
import * as TaskSystem from 'vs/workbench/parts/tasks/common/taskSystem';
import {
NamedProblemMatcher, ProblemMatcher, ProblemMatcherParser, Config as ProblemMatcherConfig,
registry as ProblemMatcherRegistry, isNamedProblemMatcher
} from 'vs/platform/markers/common/problemMatcher';
import * as TaskSystem from './taskSystem';
/**
* Defines the problem handling strategy
......@@ -55,6 +59,24 @@ export interface PlatformTaskDescription {
args?: string[];
}
export interface CommandBinding {
/**
* The command identifer the task is bound to.
*/
identifier?: string;
/**
* The title to use
*/
title?: string;
/**
* An optional category
*/
category?: string;
}
/**
* The description of a task.
*/
......@@ -122,6 +144,11 @@ export interface TaskDescription extends PlatformTaskDescription {
*/
suppressTaskName?: boolean;
/**
* The command this task is bound to.
*/
bindTo?: CommandBinding;
/**
* The problem matcher(s) to use to capture problems in the tasks
* output.
......@@ -623,6 +650,32 @@ namespace ProblemMatcherConverter {
}
}
namespace CommandBinding {
export function isEmpty(value: TaskSystem.CommandBinding): boolean {
return !value || value.identifier === void 0 && value.title === void 0 && value.category === void 0;
}
export function from(this: void, binding: CommandBinding, context: ParseContext): TaskSystem.CommandBinding {
if (!binding) {
return undefined;
}
if (!Types.isString(binding.identifier)) {
context.validationStatus.state = ValidationState.Warning;
context.logger.log(nls.localize('noCommandId', 'Warning: a command binding must defined an identifier. Ignoring binding.'));
return undefined;
}
let result: TaskSystem.CommandBinding = {
identifier: binding.identifier,
title: ''
};
if (Types.isString(binding.category)) {
result.category = binding.category;
}
return result;
}
}
namespace TaskDescription {
export interface TaskConfiguration {
......@@ -682,6 +735,9 @@ namespace TaskDescription {
task.suppressTaskName = !!externalTask.suppressTaskName;
}
if (externalTask.bindTo) {
task.bindTo = CommandBinding.from(externalTask.bindTo, context);
}
if (problemMatchers) {
task.problemMatchers = problemMatchers;
}
......
......@@ -136,6 +136,23 @@ export interface CommandConfiguration {
echo?: boolean;
}
export interface CommandBinding {
/**
* The command identifier the task is bound to.
*/
identifier: string;
/**
* The title to use
*/
title: string;
/**
* An optional category
*/
category?: string;
}
/**
* A task description
*/
......@@ -183,6 +200,11 @@ export interface TaskDescription {
*/
showOutput: ShowOutput;
/**
* The command this task is bound to.
*/
bindTo?: CommandBinding;
/**
* The problem watchers to use for this task
*/
......
......@@ -20,7 +20,7 @@ import { IConfigurationResolverService } from 'vs/workbench/services/configurati
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import * as FileConfig from './processRunnerConfiguration';
import * as TaskConfig from '../common/taskConfiguration';
let build: string = 'build';
let test: string = 'test';
......@@ -109,7 +109,7 @@ class GruntTaskMatcher implements TaskDetectorMatcher {
}
export interface DetectorResult {
config: FileConfig.ExternalTaskRunnerConfiguration;
config: TaskConfig.ExternalTaskRunnerConfiguration;
stdout: string[];
stderr: string[];
}
......@@ -143,12 +143,12 @@ export class ProcessRunnerDetector {
private fileService: IFileService;
private contextService: IWorkspaceContextService;
private configurationResolverService: IConfigurationResolverService;
private taskConfiguration: FileConfig.ExternalTaskRunnerConfiguration;
private taskConfiguration: TaskConfig.ExternalTaskRunnerConfiguration;
private _stderr: string[];
private _stdout: string[];
private _cwd: string;
constructor(fileService: IFileService, contextService: IWorkspaceContextService, configurationResolverService: IConfigurationResolverService, config: FileConfig.ExternalTaskRunnerConfiguration = null) {
constructor(fileService: IFileService, contextService: IWorkspaceContextService, configurationResolverService: IConfigurationResolverService, config: TaskConfig.ExternalTaskRunnerConfiguration = null) {
this.fileService = fileService;
this.contextService = contextService;
this.configurationResolverService = configurationResolverService;
......@@ -225,27 +225,27 @@ export class ProcessRunnerDetector {
return result;
}
private tryDetectGulp(list: boolean): TPromise<{ config: FileConfig.ExternalTaskRunnerConfiguration; stderr: string[]; }> {
private tryDetectGulp(list: boolean): TPromise<{ config: TaskConfig.ExternalTaskRunnerConfiguration; stderr: string[]; }> {
return this.fileService.resolveFile(this.contextService.toResource('gulpfile.js')).then((stat) => {
let config = ProcessRunnerDetector.detectorConfig('gulp');
let process = new LineProcess('gulp', [config.arg, '--no-color'], true, { cwd: this._cwd });
return this.runDetection(process, 'gulp', true, config.matcher, ProcessRunnerDetector.DefaultProblemMatchers, list);
}, (err: any): FileConfig.ExternalTaskRunnerConfiguration => {
}, (err: any): TaskConfig.ExternalTaskRunnerConfiguration => {
return null;
});
}
private tryDetectGrunt(list: boolean): TPromise<{ config: FileConfig.ExternalTaskRunnerConfiguration; stderr: string[]; }> {
private tryDetectGrunt(list: boolean): TPromise<{ config: TaskConfig.ExternalTaskRunnerConfiguration; stderr: string[]; }> {
return this.fileService.resolveFile(this.contextService.toResource('Gruntfile.js')).then((stat) => {
let config = ProcessRunnerDetector.detectorConfig('grunt');
let process = new LineProcess('grunt', [config.arg, '--no-color'], true, { cwd: this._cwd });
return this.runDetection(process, 'grunt', true, config.matcher, ProcessRunnerDetector.DefaultProblemMatchers, list);
}, (err: any): FileConfig.ExternalTaskRunnerConfiguration => {
}, (err: any): TaskConfig.ExternalTaskRunnerConfiguration => {
return null;
});
}
private tryDetectJake(list: boolean): TPromise<{ config: FileConfig.ExternalTaskRunnerConfiguration; stderr: string[]; }> {
private tryDetectJake(list: boolean): TPromise<{ config: TaskConfig.ExternalTaskRunnerConfiguration; stderr: string[]; }> {
let run = () => {
let config = ProcessRunnerDetector.detectorConfig('jake');
let process = new LineProcess('jake', [config.arg], true, { cwd: this._cwd });
......@@ -256,7 +256,7 @@ export class ProcessRunnerDetector {
}, (err: any) => {
return this.fileService.resolveFile(this.contextService.toResource('Jakefile.js')).then((stat) => {
return run();
}, (err: any): FileConfig.ExternalTaskRunnerConfiguration => {
}, (err: any): TaskConfig.ExternalTaskRunnerConfiguration => {
return null;
});
});
......@@ -276,7 +276,7 @@ export class ProcessRunnerDetector {
}
return { config: null, stdout: this._stdout, stderr: this._stderr };
}
let result: FileConfig.ExternalTaskRunnerConfiguration = {
let result: TaskConfig.ExternalTaskRunnerConfiguration = {
version: ProcessRunnerDetector.Version,
command: command,
isShellCommand: isShellCommand
......@@ -314,8 +314,8 @@ export class ProcessRunnerDetector {
});
}
private createTaskDescriptions(tasks: string[], problemMatchers: string[], list: boolean): FileConfig.TaskDescription[] {
let taskConfigs: FileConfig.TaskDescription[] = [];
private createTaskDescriptions(tasks: string[], problemMatchers: string[], list: boolean): TaskConfig.TaskDescription[] {
let taskConfigs: TaskConfig.TaskDescription[] = [];
if (list) {
tasks.forEach((task) => {
taskConfigs.push({
......
......@@ -53,7 +53,7 @@ export class ProcessRunnerSystem extends EventEmitter implements ITaskSystem {
private activeTaskPromise: TPromise<ITaskSummary>;
constructor(configuration: TaskRunnerConfiguration, markerService: IMarkerService, modelService: IModelService, telemetryService: ITelemetryService,
outputService: IOutputService, configurationResolverService: IConfigurationResolverService, outputChannelId: string, clearOutput: boolean = true) {
outputService: IOutputService, configurationResolverService: IConfigurationResolverService, outputChannelId: string, hasErrors: boolean) {
super();
this.configuration = configuration;
this.markerService = markerService;
......@@ -66,11 +66,7 @@ export class ProcessRunnerSystem extends EventEmitter implements ITaskSystem {
this.activeTaskIdentifier = null;
this.activeTaskPromise = null;
this.outputChannel = this.outputService.getChannel(outputChannelId);
if (clearOutput) {
this.clearOutput();
}
this.errorsShown = false;
this.errorsShown = !hasErrors;
}
......
......@@ -12,7 +12,7 @@ import * as Platform from 'vs/base/common/platform';
import { ProblemMatcher, FileLocationKind, ProblemPattern, ApplyToKind } from 'vs/platform/markers/common/problemMatcher';
import * as TaskSystem from 'vs/workbench/parts/tasks/common/taskSystem';
import { parse, ParseResult, ILogger, ExternalTaskRunnerConfiguration } from 'vs/workbench/parts/tasks/node/processRunnerConfiguration';
import { parse, ParseResult, ILogger, ExternalTaskRunnerConfiguration } from 'vs/workbench/parts/tasks/common/taskConfiguration';
class Logger implements ILogger {
public receivedMessage: boolean = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册