Skip to content

Commit f97e41b

Browse files
committed
feat: add mergingTokens overloading method
1 parent 45d24a8 commit f97e41b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sources/SourceKitLSP/Swift/SyntaxHighlightingTokens.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public struct SyntaxHighlightingTokens {
6262
return SyntaxHighlightingTokens(tokens: tokens.filter { !otherRanges.contains($0.range) } + other.tokens)
6363
}
6464

65+
public func mergingTokens(with other: [SyntaxHighlightingToken]) -> SyntaxHighlightingTokens {
66+
let otherRanges = Set(other.map(\.range))
67+
return SyntaxHighlightingTokens(tokens: tokens.filter { !otherRanges.contains($0.range) } + other)
68+
}
69+
6570
/// Sorts the tokens in this array by their start position.
6671
public func sorted(_ areInIncreasingOrder: (SyntaxHighlightingToken, SyntaxHighlightingToken) -> Bool)
6772
-> SyntaxHighlightingTokens

0 commit comments

Comments
 (0)