Class AbstractJavaParserContext<N extends com.github.javaparser.ast.Node>

java.lang.Object
com.github.javaparser.symbolsolver.javaparsermodel.contexts.AbstractJavaParserContext<N>
All Implemented Interfaces:
com.github.javaparser.resolution.Context
Direct Known Subclasses:
AbstractMethodLikeDeclarationContext, AnnotationDeclarationContext, AnonymousClassDeclarationContext, CatchClauseContext, ClassOrInterfaceDeclarationContext, ClassOrInterfaceDeclarationExtendsContext, CompilationUnitContext, EnumDeclarationContext, ExpressionContext, RecordDeclarationContext, StatementContext, SwitchEntryContext, VariableDeclaratorContext

public abstract class AbstractJavaParserContext<N extends com.github.javaparser.ast.Node> extends Object implements com.github.javaparser.resolution.Context
Author:
Federico Tomassetti
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected com.github.javaparser.resolution.TypeSolver
     
    protected N
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractJavaParserContext(N wrappedNode, com.github.javaparser.resolution.TypeSolver typeSolver)
    Constructors
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Public methods
    com.github.javaparser.resolution.model.SymbolReference<? extends com.github.javaparser.resolution.declarations.ResolvedValueDeclaration>
    findExposedPatternInParentContext(com.github.javaparser.ast.Node parent, String name)
     
    protected Collection<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration>
    findTypeDeclarations(Optional<com.github.javaparser.ast.expr.Expression> optScope)
     
    final Optional<com.github.javaparser.resolution.Context>
     
    protected com.github.javaparser.ast.Node
    getScope(com.github.javaparser.ast.Node node)
     
     
    int
     
    List<com.github.javaparser.ast.expr.TypePatternExpr>
     
    Optional<com.github.javaparser.resolution.MethodUsage>
    solveMethodAsUsage(String name, List<com.github.javaparser.resolution.types.ResolvedType> argumentsTypes)
    Similar to solveMethod but we return a MethodUsage.
    com.github.javaparser.resolution.model.SymbolReference<? extends com.github.javaparser.resolution.declarations.ResolvedValueDeclaration>
     
    static com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedValueDeclaration>
    solveWith(com.github.javaparser.resolution.SymbolDeclarator symbolDeclarator, String name)
    Static methods
    protected Optional<com.github.javaparser.resolution.model.Value>
    solveWithAsValue(com.github.javaparser.resolution.SymbolDeclarator symbolDeclarator, String name)
    Protected methods
    List<com.github.javaparser.ast.expr.TypePatternExpr>
    typePatternExprsDiscoveredInPattern(com.github.javaparser.ast.expr.ComponentPatternExpr patternExpr)
    When looking for a variable declaration in a pattern expression, there are 2 cases: 1.
    List<com.github.javaparser.ast.expr.TypePatternExpr>
     

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

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

    fieldDeclarationInScope, fieldsExposedToChild, localVariableDeclarationInScope, localVariablesExposedToChild, parameterDeclarationInScope, parametersExposedToChild, solveConstructor, solveGenericType, solveGenericTypeInParentContext, solveMethod, solveMethodInParentContext, solveSymbol, solveSymbolAsValue, solveSymbolAsValueInParentContext, solveType, solveType, solveTypeInParentContext, solveTypeInParentContext, typePatternExprInScope, typePatternExprsExposedToChild
  • Field Details

    • wrappedNode

      protected N extends com.github.javaparser.ast.Node wrappedNode
    • typeSolver

      protected com.github.javaparser.resolution.TypeSolver typeSolver
  • Constructor Details

    • AbstractJavaParserContext

      public AbstractJavaParserContext(N wrappedNode, com.github.javaparser.resolution.TypeSolver typeSolver)
      Constructors
  • Method Details

    • solveWith

      public static com.github.javaparser.resolution.model.SymbolReference<com.github.javaparser.resolution.declarations.ResolvedValueDeclaration> solveWith(com.github.javaparser.resolution.SymbolDeclarator symbolDeclarator, String name)
      Static methods
    • equals

      public boolean equals(Object o)
      Public methods
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getParent

      public final Optional<com.github.javaparser.resolution.Context> getParent()
      Specified by:
      getParent in interface com.github.javaparser.resolution.Context
    • getScope

      protected com.github.javaparser.ast.Node getScope(com.github.javaparser.ast.Node node)
    • solveSymbolInParentContext

      public com.github.javaparser.resolution.model.SymbolReference<? extends com.github.javaparser.resolution.declarations.ResolvedValueDeclaration> solveSymbolInParentContext(String name)
      Specified by:
      solveSymbolInParentContext in interface com.github.javaparser.resolution.Context
    • solveWithAsValue

      protected Optional<com.github.javaparser.resolution.model.Value> solveWithAsValue(com.github.javaparser.resolution.SymbolDeclarator symbolDeclarator, String name)
      Protected methods
    • findTypeDeclarations

      protected Collection<com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration> findTypeDeclarations(Optional<com.github.javaparser.ast.expr.Expression> optScope)
    • solveMethodAsUsage

      public Optional<com.github.javaparser.resolution.MethodUsage> solveMethodAsUsage(String name, List<com.github.javaparser.resolution.types.ResolvedType> argumentsTypes)
      Similar to solveMethod but we return a MethodUsage. A MethodUsage corresponds to a MethodDeclaration plus the resolved type variables.
      Specified by:
      solveMethodAsUsage in interface com.github.javaparser.resolution.Context
    • getWrappedNode

      public N getWrappedNode()
      Specified by:
      getWrappedNode in interface com.github.javaparser.resolution.Context
    • typePatternExprsDiscoveredInPattern

      public List<com.github.javaparser.ast.expr.TypePatternExpr> typePatternExprsDiscoveredInPattern(com.github.javaparser.ast.expr.ComponentPatternExpr patternExpr)
      When looking for a variable declaration in a pattern expression, there are 2 cases: 1. The pattern expression is a type pattern expression (e.g. Foo f), in which case we can just compare the name of the variable we're trying to resolve with the name declared in the pattern. 2. The pattern expression is a record pattern expression (e.g. Foo (Bar b, Baz (...) )), in which case we need to traverse the "pattern tree" to find all type pattern expressions, so that we can compare names for all of these. In both cases, we only really care about the type pattern expressions, so this method simply does a traversal of the pattern tree to find all type pattern expressions contained in it.
      Parameters:
      patternExpr - the root of the pattern tree to traverse
      Returns:
      all type pattern expressions discovered in the tree
    • findExposedPatternInParentContext

      public com.github.javaparser.resolution.model.SymbolReference<? extends com.github.javaparser.resolution.declarations.ResolvedValueDeclaration> findExposedPatternInParentContext(com.github.javaparser.ast.Node parent, String name)
    • typePatternExprsExposedFromChildren

      public List<com.github.javaparser.ast.expr.TypePatternExpr> typePatternExprsExposedFromChildren()
      Specified by:
      typePatternExprsExposedFromChildren in interface com.github.javaparser.resolution.Context
    • negatedTypePatternExprsExposedFromChildren

      public List<com.github.javaparser.ast.expr.TypePatternExpr> negatedTypePatternExprsExposedFromChildren()
      Specified by:
      negatedTypePatternExprsExposedFromChildren in interface com.github.javaparser.resolution.Context