Class JavaParserTypeSolver

java.lang.Object
com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver
All Implemented Interfaces:
com.github.javaparser.resolution.TypeSolver

public class JavaParserTypeSolver extends Object implements com.github.javaparser.resolution.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.
Author:
Federico Tomassetti
  • Field Summary

    Fields inherited from interface com.github.javaparser.resolution.TypeSolver

    JAVA_LANG_OBJECT, JAVA_LANG_RECORD
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    JavaParserTypeSolver(File srcDir, com.github.javaparser.ParserConfiguration parserConfiguration)
     
     
    JavaParserTypeSolver(String srcDir, com.github.javaparser.ParserConfiguration parserConfiguration)
     
     
    JavaParserTypeSolver(Path srcDir, com.github.javaparser.JavaParser javaParser, com.github.javaparser.resolution.cache.Cache<Path, Optional<com.github.javaparser.ast.CompilationUnit>> parsedFilesCache, com.github.javaparser.resolution.cache.Cache<Path, List<com.github.javaparser.ast.CompilationUnit>> parsedDirectoriesCache, com.github.javaparser.resolution.cache.Cache<String, com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration>> foundTypesCache)
    Create a JavaParserTypeSolver with a custom cache system.
    JavaParserTypeSolver(Path srcDir, com.github.javaparser.ParserConfiguration parserConfiguration)
     
    JavaParserTypeSolver(Path srcDir, com.github.javaparser.ParserConfiguration parserConfiguration, long cacheSizeLimit)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.github.javaparser.resolution.TypeSolver
     
    void
    setParent(com.github.javaparser.resolution.TypeSolver parent)
     
     
    com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration>
     
    com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration>
    tryToSolveTypeInModule(String qualifiedModuleName, String simpleTypeName)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.github.javaparser.resolution.TypeSolver

    getRoot, getSolvedJavaLangObject, getSolvedJavaLangRecord, hasType, solveType, solveTypeInModule
  • Constructor Details

    • JavaParserTypeSolver

      public JavaParserTypeSolver(File srcDir)
    • JavaParserTypeSolver

      public JavaParserTypeSolver(String srcDir)
    • JavaParserTypeSolver

      public JavaParserTypeSolver(Path srcDir)
    • JavaParserTypeSolver

      public JavaParserTypeSolver(File srcDir, com.github.javaparser.ParserConfiguration parserConfiguration)
    • JavaParserTypeSolver

      public JavaParserTypeSolver(String srcDir, com.github.javaparser.ParserConfiguration parserConfiguration)
    • JavaParserTypeSolver

      public JavaParserTypeSolver(Path srcDir, com.github.javaparser.ParserConfiguration parserConfiguration)
    • JavaParserTypeSolver

      public JavaParserTypeSolver(Path srcDir, com.github.javaparser.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, com.github.javaparser.JavaParser javaParser, com.github.javaparser.resolution.cache.Cache<Path, Optional<com.github.javaparser.ast.CompilationUnit>> parsedFilesCache, com.github.javaparser.resolution.cache.Cache<Path, List<com.github.javaparser.ast.CompilationUnit>> parsedDirectoriesCache, com.github.javaparser.resolution.cache.Cache<String, com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration>> foundTypesCache)
      Create a JavaParserTypeSolver with a custom cache system.
      Parameters:
      srcDir - The source code directory for the type solver.
      javaParser - The JavaParser to be used when parsing .java files.
      parsedFilesCache - The cache to be used to store CompilationUnit that is associated with a file.
      parsedDirectoriesCache - The cache to store the list of CompilationUnit in a given directory.
      foundTypesCache - The cache that associated a qualified name to its SymbolReference.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getParent

      public com.github.javaparser.resolution.TypeSolver getParent()
      Specified by:
      getParent in interface com.github.javaparser.resolution.TypeSolver
    • setParent

      public void setParent(com.github.javaparser.resolution.TypeSolver parent)
      Specified by:
      setParent in interface com.github.javaparser.resolution.TypeSolver
    • tryToSolveType

      public com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration> tryToSolveType(String name)
      Specified by:
      tryToSolveType in interface com.github.javaparser.resolution.TypeSolver
    • tryToSolveTypeInModule

      public com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration> tryToSolveTypeInModule(String qualifiedModuleName, String simpleTypeName)
      Specified by:
      tryToSolveTypeInModule in interface com.github.javaparser.resolution.TypeSolver