List<ReferenceChainLink> (FileLocalResolver resolver, @Nullable LighterASTNode expr) { List<ReferenceChainLink> chain = new ArrayList<>(); while (true) { if (expr == null) return reversedChain(chain); if (expr.getTokenType() == PARENTH_EXPRESSION) { expr = LightTreeUtil.firstChildOfType(resolver.getLightTree(), expr, ElementType.EXPRESSION_BIT_SET); continue; } if (expr.getTokenType() == TYPE_CAST_EXPRESSION) { String typeName = resolver.getShortClassTypeName(expr); ContainerUtil.addIfNotNull(chain, typeName != null ? new ReferenceChainLink(typeName, false, -1) : null); return reversedChain(chain); } boolean isCall = expr.getTokenType() == METHOD_CALL_EXPRESSION || expr.getTokenType() == NEW_EXPRESSION; String referenceName = getReferencedMemberName(resolver.getLightTree(), expr, isCall); if (referenceName == null) return reversedChain(chain); LighterASTNode qualifier = getQualifier(resolver.getLightTree(), expr, isCall); if (qualifier == null) { ContainerUtil.addIfNotNull(chain, createChainStart(resolver, expr, isCall, referenceName)); return reversedChain(chain); } chain.add(new ReferenceChainLink(referenceName, isCall, getArgCount(resolver.getLightTree(), expr))); expr = qualifier; } }