mirror of
https://github.com/RGBCube/cstree
synced 2025-07-29 01:57:44 +00:00
* Implement traits for Arc<MultiThreadedTokenInterner> * implement Resolver for Arc<Resolver>, update docs
4.7 KiB
4.7 KiB
Changelog
Unreleased
&I
and&mut I
will now implementResolver
ifI
implementsResolver
.&mut I
will now implementInterner
ifI
implementsInterner
.- Added an implementation for
Arc<MultiThreadedTokenInterner>
to implementResolver
andInterner
so anArc
may be used alternatively to a reference to share access to the interner.
v0.12.2
Checkpoint
s for theGreenNodeBuilder
can now be used across node boundaries, meaning you can use them to wrap (finished) nodes in addition to just tokens.- A new method
Checkpoint::revert_to
has been added which resets aGreenNodeBuilder
to the state it was in when the checkpoint was taken, allowing a parser to backtrack to the checkpoint.
v0.12.1
- Implement
Hash
andEq
forResolvedNode
andResolvedToken
v0.12.0
- Documentation has been improved in most areas, together with a switch to a more principled module structure that allows explicitly documenting submodules.
- The
Language
trait has been deprecated in favour of a newSyntax
trait.Syntax
provides the same methods thatLanguage
did before, but is implemented directly on the syntax kind enum instead of an additional type representing the language.- The supertrait requirements on
PartialOrd
,Ord
, andHash
have been dropped.
- The supertrait requirements on
- This allows us to optionally provide a derive macro for
Syntax
. To enable the macro, add thederive
feature flag in yourCargo.toml
and#[derive(Syntax)]
away! - The
interning
module has been rewritten. It now provides fuctions for obtaining a default interner (new_interner
andnew_threaded_interner
) and provides a small, dependency-free interner implementation.- Compatibility with other interners can be enable via feature flags.
- Note that compatibilty with
lasso
is not enabled by default. Use thelasso_compat
feature to match the previous default.- If you are using
lasso
interners directly that you are also passing tocstree
, note that while e.g. theGreenNodeBuilder
can work withlasso::Rodeo
s, you will not be able to convert betweenlasso
'sSpur
andcstree
'sTokenKey
. TheTokenKey
can, however, be used as the key type forlasso
interners at no additional cost by working wiht aRodeo<TokenKey>
instead of thelasso
-defaultRodeo<Spur>
.
- If you are using
- Introduced
Syntax::static_text
to optimize tokens that always appear with the same text (estimated 10-15% faster tree building when used, depending on the ratio of static to dynamic tokens).- Since
cstree
s are lossless,GreenNodeBuilder::token
must still be passed the source text even for static tokens.
- Since
- Internal performance improvements for up to 10% faster tree building by avoiding unnecessary duplication of elements.
- Use
NonNull
for the internal representation ofSyntaxNode
, meaning it now benefits from niche optimizations (Option<SyntaxNode>
is now the same size asSyntaxNode
itself: the size of a pointer). SyntaxKind
has been renamed toRawSyntaxKind
to no longer conflict with user-definedSyntaxKind
enumerations.RawSyntaxKind
has been changed to use a 32-bit index internally, which means existingLanguage
implementations and syntax kindenum
s need to be adjusted to#[repr(u32)]
and the corresponding conversions.
- The crate's export module structure has been reorganized to give different groups of definitions their own submodules. A
cstree::prelude
module is available, containing the most commonly needed types that were previously accessible viause cstree::*
. Otherwise, the module structure is now as follows:cstree
Syntax
RawSyntaxKind
build
GreenNodeBuilder
NodeCache
Checkpoint
green
GreenNode
GreenToken
GreenNodeChildren
syntax
{Syntax,Resolved}Node
{Syntax,Resolved}Token
{Syntax,Resolved}Element
{Syntax,Resolved}ElementRef
SyntaxNodeChildren
SyntaxElementChildren
SyntaxText
interning
TokenKey
and theInternKey
traitInterner
andResolver
traitsnew_interner
andTokenInterner
new_threaded_interner
andMultiThreadedTokenInterner
(with themulti_threaded_interning
feature enabled)- compatibility implementations for interning crates depending on selected feature flags
text
TextSize
TextRange
SyntaxText
(re-export)
traversal
Direction
WalkEvent
util
NodeOrToken
TokenAtOffset
sync
Arc
prelude
- re-exports of the most-used items