Class EntityDictionary

java.lang.Object
fr.inria.verveine.extractor.java.EntityDictionary

public class EntityDictionary extends Object
A dictionary of FamixJava entities to help create them and find them back Entities are mapped to keys which are the "binding" provided by the JDT pars
  • Field Details

    • SOURCE_FILENAME_PROPERTY

      public static final String SOURCE_FILENAME_PROPERTY
      A property added to CompilationUnits to record the name of the source file they belong to. Used to create FileAnchors
      See Also:
    • DEFAULT_PCKG_NAME

      public static final String DEFAULT_PCKG_NAME
      See Also:
    • MISSING_PCKG_NAME

      public static final String MISSING_PCKG_NAME
      See Also:
    • STUB_METHOD_CONTAINER_NAME

      public static final String STUB_METHOD_CONTAINER_NAME
      See Also:
    • THIS_NAME

      public static final String THIS_NAME
      See Also:
    • SUPER_NAME

      public static final String SUPER_NAME
      See Also:
    • OBJECT_NAME

      public static final String OBJECT_NAME
      See Also:
    • METACLASS_NAME

      public static final String METACLASS_NAME
      See Also:
    • OBJECT_PACKAGE_NAME

      public static final String OBJECT_PACKAGE_NAME
      See Also:
    • ARRAYS_NAME

      public static final String ARRAYS_NAME
      See Also:
    • INIT_BLOCK_NAME

      public static final String INIT_BLOCK_NAME
      See Also:
    • ANONYMOUS_NAME_PREFIX

      public static final String ANONYMOUS_NAME_PREFIX
      See Also:
    • UNKNOWN_MODIFIERS

      public static final int UNKNOWN_MODIFIERS
      See Also:
    • MODIFIER_PUBLIC

      public static final String MODIFIER_PUBLIC
      See Also:
    • MODIFIER_PRIVATE

      public static final String MODIFIER_PRIVATE
      See Also:
    • MODIFIER_PROTECTED

      public static final String MODIFIER_PROTECTED
      See Also:
    • MODIFIER_PACKAGE

      public static final String MODIFIER_PACKAGE
      See Also:
    • DEFAULT_IMPLEMENTATION_KIND_MARKER

      public static final String DEFAULT_IMPLEMENTATION_KIND_MARKER
      The symbol kind to use to define that a method is a default implementation in an interface
      See Also:
    • IMPLICIT_VAR_TYPE_NAME

      public static final String IMPLICIT_VAR_TYPE_NAME
      name of the entity representing the "unknown" type 'var' The entity is intended to be unique, see ensureFamixUniqEntity(java.lang.Class, IBinding, String)
      See Also:
    • famixRepo

      protected ch.akuhn.fame.Repository famixRepo
      The FAMIX repository where all FAMIX entities are created and stored
    • keyToEntity

      protected Map<org.eclipse.jdt.core.dom.IBinding, TNamedEntity> keyToEntity
      A dictionary to map a key (provided by the user) to FAMIX Entity
    • entityToKey

      protected Map<TNamedEntity, org.eclipse.jdt.core.dom.IBinding> entityToKey
      A reverse dictionary (see keyToEntity) to find the key of an entity.
    • enumConstantAnonymousTypes

      protected Map<org.eclipse.jdt.core.dom.IVariableBinding, org.eclipse.jdt.core.dom.ITypeBinding> enumConstantAnonymousTypes
      Associates an enum constant with the anonymous type declared in its class body. This is extraction state only; the FAMIX metamodel has no such association.
    • nameToEntity

      protected Map<String, Collection<TNamedEntity>> nameToEntity
      Another dictionary to map a name to FAMIX Entities with this name
    • typeToImpVar

      Deprecated.
      Yet another dictionary for implicit variables ('self' and 'super') Because they are implicit, they may not have a binding provided by the parser, or may have the same binding as their associated type so they can't be kept easily in keyToEntity
    • useMissingPackage

      protected boolean useMissingPackage
      Option: If true, create stubs without package into a "Missing" package
  • Constructor Details

    • EntityDictionary

      public EntityDictionary(ch.akuhn.fame.Repository famixRepo)
      Constructor taking a FAMIX repository
      Parameters:
      famixRepo -
    • EntityDictionary

      public EntityDictionary(ch.akuhn.fame.Repository famixRepo, boolean useMissingPackage)
      Constructor taking a FAMIX repository and the useMissingPackage option
      Parameters:
      famixRepo -
      useMissingPackage -
  • Method Details

    • recoverExistingRepository

      protected void recoverExistingRepository()
      Resets the dictionnary in a proper state after loading entities from an existing MSE file:
      • map all named entities to their names in mapName
      • reset some boolean properties (e.g. isStub) that are false (they are not saved in the mse file and therefore not initialized)
    • mapEntityToName

      protected void mapEntityToName(String name, TNamedEntity ent)
    • removeEntity

      public void removeEntity(NamedEntity ent)
    • mapEntityToKey

      protected void mapEntityToKey(org.eclipse.jdt.core.dom.IBinding key, TNamedEntity ent)
    • getEntityByName

      public <T extends TNamedEntity> Collection<T> getEntityByName(Class<T> fmxClass, String name)
      Returns all the Famix Entity with the given name and class
      Parameters:
      fmxClass - -- the subtype of Famix Entity we are looking for
      name - -- the name of the entity
      Returns:
      the Collection of Famix Entities with the given name and class (possibly empty)
    • getEntityByKey

      public TNamedEntity getEntityByKey(org.eclipse.jdt.core.dom.IBinding key)
      Returns the Famix Entity associated to the given key. Note: Be careful that ImplicitVariables share the same binding as their associated Class and cannot be retrieved with this method. In such a case, this method will always retrieve the Class associated to the key. To get an ImplicitVariable from the key, use getImplicitVariableByBinding(IBinding, String)
      Parameters:
      key - -- the key
      Returns:
      the Famix Entity associated to the binding or null if not found
    • registerEnumConstantAnonymousType

      public void registerEnumConstantAnonymousType(org.eclipse.jdt.core.dom.IVariableBinding enumConstant, org.eclipse.jdt.core.dom.ITypeBinding anonymousType)
    • getEnumConstantMethodOverride

      public org.eclipse.jdt.core.dom.IMethodBinding getEnumConstantMethodOverride(EnumValue enumConstant, org.eclipse.jdt.core.dom.IMethodBinding calledMethod)
    • getEntityByKey

      protected <T extends TNamedEntity> T getEntityByKey(org.eclipse.jdt.core.dom.IBinding key, Class<T> fmxClass)
      Returns the Famix Entity associated to the given key if it is an instance of the given Famix class. This avoids recovering a binding as another kind of entity than the one requested.
      Parameters:
      key - -- the key
      fmxClass - -- the expected Famix class
      Returns:
      the Famix Entity associated to the binding or null if not found or not an instance of fmxClass
    • getEntityKey

      public org.eclipse.jdt.core.dom.IBinding getEntityKey(TNamedEntity e)
      Returns the key associated to a Famix Entity.
      Parameters:
      e - -- the Named entity
      Returns:
      the key associated to this entity or null if none
    • createFamixEntity

      protected <T extends TNamedEntity & TSourceEntity> T createFamixEntity(Class<T> fmxClass, String name)
      Creates and returns a FAMIX Entity of the type fmxjava.lang.Class. The Entity is always created.
      Parameters:
      fmxClass - -- the FAMIX class of the instance to create
      name - -- the name of the new instance must not be null (and this is not tested)
      Returns:
      the FAMIX Entity or null in case of a FAMIX error
    • ensureFamixEntity

      protected <T extends TNamedEntity & TSourceEntity> T ensureFamixEntity(Class<T> fmxClass, org.eclipse.jdt.core.dom.IBinding bnd, String name)
      Returns a Famix Entity of the type fmxjava.lang.Class and maps it to its binding bnd (if not null). The Entity is created if it did not exist.
      Parameters:
      fmxClass - -- the Famix class of the instance to create
      bnd - -- the binding to map to the new instance
      name - -- the name of the new instance (used if
      bnd == null
      )
      Returns:
      the Famix Entity or null if bnd was null or in case of a Famix error
    • famixRepoAdd

      public void famixRepoAdd(Entity e)
      Adds an already created Entity to the Famix repository Used mainly for non-NamedEntity, for example relationships
      Parameters:
      e - -- the Famix entity to add to the repository
    • ensureFamixParametricClass

      public ParametricClass ensureFamixParametricClass(org.eclipse.jdt.core.dom.ITypeBinding key, String name, TWithTypes owner)
      Returns a Famix ParametricClass with the given name, creating it if it does not exist yet In the second case, sets some default properties: not Abstract, not Final, not Private, not Protected, not Public, not Interface
      Parameters:
      name - -- the name of the Famix Class
      Returns:
      the Famix Class or null in case of a Famix error
    • ensureFamixParametricInterface

      public ParametricInterface ensureFamixParametricInterface(org.eclipse.jdt.core.dom.ITypeBinding key, String name, TWithTypes owner)
      Returns a Famix ParametricInterface with the given name, creating it if it does not exist yet In the second case, sets some default properties: not Abstract, not Final, not Private, not Protected, not Public, not Interface
      Parameters:
      name - -- the name of the Famix Class
      Returns:
      the Famix Class or null in case of a Famix error
    • createFamixAnnotationInstanceAttribute

      public AnnotationInstanceAttribute createFamixAnnotationInstanceAttribute(AnnotationTypeAttribute att, String value)
    • addFamixAnnotationInstance

      public AnnotationInstance addFamixAnnotationInstance(TWithAnnotationInstances fmx, AnnotationType annType, Collection<AnnotationInstanceAttribute> annAtts)
    • ensureFamixInheritance

      public Inheritance ensureFamixInheritance(TWithInheritances sup, TWithInheritances sub, TAssociation prev, org.eclipse.jdt.core.dom.ITypeBinding supBnd)
      Returns a Famix Inheritance relationship between two Famix Classes creating it if needed
      Parameters:
      sup - -- the super class
      sub - -- the sub class
      prev - -- previous inheritance relationship in the same context
      Returns:
      the Inheritance relationship
    • buildFamixParametricAssociation

      public <T extends TParametricEntity> TParametricAssociation buildFamixParametricAssociation(TParametricAssociation association, org.eclipse.jdt.core.dom.ITypeBinding[] typeParameters, org.eclipse.jdt.core.dom.ITypeBinding[] typeArguments)
      Creates the concretization between the type parameters of the generic entity that is target of an association and the concrete types that concretize them in this association.
      Parameters:
      association - -- the association that must be linked to # or several concretizations
      typeParameters - -- the collection of type parameters declared in the generic entity
      typeArguments - -- the collection of concrete types linked to this association
      Returns:
      the parametric association
    • ensureFamixConcretization

      public Concretization ensureFamixConcretization(TTypeArgument typeArgument, TypeParameter typeParameter)
      Returns a Famix Concretization relationship between a Concrete Type and a ParameterType
      Parameters:
      typeArgument - -- the concrete type
      typeParameter - -- the generic type parameter
      Returns:
      the Concretization relationship
    • ensureFamixImplementation

      public Implementation ensureFamixImplementation(TImplementable myInterface, TCanImplement implementingClass, TAssociation prev, org.eclipse.jdt.core.dom.ITypeBinding supBnd)
      Returns a Famix Implementation relationship between two Famix Classes creating it if needed
      Parameters:
      myInterface - -- the implemented interface
      implementingClass - -- the implementing class
      prev - -- previous inheritance relationship in the same context
      Returns:
      the Inheritance relationship
    • ensureImplementedInterfaces

      public void ensureImplementedInterfaces(org.eclipse.jdt.core.dom.ITypeBinding bnd, TType fmx, TWithTypes owner, TAssociation lastAssociation)
    • addFamixReference

      public Reference addFamixReference(Method src, TType tgt, TAssociation prev, org.eclipse.jdt.core.dom.ITypeBinding referredTypeBnd)
      Returns a Famix Reference between two Famix Entities creating it if needed.
      If prev == null and a similar reference already exist (same src, same tgt), does not create a new one
      Parameters:
      src - -- source of the reference
      tgt - -- target of the reference
      prev - -- previous reference relationship in the same context
      Returns:
      the FamixReference
    • addFamixInvocation

      public Invocation addFamixInvocation(TMethod tMethod, TMethod invoked, TInvocationsReceiver receiver, String signature, TAssociation prev, org.eclipse.jdt.core.dom.IMethodBinding invokedBnd)
      Returns a Famix Invocation between two Famix Entities creating it if needed
      Parameters:
      tMethod - of the invocation
      invoked - -- method invoked
      receiver - of the invocation
      signature - -- i.e. actual invocation code
      prev - -- previous invocation relationship in the same context
      Returns:
      the FamixInvocation
    • addFamixAccess

      public Access addFamixAccess(TWithAccesses accessor, TStructuralEntity var, boolean isWrite, TAssociation prev)
      Returns a Famix Access between two Famix Entities creating it if needed
      Parameters:
      accessor - -- the entity (presumably a method) accessing the attribute
      var - -- the variable accessed
      isWrite - -- whether this is an access for reading or writing in the variable
      prev - -- previous access relationship in the same context
      Returns:
      the FamixAccess
    • chainPrevNext

      protected void chainPrevNext(TAssociation prev, TAssociation next)
    • createFamixDeclaredException

      public TThrowable createFamixDeclaredException(Method meth, TThrowable excep)
      Returns a Famix DeclaredException between a method and an Exception that it declares to throw
      Parameters:
      meth - -- the method throwing the exception
      excep - -- the exception declared to be thrown
      Returns:
      the DeclaredException
    • createFamixCaughtException

      public TThrowable createFamixCaughtException(Method meth, TThrowable excep)
      Returns a Famix CaughtException between a method and an Exception that is caught
      Parameters:
      meth - -- the method catching the exception
      excep - -- the exception caught
      Returns:
      the CaughtException
    • createFamixThrownException

      public TThrowable createFamixThrownException(Method meth, TThrowable excep)
      Returns a Famix ThrownException between a method and an Exception that it (actually) throws. Note: DeclaredException indicates that the method declares it can throw the exception, here we state that the exception is actually thrown
      Parameters:
      meth - -- the method throwing the exception
      excep - -- the exception thrown
      Returns:
      the ThrownException
    • ensureFamixEntityTyping

      public EntityTyping ensureFamixEntityTyping(org.eclipse.jdt.core.dom.ITypeBinding declaredTypeBnd, TTypedEntity typedEntity, TType declaredType)
      Returns a Famix EntityTyping between a typed entity and a type.
      Parameters:
      typedEntity - -- the typed entity
      declaredType - -- the declared type
      Returns:
      the FamixEntityTyping
    • getImplicitVariableByBinding

      @Deprecated public ImplicitVariable getImplicitVariableByBinding(org.eclipse.jdt.core.dom.IBinding bnd, String iv_name)
      Deprecated.
      Returns the Famix ImplicitVariable associated to the given binding and name (self or super). See also getEntityByKey(IBinding)
      Parameters:
      bnd - -- the binding
      Returns:
      the Famix Entity associated to the binding or null if not found
    • getImplicitVariableByType

      @Deprecated public ImplicitVariable getImplicitVariableByType(Type type, String name)
      Deprecated.
      Returns the Famix ImplicitVariable associated to the given FamixType.
      Parameters:
      type - -- the FamixType
      name - -- name of the ImplicitVariable (should be Dictionary.SELF_NAME or Dictionary.SUPER_NAME)
      Returns:
      the Famix ImplicitVariable associated to the Type or null if not found
    • ensureFamixUniqEntity

      public <T extends NamedEntity> T ensureFamixUniqEntity(Class<T> fmxClass, org.eclipse.jdt.core.dom.IBinding key, String name)
      Creates or recovers a Famix Named Entity uniq for the given name. For some specific entities we don't allow two of them with the same name. This is the case e.g. for the default package, or the Java class "Object" and its package "java.lang".
      Parameters:
      fmxClass - -- the Famix class of the instance to create
      key - -- a potential binding for the entity
      name - -- the name of the new instance (used if
      bnd == null
      )
      Returns:
      the uniq Famix Entity for this binding and/or name
    • ensureFamixClassStubOwner

      public Class ensureFamixClassStubOwner()
      Creates or recovers the Famix Class that will own all stub methods (for which the real owner is unknown)
      Returns:
      a Famix class
    • searchTypeInContext

      public Type searchTypeInContext(String name, TWithTypes ctxt)
    • ensureFamixPackage

      public Package ensureFamixPackage(org.eclipse.jdt.core.dom.IPackageBinding bnd, String name)
      Returns a Famix Package associated with its IPackageBinding and/or fully qualified name. The Entity is created if it does not exist. We assume that Namespaces must be uniq for a given name Also creates or recovers recusively it's parent namespaces.
      At least one of bnd and name must be non null.
      Parameters:
      bnd - -- the JDT Binding that may be used as a uniq key to recover this namespace
      name - -- fully qualified name of the namespace (e.g. 'java.lang')
      Returns:
      the Famix Namespace found or created. May return null in case of a Famix error
    • ensureFamixPackageDefault

      public Package ensureFamixPackageDefault()
      Creates or recovers a default Famix Package. Because this package does not really exist, it has no binding.
      Returns:
      a Famix Namespace
    • ensureFamixPackageMissing

      public Package ensureFamixPackageMissing()
      Returns an artificial Package to contain stubs with an unknown package. Always returns the same package. Create it lazily if not existing.
      Returns:
      a Famix Namespace
    • ensureFamixPackageJavaLang

      public Package ensureFamixPackageJavaLang(org.eclipse.jdt.core.dom.IPackageBinding bnd)
      Creates or recovers a Famix Package for the package of Java class "Object" (i.e. "java.lang"). Because "Object" is the root of the inheritance tree, it needs to be treated differently.
      Parameters:
      bnd - -- a potential binding for the "java.lang" package
      Returns:
      a Famix Namespace for "java.lang"
    • getFamixPackageDefault

      public Package getFamixPackageDefault()
      Returns the Package with DEFAULT_PCKG_NAME or null if not found
    • ensureFamixType

      public Type ensureFamixType(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TWithTypes owner, TWithTypes ctxt, int modifiers)
      Returns a Famix Type with the given name, creating it if it does not exist yet. In the second case, sets some default properties: not Abstract, not Final, not Private, not Protected, not Public, not Interface
      Parameters:
      bnd - -- binding for the type to create
      name - of the type
      owner - of the type
      ctxt - -- context of use of the type
    • ensureFamixType

      public Type ensureFamixType(org.eclipse.jdt.core.dom.ITypeBinding bnd, TWithTypes context)
    • ensureFamixType

      public Type ensureFamixType(org.eclipse.jdt.core.dom.ITypeBinding bnd)
    • isThrowable

      public boolean isThrowable(org.eclipse.jdt.core.dom.ITypeBinding bnd)
    • ensureFamixClass

      public Class ensureFamixClass(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TNamedEntity owner, boolean isGeneric, int modifiers)
      Returns a Famix Class associated with the ITypeBinding. The Entity is created if it does not exist.
      Parameters:
      name - -- the name of the Famix Class (MUST NOT be null, but this is not checked)
      owner - -- package defining the class (should not be null, but it will work if it is)
      Returns:
      the Famix Entity found or created. May return null if "bnd" is null or in case of a Famix error
    • ensureFamixException

      public <T extends TWithTypes & TNamedEntity> Exception ensureFamixException(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TWithTypes owner, boolean isGeneric, int modifiers)
      Returns a Famix Exception associated with the ITypeBinding. The Entity is created if it does not exist.
      Parameters:
      name - -- the name of the Famix Exception
      owner - -- type defining the Exception (should not be null, but it will work if it is)
      Returns:
      the Famix Entity found or created. May return null if "bnd" is null or in case of a Famix error
    • ensureFamixInterface

      public <T extends TWithTypes & TNamedEntity> Interface ensureFamixInterface(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TWithTypes owner, boolean isGeneric, int modifiers)
      Returns a FAMIX Interface with the given name, creating it if it does not exist yet.
      Parameters:
      name - -- the name of the FAMIX Method
      owner - -- type defining the method (should not be null, but it will work if it is)
      Returns:
      the FAMIX Class or null in case of a FAMIX error
    • asException

      public TThrowable asException(TType fmxType)
      "Converts" (if needed) a TTYpe entity to be a TThrowable. Might involve removing the existing entity, recreating a new one and migrating all the relationship of the former to the later
    • getFamixClass

      public Class getFamixClass(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TNamedEntity owner)
      helper method, we know the type exists, ensureFamixClass will recover it
    • getFamixInterface

      public Interface getFamixInterface(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, ContainerEntity owner)
      helper method, we know the type exists, ensureFamixInterface will recover it
    • getFamixException

      public Exception getFamixException(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TWithTypes owner)
      helper method, we know the type exists, ensureFamixInterface will recover it
    • ensureFamixPrimitiveType

      public PrimitiveType ensureFamixPrimitiveType(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name)
      Returns a FAMIX PrimitiveType with the given name, creating it if it does not exist yet We assume that PrimitiveType must be uniq for a given name
      Parameters:
      name - -- the name of the FAMIX PrimitiveType
      Returns:
      the FAMIX PrimitiveType or null in case of a FAMIX error
    • ensureFamixEnum

      public <T extends TWithTypes & TNamedEntity> Enum ensureFamixEnum(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TWithTypes owner)
    • getFamixEnum

      public Enum getFamixEnum(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TWithTypes owner)
      helper method, we know the type exists, ensureFamixEnum will recover it
    • ensureFamixEnumValue

      public EnumValue ensureFamixEnumValue(org.eclipse.jdt.core.dom.IVariableBinding bnd, String name, Enum owner)
    • ensureFamixAnnotationType

      public AnnotationType ensureFamixAnnotationType(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, ContainerEntity owner)
    • getFamixAnnotationType

      public AnnotationType getFamixAnnotationType(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, ContainerEntity owner)
      helper method, we know the type exists, ensureFamixAnnotationType will recover it
    • ensureFamixAnnotationTypeAttribute

      public AnnotationTypeAttribute ensureFamixAnnotationTypeAttribute(org.eclipse.jdt.core.dom.IMethodBinding bnd, String name, AnnotationType owner)
    • getFamixAnnotationTypeAttribute

      public AnnotationTypeAttribute getFamixAnnotationTypeAttribute(org.eclipse.jdt.core.dom.IMethodBinding bnd, String name, AnnotationType owner)
      helper method, we know the attribute exists, ensureFamixAnnotationTypeAttribute will recover it
    • ensureFamixWildcardType

      public Wildcard ensureFamixWildcardType(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TParametricEntity owner, TWithTypes ctxt)
      Returns a FAMIX Wildcard with its bounds
      Parameters:
      bnd -
      name -
      owner -
      Returns:
    • ensureFamixTypeParameter

      public TypeParameter ensureFamixTypeParameter(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TWithTypes owner)
      Returns a Famix TypeParameter (created by a Famix ParametricEntity) with the given name, creating it if it does not exist yet In the second case, sets some default properties: not Abstract, not Final, not Private, not Protected, not Public
      Parameters:
      name - -- the name of the Famix TypeParameter
      Returns:
      the Famix TypeParameter or null in case of a Famix error
    • isConstructorBinding

      protected boolean isConstructorBinding(org.eclipse.jdt.core.dom.IMethodBinding bnd)
      testing that a method binding is for a constructor There is a special case for "diamond constructors" (eg: new HashSet<>())
    • ensureFamixMethod

      public Method ensureFamixMethod(org.eclipse.jdt.core.dom.IMethodBinding bnd)
    • ensureFamixMethod

      public Method ensureFamixMethod(org.eclipse.jdt.core.dom.IMethodBinding bnd, String name, Collection<String> paramTypes, TType ret, TWithMethods owner, int modifiers)
      Returns a Famix Method associated with the IMethodBinding. The Entity is created if it does not exist.
      Parameters:
      name - -- the name of the Famix Method (MUST NOT be null, but this is not checked)
      ret - -- Famix Type returned by the method (ideally should only be null in case of a constructor, but will accept it in any case)
      owner - -- type defining the method (should not be null, but it will work if it is)
      Returns:
      the Famix Entity found or created. May return null if "bnd" is null or in case of a Famix error
    • ensureFamixInitializer

      public Initializer ensureFamixInitializer(TWithMethods owner, Boolean isStatic, Boolean isInitializationBlock)
      Creates or recovers the initializer method containing the attribute initializations of a type.
      Parameters:
      owner - Type containing the initializer
      isStatic - Modifier of the initializer. A type can have 2 initializers for attribute initialization: 1 static and 1 not.
      isInitializationBlock - True if the entity is an initialization block. False for the artificial method containing all field initializations.
      Returns:
      the FamixInitializer
    • ensureImplicitConstructor

      public Initializer ensureImplicitConstructor(org.eclipse.jdt.core.dom.IMethodBinding binding, TWithMethods owner, String name, Collection<String> parameterTypesNames)
    • ensureFamixStubMethod

      public Method ensureFamixStubMethod(String name)
      Creates or recovers a stub Famix Method
      Parameters:
      name - of the method
      Returns:
      the Famix Method
    • setAttributeModifiers

      public void setAttributeModifiers(Attribute fmx, int mod)
    • setMethodModifiers

      public void setMethodModifiers(Method fmx, int mod)
    • setClassModifiers

      public void setClassModifiers(Class fmx, int mod, TWithTypes owner)
    • setInterfaceModifiers

      public void setInterfaceModifiers(Interface fmx, int mod)
    • setVisibility

      public void setVisibility(THasVisibility fmx, int mod, TWithTypes owner)
      Sets the visibility of a FamixNamedEntity
      Parameters:
      fmx - -- the FamixNamedEntity
      mod - -- a description of the modifiers as understood by org.eclipse.jdt.core.dom.Modifier
    • ensureFamixAttribute

      public Attribute ensureFamixAttribute(org.eclipse.jdt.core.dom.IVariableBinding bnd, String name, Type type, TWithAttributes owner)
      Returns a Famix Attribute associated with the IVariableBinding. The Entity is created if it does not exist.
      Parameters:
      name - -- the name of the FAMIX Attribute (MUST NOT be null, but this is not checked)
      type - -- Famix Type of the Attribute (should not be null, but it will work if it is)
      owner - -- type defining the Attribute (should not be null, but it will work if it is)
      Returns:
      the Famix Entity found or created. May return null if "bnd" is null or in case of a Famix error
    • ensureFamixAttribute

      public Attribute ensureFamixAttribute(org.eclipse.jdt.core.dom.IVariableBinding bnd, String name, TWithAttributes owner)
    • getFamixAttribute

      public Attribute getFamixAttribute(org.eclipse.jdt.core.dom.IVariableBinding bnd, String name, TWithAttributes owner)
      helper method, we know the var exists, ensureFamixAttribute will recover it
    • ensureFamixParameter

      public Parameter ensureFamixParameter(org.eclipse.jdt.core.dom.IVariableBinding bnd, String name, Type typ, TMethod tMethod)
      Returns a Famix Parameter associated with the IVariableBinding. The Entity is created if it does not exist.
      Returns:
      the Famix Entity found or created. May return null if "bnd" is null or in case of a Famix error
    • ensureFamixLocalVariable

      public LocalVariable ensureFamixLocalVariable(org.eclipse.jdt.core.dom.IVariableBinding bnd, String name, TWithLocalVariables owner)
      Returns a Famix LocalVariable associated with the IVariableBinding. The Entity is created if it does not exist.
      Parameters:
      name - -- the name of the FAMIX LocalVariable
      Returns:
      the Famix Entity found or created. May return null if bnd and name are null, or bnd and owner are null, or in case of a Famix error
    • ensureFamixImplicitVariable

      public ImplicitVariable ensureFamixImplicitVariable(org.eclipse.jdt.core.dom.IBinding key, String name, TType type, TMethod tMethod)
      Returns a FAMIX ImplicitVariable with the given name ("self" or "super") and corresponding to the type. If this ImplicitVariable does not exist yet, it is created
      Parameters:
      name - -- the name of the FAMIX ImplicitVariable (should be Dictionary.SELF_NAME or Dictionary.SUPER_NAME)
      type - -- the Famix Type for this ImplicitVariable (should not be null)
      tMethod - -- the ContainerEntity where the implicit variable appears (should be a method inside type)
      Returns:
      the FAMIX ImplicitVariable or null in case of a FAMIX error
    • ensureFamixImplicitVariable

      public ImplicitVariable ensureFamixImplicitVariable(String name, TType tType, TMethod tMethod)
    • createFamixComment

      public Comment createFamixComment(org.eclipse.jdt.core.dom.Comment jCmt, TWithComments owner)
      Creates and returns a Famix Comment and associates it with an Entity (ex: for Javadocs)
      Parameters:
      jCmt - -- the content (String) of the comment
      owner - -- the entity that is commented
      Returns:
      the Famix Comment
    • createFamixComment

      public Comment createFamixComment(org.eclipse.jdt.core.dom.Comment jCmt, TWithComments owner, String content)
      Creates and returns a Famix Comment and associates it with an Entity
      Parameters:
      jCmt - -- the content (String) of the comment
      owner - -- the entity that is commented
      content - -- the text of the comment
      Returns:
      the Famix Comment
    • addSourceAnchor

      public SourceAnchor addSourceAnchor(TSourceEntity fmx, org.eclipse.jdt.core.dom.ASTNode node)
      Adds location information to a Famix Entity. Location informations are: name of the source file and line position in this file. They are found in the JDT ASTNode: ast. This method also creates some basic links between the entity and others (e.g. declaring container, return type, ...)
      Parameters:
      fmx - -- Famix Entity to add the anchor to
      node - -- JDT ASTNode, where the information is extracted
      Returns:
      the Famix SourceAnchor added to fmx. May be null in case of incorrect parameter ('fmx' or 'ast' == null)
    • addSourceAnchor

      public SourceAnchor addSourceAnchor(Method fmx, org.eclipse.jdt.core.dom.MethodDeclaration node)
      Special case of addSourceAnchor(TSourceEntity, ASTNode) to add location information to a Famix Method.
    • createIndexedFileAnchor

      protected IndexedFileAnchor createIndexedFileAnchor(org.eclipse.jdt.core.dom.ASTNode node)
      Gets the file name holding node and its start and end positions in the file. Information returned in the form of an IndexedFileAnchor
    • ensureFamixClassObject

      public Class ensureFamixClassObject()
      Creates or recovers the Famix Class for "Object". Because "Object" is the root of the inheritance tree, it needs to be treated differently.
      Returns:
      a Famix class for "Object"
    • ensureParametricArrayClass

      public ParametricClass ensureParametricArrayClass()
      We treat array types as parametrized types Array<T>. This keeps the meta-model simple: a single way to model different concepts.
      Returns:
    • ensureFamixMetaClass

      public Class ensureFamixMetaClass(org.eclipse.jdt.core.dom.ITypeBinding bnd)
      Ensures the Java meta-class:
      java.lang.Class<>
    • getFamixMetaClass

      public Class getFamixMetaClass(org.eclipse.jdt.core.dom.ITypeBinding bnd)
    • ensureFamixClassArray

      public Class ensureFamixClassArray()
      Creates or recovers the Famix Class for all arrays (
      <some-type> []
      ) In java arrays or objects of special classes (i.e. "I[" for an array of int). JDT does not create a binding for these classes, so we create a stub one here.
      Returns:
      a Famix class
    • removeLastPartOfPackageName

      public String removeLastPartOfPackageName(String qualifiedName)
    • signatureParamsFromBinding

      protected String signatureParamsFromBinding(org.eclipse.jdt.core.dom.IMethodBinding bnd)
      Generates the list of parameters for a method signature
      Returns:
      a string
    • findTypeName

      public String findTypeName(org.eclipse.jdt.core.dom.Type t)
    • referredType

      public <T extends TWithTypes & TNamedEntity> TType referredType(org.eclipse.jdt.core.dom.Type typ, T ctxt, boolean isClass)
      Ensures the proper creation of a FamixType for JDT typ in the given context. Useful for parameterizedTypes, or classInstance.
      Parameters:
      isClass - we are sure that the type is actually a class
      Returns:
      a famix type or null
    • referredType

      public <T extends TWithTypes & TNamedEntity> TType referredType(org.eclipse.jdt.core.dom.Type typ, T ctxt, boolean isClass, boolean isException)
      Ensures the proper creation of a FamixType for JDT type in the given context. Useful for parameterizedTypes, or classInstance.
      Parameters:
      isClass - we are sure that the type is actually a class
      Returns:
      a famix type or null
    • referredType

      public TType referredType(org.eclipse.jdt.core.dom.ITypeBinding bnd, TNamedEntity ctxt)
    • referredType

      public TType referredType(org.eclipse.jdt.core.dom.ITypeBinding bnd, TNamedEntity ctxt, int extraDimensions)