Fix an issue in TreeCursor.iterate
that made it iterate through siblings of the current node.
Fix a bug in TreeCursor.matchContext
where, if the context fell partially in a buffer node and partially in tree nodes, it could return incorrect results.
Fix a bug where getChild
and getChildren
would, if the first and second arguments matched the same node, return incorrect results.
The new NodeProp.isolate
can be used by parser to signal that a given node should be treated as isolated when it comes to bidirectional text rendering.
Fix a crash that could happen in mixed-language parsing when mounting a tree to a zero-length node.
Fix a bug where resolveStack
could sometimes yield the same node multiple times.
Allow mixed-parsing trees to be mounted for zero-length nodes.
Fix a bug in mixed-language parsing that could some parts of an inner language to be missed when incrementally reparsing from a stopped parse.
In Tree.build
, when given an extremely deeply nested tree structure, flatten it instead of overflowing the stack.
The new Tree.resolveStack
method returns an iterator through the nodes covering a position, including those from overlays not active at that point.
Make the package usable in TypeScript with node16/nodenext resolution.
Tree.iterate
now properly includes anonymous nodes when IterMode.IncludeAnonymous
is enabled.
Fix a bug in mixed parsing that would sometimes produce invalid trees.
Fix a bug that could cause incremental parsing to incorrectly reuse nodes inside nested mixed parses.
First stable version.
Declare matchContext
as a property of SyntaxNodeRef
.
The mixed parsing interface now passes SyntaxNodeRef
values instead of TreeCursor
instances around.
Creating a cursor at a given position is now done with Tree.cursorAt
, not cursor
.
Getting a cursor from a syntax node is now done with a method (cursor
) rather than a getter.
Tree.fullCursor
was removed and replaced by the IncludeAnonymous
iteration mode.
The optional arguments to enter
tree traversal methods were replaced with a single mode
argument.
Tree.iterate
now passes node objects, rather than type/from/to as separate arguments, to its callback functions.
The new SyntaxNodeRef
type provides an interface shared by SyntaxNode
and TreeCursor
.
TreeCursor
instances now how have an iterate
method that calls a function for each descendant of the current node.
The new matchContext
method on SyntaxNode
and TreeCursor
provides a convenient way to match the names of direct parent nodes.
Cursors can now be passed flags to control their behavior.
Work around a TypeScript issue that caused it to infer return type any
for resolve
and resolveInner
.
Fix a bug in incremental mixed-language parsing where it could incorrectly add a parse range twice, causing a crash in the inner parser.
Fix a bug where nested parsing would sometimes corrupt the length of parent nodes around the nesting point.
SyntaxNode
now has a resolveInner
method (analogous to Tree.resolveInner
).
Full tree cursors no longer automatically enter mounted subtrees.
Fix a bug where a nested parser would not re-parse inner sections when given fragments produced by a parse that finished the outer tree but was stopped before the inner trees were done.
Fix a bug that could cause incorrectly structured nodes to be created for repeat rules, breaking incremental parsing using the resulting tree.
Fix an issue in parseMixed
where parses nested two or more levels deep would use the wrong document offsets.
Fix a null-dereference crash in mixed-language parsing.
Syntax node objects now have a method enterUnfinishedNodesBefore
to scan down the tree for nodes that were broken off directly in front of a given position (which can provide a more accurate context that just resolving the position).
parseMixed
will now scan children not covered by the ranges of an eagerly computed overlay for further nesting.
Fix an issue where parseMixed
could create overlay mounts with zero ranges, which were useless and confused CodeMirror's highlighter.
Fix a bug that would cause enter
to return incorrect results when called entering children in a buffer with .
Fix a bug where parseMixed
could crash by dereferencing null.
The module name has changed from lezer-tree
to @lezer/common
.
TreeBuffer
s no longer accept a node type.
Tree.balance
no longer takes a buffer size as argument.
NodeProp.string
, NodeProp.number
, and NodeProp.flag
have been removed (the thing they provided is trivial to write by hand).
A node's context hash is now stored in the NodeProp.contextHash
prop.
Reused nodes passed to Tree.build
must now be Tree
instances (not tree buffers).
Parser
is now an abstract class that all parser implementations must extend, implementing the createParse
method.
The PartialParse
interface changed to make multi-pass parsers possible.
Parser.startParse
now takes different arguments (input, fragments, ranges)
instead of (input, startPos, context)
.
The Input
interface has changed (to become chunk-based and more low-level). A single Input
object is now shared between outer and inner parses.
stringInput
is no longer exported (Parser
methods will automatically wrap strings when appropriate).
Fix a bug in TreeFragment.applyChanges
that prevented some valid reuse of syntax nodes.
Fix a bug where reused nodes could incorrectly be dropped by Tree.build
.
Node props can now be per-node, in which case they are stored on Tree
instances rather than NodeType
s.
Tree nodes can now be replaced with other trees through NodeProp.mountedTree
.
Tree.resolveInner
can now be used to resolve into overlay trees.
SyntaxNode
objects now have a toTree
method to convert them to a stand-alone tree.
Tree.balance
now accepts a helper function to create the inner nodes.
Tree cursors' next
/prev
methods now take an enter
argument to control whether they enter the current node.
SyntaxNode
and TreeCursor
now have an enter
method to directly enter the child at the given position (if any).
Tree.iterate
callbacks now get an extra argument that allows them to create a SyntaxNode
for the current node.
The parsing interface now supports parsing specific, non-contiguous ranges of the input in a single parse.
The module now exports a parseMixed
helper function for creating mixed-language parsers.
Add support for context tracking.
Fix a bug where building a tree from a buffer would go wrong for repeat nodes whose children were all repeat nodes of the same type.
NodeType.isRepeated
is now called isAnonymous
, which more accurately describes what it means.
NodeGroup
has been renamed to NodeSet
to avoid confusion with NodeProp.group
.
The applyChanges
method on trees is no longer supported (TreeFragment
is now used to track reusable content).
Trees no longer have cut
and append
methods.
It is now possible to pass a node ID to SyntaxNode.getChild
/getChildren
and NodeType.is
. Allow specifying a tree length in Tree.build
Tree.build
now allows you to specify the length of the resulting tree.
Tree.fullCursor()
can now be used to get a cursor that includes anonymous nodes, rather than skipping them.
Introduces NodeType.define
to define node types.
The new TreeFragment
type is used to manage reusable subtrees for incremental parsing.
Tree.build
now accepts a start
option indicating the start offset of the tree.
The Input
type, which used to be InputStream
in the lezer package, is now exported from this package.
This package now exports a PartialParse
interface, which describes the interface used, for example, as return type from Parser.startParse
.
Make NodePropSource
a function type.
Fix a bug that made SyntaxNode.prevSibling
fail in most cases when the node is part of a buffer.
Fix issue where using Tree.append
with an empty tree as argument would return a tree with a nonsensical length
property.
Tree.iterate
no longer allows returning from inside the iteration (use cursors directly for that kind of use cases).
Subtree
has been renamed to SyntaxNode
and narrowed in scope a little.
The top
, skipped
, and error
node props no longer exist.
The package now offers a TreeCursor
abstraction, which can be used for both regular iteration and for custom traversal of a tree.
SyntaxNode
instances have nextSibling
/prevSibling
getters that allow more direct navigation through the tree.
Node types now expose isTop
, isSkipped
, isError
, and isRepeated
properties that indicate special status.
Adds NodeProp.group
to assign group names to node types.
Syntax nodes now have helper functions getChild
and getChildren
to retrieve direct child nodes by type or group.
NodeType.match
(and thus NodeProp.add
) now allows types to be targeted by group name.
Node types have a new is
method for checking whether their name or one of their groups matches a given string.
Fix lezer dependency versions
Adjust to new output format of repeat rules.
No longer list internal properties in the type definitions.
Drop NodeProp.delim
in favor of NodeProp.openedBy
/closedBy
.
Make the package load as an ES module on node
The package now provides an ES6 module.
Fix a bug that caused applyChanges
to include parts of the old tree that weren't safe to reuse.
Fix bug that would cause tree balancing of deep trees to produce corrupt output.
Bump version along with the rest of the lezer packages.
In applyChanges
, make sure the tree is collapsed all the way to the
nearest non-error node next to the change.
Fix a bug that prevented balancing of repeat nodes when there were skipped nodes present between the repeated elements (which ruined the efficiency of incremental parses).
TreeBuffer
objects now have an iterate
function.
Buffers can optionally be tagged with an (unnamed) node type to allow reusing them in an incremental parse without wrapping them in a tree.
Tree.build
now takes its arguments wrapped in an object. It also expects the buffer content to conform to from lezer 0.7.0's representation of repeated productions.
The repeated
node prop was removed (the parser generator now encodes repetition in the type ids).
NodeProp.add
now also allows a selector object to be passed.
Adds NodeProp.top
, which flags a grammar's outer node type.
Drops the NodeProp.lang
prop (superseded by top
).
Export BufferCursor
again, which was accidentally removed from the exports in 0.3.0.
The iterate
method now takes an object instead of separate parameters.
Introduces node props.
Node types are now objects holding a name, id, and set of props.
Tags are gone again, nodes have plain string names.
Fix incorrect node length calculation in Tree.build
.
Tree nodes are now identified with tags.
New Tag
data structure to represent node tags.
Drop support for grammar ids and node types.
Actually include the .d.ts file in the published package.
First documented release.