Skip to content

Commit

Permalink
Added function / class declarations.
Browse files Browse the repository at this point in the history
  • Loading branch information
othiym23 committed Nov 23, 2012
1 parent 4f19ea5 commit 2fd6ea3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions index.js
Expand Up @@ -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 = { var nodeVisitors = {
'VariableDeclarator' : function (filename, node) { 'VariableDeclarator' : function (filename, node) {
if (!node.init) return; if (!node.init) return;
Expand All @@ -67,6 +76,9 @@ var nodeVisitors = {
methodTags(filename, node, target); methodTags(filename, node, target);
} }
} }
},
'FunctionDeclaration' : function (filename, node) {
console.log(functionTag(filename, node));
} }
}; };


Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{ {
"name": "jstags", "name": "jstags",
"version": "0.0.1", "version": "0.0.2",
"description": "ctags-like tag generator for JavaScript and Node.js", "description": "ctags-like tag generator for JavaScript and Node.js",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
Expand Down

0 comments on commit 2fd6ea3

Please sign in to comment.