Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert getLeadingTrivia to a getter #1232

Closed
TwitchBronBron opened this issue Jun 14, 2024 · 0 comments
Closed

Convert getLeadingTrivia to a getter #1232

TwitchBronBron opened this issue Jun 14, 2024 · 0 comments
Assignees
Milestone

Comments

@TwitchBronBron
Copy link
Member

Now that #1225 landed, I think we should convert .getLeadingTrivia() into a getter. This way it is easier for plugins to manipulate the AST without needing to call a function to get the results, and makes it more clear that it's an attribute of a node rather than a return value.

Tasks:

  • convert all .getLeadingTrivia() methods into get leadingTrivia()
  • add unit tests to prove we can manipulate the leading trivia and it transpiles properly. something like:
const file = program.setFile<BrsFile>('source/main.brs', `
    function test()
    end function
`);
file.parser.ast.walk(()=>{
    FunctionStatement: (stmt) => {
        editor.arrayPush(stmt.leadingTrivia, createCommentToken(''Hello world");
    }
});
testTranspile(.....)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants