提交 8408ca4a 编写于 作者: I isidor

debug: lint in node/ and electron-browser

上级 5ef5a112
......@@ -55,7 +55,7 @@ CommonEditorRegistry.registerEditorAction(new EditorActionDescriptor(dbgactions.
CommonEditorRegistry.registerEditorAction(new EditorActionDescriptor(dbgactions.SelectionToWatchExpressionsAction, dbgactions.SelectionToWatchExpressionsAction.ID, nls.localize('addToWatch', "Debug: Add to Watch")));
CommonEditorRegistry.registerEditorAction(new EditorActionDescriptor(dbgactions.RunToCursorAction, dbgactions.RunToCursorAction.ID, nls.localize('runToCursor', "Debug: Run to Cursor")));
// Register Viewlet
// register viewlet
(<viewlet.IViewletRegistry>platform.Registry.as(viewlet.Extensions.Viewlets)).registerViewlet(new viewlet.ViewletDescriptor(
'vs/workbench/parts/debug/browser/debugViewlet',
'DebugViewlet',
......@@ -65,11 +65,11 @@ CommonEditorRegistry.registerEditorAction(new EditorActionDescriptor(dbgactions.
40
));
var openViewletKb: IKeybindings = {
const openViewletKb: IKeybindings = {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_D
};
// Register repl editor
// register repl editor
platform.Registry.as(baseeditor.Extensions.Editors).registerEditor(
new baseeditor.EditorDescriptor(repleditor.Repl.ID, 'Repl', 'vs/workbench/parts/debug/browser/replEditor', 'Repl'),
new SyncDescriptor(editorinputs.ReplEditorInput));
......@@ -78,14 +78,14 @@ let actionBarRegistry = <actionbarregistry.IActionBarRegistry> platform.Registry
actionBarRegistry.registerActionBarContributor(actionbarregistry.Scope.EDITOR, repleditor.ReplEditorActionContributor);
(<baseeditor.IEditorRegistry>platform.Registry.as(baseeditor.Extensions.Editors)).registerEditorInputFactory(editorinputs.ReplEditorInput.ID, repleditor.ReplInputFactory);
// Register Action to Open Viewlet
var registry = (<wbaregistry.IWorkbenchActionRegistry> platform.Registry.as(wbaregistry.Extensions.WorkbenchActions));
// register action to open viewlet
const registry = (<wbaregistry.IWorkbenchActionRegistry> platform.Registry.as(wbaregistry.Extensions.WorkbenchActions));
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenDebugViewletAction, OpenDebugViewletAction.ID, OpenDebugViewletAction.LABEL, openViewletKb), nls.localize('view', "View"));
(<wbext.IWorkbenchContributionsRegistry>platform.Registry.as(wbext.Extensions.Workbench)).registerWorkbenchContribution(DebugEditorModelManager);
(<wbext.IWorkbenchContributionsRegistry>platform.Registry.as(wbext.Extensions.Workbench)).registerWorkbenchContribution(debugwidget.DebugActionsWidget);
var debugCategory = nls.localize('debugCategory', "Debug");
const debugCategory = nls.localize('debugCategory', "Debug");
registry.registerWorkbenchAction(new SyncActionDescriptor(
dbgactions.StartDebugAction, dbgactions.StartDebugAction.ID, dbgactions.StartDebugAction.LABEL, { primary: KeyCode.F5 }, [{ key: debug.CONTEXT_IN_DEBUG_MODE, operator: KeybindingsRegistry.KEYBINDING_CONTEXT_OPERATOR_NOT_EQUAL, operand: true }]), debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(dbgactions.StepOverDebugAction, dbgactions.StepOverDebugAction.ID, dbgactions.StepOverDebugAction.LABEL, { primary: KeyCode.F10 }, [{ key: debug.CONTEXT_IN_DEBUG_MODE }]), debugCategory);
......@@ -98,5 +98,5 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(dbgactions.PauseAction
registry.registerWorkbenchAction(new SyncActionDescriptor(dbgactions.ConfigureAction, dbgactions.ConfigureAction.ID, dbgactions.ConfigureAction.LABEL), debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(dbgactions.OpenReplAction, dbgactions.OpenReplAction.ID, dbgactions.OpenReplAction.LABEL), debugCategory);
// Register Service
// register service
registerSingleton(IDebugService, service.DebugService);
......@@ -20,8 +20,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybindingServ
import remote = require('remote');
import IDebugService = debug.IDebugService;
var clipboard = remote.require('clipboard');
var registry = <wbaregistry.IWorkbenchActionRegistry> platform.Registry.as(wbaregistry.Extensions.WorkbenchActions);
const clipboard = remote.require('clipboard');
export class AbstractDebugAction extends actions.Action {
......@@ -36,8 +35,8 @@ export class AbstractDebugAction extends actions.Action {
this.toDispose = [];
this.toDispose.push(this.debugService.addListener2(debug.ServiceEvents.STATE_CHANGED, () => this.updateEnablement()));
var keybinding: string = null;
var keys = this.keybindingService.lookupKeybindings(id).map(k => this.keybindingService.getLabelFor(k));
let keybinding: string = null;
const keys = this.keybindingService.lookupKeybindings(id).map(k => this.keybindingService.getLabelFor(k));
if (keys && keys.length) {
keybinding = keys[0];
}
......@@ -80,7 +79,7 @@ export class ConfigureAction extends AbstractDebugAction {
}
public run(event?: any): Promise {
var sideBySide = !!(event && (event.ctrlKey || event.metaKey));
const sideBySide = !!(event && (event.ctrlKey || event.metaKey));
return this.debugService.openConfigFile(sideBySide);
}
}
......@@ -396,14 +395,14 @@ export class AddFunctionBreakpointAction extends AbstractDebugAction {
export class ToggleBreakpointAction extends EditorAction {
static ID = 'editor.debug.action.toggleBreakpoint';
constructor(descriptor:editorCommon.IEditorActionDescriptorData, editor:editorCommon.ICommonCodeEditor, @IDebugService private debugService: IDebugService) {
constructor(descriptor: editorCommon.IEditorActionDescriptorData, editor: editorCommon.ICommonCodeEditor, @IDebugService private debugService: IDebugService) {
super(descriptor, editor, Behaviour.TextFocus);
}
public run(): TPromise<boolean> {
if (this.debugService.getState() !== debug.State.Disabled) {
var lineNumber = this.editor.getPosition().lineNumber;
var modelUrl = this.editor.getModel().getAssociatedResource();
const lineNumber = this.editor.getPosition().lineNumber;
const modelUrl = this.editor.getModel().getAssociatedResource();
if (this.debugService.canSetBreakpointsIn(this.editor.getModel(), lineNumber)) {
return this.debugService.toggleBreakpoint({ uri: modelUrl, lineNumber: lineNumber });
}
......@@ -446,8 +445,8 @@ export class RunToCursorAction extends EditorAction {
}
public run(): TPromise<boolean> {
var lineNumber = this.editor.getPosition().lineNumber;
var uri = this.editor.getModel().getAssociatedResource();
const lineNumber = this.editor.getPosition().lineNumber;
const uri = this.editor.getModel().getAssociatedResource();
this.debugService.getActiveSession().addOneTimeListener(debug.SessionEvents.STOPPED, () => {
this.debugService.toggleBreakpoint({ uri, lineNumber });
......@@ -469,11 +468,11 @@ export class RunToCursorAction extends EditorAction {
return false;
}
var lineNumber = this.editor.getPosition().lineNumber;
var uri = this.editor.getModel().getAssociatedResource();
var bps = this.debugService.getModel().getBreakpoints().filter(bp => bp.lineNumber === lineNumber && bp.source.uri.toString() === uri.toString());
const lineNumber = this.editor.getPosition().lineNumber;
const uri = this.editor.getModel().getAssociatedResource();
const bps = this.debugService.getModel().getBreakpoints().filter(bp => bp.lineNumber === lineNumber && bp.source.uri.toString() === uri.toString());
// Breakpoint must not be on position (no need for this action).
// breakpoint must not be on position (no need for this action).
return bps.length === 0;
}
}
......@@ -504,7 +503,7 @@ export class SelectionToWatchExpressionsAction extends EditorAction {
}
public run(): TPromise<boolean> {
var text = this.editor.getModel().getValueInRange(this.editor.getSelection());
const text = this.editor.getModel().getValueInRange(this.editor.getSelection());
return this.viewletService.openViewlet(debug.VIEWLET_ID).then(() => this.debugService.addWatchExpression(text));
}
......@@ -513,8 +512,8 @@ export class SelectionToWatchExpressionsAction extends EditorAction {
}
public shouldShowInContextMenu(): boolean {
var selection = this.editor.getSelection();
var text = this.editor.getModel().getValueInRange(selection);
const selection = this.editor.getSelection();
const text = this.editor.getModel().getValueInRange(selection);
return !!selection && !selection.isEmpty() && this.debugService.getState() !== debug.State.Inactive && text && /\S/.test(text);
}
......@@ -528,7 +527,7 @@ export class SelectionToReplAction extends EditorAction {
}
public run(): TPromise<boolean> {
var text = this.editor.getModel().getValueInRange(this.editor.getSelection());
const text = this.editor.getModel().getValueInRange(this.editor.getSelection());
return this.debugService.addReplExpression(text).then(() => this.debugService.revealRepl());
}
......@@ -537,9 +536,7 @@ export class SelectionToReplAction extends EditorAction {
}
public shouldShowInContextMenu(): boolean {
var selection = this.editor.getSelection();
var text = this.editor.getModel().getValueInRange(selection);
const selection = this.editor.getSelection();
return !!selection && !selection.isEmpty() && this.debugService.getState() === debug.State.Stopped;
}
}
......
......@@ -69,31 +69,31 @@ export class Adapter {
}
public getSchemaAttributes(): any[] {
// Fill in the default configuration attributes shared by all adapters.
// fill in the default configuration attributes shared by all adapters.
if (this.configurationAttributes) {
return Object.keys(this.configurationAttributes).map(request => {
const attributes = this.configurationAttributes[request];
const defaultRequired = ['name', 'type', 'request'];
attributes["required"] = attributes["required"] && attributes["required"].length ? defaultRequired.concat(attributes["required"]) : defaultRequired;
attributes['additionalProperties'] = false;
attributes['type'] = 'object';
if (!attributes['properties']) {
attributes['properties'] = { };
attributes.required = attributes.required && attributes.required.length ? defaultRequired.concat(attributes.required) : defaultRequired;
attributes.additionalProperties = false;
attributes.type = 'object';
if (!attributes.properties) {
attributes.properties = { };
}
attributes['properties']['type'] = {
attributes.properties.type = {
enum: [this.type],
description: 'Type of configuration.',
};
attributes['properties']['name'] = {
attributes.properties.name = {
type: 'string',
description: 'Name of configuration; appears in the launch configuration drop down menu.',
default: 'Launch'
};
attributes['properties']['request'] = {
attributes.properties.request = {
enum: [request],
description: 'Request type of configuration. Can be "launch" or "attach".',
};
attributes['properties']['preLaunchTask'] = {
attributes.properties.preLaunchTask = {
type: 'string',
description: 'Task to run before debug session starts.'
};
......
......@@ -26,7 +26,7 @@ import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService';
// Debuggers extension point
// debuggers extension point
export var debuggersExtPoint = pluginsRegistry.PluginsRegistry.registerExtensionPoint<debug.IRawAdapter[]>('debuggers', {
description: nls.localize('vscode.extension.contributes.debuggers', 'Contributes debug adapters.'),
......@@ -115,10 +115,10 @@ export var debuggersExtPoint = pluginsRegistry.PluginsRegistry.registerExtension
}
});
// Debug General Schema
// debug general schema
export var schemaId = 'local://schemas/launch';
var schema: IJSONSchema = {
const schema: IJSONSchema = {
id: schemaId,
type: 'object',
title: nls.localize('app.launch.json.title', "Launch configuration"),
......@@ -139,7 +139,7 @@ var schema: IJSONSchema = {
}
}
var jsonRegistry = <jsonContributionRegistry.IJSONContributionRegistry>platform.Registry.as(jsonContributionRegistry.Extensions.JSONContribution);
const jsonRegistry = <jsonContributionRegistry.IJSONContributionRegistry>platform.Registry.as(jsonContributionRegistry.Extensions.JSONContribution);
jsonRegistry.registerSchema(schemaId, schema);
jsonRegistry.addSchemaFileAssociation('/.vscode/launch.json', schemaId);
......@@ -184,7 +184,7 @@ export class ConfigurationManager {
if (attribute === 'enableBreakpointsFor') {
Object.keys(adapter.enableBreakpointsFor).forEach(languageId => duplicate.enableBreakpointsFor[languageId] = true);
} else if (duplicate[attribute] && attribute !== 'type') {
// Give priority to the later registered extension.
// give priority to the later registered extension.
duplicate[attribute] = adapter[attribute];
extension.collector.error(nls.localize('duplicateDebuggerType', "Debug type '{0}' is already registered and has attribute '{1}', ignoring attribute '{1}'.", adapter.type, attribute));
} else {
......@@ -202,7 +202,7 @@ export class ConfigurationManager {
});
});
// Update the schema to include all attributes and types from extensions.
// update the schema to include all attributes and types from extensions.
// debug.schema.properties['configurations'].items.properties.type.enum = this.adapters.map(adapter => adapter.type);
this.adapters.forEach(adapter => {
const schemaAttributes = adapter.getSchemaAttributes();
......@@ -232,10 +232,10 @@ export class ConfigurationManager {
return;
}
// If the configuration name is not set yet, take the first launch config (can happen if debug viewlet has not been opened yet).
// if the configuration name is not set yet, take the first launch config (can happen if debug viewlet has not been opened yet).
const filtered = name ? config.configurations.filter(cfg => cfg.name === name) : [config.configurations[0]];
// Massage configuration attributes - append workspace path to relatvie paths, substitute variables in paths.
// massage configuration attributes - append workspace path to relatvie paths, substitute variables in paths.
this.configuration = filtered.length === 1 ? filtered[0] : null;
if (this.configuration) {
if (this.systemVariables) {
......@@ -306,7 +306,7 @@ export class ConfigurationManager {
return Promise.as(true);
}
// Check package.json for 'main' or 'scripts' so we generate a more pecise 'program' attribute in launch.json.
// check package.json for 'main' or 'scripts' so we generate a more pecise 'program' attribute in launch.json.
const packageJsonUri = uri.file(paths.join(this.contextService.getWorkspace().resource.fsPath, '/package.json'));
return this.fileService.resolveContent(packageJsonUri).then(jsonContent => {
try {
......@@ -322,8 +322,8 @@ export class ConfigurationManager {
return null;
}, err => null).then(program => {
adapter.initialConfigurations.forEach(config => {
if (program && config["program"]) {
config["program"] = program;
if (program && config.program) {
config.program = program;
}
});
});
......@@ -337,8 +337,8 @@ export class ConfigurationManager {
return false;
}
var mode = model ? model.getMode() : null;
var modeId = mode ? mode.getId() : null;
const mode = model ? model.getMode() : null;
const modeId = mode ? mode.getId() : null;
return !!this.allModeIdsForBreakpoints[modeId];
}
......
......@@ -54,8 +54,8 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
protected send(command: string, args: any): TPromise<DebugProtocol.Response> {
return this.initServer().then(() => super.send(command, args).then(response => response, (errorResponse: DebugProtocol.ErrorResponse) => {
var error = errorResponse.body ? errorResponse.body.error : null;
var message = error ? debug.formatPII(error.format, false, error.variables) : errorResponse.message;
const error = errorResponse.body ? errorResponse.body.error : null;
const message = error ? debug.formatPII(error.format, false, error.variables) : errorResponse.message;
if (error && error.sendTelemetry) {
this.telemetryService.publicLog('debugProtocolErrorResponse', { error : message });
}
......@@ -94,11 +94,11 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
return this.sendAndLazyEmit('continue', args);
}
// Node sometimes sends "stopped" events earlier than the response for the "step" request.
// Due to this we only emit "continued" if we did not miss a stopped event.
// We do not emit straight away to reduce viewlet flickering.
// node sometimes sends "stopped" events earlier than the response for the "step" request.
// due to this we only emit "continued" if we did not miss a stopped event.
// we do not emit straight away to reduce viewlet flickering.
private sendAndLazyEmit(command: string, args: any, eventType = debug.SessionEvents.CONTINUED): TPromise<DebugProtocol.Response> {
var count = this.flowEventsCount;
const count = this.flowEventsCount;
return this.send(command, args).then(response => {
setTimeout(() => {
if (this.flowEventsCount === count) {
......@@ -168,8 +168,6 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
return this.adapter.type;
}
//---- private
private connectServer(port: number): Promise {
return new Promise((c, e) => {
this.socket = net.createConnection(port, null, () => {
......@@ -191,10 +189,10 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
this.serverProcess.on('error', (err: Error) => this.onServerError(err));
this.serverProcess.on('exit', (code: number, signal: string) => this.onServerExit());
var sanitize = (s: string) => s.toString().replace(/\r?\n$/mg, '');
// this.serverProcess.stdout.on('data', (data: string) => {
// console.log('%c' + sanitize(data), 'background: #ddd; font-style: italic;');
// });
const sanitize = (s: string) => s.toString().replace(/\r?\n$/mg, '');
// this.serverProcess.stdout.on('data', (data: string) => {
// console.log('%c' + sanitize(data), 'background: #ddd; font-style: italic;');
// });
this.serverProcess.stderr.on('data', (data: string) => {
console.log(sanitize(data));
});
......@@ -240,13 +238,13 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
this.stopServerPending = true;
var ret: Promise;
let ret: Promise;
// when killing a process in windows its child
// processes are *not* killed but become root
// processes. Therefore we use TASKKILL.EXE
if (platform.isWindows) {
ret = new Promise((c, e) => {
var killer = cp.exec(`taskkill /F /T /PID ${this.serverProcess.pid}`, function (err, stdout, stderr) {
const killer = cp.exec(`taskkill /F /T /PID ${this.serverProcess.pid}`, function (err, stdout, stderr) {
if (err) {
return e(err);
}
......
......@@ -78,7 +78,7 @@ export class V8Protocol extends ee.EventEmitter {
private doSend(command: string, args: any, clb: (result: DebugProtocol.Response) => void): void {
var request: DebugProtocol.Request = {
const request: DebugProtocol.Request = {
type: 'request',
seq: this.sequence++,
command: command
......@@ -90,8 +90,8 @@ export class V8Protocol extends ee.EventEmitter {
// store callback for this request
this.pendingRequests[request.seq] = clb;
var json = JSON.stringify(request);
var length = Buffer.byteLength(json, 'utf8');
const json = JSON.stringify(request);
const length = Buffer.byteLength(json, 'utf8');
this.outputStream.write('Content-Length: ' + length.toString() + V8Protocol.TWO_CRLF, 'utf8');
this.outputStream.write(json, 'utf8');
......@@ -101,7 +101,7 @@ export class V8Protocol extends ee.EventEmitter {
while (true) {
if (this.contentLength >= 0) {
if (this.rawData.length >= this.contentLength) {
var message = this.rawData.toString('utf8', 0, this.contentLength);
const message = this.rawData.toString('utf8', 0, this.contentLength);
this.rawData = this.rawData.slice(this.contentLength);
this.contentLength = -1;
if (message.length > 0) {
......@@ -110,10 +110,10 @@ export class V8Protocol extends ee.EventEmitter {
continue; // there may be more complete messages to process
}
} else {
var s = this.rawData.toString('utf8', 0, this.rawData.length);
var idx = s.indexOf(V8Protocol.TWO_CRLF);
const s = this.rawData.toString('utf8', 0, this.rawData.length);
const idx = s.indexOf(V8Protocol.TWO_CRLF);
if (idx !== -1) {
var match = /Content-Length: (\d+)/.exec(s);
const match = /Content-Length: (\d+)/.exec(s);
if (match && match[1]) {
this.contentLength = Number(match[1]);
this.rawData = this.rawData.slice(idx + V8Protocol.TWO_CRLF.length);
......@@ -126,14 +126,14 @@ export class V8Protocol extends ee.EventEmitter {
}
private dispatch(body: string): void {
var rawData = JSON.parse(body);
const rawData = JSON.parse(body);
if (typeof rawData.event !== 'undefined') {
var event = <DebugProtocol.Event> rawData;
const event = <DebugProtocol.Event> rawData;
this.emit(event.event, event);
} else {
var response = <DebugProtocol.Response> rawData;
var clb = this.pendingRequests[response.request_seq];
const response = <DebugProtocol.Response> rawData;
const clb = this.pendingRequests[response.request_seq];
if (clb) {
delete this.pendingRequests[response.request_seq];
clb(response);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册