Class JavaParserTypeSolver
java.lang.Object
com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver
- All Implemented Interfaces:
TypeSolver
Defines a directory containing source code that should be used for solving symbols.
The directory must correspond to the root package of the files within.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final Cache<String, SymbolReference<ResolvedReferenceTypeDeclaration>> private final JavaParserprivate TypeSolverprivate final Cache<Path, List<CompilationUnit>> private final Cache<Path, Optional<CompilationUnit>> private final PathFields inherited from interface TypeSolver
JAVA_LANG_OBJECT, JAVA_LANG_RECORD -
Constructor Summary
ConstructorsConstructorDescriptionJavaParserTypeSolver(File srcDir) JavaParserTypeSolver(File srcDir, ParserConfiguration parserConfiguration) JavaParserTypeSolver(String srcDir) JavaParserTypeSolver(String srcDir, ParserConfiguration parserConfiguration) JavaParserTypeSolver(Path srcDir) JavaParserTypeSolver(Path srcDir, JavaParser javaParser, Cache<Path, Optional<CompilationUnit>> parsedFilesCache, Cache<Path, List<CompilationUnit>> parsedDirectoriesCache, Cache<String, SymbolReference<ResolvedReferenceTypeDeclaration>> foundTypesCache) Create aJavaParserTypeSolverwith a custom cache system.JavaParserTypeSolver(Path srcDir, ParserConfiguration parserConfiguration) JavaParserTypeSolver(Path srcDir, ParserConfiguration parserConfiguration, long cacheSizeLimit) -
Method Summary
Modifier and TypeMethodDescriptionprivate <TKey,TValue>
Cache<TKey, TValue> BuildCache(long cacheSizeLimit) Parent of the this TypeSolver.private Optional<CompilationUnit> private List<CompilationUnit> parseDirectory(Path srcDirectory) Note that this parse only files directly contained in this directory.private List<CompilationUnit> parseDirectory(Path srcDirectory, boolean recursively) private List<CompilationUnit> parseDirectoryRecursively(Path srcDirectory) private voidpopulateModuleInfoCache(Path srcDir) voidsetParent(TypeSolver parent) Set the parent of this TypeSolver.toString()tryToSolveType(String name) Try to solve the type with the given name.tryToSolveTypeInModule(String qualifiedModuleName, String simpleTypeName) tryToSolveTypeUncached(String name) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface TypeSolver
getRoot, getSolvedJavaLangObject, getSolvedJavaLangRecord, hasType, solveType, solveTypeInModule
-
Field Details
-
srcDir
-
javaParser
-
parent
-
parsedFiles
-
parsedDirectories
-
foundTypes
-
modulesToExportedPackages
-
CACHE_SIZE_UNSET
private static final int CACHE_SIZE_UNSET- See Also:
-
-
Constructor Details
-
JavaParserTypeSolver
-
JavaParserTypeSolver
-
JavaParserTypeSolver
-
JavaParserTypeSolver
-
JavaParserTypeSolver
-
JavaParserTypeSolver
-
JavaParserTypeSolver
public JavaParserTypeSolver(Path srcDir, ParserConfiguration parserConfiguration, long cacheSizeLimit) - Parameters:
srcDir- is the source code directory for the type solver.parserConfiguration- is the configuration the solver should use when inspecting source code files.cacheSizeLimit- is an optional size limit to the internal caches used by this solver. Be advised that setting the size too low might lead to noticeable performance degradation. However, using a size limit is advised when solving symbols in large code sources. In such cases, internal caches might consume large amounts of heap space.
-
JavaParserTypeSolver
public JavaParserTypeSolver(Path srcDir, JavaParser javaParser, Cache<Path, Optional<CompilationUnit>> parsedFilesCache, Cache<Path, List<CompilationUnit>> parsedDirectoriesCache, Cache<String, SymbolReference<ResolvedReferenceTypeDeclaration>> foundTypesCache) Create aJavaParserTypeSolverwith a custom cache system.- Parameters:
srcDir- The source code directory for the type solver.javaParser- TheJavaParserto be used when parsing .java files.parsedFilesCache- The cache to be used to storeCompilationUnitthat is associated with a file.parsedDirectoriesCache- The cache to store the list ofCompilationUnitin a given directory.foundTypesCache- The cache that associated a qualified name to itsSymbolReference.
-
-
Method Details
-
BuildCache
-
populateModuleInfoCache
-
toString
-
getParent
Description copied from interface:TypeSolverParent of the this TypeSolver. This can return null.- Specified by:
getParentin interfaceTypeSolver
-
setParent
Description copied from interface:TypeSolverSet the parent of this TypeSolver.- Specified by:
setParentin interfaceTypeSolver
-
parse
-
parseDirectory
Note that this parse only files directly contained in this directory. It does not traverse recursively all children directory. -
parseDirectoryRecursively
-
parseDirectory
-
tryToSolveType
Description copied from interface:TypeSolverTry to solve the type with the given name. It always return a SymbolReference which can be solved or unsolved.- Specified by:
tryToSolveTypein interfaceTypeSolver
-
tryToSolveTypeUncached
-
tryToSolveTypeInModule
public SymbolReference<ResolvedReferenceTypeDeclaration> tryToSolveTypeInModule(String qualifiedModuleName, String simpleTypeName) - Specified by:
tryToSolveTypeInModulein interfaceTypeSolver
-