Skip to content

Add isMissing flag #320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tree-sitter/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### v0.9.0.4

* Add `isMissing` flag for nodes.
* Add bindings for the edit API.

### v0.9.0.3
Expand Down
5 changes: 4 additions & 1 deletion tree-sitter/src/TreeSitter/Node.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ data Node = Node
, nodeFieldName :: !CString
, nodeIsNamed :: !CBool
, nodeIsExtra :: !CBool
, nodeIsMissing :: !CBool
}
deriving (Show, Eq, Generic)

Expand Down Expand Up @@ -85,8 +86,9 @@ instance Storable Node where
<*> peekStruct
<*> peekStruct
<*> peekStruct
<*> peekStruct
{-# INLINE peek #-}
poke ptr (Node n t s ep eb c fn nn ne) = flip evalStruct ptr $ do
poke ptr (Node n t s ep eb c fn nn ne nm) = flip evalStruct ptr $ do
pokeStruct n
pokeStruct t
pokeStruct s
Expand All @@ -96,6 +98,7 @@ instance Storable Node where
pokeStruct fn
pokeStruct nn
pokeStruct ne
pokeStruct nm
{-# INLINE poke #-}

instance Storable TSPoint where
Expand Down
2 changes: 2 additions & 0 deletions tree-sitter/src/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ typedef struct Node {
const char *fieldName;
bool isNamed;
bool isExtra;
bool isMissing;
} Node;

void log_to_stdout(void *payload, TSLogType type, const char *message) {
Expand All @@ -33,6 +34,7 @@ static inline void ts_node_poke(const char *fieldName, TSNode node, Node *out) {
out->fieldName = fieldName;
out->isNamed = ts_node_is_named(node);
out->isExtra = ts_node_is_extra(node);
out->isMissing = ts_node_is_missing(node);
}

void ts_node_poke_p(TSNode *node, Node *out) {
Expand Down
4 changes: 2 additions & 2 deletions tree-sitter/test/TreeSitter/Example.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ prop_Node_sizeOf = property $
sizeOf (undefined :: Node) === fromIntegral sizeof_node

prop_Node_roundtrips = property $ do
peeked <- liftIO (with (Node (TSNode 1 (TSPoint 2 3) 4 nullPtr nullPtr) nullPtr 1 (TSPoint 4 5) 7 8 nullPtr 9 10) peek)
peeked === Node (TSNode 1 (TSPoint 2 3) 4 nullPtr nullPtr) nullPtr 1 (TSPoint 4 5) 7 8 nullPtr 9 10
peeked <- liftIO (with (Node (TSNode 1 (TSPoint 2 3) 4 nullPtr nullPtr) nullPtr 1 (TSPoint 4 5) 7 8 nullPtr 9 10 11) peek)
peeked === Node (TSNode 1 (TSPoint 2 3) 4 nullPtr nullPtr) nullPtr 1 (TSPoint 4 5) 7 8 nullPtr 9 10 11

prop_TSTreeCursor_sizeOf = property $
sizeOfCursor === fromIntegral sizeof_tstreecursor
Expand Down
Loading