Permalink
Browse files

Added function / class declarations.

  • Loading branch information...
othiym23 committed Nov 23, 2012
1 parent 4f19ea5 commit 2fd6ea3b9718b9111d764c671bc3b95200daa30d
Showing with 13 additions and 1 deletion.
  1. +12 −0 index.js
  2. +1 −1 package.json
View
@@ -47,6 +47,15 @@ function methodTags(filename, node, object) {
});
}
+function functionTag(filename, node) {
+ var name = node.id.name;
+ var startLine = node.loc.start.line - 1;
+ var pattern = startLine + '/\\<' + node.id.name + '\\>/;"';
+ var type = (name[0] === name[0].toUpperCase()) ? 'c' : 'f';
+
+ return [name, filename, pattern, type, 'lineno:' + (startLine + 1)].join('\t');
+}
+
var nodeVisitors = {
'VariableDeclarator' : function (filename, node) {
if (!node.init) return;
@@ -67,6 +76,9 @@ var nodeVisitors = {
methodTags(filename, node, target);
}
}
+ },
+ 'FunctionDeclaration' : function (filename, node) {
+ console.log(functionTag(filename, node));
}
};
View
@@ -1,6 +1,6 @@
{
"name": "jstags",
- "version": "0.0.1",
+ "version": "0.0.2",
"description": "ctags-like tag generator for JavaScript and Node.js",
"main": "index.js",
"scripts": {

0 comments on commit 2fd6ea3

Please sign in to comment.