public SetBreakpointCommand(int id, NodeModule module, NodeBreakpoint breakpoint, bool withoutPredicate, bool remote, SourceMapper sourceMapper = null) : base(id, "setbreakpoint") { Utilities.ArgumentNotNull("breakpoint", breakpoint); _module = module; _breakpoint = breakpoint; _sourceMapper = sourceMapper; _position = breakpoint.GetPosition(_sourceMapper); // Zero based line numbers int line = _position.Line; // Zero based column numbers // Special case column to avoid (line 0, column 0) which // Node (V8) treats specially for script loaded via require // Script wrapping process: https://github.com/joyent/node/blob/v0.10.26-release/src/node.js#L880 int column = _position.Column; if (line == 0) { column += NodeConstants.ScriptWrapBegin.Length; } _arguments = new Dictionary<string, object> { { "line", line }, { "column", column } }; if (_module != null) { _arguments["type"] = "scriptId"; _arguments["target"] = _module.Id; } else if (remote) { _arguments["type"] = "scriptRegExp"; _arguments["target"] = CreateRemoteScriptRegExp(_position.FileName); } else { _arguments["type"] = "scriptRegExp"; _arguments["target"] = CreateLocalScriptRegExp(_position.FileName); } if (!NodeBreakpointBinding.GetEngineEnabled(_breakpoint.Enabled, _breakpoint.BreakOn, 0)) { _arguments["enabled"] = false; } if (withoutPredicate) { return; } int ignoreCount = NodeBreakpointBinding.GetEngineIgnoreCount(_breakpoint.BreakOn, 0); if (ignoreCount > 0) { _arguments["ignoreCount"] = ignoreCount; } if (!string.IsNullOrEmpty(_breakpoint.Condition)) { _arguments["condition"] = _breakpoint.Condition; } }
/// <summary> /// Gets the position in the target JavaScript file using the provided SourceMapper. /// /// This translates the breakpoint from the location where the user set it (possibly /// a TypeScript file) into the location where it lives in JavaScript code. /// </summary> public FilePosition GetPosition(SourceMapper mapper) { // Checks whether source map is available string javaScriptFileName; int javaScriptLine; int javaScriptColumn; if (mapper != null && mapper.MapToJavaScript(Target.FileName, Target.Line, Target.Column, out javaScriptFileName, out javaScriptLine, out javaScriptColumn)) { return new FilePosition(javaScriptFileName, javaScriptLine, javaScriptColumn); } return Target; }
private NodeDebugger() { _connection = new DebuggerConnection(new NetworkClientFactory()); _connection.ConnectionClosed += OnConnectionClosed; _client = new DebuggerClient(_connection); _client.BreakpointEvent += OnBreakpointEvent; _client.CompileScriptEvent += OnCompileScriptEvent; _client.ExceptionEvent += OnExceptionEvent; _resultFactory = new EvaluationResultFactory(); _exceptionHandler = new ExceptionHandler(); _sourceMapper = new SourceMapper(); _fileNameMapper = new LocalFileNameMapper(); }
public void GetOriginalFileNameWithStackFrame() { string javaScriptFileName = TestData.GetPath(@"TestData\TypeScriptMultfile\all.js"); var sourceMapper = new SourceMapper(); int? line = 24, column = 9; string originalFileName = sourceMapper.GetOriginalFileName(javaScriptFileName, line, column); Assert.IsTrue(originalFileName.Contains("file2.ts")); }
public void MapToJavaScript() { var mapper = new SourceMapper(); string fileName; int lineNo, columnNo; Assert.IsTrue(mapper.MapToJavaScript(TestData.GetPath(@"TestData\DebuggerProject\TypeScriptTest.ts"), 1, 0, out fileName, out lineNo, out columnNo)); Assert.AreEqual(TestData.GetPath(@"TestData\DebuggerProject\TypeScriptTest.js"), fileName); }
public void MapToOriginal() { var mapper = new SourceMapper(); var mapInfo = mapper.MapToOriginal(TestData.GetPath(@"TestData\DebuggerProject\TypeScriptTest.js"), 1, 0); Assert.AreEqual("TypeScriptTest.ts", mapInfo.FileName); }