|
2 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | 3 | * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ |
4 | 4 |
|
| 5 | +// @flow |
| 6 | + |
5 | 7 | import { without, range } from "lodash"; |
6 | 8 |
|
7 | 9 | import type { Location, Source, ColumnPosition } from "../types"; |
| 10 | + |
| 11 | +import type { AstPosition, AstLocation, PausePoint } from "../workers/parser"; |
8 | 12 | import type { |
9 | | - AstPosition, |
10 | | - AstLocation, |
11 | 13 | SymbolDeclarations, |
12 | | - SymbolDeclaration, |
13 | | - PausePoint |
14 | | -} from "../workers/parser"; |
| 14 | + FunctionDeclaration |
| 15 | +} from "../workers/parser/getSymbols"; |
15 | 16 |
|
16 | 17 | export function findBestMatchExpression( |
17 | 18 | symbols: SymbolDeclarations, |
18 | 19 | tokenPos: ColumnPosition |
19 | 20 | ) { |
20 | 21 | const { memberExpressions, identifiers, literals } = symbols; |
21 | 22 | const { line, column } = tokenPos; |
22 | | - return identifiers |
23 | | - .concat(memberExpressions, literals) |
| 23 | + |
| 24 | + const members = memberExpressions.filter(({ computed }) => !computed); |
| 25 | + |
| 26 | + return [] |
| 27 | + .concat(identifiers, members, literals) |
24 | 28 | .reduce((found, expression) => { |
25 | 29 | const overlaps = |
26 | 30 | expression.location.start.line == line && |
27 | 31 | expression.location.start.column <= column && |
28 | | - expression.location.end.column >= column && |
29 | | - !expression.computed; |
| 32 | + expression.location.end.column >= column; |
30 | 33 |
|
31 | 34 | if (overlaps) { |
32 | 35 | return expression; |
@@ -66,7 +69,7 @@ export function containsPosition(a: AstLocation, b: AstPosition) { |
66 | 69 | } |
67 | 70 |
|
68 | 71 | export function findClosestFunction( |
69 | | - functions: SymbolDeclaration[], |
| 72 | + functions: FunctionDeclaration[], |
70 | 73 | location: Location |
71 | 74 | ) { |
72 | 75 | return functions.reduce((found, currNode) => { |
|
0 commit comments