MCPcopy Create free account
hub / github.com/docker/docker-language-server / TestSemanticTokensFull

Function TestSemanticTokensFull

e2e-tests/semanticTokens_test.go:15–108  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestSemanticTokensFull(t *testing.T) {
16 s := startServer()
17
18 client := bytes.NewBuffer(make([]byte, 0, 1024))
19 server := bytes.NewBuffer(make([]byte, 0, 1024))
20 serverStream := &TestStream{incoming: server, outgoing: client, closed: false}
21 defer serverStream.Close()
22 go s.ServeStream(serverStream)
23
24 clientStream := jsonrpc2.NewBufferedStream(&TestStream{incoming: client, outgoing: server, closed: false}, jsonrpc2.VSCodeObjectCodec{})
25 defer clientStream.Close()
26 conn := jsonrpc2.NewConn(context.Background(), clientStream, &ConfigurationHandler{t: t})
27 initialize(t, conn, protocol.InitializeParams{})
28
29 homedir, err := os.UserHomeDir()
30 require.NoError(t, err)
31
32 testCases := []struct {
33 name string
34 languageIdentifier protocol.LanguageIdentifier
35 content string
36 result *protocol.SemanticTokens
37 }{
38 {
39 name: "target {}",
40 languageIdentifier: protocol.DockerBakeLanguage,
41 content: "target {}",
42 result: &protocol.SemanticTokens{Data: []uint32{0, 0, 6, hcl.SemanticTokenTypeIndex(hcl.TokenType_Type), 0}},
43 },
44 {
45 name: "single line comment after content with no newlines after it",
46 languageIdentifier: protocol.DockerBakeLanguage,
47 content: "variable \"port\" {default = true} # hello",
48 result: &protocol.SemanticTokens{
49 Data: []uint32{
50 0, 0, 8, hcl.SemanticTokenTypeIndex(hcl.TokenType_Type), 0,
51 0, 9, 6, hcl.SemanticTokenTypeIndex(hcl.TokenType_Class), 0,
52 0, 8, 7, hcl.SemanticTokenTypeIndex(hcl.TokenType_Property), 0,
53 0, 10, 4, hcl.SemanticTokenTypeIndex(hcl.TokenType_Keyword), 0,
54 0, 6, 7, hcl.SemanticTokenTypeIndex(hcl.TokenType_Comment), 0,
55 },
56 },
57 },
58 {
59 name: "single line comment after content followed by LF",
60 languageIdentifier: protocol.DockerBakeLanguage,
61 content: "variable \"port\" {default = true} # hello\n",
62 result: &protocol.SemanticTokens{
63 Data: []uint32{
64 0, 0, 8, hcl.SemanticTokenTypeIndex(hcl.TokenType_Type), 0,
65 0, 9, 6, hcl.SemanticTokenTypeIndex(hcl.TokenType_Class), 0,
66 0, 8, 7, hcl.SemanticTokenTypeIndex(hcl.TokenType_Property), 0,
67 0, 10, 4, hcl.SemanticTokenTypeIndex(hcl.TokenType_Keyword), 0,
68 0, 6, 7, hcl.SemanticTokenTypeIndex(hcl.TokenType_Comment), 0,
69 },
70 },
71 },
72 {

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
SemanticTokenTypeIndexFunction · 0.92
startServerFunction · 0.85
initializeFunction · 0.85
CloseMethod · 0.65
ServeStreamMethod · 0.45

Tested by

no test coverage detected