Skip to content

Commit cdd5588

Browse files
committed
Fix infinit loop during parsing
Fixes #33
1 parent fc10411 commit cdd5588

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3205,6 +3205,21 @@ FamixPythonProject1Test >> testInvocationToUnknowEntityOfSameNameAsUnknowPackage
32053205
self assert: unknowFunction isStub
32063206
]
32073207
3208+
{ #category : 'tests' }
3209+
FamixPythonProject1Test >> testInvocationToUnknowEntityOfSameNameAsUnknowPackage2 [
3210+
"Regression test"
3211+
3212+
| unknowFunction |
3213+
"I get the one without children to have the bottom most entity of this name since it should be in an entity of the same name."
3214+
unknowFunction := self model entities detect: [ :entity |
3215+
entity class = FamixPythonUnknownEntity and: [ entity name = 'variable_scope' and: [ entity childEntities isEmpty ] ] ].
3216+
3217+
self assert: unknowFunction name equals: 'variable_scope'.
3218+
self assert: unknowFunction parentPackage name equals: 'variable_scope'.
3219+
self deny: unknowFunction identicalTo: unknowFunction parentPackage.
3220+
self assert: unknowFunction isStub
3221+
]
3222+
32083223
{ #category : 'tests - invocations' }
32093224
FamixPythonProject1Test >> testInvocationsThatCannotBeResolved [
32103225
"I created a file with a lot of invocations that cannot be resolved and we will ensure we do not create any invocation for them."

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ FamixPythonVisitor >> manageAttributeAsCallReceiver: aNode [
350350
expectedKind: {
351351
FamixPythonFunction.
352352
FamixPythonClass };
353-
notFoundReplacementEntity: [ :unresolved :currentEntity | "This one can be a function or a class"
353+
notFoundReplacementEntity: [ :unresolved :currentEntity |
354+
"This one can be a function or a class"
354355
(self ensureStubUnknownEntityNamed: unresolved identifier)
355356
parentPackage: import importedEntity;
356357
yourself ];
@@ -363,10 +364,7 @@ FamixPythonVisitor >> manageAttributeAsCallReceiver: aNode [
363364
ifFound: [ :import |
364365
^ self
365366
resolve: ((FamixPythonDependencyFromImportedEntityResolvable identifier: identifier import: import)
366-
notFoundReplacementEntity: [ :unresolved :currentEntity |
367-
(self ensureStubUnknownEntityNamed: unresolved identifier)
368-
parentPackage: unresolved import importedEntity;
369-
yourself ];
367+
notFoundReplacementEntity: [ :unresolved :currentEntity | self ensureStubUnknownEntityNamed: unresolved identifier in: unresolved import importedEntity ];
370368
yourself)
371369
foundAction: [ :result :currentEntity | self createAssociationsForFunctionCallNode: (aNode parentOfType: #call) forResult: result in: currentEntity ] ].
372370

0 commit comments

Comments
 (0)