Skip to content

Commit

Permalink
fix issue in identifying files by absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomassetti committed Jul 15, 2018
1 parent f4147df commit 04423e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ private SymbolReference<ResolvedReferenceTypeDeclaration> tryToSolveTypeUncached
typeName.append(nameElements[j]);
}

// As an optimization we first try to look in the canonical position where we expect to find the file
Path srcFile = Paths.get(filePath.toString());
{
Optional<CompilationUnit> compilationUnit = parse(srcFile);
Expand All @@ -195,8 +196,9 @@ private SymbolReference<ResolvedReferenceTypeDeclaration> tryToSolveTypeUncached
}
}

// If this is not possible we parse all files
{
List<CompilationUnit> compilationUnits = parseDirectory(srcFile.getParent());
List<CompilationUnit> compilationUnits = parseDirectory(srcDir);
for (CompilationUnit compilationUnit : compilationUnits) {
Optional<com.github.javaparser.ast.body.TypeDeclaration<?>> astTypeDeclaration = Navigator.findType(compilationUnit, typeName.toString());
if (astTypeDeclaration.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public void resolveFieldOfEnumAsInternalClassOfInterfaceQualifiedSamePackage() t

assertTrue(fae.isPresent());

assertEquals("", fae.get().resolve().getType().describe());
assertEquals("", fae.get().resolve().getName());
assertEquals("foo.bar.AnInterface.ListChangeType", fae.get().resolve().getType().describe());
assertEquals("ADDITION", fae.get().resolve().getName());
}

@Test
Expand Down Expand Up @@ -104,7 +104,7 @@ public void resolveFieldOfEnumAsInternalClassOfInterfaceQualifiedDifferentPackag

assertTrue(fae.isPresent());

assertEquals("", fae.get().resolve().getType().describe());
assertEquals("", fae.get().resolve().getName());
assertEquals("foo.bar.AnInterface.ListChangeType", fae.get().resolve().getType().describe());
assertEquals("ADDITION", fae.get().resolve().getName());
}
}

0 comments on commit 04423e5

Please sign in to comment.