(node ast.Node, hovered *token.Token)
| 78 | } |
| 79 | |
| 80 | func 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 | |
| 111 | func 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" { |
no test coverage detected