Interface CAstEntity

All Known Subinterfaces:
JavaProcedureEntity
All Known Implementing Classes:
AbstractClassEntity, AbstractCodeEntity, AbstractEntity, AbstractFieldEntity, AbstractGlobalEntity, AbstractScriptEntity, DelegatingEntity, JDTJava2CAstTranslator.ClassEntity, JDTJava2CAstTranslator.CompilationUnitEntity, JDTJava2CAstTranslator.FieldEntity, JDTJava2CAstTranslator.ProcedureEntity

public interface CAstEntity
The assumption is that abstract syntax trees pertain to particular programming language constructs, such as classes, methods, programs and the like. Thus, the expectation is that users of CAst will typically be communicating such entities, and this interface is meant to give them a mechanism to do this.

The set of kinds that are currently in this file is not meant to be exhaustive, and should be extended as needed for any new languages that come along.

Author:
Julian Dolby (dolby@us.ibm.com)
  • Field Details

    • FUNCTION_ENTITY

      static final int FUNCTION_ENTITY
      This entity is a function. Children: in JavaScript, FUNCTION_ENTITY's; in Java, none.
      See Also:
    • SCRIPT_ENTITY

      static final int SCRIPT_ENTITY
      This entity is a program script for a scripting language. Children: in JavaScript, FUNCTION_ENTITY's(?); doesn't occur in Java.
      See Also:
    • TYPE_ENTITY

      static final int TYPE_ENTITY
      This entity is a type in an object-oriented language. Children: typically, immediately enclosed FIELD_ENTITY's, FUNCTION_ENTITY's, and TYPE_ENTITY's.
      See Also:
    • FIELD_ENTITY

      static final int FIELD_ENTITY
      This entity is a field in an object-oriented language. Children: usually, none
      See Also:
    • FILE_ENTITY

      static final int FILE_ENTITY
      This entity is a source file (i.e. a compilation unit).
      See Also:
    • RULE_ENTITY

      static final int RULE_ENTITY
      This entity represents a rule in a logic language.
      See Also:
    • MACRO_ENTITY

      static final int MACRO_ENTITY
      This entity is a macro. A macro is a code body that only makes sense when expanded in the context of another code body.
      See Also:
    • GLOBAL_ENTITY

      static final int GLOBAL_ENTITY
      This entity represents a global varible
      See Also:
    • SUB_LANGUAGE_BASE

      static final int SUB_LANGUAGE_BASE
      Languages that introduce new kinds of CAstEntity should use this number as the base of integers chosen to denote the new entity types.
      See Also:
  • Method Details

    • getKind

      int getKind()
      What kind of entity is this? The answer should be one of the constants in this file. This has no meaning to the CAPA AST interfaces, but should be meaningful to a given producer and consumer of an entity.
    • getName

      String getName()
      Some programming language constructs have names. This should be it, if appropriate, and null otherwise.
    • getSignature

      String getSignature()
      Some programming language constructs have signatures, which are like names but usually have some detail to distinguish the construct from others with the same name. Signatures often denote typing information as well, but this is not required. This method should return a signature if appropriate, and null otherwise.
    • getArgumentNames

      String[] getArgumentNames()
      Some programming language constructs have named arguments. This should be their names, if appropriate. Otherwise, please return an array of size 0, since null can be a pain.
    • getArgumentDefaults

      CAstNode[] getArgumentDefaults()
      Some programming language constructs allow arguments to have default values. This should be those defaults, one per named argument above. Otherwise, please return an array of size 0, since null can be a pain.
    • getArgumentCount

      int getArgumentCount()
      Some programming language constructs have a specific number of arguments. This should be that number, if appropriate, and 0 otherwise.
    • getAllScopedEntities

      Map<CAstNode,Collection<CAstEntity>> getAllScopedEntities()
      Some programming language constructs have a lexical structure. This should be those constructs that are directly inside the current one. The result of this method is a map from source construct to the set of entities induced by that construct. Entities induced by no particular construct are mapped by the null key.
    • getScopedEntities

      Iterator<CAstEntity> getScopedEntities(CAstNode construct)
      Some programming language constructs have a lexical structure. This should be those constructs that are directly inside the current one. The result of this method is the scoped entities induced by the construct `construct' (i.e. a node of the AST returned by

      Enclosed entities not induced by a specific AST node are mapped by the construct 'null'.

    • getAST

      CAstNode getAST()
      The CAPA AST of this entity.
    • getControlFlow

      CAstControlFlowMap getControlFlow()
      The control flow map for the CAPA AST of this entity.
    • getSourceMap

      CAstSourcePositionMap getSourceMap()
      The map of CAstNodes to source positions for the CAPA AST of this entity.
    • getPosition

      The source position of this entity.
    • getNamePosition

      The source position of the token denoting this entity's name.
    • getPosition

      CAstSourcePositionMap.Position getPosition(int arg)
      The source position of argument 'arg' this entity, if any;
    • getNodeTypeMap

      CAstNodeTypeMap getNodeTypeMap()
      The map from CAstNodes to types. Valid for nodes that have an explicitly declared type (e.g. local vars).
    • getQualifiers

      Collection<CAstQualifier> getQualifiers()
      Returns an Iterator over the qualifiers of the given entity, if it has any, e.g., "final", "private".
    • getType

      CAstType getType()
      The CAst type of this entity.
    • getAnnotations

      Collection<CAstAnnotation> getAnnotations()
      Returns the set of any annotations this entity may have
    • getOriginal

      default CAstEntity getOriginal()
      Allow finding original entity after rewrites