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

Function createYamlHover

internal/compose/hover.go:80–109  ·  view source on GitHub ↗
(node ast.Node, hovered *token.Token)

Source from the content-addressed store, hash-verified

78}
79
80func createYamlHover(node ast.Node, hovered *token.Token) *protocol.Hover {
81 split := strings.Split(node.String(), "\n")
82 // remove leading empty line inserted by goccy/go-yaml if present
83 if strings.TrimSpace(split[0]) == "" {
84 split = split[1:]
85 }
86 skip := -1
87 for i := range len(split) {
88 if skip == -1 {
89 for j := range len(split[i]) {
90 if !unicode.IsSpace(rune(split[i][j])) {
91 skip = j
92 break
93 }
94 }
95 }
96 // extra check in case there are empty lines
97 if len(split[i]) > skip {
98 split[i] = split[i][skip:]
99 }
100 }
101 r := createRange(hovered, len(hovered.Value))
102 return &protocol.Hover{
103 Contents: protocol.MarkupContent{
104 Kind: protocol.MarkupKindMarkdown,
105 Value: fmt.Sprintf("```YAML\n%v\n```", strings.Join(split, "\n")),
106 },
107 Range: &r,
108 }
109}
110
111func serviceHover(doc document.ComposeDocument, mappingNode *ast.MappingNode, nodePath []ast.Node) *protocol.Hover {
112 if (len(nodePath) == 4 || len(nodePath) == 5) && nodePath[0].GetToken().Value == "services" {

Callers 2

HoverFunction · 0.85
createDependencyHoverFunction · 0.85

Calls 2

StringMethod · 0.80
createRangeFunction · 0.70

Tested by

no test coverage detected