diff --git a/src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st b/src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st index 3bc5de2..ca33930 100644 --- a/src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st +++ b/src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st @@ -25,6 +25,19 @@ FamixPythonProject1Test >> testModel [ self assert: self model rootFolder equals: FamixPythonBridge parsingExamples / 'project1' ] +{ #category : 'tests - imports' } +FamixPythonProject1Test >> testModuleImportsModuleInPackage [ + + | importingModule importedModule import | + self denyEmpty: self model allImports. + importingModule := self moduleNamed: 'moduleInRootPackage2'. + importedModule := self moduleNamed: 'moduleInSubPackage1'. + import := importingModule outgoingImports detect: [ :pimport | pimport target name = 'moduleInSubPackage1' ]. + + self assert: import importingEntity equals: importingModule. + self assert: import importedEntity equals: importedModule +] + { #category : 'tests - modules' } FamixPythonProject1Test >> testModuleInRootPackage [ diff --git a/src/Famix-Python-Importer/FamixPythonImport.extension.st b/src/Famix-Python-Importer/FamixPythonImport.extension.st index ea26f70..a72e9b4 100644 --- a/src/Famix-Python-Importer/FamixPythonImport.extension.st +++ b/src/Famix-Python-Importer/FamixPythonImport.extension.st @@ -7,8 +7,8 @@ FamixPythonImport >> displayStringOn: aStream [ nextPutAll: 'a ' ; nextPutAll: self class name ; nextPutAll: '('. - self fromName displayStringOn: aStream. + self source displayStringOn: aStream. aStream nextPutAll: ' -> '. - self entityName displayStringOn: aStream. + self target displayStringOn: aStream. aStream nextPutAll: ')' ] diff --git a/src/Famix-Python-Importer/FamixPythonImporterVisitor.class.st b/src/Famix-Python-Importer/FamixPythonImporterVisitor.class.st index 2431c07..8d1c7a1 100644 --- a/src/Famix-Python-Importer/FamixPythonImporterVisitor.class.st +++ b/src/Famix-Python-Importer/FamixPythonImporterVisitor.class.st @@ -135,15 +135,18 @@ FamixPythonImporterVisitor >> createImport: anImport ofName: aName from: fromNam self setSourceAnchor: import from: anImport. self currentEntity addOutgoingImport: import. - +self flag: #todo. "Check how to manage the push before the main entity and the pops." (self solver - pushResolvableAsScopeBeforeMainEntityScope: (FamixPythonImportResolvable path: aName) - foundAction: [ :entity :currentEntity | entity addIncomingImport: import ]) notFoundReplacementEntity: [ :unresolvedImport :currentEntity | + "pushResolvableAsScopeBeforeMainEntityScope: (FamixPythonImportResolvable path: aName)" + resolve:((FamixPythonImportResolvable path: aName) + notFoundReplacementEntity: [ :unresolvedImport :currentEntity | self flag: #todo. "Add infos and check that we do not already have this stub" model newModule isStub: true; addIncomingImport: import; - yourself ]. + yourself ]; + yourself) + foundAction: [ :entity :currentEntity | entity addIncomingImport: import ]) . ^ import ]