This substantially decreases the number of edges in our graphs,
especially when few nodes have changed. Diffing slow_before.rs with
slow_after.rs now takes half the time on my machine.
This makes diffing slightly greedier, so there may exist cases where
diffs are slightly worse. Comparing AXAB with AB is arguably nicer
as (+AX)AB rather than A(+XA)B. However, all the tests still pass,
and it's a huge perf win.
Closes#47
Positions almost always span a single line, as they just track
tokens. The only exception is multiline strings or comments.
Trying to match up all the lines between two tokens is far more
complex and doesn't provide much benefit. It was already the case that
we used the first line in the position in several code paths anyway.
This is important when executing tree-sitter queries, as highlighting
queries tend to target leaf nodes. Flattening the tree loses that.
This may also lead to more accurate diffing logic in some examples,
but I haven't found any obvious cases.
j counts from 0, so add the start value. Also ensure it is never equal
to i, or we get confused by delimiters where the open and close tokens
are the same (such as `|foo|` in Rust).
At least this parser uses C++11 (lambda expressions) and C++14 features
(lambda `auto` parameter types). Since the default C++ standard of
compilers can vary, this patch explicitly sets C++14 mode when building
any vendored C++ files.
Previously, we only handled simple cases like `(x)` where the first
and last token were the delimiter tokens. We now allow arbitrary
tokens before and after the delimiter, and wrap them in an additional
list.
This was more common in the C family parsers, but it's a general
problem. It also helps with robustness of JSX/TSX delimiter parsing of
`<`, where we now require a close `>` at the same level.
* Fixes precedence between is and as
'is' has higher precedence than 'as'. To get the test case to parse I also had to restrict the types of expressions that can be 'constant_pattern'.
* is and as has same precedence
Better understanding of is and as precedence. They have same precedence, but are left associative. The also have the same precedence as relative operators and not the same as equallity operators.
* Added more expressions to constant_pattern
nameof and some casts are allowed in constant expressions.
* Changed nullable_type to not be able to contain it self
This was to avoid precedence problems when parsing things like "int? ?".