Debian Codegraph @

internal/golangorgx/gopls/protocol/semantic.go

raw symbols SCIP
1 // Copyright 2023 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package protocolscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/gopls/protocol`/
6
7 // The file defines helpers for semantics tokens.
8
9 import "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/"
10
11 // SemanticTypes to use in case there is no client, as in the command line, or tests
12 func SemanticTypesscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/gopls/protocol`/SemanticTypes().() []string {
13 return semanticTypesscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/gopls/protocol`/semanticTypes.[:]
14 }
15
16 // SemanticModifiers to use in case there is no client.
17 func SemanticModifiersscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/gopls/protocol`/SemanticModifiers().() []string {
18 return semanticModifiersscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/gopls/protocol`/semanticModifiers.[:]
19 }
20
21 // SemType returns a string equivalent of the type, for gopls semtok
22 func SemTypescip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/gopls/protocol`/SemType().(n int) string {
23 tokTypes := SemanticTypesscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/gopls/protocol`/SemanticTypes().()
24 tokMods := SemanticModifiersscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/gopls/protocol`/SemanticModifiers().()
25 if n >= 0 && n < len(tokTypes) {
26 return tokTypes[n]
27 }
28 // not found for some reason
29 return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("?%d[%d,%d]?", n, len(tokTypes), len(tokMods))
30 }
31
32 // SemMods returns the []string equivalent of the mods, for gopls semtok.
33 func SemModsscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/gopls/protocol`/SemMods().(n int) []string {
34 tokMods := SemanticModifiersscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/gopls/protocol`/SemanticModifiers().()
35 mods := []string{}
36 for i := 0; i < len(tokMods); i++ {
37 if (n & (1 << uint(i))) != 0 {
38 mods = append(mods, tokMods[i])
39 }
40 }
41 return mods
42 }
43
44 // From https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_semanticTokens
45 var (
46 semanticTypesscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/gopls/protocol`/semanticTypes. = [...]string{
47 "namespace", "type", "class", "enum", "interface",
48 "struct", "typeParameter", "parameter", "variable", "property", "enumMember",
49 "event", "function", "method", "macro", "keyword", "modifier", "comment",
50 "string", "number", "regexp", "operator",
51 }
52 semanticModifiersscip-go gomod cuelang.org/go . `cuelang.org/go/internal/golangorgx/gopls/protocol`/semanticModifiers. = [...]string{
53 "declaration", "definition", "readonly", "static",
54 "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary",
55 }
56 )