-
Notifications
You must be signed in to change notification settings - Fork 8
/
types.go
54 lines (45 loc) · 1.3 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package tfschema
import (
lsp "github.com/Azure/azapi-lsp/internal/protocol"
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hclsyntax"
)
var Resources []Resource
type Resource struct {
Name string
Properties []Property
}
type Property struct {
Name string
Modifier string
Type string
Description string
CompletionNewText string
GenericCandidatesFunc GenericCandidatesFunc
ValueCandidatesFunc ValueCandidatesFunc
NestedProperties []Property
}
func (r *Resource) GetProperty(propertyName string) *Property {
if r == nil {
return nil
}
for _, prop := range r.Properties {
if prop.Name == propertyName {
return &prop
}
}
return nil
}
type GenericCandidatesFunc func(data []byte, filename string, block *hclsyntax.Block, attribute *hclsyntax.Attribute, pos hcl.Pos, property *Property) []lsp.CompletionItem
type ValueCandidatesFunc func(prefix *string, r lsp.Range) []lsp.CompletionItem
var _ ValueCandidatesFunc = FixedValueCandidatesFunc(nil)
func FixedValueCandidatesFunc(fixedItems []lsp.CompletionItem) ValueCandidatesFunc {
return func(prefix *string, r lsp.Range) []lsp.CompletionItem {
for i := range fixedItems {
if fixedItems[i].TextEdit != nil {
fixedItems[i].TextEdit.Range = r
}
}
return fixedItems
}
}