Fredrik Ekre
cf56644a62
Add long-form printing of Runic.Node
2 years ago
Fredrik Ekre
6c9a8a8c58
Improve diff output by printing to stderr and use real filename
2 years ago
Fredrik Ekre
80a9753d94
Fix -d,--diff option by using git-diff.
2 years ago
Fredrik Ekre
86e52bb9b3
Add metadata tags to the Node struct.
2 years ago
Fredrik Ekre
5a9f8ad523
Add a pretty-printer for Runic.Node.
2 years ago
Fredrik Ekre
944076139c
Wrap JuliaSyntax.GreenNode in Runic.Node
...
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′′/
2 years ago
Fredrik Ekre
f4e7d13ca9
Runic.main: add some pretty dots.
2 years ago
Fredrik Ekre
97542d1caa
Rename `node_bytes` to `read_bytes`
2 years ago
Fredrik Ekre
c7d804889a
Add .gitignore
2 years ago
Fredrik Ekre
b9fbbca5b8
Add `make_node` utility function
...
This patch adds the `make_node(node, children)` method which creates a
new node with the same head as `node` but with replaced children.
2 years ago
Fredrik Ekre
eaf9a529a3
Insert bytes directly into the stream
...
This patch removes the need for backing up bytes in every function by
simply splicing the bytes into place directly.
2 years ago
Fredrik Ekre
5d57cd93a5
Replace `=` and `\in` with `in` in generators
...
At least we can reuse all the code from for loops pretty easily.
2 years ago
Fredrik Ekre
b9b80002f9
Replace `=` and `\in` with `in` in for loop specifications
...
There is a lot of code for handling this. Partly because we need to
handle both regular loops, and cartesian loops.
2 years ago
Fredrik Ekre
a335e4d3d0
Some more thoughts
2 years ago
Fredrik Ekre
6f8c7c7152
Fix an edgecase in operator chains with newlines hidden inside
...
This also removes the limitation of no newline children in a operator
call chain and fixes a bug with trailing comments inside a chain.
2 years ago
Fredrik Ekre
fac7aa8d64
Fix whitespace in dotted comparison chains
2 years ago
Fredrik Ekre
4d54e37fcd
Fix edgecases in spaces in operator call chains
...
This patch fixes a bug where, in an operator call chain, whitespace was
borrows from the next child, but the call chain continued after.
2 years ago
Fredrik Ekre
a181b65baa
Fix <: and >: without LHS
...
This patch fixes formatting of <: and >: when used without LHS. This is
again an inconsistency compared to other operators.
2 years ago
Fredrik Ekre
a0b7eb2c2c
Add utility function to extract children::Vector in a type stable way.
2 years ago
Fredrik Ekre
b2b3e905ed
Fix spaces around assignment with non-trivia operators.
2 years ago
Fredrik Ekre
4912ba7b1b
main: some pretty printing when formatting files.
2 years ago
Fredrik Ekre
32ba9d345b
main: help message, check mode
2 years ago
Fredrik Ekre
bc011731e1
Run Runic on Runic on CI.
2 years ago
Fredrik Ekre
dfdd7033f7
Fix Runic.main on old Julia versions.
2 years ago
Fredrik Ekre
0d4c3183e1
Format files with Runic :^)
2 years ago
Fredrik Ekre
04a20b7c30
Fix spaces around operators when nesting calls
...
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.
2 years ago
Fredrik Ekre
d7ea5f69a7
Fix float formatting with tight-binding +/-
...
A leading `+`/`-` is part of the float literal if there is no space in
between (in which case it becomes a call). This patch fixes the regexes
to handle this for float parsing.
2 years ago
Fredrik Ekre
7c48019613
Fix whitespace around :: when LHS is missing
...
`::` can be used without a LHS in e.g. function definitions like
`f(::Int) = ...`.
2 years ago
Fredrik Ekre
7b7cfc5dc3
Fix formatting of for-loops with Unicode \in.
2 years ago
Fredrik Ekre
8927fbcc63
Make asserts toggleable.
2 years ago
Fredrik Ekre
d6887109e3
Prune spaces around `:`, `^`, and `::`.
2 years ago
Fredrik Ekre
1bb9480718
Filter out K":" and K"^" from space_around_operators
...
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.
2 years ago
Fredrik Ekre
d076ca8546
Format files with Runic :^)
2 years ago
Fredrik Ekre
00987199c3
Whitespace around <: and >:
2 years ago
Fredrik Ekre
8e13c29a50
Fix spaces around assignment in for-loop specifications
...
`for`-loop nodes are of kind K"=" even when using `in`. This patch fixes
the predicate for `spaces_around_assignments` to include K"in" as an
option. Note that when using `in` spaces are required, but the pass
is still useful to remove spaces when there are more than one.
2 years ago
Fredrik Ekre
a0ba874830
Fix infix_op_call predicat
2 years ago
Fredrik Ekre
0db3c5484a
Fix spaces in comparison chains
2 years ago
Fredrik Ekre
c489dfcaa5
Format spaces around assignment
...
This patch generalizes the `spaces_around_operators` pass to
`spaces_around_x` and uses it for both operators and assignment.
The new `spaces_around_assignments` matches a lot of things:
- regular assignment (`a=b` -> `a = b`, `a+=b` -> `a += b`,
`a=+b` -> `a = + b`)
- dotted assignment (`a.=b` -> `a .= b`, `a.+=b` -> `a .+= b`,
`a.=+b` -> `a .= + b`)
- keywords in function definitions and at callsites
(`f(x=1) = x` -> f(x = 1)`, `g(x=1)` -> `g(x = 1)`).
- named tuples (`(x=1, y=2)` -> `(x = 1, y = 2)`)
- etc...
2 years ago
Fredrik Ekre
40ccafd579
Format spaces around operators
...
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.
2 years ago
Fredrik Ekre
f6e55f62e8
Format floating point literals.
2 years ago
Fredrik Ekre
df9c263ec8
Extract rewriters into separate functions.
2 years ago
Fredrik Ekre
e8138837a6
Help the compiler by asserting the children type.
2 years ago
Fredrik Ekre
0d326642f0
Use `nothing` as sentinel value if the node didn't change.
2 years ago
Fredrik Ekre
98a8ea4a53
Use concrete type of GreenNode in Context struct.
2 years ago
Fredrik Ekre
6bdf466e6b
Add SPDX license identifiers to files.
2 years ago
Fredrik Ekre
01a703f861
Keep track of previous/next sibling
...
Sometimes there is a need to check the kind (possibly more) of previous
and next siblings in order to decide on formatting. This patch keeps
track of this in the Context.
This is used for replacing trailing whitespace from consecutive
NewlineWs nodes since sometimes the whitespace is after the LF.
2 years ago
Fredrik Ekre
e12233cd4e
Tests for newline stripping
2 years ago
Fredrik Ekre
c1d7da9e9c
Add compat for const struct fields.
2 years ago
Fredrik Ekre
673a43f963
Add test/runtests.jl
2 years ago
Fredrik Ekre
3d752d9e59
CI YAML files.
2 years ago