This patch introduces line continuation based indent for triple strings,
which typically span multiple lines without any explicit newlines in the
syntax tree (since they are hidden inside the string).
This result in the following changes, some of which are clearly
bugfixes:
Operator chains:
```diff
"""
abc
""" * """
-def
-"""
+ def
+ """
```
Operator chain as assignment right hand side:
```diff
x = """
-abc
-""" * """
-def
-"""
+ abc
+ """ * """
+ def
+ """
```
Implicit tuples:
```diff
"""
abc
""",
"""
-def
-"""
+ def
+ """
```
Note that single triple strings as a right hand side is excluded from
the indent rule, similar to having `if/try/let/...` blocks as a right
hand side.
- Listlike expressions (e.g. tuples, calls, paren-blocks, vectors) that
span multiple lines now always require a leading and a trailing
newline (and thus a trailing comma from previous listlike spacing
code). For example
```diff
-f(a,
- b)
+f(
+ a,
+ b,
+)
```
- Listlike expressions are now hard indents instead of the
soft/continuation style from before. This looks better.
- Vectors (K"vect" and K"ref") are now spaced like lists.
- Fix some bugs in spaces-around-operators when there where hidden
newlines at the beginning of the call chain.
Closes#9.
This is a huge patch and adds formatting of indentation. It is slightly
difficult to come up with a good set of rules but I think what is here
is pretty nice. There are two types of indentation: block/hard
indentation and continuation/soft indentation.
Block indentation are context independent and are thus "hard" or
required in the sense that they always happen. Block indentation are
enabled for all `x - end` blocks where `x` is one of `begin`, `do`,
`for`, `function`, `if`, `let`, `quote`, `struct`, `try`, `while`. A
notable exception is `module`, but one idea is to indent nested modules
(in the same file).
Continuation or soft indents are context dependent in the sense that if
nested within another soft indent they extra indents are skipped. Soft
indentation applies to all expressions spanning multiple lines.
For example, newlines in operator chains:
```julia
a + b * c +
d # soft indent
```
function calls
```julia
foo(
a, b c, d # soft indent
)
```
etc.
Using JuliaSyntax.GreenNode directly have worked for a long time, but at
this point it seems that it is easier to re-package the tree in a custom
type. This will be used to attach metadata to nodes, for example.
Also include the following renames:
- s/verified_children/verified_kids/
- s/children/kids/
- s/children′/kids′/
- s/children′′/kids′′/
- s/child/kid/
- s/child′/kid′/
- s/child′′/kid′′/
The next leaf node might not be a direct grand child when nesting
operators. This patches introduces a function `replace_first_leaf` that
replaces the correct leaf.
It is a bit weird to not be consistent and put spaces around all
operators, but most people would agree that using no spaces for `:` and
`^` look better.
This adds a pass which adds a single space between operators, for
example `a+b` -> `a + b` and `a==b` -> `a == b`. Note that comparison
chains are still left untouched (`a == b == c`) and is a todo.