-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Big refactoring to start to manage namespace resolution
- Loading branch information
Showing
8 changed files
with
242 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/Famix-Python-Importer/FamixPythonAbstractInvocationOrInstantiationResolvable.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
Class { | ||
#name : 'FamixPythonAbstractInvocationOrInstantiationResolvable', | ||
#superclass : 'SRResolvable', | ||
#instVars : [ | ||
'identifier', | ||
'entity' | ||
], | ||
#category : 'Famix-Python-Importer-SymbolResolution', | ||
#package : 'Famix-Python-Importer', | ||
#tag : 'SymbolResolution' | ||
} | ||
|
||
{ #category : 'accessing' } | ||
FamixPythonAbstractInvocationOrInstantiationResolvable class >> identifier: anIdentifierString [ | ||
|
||
^ self new | ||
identifier: anIdentifierString; | ||
yourself | ||
] | ||
|
||
{ #category : 'hooks' } | ||
FamixPythonAbstractInvocationOrInstantiationResolvable >> applyReplacementStrategyWithCurrentEntity: aCurrentEntity [ | ||
|
||
self entity: (self notFoundReplacementEntity cull: self cull: aCurrentEntity) | ||
] | ||
|
||
{ #category : 'accessing' } | ||
FamixPythonAbstractInvocationOrInstantiationResolvable >> entity [ | ||
|
||
^ entity | ||
] | ||
|
||
{ #category : 'accessing' } | ||
FamixPythonAbstractInvocationOrInstantiationResolvable >> entity: anObject [ | ||
|
||
entity := anObject | ||
] | ||
|
||
{ #category : 'accessing' } | ||
FamixPythonAbstractInvocationOrInstantiationResolvable >> identifier [ | ||
|
||
^ identifier | ||
] | ||
|
||
{ #category : 'accessing' } | ||
FamixPythonAbstractInvocationOrInstantiationResolvable >> identifier: anObject [ | ||
|
||
identifier := anObject | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...amix-Python-Importer/FamixPythonInvocationOrInstantiationWithNamespaceResolvable.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Class { | ||
#name : 'FamixPythonInvocationOrInstantiationWithNamespaceResolvable', | ||
#superclass : 'FamixPythonAbstractInvocationOrInstantiationResolvable', | ||
#instVars : [ | ||
'import' | ||
], | ||
#category : 'Famix-Python-Importer-SymbolResolution', | ||
#package : 'Famix-Python-Importer', | ||
#tag : 'SymbolResolution' | ||
} | ||
|
||
{ #category : 'instance creation' } | ||
FamixPythonInvocationOrInstantiationWithNamespaceResolvable class >> identifier: aString import: anImport [ | ||
|
||
^ (self identifier: aString) | ||
import: anImport; | ||
yourself | ||
] | ||
|
||
{ #category : 'accessing' } | ||
FamixPythonInvocationOrInstantiationWithNamespaceResolvable >> import: anObject [ | ||
import := anObject | ||
] | ||
|
||
{ #category : 'resolution' } | ||
FamixPythonInvocationOrInstantiationWithNamespaceResolvable >> resolveInScope: aScope currentEntity: currentEntity [ | ||
|
||
import importedEntity name = identifier ifTrue: [ ^ self entity: import importedEntity ]. | ||
|
||
^ (import importedEntity definedEntitiesNamed: identifier ofKinds: self expectedKinds) ifEmpty: [ SRNoResolutionPossible signal ] ifNotEmpty: [ :entities | | ||
| matchingEntities | | ||
self flag: #todo. "This could probably be simplified? Or at least remove duplication with sibling classes.." | ||
matchingEntities := entities sorted: [ :anEntity | anEntity sourceAnchor startPos ] ascending. | ||
(matchingEntities collectAsSet: #class) size = 1 | ||
ifTrue: [ "This is an instantiation" | ||
matchingEntities last isClass ifTrue: [ ^ self entity: matchingEntities last ]. | ||
|
||
self entity: matchingEntities ] | ||
ifFalse: [ | ||
self entity: (matchingEntities last isClass | ||
ifTrue: [ matchingEntities last ] | ||
ifFalse: [ { matchingEntities last } ]) ] ] | ||
] |
6 changes: 6 additions & 0 deletions
6
src/Famix-Python-Importer/PyFieldAccessExpressionNode.extension.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/Famix-Python-Importer/PyFunctionCallExpressionNode.extension.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters