Skip to content

Instantly share code, notes, and snippets.

@andresdominguez
Last active December 2, 2016 04:27
Show Gist options
  • Save andresdominguez/aa3054f239edd867188bf008c2bc438f to your computer and use it in GitHub Desktop.
Save andresdominguez/aa3054f239edd867188bf008c2bc438f to your computer and use it in GitHub Desktop.
Find parameter list of the inject function
@Nullable
private JSParameterList findInjectParameterList(PsiFile file) {
// Recursively find all the call expressions in the file.
Collection<JSCallExpression> callExpressions =
PsiTreeUtil.findChildrenOfType(file, JSCallExpression.class);
for (JSCallExpression jsCallExpression : callExpressions) {
// Find the inject() element.
if (jsCallExpression.getText().startsWith("inject")) {
// Get the parameter list. Should be a child of the call expression.
return PsiTreeUtil.findChildOfType(jsCallExpression, JSParameterList.class);
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment