Skip to content

Commit

Permalink
Fix source anchor of modules
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Oct 8, 2024
1 parent 53a34cb commit 9d9aaea
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
37 changes: 37 additions & 0 deletions src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,43 @@ FamixPythonProject1Test >> testSimpleMethod [
self assert: method parentType equals: (self classNamed: 'Person')
]

{ #category : 'tests - modules' }
FamixPythonProject1Test >> testSourceAnchorModule [

| module |
self denyEmpty: self model allModules.

module := self moduleNamed: 'moduleToTestSourceAnchor'.

self assert: module sourceAnchor isNotNil.
self assert: module sourceText equals:('# DO NOT UPDATE THIS MODULE CONTENT THIS IS TO TEST SOURCE ANCHOR
def fibonacci(n):
# Check if input is 0 then it will
# print incorrect input
if n < 0:
print("Incorrect input")
# Check if n is 0
# then it will return 0
elif n == 0:
return 0
# Check if n is 1,2
# it will return 1
elif n == 1 or n == 2:
return 1
else:
return fibonacci(n - 1) + fibonacci(n - 2)
# Driver Program
print(fibonacci(9))
' copyReplaceAll: String cr with: String lf)
]

{ #category : 'tests - packages' }
FamixPythonProject1Test >> testSubPackage [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,14 @@ FamixPythonImporterVisitor >> createModule: aModuleNode named: aName [
module := model newModule.
module name: aName.

^ self setSourceAnchor: module from: aModuleNode
self setSourceAnchor: module from: aModuleNode.

"The FileNode exclude things such as the comments at the beginning of files so we just put again manually the whole file"
module sourceAnchor
startPos: 1;
endPos: aModuleNode fileReference size.

^ module
]

{ #category : 'private-entity-creation' }
Expand Down

0 comments on commit 9d9aaea

Please sign in to comment.