diff --git a/decoder/expression_candidates.go b/decoder/expression_candidates.go index 9353c580..762c0119 100644 --- a/decoder/expression_candidates.go +++ b/decoder/expression_candidates.go @@ -100,15 +100,6 @@ func constraintsAtPos(expr hcl.Expression, constraints ExprConstraints, pos hcl. Filename: rng.Filename, } - tc, ok := constraints.TupleConsExpr() - if ok && len(eType.Exprs) == 0 && tupleConsBody.ContainsPos(pos) { - return ExprConstraints(tc.AnyElem), hcl.Range{ - Start: pos, - End: pos, - Filename: eType.Range().Filename, - } - } - se, ok := constraints.SetExpr() if ok && len(eType.Exprs) == 0 && tupleConsBody.ContainsPos(pos) { return ExprConstraints(se.Elem), hcl.Range{ @@ -329,22 +320,9 @@ func (d *PathDecoder) constraintToCandidates(ctx context.Context, constraint sch }) case schema.TraversalExpr: candidates = append(candidates, d.candidatesForTraversalConstraint(ctx, c, outerBodyRng, prefixRng, editRng)...) - case schema.TupleConsExpr: - candidates = append(candidates, lang.Candidate{ - Label: fmt.Sprintf(`[%s]`, labelForConstraints(c.AnyElem)), - Detail: c.Name, - Description: c.Description, - Kind: lang.TupleCandidateKind, - TextEdit: lang.TextEdit{ - NewText: `[ ]`, - Snippet: `[ ${0} ]`, - Range: editRng, - }, - TriggerSuggest: triggerSuggestForExprConstraints(c.AnyElem), - }) case schema.ListExpr: candidates = append(candidates, lang.Candidate{ - Label: fmt.Sprintf(`[%s]`, labelForConstraints(c.Elem)), + Label: fmt.Sprintf(`[ %s ]`, labelsForConstraints(c.Elem)), Detail: c.FriendlyName(), Description: c.Description, Kind: lang.ListCandidateKind, @@ -357,7 +335,7 @@ func (d *PathDecoder) constraintToCandidates(ctx context.Context, constraint sch }) case schema.SetExpr: candidates = append(candidates, lang.Candidate{ - Label: fmt.Sprintf(`[%s]`, labelForConstraints(c.Elem)), + Label: fmt.Sprintf(`[ %s ]`, labelsForConstraints(c.Elem)), Detail: c.FriendlyName(), Description: c.Description, Kind: lang.SetCandidateKind, @@ -374,7 +352,7 @@ func (d *PathDecoder) constraintToCandidates(ctx context.Context, constraint sch triggerSuggest = triggerSuggestForExprConstraints(c.Elems[0]) } candidates = append(candidates, lang.Candidate{ - Label: fmt.Sprintf(`[%s]`, labelForConstraints(c.Elems[0])), + Label: fmt.Sprintf(`[ %s ]`, labelsForConstraints(c.Elems[0])), Detail: c.FriendlyName(), Description: c.Description, Kind: lang.TupleCandidateKind, @@ -387,7 +365,7 @@ func (d *PathDecoder) constraintToCandidates(ctx context.Context, constraint sch }) case schema.MapExpr: candidates = append(candidates, lang.Candidate{ - Label: fmt.Sprintf(`{ key =%s}`, labelForConstraints(c.Elem)), + Label: fmt.Sprintf(`{ key = %s }`, labelsForConstraints(c.Elem)), Detail: c.FriendlyName(), Description: c.Description, Kind: lang.MapCandidateKind, @@ -507,11 +485,6 @@ func newTextForConstraints(cons schema.ExprConstraints, isNested bool) string { return newTextForLiteralValue(c.Val) case schema.KeywordExpr: return c.Keyword - case schema.TupleConsExpr: - if isNested { - return "[ ]" - } - return fmt.Sprintf("[\n %s\n]", newTextForConstraints(c.AnyElem, true)) case schema.ListExpr: if isNested { return "[ ]" @@ -562,11 +535,6 @@ func snippetForConstraints(placeholder uint, cons schema.ExprConstraints, isNest return snippetForLiteralValue(placeholder, c.Val) case schema.KeywordExpr: return fmt.Sprintf("${%d:%s}", placeholder, c.Keyword) - case schema.TupleConsExpr: - if isNested { - return fmt.Sprintf("[ ${%d} ]", placeholder+1) - } - return fmt.Sprintf("[\n %s\n]", snippetForConstraints(placeholder+1, c.AnyElem, true)) case schema.ListExpr: if isNested { return fmt.Sprintf("[ ${%d} ]", placeholder+1) @@ -591,40 +559,55 @@ func snippetForConstraints(placeholder uint, cons schema.ExprConstraints, isNest return "" } -func labelForConstraints(cons schema.ExprConstraints) string { - labels := " " - labelsAdded := 0 - for _, constraint := range cons { - if len(labels) > 10 { - labels += "…" - break - } - if labelsAdded > 0 { - labels += "| " +type labelSet []string + +func (ls labelSet) String() string { + if len(ls) > 10 { + return strings.Join(ls[:9], " | ") + " …" + } + + return strings.Join(ls, " | ") +} + +func (ls labelSet) AddLabelIfNotPresent(label string) labelSet { + if !ls.HasLabel(label) { + return append(ls, label) + } + return ls +} + +func (ls labelSet) HasLabel(label string) bool { + for _, l := range ls { + if l == label { + return true } + } + return false +} + +func labelsForConstraints(cons schema.ExprConstraints) labelSet { + ls := make(labelSet, 0) + + for _, constraint := range cons { switch c := constraint.(type) { case schema.LiteralTypeExpr: - labels += labelForLiteralType(c.Type) + ls = ls.AddLabelIfNotPresent(labelForLiteralType(c.Type)) case schema.LiteralValue: continue case schema.KeywordExpr: - labels += c.FriendlyName() + ls = ls.AddLabelIfNotPresent(c.FriendlyName()) case schema.TraversalExpr: - labels += c.FriendlyName() - case schema.TupleConsExpr: - labels += fmt.Sprintf("[%s]", labelForConstraints(c.AnyElem)) + ls = ls.AddLabelIfNotPresent(c.FriendlyName()) case schema.ListExpr: - labels += fmt.Sprintf("[%s]", labelForConstraints(c.Elem)) + ls = ls.AddLabelIfNotPresent(fmt.Sprintf("[ %s ]", labelsForConstraints(c.Elem))) case schema.SetExpr: - labels += fmt.Sprintf("[%s]", labelForConstraints(c.Elem)) + ls = ls.AddLabelIfNotPresent(fmt.Sprintf("[ %s ]", labelsForConstraints(c.Elem))) case schema.TupleExpr: - labels += fmt.Sprintf("[%s]", labelForConstraints(c.Elems[0])) + ls = ls.AddLabelIfNotPresent(fmt.Sprintf("[ %s ]", labelsForConstraints(c.Elems[0]))) } - labelsAdded++ } - labels += " " - return labels + return ls } func typeToCandidates(ofType cty.Type, editRng hcl.Range) []lang.Candidate { @@ -746,8 +729,6 @@ func triggerSuggestForExprConstraints(ec schema.ExprConstraints) bool { return true case schema.TraversalExpr: return true - case schema.TupleConsExpr: - return triggerSuggestForExprConstraints(et.AnyElem) case schema.ListExpr: return triggerSuggestForExprConstraints(et.Elem) case schema.SetExpr: @@ -779,12 +760,6 @@ func snippetForExprContraints(placeholder uint, ec schema.ExprConstraints) strin return snippetForLiteralValue(placeholder, et.Val) } return "" - case schema.TupleConsExpr: - ec := ExprConstraints(et.AnyElem) - if ec.HasKeywordsOnly() { - return "[ ${0} ]" - } - return "[\n ${0}\n]" case schema.ListExpr: ec := ExprConstraints(et.Elem) if ec.HasKeywordsOnly() { @@ -828,13 +803,6 @@ func snippetForExprContraint(placeholder uint, ec schema.ExprConstraints) string // return snippetForLiteralValue(placeholder, et.Val) // } // return "" - if t, ok := e.TupleConsExpr(); ok { - ec := ExprConstraints(t.AnyElem) - if ec.HasKeywordsOnly() { - return "[ ${0} ]" - } - return "[\n ${0}\n]" - } if t, ok := e.ListExpr(); ok { ec := ExprConstraints(t.Elem) if ec.HasKeywordsOnly() { diff --git a/decoder/expression_candidates_test.go b/decoder/expression_candidates_test.go index ac2aa999..88969f04 100644 --- a/decoder/expression_candidates_test.go +++ b/decoder/expression_candidates_test.go @@ -670,112 +670,6 @@ func TestDecoder_CandidateAtPos_expressions(t *testing.T) { }, }), }, - { - "tuple constant expression", - map[string]*schema.AttributeSchema{ - "attr": { - Expr: schema.ExprConstraints{ - schema.TupleConsExpr{ - AnyElem: schema.ExprConstraints{ - schema.LiteralValue{Val: cty.StringVal("one")}, - schema.LiteralValue{Val: cty.StringVal("two")}, - }, - }, - }, - }, - }, - `attr = -`, - hcl.Pos{Line: 1, Column: 8, Byte: 7}, - lang.CompleteCandidates([]lang.Candidate{ - { - Label: "[ ]", - TextEdit: lang.TextEdit{ - Range: hcl.Range{ - Filename: "test.tf", - Start: hcl.Pos{ - Line: 1, - Column: 8, - Byte: 7, - }, - End: hcl.Pos{ - Line: 1, - Column: 8, - Byte: 7, - }, - }, - NewText: "[ ]", - Snippet: "[ ${0} ]", - }, - Kind: lang.TupleCandidateKind, - TriggerSuggest: true, - }, - }), - }, - { - "tuple constant expression inside", - map[string]*schema.AttributeSchema{ - "attr": { - Expr: schema.ExprConstraints{ - schema.TupleConsExpr{ - AnyElem: schema.ExprConstraints{ - schema.LiteralValue{Val: cty.StringVal("one")}, - schema.LiteralValue{Val: cty.StringVal("two")}, - }, - }, - }, - }, - }, - `attr = [ ] -`, - hcl.Pos{Line: 1, Column: 10, Byte: 9}, - lang.CompleteCandidates([]lang.Candidate{ - { - Label: "one", - Detail: "string", - TextEdit: lang.TextEdit{ - Range: hcl.Range{ - Filename: "test.tf", - Start: hcl.Pos{ - Line: 1, - Column: 10, - Byte: 9, - }, - End: hcl.Pos{ - Line: 1, - Column: 10, - Byte: 9, - }, - }, - NewText: `"one"`, - Snippet: `"${1:one}"`, - }, - Kind: lang.StringCandidateKind, - }, - { - Label: "two", - Detail: "string", - TextEdit: lang.TextEdit{ - Range: hcl.Range{ - Filename: "test.tf", - Start: hcl.Pos{ - Line: 1, - Column: 10, - Byte: 9, - }, - End: hcl.Pos{ - Line: 1, - Column: 10, - Byte: 9, - }, - }, - NewText: `"two"`, - Snippet: `"${1:two}"`, - }, - Kind: lang.StringCandidateKind, - }, - }), - }, { "tuple as list type", map[string]*schema.AttributeSchema{ @@ -1281,55 +1175,6 @@ func TestDecoder_CandidateAtPos_expressions(t *testing.T) { }, }), }, - { - "map expression of tuple expr", - map[string]*schema.AttributeSchema{ - "attr": { - Expr: schema.ExprConstraints{ - schema.MapExpr{ - Elem: schema.ExprConstraints{ - schema.TupleConsExpr{ - Name: "special tuple", - AnyElem: schema.LiteralTypeOnly(cty.Number), - }, - }, - Name: "special map", - }, - }, - }, - }, - `attr = -`, - hcl.Pos{Line: 1, Column: 8, Byte: 7}, - lang.CompleteCandidates([]lang.Candidate{ - { - Label: "{ key = [ number ] }", - Detail: "special map", - TextEdit: lang.TextEdit{ - Range: hcl.Range{ - Filename: "test.tf", - Start: hcl.Pos{ - Line: 1, - Column: 8, - Byte: 7, - }, - End: hcl.Pos{ - Line: 1, - Column: 8, - Byte: 7, - }, - }, - NewText: `{ - name = [ ] -}`, - Snippet: `{ - ${1:name} = [ ${2} ] -}`, - }, - Kind: lang.MapCandidateKind, - }, - }), - }, { "literal of dynamic pseudo type", map[string]*schema.AttributeSchema{ @@ -1504,6 +1349,70 @@ func TestDecoder_CandidateAtPos_expressions(t *testing.T) { }, }), }, + { + "empty list", + map[string]*schema.AttributeSchema{ + "attr": { + Expr: schema.ExprConstraints{ + schema.ListExpr{}, + }, + }, + }, + `attr = +`, + hcl.Pos{Line: 1, Column: 8, Byte: 7}, + lang.CompleteCandidates([]lang.Candidate{ + { + Label: "[ ]", + Detail: "list", + TextEdit: lang.TextEdit{ + Range: hcl.Range{ + Filename: "test.tf", + Start: hcl.Pos{Line: 1, Column: 8, Byte: 7}, + End: hcl.Pos{Line: 1, Column: 8, Byte: 7}, + }, + NewText: "[ ]", + Snippet: "[ ${0} ]", + }, + Kind: lang.ListCandidateKind, + }, + }), + }, + { + "multiple traversal constraints in set", + map[string]*schema.AttributeSchema{ + "attr": { + Expr: schema.ExprConstraints{ + schema.SetExpr{ + Elem: schema.ExprConstraints{ + schema.TraversalExpr{OfScopeId: lang.ScopeId("one")}, + schema.TraversalExpr{OfScopeId: lang.ScopeId("two")}, + }, + }, + }, + }, + }, + `attr = +`, + hcl.Pos{Line: 1, Column: 8, Byte: 7}, + lang.CompleteCandidates([]lang.Candidate{ + { + Label: "[ reference ]", + Detail: "set of reference", + TextEdit: lang.TextEdit{ + Range: hcl.Range{ + Filename: "test.tf", + Start: hcl.Pos{Line: 1, Column: 8, Byte: 7}, + End: hcl.Pos{Line: 1, Column: 8, Byte: 7}, + }, + NewText: "[ ]", + Snippet: "[ ${0} ]", + }, + Kind: lang.SetCandidateKind, + TriggerSuggest: true, + }, + }), + }, } for i, tc := range testCases { diff --git a/decoder/expression_constraints.go b/decoder/expression_constraints.go index 40d25b33..f2d2333e 100644 --- a/decoder/expression_constraints.go +++ b/decoder/expression_constraints.go @@ -58,15 +58,6 @@ func (ec ExprConstraints) ObjectExpr() (schema.ObjectExpr, bool) { return schema.ObjectExpr{}, false } -func (ec ExprConstraints) TupleConsExpr() (schema.TupleConsExpr, bool) { - for _, c := range ec { - if tc, ok := c.(schema.TupleConsExpr); ok { - return tc, ok - } - } - return schema.TupleConsExpr{}, false -} - func (ec ExprConstraints) SetExpr() (schema.SetExpr, bool) { for _, c := range ec { if se, ok := c.(schema.SetExpr); ok { diff --git a/decoder/hover.go b/decoder/hover.go index 013d2e1e..ce1d4632 100644 --- a/decoder/hover.go +++ b/decoder/hover.go @@ -318,17 +318,6 @@ func (d *PathDecoder) hoverDataForExpr(ctx context.Context, expr hcl.Expression, Range: expr.Range(), }, nil case *hclsyntax.TupleConsExpr: - tupleCons, ok := constraints.TupleConsExpr() - if ok { - content := fmt.Sprintf("_%s_", tupleCons.FriendlyName()) - if tupleCons.Description.Value != "" { - content += "\n\n" + tupleCons.Description.Value - } - return &lang.HoverData{ - Content: lang.Markdown(content), - Range: expr.Range(), - }, nil - } se, ok := constraints.SetExpr() if ok { for _, elemExpr := range e.Exprs { diff --git a/decoder/hover_expressions_test.go b/decoder/hover_expressions_test.go index 2a70f286..f438a890 100644 --- a/decoder/hover_expressions_test.go +++ b/decoder/hover_expressions_test.go @@ -935,36 +935,6 @@ _object_`), }, nil, }, - { - "tuple constant expression", - map[string]*schema.AttributeSchema{ - "tuplecons": {Expr: schema.ExprConstraints{ - schema.TupleConsExpr{ - Name: "special tuple", - AnyElem: schema.LiteralTypeOnly(cty.String), - }, - }}, - }, - `tuplecons = [ "one", "two" ]`, - hcl.Pos{Line: 1, Column: 18, Byte: 17}, - &lang.HoverData{ - Content: lang.Markdown("_special tuple_"), - Range: hcl.Range{ - Filename: "test.tf", - Start: hcl.Pos{ - Line: 1, - Column: 13, - Byte: 12, - }, - End: hcl.Pos{ - Line: 1, - Column: 29, - Byte: 28, - }, - }, - }, - nil, - }, { "list expression", map[string]*schema.AttributeSchema{ @@ -1266,6 +1236,72 @@ _object_`), }, nil, }, + { + "attribute with multiple constraints", + map[string]*schema.AttributeSchema{ + "attr": { + Expr: schema.ExprConstraints{ + schema.SetExpr{ + Elem: schema.ExprConstraints{ + schema.TraversalExpr{OfScopeId: lang.ScopeId("one")}, + schema.TraversalExpr{OfScopeId: lang.ScopeId("two")}, + }, + }, + }}, + }, + `attr = []`, + hcl.Pos{Line: 1, Column: 3, Byte: 2}, + &lang.HoverData{ + Content: lang.Markdown("**attr** _set of reference_"), + Range: hcl.Range{ + Filename: "test.tf", + Start: hcl.Pos{ + Line: 1, + Column: 1, + Byte: 0, + }, + End: hcl.Pos{ + Line: 1, + Column: 10, + Byte: 9, + }, + }, + }, + nil, + }, + { + "expression with multiple constraints", + map[string]*schema.AttributeSchema{ + "attr": { + Expr: schema.ExprConstraints{ + schema.SetExpr{ + Elem: schema.ExprConstraints{ + schema.TraversalExpr{OfScopeId: lang.ScopeId("one")}, + schema.TraversalExpr{OfScopeId: lang.ScopeId("two")}, + }, + }, + }}, + }, + `attr = [ ]`, + hcl.Pos{Line: 1, Column: 10, Byte: 9}, + &lang.HoverData{ + Content: lang.Markdown("_set of reference_"), + Range: hcl.Range{ + Filename: "test.tf", + Start: hcl.Pos{ + Line: 1, + Column: 8, + Byte: 7, + }, + End: hcl.Pos{ + Line: 1, + Column: 12, + Byte: 11, + }, + }, + }, + nil, + }, } for i, tc := range testCases { diff --git a/decoder/reference_origins.go b/decoder/reference_origins.go index 3ae3454d..5cb942a5 100644 --- a/decoder/reference_origins.go +++ b/decoder/reference_origins.go @@ -197,14 +197,6 @@ func (d *PathDecoder) findOriginsInExpression(expr hcl.Expression, ec schema.Exp switch eType := expr.(type) { case *hclsyntax.TupleConsExpr: - tce, ok := ExprConstraints(ec).TupleConsExpr() - if ok { - for _, elemExpr := range eType.ExprList() { - origins = append(origins, d.findOriginsInExpression(elemExpr, tce.AnyElem, allowSelfRefs)...) - } - break - } - le, ok := ExprConstraints(ec).ListExpr() if ok { for _, elemExpr := range eType.ExprList() { diff --git a/decoder/reference_origins_collect_hcl_test.go b/decoder/reference_origins_collect_hcl_test.go index aabab58b..8be318d1 100644 --- a/decoder/reference_origins_collect_hcl_test.go +++ b/decoder/reference_origins_collect_hcl_test.go @@ -701,49 +701,6 @@ tuple = [ var.third ] }, }, }, - { - "origin inside tuple cons expression", - &schema.BodySchema{ - Attributes: map[string]*schema.AttributeSchema{ - "tuple_cons": { - Expr: schema.ExprConstraints{ - schema.TupleConsExpr{ - AnyElem: schema.ExprConstraints{ - schema.TraversalExpr{ - OfScopeId: lang.ScopeId("test"), - }, - }, - }, - }, - }, - }, - }, - `tuple_cons = [ var.one ]`, - reference.Origins{ - reference.LocalOrigin{ - Addr: lang.Address{ - lang.RootStep{Name: "var"}, - lang.AttrStep{Name: "one"}, - }, - Range: hcl.Range{ - Filename: "test.tf", - Start: hcl.Pos{ - Line: 1, - Column: 16, - Byte: 15, - }, - End: hcl.Pos{ - Line: 1, - Column: 23, - Byte: 22, - }, - }, - Constraints: reference.OriginConstraints{ - {OfScopeId: lang.ScopeId("test")}, - }, - }, - }, - }, { "origin inside object and map expression with multiple matches", &schema.BodySchema{ diff --git a/decoder/reference_origins_collect_json_test.go b/decoder/reference_origins_collect_json_test.go index 9196c1c3..4ea2db08 100644 --- a/decoder/reference_origins_collect_json_test.go +++ b/decoder/reference_origins_collect_json_test.go @@ -692,46 +692,6 @@ func TestCollectReferenceOrigins_json(t *testing.T) { }, }, }, - { - "origin inside tuple cons expression", - &schema.BodySchema{ - Attributes: map[string]*schema.AttributeSchema{ - "tuple_cons": { - Expr: schema.ExprConstraints{ - schema.TupleConsExpr{ - AnyElem: schema.ExprConstraints{ - schema.TraversalExpr{ - OfScopeId: lang.ScopeId("test"), - }, - }, - }, - }, - }, - }, - }, - `{"tuple_cons": [ "${var.one}" ]}`, - reference.Origins{ - reference.LocalOrigin{ - Addr: lang.Address{ - lang.RootStep{Name: "var"}, - lang.AttrStep{Name: "one"}, - }, - Range: hcl.Range{ - Filename: "test.tf.json", - Start: hcl.Pos{ - Line: 1, - Column: 21, - Byte: 20, - }, - End: hcl.Pos{ - Line: 1, - Column: 28, - Byte: 27, - }, - }, - }, - }, - }, { "origin inside object and map expression with multiple matches", &schema.BodySchema{ diff --git a/decoder/reference_targets.go b/decoder/reference_targets.go index 5ce68034..85af9391 100644 --- a/decoder/reference_targets.go +++ b/decoder/reference_targets.go @@ -629,12 +629,6 @@ func referenceTargetsForExpr(expr hcl.Expression, ec ExprConstraints) reference. refs = append(refs, referenceTargetsForExpr(itemExpr, ExprConstraints(te.Elems[i]))...) } } - tce, ok := ec.TupleConsExpr() - if ok { - for _, itemExpr := range e.Exprs { - refs = append(refs, referenceTargetsForExpr(itemExpr, ExprConstraints(tce.AnyElem))...) - } - } } return refs diff --git a/decoder/semantic_tokens.go b/decoder/semantic_tokens.go index 792c7e0c..9ab1260b 100644 --- a/decoder/semantic_tokens.go +++ b/decoder/semantic_tokens.go @@ -276,14 +276,6 @@ func (d *PathDecoder) tokensForExpression(ctx context.Context, expr hclsyntax.Ex case *hclsyntax.TemplateWrapExpr: return d.tokensForExpression(ctx, eType.Wrapped, constraints) case *hclsyntax.TupleConsExpr: - tc, ok := constraints.TupleConsExpr() - if ok { - ec := ExprConstraints(tc.AnyElem) - for _, expr := range eType.Exprs { - tokens = append(tokens, d.tokensForExpression(ctx, expr, ec)...) - } - return tokens - } se, ok := constraints.SetExpr() if ok { ec := ExprConstraints(se.Elem) diff --git a/decoder/semantic_tokens_expr_test.go b/decoder/semantic_tokens_expr_test.go index 3a4e95b3..7705da6b 100644 --- a/decoder/semantic_tokens_expr_test.go +++ b/decoder/semantic_tokens_expr_test.go @@ -902,73 +902,6 @@ EOT }, }, }, - { - "tuple constant expression", - map[string]*schema.AttributeSchema{ - "attr": { - Expr: schema.ExprConstraints{ - schema.TupleConsExpr{ - AnyElem: schema.LiteralTypeOnly(cty.String), - }, - }, - }, - }, - `attr = [ "one", 42, "two" ] -`, - []lang.SemanticToken{ - { // attr - Type: lang.TokenAttrName, - Modifiers: []lang.SemanticTokenModifier{}, - Range: hcl.Range{ - Filename: "test.tf", - Start: hcl.Pos{ - Line: 1, - Column: 1, - Byte: 0, - }, - End: hcl.Pos{ - Line: 1, - Column: 5, - Byte: 4, - }, - }, - }, - { // "one" - Type: lang.TokenString, - Modifiers: []lang.SemanticTokenModifier{}, - Range: hcl.Range{ - Filename: "test.tf", - Start: hcl.Pos{ - Line: 1, - Column: 10, - Byte: 9, - }, - End: hcl.Pos{ - Line: 1, - Column: 15, - Byte: 14, - }, - }, - }, - { // "two" - Type: lang.TokenString, - Modifiers: []lang.SemanticTokenModifier{}, - Range: hcl.Range{ - Filename: "test.tf", - Start: hcl.Pos{ - Line: 1, - Column: 21, - Byte: 20, - }, - End: hcl.Pos{ - Line: 1, - Column: 26, - Byte: 25, - }, - }, - }, - }, - }, { "list expression", map[string]*schema.AttributeSchema{ diff --git a/schema/expressions.go b/schema/expressions.go index 396ca940..f84022fa 100644 --- a/schema/expressions.go +++ b/schema/expressions.go @@ -124,33 +124,6 @@ func (lv LiteralValue) Copy() ExprConstraint { } } -// TODO: Consider removing TupleConsExpr -// in favour of ListExpr, SetExpr and TupleExpr -type TupleConsExpr struct { - AnyElem ExprConstraints - Name string - Description lang.MarkupContent -} - -func (TupleConsExpr) isExprConstraintImpl() exprConstrSigil { - return exprConstrSigil{} -} - -func (tc TupleConsExpr) FriendlyName() string { - if tc.Name == "" { - return "tuple" - } - return tc.Name -} - -func (tc TupleConsExpr) Copy() ExprConstraint { - return TupleConsExpr{ - AnyElem: tc.AnyElem.Copy(), - Name: tc.Name, - Description: tc.Description, - } -} - type ListExpr struct { Elem ExprConstraints Description lang.MarkupContent diff --git a/schema/expressions_test.go b/schema/expressions_test.go index 3decc2b4..236aa200 100644 --- a/schema/expressions_test.go +++ b/schema/expressions_test.go @@ -11,7 +11,6 @@ var ( _ ExprConstraint = ObjectExpr{} _ ExprConstraint = SetExpr{} _ ExprConstraint = TraversalExpr{} - _ ExprConstraint = TupleConsExpr{} _ ExprConstraint = TupleExpr{} _ ExprConstraint = TypeDeclarationExpr{} )