Class JavaSymbolSolver

java.lang.Object
com.github.javaparser.symbolsolver.JavaSymbolSolver
All Implemented Interfaces:
com.github.javaparser.resolution.SymbolResolver

public class JavaSymbolSolver extends Object implements com.github.javaparser.resolution.SymbolResolver
This implementation of the SymbolResolver wraps the functionality of the library to make them easily usable from JavaParser nodes.

An instance of this class should be created once and then injected in all the CompilationUnit for which we want to enable symbol resolution. To do so the method inject can be used, or you can use ParserConfiguration.setSymbolResolver(SymbolResolver) and the parser will do the injection for you.

Author:
Federico Tomassetti
  • Constructor Summary

    Constructors
    Constructor
    Description
    JavaSymbolSolver(com.github.javaparser.resolution.TypeSolver typeSolver)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.github.javaparser.resolution.types.ResolvedType
    calculateType(com.github.javaparser.ast.expr.Expression expression)
     
    void
    inject(com.github.javaparser.ast.CompilationUnit destination)
    Register this SymbolResolver into a CompilationUnit, so that symbol resolution becomes available to all nodes part of the CompilationUnit.
    <T> T
    resolveDeclaration(com.github.javaparser.ast.Node node, Class<T> resultClass)
     
    <T> T
    toResolvedType(com.github.javaparser.ast.type.Type javaparserType, Class<T> resultClass)
     
    com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration
    toTypeDeclaration(com.github.javaparser.ast.Node node)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JavaSymbolSolver

      public JavaSymbolSolver(@NotNull com.github.javaparser.resolution.TypeSolver typeSolver)
  • Method Details

    • inject

      public void inject(com.github.javaparser.ast.CompilationUnit destination)
      Register this SymbolResolver into a CompilationUnit, so that symbol resolution becomes available to all nodes part of the CompilationUnit.
    • resolveDeclaration

      public <T> T resolveDeclaration(com.github.javaparser.ast.Node node, Class<T> resultClass)
      Specified by:
      resolveDeclaration in interface com.github.javaparser.resolution.SymbolResolver
    • toResolvedType

      public <T> T toResolvedType(com.github.javaparser.ast.type.Type javaparserType, Class<T> resultClass)
      Specified by:
      toResolvedType in interface com.github.javaparser.resolution.SymbolResolver
    • calculateType

      public com.github.javaparser.resolution.types.ResolvedType calculateType(com.github.javaparser.ast.expr.Expression expression)
      Specified by:
      calculateType in interface com.github.javaparser.resolution.SymbolResolver
    • toTypeDeclaration

      public com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration toTypeDeclaration(com.github.javaparser.ast.Node node)
      Specified by:
      toTypeDeclaration in interface com.github.javaparser.resolution.SymbolResolver