Skip to content

Commit

Permalink
Merge pull request #9066 from guillep/fix/9063
Browse files Browse the repository at this point in the history
Parse comments at the end of methods without statements
  • Loading branch information
MarcusDenker committed Apr 15, 2021
2 parents 230b47c + b74a678 commit b6c58cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/AST-Core-Tests/RBMethodNodeTest.class.st
Expand Up @@ -188,6 +188,18 @@ RBMethodNodeTest >> testMethodClass [
self assert: ast methodClass equals: nil
]

{ #category : #'testing-comments' }
RBMethodNodeTest >> testMethodWithCommentsAndEmptyStatements [

| tree |
tree := self parseMethod: 'foo: abd bar: cde
"this is comment".
"this is another comment"'.

self assert: tree comments first contents equals: 'this is comment'.
self assert: tree body comments first contents equals: 'this is another comment'
]

{ #category : #tests }
RBMethodNodeTest >> testMethodsHasTemporaries [

Expand Down
4 changes: 3 additions & 1 deletion src/AST-Core/RBParser.class.st
Expand Up @@ -1114,7 +1114,9 @@ RBParser >> parseStatementList: pragmaBoolean into: sequenceNode untilAnyCloserO
periodList: periods
withAcceptedStatementClosers: aCollectionOfClosers ].

statements notEmpty ifTrue: [ self addCommentsTo: statements last ].
statements
ifEmpty: [ self addCommentsTo: sequenceNode ]
ifNotEmpty: [ self addCommentsTo: statements last ].
sequenceNode
statements: statements;
periods: periods.
Expand Down

0 comments on commit b6c58cf

Please sign in to comment.