Skip to content

Commit 92d7ceb

Browse files
committed
Add doc comments
1 parent 9513ca5 commit 92d7ceb

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Sources/SwiftParser/IncrementalParseTransition.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public final class IncrementalParseReusedNodeCollector:
4343
}
4444
}
4545

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.
4649
public final class IncrementalParseNodeAffectRangeCollector {
4750
fileprivate var nodeAffectRange: [RawSyntax.ID: Int] = [:]
4851

Sources/SwiftParser/Lexer/LexemeSequence.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ extension Lexer {
3232
/// usually less than 0.1% of the memory allocated by the syntax arena.
3333
var lexerStateAllocator = BumpPtrAllocator(slabSize: 256)
3434

35+
/// Compute the offset of the end of next token
3536
var offsetToNextTokenEnd: Int {
3637
self.getOffsetToStart(self.nextToken) + self.nextToken.byteLength
3738
}
3839

40+
/// See doc comments in ``LookaheadTracker``
3941
var lookaheadTracker: UnsafeMutablePointer<LookaheadTracker>
4042

4143
fileprivate init(sourceBufferStart: Lexer.Cursor, cursor: Lexer.Cursor) {
@@ -61,10 +63,12 @@ extension Lexer {
6163
return self.nextToken
6264
}
6365

66+
/// Get the offset of `token` to `sourceBufferStart`.
6467
func getOffsetToStart(_ token: Lexer.Lexeme) -> Int {
6568
return self.sourceBufferStart.distance(to: token.cursor)
6669
}
6770

71+
/// Advance the the cursor by `offset` and reset `currentToken`
6872
mutating func advance(by offset: Int, currentToken: inout Lexer.Lexeme) {
6973
self.cursor = currentToken.cursor
7074
self.cursor.position = self.cursor.position.advanced(by: offset)

Sources/SwiftParser/Parser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ extension Parser {
682682
}
683683
}
684684

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``
686686
public struct LookaheadTracker {
687687
private var _furthestOffset: Int
688688

0 commit comments

Comments
 (0)