Interface IJavaElement

All Known Subinterfaces:
IJavaAnnotation, IJavaAnnotationElement, IJavaArrayElt, IJavaAssignment, IJavaBlock, IJavaBreak, IJavaCall, IJavaClass, IJavaCompound, IJavaConditionalExpression, IJavaConstant, IJavaContinue, IJavaDecompilableElement, IJavaDefinition, IJavaDoWhile, IJavaExpression, IJavaField, IJavaFor, IJavaForEach, IJavaGoto, IJavaIdentifier, IJavaIf, IJavaInstanceField, IJavaLabel, IJavaLeftExpression, IJavaMethod, IJavaMonitor, IJavaNew, IJavaNewArray, IJavaOperation, IJavaPredicate, IJavaPredicate_LEGACY, IJavaReturn, IJavaStatement, IJavaStaticField, IJavaSwitch, IJavaSynchronizedBlock, IJavaTerminalStatement, IJavaThrow, IJavaTry, IJavaTypeReference, IJavaWhile

@Ser public interface IJavaElement
Top-level interface for all elements of a Java Abstract Syntax Tree.

Each AST element implements this interface or one of the sub-interfaces.

  • Field Details

  • Method Details

    • hasPhysicalMethodIndex

      boolean hasPhysicalMethodIndex()
      Determine whether an explicit physical method index is attached to this element.

      For code located in a method, the default method attached to an AST element is the method containing the element.

      Returns:
    • setPhysicalMethodIndex

      void setPhysicalMethodIndex(int midx)
      Set an explicit low-level dex method index of this AST element. This method is useful to override the default (owner method), such as when a method contains inlined code from another method.

      For code located in a method, the default method attached to an AST element is the method containing the element.

      Parameters:
      midx - a lower-level dex method index, or -1 to signify none or the default
    • getPhysicalMethodIndex

      int getPhysicalMethodIndex()
      Retrieve the explicit low-level dex method index of this AST element.

      For code located in a method, the default method attached to an AST element is the method containing the element.

      Returns:
      a lower-level dex method index, or -1 to signify none or the default
    • hasPhysicalOffset

      boolean hasPhysicalOffset()
      Determine whether a physical offset is attached to this element.
      Returns:
    • getPhysicalOffset

      int getPhysicalOffset()
      Retrieve the low-level offset that map to this AST element.
      Returns:
      a physical method offset, -1 if none is available
    • setPhysicalOffset

      void setPhysicalOffset(int offset)
      Set a low-level physical offset to this AST element.
      Parameters:
      offset -
    • collectAllPhysicalOffsets

      void collectAllPhysicalOffsets(Collection<Integer> physicalOffsets)
      Collect physical offsets for this element and all its constituents. The first element added is for this one, followed by the sub-elements's.
      Parameters:
      physicalOffsets - output collection
    • getSubElements

      List<IJavaElement> getSubElements()
      Get the list of AST elements that constitute this AST element. Typically, for simple statements, it may be expression. For complex expressions, it may be simpler expressions. For compound statements, it may more statements and expressions.

      Note that type and annotation elements are not returned by this method.

      Returns:
      the list of constituting elements, may be empty but never null
    • replaceSubElement

      boolean replaceSubElement(IJavaElement oldElement, IJavaElement newElement)
      Replace one element by another one. Only the references are compared, no equals/deep compare. At most one element is replaced.

      Note that type and annotation elements cannot be replaced using this method.

      Parameters:
      oldElement - the element to be replaced
      newElement - the new element
      Returns:
    • canCauseException

      boolean canCauseException()
      This non-recursive method indicates whether or not this element may be the cause of an exception. In order to recursively check if the element throws (e.g., for a statement), use JUtil.canThrow(IStatement).
      Returns:
    • generate

      void generate(JavaOutputSink out)
      Generate this AST element recursively into a sink.
      Parameters:
      out -
    • getTags

      Map<String,Object> getTags()
      Get a read-only collection of the current tag map. Tags are special key-value pairs that can be attached to AST elements and rendered during AST generation.
      Returns:
    • addTag

      Object addTag(String key, Object value)
      Add a tag. See getTags().
      Parameters:
      key -
      value -
      Returns:
    • removeTag

      Object removeTag(String key)
      Remove a tag. See getTags().
      Parameters:
      key -
      Returns:
    • setData

      void setData(String key, Object value)
      Attach a piece of arbitrary data to this AST element.
      Parameters:
      key -
      value -
    • getData

      Object getData(Object key)
      Retrieve a piece of data attached to this AST element.
      Parameters:
      key -
      Returns:
    • setFlags

      void setFlags(int f)
      Set flags on this element. See FLAG_xxx for a list of legal flags.
      Parameters:
      f -
    • getFlags

      int getFlags()
      Retrieve the flags set on this element. See FLAG_xxx for a list of legal flags.
      Returns:
    • addFlags

      void addFlags(int f)
      Add flags to the current list of flags on this element. See FLAG_xxx for a list of legal flags.
      Parameters:
      f -
    • removeFlags

      void removeFlags(int f)
      Remove some flags from this element. See FLAG_xxx for a list of legal flags.
      Parameters:
      f -
    • hasFlags

      boolean hasFlags(int f)
      Determine whether any flags have been set on this element. See FLAG_xxx for a list of legal flags.
      Parameters:
      f -
      Returns:
    • getElementType

      JavaElementType getElementType()
      This method returns the type of Java AST element held by this object.
      Returns:
    • toShortString

      String toShortString()
      Generate a short-string version of this element.
      Returns:
    • duplicate

      IJavaElement duplicate()
      Duplicate this element.
      Returns:
      a (possibly) duplicated object of the same type
    • visitDepthPre

      boolean visitDepthPre(IJVisitor visitor)
      Visit this AST tree. Processing of a node is done before visiting the children.
      Parameters:
      visitor -
      Returns:
    • visitDepthPre

      boolean visitDepthPre(IJVisitor visitor, IJavaElement parent)
      Visit this AST tree. Processing of a node is done before visiting the children.
      Parameters:
      visitor -
      parent -
      Returns:
    • visitDepthPre

      boolean visitDepthPre(IJVisitor visitor, IJavaElement parent, JVisitResults results)
      Visit this AST tree. Processing of a node is done before visiting the children.
      Parameters:
      visitor -
      parent -
      results -
      Returns:
    • visitDepthPost

      boolean visitDepthPost(IJVisitor visitor)
      Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.
      Parameters:
      visitor - the visitor object
      Returns:
      true if the visit was successful
    • visitDepthPost

      boolean visitDepthPost(IJVisitor visitor, IJavaElement parent)
      Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.
      Parameters:
      visitor - the visitor object
      parent -
      Returns:
      true if the visit was successful
    • visitDepthPost

      boolean visitDepthPost(IJVisitor visitor, IJavaElement parent, JVisitResults results)
      Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.
      Parameters:
      visitor - the visitor object
      parent -
      results -
      Returns:
      true if the visit was successful
    • visitDepthPost

      boolean visitDepthPost(IJVisitor visitor, IJavaElement parent, JVisitResults results, boolean doNotVisitBlocksInsideCompounds)
      Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.
      Parameters:
      visitor - the visitor object
      parent -
      results -
      doNotVisitBlocksInsideCompounds - true to avoid exploring the sub-blocks of compound statements (e.g., if true, when visiting an if-statements, the predicate expressions will be visited, but the if-blocks will not)
      Returns:
      true if the visit was successful
    • isReconArtifact

      boolean isReconArtifact()
    • setLambdaRecon

      void setLambdaRecon(JavaReconLambda recon)
    • getReconLambda

      JavaReconLambda getReconLambda()
    • setReconEnum

      void setReconEnum(JavaReconEnum recon)
    • getReconEnum

      JavaReconEnum getReconEnum()
    • setReconEnummap

      void setReconEnummap(JavaReconEnummap recon)
    • getReconEnummap

      JavaReconEnummap getReconEnummap()
    • setReconAnon

      void setReconAnon(JavaReconAnon recon)
    • getReconAnon

      JavaReconAnon getReconAnon()
    • setOrigin

      void setOrigin(String origin)
    • getOrigin

      String getOrigin()