-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix component search only finding first callExpr
- Loading branch information
1 parent
6892583
commit 4d3b906
Showing
4 changed files
with
65 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { CallExpression, Node } from 'estree' | ||
import { visitChildren } from './visitChildren' | ||
|
||
export function findCallExpressions(root: Node, calleeName: string): Array<CallExpression> { | ||
const isTargetCallExpression = (node: Node): node is CallExpression => { | ||
if (node.type !== 'CallExpression') { | ||
return false | ||
} | ||
|
||
if (node.callee.type !== 'Identifier') { | ||
return false | ||
} | ||
|
||
if (node.callee.name !== calleeName) { | ||
return false | ||
} | ||
|
||
return true | ||
} | ||
|
||
const foundExpressions: Array<CallExpression> = [] | ||
const search = (node: Node) => { | ||
if (isTargetCallExpression(node)) { | ||
foundExpressions.push(node) | ||
} | ||
|
||
visitChildren(node, search) | ||
} | ||
|
||
search(root) | ||
return foundExpressions | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters