[debugger] added synonyms for run, cont, next, step, out, shorten breakpoint message...
authorFedor Indutny <fedor.indutny@gmail.com>
Thu, 8 Sep 2011 19:33:28 +0000 (02:33 +0700)
committerFedor Indutny <fedor.indutny@gmail.com>
Thu, 8 Sep 2011 19:33:28 +0000 (02:33 +0700)
lib/_debugger.js

index 1c5ea6d..be5d946 100644 (file)
@@ -649,14 +649,26 @@ function Interface() {
   var proto = Interface.prototype,
       ignored = ['pause', 'resume', 'exitRepl', 'handleBreak',
                  'requireConnection', 'killChild', 'trySpawn',
-                 'controlEval', 'debugEval'];
+                 'controlEval', 'debugEval'],
+      synonym = {
+        'run': 'r',
+        'cont': 'c',
+        'next': 'n',
+        'step': 's',
+        'out': 'o'
+      };
+
+  function defineProperty(key, protoKey) {
+    Object.defineProperty(self.repl.context, key, {
+      get: proto[protoKey].bind(self),
+      enumerable: true
+    });
+  };
 
   for (var i in proto) {
     if (proto.hasOwnProperty(i) && ignored.indexOf(i) === -1) {
-      Object.defineProperty(this.repl.context, i, {
-        get: proto[i].bind(this),
-        enumerable: true
-      });
+      defineProperty(i, i);
+      if (synonym[i]) defineProperty(synonym[i], i);
     }
   }
 
@@ -689,35 +701,19 @@ Interface.prototype.resume = function() {
 
 
 Interface.prototype.handleBreak = function(r) {
+  var expected = this.paused !== 0;
+
   this.pause();
-  var result = '\n';
-  if (r.breakpoints) {
-    result += 'breakpoint';
-    if (r.breakpoints.length > 1) {
-      result += 's';
-    }
-    result += ' #';
-    for (var i = 0; i < r.breakpoints.length; i++) {
-      if (i > 0) {
-        result += ', #';
-      }
-      result += r.breakpoints[i];
-    }
-  } else {
-    result += 'break';
-  }
-  result += ' in ';
-  result += r.invocationText;
-  result += ', ';
-  result += SourceInfo(r);
-  result += '\n';
-  result += SourceUnderline(r.sourceLineText, r.sourceColumn);
 
   this.client.currentSourceLine = r.sourceLine;
   this.client.currentFrame = 0;
   this.client.currentScript = r.script.name;
 
-  console.log(result);
+  if (!expected) {
+    console.log('');
+  }
+  console.log(SourceInfo(r));
+  console.log(SourceUnderline(r.sourceLineText, r.sourceColumn));
   this.resume();
 };
 
@@ -942,7 +938,9 @@ Interface.prototype.cont = function() {
 
   var self = this;
   this.client.reqContinue(function() {
-    self.resume();
+    process.nextTick(function() {
+      self.resume();
+    });
   });
 };
 
@@ -955,7 +953,9 @@ Interface.prototype.next = function() {
 
   var self = this;
   this.client.step('next', 1, function(res) {
-    self.resume();
+    process.nextTick(function() {
+      self.resume();
+    });
   });
 };
 
@@ -968,7 +968,9 @@ Interface.prototype.step = function() {
 
   var self = this;
   this.client.step('in', 1, function(res) {
-    self.resume();
+    process.nextTick(function() {
+      self.resume();
+    });
   });
 };
 
@@ -981,7 +983,9 @@ Interface.prototype.out = function() {
 
   var self = this;
   this.client.step('out', 1, function(res) {
-    self.resume();
+    process.nextTick(function() {
+      self.resume();
+    });
   });
 };