Skip to content

Commit

Permalink
Add test + remove commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Aug 27, 2024
1 parent 383d0b8 commit 6c4059e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
11 changes: 11 additions & 0 deletions src/Famix-Python-Importer-Tests/FamixPythonImporterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ FamixPythonImporterTest >> testClassKnowsItsMethods [

]

{ #category : 'tests - classes' }
FamixPythonImporterTest >> testClassSuperclass [

| class |
importer accept: pyDoc.
class := importer classNamed: 'Player'.
self assert: class class equals: FamixPythonClass.
self assert: class superclass isNotNil.
self assert: class superclass name equals: 'Sprite'
]

{ #category : 'tests - classes' }
FamixPythonImporterTest >> testClasses [

Expand Down
15 changes: 1 addition & 14 deletions src/Famix-Python-Importer/FamixPythonImporterVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ FamixPythonImporterVisitor >> createAnnotationTypeNamed: aString [
{ #category : 'private-entity-creation' }
FamixPythonImporterVisitor >> createClass: classDefinitionNode [

| famixClass superClasses metaClasses |
| famixClass superClasses |
famixClass := model newClass.
famixClass name: classDefinitionNode pythonClassName.

Expand All @@ -128,19 +128,6 @@ FamixPythonImporterVisitor >> createClass: classDefinitionNode [
superclass: object yourself;
subclass: famixClass ].

"Reject all superclass declarations, keep only metaclasses (if any, there should be at most one)."
"I don't know why this was used. We need tests hitting this part of the code to fix it."
"metaClasses := classDefinitionNode superClasses reject: [ :s | s class = PySymbolNode or: [ s class = PyTrailersNode ] ].
metaClasses do: [ :m |
| metaClassName metaClassObject |
metaClassName := m superclass name.
metaClassObject := self classNamed: metaClassName.
metaClassObject ifNil: [
metaClassObject := model newClass
name: metaClassName;
stub: true ].
famixClass metaclass: metaClassObject ]."

^ self setSourceAnchor: famixClass from: classDefinitionNode
]

Expand Down

0 comments on commit 6c4059e

Please sign in to comment.