use of com.intellij.lang.LighterASTNode in project intellij-community by JetBrains.
the class ContractInferenceInterpreter method resolveParameter.
private int resolveParameter(@Nullable LighterASTNode expr) {
if (expr != null && expr.getTokenType() == REFERENCE_EXPRESSION && findExpressionChild(myTree, expr) == null) {
String name = JavaLightTreeUtil.getNameIdentifierText(myTree, expr);
if (name == null)
return -1;
List<LighterASTNode> parameters = getParameters();
for (int i = 0; i < parameters.size(); i++) {
if (name.equals(JavaLightTreeUtil.getNameIdentifierText(myTree, parameters.get(i)))) {
return i;
}
}
}
return -1;
}
use of com.intellij.lang.LighterASTNode in project intellij-community by JetBrains.
the class JavaNullMethodArgumentIndex method getNullParameterIndices.
@Nullable
private static IntArrayList getNullParameterIndices(LighterAST lighterAst, @NotNull LighterASTNode methodCall) {
final LighterASTNode node = LightTreeUtil.firstChildOfType(lighterAst, methodCall, EXPRESSION_LIST);
if (node == null)
return null;
final List<LighterASTNode> parameters = JavaLightTreeUtil.getExpressionChildren(lighterAst, node);
IntArrayList indices = new IntArrayList(1);
for (int idx = 0; idx < parameters.size(); idx++) {
if (isNullLiteral(lighterAst, parameters.get(idx))) {
indices.add(idx);
}
}
return indices;
}
use of com.intellij.lang.LighterASTNode in project intellij-community by JetBrains.
the class JavaFunctionalExpressionIndex method createChainStart.
@Nullable
private static ReferenceChainLink createChainStart(FileLocalResolver resolver, LighterASTNode expr, boolean isCall, String referenceName) {
if (!isCall) {
FileLocalResolver.LightResolveResult result = resolver.resolveLocally(expr);
if (result == FileLocalResolver.LightResolveResult.UNKNOWN)
return null;
LighterASTNode target = result.getTarget();
if (target != null) {
String typeName = resolver.getShortClassTypeName(target);
return typeName != null ? new ReferenceChainLink(typeName, false, -1) : null;
}
}
return new ReferenceChainLink(referenceName, isCall, getArgCount(resolver.getLightTree(), expr));
}
use of com.intellij.lang.LighterASTNode in project intellij-community by JetBrains.
the class JavaFunctionalExpressionIndex method getQualifier.
@Nullable
private static LighterASTNode getQualifier(LighterAST tree, LighterASTNode expr, boolean isCall) {
LighterASTNode qualifier = tree.getChildren(expr).get(0);
if (isCall) {
List<LighterASTNode> children = tree.getChildren(qualifier);
qualifier = children.isEmpty() ? null : children.get(0);
}
return qualifier != null && ElementType.EXPRESSION_BIT_SET.contains(qualifier.getTokenType()) ? qualifier : null;
}
use of com.intellij.lang.LighterASTNode in project intellij-community by JetBrains.
the class JavaFunctionalExpressionIndex method createOccurrence.
@NotNull
private static FunExprOccurrence createOccurrence(@NotNull LighterASTNode funExpr, FileLocalResolver resolver) {
LighterAST tree = resolver.getLightTree();
LighterASTNode containingCall = getContainingCall(tree, funExpr);
List<LighterASTNode> args = JavaLightTreeUtil.getArgList(tree, containingCall);
int argIndex = args == null ? -1 : getArgIndex(args, funExpr);
LighterASTNode chainExpr = containingCall;
if (chainExpr == null) {
LighterASTNode assignment = skipExpressionsUp(tree, funExpr, TokenSet.create(ASSIGNMENT_EXPRESSION));
if (assignment != null) {
chainExpr = findExpressionChild(assignment, tree);
}
}
return new FunExprOccurrence(funExpr.getStartOffset(), argIndex, createCallChain(resolver, chainExpr));
}
Aggregations