Source:
public SymbolReference<TypeDeclaration> solveType(String name, TypeSolver typeSolver) { List<com.github.javaparser.ast.body.TypeDeclaration> typeDeclarations = myDeclaration .findMembersOfKind(com.github.javaparser.ast.body.TypeDeclaration.class); Optional<SymbolReference<TypeDeclaration>> exactMatch = typeDeclarations .stream() .filter(internalType -> internalType.getName().getId().equals(name)) .findFirst() .map(internalType -> SymbolReference.solved( JavaParserFacade.get(typeSolver).getTypeDeclaration(internalType))); Optional<SymbolReference<TypeDeclaration>> recursiveMatch = typeDeclarations .stream() .filter(internalType -> name.startsWith(String.format("%s.", internalType.getName()))) .findFirst() .map(internalType -> JavaParserFactory .getContext(internalType, typeSolver) .solveType(name.substring(internalType.getName().getId().length() + 1), typeSolver)); Optional<SymbolReference<TypeDeclaration>> anyMatch = exactMatch.map(Optional::of).orElse(recursiveMatch); if (anyMatch.isPresent()) { return anyMatch.get(); } Optional<SymbolReference<TypeDeclaration>> typeArgumentsMatch = wrappedNode .getTypeArguments() .map(nodes -> ((NodeWithTypeArguments<?>) nodes).getTypeArguments() .orElse(new NodeList<>())) .orElse(new NodeList<>()) .stream() .filter(type -> type.toString().equals(name)) .findFirst() .map(matchingType -> SymbolReference.solved( new JavaParserTypeParameter(new TypeParameter(matchingType.toString()), typeSolver))); if (typeArgumentsMatch.isPresent()) { return typeArgumentsMatch.get(); } if (myDeclaration.getSuperTypeDeclaration().getName().equals(name)) { return SymbolReference.solved(myDeclaration.getSuperTypeDeclaration()); } else { Optional<SymbolReference<TypeDeclaration>> superClassInternalTypesMatch = myDeclaration .getSuperTypeDeclaration() .internalTypes() .stream() .filter(internalType -> internalType.getName().equals(name)) .findFirst() .map(SymbolReference::solved); if (superClassInternalTypesMatch.isPresent()) { return superClassInternalTypesMatch.get(); } } return getParent().solveType(name, typeSolver); }

Target:
public SymbolReference<TypeDeclaration> solveType(String name, TypeSolver typeSolver) { List<com.github.javaparser.ast.body.TypeDeclaration> typeDeclarations = myDeclaration .findMembersOfKind(com.github.javaparser.ast.body.TypeDeclaration.class); Optional<SymbolReference<TypeDeclaration>> exactMatch = typeDeclarations .stream() .filter(internalType -> internalType.getName().getId().equals(name)) .findFirst() .map(internalType -> SymbolReference.solved( JavaParserFacade.get(typeSolver).getTypeDeclaration(internalType))); if(exactMatch.isPresent()){ return exactMatch.get(); } Optional<SymbolReference<TypeDeclaration>> recursiveMatch = typeDeclarations .stream() .filter(internalType -> name.startsWith(String.format("%s.", internalType.getName()))) .findFirst() .map(internalType -> JavaParserFactory .getContext(internalType, typeSolver) .solveType(name.substring(internalType.getName().getId().length() + 1), typeSolver)); if (recursiveMatch.isPresent()) { return recursiveMatch.get(); } Optional<SymbolReference<TypeDeclaration>> typeArgumentsMatch = wrappedNode .getTypeArguments() .map(nodes -> ((NodeWithTypeArguments<?>) nodes).getTypeArguments() .orElse(new NodeList<>())) .orElse(new NodeList<>()) .stream() .filter(type -> type.toString().equals(name)) .findFirst() .map(matchingType -> SymbolReference.solved( new JavaParserTypeParameter(new TypeParameter(matchingType.toString()), typeSolver))); if (typeArgumentsMatch.isPresent()) { return typeArgumentsMatch.get(); } if (myDeclaration.getSuperTypeDeclaration().getName().equals(name)) { return SymbolReference.solved(myDeclaration.getSuperTypeDeclaration()); } else { Optional<SymbolReference<TypeDeclaration>> superClassInternalTypesMatch = myDeclaration .getSuperTypeDeclaration() .internalTypes() .stream() .filter(internalType -> internalType.getName().equals(name)) .findFirst() .map(SymbolReference::solved); if (superClassInternalTypesMatch.isPresent()) { return superClassInternalTypesMatch.get(); } } return getParent().solveType(name, typeSolver); }