Repository navigation
Token dependent indention - #106
lorenzwalthert wants to merge 27 commits into
Conversation
Codecov Report
@@ Coverage Diff @@
## master #106 +/- ##
=========================================
Coverage ? 87.93%
=========================================
Files ? 18
Lines ? 721
Branches ? 0
=========================================
Hits ? 634
Misses ? 87
Partials ? 0
Continue to review full report at Codecov.
|
15225be to
7cb0f54
Compare
Uses a specialised visitor-like approach.
update the newline attribute according to lag_newlines after line breaks are definitively set.
Now, it is possible to style spacing without touching indention
switch from token trigger '(' to 'FUNCTION' and 'SYMBOL_FUNCTION_CALL' to avoid re-indention with arithmetic braces, if conditions and the like.
|
I think this is quite a bit to review. Maybe we should even split it up. I believe that the code is not too bad, apart from everything in R/indent-token-dependent. I think I still have not found a good way of indenting token-dependent. It's all based on indices and maybe there are simpler ways to solve it. call(1,
3)And then add a rule that turns that into call(
1,
3)Or even call(
1,
3
) |
b1018e1 to
e6244f5
Compare
|
If you can split it into smaller pieces, please do by all means -- these will be much easier to review. |
|
Ok, will do so. Will require some time though. |
|
This PR was split up in the above referenced pull requests and can hence be closed. |
This PR consists of two parts:
Step 1: Allow for token-dependent indention
This implements #94 (and hence #66) rudimentary. By flattening out the nested parse table completely and computing the absolute position a token will take when serialised, we can use a look-up approach to set the indention of any token dependent on the indention of another token. There is room for improvement since
set_token_dependent_indention()is really just work in progress and can be improved.Step 2: Allow for styling without touching indention
Since step 1 implies to merge the spacing and indention information in
enrich_terminals()into the columnspaces, we are also able to discard the indention computed and use what we called raw indention, that is, take the indention from the input and don't modify it. The only thing for it to work is to not overwrite the spacing information if there is a line break after a token, which is checked vianewlines. Since we modifylag_newlinesbefore (in R/rules-line_breaks.R) and notnewlines, this attribute needs to be updated after line breaks are set (closes #104). Hence, step 2 closes #105 and lays the foundations for #85.