Interface Model

All Known Subinterfaces:
AnnotatedModel, ErroneousModel, NamedModel, NameHoldingModel
All Known Implementing Classes:
AbstractCaseLabelModel, AbstractExpressionModel, AbstractModel, AbstractPatternModel, AbstractStatementModel, AnnotationArgumentModel, AnnotationExpressionModel, AnyPatternModel, ArrayAccessExpressionModel, ArrayDeclarationExpressionModel, AssertStatementModel, AssignmentExpressionModel, BinaryExpressionModel, BindingPatternModel, BlockStatementModel, BreakStatementModel, CaseModel, CastExpressionModel, CatchModel, ClassModel, CompilationUnitModel, ConditionalExpressionModel, ConstCaseLabelModel, ContinueStatementModel, DeconstructionPatternModel, DefaultCaseLabelModel, DoWhileLoopStatementModel, EmptyStatementModel, EnhancedForLoopStatementModel, ErroneousExpressionModel, ErroneousExpressionStatementModel, ExpressionStatementModel, ForLoopStatementModel, GuardedPatternModel, IfStatementModel, ImplementsModel, ImportModel, InstanceofExpressionModel, LabeledStatementModel, LambdaExpressionModel, LiteralExpressionModel, MemberSelectExpressionModel, MethodBodyModel, MethodInvocationExpressionModel, MethodModel, MethodReferenceExpressionModel, ModifiersMapper.ModifiersParsePair, ModifiersModel, NameExpressionModel, NewClassExpressionModel, PackageModel, ParenthesizedExpressionModel, ParenthesizedPatternModel, PatternCaseLabelModel, PermitsModel, ReturnStatementModel, SwitchExpressionModel, SwitchStatementModel, SynchronizedStatementModel, ThrowStatementModel, TryStatementModel, TypeArgumentsMapper.Args, TypeModel, TypeModel.Array, TypeModel.NamedObject, TypeModel.Parameterized, TypeModel.Primitive, TypeModel.Union, TypeModel.Var, TypeModel.Wildcard, TypeParameterModel, UnaryExpressionModel, UnknownExpressionModel, UnknownPatternModel, UnknownStatementModel, VariableModel, WhileLoopStatementModel, YieldStatementModel

public interface Model
Base model type for all AST elements.
Author:
Matt Coley
  • Method Details

    • resolve

      @Nonnull default Resolution resolve(@Nonnull Resolver resolver)
      Parameters:
      resolver - Resolver to utilize.
      Returns:
      Resolution of what this model represents.
    • resolveAt

      @Nonnull Resolution resolveAt(@Nonnull Resolver resolver, int position)
      Parameters:
      resolver - Resolver to utilize.
      position - Absolute position in the source code of the item we want to resolve.
      Returns:
      Resolution of what this model represents at the given position.
    • visit

      default void visit(@Nonnull ModelVisitor visitor)
      Visits the current model and all children with the given visitor.
      Parameters:
      visitor - Visitor to observe this model and all children.
    • getChildAtPosition

      @Nullable default Model getChildAtPosition(int position)
      Parameters:
      position - Absolute position in the source code.
      Returns:
      Child contained by this model that contains the given position. null if no child contains the given point.
    • getRecursiveChildrenOfType

      @Nonnull default <M extends Model> List<M> getRecursiveChildrenOfType(@Nonnull Class<M> type)
      Type Parameters:
      M - Model type.
      Parameters:
      type - Model type to get.
      Returns:
      List of all children at all depths that are assignable to the requested type.
    • getParentOfType

      @Nullable default <M extends Model> M getParentOfType(@Nonnull Class<M> type)
      Type Parameters:
      M - Model type.
      Parameters:
      type - Model type to get.
      Returns:
      The first parent in this model's hierarchy that is assignable to the requested type. null if no parent in the model matches.
    • isParentOf

      default boolean isParentOf(@Nonnull Model model)
      Parameters:
      model - Model to check for as a child of this model.
      Returns:
      true when the given model is a child of this model.
    • isChildOf

      default boolean isChildOf(@Nonnull Model model)
      Parameters:
      model - Model to check for as a parent of this model.
      Returns:
      true when the given model is a parent of this model.
    • getSource

      @Nonnull default String getSource(@Nonnull CompilationUnitModel unit)
      Parameters:
      unit - Unit holding the original source code.
      Returns:
      Substring of source code this model is backed by.
    • getChildren

      @Nonnull List<Model> getChildren()
      Returns:
      Direct child models.
    • getParent

      @Nullable Model getParent()
      Returns:
      Direct parent model. Should only ever be null for CompilationUnitModel.
    • getRange

      @Nonnull Range getRange()
      Returns:
      Range within the source code this model originates from.