rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
153 stars 47 forks source link

No way to walk AstNodes and get comments at end of block #1181

Closed markwpearce closed 2 months ago

markwpearce commented 2 months ago

Consider:

sub myFunc()
    ' There is a comment here
end sub

There is no way to to do an AST walk and get access to the final comment. Technically, the comment is leadingTrivia on the end sub token.

We may need to add a getEndTrivia() method on AstNode... for most nodes, it would empty, except for "block" type statements/expressions that have an end where it would get the leading trivia of the end token