rokucommunity / brighterscript

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

How do plugins add/remove comments in v1? #1206

Closed TwitchBronBron closed 3 weeks ago

TwitchBronBron commented 1 month ago

Some of the getLeadingTrivia() and getTrailingTrivia() calls return a new array of trivia, which means plugins don't have an easy way to manipulate that list without digging around in the leadingTrivia of each statement (or child expression). For example, a plugin that wants to prepend a comment to the start of every function, or delete all leading comments for a given statement.

How should we handle something like this with the plugin system and the new v1 comments-as-trivia model?

markwpearce commented 1 month ago

Could we just have a method on all nodes… something like:

setLeadingTrivia(trivia: Array<CommentToken | WhitespaceToken l NewLineToken>)