File tree Expand file tree Collapse file tree 3 files changed +8
-1
lines changed Expand file tree Collapse file tree 3 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ public final class IncrementalParseReusedNodeCollector:
43
43
}
44
44
}
45
45
46
+ /// Record the affect range for potential re-used nodes. When edits intersect the affect range, the node is not able to be re-used.
47
+ ///
48
+ /// This is also a trigger to enable parser to parse incrementally.
46
49
public final class IncrementalParseNodeAffectRangeCollector {
47
50
fileprivate var nodeAffectRange : [ RawSyntax . ID : Int ] = [ : ]
48
51
Original file line number Diff line number Diff line change @@ -32,10 +32,12 @@ extension Lexer {
32
32
/// usually less than 0.1% of the memory allocated by the syntax arena.
33
33
var lexerStateAllocator = BumpPtrAllocator ( slabSize: 256 )
34
34
35
+ /// Compute the offset of the end of next token
35
36
var offsetToNextTokenEnd : Int {
36
37
self . getOffsetToStart ( self . nextToken) + self . nextToken. byteLength
37
38
}
38
39
40
+ /// See doc comments in ``LookaheadTracker``
39
41
var lookaheadTracker : UnsafeMutablePointer < LookaheadTracker >
40
42
41
43
fileprivate init ( sourceBufferStart: Lexer . Cursor , cursor: Lexer . Cursor ) {
@@ -61,10 +63,12 @@ extension Lexer {
61
63
return self . nextToken
62
64
}
63
65
66
+ /// Get the offset of `token` to `sourceBufferStart`.
64
67
func getOffsetToStart( _ token: Lexer . Lexeme ) -> Int {
65
68
return self . sourceBufferStart. distance ( to: token. cursor)
66
69
}
67
70
71
+ /// Advance the the cursor by `offset` and reset `currentToken`
68
72
mutating func advance( by offset: Int , currentToken: inout Lexer . Lexeme ) {
69
73
self . cursor = currentToken. cursor
70
74
self . cursor. position = self . cursor. position. advanced ( by: offset)
Original file line number Diff line number Diff line change @@ -682,7 +682,7 @@ extension Parser {
682
682
}
683
683
}
684
684
685
- /// Record the furthest offset to `sourceBufferStart` that is reached by ``Parser.Lookahead `` or ``Parser.peek() `` in ``Lexer. LexemeSequence``
685
+ /// Record the furthest offset to `sourceBufferStart` that is reached by ``Parser.Peek() `` or ``Lookahead `` in ``Lexer/ LexemeSequence``
686
686
public struct LookaheadTracker {
687
687
private var _furthestOffset : Int
688
688
You can’t perform that action at this time.
0 commit comments