Skip to content

Commit

Permalink
Merge pull request #146 from moosetechnology/import-parameter-statement
Browse files Browse the repository at this point in the history
Keep sourceAnchor in VariableDeclaration from PARAMETER statement
  • Loading branch information
NicolasAnquetil authored Jun 19, 2024
2 parents 9478b59 + 7d68da9 commit 4403570
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/EsopeImporter-Tests/JsonToIASTVisitorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ JsonToIASTVisitorTest >> testParameterStatement [
END
"

| programFile stmt |
| programFile stmt access |
programFile := self visitJsonCode: '{"meta":{"miVersion":"fortran77","miFilename":"/home/anquetil/Pharo/images/fortran-metamodels/srcCode.f"},"program_units":[{"anno":[],"arguments":null,"blocks":[{"anno":[],"label":null,"span":"(2:7)-(2:55)","statement":{"anno":[],"declarators":{"anno":[],"list":[{"anno":[],"initial":{"anno":[],"span":"(2:25)-(2:25)","tag":"value","value":{"contents":["1",null],"tag":"integer"}},"length":null,"span":"(2:18)-(2:25)","type":"scalar","variable":{"anno":[],"span":"(2:18)-(2:23)","tag":"value","value":{"contents":"legere","tag":"variable"}}},{"anno":[],"initial":{"anno":[],"span":"(2:34)-(2:34)","tag":"value","value":{"contents":["2",null],"tag":"integer"}},"length":null,"span":"(2:28)-(2:34)","type":"scalar","variable":{"anno":[],"span":"(2:28)-(2:32)","tag":"value","value":{"contents":"grave","tag":"variable"}}},{"anno":[],"initial":{"anno":[],"span":"(2:44)-(2:44)","tag":"value","value":{"contents":["3",null],"tag":"integer"}},"length":null,"span":"(2:37)-(2:44)","type":"scalar","variable":{"anno":[],"span":"(2:37)-(2:42)","tag":"value","value":{"contents":"fatale","tag":"variable"}}},{"anno":[],"initial":{"anno":[],"span":"(2:54)-(2:54)","tag":"value","value":{"contents":["4",null],"tag":"integer"}},"length":null,"span":"(2:47)-(2:54)","type":"scalar","variable":{"anno":[],"span":"(2:47)-(2:52)","tag":"value","value":{"contents":"finale","tag":"variable"}}}],"span":"(2:18)-(2:54)"},"span":"(2:7)-(2:55)","tag":"parameter"},"tag":"statement"}],"name":"paramstmt","options":[null,null],"span":"(1:7)-(3:9)","subprograms":null,"tag":"subroutine"}]}'.


Expand All @@ -1087,7 +1087,13 @@ JsonToIASTVisitorTest >> testParameterStatement [
self assert: each class equals: IASTVarAccess ].
self
assertCollection: (stmt collect: #entityName)
hasSameElements: #(legere grave fatale finale)
hasSameElements: #(legere grave fatale finale).

access := stmt detect: [ :e | e entityName = 'grave' ].
self assert: access sourceAnchor startLine equals: 2.
self assert: access sourceAnchor startColumn equals: 28.
self assert: access sourceAnchor endLine equals: 2.
self assert: access sourceAnchor endColumn equals: 33
]

{ #category : #'tests-esope' }
Expand Down
2 changes: 2 additions & 0 deletions src/EsopeImporter/JsonToIASTVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ JsonToIASTVisitor >> visitOpenStatement: anOpenStatement [
{ #category : #'visiting statement' }
JsonToIASTVisitor >> visitParameterStatement: aParameterStatementNode [
"span declarators
Variable in PARAMETER statement will come back as IASTVariable-s
We need them to be IASTVarAccess"

Expand All @@ -597,6 +598,7 @@ JsonToIASTVisitor >> visitParameterStatement: aParameterStatementNode [
IASTVarAccess new
isWrite: true ;
entityName: v entityName ;
sourceAnchor: v sourceAnchor ;
yourself
]
]
Expand Down

0 comments on commit 4403570

Please sign in to comment.