This repository was archived by the owner on Oct 18, 2024. It is now read-only.
v4.0.0
android-tree-sitter v4.0.0
This is a major release of Android Tree Sitter which includes the following changes :
- Maven group ID for ATS has been changed from
com.itsaky.androidide
tocom.itsaky.androidide.treesitter
. - New
TSObjectFactory
andTSObjectFactoryProvider
APIs to allow usage of customTS*
objects.- This change makes constructors of all TS objects
protected so that they can only be accessed within the same package and in
subclasses. Every TS object now provides
a staticcreate
method to create instances of the same. Users are expected
to use those methods to create instances of the corresponding classes instead of using the factory directly. - You can configure a custom
TSObjectFactory
which would create customTS*
objects. This can be used to implement recyclable objects.
- This change makes constructors of all TS objects
public
fields inTS*
classes are nowprotected
and provide getters/
setters for better encapsulation.- Native methods now also check the validity of the native object before they are accessed. If the native object pointer provided to a native method is invalid (null pointer), an
IllegalArgumentException
is thrown. TSQueryCursor
:TSQueryCursor
now checks whether a query has been executed whennextMatch
andremoveMatch
are called. If not, it throws anIllegalStateException
.- When executing a query, related
TS*
objects are now checked for access (e.g. cursor, query, node, etc). - The query cursor now does not allow executing queries on changed nodes i.e nodes for which
TSNode.hasChanges()
returnstrue
. This behavior can be changed withTSQueryCursor.setAllowChangedNodes(boolean)
. - Query cursors are now
Iterable<TSQueryMatch>
.
TSNode
:- New APIs :
edit(TSInputEdit)
getNextParseState()
getDescendantCount()
getGrammarType()
getLanguage()
- New APIs :
TSParser
:TSParser
parse operation is now cancellable. You can request cancellation for the previousTSParser.parse(...)
call with :requestCancellationAsync
: Request cancellation asynchronously.requestCancellationAndWait
: Requests cancellation and blocks the current thread until theparse
is cancelled.
TSParser.parse(...)
now throws aParseInProgressException
if a parse operation is already in progress. You can check whether a parser is parsing a syntax tree withTSParser.isParsing()
.