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

Debug mode #74

Closed
zimbatm opened this issue Jul 10, 2019 · 3 comments
Closed

Debug mode #74

zimbatm opened this issue Jul 10, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@zimbatm
Copy link
Member

zimbatm commented Jul 10, 2019

It would be cool if the engine could should all the matching rules with the diff. The more rule we add, the harder it becomes to understand how they interact with each-other.

Example output:

<rule name> matched <element>
<diff>

What do you think @matklad ?

@matklad
Copy link
Contributor

matklad commented Jul 12, 2019

Yeah, I also find it quite hard to debug interactions between the rules. Though, I am not sure if just somehow showing matching rules would help: it seems like it would produce way to much information to be useful.

At the moment, I just comment out some rules to minimize the example. I imagine that could be automated: formatting could print a series of diffs, starting with "zero rules applied", and ending with "all rules applied". Still not sure if that would be more effective than just manually commenting out specifc things

@zimbatm
Copy link
Member Author

zimbatm commented Jul 13, 2019

The difference would mainly be that as a user it would be possible to understand what is going on without toughing the code (assuming that the output is helpful). I think rules would also have to have names attached to them so they could be distinguished one from another.

Brainstorming a bit more, another approach might be to attach some assertions onto a node, asserting that rule X is going to be applied to it.

bors bot added a commit that referenced this issue Jul 17, 2019
79: implement new version of indentation DLS r=matklad a=matklad

I've looked how Kotlin handles this and I liked the approach:

https://github.com/JetBrains/kotlin/blob/7d173ed3856e429739b55d8c3892e1b85ca41571/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt#L682-L690

The main trick they use is negative rules: "indent all children except
X". They nicely handle comments and in general simplify things a bit.

I've also added names to rules to as a step towards future debug mode,
as well as an ability to specify simple tests in-line, which should
help with long-term rule maintainability.

closes #71, #65 

prerequisite of #74

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
@zimbatm zimbatm added the enhancement New feature or request label Jul 30, 2019
@matklad
Copy link
Contributor

matklad commented Sep 6, 2019

This is implemented as --explain flag in #79!

@matklad matklad closed this as completed Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants