Skip to content

Commit

Permalink
Handle JS callback function names, fixes #81
Browse files Browse the repository at this point in the history
  • Loading branch information
Hirse committed Mar 13, 2017
1 parent d06e765 commit 90139cd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
This project tries to adhere to [Semantic Versioning](http://semver.org/).


## Unreleased
### Fixed
- Use correct name (or none) for callback functions (see [#81](https://github.com/Hirse/brackets-outline-list/issues/81))


## 1.0.0 - 2017-03-12
### Added
- Support ES6 Classes (see [#79](https://github.com/Hirse/brackets-outline-list/issues/79))
Expand Down
2 changes: 1 addition & 1 deletion src/lexers/JSParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ define(function (require, exports, module) {

if (Array.isArray(child)) {
for (var i = 0; i < child.length; i++) {
list = _traverse(child[i], list, name, level);
list = _traverse(child[i], list, "", level);
}
} else {
list = _traverse(child, list, name, level);
Expand Down
20 changes: 20 additions & 0 deletions test/JavaScriptSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,26 @@ define(function JavaScriptSpec(require) {
]);
});

it("detects callback functions", function () {
var test = require("text!example/javascript/callback.js");
var result = Parser.parse(test);
expect(result).toEqual([
{
type: "unnamed",
name: "function",
args: [],
level: 0,
line: 1
}, {
type: "unnamed",
name: "function",
args: [],
level: 0,
line: 2
}
]);
});

it("detects comments", function () {
var test = require("text!example/javascript/comment.js");
var result = Parser.parse(test);
Expand Down
2 changes: 2 additions & 0 deletions test/example/javascript/callback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var a = call(function () {});
const b = call(() => {});

0 comments on commit 90139cd

Please sign in to comment.