include classes in javascript outline

pull/125/merge
nightwing 2017-04-29 19:27:55 +04:00
rodzic bf954c2617
commit e21ed3a696
3 zmienionych plików z 22 dodań i 2 usunięć

Wyświetl plik

@ -86,7 +86,7 @@ var outlineSync = outlineHandler.outlineSync = function(doc, node, includeProps)
return this;
},
// x : function(...) { ... } -> name is x
'PropertyInit(x, Function(name, fargs, body))', function(b) {
'PropertyInit(x, Function(name, fargs, body))', 'Method(x, Function(name, fargs, body))', function(b) {
results.push({
icon: 'method',
name: b.x.value + fargsToString(b.fargs),
@ -153,6 +153,16 @@ var outlineSync = outlineHandler.outlineSync = function(doc, node, includeProps)
});
return this;
},
'Class(x, y, body)', function(b) {
results.push({
icon: 'event',
name: b.x.value + (b.y.value ? " extends " + b.y.value : ""),
pos: this.getPos(),
displayPos: b.x.getPos(),
items: b.body && outlineSync(doc, b.body, includeProps)
});
return this;
},
/* UNDONE: callbacks in outline
// intelligently name callback functions for method calls
// setTimeout(function() { ... }, 200) -> name is setTimeout [callback]

Wyświetl plik

@ -5,6 +5,7 @@
if (typeof define === "undefined") {
require("amd-loader");
require("../../test/setup_paths");
require("c9/inline-mocha")(module);
}
function outlineSync(handler, document, node) {
@ -35,6 +36,9 @@ define(function(require, exports, module) {
assert.equal(outline[1].items[0].name, 'nested(c)');
assert.equal(outline[2].name, 'someFunction(a, b)');
assert.equal(outline[3].name, 'someFunction.bla()');
assert.equal(outline[4].name, 'SomeClass');
assert.equal(outline[4].items[0].name, 'method(x)');
assert.equal(outline.length, 5);
done();
});

Wyświetl plik

@ -12,4 +12,10 @@ function simpleFunctionNested(a, b) {
someFunction.bla = function() {
};
})();
})();
class SomeClass {
method(x) {
}
}