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

Formatter: Retain information on Bracket Expressions #156

Open
kindlich opened this issue Jun 9, 2024 · 0 comments
Open

Formatter: Retain information on Bracket Expressions #156

kindlich opened this issue Jun 9, 2024 · 0 comments
Labels
enhancement New feature or request formatter Issues that concern the code-formatter parser
Milestone

Comments

@kindlich
Copy link
Member

kindlich commented Jun 9, 2024

Currently, Bracket Expression Parsers can return any ParsedExpression and the information about the bracket expression is lost during the parsing.

Therefore, when using the code-formatter, the Bracket Expressions are replaced by their Parsed-Expression equivalent, which is not optimal for formatting scripts.

Example:

println(<item:minecraft:bedrock>.commandString);

// becomes after a re-format
println(BracketHandlers.getItem("minecraft:bedrock").commandString);

Possible Fixes/Ideas:

  • Optionally attach a custom Tag to Parsed expressions which will be used in the code-formatter if present.
    return expression.hasTag(FormattingInfo.class) ? expression.getTag(FormattingInfo.class).format() : expression.accept(formatterVisitor);
@kindlich kindlich added enhancement New feature or request formatter Issues that concern the code-formatter parser labels Jun 9, 2024
@kindlich kindlich added this to the v1.0.0 milestone Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request formatter Issues that concern the code-formatter parser
Projects
None yet
Development

No branches or pull requests

1 participant