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
1 parent
656bb37
commit 4067732
Showing
16 changed files
with
127 additions
and
89 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
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
72 changes: 72 additions & 0 deletions
72
...bol-solver-core/src/test/java/me/tomassetti/symbolsolver/resolution/SymbolSolverTest.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,72 @@ | ||
package me.tomassetti.symbolsolver.resolution; | ||
|
||
import me.tomassetti.symbolsolver.AbstractTest; | ||
import me.tomassetti.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration; | ||
import me.tomassetti.symbolsolver.model.declarations.ValueDeclaration; | ||
import me.tomassetti.symbolsolver.model.resolution.SymbolReference; | ||
import me.tomassetti.symbolsolver.model.resolution.TypeSolver; | ||
import me.tomassetti.symbolsolver.resolution.typesolvers.CombinedTypeSolver; | ||
import me.tomassetti.symbolsolver.resolution.typesolvers.JavaParserTypeSolver; | ||
import me.tomassetti.symbolsolver.resolution.typesolvers.JreTypeSolver; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author Federico Tomassetti | ||
*/ | ||
public class SymbolSolverTest extends AbstractTest { | ||
|
||
private TypeSolver typeSolverNewCode; | ||
private SymbolSolver symbolSolver; | ||
|
||
@Before | ||
public void setup() { | ||
|
||
File srcNewCode = adaptPath(new File("src/test/resources/javaparser_new_src/javaparser-core")); | ||
CombinedTypeSolver combinedTypeSolverNewCode = new CombinedTypeSolver(); | ||
combinedTypeSolverNewCode.add(new JreTypeSolver()); | ||
combinedTypeSolverNewCode.add(new JavaParserTypeSolver(srcNewCode)); | ||
combinedTypeSolverNewCode.add(new JavaParserTypeSolver(adaptPath(new File("src/test/resources/javaparser_new_src/javaparser-generated-sources")))); | ||
typeSolverNewCode = combinedTypeSolverNewCode; | ||
|
||
symbolSolver = new SymbolSolver(typeSolverNewCode); | ||
} | ||
|
||
@Test | ||
public void testSolveSymbolUnexisting() { | ||
JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolverNewCode.solveType("com.github.javaparser.ast.body.ConstructorDeclaration"); | ||
|
||
SymbolReference<? extends ValueDeclaration> res = symbolSolver.solveSymbolInType(constructorDeclaration, "unexisting"); | ||
assertEquals(false, res.isSolved()); | ||
} | ||
|
||
@Test | ||
public void testSolveSymbolToDeclaredField() { | ||
JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolverNewCode.solveType("com.github.javaparser.ast.body.ConstructorDeclaration"); | ||
|
||
SymbolReference<? extends ValueDeclaration> res = symbolSolver.solveSymbolInType(constructorDeclaration, "name"); | ||
assertEquals(true, res.isSolved()); | ||
assertEquals(true, res.getCorrespondingDeclaration().isField()); | ||
} | ||
|
||
@Test | ||
public void testSolveSymbolToInheritedPublicField() { | ||
JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolverNewCode.solveType("com.github.javaparser.ast.body.ConstructorDeclaration"); | ||
|
||
SymbolReference<? extends ValueDeclaration> res = symbolSolver.solveSymbolInType(constructorDeclaration, "NODE_BY_BEGIN_POSITION"); | ||
assertEquals(true, res.isSolved()); | ||
assertEquals(true, res.getCorrespondingDeclaration().isField()); | ||
} | ||
|
||
@Test | ||
public void testSolveSymbolToInheritedPrivateField() { | ||
JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolverNewCode.solveType("com.github.javaparser.ast.body.ConstructorDeclaration"); | ||
|
||
SymbolReference<? extends ValueDeclaration> res = symbolSolver.solveSymbolInType(constructorDeclaration, "parentNode"); | ||
assertEquals(false, res.isSolved()); | ||
} | ||
} |
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