From bb5044d015a4dd37c6c43b387d491e7888a50503 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Sat, 20 May 2017 17:40:03 -0700 Subject: [PATCH] Range and StartRange methods on Expression This gives us some contextual information to use for error handling when working generically with expressions. --- zcl/json/structure.go | 8 ++++++++ zcl/structure.go | 3 +++ 2 files changed, 11 insertions(+) diff --git a/zcl/json/structure.go b/zcl/json/structure.go index 6ad28ab..0b39861 100644 --- a/zcl/json/structure.go +++ b/zcl/json/structure.go @@ -259,3 +259,11 @@ func (e *expression) Value(ctx *zcl.EvalContext) (cty.Value, zcl.Diagnostics) { return cty.DynamicVal, nil } } + +func (e *expression) Range() zcl.Range { + return e.src.Range() +} + +func (e *expression) StartRange() zcl.Range { + return e.src.StartRange() +} diff --git a/zcl/structure.go b/zcl/structure.go index 877b33d..96a9857 100644 --- a/zcl/structure.go +++ b/zcl/structure.go @@ -101,6 +101,9 @@ type Expression interface { // the specific symbol in question. Value(ctx *EvalContext) (cty.Value, Diagnostics) + Range() Range + StartRange() Range + // TODO: A "Variables" method that returns a description of all of the // variables used in the expression, so callers can populate the scope // only with variables that are actually used.