Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
97 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 23 additions & 20 deletions
43
...est/java/com/github/javaparser/symbolsolver/utils/SymbolSolverCollectionStrategyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,45 @@ | ||
package com.github.javaparser.symbolsolver.utils; | ||
|
||
import com.github.javaparser.JavaParser; | ||
import com.github.javaparser.ParseResult; | ||
import com.github.javaparser.ast.CompilationUnit; | ||
import com.github.javaparser.ast.body.MethodDeclaration; | ||
import com.github.javaparser.utils.*; | ||
import com.github.javaparser.utils.CodeGenerationUtils; | ||
import com.github.javaparser.utils.Log; | ||
import com.github.javaparser.utils.ProjectRoot; | ||
import com.github.javaparser.utils.SourceRoot; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.Optional; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
public class SymbolSolverCollectionStrategyTest { | ||
|
||
private final Path root = CodeGenerationUtils.mavenModuleRoot(SymbolSolverCollectionStrategyTest.class).resolve("").getParent(); | ||
private final ProjectRoot projectRoot = new CollectionContext(new SymbolSolverCollectionStrategy()).collect(root); | ||
private final Path root = CodeGenerationUtils.mavenModuleRoot(JavaParser.class); | ||
private final ProjectRoot projectRoot = new SymbolSolverCollectionStrategy().collect(root); | ||
|
||
@Test | ||
public void resolveExpressions() throws IOException { | ||
Log.setAdapter(new Log.StandardOutStandardErrorAdapter()); | ||
Optional<SourceRoot> sourceRoot = projectRoot.getSourceRoot(root.resolve("javaparser-core/src/main/java")); | ||
assertTrue(sourceRoot.isPresent()); | ||
int unresolved = 0; | ||
for (ParseResult<CompilationUnit> parseResult : sourceRoot.get().tryToParse()) { | ||
CompilationUnit compilationUnit = parseResult.getResult().get(); | ||
for (MethodDeclaration expr : compilationUnit.findAll(MethodDeclaration.class)) { | ||
try { | ||
expr.resolve().getQualifiedSignature(); | ||
} catch (UnsupportedOperationException e) { | ||
// not supported operation, just skip | ||
} catch (Exception e) { | ||
unresolved++; | ||
Log.error(e, "Unable to resolve %s from %s", expr, compilationUnit.getStorage().get().getPath()); | ||
SourceRoot sourceRoot = projectRoot.getSourceRoot(root.resolve("src/main/java")).get(); | ||
AtomicInteger unresolved = new AtomicInteger(); | ||
for (ParseResult<CompilationUnit> parseResult : sourceRoot.tryToParse()) { | ||
parseResult.ifSuccessful(compilationUnit -> { | ||
for (MethodDeclaration expr : compilationUnit.findAll(MethodDeclaration.class)) { | ||
try { | ||
expr.resolve().getQualifiedSignature(); | ||
} catch (UnsupportedOperationException e) { | ||
// not supported operation, just skip | ||
} catch (Exception e) { | ||
unresolved.getAndIncrement(); | ||
Log.error(e, "Unable to resolve %s from %s", expr, compilationUnit.getStorage().get().getPath()); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
// not too many MethodDeclarations should be unresolved | ||
assertTrue(unresolved < 10); | ||
assertTrue(unresolved.get() < 10); | ||
} | ||
} |