Source:
private static NameCategory reclassificationOfContextuallyAmbiguousQualifiedAmbiguousName(Node nameNode, TypeSolver typeSolver) { Node leftName = NameLogic.getQualifier(nameNode); String rightName = NameLogic.nameAsString(NameLogic.getRightMostName(nameNode)); NameCategory leftNameCategory = classifyReference(leftName, typeSolver); if (leftNameCategory == NameCategory.PACKAGE_NAME) { if (typeSolver.hasType(nameAsString(nameNode))) { return NameCategory.TYPE_NAME; } else { return NameCategory.PACKAGE_NAME; } } if (leftNameCategory == NameCategory.TYPE_NAME) { SymbolReference<ResolvedTypeDeclaration> scopeTypeRef = JavaParserFactory.getContext(leftName, typeSolver) .solveType(NameLogic.nameAsString(leftName), typeSolver); if (scopeTypeRef.isSolved()) { ResolvedTypeDeclaration scopeType = scopeTypeRef.getCorrespondingDeclaration(); if (scopeType instanceof ResolvedReferenceTypeDeclaration) { ResolvedReferenceTypeDeclaration scopeRefType = scopeType.asReferenceType(); if (scopeRefType.getAllMethods().stream().anyMatch(m -> m.getName().equals(rightName))) { return NameCategory.EXPRESSION_NAME; } if (scopeRefType.getAllFields().stream().anyMatch(f -> f.isStatic() && f.getName().equals(rightName))) { return NameCategory.EXPRESSION_NAME; } if (scopeRefType.hasInternalType(rightName)) { return NameCategory.TYPE_NAME; } return NameCategory.COMPILATION_ERROR; } else { throw new UnsupportedOperationException(); } } else { throw new UnsolvedSymbolException("Unable to solve context type: " + NameLogic.nameAsString(leftName)); } } if (leftNameCategory == NameCategory.EXPRESSION_NAME) { return NameCategory.EXPRESSION_NAME; } throw new UnsupportedOperationException(); }

Target:
private static NameCategory reclassificationOfContextuallyAmbiguousQualifiedAmbiguousName(Node nameNode, TypeSolver typeSolver) { Node leftName = NameLogic.getQualifier(nameNode); String rightName = NameLogic.nameAsString(NameLogic.getRightMostName(nameNode)); NameCategory leftNameCategory = classifyReference(leftName, typeSolver); if (leftNameCategory == NameCategory.PACKAGE_NAME) { if (typeSolver.hasType(nameAsString(nameNode))) { return NameCategory.TYPE_NAME; } else { return NameCategory.PACKAGE_NAME; } } if (leftNameCategory == NameCategory.TYPE_NAME) { SymbolReference<ResolvedTypeDeclaration> scopeTypeRef = JavaParserFactory.getContext(leftName, typeSolver) .solveType(NameLogic.nameAsString(leftName), typeSolver); if (scopeTypeRef.isSolved()) { ResolvedTypeDeclaration scopeType = scopeTypeRef.getCorrespondingDeclaration(); if (scopeType instanceof ResolvedReferenceTypeDeclaration) { ResolvedReferenceTypeDeclaration scopeRefType = scopeType.asReferenceType(); if (scopeRefType.getAllMethods().stream().anyMatch(m -> m.getName().equals(rightName))) { return NameCategory.EXPRESSION_NAME; } if (scopeRefType.getAllFields().stream().anyMatch(f -> f.isStatic() && f.getName().equals(rightName))) { return NameCategory.EXPRESSION_NAME; } if (scopeRefType.hasInternalType(rightName)) { return NameCategory.TYPE_NAME; } return NameCategory.COMPILATION_ERROR; } else { throw new UnsupportedOperationException("The name is a type but it has been resolved to something that is not a reference type"); } } else { throw new UnsolvedSymbolException("Unable to solve context type: " + NameLogic.nameAsString(leftName)); } } if (leftNameCategory == NameCategory.EXPRESSION_NAME) { return NameCategory.EXPRESSION_NAME; } throw new UnsupportedOperationException("I do not know how to handle this semantic reclassification of ambiguous name categories"); }