-
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 #4430 from apiiro/fix-4427-resolution-of-extends-a…
…nd-implements Make resoltuion of implements and extends types start with the parent…
- Loading branch information
Showing
4 changed files
with
62 additions
and
2 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/Issue4427Test.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 com.github.javaparser.ParserConfiguration; | ||
import com.github.javaparser.StaticJavaParser; | ||
import com.github.javaparser.ast.CompilationUnit; | ||
import com.github.javaparser.ast.expr.NameExpr; | ||
import com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver; | ||
import com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver; | ||
import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
public class Issue4427Test extends AbstractSymbolResolutionTest { | ||
@Test | ||
public void testIssue4427() throws IOException { | ||
Path issueResourcesPath = adaptPath("src/test/resources/issue4427"); | ||
ReflectionTypeSolver rts = new ReflectionTypeSolver(); | ||
JavaParserTypeSolver jpts = new JavaParserTypeSolver(issueResourcesPath); | ||
CombinedTypeSolver cts = new CombinedTypeSolver(); | ||
cts.add(rts); | ||
cts.add(jpts); | ||
ParserConfiguration pc = new ParserConfiguration() | ||
.setSymbolResolver(new JavaSymbolSolver(cts)); | ||
StaticJavaParser.setConfiguration(pc); | ||
CompilationUnit cu = StaticJavaParser.parse(issueResourcesPath.resolve("DerivedClass.java")); | ||
|
||
// We shouldn't throw a mismatched symbol | ||
assertDoesNotThrow(() -> cu.findAll(NameExpr.class).stream() | ||
.map(NameExpr::resolve) | ||
.findAny().get()); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
javaparser-symbol-solver-testing/src/test/resources/issue4427/BaseClass.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,4 @@ | ||
public abstract class BaseClass { | ||
|
||
protected int x; | ||
} |
11 changes: 11 additions & 0 deletions
11
javaparser-symbol-solver-testing/src/test/resources/issue4427/DerivedClass.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,11 @@ | ||
public class DerivedClass extends BaseClass { | ||
|
||
void f() { | ||
x = x + 1; | ||
} | ||
|
||
|
||
static class BaseClass extends SecondBaseClass { | ||
|
||
} | ||
} |