Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3671 from jlerbsc/master
Fix issue #3614 UnsolvedSymbolException when package declaration contains comment
- Loading branch information
Showing
2 changed files
with
40 additions
and
4 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
36 changes: 36 additions & 0 deletions
36
...symbol-solver-testing/src/test/java/com/github/javaparser/symbolsolver/Issue3614Test.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.github.javaparser.symbolsolver; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.github.javaparser.ParserConfiguration; | ||
import com.github.javaparser.StaticJavaParser; | ||
import com.github.javaparser.ast.CompilationUnit; | ||
import com.github.javaparser.ast.expr.VariableDeclarationExpr; | ||
import com.github.javaparser.symbolsolver.resolution.AbstractResolutionTest; | ||
import com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver; | ||
import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver; | ||
|
||
public class Issue3614Test extends AbstractResolutionTest { | ||
|
||
@Test | ||
void test() { | ||
String code = "package java./*aaaaa*/util;\n" | ||
+ "class Foo {\n" | ||
+ " public void test() {\n" | ||
+ " ArrayList list = new ArrayList();\n" | ||
+ " }" | ||
+ "}"; | ||
|
||
ParserConfiguration configuration = new ParserConfiguration() | ||
.setSymbolResolver(new JavaSymbolSolver(new CombinedTypeSolver(new ReflectionTypeSolver()))); | ||
StaticJavaParser.setConfiguration(configuration); | ||
|
||
CompilationUnit cu = StaticJavaParser.parse(code); | ||
|
||
VariableDeclarationExpr vde = cu.findFirst(VariableDeclarationExpr.class).get(); | ||
String resolvedType = vde.calculateResolvedType().describe(); | ||
assertEquals("java.util.ArrayList", resolvedType); | ||
} | ||
} |