Class EntityDictionary
java.lang.Object
fr.inria.verveine.extractor.java.EntityDictionary
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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final StringThe symbol kind to use to define that a method is a default implementation in an interfacestatic final Stringprotected Map<TNamedEntity, org.eclipse.jdt.core.dom.IBinding> A reverse dictionary (seekeyToEntity) to find the key of an entity.protected Map<org.eclipse.jdt.core.dom.IVariableBinding, org.eclipse.jdt.core.dom.ITypeBinding> Associates an enum constant with the anonymous type declared in its class body.protected ch.akuhn.fame.RepositoryThe FAMIX repository where all FAMIX entities are created and storedstatic final Stringname of the entity representing the "unknown" type 'var' The entity is intended to be unique, seeensureFamixUniqEntity(java.lang.Class, IBinding, String)static final Stringprotected Map<org.eclipse.jdt.core.dom.IBinding, TNamedEntity> A dictionary to map a key (provided by the user) to FAMIX Entitystatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Map<String, Collection<TNamedEntity>> Another dictionary to map a name to FAMIX Entities with this namestatic final Stringstatic final Stringstatic final StringA property added to CompilationUnits to record the name of the source file they belong to.static final Stringstatic final Stringstatic final Stringprotected Map<Type, EntityDictionary.ImplicitVars> Deprecated.static final intprotected booleanOption: If true, create stubs without package into a "Missing" package -
Constructor Summary
ConstructorsConstructorDescriptionEntityDictionary(ch.akuhn.fame.Repository famixRepo) Constructor taking a FAMIX repositoryEntityDictionary(ch.akuhn.fame.Repository famixRepo, boolean useMissingPackage) Constructor taking a FAMIX repository and the useMissingPackage option -
Method Summary
Modifier and TypeMethodDescriptionaddFamixAccess(TWithAccesses accessor, TStructuralEntity var, boolean isWrite, TAssociation prev) Returns a Famix Access between two Famix Entities creating it if neededaddFamixAnnotationInstance(TWithAnnotationInstances fmx, AnnotationType annType, Collection<AnnotationInstanceAttribute> annAtts) 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 neededaddFamixReference(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.
Ifprev == nulland a similar reference already exist (samesrc, sametgt), does not create a new oneaddSourceAnchor(Method fmx, org.eclipse.jdt.core.dom.MethodDeclaration node) Special case of addSourceAnchor(TSourceEntity, ASTNode) to add location information to a Famix Method.addSourceAnchor(TSourceEntity fmx, org.eclipse.jdt.core.dom.ASTNode node) Adds location information to a Famix Entity.asException(TType fmxType) "Converts" (if needed) a TTYpe entity to be a TThrowable.<T extends TParametricEntity>
TParametricAssociationbuildFamixParametricAssociation(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.protected voidchainPrevNext(TAssociation prev, TAssociation next) createFamixCaughtException(Method meth, TThrowable excep) Returns a Famix CaughtException between a method and an Exception that is caughtcreateFamixComment(org.eclipse.jdt.core.dom.Comment jCmt, TWithComments owner) Creates and returns a Famix Comment and associates it with an Entity (ex: for Javadocs)createFamixComment(org.eclipse.jdt.core.dom.Comment jCmt, TWithComments owner, String content) Creates and returns a Famix Comment and associates it with an EntitycreateFamixDeclaredException(Method meth, TThrowable excep) Returns a Famix DeclaredException between a method and an Exception that it declares to throwprotected <T extends TNamedEntity & TSourceEntity>
TcreateFamixEntity(Class<T> fmxClass, String name) Creates and returns a FAMIX Entity of the type fmxjava.lang.Class.createFamixThrownException(Method meth, TThrowable excep) Returns a Famix ThrownException between a method and an Exception that it (actually) throws.protected IndexedFileAnchorcreateIndexedFileAnchor(org.eclipse.jdt.core.dom.ASTNode node) Gets the file name holdingnodeand its start and end positions in the file.ensureFamixAnnotationType(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, ContainerEntity owner) e.g.ensureFamixAnnotationTypeAttribute(org.eclipse.jdt.core.dom.IMethodBinding bnd, String name, AnnotationType owner) ensureFamixAttribute(org.eclipse.jdt.core.dom.IVariableBinding bnd, String name, Type type, TWithAttributes owner) Returns a Famix Attribute associated with the IVariableBinding.ensureFamixAttribute(org.eclipse.jdt.core.dom.IVariableBinding bnd, String name, TWithAttributes owner) ensureFamixClass(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TNamedEntity owner, boolean isGeneric, int modifiers) Returns a Famix Class associated with the ITypeBinding.Creates or recovers the Famix Class for all arrays (Creates or recovers the Famix Class for "Object".Creates or recovers the Famix Class that will own all stub methods (for which the real owner is unknown)ensureFamixConcretization(TTypeArgument typeArgument, TypeParameter typeParameter) Returns a Famix Concretization relationship between a Concrete Type and a ParameterTypeprotected <T extends TNamedEntity & TSourceEntity>
TensureFamixEntity(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).ensureFamixEntityTyping(org.eclipse.jdt.core.dom.ITypeBinding declaredTypeBnd, TTypedEntity typedEntity, TType declaredType) Returns a Famix EntityTyping between a typed entity and a type.<T extends TWithTypes & TNamedEntity>
EnumensureFamixEnum(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TWithTypes owner) ensureFamixEnumValue(org.eclipse.jdt.core.dom.IVariableBinding bnd, String name, Enum owner) <T extends TWithTypes & TNamedEntity>
ExceptionensureFamixException(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TWithTypes owner, boolean isGeneric, int modifiers) Returns a Famix Exception associated with the ITypeBinding.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 neededensureFamixImplicitVariable(String name, TType tType, TMethod tMethod) 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.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 neededensureFamixInitializer(TWithMethods owner, Boolean isStatic, Boolean isInitializationBlock) Creates or recovers the initializer method containing the attribute initializations of a type.<T extends TWithTypes & TNamedEntity>
InterfaceensureFamixInterface(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.ensureFamixLocalVariable(org.eclipse.jdt.core.dom.IVariableBinding bnd, String name, TWithLocalVariables owner) Returns a Famix LocalVariable associated with the IVariableBinding.ensureFamixMetaClass(org.eclipse.jdt.core.dom.ITypeBinding bnd) Ensures the Java meta-class:ensureFamixMethod(org.eclipse.jdt.core.dom.IMethodBinding bnd) 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.ensureFamixPackage(org.eclipse.jdt.core.dom.IPackageBinding bnd, String name) Returns a Famix Package associated with its IPackageBinding and/or fully qualified name.Creates or recovers a default Famix Package.ensureFamixPackageJavaLang(org.eclipse.jdt.core.dom.IPackageBinding bnd) Creates or recovers a Famix Package for the package of Java class "Object" (i.e.Returns an artificial Package to contain stubs with an unknown package.ensureFamixParameter(org.eclipse.jdt.core.dom.IVariableBinding bnd, String name, Type typ, TMethod tMethod) Returns a Famix Parameter associated with the IVariableBinding.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 InterfaceensureFamixParametricInterface(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 InterfaceensureFamixPrimitiveType(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 nameensureFamixStubMethod(String name) Creates or recovers a stub Famix MethodensureFamixType(org.eclipse.jdt.core.dom.ITypeBinding bnd) 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.ensureFamixType(org.eclipse.jdt.core.dom.ITypeBinding bnd, TWithTypes context) 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<T extends NamedEntity>
TensureFamixUniqEntity(Class<T> fmxClass, org.eclipse.jdt.core.dom.IBinding key, String name) Creates or recovers a Famix Named Entity uniq for the given name.ensureFamixWildcardType(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TParametricEntity owner, TWithTypes ctxt) Returns a FAMIX Wildcard with its boundsvoidensureImplementedInterfaces(org.eclipse.jdt.core.dom.ITypeBinding bnd, TType fmx, TWithTypes owner, TAssociation lastAssociation) ensureImplicitConstructor(org.eclipse.jdt.core.dom.IMethodBinding binding, TWithMethods owner, String name, Collection<String> parameterTypesNames) We treat array types as parametrized typesArray<T>.voidAdds an already created Entity to the Famix repository Used mainly for non-NamedEntity, for example relationshipsfindTypeName(org.eclipse.jdt.core.dom.Type t) getEntityByKey(org.eclipse.jdt.core.dom.IBinding key) Returns the Famix Entity associated to the given key.protected <T extends TNamedEntity>
TgetEntityByKey(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.<T extends TNamedEntity>
Collection<T> getEntityByName(Class<T> fmxClass, String name) Returns all the Famix Entity with the given name and classorg.eclipse.jdt.core.dom.IBindingReturns the key associated to a Famix Entity.org.eclipse.jdt.core.dom.IMethodBindinggetEnumConstantMethodOverride(EnumValue enumConstant, org.eclipse.jdt.core.dom.IMethodBinding calledMethod) getFamixAnnotationType(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, ContainerEntity owner) helper method, we know the type exists, ensureFamixAnnotationType will recover itgetFamixAnnotationTypeAttribute(org.eclipse.jdt.core.dom.IMethodBinding bnd, String name, AnnotationType owner) helper method, we know the attribute exists, ensureFamixAnnotationTypeAttribute will recover itgetFamixAttribute(org.eclipse.jdt.core.dom.IVariableBinding bnd, String name, TWithAttributes owner) helper method, we know the var exists, ensureFamixAttribute will recover itgetFamixClass(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TNamedEntity owner) helper method, we know the type exists, ensureFamixClass will recover itgetFamixEnum(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TWithTypes owner) helper method, we know the type exists, ensureFamixEnum will recover itgetFamixException(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, TWithTypes owner) helper method, we know the type exists, ensureFamixInterface will recover itgetFamixInterface(org.eclipse.jdt.core.dom.ITypeBinding bnd, String name, ContainerEntity owner) helper method, we know the type exists, ensureFamixInterface will recover itgetFamixMetaClass(org.eclipse.jdt.core.dom.ITypeBinding bnd) Returns the Package withDEFAULT_PCKG_NAMEornullif not foundgetImplicitVariableByBinding(org.eclipse.jdt.core.dom.IBinding bnd, String iv_name) Deprecated.getImplicitVariableByType(Type type, String name) Deprecated.protected booleanisConstructorBinding(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<>())booleanisThrowable(org.eclipse.jdt.core.dom.ITypeBinding bnd) protected voidmapEntityToKey(org.eclipse.jdt.core.dom.IBinding key, TNamedEntity ent) protected voidmapEntityToName(String name, TNamedEntity ent) protected voidResets 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.referredType(org.eclipse.jdt.core.dom.ITypeBinding bnd, TNamedEntity ctxt) referredType(org.eclipse.jdt.core.dom.ITypeBinding bnd, TNamedEntity ctxt, int extraDimensions) <T extends TWithTypes & TNamedEntity>
TTypereferredType(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.<T extends TWithTypes & TNamedEntity>
TTypereferredType(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.voidregisterEnumConstantAnonymousType(org.eclipse.jdt.core.dom.IVariableBinding enumConstant, org.eclipse.jdt.core.dom.ITypeBinding anonymousType) voidremoveEntity(NamedEntity ent) removeLastPartOfPackageName(String qualifiedName) searchTypeInContext(String name, TWithTypes ctxt) voidsetAttributeModifiers(Attribute fmx, int mod) voidsetClassModifiers(Class fmx, int mod, TWithTypes owner) voidsetInterfaceModifiers(Interface fmx, int mod) voidsetMethodModifiers(Method fmx, int mod) voidsetVisibility(THasVisibility fmx, int mod, TWithTypes owner) Sets the visibility of a FamixNamedEntityprotected StringsignatureParamsFromBinding(org.eclipse.jdt.core.dom.IMethodBinding bnd) Generates the list of parameters for a method signature
-
Field Details
-
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
- See Also:
-
MISSING_PCKG_NAME
- See Also:
-
STUB_METHOD_CONTAINER_NAME
- See Also:
-
THIS_NAME
- See Also:
-
SUPER_NAME
- See Also:
-
OBJECT_NAME
- See Also:
-
METACLASS_NAME
- See Also:
-
OBJECT_PACKAGE_NAME
- See Also:
-
ARRAYS_NAME
- See Also:
-
INIT_BLOCK_NAME
- See Also:
-
ANONYMOUS_NAME_PREFIX
- See Also:
-
UNKNOWN_MODIFIERS
public static final int UNKNOWN_MODIFIERS- See Also:
-
MODIFIER_PUBLIC
- See Also:
-
MODIFIER_PRIVATE
- See Also:
-
MODIFIER_PROTECTED
- See Also:
-
MODIFIER_PACKAGE
- See Also:
-
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
name of the entity representing the "unknown" type 'var' The entity is intended to be unique, seeensureFamixUniqEntity(java.lang.Class, IBinding, String)- See Also:
-
famixRepo
protected ch.akuhn.fame.Repository famixRepoThe FAMIX repository where all FAMIX entities are created and stored -
keyToEntity
A dictionary to map a key (provided by the user) to FAMIX Entity -
entityToKey
A reverse dictionary (seekeyToEntity) to find the key of an entity. -
enumConstantAnonymousTypes
protected Map<org.eclipse.jdt.core.dom.IVariableBinding, org.eclipse.jdt.core.dom.ITypeBinding> enumConstantAnonymousTypesAssociates 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
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 inkeyToEntity -
useMissingPackage
protected boolean useMissingPackageOption: 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
-
removeEntity
-
mapEntityToKey
-
getEntityByName
Returns all the Famix Entity with the given name and class- Parameters:
fmxClass- -- the subtype of Famix Entity we are looking forname- -- the name of the entity- Returns:
- the Collection of Famix Entities with the given name and class (possibly empty)
-
getEntityByKey
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, usegetImplicitVariableByBinding(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 keyfmxClass- -- the expected Famix class- Returns:
- the Famix Entity associated to the binding or null if not found or not an instance of fmxClass
-
getEntityKey
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 createname- -- 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 createbnd- -- the binding to map to the new instancename- -- 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
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 classsub- -- the sub classprev- -- 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 concretizationstypeParameters- -- the collection of type parameters declared in the generic entitytypeArguments- -- 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 typetypeParameter- -- 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 interfaceimplementingClass- -- the implementing classprev- -- 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.
Ifprev == nulland a similar reference already exist (samesrc, sametgt), does not create a new one- Parameters:
src- -- source of the referencetgt- -- target of the referenceprev- -- 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 invocationinvoked- -- method invokedreceiver- of the invocationsignature- -- i.e. actual invocation codeprev- -- 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 attributevar- -- the variable accessedisWrite- -- whether this is an access for reading or writing in the variableprev- -- previous access relationship in the same context- Returns:
- the FamixAccess
-
chainPrevNext
-
createFamixDeclaredException
Returns a Famix DeclaredException between a method and an Exception that it declares to throw- Parameters:
meth- -- the method throwing the exceptionexcep- -- the exception declared to be thrown- Returns:
- the DeclaredException
-
createFamixCaughtException
Returns a Famix CaughtException between a method and an Exception that is caught- Parameters:
meth- -- the method catching the exceptionexcep- -- the exception caught- Returns:
- the CaughtException
-
createFamixThrownException
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 exceptionexcep- -- 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 entitydeclaredType- -- 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 alsogetEntityByKey(IBinding)- Parameters:
bnd- -- the binding- Returns:
- the Famix Entity associated to the binding or null if not found
-
getImplicitVariableByType
Deprecated.Returns the Famix ImplicitVariable associated to the given FamixType.- Parameters:
type- -- the FamixTypename- -- 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 createkey- -- a potential binding for the entityname- -- the name of the new instance (used if
)bnd == null- Returns:
- the uniq Famix Entity for this binding and/or name
-
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
-
ensureFamixPackage
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 namespacename- -- 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
Creates or recovers a default Famix Package. Because this package does not really exist, it has no binding.- Returns:
- a Famix Namespace
-
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
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
Returns the Package withDEFAULT_PCKG_NAMEornullif 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 createname- of the typeowner- of the typectxt- -- context of use of the type
-
ensureFamixType
-
ensureFamixType
-
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 Exceptionowner- -- 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 Methodowner- -- 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
"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
helper method, we know the type exists, ensureFamixEnum will recover it -
ensureFamixEnumValue
-
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
-
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 initializerisStatic- 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
-
setAttributeModifiers
-
setMethodModifiers
-
setClassModifiers
-
setInterfaceModifiers
-
setVisibility
Sets the visibility of a FamixNamedEntity- Parameters:
fmx- -- the FamixNamedEntitymod- -- 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
-
createFamixComment
Creates and returns a Famix Comment and associates it with an Entity (ex: for Javadocs)- Parameters:
jCmt- -- the content (String) of the commentowner- -- 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 commentowner- -- the entity that is commentedcontent- -- the text of the comment- Returns:
- the Famix Comment
-
addSourceAnchor
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 tonode- -- 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
Special case of addSourceAnchor(TSourceEntity, ASTNode) to add location information to a Famix Method. -
createIndexedFileAnchor
Gets the file name holdingnodeand its start and end positions in the file. Information returned in the form of an IndexedFileAnchor -
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
We treat array types as parametrized typesArray<T>. This keeps the meta-model simple: a single way to model different concepts.- Returns:
-
ensureFamixMetaClass
Ensures the Java meta-class:java.lang.Class<> -
getFamixMetaClass
-
ensureFamixClassArray
Creates or recovers the Famix Class for all arrays (
) 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.<some-type> []- Returns:
- a Famix class
-
removeLastPartOfPackageName
-
signatureParamsFromBinding
Generates the list of parameters for a method signature- Returns:
- a string
-
findTypeName
-
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
-
referredType
public TType referredType(org.eclipse.jdt.core.dom.ITypeBinding bnd, TNamedEntity ctxt, int extraDimensions)
-