Skip to content

Commit 801ae9a

Browse files
committed
Cleaning
1 parent c0d763e commit 801ae9a

File tree

1 file changed

+9
-30
lines changed

1 file changed

+9
-30
lines changed

src/Famix-Python-Importer/FamixPythonVisitor.class.st

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ FamixPythonVisitor >> createInheritance [
8787
]
8888

8989
{ #category : 'association creation' }
90-
FamixPythonVisitor >> createInheritance: anAttributeNode [
91-
self flag: #todo. "Should have a #From: in the name but currently clashing with another method"
90+
FamixPythonVisitor >> createInheritanceFrom: anAttributeNode [
91+
9292
^ self createInheritance
9393
in: [ :inheritance | self setSourceAnchor: inheritance from: anAttributeNode ];
9494
yourself
@@ -143,15 +143,6 @@ FamixPythonVisitor >> createStubPackageNamed: aString [
143143
yourself
144144
]
145145

146-
{ #category : 'ensure entity' }
147-
FamixPythonVisitor >> ensureMethod: aMethodNode [
148-
149-
^ (self methodNamed: aMethodNode _name inClassNamed: self currentEntity name)
150-
ifNotNil: [ "I think that this should never happen. Let's keep and halt for a while and see if we ever end up here. If it's the case, I need to add a test to reproduce this!"
151-
1 halt ]
152-
ifNil: [ self manageMethodDeclarationFrom: aMethodNode ]
153-
]
154-
155146
{ #category : 'ensure entity' }
156147
FamixPythonVisitor >> ensureStubClassNamed: aName [
157148

@@ -397,7 +388,7 @@ FamixPythonVisitor >> manageImportedInheritanceDeclaredBy: anAttributeNode [
397388

398389
| inheritance definition |
399390
"We should never end up here because this means we have the sources of the imported entities but I'm still bulletproofing the parser in case we have some code that cannot run""If we did not find an import, we have a stub."
400-
inheritance := self createInheritance: anAttributeNode.
391+
inheritance := self createInheritanceFrom: anAttributeNode.
401392
definition := self attributeAsAssociation: anAttributeNode.
402393

403394
self findImportMatchingSource: definition key ifFound: [ :import |
@@ -421,7 +412,7 @@ FamixPythonVisitor >> manageImportedInheritanceDeclaredBy: anAttributeNode [
421412
FamixPythonVisitor >> manageInheritanceDeclaredBy: superclassNode [
422413

423414
| inheritance |
424-
inheritance := self createInheritance: superclassNode.
415+
inheritance := self createInheritanceFrom: superclassNode.
425416

426417
self
427418
resolve: ((SRIdentifierWithNode identifier: superclassNode sourceText)
@@ -469,15 +460,12 @@ FamixPythonVisitor >> manageMetaclassUsageDeclaredBy: aKeywordArgumentNode [
469460
{ #category : 'private' }
470461
FamixPythonVisitor >> manageMethodDeclarationFrom: aMethodNode [
471462

472-
| method name signature |
473-
name := self visit: aMethodNode _name.
474-
signature := aMethodNode completeSource copyFrom: aMethodNode _name startPosition to: aMethodNode _parameters endPosition.
475-
method := (self createMethodNamed: name)
476-
signature: signature;
463+
| method name |
464+
method := (self createMethodNamed: (name := self visit: aMethodNode _name))
465+
signature: (aMethodNode completeSource copyFrom: aMethodNode _name startPosition to: aMethodNode _parameters endPosition);
466+
parentType: self currentEntity;
477467
yourself.
478468

479-
method parentType: self currentEntity.
480-
481469
name = '__init__' ifTrue: [ method isConstructor: true ].
482470

483471
(name beginsWith: 'get_') ifTrue: [
@@ -519,15 +507,6 @@ FamixPythonVisitor >> manageWriteAccessTo: aNode [
519507
^ variable
520508
]
521509

522-
{ #category : 'accessing' }
523-
FamixPythonVisitor >> methodNamed: aString inClassNamed: aClassName [
524-
525-
self flag: #todo. "Check if we get here? If it's the case, we should probably create a new methods shadowing the previous one."
526-
^ self model allModelMethods
527-
detect: [ :method | method name = aString and: [ method parentType name = aClassName ] ]
528-
ifNone: [ nil ]
529-
]
530-
531510
{ #category : 'accessing' }
532511
FamixPythonVisitor >> modelClass [
533512

@@ -1053,7 +1032,7 @@ FamixPythonVisitor >> visitFunctionDefinition: aFunctionDefinition [
10531032

10541033
| entity |
10551034
entity := self currentEntity isClass
1056-
ifTrue: [ self ensureMethod: aFunctionDefinition ]
1035+
ifTrue: [ self manageMethodDeclarationFrom: aFunctionDefinition ]
10571036
ifFalse: [ self manageFunctionDeclarationFrom: aFunctionDefinition ].
10581037

10591038
^ self useCurrentEntity: entity during: [

0 commit comments

Comments
 (0)