提交 f4dfed42 编写于 作者: I isidor

debug: show warnings in launch.json for relative paths

fixes #1575
上级 48127859
......@@ -93,7 +93,7 @@ export class ReplExpressionsRenderer implements tree.IRenderer {
private static VALUE_OUTPUT_TEMPLATE_ID = 'outputValue';
private static KEY_VALUE_OUTPUT_TEMPLATE_ID = 'outputKeyValue';
private static FILE_LOCATION_PATTERNS:RegExp[] = [
private static FILE_LOCATION_PATTERNS: RegExp[] = [
// group 0: the full thing :)
// group 1: absolute path
// group 2: drive letter on windows with trailing backslash or leading slash on mac/linux
......@@ -101,7 +101,7 @@ export class ReplExpressionsRenderer implements tree.IRenderer {
// group 4: column number
// eg: at Context.<anonymous> (c:\Users\someone\Desktop\mocha-runner\test\test.js:26:11)
/((\/|[a-zA-Z]:\\)[^\(\)<>\'\"\[\]]+):(\d+):(\d+)/
]
];
private width: number;
private characterWidth: number;
......
......@@ -81,23 +81,28 @@ export class Adapter {
if (!attributes.properties) {
attributes.properties = { };
}
attributes.properties.type = {
const properties = attributes.properties;
properties.type = {
enum: [this.type],
description: nls.localize('debugType', "Type of configuration.")
};
attributes.properties.name = {
properties.name = {
type: 'string',
description: nls.localize('debugName', "Name of configuration; appears in the launch configuration drop down menu."),
default: 'Launch'
};
attributes.properties.request = {
properties.request = {
enum: [request],
description: nls.localize('debugRequest', "Request type of configuration. Can be \"launch\" or \"attach\"."),
};
attributes.properties.preLaunchTask = {
properties.preLaunchTask = {
type: 'string',
description: nls.localize('debugPrelaunchTask', "Task to run before debug session starts.")
};
this.warnRelativePaths(properties.outDir);
this.warnRelativePaths(properties.program);
this.warnRelativePaths(properties.cwd);
this.warnRelativePaths(properties.runtimeExecutable);
return attributes;
});
......@@ -105,4 +110,11 @@ export class Adapter {
return null;
}
private warnRelativePaths(attribute: any): void {
if (attribute) {
attribute.pattern = '^\\${.*}.*|^((\\/|[a-zA-Z]:\\\\)[^\\(\\)<>\\\'\\"\\[\\]]+)';
attribute.errorMessage = nls.localize('relativePathsNotConverted', "Relative paths will no longer be converted to absolute ones. Consider using ${workspaceRoot} as a prefix.");
}
}
}
......@@ -19,7 +19,6 @@ import jsonContributionRegistry = require('vs/platform/jsonschemas/common/jsonCo
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IFileService } from 'vs/platform/files/common/files';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IMessageService } from 'vs/platform/message/common/message';
import debug = require('vs/workbench/parts/debug/common/debug');
import { SystemVariables } from 'vs/workbench/parts/lib/node/systemVariables';
import { Adapter } from 'vs/workbench/parts/debug/node/debugAdapter';
......@@ -158,11 +157,10 @@ export class ConfigurationManager {
@ITelemetryService private telemetryService: ITelemetryService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IConfigurationService private configurationService: IConfigurationService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IMessageService private messageService: IMessageService
@IQuickOpenService private quickOpenService: IQuickOpenService
) {
this.systemVariables = this.contextService.getWorkspace() ? new SystemVariables(this.editorService, this.contextService) : null;
this.setConfiguration(configName, true);
this.setConfiguration(configName);
this.adapters = [];
this.registerListeners();
this.allModeIdsForBreakpoints = {};
......@@ -226,7 +224,7 @@ export class ConfigurationManager {
return this.adapters.filter(adapter => adapter.type === this.configuration.type).pop();
}
public setConfiguration(name: string, silent = false): Promise {
public setConfiguration(name: string): Promise {
return this.loadLaunchConfig().then(config => {
if (!config || !config.configurations) {
this.configuration = null;
......@@ -246,13 +244,13 @@ export class ConfigurationManager {
}
this.configuration.debugServer = config.debugServer;
this.configuration.outDir = this.resolvePath(this.configuration.outDir, silent);
this.configuration.outDir = this.resolvePath(this.configuration.outDir);
this.configuration.address = this.configuration.address || 'localhost';
this.configuration.program = this.resolvePath(this.configuration.program, silent);
this.configuration.program = this.resolvePath(this.configuration.program);
this.configuration.stopOnEntry = this.configuration.stopOnEntry === undefined ? false : this.configuration.stopOnEntry;
this.configuration.args = this.configuration.args && this.configuration.args.length > 0 ? this.systemVariables.resolve(this.configuration.args) : null;
this.configuration.cwd = this.resolvePath(this.configuration.cwd || '.', true);
this.configuration.runtimeExecutable = this.resolvePath(this.configuration.runtimeExecutable, silent);
this.configuration.cwd = this.resolvePath(this.configuration.cwd || '.');
this.configuration.runtimeExecutable = this.resolvePath(this.configuration.runtimeExecutable);
this.configuration.runtimeArgs = this.configuration.runtimeArgs && this.configuration.runtimeArgs.length > 0 ? this.configuration.runtimeArgs : null;
}
});
......@@ -344,16 +342,13 @@ export class ConfigurationManager {
return !!this.allModeIdsForBreakpoints[modeId];
}
private resolvePath(p: string, silent: boolean): string {
private resolvePath(p: string): string {
if (!p) {
return null;
}
if (path.isAbsolute(p)) {
return paths.normalize(p, true);
}
if (!silent) {
this.messageService.show(Severity.Warning, 'Relative paths in \'launch.json\' will no longer be supported, use \'${workspaceRoot}/' + p + '\' instead.');
}
return paths.normalize(uri.file(paths.join(this.contextService.getWorkspace().resource.fsPath, p)).fsPath, true);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册