@@ -196,12 +196,49 @@ private struct ClassificationVisitor {
196196
197197 for case (let index, let child? ) in children. enumerated ( ) {
198198
199- let classification : ( SyntaxClassification , Bool ) ?
199+ let classification : ( classification : SyntaxClassification , force : Bool ) ?
200200 if case . layout( let layout) = descriptor. node. kind. syntaxNodeType. structure {
201201 classification = SyntaxClassification . classify ( layout [ index] )
202202 } else {
203203 classification = nil
204204 }
205+
206+ if let classification, classification. force {
207+ // Leading trivia.
208+ if let triviaPieces = child. leadingTriviaPieces {
209+ for triviaPiece in triviaPieces {
210+ let range = triviaPiece. classify ( offset: byteOffset)
211+ report ( range: range)
212+ byteOffset += triviaPiece. byteLength
213+ }
214+ }
215+ child. leadingTriviaPieces? . compactMap { $0 } . forEach {
216+ let range = $0. classify ( offset: byteOffset)
217+ report ( range: range)
218+ }
219+ // Layout node text.
220+ let layoutNodeTextLength = child. byteLength - child. leadingTriviaByteLength - child. trailingTriviaByteLength
221+ let range = SyntaxClassifiedRange (
222+ kind: classification. classification,
223+ range: ByteSourceRange (
224+ offset: byteOffset,
225+ length: layoutNodeTextLength
226+ )
227+ )
228+ report ( range: range)
229+ byteOffset += layoutNodeTextLength
230+
231+ // Trailing trivia.
232+ if let triviaPieces = child. trailingTriviaPieces {
233+ for triviaPiece in triviaPieces {
234+ let range = triviaPiece. classify ( offset: byteOffset)
235+ report ( range: range)
236+ byteOffset += triviaPiece. byteLength
237+ }
238+ }
239+ continue
240+ }
241+
205242 let result = visit (
206243 . init(
207244 node: child,
0 commit comments