Class 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 Detail

      • JavaSymbolSolver

        public JavaSymbolSolver​(com.github.javaparser.symbolsolver.model.resolution.TypeSolver typeSolver)
    • Method Detail

      • 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