diff --git a/src/Famix-Python-Entities/FamixPythonModule.class.st b/src/Famix-Python-Entities/FamixPythonModule.class.st index add0459..fbc255f 100644 --- a/src/Famix-Python-Entities/FamixPythonModule.class.st +++ b/src/Famix-Python-Entities/FamixPythonModule.class.st @@ -21,6 +21,7 @@ |---| | `accesses` | `FamixTWithAccesses` | `accessor` | `FamixTAccess` | Accesses to variables made by this behaviour.| | `outgoingInvocations` | `FamixTWithInvocations` | `sender` | `FamixTInvocation` | Outgoing invocations sent by this behaviour.| +| `outgoingReferences` | `FamixTWithReferences` | `referencer` | `FamixTReference` | References from this entity to other entities.| ### Incoming dependencies | Relation | Origin | Opposite | Type | Comment | @@ -33,8 +34,8 @@ Class { #name : 'FamixPythonModule', #superclass : 'FamixPythonContainerEntity', - #traits : 'FamixTImportable + FamixTModule + FamixTPackageable + FamixTWithAccesses + FamixTWithComments + FamixTWithFunctions + FamixTWithGlobalVariables + FamixTWithInvocations + FamixTWithLambdas', - #classTraits : 'FamixTImportable classTrait + FamixTModule classTrait + FamixTPackageable classTrait + FamixTWithAccesses classTrait + FamixTWithComments classTrait + FamixTWithFunctions classTrait + FamixTWithGlobalVariables classTrait + FamixTWithInvocations classTrait + FamixTWithLambdas classTrait', + #traits : 'FamixTImportable + FamixTModule + FamixTPackageable + FamixTWithAccesses + FamixTWithComments + FamixTWithFunctions + FamixTWithGlobalVariables + FamixTWithInvocations + FamixTWithLambdas + FamixTWithReferences', + #classTraits : 'FamixTImportable classTrait + FamixTModule classTrait + FamixTPackageable classTrait + FamixTWithAccesses classTrait + FamixTWithComments classTrait + FamixTWithFunctions classTrait + FamixTWithGlobalVariables classTrait + FamixTWithInvocations classTrait + FamixTWithLambdas classTrait + FamixTWithReferences classTrait', #category : 'Famix-Python-Entities-Entities', #package : 'Famix-Python-Entities', #tag : 'Entities' diff --git a/src/Famix-Python-Generator/FamixPythonGenerator.class.st b/src/Famix-Python-Generator/FamixPythonGenerator.class.st index 659cc05..4cc5615 100644 --- a/src/Famix-Python-Generator/FamixPythonGenerator.class.st +++ b/src/Famix-Python-Generator/FamixPythonGenerator.class.st @@ -165,6 +165,7 @@ FamixPythonGenerator >> defineHierarchy [ module --|> #TWithGlobalVariables. module --|> #TWithLambdas. module --|> #TWithAccesses. + module --|> #TWithReferences. namedEntity --|> sourcedEntity. namedEntity --|> #TInvocationsReceiver. diff --git a/src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st b/src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st index 811c811..b9cc794 100644 --- a/src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st +++ b/src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st @@ -2193,6 +2193,40 @@ FamixPythonProject1Test >> testReadAccessToParameter [ self assert: (function accesses anySatisfy: [ :anAccess | anAccess variable = parameter ]) ] +{ #category : 'tests - references' } +FamixPythonProject1Test >> testReferenceFromModule [ + + | class module reference | + class := self classNamed: 'Student'. + module := self moduleNamed: 'moduleAtRoot2'. + + reference := (class incomingReferences select: [ :aReference | aReference referencer = module ]) detectMax: [ :aReference | aReference sourceAnchor startPos ]. + + self assert: reference class equals: FamixPythonReference. + self assert: reference source equals: module. + self assert: reference referencer equals: module. + self assert: reference target equals: class. + self assert: reference referredType equals: class. + self assert: (module outgoingReferences anySatisfy: [ :aReference | aReference referredType = class ]) +] + +{ #category : 'tests - references' } +FamixPythonProject1Test >> testReferenceFromPackage [ + + | class package reference | + class := self classNamed: 'Room'. + package := self packageNamed: 'subsubpackage1'. + + reference := (class incomingReferences select: [ :aReference | aReference referencer = package ]) detectMax: [ :aReference | aReference sourceAnchor startPos ]. + + self assert: reference class equals: FamixPythonReference. + self assert: reference source equals: package. + self assert: reference referencer equals: package. + self assert: reference target equals: class. + self assert: reference referredType equals: class. + self assert: (package outgoingReferences anySatisfy: [ :aReference | aReference referredType = class ]) +] + { #category : 'tests - modules' } FamixPythonProject1Test >> testRootModule [