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
cd885e8
commit 6b50c90
Showing
37 changed files
with
135 additions
and
79 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
28 changes: 28 additions & 0 deletions
28
...l-solver-core/src/main/java/me/tomassetti/symbolsolver/core/resolution/ContextHelper.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,28 @@ | ||
package me.tomassetti.symbolsolver.core.resolution; | ||
|
||
import me.tomassetti.symbolsolver.javaparsermodel.declarations.JavaParserEnumDeclaration; | ||
import me.tomassetti.symbolsolver.javaparsermodel.declarations.JavaParserMethodDeclaration; | ||
import me.tomassetti.symbolsolver.javassistmodel.JavassistMethodDeclaration; | ||
import me.tomassetti.symbolsolver.model.declarations.MethodDeclaration; | ||
import me.tomassetti.symbolsolver.model.invokations.MethodUsage; | ||
import me.tomassetti.symbolsolver.model.typesystem.Type; | ||
import me.tomassetti.symbolsolver.reflectionmodel.ReflectionMethodDeclaration; | ||
|
||
import java.util.List; | ||
|
||
public class ContextHelper { | ||
|
||
static MethodUsage resolveTypeVariables(Context context, MethodDeclaration methodDeclaration, List<Type> parameterTypes) { | ||
if (methodDeclaration instanceof JavaParserMethodDeclaration) { | ||
return ((JavaParserMethodDeclaration)methodDeclaration).resolveTypeVariables(context, parameterTypes); | ||
} else if (methodDeclaration instanceof JavassistMethodDeclaration) { | ||
return ((JavassistMethodDeclaration)methodDeclaration).resolveTypeVariables(context, parameterTypes); | ||
} else if (methodDeclaration instanceof JavaParserEnumDeclaration.ValuesMethod) { | ||
return ((JavaParserEnumDeclaration.ValuesMethod)methodDeclaration).resolveTypeVariables(context, parameterTypes); | ||
} else if (methodDeclaration instanceof ReflectionMethodDeclaration) { | ||
return ((ReflectionMethodDeclaration)methodDeclaration).resolveTypeVariables(context, parameterTypes); | ||
} else { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...ore/src/main/java/me/tomassetti/symbolsolver/javaparsermodel/UnsolvedSymbolException.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
4 changes: 2 additions & 2 deletions
4
...-core/src/main/java/me/tomassetti/symbolsolver/javaparsermodel/UnsolvedTypeException.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
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
52 changes: 52 additions & 0 deletions
52
...core/src/main/java/me/tomassetti/symbolsolver/javaparsermodel/contexts/ContextHelper.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,52 @@ | ||
package me.tomassetti.symbolsolver.javaparsermodel.contexts; | ||
|
||
import me.tomassetti.symbolsolver.core.resolution.Context; | ||
import me.tomassetti.symbolsolver.javaparsermodel.declarations.JavaParserEnumDeclaration; | ||
import me.tomassetti.symbolsolver.javassistmodel.JavassistClassDeclaration; | ||
import me.tomassetti.symbolsolver.javassistmodel.JavassistInterfaceDeclaration; | ||
import me.tomassetti.symbolsolver.model.declarations.TypeDeclaration; | ||
import me.tomassetti.symbolsolver.model.invokations.MethodUsage; | ||
import me.tomassetti.symbolsolver.model.resolution.TypeSolver; | ||
import me.tomassetti.symbolsolver.model.typesystem.Type; | ||
import me.tomassetti.symbolsolver.reflectionmodel.ReflectionClassDeclaration; | ||
import me.tomassetti.symbolsolver.reflectionmodel.ReflectionInterfaceDeclaration; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
/** | ||
* Created by federico on 14/10/16. | ||
*/ | ||
public class ContextHelper { | ||
|
||
public static Context getContext(TypeDeclaration typeDeclaration) { | ||
try { | ||
return (Context)typeDeclaration.getClass().getMethod("getContext").invoke(typeDeclaration); | ||
} catch (IllegalAccessException e) { | ||
throw new RuntimeException(e); | ||
} catch (InvocationTargetException e) { | ||
throw new RuntimeException(e); | ||
} catch (NoSuchMethodException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public static Optional<MethodUsage> solveMethodAsUsage(TypeDeclaration typeDeclaration, String name, | ||
List<Type> parameterTypes, TypeSolver typeSolver, | ||
Context invokationContext, List<Type> typeParameters) { | ||
if (typeDeclaration instanceof JavassistClassDeclaration) { | ||
return ((JavassistClassDeclaration) typeDeclaration).solveMethodAsUsage(name, parameterTypes, typeSolver, invokationContext, typeParameters); | ||
} else if (typeDeclaration instanceof JavassistInterfaceDeclaration) { | ||
return ((JavassistInterfaceDeclaration) typeDeclaration).solveMethodAsUsage(name, parameterTypes, typeSolver, invokationContext, typeParameters); | ||
} else if (typeDeclaration instanceof JavaParserEnumDeclaration) { | ||
return ((JavaParserEnumDeclaration) typeDeclaration).solveMethodAsUsage(name, parameterTypes, typeSolver, invokationContext, typeParameters); | ||
} else if (typeDeclaration instanceof ReflectionClassDeclaration) { | ||
return ((ReflectionClassDeclaration) typeDeclaration).solveMethodAsUsage(name, parameterTypes, typeSolver, invokationContext, typeParameters); | ||
} else if (typeDeclaration instanceof ReflectionInterfaceDeclaration) { | ||
return ((ReflectionInterfaceDeclaration) typeDeclaration).solveMethodAsUsage(name, parameterTypes, typeSolver, invokationContext, typeParameters); | ||
} | ||
return getContext(typeDeclaration).solveMethodAsUsage(name, parameterTypes, typeSolver); | ||
} | ||
|
||
} |
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
Oops, something went wrong.