public NodeModule BuildModule(NodeModule module, IServiceProvider provider) { var configurableService = provider.GetRequiredService <ConfigurationManager>(); configurableService.RegisterType(module.GetType(), module.Instance); return(module); }
public void CreateSetBreakpointCommandWithNullBreakpoint() { // Arrange const int commandId = 3; const int moduleId = 5; const string fileName = "module.js"; var module = new NodeModule(moduleId, fileName); SetBreakpointCommand setBreakpointCommand = null; Exception exception = null; // Act try { setBreakpointCommand = new SetBreakpointCommand(commandId, module, null, false, false); } catch (Exception e) { exception = e; } // Assert Assert.IsNull(setBreakpointCommand); Assert.IsNotNull(exception); Assert.IsInstanceOfType(exception, typeof(ArgumentNullException)); }
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 CompileScriptEvent(JObject message) { Running = (bool)message["running"]; var scriptId = (int)message["body"]["script"]["id"]; string fileName = (string)message["body"]["script"]["name"] ?? NodeVariableType.UnknownModule; Module = new NodeModule(scriptId, fileName); }
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; } }
public override Query ApplyWhere(Node node) { var newFilter = null == Filter ? node : NodeModule.CombineAnd(Filter, node); return(new DerivedQuery <TBase, TDerived>( Provider, newFilter, SortBy, IsDescending, Offset, Limit)); }
public ChangeLiveCommand(int id, NodeModule module) : base(id, "changelive") { // Wrap script contents as following https://github.com/joyent/node/blob/v0.10.26-release/src/node.js#L880 string source = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", NodeConstants.ScriptWrapBegin, module.Source, NodeConstants.ScriptWrapEnd); _arguments = new Dictionary<string, object> { { "script_id", module.Id }, { "new_source", source }, { "preview_only", false }, }; }
public ChangeLiveCommand(int id, NodeModule module) : base(id, "changelive") { // Wrap script contents as following https://github.com/joyent/node/blob/v0.10.26-release/src/node.js#L880 string source = string.Format("{0}{1}{2}", NodeConstants.ScriptWrapBegin, module.Source, NodeConstants.ScriptWrapEnd); _arguments = new Dictionary <string, object> { { "script_id", module.Id }, { "new_source", source }, { "preview_only", false }, }; }
public BreakpointEvent(JObject message) { Running = false; Line = (int)message["body"]["sourceLine"]; Column = (int)message["body"]["sourceColumn"]; var scriptId = (int)message["body"]["script"]["id"]; var fileName = (string)message["body"]["script"]["name"]; Module = new NodeModule(scriptId, fileName); JToken breakpoints = message["body"]["breakpoints"]; Breakpoints = breakpoints != null ? breakpoints.Values<int>().ToList() : new List<int>(); }
private Node GetCommandFromSpecificModule(NodeModule module, string commandName) { commandName = commandName.ToLowerInvariant(); var commandNode = module.Children .FirstOrDefault(x => x.Metadata.Identifiers .Any(z => z.ToLowerInvariant() == commandName)); if (commandNode == null) { throw new EntityNullException <Node>(); } return(commandNode); }
public void ProcessChangeLiveResponse() { // Arrange const int commandId = 3; const int moduleId = 5; const string fileName = "fileName.js"; var module = new NodeModule(moduleId, fileName); var changeLiveCommand = new ChangeLiveCommand(commandId, module); // Act changeLiveCommand.ProcessResponse(SerializationTestData.GetChangeLiveResponse()); // Assert Assert.AreEqual(commandId, changeLiveCommand.Id); Assert.IsTrue(changeLiveCommand.Updated); Assert.IsTrue(changeLiveCommand.StackModified); }
public BreakpointEvent(JObject message) { Running = false; Line = (int)message["body"]["sourceLine"]; Column = (int)message["body"]["sourceColumn"]; var scriptId = (int)message["body"]["script"]["id"]; var fileName = (string)message["body"]["script"]["name"]; Module = new NodeModule(scriptId, fileName); JToken breakpoints = message["body"]["breakpoints"]; Breakpoints = breakpoints != null ? breakpoints.Values <int>().ToList() : new List <int>(); }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { if (treeView.SelectedNode != null) { Node parent = treeView.SelectedNode.Parent.Tag as Node; List <string> parents = new List <string>(); while (parent != null) { parents.Add(parent.ToString()); parent = parent.Parent; } parents.Reverse(); NodeModule nm = treeView.SelectedNode.Tag as NodeModule; string id = nm.Tag.ToString(); if (id.StartsWith("f")) { using (SQLiteCommand command = new SQLiteCommand(ConnectionManager.connection)) { command.CommandText = @"delete from files where id=@id"; command.Parameters.Add(new SQLiteParameter("@id", id.Substring(1))); command.ExecuteNonQuery(); } } else { using (SQLiteCommand command = new SQLiteCommand(ConnectionManager.connection)) { command.CommandText = @"delete from folders where id=@id"; command.Parameters.Add(new SQLiteParameter("@id", id)); command.ExecuteNonQuery(); } } treeView.Model = new SlowTreeModel(); TreePath tp = new TreePath(); treeView.FindNode(tp).Expand(); for (int i = 0; i < parents.Count; i++) { tp = new TreePath(tp, parents[i]); treeView.FindNode(tp).Expand(); } } }
// Gets the document that contains this document context. // This method is for those debug engines that supply documents directly to the IDE. Since the sample engine // does not do this, this method returns E_NOTIMPL. int IDebugDocumentContext2.GetDocument(out IDebugDocument2 ppDocument) { // Expose document for downloaded modules ppDocument = null; if (Downloaded) { NodeModule module = Module; if (module != null) { // Lazily create document per module ppDocument = (AD7Document)module.Document; if (ppDocument == null) { ppDocument = new AD7Document(this); module.Document = ppDocument; } } } return(ppDocument != null ? VSConstants.S_OK : VSConstants.E_FAIL); }
public ExceptionEvent(JObject message) { Running = false; JToken body = message["body"]; Line = (int?)body["sourceLine"]; Column = (int?)body["sourceColumn"]; Uncaught = (bool)body["uncaught"]; ExceptionId = (int)body["exception"]["handle"]; Description = (string)body["exception"]["text"]; TypeName = GetExceptionType(body); ExceptionName = GetExceptionName(message); ErrorNumber = GetExceptionCodeRef(body); JToken script = body["script"]; if (script != null) { var scriptId = (int)script["id"]; var fileName = (string)script["name"]; Module = new NodeModule(scriptId, fileName); } }
public void ProcessScriptsResponse() { // Arrange const int commandId = 3; const bool includeSource = true; const string nodejs = "node.js"; var scriptsCommand = new ScriptsCommand(commandId, includeSource); // Act scriptsCommand.ProcessResponse(SerializationTestData.GetScriptsResponse()); // Assert Assert.AreEqual(commandId, scriptsCommand.Id); Assert.IsNotNull(scriptsCommand.Modules); Assert.AreEqual(17, scriptsCommand.Modules.Count); NodeModule module = scriptsCommand.Modules[0]; Assert.AreEqual(nodejs, module.Name); Assert.AreEqual(nodejs, module.Source); Assert.AreEqual(nodejs, module.FileName); Assert.AreEqual(nodejs, module.JavaScriptFileName); Assert.AreEqual(17, module.Id); }
public void CreateChangeLiveCommand() { // Arrange const int commandId = 3; const int moduleId = 5; const string fileName = "fileName.js"; const string source = "source"; string wrappedSource = string.Format("{0}{1}{2}", NodeConstants.ScriptWrapBegin, source, NodeConstants.ScriptWrapEnd.Replace("\n", @"\n")); var module = new NodeModule(moduleId, fileName) { Source = source }; // Act var changeLiveCommand = new ChangeLiveCommand(commandId, module); // Assert Assert.AreEqual(commandId, changeLiveCommand.Id); Assert.AreEqual( string.Format( "{{\"command\":\"changelive\",\"seq\":{0},\"type\":\"request\",\"arguments\":{{\"script_id\":{1},\"new_source\":\"{2}\",\"preview_only\":false}}}}", commandId, moduleId, wrappedSource), changeLiveCommand.ToString()); }
public void CreateSetBreakpointCommandOnFirstLine() { // Arrange const int commandId = 3; const int moduleId = 5; const int line = 0; const int column = 0; const string fileName = "c:\\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 + NodeConstants.ScriptWrapBegin.Length, module.Id), setBreakpointCommand.ToString()); }
public AD7Module(NodeModule debuggedModule) { this.DebuggedModule = debuggedModule; }
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"] = GetCaseInsensitiveRegex(_position.FileName); } else { _arguments["type"] = "script"; _arguments["target"] = _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; } }