(input []byte, blocks hclsyntax.Blocks, position protocol.Position)
| 61 | } |
| 62 | |
| 63 | func hoveredVariableName(input []byte, blocks hclsyntax.Blocks, position protocol.Position) string { |
| 64 | for _, block := range blocks { |
| 65 | if isInsideBodyRangeLines(block.Body, int(position.Line+1)) { |
| 66 | if block.Type == "variable" && len(block.LabelRanges) > 0 && isInsideRange(block.LabelRanges[0], position) { |
| 67 | label := string(input[block.LabelRanges[0].Start.Byte:block.LabelRanges[0].End.Byte]) |
| 68 | if Quoted(label) { |
| 69 | if block.LabelRanges[0].Start.Column == int(position.Character+1) || block.LabelRanges[0].End.Column == int(position.Character+1) { |
| 70 | return "" |
| 71 | } |
| 72 | } |
| 73 | return block.Labels[0] |
| 74 | } |
| 75 | |
| 76 | for _, attribute := range block.Body.Attributes { |
| 77 | if isInsideRange(attribute.Expr.Range(), position) { |
| 78 | name := extractVariableName(input, attribute.Expr) |
| 79 | if name != "" { |
| 80 | return name |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | return "" |
| 87 | } |
| 88 | |
| 89 | func extractVariableName(input []byte, expression hclsyntax.Expression) string { |
| 90 | if tupleCons, ok := expression.(*hclsyntax.TupleConsExpr); ok { |
no test coverage detected