Skip to content

Commit

Permalink
Merge pull request #1458 from AwesomeLemon/incorrect-package-search-o…
Browse files Browse the repository at this point in the history
…rder

Fix incorrect order in search for class.
  • Loading branch information
ftomassetti committed Mar 6, 2018
2 parents 3e52851 + 0a5d0f8 commit b0185a7
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ public SymbolReference<ResolvedTypeDeclaration> solveType(String name, TypeSolve
}
}

// Look in current package
if (this.wrappedNode.getPackageDeclaration().isPresent()) {
String qName = this.wrappedNode.getPackageDeclaration().get().getName().toString() + "." + name;
SymbolReference<ResolvedReferenceTypeDeclaration> ref = typeSolver.tryToSolveType(qName);
if (ref != null && ref.isSolved()) {
return SymbolReference.adapt(ref, ResolvedTypeDeclaration.class);
}
} else {
// look for classes in the default package
String qName = name;
SymbolReference<ResolvedReferenceTypeDeclaration> ref = typeSolver.tryToSolveType(qName);
if (ref != null && ref.isSolved()) {
return SymbolReference.adapt(ref, ResolvedTypeDeclaration.class);
}
}

if (wrappedNode.getImports() != null) {
int dotPos = name.indexOf('.');
String prefix = null;
Expand Down Expand Up @@ -169,22 +185,6 @@ public SymbolReference<ResolvedTypeDeclaration> solveType(String name, TypeSolve
}
}

// Look in current package
if (this.wrappedNode.getPackageDeclaration().isPresent()) {
String qName = this.wrappedNode.getPackageDeclaration().get().getName().toString() + "." + name;
SymbolReference<ResolvedReferenceTypeDeclaration> ref = typeSolver.tryToSolveType(qName);
if (ref.isSolved()) {
return SymbolReference.adapt(ref, ResolvedTypeDeclaration.class);
}
} else {
// look for classes in the default package
String qName = name;
SymbolReference<ResolvedReferenceTypeDeclaration> ref = typeSolver.tryToSolveType(qName);
if (ref.isSolved()) {
return SymbolReference.adapt(ref, ResolvedTypeDeclaration.class);
}
}

// Look in the java.lang package
SymbolReference<ResolvedReferenceTypeDeclaration> ref = typeSolver.tryToSolveType("java.lang." + name);
if (ref.isSolved()) {
Expand Down

0 comments on commit b0185a7

Please sign in to comment.