Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4590 from jasonLaster/flow-params
Browse files Browse the repository at this point in the history
Exclude flow types from identifier locations
  • Loading branch information
bomsy authored Nov 7, 2017
2 parents 4d137e9 + 85c3c84 commit 6d960c5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/workers/parser/getSymbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ function extractSymbols(source: Source) {
}

if (t.isIdentifier(path)) {
const { start, end } = path.node.loc;
let { start, end } = path.node.loc;

if (path.node.typeAnnotation) {
const column = path.node.typeAnnotation.loc.start.column;
end = { ...end, column };
}

identifiers.push({
name: path.node.name,
Expand Down
33 changes: 33 additions & 0 deletions src/workers/parser/tests/__snapshots__/getSymbols.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,39 @@ identifiers:
classes:
imports:
"
`;

exports[`Parser.getSymbols flow 1`] = `
"functions:
[(2, 2), (4, 3)] renderHello(name) App
variables:
[(2, 14), (2, 26)] name
callExpressions:
memberExpressions:
objectProperties:
comments:
identifiers:
[(1, 6), (1, 9)] App App
[(2, 2), (2, 13)] renderHello renderHello
[(2, 14), (2, 18)] name name
[(3, 20), (3, 24)] name name
[(1, 18), (1, 27)] Component Component
classes:
[(1, 0), (5, 1)] App
imports:
"
`;
Expand Down
5 changes: 5 additions & 0 deletions src/workers/parser/tests/fixtures/flow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class App extends Component {
renderHello(name: string) {
return `howdy ${name}`;
}
}
3 changes: 2 additions & 1 deletion src/workers/parser/tests/getSymbols.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ cases(
type: "html"
},
{ name: "component", file: "component" },
{ name: "react component", file: "frameworks/component" }
{ name: "react component", file: "frameworks/component" },
{ name: "flow", file: "flow" }
]
);

0 comments on commit 6d960c5

Please sign in to comment.