aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/hcl2/hcl/diagnostic.go
diff options
context:
space:
mode:
authorNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
committerNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
commit107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch)
treeca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/hashicorp/hcl2/hcl/diagnostic.go
parent844b5a68d8af4791755b8f0ad293cc99f5959183 (diff)
downloadterraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/hashicorp/hcl2/hcl/diagnostic.go')
-rw-r--r--vendor/github.com/hashicorp/hcl2/hcl/diagnostic.go42
1 files changed, 41 insertions, 1 deletions
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/diagnostic.go b/vendor/github.com/hashicorp/hcl2/hcl/diagnostic.go
index 6ecf744..c320961 100644
--- a/vendor/github.com/hashicorp/hcl2/hcl/diagnostic.go
+++ b/vendor/github.com/hashicorp/hcl2/hcl/diagnostic.go
@@ -26,14 +26,43 @@ const (
26type Diagnostic struct { 26type Diagnostic struct {
27 Severity DiagnosticSeverity 27 Severity DiagnosticSeverity
28 28
29 // Summary and detail contain the English-language description of the 29 // Summary and Detail contain the English-language description of the
30 // problem. Summary is a terse description of the general problem and 30 // problem. Summary is a terse description of the general problem and
31 // detail is a more elaborate, often-multi-sentence description of 31 // detail is a more elaborate, often-multi-sentence description of
32 // the probem and what might be done to solve it. 32 // the probem and what might be done to solve it.
33 Summary string 33 Summary string
34 Detail string 34 Detail string
35
36 // Subject and Context are both source ranges relating to the diagnostic.
37 //
38 // Subject is a tight range referring to exactly the construct that
39 // is problematic, while Context is an optional broader range (which should
40 // fully contain Subject) that ought to be shown around Subject when
41 // generating isolated source-code snippets in diagnostic messages.
42 // If Context is nil, the Subject is also the Context.
43 //
44 // Some diagnostics have no source ranges at all. If Context is set then
45 // Subject should always also be set.
35 Subject *Range 46 Subject *Range
36 Context *Range 47 Context *Range
48
49 // For diagnostics that occur when evaluating an expression, Expression
50 // may refer to that expression and EvalContext may point to the
51 // EvalContext that was active when evaluating it. This may allow for the
52 // inclusion of additional useful information when rendering a diagnostic
53 // message to the user.
54 //
55 // It is not always possible to select a single EvalContext for a
56 // diagnostic, and so in some cases this field may be nil even when an
57 // expression causes a problem.
58 //
59 // EvalContexts form a tree, so the given EvalContext may refer to a parent
60 // which in turn refers to another parent, etc. For a full picture of all
61 // of the active variables and functions the caller must walk up this
62 // chain, preferring definitions that are "closer" to the expression in
63 // case of colliding names.
64 Expression Expression
65 EvalContext *EvalContext
37} 66}
38 67
39// Diagnostics is a list of Diagnostic instances. 68// Diagnostics is a list of Diagnostic instances.
@@ -96,6 +125,17 @@ func (d Diagnostics) HasErrors() bool {
96 return false 125 return false
97} 126}
98 127
128func (d Diagnostics) Errs() []error {
129 var errs []error
130 for _, diag := range d {
131 if diag.Severity == DiagError {
132 errs = append(errs, diag)
133 }
134 }
135
136 return errs
137}
138
99// A DiagnosticWriter emits diagnostics somehow. 139// A DiagnosticWriter emits diagnostics somehow.
100type DiagnosticWriter interface { 140type DiagnosticWriter interface {
101 WriteDiagnostic(*Diagnostic) error 141 WriteDiagnostic(*Diagnostic) error