@@ -4,10 +4,11 @@ I'm mainly invoked by the MooseImportClassesTask
4
4
"
5
5
Class {
6
6
#name : #FamixStImporter ,
7
- #superclass : #FamixStAbstractImporter ,
7
+ #superclass : #Object ,
8
+ #traits : ' FamixStTImportUtils' ,
9
+ #classTraits : ' FamixStTImportUtils classTrait' ,
8
10
#instVars : [
9
11
' methods' ,
10
- ' classes' ,
11
12
' namespaces' ,
12
13
' packages' ,
13
14
' globals' ,
@@ -65,8 +66,7 @@ FamixStImporter >> basicClassCreation: aClass [
65
66
class := classes at: aClass put: self factory classEntity new .
66
67
class name: (aClass name replaceAll: Character space with: $_).
67
68
class stub: true .
68
- importingContext shouldImportNamespace ifTrue: [
69
- class typeContainer: (self ensureNamespace: aClass environment) ].
69
+ self importingContext shouldImportNamespace ifTrue: [ class typeContainer: (self ensureNamespace: aClass environment) ].
70
70
anchor := self factory anchor new
71
71
element: class ;
72
72
pharoEntity: aClass;
@@ -93,12 +93,6 @@ FamixStImporter >> checkAbstractClass: class [
93
93
class isAbstract: (class methods contains: [ :each | each isAbstract ])
94
94
]
95
95
96
- { #category : #' private accessing' }
97
- FamixStImporter >> classes [
98
-
99
- ^ classes
100
- ]
101
-
102
96
{ #category : #' private-entity-creation' }
103
97
FamixStImporter >> createAnnotationType: aPragmaNode [
104
98
| pragmaAnnotationType |
@@ -119,77 +113,58 @@ FamixStImporter >> createAnnotationType: aPragmaNode [
119
113
120
114
{ #category : #' private-entity-creation' }
121
115
FamixStImporter >> createAttribute: name for: aClass [
116
+
122
117
| attribute realName possibleTypes |
123
118
realName := self nameForInstanceVariable: name class : aClass.
124
- attribute := (self scopeOfClass: aClass)
125
- at: realName
126
- bind: self factory attribute new .
119
+ attribute := (self scopeOfClass: aClass) at: realName bind: self factory attribute new .
127
120
attribute stub: true .
128
121
attribute name: realName asSymbol.
129
- importingContext shouldMergeClassAndMetaclass
122
+ self importingContext shouldMergeClassAndMetaclass
130
123
ifTrue: [ attribute parentType: (self ensureClass: aClass instanceSide) ]
131
124
ifFalse: [ attribute parentType: (self ensureClass: aClass) ].
132
125
attribute isClassSide: aClass isMeta.
133
126
" now we use RoelTyper to see a unique type can be retrieve for this attribute: "
134
- importingContext shouldComputeTypeOfAttributes
135
- ifTrue: [ possibleTypes := (TypeCollector
136
- typeInstvar: name asSymbol
137
- ofClassWithLookup: aClass) types.
138
- possibleTypes size = 1
139
- ifTrue: [ attribute
140
- declaredType: (self ensureClass: possibleTypes first instanceSide) ] ].
127
+ self importingContext shouldComputeTypeOfAttributes ifTrue: [
128
+ possibleTypes := (TypeCollector typeInstvar: name asSymbol ofClassWithLookup: aClass) types.
129
+ possibleTypes size = 1 ifTrue: [ attribute declaredType: (self ensureClass: possibleTypes first instanceSide) ] ].
141
130
^ attribute
142
131
]
143
132
144
133
{ #category : #' private-entity-creation' }
145
134
FamixStImporter >> createClass: aClass [
146
135
147
136
| class inheritance |
148
- class := (importingContext shouldMergeClassAndMetaclass and : [
149
- aClass isMeta ])
150
- ifTrue: [
151
- classes
152
- at: aClass
153
- put: (self ensureClass: aClass soleInstance) ]
137
+ class := (self importingContext shouldMergeClassAndMetaclass and : [ aClass isMeta ])
138
+ ifTrue: [ classes at: aClass put: (self ensureClass: aClass soleInstance) ]
154
139
ifFalse: [ self basicClassCreation: aClass ].
155
140
156
- importingContext shouldImportPackage ifTrue: [
157
- class parentPackage: (self ensurePackage: aClass package) ].
141
+ self importingContext shouldImportPackage ifTrue: [ class parentPackage: (self ensurePackage: aClass package) ].
158
142
159
- importingContext shouldImportInheritance ifTrue: [
160
- (aClass superclass isNotNil and : [
161
- importingContext shouldMergeClassAndMetaclass
143
+ self importingContext shouldImportInheritance ifTrue: [
144
+ (aClass superclass isNotNil and : [
145
+ self importingContext shouldMergeClassAndMetaclass
162
146
ifFalse: [ true ]
163
- ifTrue: [ aClass isMeta not ] ]) ifTrue: [
147
+ ifTrue: [ aClass isMeta not ] ]) ifTrue: [
164
148
inheritance := self addEntity: self factory inheritance new .
165
149
inheritance superclass: (self ensureClass: aClass superclass).
166
150
inheritance subclass: class ] ].
167
151
168
152
aClass isMeta ifFalse: [ self ensureClass: aClass class ].
169
153
170
- importingContext shouldImportAttribute ifTrue: [
171
- aClass instVarNames do: [ :eachName |
172
- self ensureAttribute: eachName for: aClass ].
154
+ self importingContext shouldImportAttribute ifTrue: [
155
+ aClass instVarNames do: [ :eachName | self ensureAttribute: eachName for: aClass ].
173
156
" since the classVar of a class are not the same as the classVar of the class class"
174
157
" with latest pharo class classVar = class class classVar so we should not need that anymore"
175
158
aClass isMeta
176
- ifTrue: [
177
- aClass soleInstance classVarNames do: [ :eachClassVarName |
178
- self
179
- ensureClassVarAttribute: eachClassVarName
180
- for: aClass soleInstance ] ]
181
- ifFalse: [
182
- aClass classVarNames do: [ :eachClassVarName |
183
- self ensureClassVarAttribute: eachClassVarName for: aClass ] ] ].
184
-
185
- (importingContext shouldImportComment and : [ aClass hasComment ])
186
- ifTrue: [
187
- (importingContext shouldMergeClassAndMetaclass and : [
188
- aClass isMeta ]) ifFalse: [
189
- | comment |
190
- comment := self addEntity: self factory comment new .
191
- comment content: aClass comment asString.
192
- comment commentedEntity: class ] ].
159
+ ifTrue: [ aClass soleInstance classVarNames do: [ :eachClassVarName | self ensureClassVarAttribute: eachClassVarName for: aClass soleInstance ] ]
160
+ ifFalse: [ aClass classVarNames do: [ :eachClassVarName | self ensureClassVarAttribute: eachClassVarName for: aClass ] ] ].
161
+
162
+ (self importingContext shouldImportComment and : [ aClass hasComment ]) ifTrue: [
163
+ (self importingContext shouldMergeClassAndMetaclass and : [ aClass isMeta ]) ifFalse: [
164
+ | comment |
165
+ comment := self addEntity: self factory comment new .
166
+ comment content: aClass comment asString.
167
+ comment commentedEntity: class ] ].
193
168
194
169
^ class
195
170
]
@@ -227,7 +202,7 @@ FamixStImporter >> createMethod: aCompiledMethod [
227
202
228
203
| method anchor |
229
204
method := self createStubMethod: aCompiledMethod.
230
- importingContext shouldImportMethodBody ifTrue: [
205
+ self importingContext shouldImportMethodBody ifTrue: [
231
206
| visitor |
232
207
visitor := SmalltalkMethodVisitor on: self .
233
208
visitor runWith: aCompiledMethod and : method ].
@@ -443,14 +418,10 @@ FamixStImporter >> ensureSmalltalkStubMethod: aCompiledMethod [
443
418
FamixStImporter >> ensureSmalltalkStubMethodsFor: aSignature [
444
419
445
420
| implementors |
446
- importingContext shouldImportSmalltalkStubMethod ifFalse: [ ^ #( ) ].
421
+ self importingContext shouldImportSmalltalkStubMethod ifFalse: [ ^ #( ) ].
447
422
implementors := self allImplementorsOf: aSignature.
448
- implementors ifEmpty: [
449
- ^ { (self
450
- basicCreateMethod: (aSignature copyUpTo: $()
451
- withSignature: aSignature) } ].
452
- ^ implementors collect: [ :meth |
453
- self ensureSmalltalkStubMethod: meth ]
423
+ implementors ifEmpty: [ ^ { (self basicCreateMethod: (aSignature copyUpTo: $() withSignature: aSignature) } ].
424
+ ^ implementors collect: [ :meth | self ensureSmalltalkStubMethod: meth ]
454
425
]
455
426
456
427
{ #category : #' public-entity-creation' }
@@ -472,21 +443,18 @@ FamixStImporter >> famixClasses [
472
443
FamixStImporter >> importClass: aClass [
473
444
474
445
| class |
475
- importingContext shouldImportClass ifFalse: [ ^ self ].
446
+ self importingContext shouldImportClass ifFalse: [ ^ self ].
476
447
477
448
class := self ensureClass: aClass.
478
449
class stub: false .
479
450
class attributes do: [ :each | each stub: false ].
480
451
481
- importingContext shouldImportPackage ifTrue: [
482
- class parentPackage stub: false ].
452
+ self importingContext shouldImportPackage ifTrue: [ class parentPackage stub: false ].
483
453
484
- importingContext shouldImportSubclasses ifTrue: [
485
- aClass subclasses do: [ :each | self ensureClass: each ] ].
454
+ self importingContext shouldImportSubclasses ifTrue: [ aClass subclasses do: [ :each | self ensureClass: each ] ].
486
455
487
- importingContext shouldImportMethod ifTrue: [
488
- aClass methods do: [ :each |
489
- (self ensureMethod: each) isStub: false ].
456
+ self importingContext shouldImportMethod ifTrue: [
457
+ aClass methods do: [ :each | (self ensureMethod: each) isStub: false ].
490
458
self checkAbstractClass: class ].
491
459
492
460
aClass isMeta ifFalse: [ self importClass: aClass class ]
@@ -496,12 +464,11 @@ FamixStImporter >> importClass: aClass [
496
464
FamixStImporter >> importClassExtension: aClassExtension [
497
465
498
466
| method |
499
- importingContext shouldImportClassExtension ifFalse: [ ^ self ].
467
+ self importingContext shouldImportClassExtension ifFalse: [ ^ self ].
500
468
501
469
method := (self ensureMethod: aClassExtension) isStub: false .
502
470
503
- importingContext shouldImportPackage ifTrue: [
504
- method parentPackage isStub: false ]
471
+ self importingContext shouldImportPackage ifTrue: [ method parentPackage isStub: false ]
505
472
]
506
473
507
474
{ #category : #initialization }
@@ -526,12 +493,9 @@ FamixStImporter >> methods [
526
493
527
494
{ #category : #' private utils' }
528
495
FamixStImporter >> nameForInstanceVariable: name class : aClass [
529
-
530
- (importingContext shouldMergeClassAndMetaclass)
531
- and : [aClass isMeta ifTrue: [ ^ self CIVString , name]].
496
+
497
+ self importingContext shouldMergeClassAndMetaclass and : [ aClass isMeta ifTrue: [ ^ self CIVString , name ] ].
532
498
^ name
533
-
534
-
535
499
]
536
500
537
501
{ #category : #' private-entity-creation' }
0 commit comments