File tree 6 files changed +48
-34
lines changed
6 files changed +48
-34
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,6 @@ import (
10
10
lsp "github.com/sourcegraph/go-lsp"
11
11
)
12
12
13
- type ConfigBlock interface {
14
- CompletionItemsAtPos (pos hcl.Pos ) (lsp.CompletionList , error )
15
- Name () string
16
- BlockType () string
17
- }
18
-
19
13
type configBlockFactory interface {
20
14
New (* hclsyntax.Block ) (ConfigBlock , error )
21
15
}
Original file line number Diff line number Diff line change @@ -6,11 +6,6 @@ import (
6
6
tfjson "github.com/hashicorp/terraform-json"
7
7
)
8
8
9
- type Attribute struct {
10
- schema * tfjson.SchemaAttribute
11
- hclAttribute * hcl.Attribute
12
- }
13
-
14
9
func (a * Attribute ) Schema () * tfjson.SchemaAttribute {
15
10
return a .schema
16
11
}
Original file line number Diff line number Diff line change @@ -6,11 +6,6 @@ import (
6
6
tfjson "github.com/hashicorp/terraform-json"
7
7
)
8
8
9
- type BlockType struct {
10
- BlockList []Block
11
- schema * tfjson.SchemaBlockType
12
- }
13
-
14
9
func (b * BlockType ) Schema () * tfjson.SchemaBlockType {
15
10
return b .schema
16
11
}
Original file line number Diff line number Diff line change @@ -8,17 +8,6 @@ import (
8
8
tfjson "github.com/hashicorp/terraform-json"
9
9
)
10
10
11
- // Block implements an abstraction above HCL block
12
- // and both tfjson's SchemaBlock & SchemaBlockType
13
- type Block interface {
14
- BlockAtPos (pos hcl.Pos ) (Block , bool )
15
- Range () hcl.Range
16
- PosInBody (pos hcl.Pos ) bool
17
- PosInAttribute (pos hcl.Pos ) bool
18
- Attributes () map [string ]* Attribute
19
- BlockTypes () map [string ]* BlockType
20
- }
21
-
22
11
// ParseBlock parses HCL configuration based on tfjson's SchemaBlock
23
12
// and keeps hold of all tfjson schema details on block or attribute level
24
13
func ParseBlock (block * hclsyntax.Block , schema * tfjson.SchemaBlock ) Block {
Original file line number Diff line number Diff line change @@ -23,13 +23,6 @@ import (
23
23
// (e.g. meta-parameters)
24
24
const parserVersionConstraint = ">= 0.12.0"
25
25
26
- type Parser interface {
27
- SetLogger (* log.Logger )
28
- SetCapabilities (lsp.TextDocumentClientCapabilities )
29
- SetSchemaReader (schema.Reader )
30
- ParseBlockFromHCL (* hcl.Block ) (ConfigBlock , error )
31
- }
32
-
33
26
type parser struct {
34
27
logger * log.Logger
35
28
caps lsp.TextDocumentClientCapabilities
Original file line number Diff line number Diff line change
1
+ package lang
2
+
3
+ import (
4
+ "log"
5
+
6
+ hcl "github.com/hashicorp/hcl/v2"
7
+ tfjson "github.com/hashicorp/terraform-json"
8
+ "github.com/hashicorp/terraform-ls/internal/terraform/schema"
9
+ lsp "github.com/sourcegraph/go-lsp"
10
+ )
11
+
12
+ // Parser implements a parser which can turn raw HCL block
13
+ // into ConfigBlock with the help of a schema reader
14
+ type Parser interface {
15
+ SetLogger (* log.Logger )
16
+ SetCapabilities (lsp.TextDocumentClientCapabilities )
17
+ SetSchemaReader (schema.Reader )
18
+ ParseBlockFromHCL (* hcl.Block ) (ConfigBlock , error )
19
+ }
20
+
21
+ // ConfigBlock implements an abstraction above HCL block
22
+ // which provides any LSP capabilities (e.g. completion)
23
+ type ConfigBlock interface {
24
+ CompletionItemsAtPos (pos hcl.Pos ) (lsp.CompletionList , error )
25
+ Name () string
26
+ BlockType () string
27
+ }
28
+
29
+ // Block represents a decoded HCL block (by a Parser)
30
+ // which keeps track of the related schema
31
+ type Block interface {
32
+ BlockAtPos (pos hcl.Pos ) (Block , bool )
33
+ Range () hcl.Range
34
+ PosInBody (pos hcl.Pos ) bool
35
+ PosInAttribute (pos hcl.Pos ) bool
36
+ Attributes () map [string ]* Attribute
37
+ BlockTypes () map [string ]* BlockType
38
+ }
39
+
40
+ type BlockType struct {
41
+ BlockList []Block
42
+ schema * tfjson.SchemaBlockType
43
+ }
44
+
45
+ type Attribute struct {
46
+ schema * tfjson.SchemaAttribute
47
+ hclAttribute * hcl.Attribute
48
+ }
You can’t perform that action at this time.
0 commit comments