mirror of
https://github.com/Microsoft/vscode
synced 2024-10-13 14:57:14 +00:00
Fixes #7877: Confusing message: No build tasks configured
This commit is contained in:
parent
f116ac5525
commit
0f8c198c69
|
@ -169,10 +169,7 @@ class CleanAction extends AbstractTaskAction {
|
|||
}
|
||||
}
|
||||
|
||||
class ConfigureTaskRunnerAction extends Action {
|
||||
|
||||
public static ID = 'workbench.action.tasks.configureTaskRunner';
|
||||
public static TEXT = nls.localize('ConfigureTaskRunnerAction.label', "Configure Task Runner");
|
||||
abstract class OpenTaskConfigurationAction extends Action {
|
||||
|
||||
private configurationService: IConfigurationService;
|
||||
private fileService: IFileService;
|
||||
|
@ -273,6 +270,35 @@ class ConfigureTaskRunnerAction extends Action {
|
|||
}
|
||||
}
|
||||
|
||||
class ConfigureTaskRunnerAction extends OpenTaskConfigurationAction {
|
||||
public static ID = 'workbench.action.tasks.configureTaskRunner';
|
||||
public static TEXT = nls.localize('ConfigureTaskRunnerAction.label', "Configure Task Runner");
|
||||
|
||||
constructor(id: string, label: string, @IConfigurationService configurationService: IConfigurationService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService, @IFileService fileService: IFileService,
|
||||
@IWorkspaceContextService contextService: IWorkspaceContextService, @IOutputService outputService: IOutputService,
|
||||
@IMessageService messageService: IMessageService, @IQuickOpenService quickOpenService: IQuickOpenService,
|
||||
@IEnvironmentService environmentService: IEnvironmentService) {
|
||||
super(id, label, configurationService, editorService, fileService, contextService,
|
||||
outputService, messageService, quickOpenService, environmentService);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ConfigureBuildTaskAction extends OpenTaskConfigurationAction {
|
||||
public static ID = 'workbench.action.tasks.configureBuildTask';
|
||||
public static TEXT = nls.localize('ConfigureBuildTaskAction.label', "Configure Build Task");
|
||||
|
||||
constructor(id: string, label: string, @IConfigurationService configurationService: IConfigurationService,
|
||||
@IWorkbenchEditorService editorService: IWorkbenchEditorService, @IFileService fileService: IFileService,
|
||||
@IWorkspaceContextService contextService: IWorkspaceContextService, @IOutputService outputService: IOutputService,
|
||||
@IMessageService messageService: IMessageService, @IQuickOpenService quickOpenService: IQuickOpenService,
|
||||
@IEnvironmentService environmentService: IEnvironmentService) {
|
||||
super(id, label, configurationService, editorService, fileService, contextService,
|
||||
outputService, messageService, quickOpenService, environmentService);
|
||||
}
|
||||
}
|
||||
|
||||
class CloseMessageAction extends Action {
|
||||
|
||||
public static ID = 'workbench.action.build.closeMessage';
|
||||
|
@ -754,6 +780,12 @@ class TaskService extends EventEmitter implements ITaskService {
|
|||
this.outputService, this.messageService, this.quickOpenService, this.environmentService);
|
||||
}
|
||||
|
||||
private configureBuildTask(): Action {
|
||||
return new ConfigureBuildTaskAction(ConfigureBuildTaskAction.ID, ConfigureBuildTaskAction.TEXT,
|
||||
this.configurationService, this.editorService, this.fileService, this.contextService,
|
||||
this.outputService, this.messageService, this.quickOpenService, this.environmentService);
|
||||
}
|
||||
|
||||
public build(): TPromise<ITaskSummary> {
|
||||
return this.executeTarget(taskSystem => taskSystem.build());
|
||||
}
|
||||
|
@ -878,6 +910,14 @@ class TaskService extends EventEmitter implements ITaskService {
|
|||
return false; // Nothing to do here
|
||||
}
|
||||
|
||||
private getConfigureAction(code: TaskErrors): Action {
|
||||
switch(code) {
|
||||
case TaskErrors.NoBuildTask:
|
||||
return this.configureBuildTask();
|
||||
default:
|
||||
return this.configureAction();
|
||||
}
|
||||
}
|
||||
private handleError(err:any):void {
|
||||
let showOutput = true;
|
||||
if (err instanceof TaskError) {
|
||||
|
@ -887,7 +927,7 @@ class TaskService extends EventEmitter implements ITaskService {
|
|||
if (needsConfig || needsTerminate) {
|
||||
let closeAction = new CloseMessageAction();
|
||||
let action = needsConfig
|
||||
? this.configureAction()
|
||||
? this.getConfigureAction(buildError.code)
|
||||
: new TerminateAction(TerminateAction.ID, TerminateAction.TEXT, this, this.telemetryService, this.messageService, this.contextService);
|
||||
|
||||
closeAction.closeFunction = this.messageService.show(buildError.severity, { message: buildError.message, actions: [closeAction, action ] });
|
||||
|
|
|
@ -21,6 +21,7 @@ import * as FileConfig from './processRunnerConfiguration';
|
|||
|
||||
let build: string = 'build';
|
||||
let test: string = 'test';
|
||||
let defaultValue: string = 'default';
|
||||
|
||||
interface TaskInfo {
|
||||
index: number;
|
||||
|
@ -341,12 +342,15 @@ export class ProcessRunnerDetector {
|
|||
|
||||
private testBuild(taskInfo: TaskInfo, taskName: string, index: number):void {
|
||||
if (taskName === build) {
|
||||
taskInfo.index = index;
|
||||
taskInfo.exact = 4;
|
||||
} else if ((Strings.startsWith(taskName, build) || Strings.endsWith(taskName, build)) && taskInfo.exact < 4) {
|
||||
taskInfo.index = index;
|
||||
taskInfo.exact = 3;
|
||||
} else if ((Strings.startsWith(taskName, build) || Strings.endsWith(taskName, build)) && taskInfo.exact < 3) {
|
||||
} else if (taskName.indexOf(build) !== -1 && taskInfo.exact < 3) {
|
||||
taskInfo.index = index;
|
||||
taskInfo.exact = 2;
|
||||
} else if (taskName.indexOf(build) !== -1 && taskInfo.exact < 2) {
|
||||
} else if (taskName === defaultValue && taskInfo.exact < 2) {
|
||||
taskInfo.index = index;
|
||||
taskInfo.exact = 1;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ export class ProcessRunnerSystem extends EventEmitter implements ITaskSystem {
|
|||
|
||||
public build(): ITaskRunResult {
|
||||
if (!this.defaultBuildTaskIdentifier) {
|
||||
throw new TaskError(Severity.Info, nls.localize('TaskRunnerSystem.noBuildTask', 'No build task configured.'), TaskErrors.NoBuildTask);
|
||||
throw new TaskError(Severity.Info, nls.localize('TaskRunnerSystem.noBuildTask', 'No task is marked as a build task in the tasks.json. Mark a task with \'isBuildCommand\'.'), TaskErrors.NoBuildTask);
|
||||
}
|
||||
return this.executeTask(this.defaultBuildTaskIdentifier, Triggers.shortcut);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue