Skip to content

Commit a347f65

Browse files
committed
Update API to latest Moose
1 parent 34eb2b2 commit a347f65

6 files changed

Lines changed: 19 additions & 28 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5270,7 +5270,7 @@ FamixPythonProject1Test >> testPackageWithoutInitFile [
52705270
52715271
self assert: rootPackage class equals: FamixPythonPackage.
52725272
self assert: rootPackage name equals: 'root4'.
5273-
self assert: (rootPackage query descendants ofType: FamixTModule) size equals: 2
5273+
self assert: (rootPackage query containedEntities ofType: FamixTModule) size equals: 2
52745274
]
52755275
52765276
{ #category : 'tests - packages' }

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ FamixPythonAbstractImportResolvable >> findTargetEntityFor: aPath from: startEnt
2424
possibleEntities := startEntities select: [ :possibleEntity | possibleEntity name = splittedPath first and: [ possibleEntity isStub not ] ].
2525
splittedPath removeFirst.
2626
[ splittedPath isNotEmpty ] whileTrue: [
27-
| childName |
28-
childName := splittedPath anyOne.
29-
splittedPath removeFirst.
30-
possibleEntities := possibleEntities flatCollect: [ :possibleEntity |
31-
possibleEntity children select: [ :child | (child isPackage or: [ child isModule ]) and: [ child name = childName ] ] ] ].
27+
| childName |
28+
childName := splittedPath anyOne.
29+
splittedPath removeFirst.
30+
possibleEntities := possibleEntities flatCollect: [ :possibleEntity |
31+
possibleEntity containedEntities select: [ :child | (child isPackage or: [ child isModule ]) and: [ child name = childName ] ] ] ].
3232
possibleEntities ifEmpty: [ SRNoResolutionPossible signal ].
3333

3434
possibleEntities size = 1 ifFalse: [ self error: 'There should be only one possible entity to import.' ].

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,33 +42,26 @@ FamixPythonFromImportResolvable >> resolveInScope: aScope currentEntity: current
4242
"If the path is '.' then we are in the parent of the current entity.
4343
Else we will need to resolve the path."
4444
targetModule := path = '.'
45-
ifTrue: [ (currentEntity query ancestors ofType: FamixTPackage) anyOne ]
45+
ifTrue: [ (currentEntity query containers ofType: FamixTPackage) anyOne ]
4646
ifFalse: [
4747
| remainingPath |
4848
(path beginsWith: '.')
4949
ifTrue: [
5050
| currentPackage |
5151
"In case of a relative path we need to find the origin package for the resolution"
5252
remainingPath := path allButFirst.
53-
currentPackage := (currentEntity query ancestors ofType: FamixTPackage) anyOne. "If we have a module, we need to start with its parent package. If we have a package, it starts in itself."
53+
currentPackage := (currentEntity query containers ofType: FamixTPackage) anyOne. "If we have a module, we need to start with its parent package. If we have a package, it starts in itself."
5454
[ remainingPath beginsWith: '.' ] whileTrue: [
5555
currentPackage := currentPackage parentPackage.
5656
remainingPath := remainingPath allButFirst ].
57-
possibleEntities := currentPackage children ]
57+
possibleEntities := currentPackage containedEntities ]
5858
ifFalse: [ "If we have an absolute path we just start at the root."
5959
remainingPath := path.
60-
possibleEntities := currentEntity rootParents flatCollect: #children ].
61-
62-
"We trim the path because we can have spaces after the dots in relativ paths."
63-
self findTargetEntityFor: remainingPath trim from: possibleEntities ].
64-
65-
66-
"If we have an import all then we import the targeted module directly."
60+
possibleEntities := currentEntity rootContainers flatCollect: #children ]. "We trim the path because we can have spaces after the dots in relativ paths."
61+
self findTargetEntityFor: remainingPath trim from: possibleEntities ]. "If we have an import all then we import the targeted module directly."
6762
possibleEntities := entityName = '*'
6863
ifTrue: [ { targetModule } ]
69-
ifFalse: [ targetModule allChildren select: [ :child | child isNamedEntity and: [ child name = entityName ] ] ].
70-
71-
"It is possible that we have multiple entities with the same name and in that case, python select the last one declared. So we sort by source anchor position to find this one."
64+
ifFalse: [ targetModule allContainedEntities select: [ :child | child isNamedEntity and: [ child name = entityName ] ] ]. "It is possible that we have multiple entities with the same name and in that case, python select the last one declared. So we sort by source anchor position to find this one."
7265
self result: (possibleEntities detectMax: [ :possibleEntity |
7366
possibleEntity sourceAnchor
7467
ifNil: [ 1 "Packages might not have sources." ]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ FamixPythonMethodInvocationResolvable >> identifier: anObject [
3636
FamixPythonMethodInvocationResolvable >> resolveInScope: aScope currentEntity: currentEntity [
3737

3838
| reacheableClasses candidates |
39-
reacheableClasses := aScope entity withAllParents flatCollect: [ :entity | entity reachableEntities select: #isClass ].
39+
reacheableClasses := aScope entity withAllContainers flatCollect: [ :entity | entity reachableEntities select: #isClass ].
4040
candidates := OrderedCollection new.
4141

4242
reacheableClasses do: [ :class |

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ FamixPythonVisitor >> checkShadowingOfName: aString during: aBlock [
3636

3737
| shadowedEntity newEntity |
3838
self withCurrentEntityDo: [ :entity |
39-
((entity query descendants ofType: FamixTShadowable) select: [ :child | child name = aString ]) ifNotEmpty: [ :entities |
39+
((entity query containedEntities ofType: FamixTShadowable) select: [ :child | child name = aString ]) ifNotEmpty: [ :entities |
4040
shadowedEntity := entities detectMax: [ :anEntity | anEntity sourceAnchor startPos ] ] ].
4141

4242
newEntity := aBlock value.
@@ -208,7 +208,7 @@ FamixPythonVisitor >> ensureStubUnknownEntityNamed: aString [
208208
{ #category : 'ensure entity' }
209209
FamixPythonVisitor >> ensureStubUnknownEntityNamed: aString in: anEntity [
210210

211-
^ anEntity children
211+
^ anEntity containedEntities
212212
detect: [ :child | child name = aString ]
213213
ifNone: [
214214
(model newUnknownEntityNamed: aString)
@@ -582,10 +582,8 @@ FamixPythonVisitor >> manageWriteAccessTo: aNode [
582582
"I'm managing the write access to an identifier. I have an alternative for access to an attibute such as `instance.var = 3`. See #manageAttributeWriteAccessTo: for this."
583583

584584
| variable name |
585-
name := aNode sourceText.
586-
587-
"If we have a variable of this name already, we should not recreate it. Except if this variable got shadowed! In that case, we should recreate it."
588-
(self currentEntity query descendants ofType: FamixTStructuralEntity)
585+
name := aNode sourceText. "If we have a variable of this name already, we should not recreate it. Except if this variable got shadowed! In that case, we should recreate it."
586+
(self currentEntity query containedEntities ofType: FamixTStructuralEntity)
589587
detect: [ :child | child name = name and: [ child isShadowable not or: [ child isShadowed not ] ] ]
590588
ifFound: [ :var | variable := var ]
591589
ifNone: [
@@ -1408,7 +1406,7 @@ FamixPythonVisitor >> visitModule: aModuleNode [
14081406

14091407
self currentEntity: entity ].
14101408

1411-
fileReference basename = #'moduleAtRoot111.py' ifTrue: [ 1 halt ].
1409+
fileReference basename = #'moduleAtRoot2ip.py' ifTrue: [ 1 halt ].
14121410

14131411
self visitChildren: aModuleNode.
14141412

src/Famix-Python-Importer/TEntityMetaLevelDependency.extension.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Extension { #name : 'TEntityMetaLevelDependency' }
44
TEntityMetaLevelDependency >> allEffectiveImports [
55
"Return all the imports effective in this entity."
66

7-
^ self withAllParents flatCollect: [ :entity | entity query outgoing local dependenciesOfType: FamixPythonImport ]
7+
^ self withAllContainers flatCollect: [ :entity | entity query outgoing local dependenciesOfType: FamixPythonImport ]
88
]
99

1010
{ #category : '*Famix-Python-Importer' }

0 commit comments

Comments
 (0)