Skip to content

Commit f290dcf

Browse files
authored
Merge pull request #1107 from jecisc/method-changes
Remove dependency from method addition and updates changes to ring
2 parents d8b9cc1 + ab3de12 commit f290dcf

4 files changed

Lines changed: 74 additions & 119 deletions

File tree

src/Famix-MetamodelBuilder-Core/FmxMBRealRingEnvironment.class.st

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ Class {
99
#tag : 'Implementation'
1010
}
1111

12+
{ #category : 'adding' }
13+
FmxMBRealRingEnvironment >> addMethod: sourceCode in: aClassName classSide: aBoolean protocol: protocol [
14+
15+
changesToApply add: (FmxMethodAddition
16+
className: aClassName
17+
isClassSide: aBoolean
18+
sourceCode: sourceCode
19+
protocol: protocol)
20+
]
21+
1222
{ #category : 'accessing' }
1323
FmxMBRealRingEnvironment >> apply [
1424

@@ -184,13 +194,13 @@ FmxMBRealRingEnvironment >> recordMethodsAdoptionsOf: realClass to: anRGClass re
184194
((anRGClass localSelectors difference: generatedMethodNamesOfRealClass)
185195
select: [ :selectorOfMethodToAdd | realClass ifNil: [ true ] ifNotNil: [ (realClass localSelectors includes: selectorOfMethodToAdd) not ] ]
186196
thenCollect: [ :selectorOfMethodToAdd | anRGClass methodNamed: selectorOfMethodToAdd ])
187-
ifNotEmpty: [ :methods | changesToApply add: (FmxMethodAdditions className: aClassName isClassSide: anRGClass isClassSide rgMethods: methods) ].
197+
ifNotEmpty: [ :methods | methods do: [ :method | self addMethod: method sourceCode in: aClassName classSide: anRGClass isClassSide protocol: method protocol ] ].
188198

189199
"Finally, update methods needing updates"
190200
((generatedMethodNamesOfRealClass intersection: anRGClass localSelectors)
191201
collect: [ :selectorOfMethodToUpdate | anRGClass methodNamed: selectorOfMethodToUpdate ]
192202
thenSelect: [ :method | realClass needToAdaptToMethod: method ])
193-
ifNotEmpty: [ :methods | changesToApply add: (FmxMethodUpdates className: aClassName isClassSide: anRGClass isClassSide rgMethods: methods) ]
203+
ifNotEmpty: [ :methods |methods do: [ :method | self addMethod: method sourceCode in: aClassName classSide: anRGClass isClassSide protocol: method protocol ] ]
194204
]
195205

196206
{ #category : 'installing' }
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"
2+
## Description
3+
4+
I represent a change that would create a method to a class during a Famix generation
5+
6+
## Examples
7+
8+
```st
9+
FmxMethodAddition className: FmxMethodAddition isClassSide: false sourceCode: 'x ^ x' protocol: 'accessing'
10+
```
11+
"
12+
Class {
13+
#name : 'FmxMethodAddition',
14+
#superclass : 'FmxLazyClassChange',
15+
#instVars : [
16+
'protocol',
17+
'sourceCode'
18+
],
19+
#category : 'Famix-MetamodelBuilder-Core-Changes',
20+
#package : 'Famix-MetamodelBuilder-Core',
21+
#tag : 'Changes'
22+
}
23+
24+
{ #category : 'class initialization' }
25+
FmxMethodAddition class >> className: aSymbol isClassSide: aBoolean sourceCode: aString protocol: protocol [
26+
27+
^ self new
28+
className: aSymbol;
29+
isClassSide: aBoolean;
30+
sourceCode: aString;
31+
protocol: protocol;
32+
yourself
33+
]
34+
35+
{ #category : 'accessing' }
36+
FmxMethodAddition >> apply [
37+
38+
self realClass compile: sourceCode classified: protocol
39+
]
40+
41+
{ #category : 'printing' }
42+
FmxMethodAddition >> printOn: aStream [
43+
44+
super printOn: aStream.
45+
46+
aStream
47+
nextPutAll: '[';
48+
nextPutAll: (protocol ifNil: [ 'empty' ]);
49+
nextPutAll: ' - ';
50+
nextPutAll: (sourceCode ifNil: [ 'empty' ]);
51+
nextPutAll: ']'
52+
]
53+
54+
{ #category : 'accessing' }
55+
FmxMethodAddition >> protocol: anObject [
56+
protocol := anObject
57+
]
58+
59+
{ #category : 'accessing' }
60+
FmxMethodAddition >> sourceCode: anObject [
61+
sourceCode := anObject
62+
]

src/Famix-MetamodelBuilder-Core/FmxMethodAdditions.class.st

Lines changed: 0 additions & 82 deletions
This file was deleted.

src/Famix-MetamodelBuilder-Core/FmxMethodUpdates.class.st

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)