@@ -209,9 +209,6 @@ impl SyntaxNode {
209
209
SyntaxNode :: new ( data)
210
210
}
211
211
212
- /// Returns a green tree, equal to the green tree this node
213
- /// belongs two, except with this node substitute. The complexity
214
- /// of operation is proportional to the depth of the tree
215
212
pub fn replace_with ( & self , replacement : GreenNode ) -> GreenNode {
216
213
assert_eq ! ( self . kind( ) , replacement. kind( ) ) ;
217
214
match self . 0 . kind . as_child ( ) {
@@ -334,13 +331,11 @@ impl SyntaxNode {
334
331
Some ( SyntaxElement :: new ( element, parent. clone ( ) , index as u32 , offset) )
335
332
}
336
333
337
- /// Return the leftmost token in the subtree of this node
338
334
#[ inline]
339
335
pub fn first_token ( & self ) -> Option < SyntaxToken > {
340
336
self . first_child_or_token ( ) ?. first_token ( )
341
337
}
342
338
343
- /// Return the rightmost token in the subtree of this node
344
339
#[ inline]
345
340
pub fn last_token ( & self ) -> Option < SyntaxToken > {
346
341
self . last_child_or_token ( ) ?. last_token ( )
@@ -378,8 +373,6 @@ impl SyntaxNode {
378
373
} )
379
374
}
380
375
381
- /// Traverse the subtree rooted at the current node (including the current
382
- /// node) in preorder, excluding tokens.
383
376
#[ inline]
384
377
pub fn preorder ( & self ) -> impl Iterator < Item = WalkEvent < SyntaxNode > > {
385
378
let this = self . clone ( ) ;
@@ -403,8 +396,6 @@ impl SyntaxNode {
403
396
} )
404
397
}
405
398
406
- /// Traverse the subtree rooted at the current node (including the current
407
- /// node) in preorder, including tokens.
408
399
#[ inline]
409
400
pub fn preorder_with_tokens < ' a > ( & ' a self ) -> impl Iterator < Item = WalkEvent < SyntaxElement > > {
410
401
let start: SyntaxElement = self . clone ( ) . into ( ) ;
@@ -431,8 +422,6 @@ impl SyntaxNode {
431
422
} )
432
423
}
433
424
434
- /// Find a token in the subtree corresponding to this node, which covers the offset.
435
- /// Precondition: offset must be withing node's range.
436
425
pub fn token_at_offset ( & self , offset : TextSize ) -> TokenAtOffset < SyntaxToken > {
437
426
// TODO: this could be faster if we first drill-down to node, and only
438
427
// then switch to token search. We should also replace explicit
@@ -470,10 +459,6 @@ impl SyntaxNode {
470
459
}
471
460
}
472
461
473
- /// Return the deepest node or token in the current subtree that fully
474
- /// contains the range. If the range is empty and is contained in two leaf
475
- /// nodes, either one can be returned. Precondition: range must be contained
476
- /// withing the current node
477
462
pub fn covering_element ( & self , range : TextRange ) -> SyntaxElement {
478
463
let mut res: SyntaxElement = self . clone ( ) . into ( ) ;
479
464
loop {
@@ -504,9 +489,6 @@ impl SyntaxToken {
504
489
SyntaxToken { parent, index, offset }
505
490
}
506
491
507
- /// Returns a green tree, equal to the green tree this token
508
- /// belongs two, except with this token substitute. The complexity
509
- /// of operation is proportional to the depth of the tree
510
492
pub fn replace_with ( & self , replacement : GreenToken ) -> GreenNode {
511
493
assert_eq ! ( self . kind( ) , replacement. kind( ) ) ;
512
494
let mut replacement = Some ( replacement) ;
@@ -580,7 +562,6 @@ impl SyntaxToken {
580
562
} )
581
563
}
582
564
583
- /// Next token in the tree (i.e, not necessary a sibling)
584
565
pub fn next_token ( & self ) -> Option < SyntaxToken > {
585
566
match self . next_sibling_or_token ( ) {
586
567
Some ( element) => element. first_token ( ) ,
@@ -591,7 +572,7 @@ impl SyntaxToken {
591
572
. and_then ( |element| element. first_token ( ) ) ,
592
573
}
593
574
}
594
- /// Previous token in the tree (i.e, not necessary a sibling)
575
+
595
576
pub fn prev_token ( & self ) -> Option < SyntaxToken > {
596
577
match self . prev_sibling_or_token ( ) {
597
578
Some ( element) => element. last_token ( ) ,
0 commit comments