Skip to content

Commit e74e5f6

Browse files
authored
Merge pull request #713 from moosetechnology/712-MooseGroup-allTypes-does-not-return-any-FamixTParametricEntity
Fix MooseGroup `allUsing`
2 parents 24d91d2 + e814686 commit e74e5f6

File tree

6 files changed

+70
-14
lines changed

6 files changed

+70
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"
2+
## Relations
3+
======================
4+
5+
### Outgoing dependencies
6+
| Relation | Origin | Opposite | Type | Comment |
7+
|---|
8+
| `concretisations` | `FamixTParametricEntity` | `genericEntity` | `FamixTConcretisation` | concretisations relationships, i.e. known concreteEntities of this type.|
9+
10+
### Incoming dependencies
11+
| Relation | Origin | Opposite | Type | Comment |
12+
|---|
13+
| `genericEntity` | `FamixTParametricEntity` | `concreteEntity` | `FamixTConcretisation` | genericEntity relationships, i.e. known genericEntity of this type.|
14+
15+
### Other
16+
| Relation | Origin | Opposite | Type | Comment |
17+
|---|
18+
| `concreteParameters` | `FamixTParametricEntity` | `concreteEntities` | `FamixTConcreteParameterType` | list of concreteParameters|
19+
| `genericParameters` | `FamixTParametricEntity` | `genericEntities` | `FamixTGenericParameterType` | list of genericParameters|
20+
21+
22+
23+
"
24+
Class {
25+
#name : #FamixTest3ParametricClass,
26+
#superclass : #FamixTest3Class,
27+
#traits : 'FamixTParametricEntity',
28+
#classTraits : 'FamixTParametricEntity classTrait',
29+
#category : #'Famix-Test3-Entities-Entities'
30+
}
31+
32+
{ #category : #meta }
33+
FamixTest3ParametricClass class >> annotation [
34+
35+
<FMClass: #ParametricClass super: #FamixTest3Class>
36+
<package: #'Famix-Test3-Entities'>
37+
<generated>
38+
^ self
39+
]

src/Famix-Test3-Entities/FamixTest3TEntityCreator.trait.st

+7
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ FamixTest3TEntityCreator >> newPackageNamed: aName [
9595
^ self add: (FamixTest3Package named: aName)
9696
]
9797

98+
{ #category : #'entity creation' }
99+
FamixTest3TEntityCreator >> newParametricClass [
100+
101+
<generated>
102+
^ self add: FamixTest3ParametricClass new
103+
]
104+
98105
{ #category : #'entity creation' }
99106
FamixTest3TEntityCreator >> newPrimitiveType [
100107

src/Famix-Test3-Tests/FamixTest3MooseQueryTest.class.st

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ FamixTest3MooseQueryTest >> testNumberOfInternalProviders [
118118

119119
{ #category : #tests }
120120
FamixTest3MooseQueryTest >> testParentTypes [
121-
self assertCollection: self m1 parentTypes hasSameElements: {FamixTWithMethods . FamixTest3Class}
121+
self assertCollection: self m1 parentTypes hasSameElements: {FamixTWithMethods . FamixTest3Class . FamixTest3ParametricClass}
122122
]
123123

124124
{ #category : #tests }

src/Famix-TestGenerators/FamixTest3Generator.class.st

+12-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Class {
1212
'typeGroup',
1313
'attribute',
1414
'access',
15-
'package'
15+
'package',
16+
'parametricClass'
1617
],
1718
#category : #'Famix-TestGenerators'
1819
}
@@ -45,8 +46,7 @@ FamixTest3Generator >> defineClasses [
4546
primitiveType := builder newClassNamed: #PrimitiveType.
4647
reference := builder newClassNamed: #Reference.
4748
invocation := builder newClassNamed: #Invocation.
48-
49-
49+
parametricClass := builder newClassNamed: #ParametricClass.
5050
]
5151

5252
{ #category : #definition }
@@ -57,27 +57,30 @@ FamixTest3Generator >> defineHierarchy [
5757
access --|> #TAccess.
5858

5959
attribute --|> #TAttribute.
60-
60+
6161
type --|> namedEntity.
6262
type --|> #TType.
6363

6464
classEntity --|> type.
6565
classEntity --|> #TClass.
6666
classEntity --|> #TPackageable.
6767

68+
parametricClass --|> classEntity.
69+
parametricClass --|> #TParametricEntity.
70+
6871
method --|> namedEntity.
6972
method --|> #TMethod.
70-
73+
7174
package --|> #TPackage.
72-
75+
7376
primitiveType --|> type.
7477
primitiveType --|> #TWithTypes.
7578
primitiveType --|> #TReferenceable.
7679

7780
reference --|> #TReference.
78-
81+
7982
invocation --|> #TInvocation.
80-
83+
8184
"groups"
82-
classEntitygroup --|> typeGroup.
85+
classEntitygroup --|> typeGroup
8386
]

src/Moose-Core-Tests/MooseAbstractGroupTest.class.st

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ MooseAbstractGroupTest >> testAllSatisfy [
7474

7575
{ #category : #tests }
7676
MooseAbstractGroupTest >> testAllUsing [
77-
group addAll: {FamixTest3Class new . FamixTest3Type new}.
77+
group addAll: {FamixTest3Class new . FamixTest3Type new . FamixTest3ParametricClass new}.
7878
self should: [ group allUsing: FamixTest3Type ] raise: MooseAllUsingOnClass.
79-
self assert: (group allUsing: FamixTClass) size equals: 1.
80-
self assert: (group allUsing: FamixTType) size equals: 2
79+
self assert: (group allUsing: FamixTClass) size equals: 2.
80+
self assert: (group allUsing: FamixTType) size equals: 3.
8181
]
8282

8383
{ #category : #tests }

src/Moose-Core/MooseAbstractGroup.class.st

+8-1
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,15 @@ MooseAbstractGroup >> printOn: aStream [
597597
MooseAbstractGroup >> rawAllUsing: aTrait [
598598
"This is an optimization of #allUsing: when we do not need to manipulate a MooseGroup as result."
599599

600+
| seen |
600601
aTrait isTrait ifFalse: [ MooseAllUsingOnClass signal ].
601-
^ self entityStorage select: [ :entity | entity class traitComposition includesTrait: aTrait ]
602+
seen := IdentitySet new.
603+
^ Array streamContents: [ :stream |
604+
aTrait allUsers flattened do: [ :directUser |
605+
directUser withAllSubclasses do: [ :user |
606+
(seen includes: user) ifFalse: [
607+
seen add: user.
608+
stream nextPutAll: (self entityStorage selectAllWithType: user) ] ] ] ]
602609
]
603610

604611
{ #category : #'adding/removing' }

0 commit comments

Comments
 (0)