public NodeBreakpointBinding(NodeBreakpoint breakpoint, FilePosition target, FilePosition position, int breakpointId, int? scriptId, bool fullyBound) { _breakpoint = breakpoint; _target = target; _position = position; _breakpointId = breakpointId; _scriptId = scriptId; _enabled = breakpoint.Enabled; _breakOn = breakpoint.BreakOn; _condition = breakpoint.Condition; _engineEnabled = GetEngineEnabled(); _engineIgnoreCount = GetEngineIgnoreCount(); _fullyBould = fullyBound; }
public NodeBreakpointBinding(NodeBreakpoint breakpoint, FilePosition target, FilePosition position, int breakpointId, int?scriptId, bool fullyBound) { this._breakpoint = breakpoint; this._target = target; this._position = position; this._breakpointId = breakpointId; this._scriptId = scriptId; this._enabled = breakpoint.Enabled; this._breakOn = breakpoint.BreakOn; this._condition = breakpoint.Condition; this._engineEnabled = GetEngineEnabled(); this._engineIgnoreCount = GetEngineIgnoreCount(); this._fullyBould = fullyBound; }
public void CreateSetBreakpointCommandOnRemoteFile() { // Arrange const int commandId = 3; const int line = 2; const int column = 0; const string fileName = @"module.js"; var breakOn = new BreakOn(BreakOnKind.Equal, 2); var position = new FilePosition(fileName, line, column); var breakpoint = new NodeBreakpoint(null, position, true, breakOn, null); // Act var setBreakpointCommand = new SetBreakpointCommand(commandId, null, breakpoint, false, true); // Assert Assert.AreEqual(commandId, setBreakpointCommand.Id); Assert.AreEqual( string.Format( "{{\"command\":\"setbreakpoint\",\"seq\":{0},\"type\":\"request\",\"arguments\":{{\"line\":{1},\"column\":{2},\"type\":\"scriptRegExp\",\"target\":\"^[Mm][Oo][Dd][Uu][Ll][Ee]\\\\.[Jj][Ss]$\",\"ignoreCount\":1}}}}", commandId, line, column), setBreakpointCommand.ToString()); }
public void CreateSetBreakpointCommand() { // Arrange const int commandId = 3; const int moduleId = 5; const int line = 2; const int column = 0; const string fileName = "module.js"; var module = new NodeModule(moduleId, fileName); var breakOn = new BreakOn(BreakOnKind.Equal, 2); var position = new FilePosition(fileName, line, column); var breakpoint = new NodeBreakpoint(null, position, true, breakOn, null); // Act var setBreakpointCommand = new SetBreakpointCommand(commandId, module, breakpoint, false, false); // Assert Assert.AreEqual(commandId, setBreakpointCommand.Id); Assert.AreEqual( string.Format( "{{\"command\":\"setbreakpoint\",\"seq\":{0},\"type\":\"request\",\"arguments\":{{\"line\":{1},\"column\":{2},\"type\":\"scriptId\",\"target\":{3},\"ignoreCount\":1}}}}", commandId, line, column, module.Id), setBreakpointCommand.ToString()); }
public BreakpointBindingEventArgs(NodeBreakpoint breakpoint, NodeBreakpointBinding breakpointBinding) { _breakpoint = breakpoint; _breakpointBinding = breakpointBinding; }
private async Task<SetBreakpointCommand> SetBreakpointAsync( NodeBreakpoint breakpoint, bool withoutPredicate = false, CancellationToken cancellationToken = new CancellationToken()) { DebugWriteCommand("Set Breakpoint"); // Try to find module NodeModule module = GetModuleForFilePath(breakpoint.Target.FileName); var setBreakpointCommand = new SetBreakpointCommand(CommandId, module, breakpoint, withoutPredicate, IsRemote, SourceMapper); await TrySendRequestAsync(setBreakpointCommand, cancellationToken).ConfigureAwait(false); return setBreakpointCommand; }
public async Task<NodeBreakpointBinding> BindBreakpointAsync(NodeBreakpoint breakpoint, CancellationToken cancellationToken = new CancellationToken()) { SetBreakpointCommand result = await SetBreakpointAsync(breakpoint, cancellationToken: cancellationToken).ConfigureAwait(false); var position = breakpoint.GetPosition(SourceMapper); bool fullyBound = (result.ScriptId.HasValue && result.Line == position.Line); NodeBreakpointBinding breakpointBinding = CreateBreakpointBinding(breakpoint, result.BreakpointId, result.ScriptId, position.FileName, result.Line, result.Column, fullyBound); // Fully bound (normal case) // Treat as success if (fullyBound) { HandleBindBreakpointSuccess(breakpointBinding, breakpoint); return breakpointBinding; } // Not fully bound, with predicate // Rebind without predicate if (breakpoint.HasPredicate) { await RemoveBreakpointAsync(breakpointBinding, cancellationToken).ConfigureAwait(false); result = await SetBreakpointAsync(breakpoint, true, cancellationToken).ConfigureAwait(false); Debug.Assert(!(result.ScriptId.HasValue && result.Line == position.Line)); CreateBreakpointBinding(breakpoint, result.BreakpointId, result.ScriptId, position.FileName, result.Line, result.Column, false); } // Not fully bound, without predicate // Treat as failure (for now) HandleBindBreakpointFailure(breakpoint); return null; }
private void HandleBindBreakpointFailure(NodeBreakpoint breakpoint) { EventHandler<BreakpointBindingEventArgs> breakpointBindFailure = BreakpointBindFailure; if (breakpointBindFailure != null) { breakpointBindFailure(this, new BreakpointBindingEventArgs(breakpoint, null)); } }
private void HandleBindBreakpointSuccess(NodeBreakpointBinding breakpointBinding, NodeBreakpoint breakpoint) { EventHandler<BreakpointBindingEventArgs> breakpointBound = BreakpointBound; if (breakpointBound != null) { breakpointBound(this, new BreakpointBindingEventArgs(breakpoint, breakpointBinding)); } }
private NodeBreakpointBinding CreateBreakpointBinding(NodeBreakpoint breakpoint, int breakpointId, int? scriptId, string filename, int line, int column, bool fullyBound) { var position = new FilePosition(filename, line, column); FilePosition target = position; SourceMapInfo mapping = SourceMapper.MapToOriginal(filename, line, column); if (mapping != null) { target = new FilePosition(breakpoint.Target.FileName, mapping.Line, mapping.Column); } NodeBreakpointBinding breakpointBinding = breakpoint.CreateBinding(target, position, breakpointId, scriptId, fullyBound); _breakpointBindings[breakpointId] = breakpointBinding; return breakpointBinding; }
public void ProcessSetBreakpointResponse() { // Arrange const int commandId = 3; const int moduleId = 33; const int line = 2; const int column = 0; const string fileName = "module.js"; var module = new NodeModule(moduleId, fileName); var breakOn = new BreakOn(BreakOnKind.Equal, 2); var position = new FilePosition(fileName, line, column); var breakpoint = new NodeBreakpoint(null, position, true, breakOn, null); var setBreakpointCommand = new SetBreakpointCommand(commandId, module, breakpoint, false, false); JObject breakpointResponse = SerializationTestData.GetSetBreakpointResponse(); // Act setBreakpointCommand.ProcessResponse(breakpointResponse); // Assert Assert.AreEqual(2, setBreakpointCommand.BreakpointId); Assert.AreEqual(0, setBreakpointCommand.Column); Assert.AreEqual(0, setBreakpointCommand.Line); Assert.AreEqual(false, setBreakpointCommand.Running); Assert.AreEqual(33, setBreakpointCommand.ScriptId); }
public void CreateSetBreakpointCommandOnLocalFile() { // Arrange const int commandId = 3; const int line = 2; const int column = 0; const string fileName = @"c:\module.js"; var breakOn = new BreakOn(BreakOnKind.Equal, 2); var position = new FilePosition(fileName, line, column); var breakpoint = new NodeBreakpoint(null, position, true, breakOn, null); // Act var setBreakpointCommand = new SetBreakpointCommand(commandId, null, breakpoint, false, false); // Assert Assert.AreEqual(commandId, setBreakpointCommand.Id); Assert.AreEqual( string.Format( "{{\"command\":\"setbreakpoint\",\"seq\":{0},\"type\":\"request\",\"arguments\":{{\"line\":{1},\"column\":{2},\"type\":\"scriptRegExp\",\"target\":\"{3}\",\"ignoreCount\":1}}}}", commandId, line, column, SetBreakpointCommand.CreateLocalScriptRegExp(fileName).Replace(@"\", @"\\")), setBreakpointCommand.ToString()); }
public BreakpointBindingEventArgs(NodeBreakpoint breakpoint, NodeBreakpointBinding breakpointBinding) { this.Breakpoint = breakpoint; this.BreakpointBinding = breakpointBinding; }