[Pkg-mozext-commits] [adblock-plus] 28/464: Comment processing improved

David Prévot taffit at moszumanska.debian.org
Tue Jul 22 20:43:59 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit b360820093e21ee85fc1c5ecae69273e27641029
Author: Joshua Cranmer <Pidgeot18 at gmail.com>
Date:   Thu May 7 13:10:10 2009 -0400

    Comment processing improved
---
 scripts/doxygen.js | 51 +++++++++++++++++++++++++++------------------------
 utils/comments.js  | 26 +++++++++++++++++++-------
 2 files changed, 46 insertions(+), 31 deletions(-)

diff --git a/scripts/doxygen.js b/scripts/doxygen.js
index a37840c..ce03e35 100644
--- a/scripts/doxygen.js
+++ b/scripts/doxygen.js
@@ -15,6 +15,7 @@ FILE doxygen.js
 101:0 CONSTANT const1 VALUE 10
 */
 
+include("../utils/dumpast.js");
 include("../utils/cleanast.js");
 include("../utils/comments.js");
 include("../utils/jstypes.js");
@@ -27,46 +28,48 @@ function process_js(ast, f) {
   let toplevel = clean_ast(ast);
   associate_comments(f, toplevel);
   for each (let v in toplevel.variables) {
+    if (v.comment)
+      _print(v.comment);
     _print(loc(v.loc) + " VARIABLE " + v.name);
   }
   for each (let v in toplevel.constants) {
+    if (v.comment)
+      _print(v.comment);
     _print(loc(v.loc) + " CONST " + v.name);
   }
   for each (let v in toplevel.objects) {
     divine_inheritance(v, toplevel.constants);
+    if (v.comment)
+      _print(v.comment);
     let inherits = v.inherits ? (" INHERITS " + v.inherits.join(", ")) : "";
     _print(loc(v.loc) + " CLASS " + v.name + inherits);
-    for (let name in v.functions) {
-      _print(loc(v.functions[name].loc) + " CLASS METHOD " + name);
-    }
-    for (let name in v.variables) {
-      _print(loc(v.variables[name].loc) + " CLASS VARIABLE " + name);
+    let attrs = { METHOD: v.functions, VARIABLE: v.variables, GETTER: v.getters,
+      SETTER: v.setters };
+    for (let attr in attrs) {
+      for (let name in attrs[attr]) {
+        if (attrs[attr][name].comment)
+          _print(attrs[attr][name].comment);
+        _print(loc(attrs[attr][name].loc) + " CLASS " + attr + " " + name);
+      }
     }
-    for (let name in v.getters) {
-      _print(loc(v.getters[name].loc) + " CLASS GETTER " + name);
-    }
-    for (let name in v.setters) {
-      _print(loc(v.setters[name].loc) + " CLASS SETTER " + name);
-    }
-	_print("CLASS END");
+    _print("CLASS END");
   }
   for each (let v in toplevel.classes) {
     divine_inheritance(v, toplevel.constants);
+    if (v.comment)
+      _print(v.comment);
     let inherits = v.inherits ? (" INHERITS " + v.inherits.join(", ")) : "";
     _print(loc(v.loc) + " CLASS " + v.name + inherits);
-    for (let name in v.functions) {
-      _print(loc(v.functions[name].loc) + " CLASS METHOD " + name);
-    }
-    for (let name in v.variables) {
-      _print(loc(v.variables[name].loc) + " CLASS VARIABLE " + name);
-    }
-    for (let name in v.getters) {
-      _print(loc(v.getters[name].loc) + " CLASS GETTER " + name);
-    }
-    for (let name in v.setters) {
-      _print(loc(v.setters[name].loc) + " CLASS SETTER " + name);
+    let attrs = { METHOD: v.functions, VARIABLE: v.variables, GETTER: v.getters,
+      SETTER: v.setters };
+    for (let attr in attrs) {
+      for (let name in attrs[attr]) {
+        if (attrs[attr][name].comment)
+          _print(attrs[attr][name].comment);
+        _print(loc(attrs[attr][name].loc) + " CLASS " + attr + " " + name);
+      }
     }
-	_print("CLASS END");
+    _print("CLASS END");
   }
   for each (let v in toplevel.functions) {
     if (v.comment)
diff --git a/utils/comments.js b/utils/comments.js
index cdc70be..351376b 100644
--- a/utils/comments.js
+++ b/utils/comments.js
@@ -7,12 +7,24 @@ function associate_comments(filename, scopeObject) {
 
   // Now, get us a sorted list of all important AST locations
   let locations = [{loc: {line: 0, column: -1}}];
+
+  function add_func(func) {
+    locations.push({loc: func.loc, obj: func, commentWanted: true});
+    // The following will get us to the last line of the function
+    if (func.body.kids.length == 0)
+      return;
+    let last = func.body.kids[func.body.kids.length - 1];
+    while (last.kids[last.kids.length - 1] &&
+        last.kids[last.kids.length - 1].line > last.line)
+      last = last.kids[last.kids.length - 1];
+    locations.push({loc: {line: last.line, column: last.column}});
+  }
   for each (let v in scopeObject.variables)
     locations.push({loc: v.loc, obj: v, commentWanted: true});
   for each (let v in scopeObject.constants)
     locations.push({loc: v.loc, obj: v, commentWanted: true});
   for each (let v in scopeObject.functions)
-    locations.push({loc: v.loc, obj: v, commentWanted: true});
+    add_func(v);
   for each (let v in scopeObject.code)
     locations.push({loc: {line: v.line, column: v.column}, obj: v});
   for each (let o in scopeObject.objects) {
@@ -20,22 +32,22 @@ function associate_comments(filename, scopeObject) {
     for each (let x in o.variables)
       locations.push({loc: x.loc, obj: x, commentWanted: true});
     for each (let x in o.functions)
-      locations.push({loc: x.loc, obj: x, commentWanted: true});
+      add_func(x);
     for each (let x in o.getters)
-      locations.push({loc: x.loc, obj: x, commentWanted: true});
+      add_func(x);
     for each (let x in o.setters)
-      locations.push({loc: x.loc, obj: x, commentWanted: true});
+      add_func(x);
   }
   for each (let o in scopeObject.classes) {
     locations.push({loc: o.loc, obj: o, commentWanted: true});
     for each (let x in o.variables)
       locations.push({loc: x.loc, obj: x, commentWanted: true});
     for each (let x in o.functions)
-      locations.push({loc: x.loc, obj: x, commentWanted: true});
+      add_func(x);
     for each (let x in o.getters)
-      locations.push({loc: x.loc, obj: x, commentWanted: true});
+      add_func(x);
     for each (let x in o.setters)
-      locations.push({loc: x.loc, obj: x, commentWanted: true});
+      add_func(x);
   }
   locations.sort(function (a, b) {
     if (a.loc.line == b.loc.line)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list