Skip to content

Commit 6e990ff

Browse files
authored
Fix missing 'namespace' token type (#412)
Fixes #410.
1 parent c21ac75 commit 6e990ff

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lsp-test/test/Test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ main = hspec $ around withDummyServer $ do
429429
it "full works" $ \(hin, hout) -> runSessionWithHandles hin hout def fullCaps "." $ do
430430
let doc = TextDocumentIdentifier (Uri "")
431431
Just toks <- getSemanticTokens doc
432-
liftIO $ toks ^. xdata `shouldBe` List [0,1,2,0,0]
432+
liftIO $ toks ^. xdata `shouldBe` List [0,1,2,1,0]
433433

434434
didChangeCaps :: ClientCapabilities
435435
didChangeCaps = def { _workspace = Just workspaceCaps }

lsp-types/src/Language/LSP/Types/SemanticTokens.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import Data.Maybe (fromMaybe,
2929
import Data.String
3030

3131
data SemanticTokenTypes =
32-
SttType
32+
SttNamespace
33+
| SttType
3334
| SttClass
3435
| SttEnum
3536
| SttInterface
@@ -54,6 +55,7 @@ data SemanticTokenTypes =
5455
deriving (Show, Read, Eq, Ord)
5556

5657
instance A.ToJSON SemanticTokenTypes where
58+
toJSON SttNamespace = A.String "namespace"
5759
toJSON SttType = A.String "type"
5860
toJSON SttClass = A.String "class"
5961
toJSON SttEnum = A.String "enum"
@@ -78,6 +80,7 @@ instance A.ToJSON SemanticTokenTypes where
7880
toJSON (SttUnknown t) = A.String t
7981

8082
instance A.FromJSON SemanticTokenTypes where
83+
parseJSON (A.String "namespace") = pure SttNamespace
8184
parseJSON (A.String "type") = pure SttType
8285
parseJSON (A.String "class") = pure SttClass
8386
parseJSON (A.String "enum") = pure SttEnum
@@ -105,7 +108,8 @@ instance A.FromJSON SemanticTokenTypes where
105108
-- | The set of semantic token types which are "known" (i.e. listed in the LSP spec).
106109
knownSemanticTokenTypes :: [SemanticTokenTypes]
107110
knownSemanticTokenTypes = [
108-
SttType
111+
SttNamespace
112+
, SttType
109113
, SttClass
110114
, SttEnum
111115
, SttInterface

0 commit comments

Comments
 (0)