Permalink
Browse files

minor changes

  • Loading branch information...
1 parent 597d479 commit 385f0e958ee7870739f6dba8fd82343f0be881cc @ramitos ramitos committed May 23, 2012
Showing with 51 additions and 43 deletions.
  1. +1 −1 example.js
  2. +1 −1 lib/cfa2/jscfa.js
  3. +12 −13 lib/jsctags/ctags/index.js
  4. +13 −8 lib/jsctags/ctags/reader.js
  5. +2 −2 lib/jsctags/ctags/writer.js
  6. +1 −1 lib/jsctags/traits.js
  7. +4 −1 package.json
  8. +15 −14 test/readtags.js
  9. +2 −2 test/testcases/boot.js
View
@@ -4,6 +4,6 @@ var tags = require('lib/jsctags/ctags').Tags,
tags = new tags();
fs.readFile('./example.js', 'utf-8', function (e, data) {
- tags.scan(data, __dirname + '/example.js', {commonJS: false});
+ tags.scan(data, __dirname + '/example.js', {commonJS: true});
console.log(tags);
});
View
@@ -1165,7 +1165,7 @@ function tagVarRefsId(classifyEvents) {
n.kind = HEAP;
n.addr = exports_object_av_addr;
var p = arguments[3]; // exported property name passed as extra arg
- if (p.type === STRING)
+ if (p && p.type === STRING)
exports_object.lines[p.value.slice(0, -1)] = p.lineno;
return;
}
@@ -36,22 +36,22 @@
* ***** END LICENSE BLOCK ***** */
var parse = require('../../../narcissus/lib/parser').parse;
-var _ = require('underscore')._;
+var _ = require('../underscore')._;
var Interpreter = require('./interp').Interpreter;
var TagReader = require('./reader').TagReader;
var TagWriter = require('./writer').TagWriter;
var Trait = require('../traits').Trait;
-exports.Tags = function(initialTags) {
+exports.Tags = function (initialTags) {
this.tags = initialTags != null ? initialTags : [];
this.init();
};
exports.Tags.prototype = Object.create(Object.prototype, Trait.compose(Trait({
- _search: function(id, pred) {
+ _search: function (id, pred) {
var shadowTag = { name: id };
var tags = this.tags;
- var index = _(tags).sortedIndex(shadowTag, function(tag) {
+ var index = _(tags).sortedIndex(shadowTag, function (tag) {
return tag.name;
});
@@ -66,11 +66,11 @@ exports.Tags.prototype = Object.create(Object.prototype, Trait.compose(Trait({
return tags.slice(start + 1, end);
},
- add: function(newTags) {
+ add: function (newTags) {
var tags = this.tags;
Array.prototype.push.apply(tags, newTags);
- tags.sort(function(a, b) {
+ tags.sort(function (a, b) {
var nameA = a.name, nameB = b.name;
if (nameA < nameB) {
return -1;
@@ -83,16 +83,16 @@ exports.Tags.prototype = Object.create(Object.prototype, Trait.compose(Trait({
},
/** Returns all the tags that match the given identifier. */
- get: function(id) {
- return this._search(id, function(tag) { return tag.name === id; });
+ get: function (id) {
+ return this._search(id, function (tag) { return tag.name === id; });
},
/**
* Adds the tags from the supplied JavaScript file to the internal store of
* tags.
*/
//dimvar: string (file contents), path to file, options
- scan: function(src, file, opts) {
+ scan: function (src, file, opts) {
if (opts === null || opts === undefined) {
opts = {};
}
@@ -106,11 +106,10 @@ exports.Tags.prototype = Object.create(Object.prototype, Trait.compose(Trait({
},
/** Returns all the tags that begin with the given prefix. */
- stem: function(prefix) {
+ stem: function (prefix) {
var len = prefix.length;
- return this._search(prefix, function(tag) {
+ return this._search(prefix, function (tag) {
return tag.name.substring(0, len) === prefix;
});
}
-}), TagReader, TagWriter));
-
+}), TagReader, TagWriter));
@@ -35,14 +35,14 @@
*
* ***** END LICENSE BLOCK ***** */
-var _ = require('underscore')._;
-var Trait = require('traits').Trait;
+var _ = require('../underscore')._;
+var Trait = require('../traits').Trait;
exports.TagReader = Trait({
- readLines: function(lines) {
+ readLines: function (lines) {
var tags = [];
- _(lines).each(function(line) {
+ _(lines).each(function (line) {
var parts = line.split("\t");
if (parts.length < 3) {
return;
@@ -54,7 +54,11 @@ exports.TagReader = Trait({
}
// TODO: cope with tab characters in the addr
- var tag = { name: name, tagfile: parts[1], addr: parts[2] };
+ var tag = {
+ name: name,
+ tagfile: parts[1],
+ addr: parts[2]
+ };
var fieldIndex;
if (parts.length > 3 && parts[3].indexOf(":") === -1) {
@@ -65,20 +69,21 @@ exports.TagReader = Trait({
}
var fields = {};
- _(parts.slice(fieldIndex)).each(function(field) {
+ _(parts.slice(fieldIndex)).each(function (field) {
var match = /^([^:]+):(.*)/.exec(field);
fields[match[1]] = match[2];
});
tag.fields = fields;
tags.push(tag);
});
-
+
this.add(tags);
},
- readString: function(str) {
+ readString: function (str) {
this.readLines(str.split("\n"));
+ str = str.split("\n");
}
});
@@ -35,8 +35,8 @@
*
* ***** END LICENSE BLOCK ***** */
-var Trait = require('traits').Trait;
-var _ = require('underscore')._;
+var Trait = require('../traits').Trait;
+var _ = require('../underscore')._;
const ESCAPES = { "\\": "\\\\", "\n": "\\n", "\r": "\\r", "\t": "\\t" };
@@ -661,4 +661,4 @@ var Trait = (function(){
if (typeof exports !== "undefined") { // CommonJS module support
exports.Trait = Trait;
-}
+}
View
@@ -2,7 +2,10 @@
"name": "ctags",
"description": "Intelligent code indexing for JavaScript",
"version": "0.1.0",
- "keywords": [ "ctags", "tags" ],
+ "keywords": [
+ "ctags",
+ "tags"
+ ],
"maintainers": [
{
"name": "Patrick Walton",
View
@@ -1,16 +1,17 @@
-#!/usr/bin/env node
+//#!/usr/bin/env node
+var tags = require('../lib/jsctags/ctags').Tags,
+ fs = require('fs'),
+ util = require('util'),
+ path = require('path'),
+ argv = process.argv;
-var argv = process.argv;
-var path = require('path');
-require.paths.unshift(path.join(path.dirname(argv[1]), "..", "lib",
- "jsctags"));
-
-var ctags = require('ctags'), fs = require('fs'), util = require('util');
-
-var tags = new ctags.Tags();
-var str = fs.readFileSync(argv[2]);
-tags.readString(str);
-
-var result = (argv.length >= 4) ? tags.stem(argv[3]) : tags.tags;
-util.puts(util.inspect(result));
+tags = new tags();
+fs.readFile(argv[2], 'utf-8', function (e, data) {
+ if (e) throw e;
+ //tags.readString(data);
+ tags.scan(data, argv[2]);
+
+ var result = (argv.length >= 4) ? tags.stem(argv[3]) : tags.tags;
+ util.puts(util.inspect(result));
+});
@@ -38,7 +38,7 @@
// This module is set up to be dependency-less so that Narwhal
// will be able to run it right away.
-bespin.useBespin = function(element, options) {
+bespin.useBespin = function (element, options) {
var baseConfig = %s;
options = options || {};
for (var key in options) {
@@ -49,7 +49,7 @@ bespin.useBespin = function(element, options) {
return appconfig.launch(baseConfig);
};
-document.addEventListener("DOMContentLoaded", function() {
+document.addEventListener("DOMContentLoaded", function () {
var nodes = document.querySelectorAll(".bespin");
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];

0 comments on commit 385f0e9

Please sign in to comment.