-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 #2876 from jlerbsc/master
Fixx issue 2284 Can't get qualified signature of a resolved method inside a Constant Enum declaration
- Loading branch information
Showing
2 changed files
with
103 additions
and
7 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
48 changes: 48 additions & 0 deletions
48
...symbol-solver-testing/src/test/java/com/github/javaparser/symbolsolver/Issue2284Test.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,48 @@ | ||
package com.github.javaparser.symbolsolver; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.List; | ||
|
||
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.body.MethodDeclaration; | ||
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver; | ||
import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver; | ||
|
||
public class Issue2284Test extends AbstractSymbolResolutionTest { | ||
|
||
@Test | ||
public void test() { | ||
|
||
TypeSolver typeSolver = new ReflectionTypeSolver(false); | ||
ParserConfiguration config = new ParserConfiguration(); | ||
config.setSymbolResolver(new JavaSymbolSolver(typeSolver)); | ||
StaticJavaParser.setConfiguration(config); | ||
|
||
String s = | ||
"public enum Enum {\n" + | ||
" CONSTANT_ENUM() {\n" + | ||
" @Override\n" + | ||
" String getEnumName() {\n" + | ||
" return \"CONSTANT_ENUM\";\n" + | ||
" }\n" + | ||
" };\n" + | ||
" \n" + | ||
" String getEnumName() {\n" + | ||
" return \"default\";\n" + | ||
" }\n" + | ||
"}"; | ||
|
||
CompilationUnit cu = StaticJavaParser.parse(s); | ||
List<MethodDeclaration> mds = cu.findAll(MethodDeclaration.class); | ||
mds.forEach(md-> { | ||
assertEquals("Enum.getEnumName()", md.resolve().getQualifiedSignature()); | ||
}); | ||
|
||
} | ||
|
||
} |