apple / sourcekit-lsp

Language Server Protocol implementation for Swift and C-based languages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`SemanticTokensManager` should not have `DocumentSnapshot.ID` as key

ahoppen opened this issue · comments

#857 (comment)

I suspect we'll not have all that many documents, but given we only ever keep the latest this could just be eg.

struct VersionedTokens {
  let version: Int
  let tokens: [SyntaxHighlightingToken]
}
...
private var semanticTokens: [DocumentURI: VersionedTokens]

Then the discard is just semanticTokens.removeValue(uri) and setSemanticTokens would just check if the version is less than the one stored (if any), then set.

Assuming that is that we do only want the latest, right now we could technically store version 5 then 4 and we'd have both (but 4 then 5 would only have 5).

Tracked in Apple’s issue tracker as rdar://116705694

SemanticTokensManager no longer exists.