@@ -10,20 +10,24 @@ try {
1010}
1111
1212const util = require ( 'util' )
13- const { Query, Parser, NodeMethods, Tree, TreeCursor} = binding ;
13+ const { Query, Parser, NodeMethods, Tree, TreeCursor, LookaheadIterator } = binding ;
1414
1515/*
1616 * Tree
1717 */
1818
19- const { rootNode, edit} = Tree . prototype ;
19+ const { rootNode, rootNodeWithOffset , edit} = Tree . prototype ;
2020
2121Object . defineProperty ( Tree . prototype , 'rootNode' , {
2222 get ( ) {
2323 return unmarshalNode ( rootNode . call ( this ) , this ) ;
2424 }
2525} ) ;
2626
27+ Tree . prototype . rootNodeWithOffset = function ( offset_bytes , offset_extent ) {
28+ return unmarshalNode ( rootNodeWithOffset . call ( this , offset_bytes , offset_extent . row , offset_extent . column ) , this ) ;
29+ }
30+
2731Tree . prototype . edit = function ( arg ) {
2832 edit . call (
2933 this ,
@@ -58,16 +62,31 @@ class SyntaxNode {
5862 '}'
5963 }
6064
61- get type ( ) {
65+ get id ( ) {
6266 marshalNode ( this ) ;
63- return NodeMethods . type ( this . tree ) ;
67+ return NodeMethods . id ( this . tree ) ;
6468 }
6569
6670 get typeId ( ) {
6771 marshalNode ( this ) ;
6872 return NodeMethods . typeId ( this . tree ) ;
6973 }
7074
75+ get grammarId ( ) {
76+ marshalNode ( this ) ;
77+ return NodeMethods . grammarId ( this . tree ) ;
78+ }
79+
80+ get type ( ) {
81+ marshalNode ( this ) ;
82+ return NodeMethods . type ( this . tree ) ;
83+ }
84+
85+ get grammarName ( ) {
86+ marshalNode ( this ) ;
87+ return NodeMethods . grammarName ( this . tree ) ;
88+ }
89+
7190 get isNamed ( ) {
7291 marshalNode ( this ) ;
7392 return NodeMethods . isNamed ( this . tree ) ;
@@ -164,6 +183,21 @@ class SyntaxNode {
164183 return unmarshalNode ( NodeMethods . previousNamedSibling ( this . tree ) , this . tree ) ;
165184 }
166185
186+ get parseState ( ) {
187+ marshalNode ( this ) ;
188+ return NodeMethods . parseState ( this . tree ) ;
189+ }
190+
191+ get nextParseState ( ) {
192+ marshalNode ( this ) ;
193+ return NodeMethods . nextParseState ( this . tree ) ;
194+ }
195+
196+ get descendantCount ( ) {
197+ marshalNode ( this ) ;
198+ return NodeMethods . descendantCount ( this . tree ) ;
199+ }
200+
167201 hasChanges ( ) {
168202 marshalNode ( this ) ;
169203 return NodeMethods . hasChanges ( this . tree ) ;
@@ -179,6 +213,16 @@ class SyntaxNode {
179213 return NodeMethods . isMissing ( this . tree ) ;
180214 }
181215
216+ isExtra ( ) {
217+ marshalNode ( this ) ;
218+ return NodeMethods . isExtra ( this . tree ) ;
219+ }
220+
221+ isError ( ) {
222+ marshalNode ( this ) ;
223+ return NodeMethods . isError ( this . tree ) ;
224+ }
225+
182226 toString ( ) {
183227 marshalNode ( this ) ;
184228 return NodeMethods . toString ( this . tree ) ;
@@ -194,6 +238,31 @@ class SyntaxNode {
194238 return unmarshalNode ( NodeMethods . namedChild ( this . tree , index ) , this . tree ) ;
195239 }
196240
241+ childForFieldName ( fieldName ) {
242+ marshalNode ( this ) ;
243+ return unmarshalNode ( NodeMethods . childForFieldName ( this . tree , fieldName ) , this . tree ) ;
244+ }
245+
246+ childForFieldId ( fieldId ) {
247+ marshalNode ( this ) ;
248+ return unmarshalNode ( NodeMethods . childForFieldId ( this . tree , fieldId ) , this . tree ) ;
249+ }
250+
251+ fieldNameForChild ( childIndex ) {
252+ marshalNode ( this ) ;
253+ return NodeMethods . fieldNameForChild ( this . tree , childIndex ) ;
254+ }
255+
256+ childrenForFieldName ( fieldName , cursor ) {
257+ marshalNode ( this ) ;
258+ return unmarshalNodes ( NodeMethods . childrenForFieldName ( this . tree , fieldName , cursor ) , this . tree ) ;
259+ }
260+
261+ childrenForFieldId ( fieldId ) {
262+ marshalNode ( this ) ;
263+ return unmarshalNodes ( NodeMethods . childrenForFieldId ( this . tree , fieldId ) , this . tree ) ;
264+ }
265+
197266 firstChildForIndex ( index ) {
198267 marshalNode ( this ) ;
199268 return unmarshalNode ( NodeMethods . firstChildForIndex ( this . tree , index ) , this . tree ) ;
@@ -282,7 +351,7 @@ Parser.prototype.parse = function(input, oldTree, {bufferSize, includedRanges}={
282351 input ,
283352 oldTree ,
284353 bufferSize ,
285- includedRanges
354+ includedRanges ,
286355 ) ;
287356 if ( tree ) {
288357 tree . input = treeInput
@@ -467,11 +536,22 @@ Query.prototype._init = function() {
467536 this . refutedProperties = Object . freeze ( refutedProperties ) ;
468537}
469538
470- Query . prototype . matches = function ( rootNode , startPosition = ZERO_POINT , endPosition = ZERO_POINT ) {
539+ Query . prototype . matches = function (
540+ rootNode ,
541+ {
542+ startPosition = ZERO_POINT ,
543+ endPosition = ZERO_POINT ,
544+ startIndex = 0 ,
545+ endIndex = 0 ,
546+ matchLimit = 0xFFFFFFFF ,
547+ maxStartDepth = 0xFFFFFFFF
548+ } = { }
549+ ) {
471550 marshalNode ( rootNode ) ;
472551 const [ returnedMatches , returnedNodes ] = _matches . call ( this , rootNode . tree ,
473552 startPosition . row , startPosition . column ,
474- endPosition . row , endPosition . column
553+ endPosition . row , endPosition . column ,
554+ startIndex , endIndex , matchLimit , maxStartDepth
475555 ) ;
476556 const nodes = unmarshalNodes ( returnedNodes , rootNode . tree ) ;
477557 const results = [ ] ;
@@ -505,11 +585,22 @@ Query.prototype.matches = function(rootNode, startPosition = ZERO_POINT, endPosi
505585 return results ;
506586}
507587
508- Query . prototype . captures = function ( rootNode , startPosition = ZERO_POINT , endPosition = ZERO_POINT ) {
588+ Query . prototype . captures = function (
589+ rootNode ,
590+ {
591+ startPosition = ZERO_POINT ,
592+ endPosition = ZERO_POINT ,
593+ startIndex = 0 ,
594+ endIndex = 0 ,
595+ matchLimit = 0xFFFFFFFF ,
596+ maxStartDepth = 0xFFFFFFFF
597+ } = { }
598+ ) {
509599 marshalNode ( rootNode ) ;
510600 const [ returnedMatches , returnedNodes ] = _captures . call ( this , rootNode . tree ,
511601 startPosition . row , startPosition . column ,
512- endPosition . row , endPosition . column
602+ endPosition . row , endPosition . column ,
603+ startIndex , endIndex , matchLimit , maxStartDepth
513604 ) ;
514605 const nodes = unmarshalNodes ( returnedNodes , rootNode . tree ) ;
515606 const results = [ ] ;
@@ -709,3 +800,4 @@ module.exports.Query = Query;
709800module . exports . Tree = Tree ;
710801module . exports . SyntaxNode = SyntaxNode ;
711802module . exports . TreeCursor = TreeCursor ;
803+ module . exports . LookaheadIterator = LookaheadIterator ;
0 commit comments