Skip to content

Commit 2924817

Browse files
authored
Merge pull request #699 from moosetechnology/696-We-should-have-an-utility-method-to-access-to-methods-of-a-parametric-class
Fix #696
2 parents dc44f6e + dcaff54 commit 2924817

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

src/Famix-Traits/FamixTParametricEntity.trait.st

+23-26
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ FamixTParametricEntity >> addGenericParameter: anObject [
6565
^ self genericParameters add: anObject
6666
]
6767

68+
{ #category : #accessing }
69+
FamixTParametricEntity >> allTypeParameters [
70+
71+
| collection |
72+
collection := OrderedCollection new:
73+
self concreteParameters + self genericParameters size.
74+
collection
75+
addAll: self concreteParameters;
76+
addAll: self genericParameters.
77+
^ collection
78+
]
79+
6880
{ #category : #accessing }
6981
FamixTParametricEntity >> concreteParameters [
7082
"Relation named: #concreteParameters type: #FamixTConcreteParameterType opposite: #concreteEntities"
@@ -133,40 +145,25 @@ FamixTParametricEntity >> genericParameters: anObject [
133145

134146
{ #category : #accessing }
135147
FamixTParametricEntity >> isConcreteEntity [
136-
"An Entity is generic if it has at least one ParameterType"
148+
"An Entity is generic if it has at least one ParameterType"
137149

138-
| param res |
139-
res := true.
140-
param := OrderedCollection new.
141-
param addAll: self genericParameters.
142-
param addAll: self concreteParameters.
143-
param do: [ :p | p isParameterType
144-
ifTrue: [ res := false ] ].
145-
^ res.
146-
147-
"self genericParameters ifNotEmpty: [ ^ false ]
148-
ifEmpty: [^ true]."
150+
^ self isGenericEntity not
149151
]
150152

151153
{ #category : #accessing }
152154
FamixTParametricEntity >> isGenericEntity [
153-
"An Entity is generic if it has at least one ParameterType"
155+
"An Entity is generic if it has at least one ParameterType"
154156

155-
| param res |
156-
res := false.
157-
param := OrderedCollection new.
158-
param addAll: self genericParameters.
159-
param addAll: self concreteParameters.
160-
param do: [ :p | p isParameterType
161-
ifTrue: [ res := true ] ].
162-
^ res.
157+
self genericParameters ifNotEmpty: [ ^ true ].
158+
^ self concreteParameters anySatisfy: [ :p | p isParameterType ]
163159
]
164160

165161
{ #category : #accessing }
166-
FamixTParametricEntity >> parametricParameters [
162+
FamixTParametricEntity >> rootGenericEntity [
167163

168-
|collection|
169-
collection := OrderedCollection new.
170-
collection addAll: self concreteParameters , self genericParameters .
171-
^ collection
164+
| root |
165+
root := self.
166+
[ root genericEntity isNotNil ] whileTrue: [
167+
root := root genericEntity ].
168+
^ root
172169
]

0 commit comments

Comments
 (0)