Range and StartRange methods on Expression

This gives us some contextual information to use for error handling when
working generically with expressions.
This commit is contained in:
Martin Atkins 2017-05-20 17:40:03 -07:00
parent 802ea19d72
commit bb5044d015
2 changed files with 11 additions and 0 deletions

View File

@ -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()
}

View File

@ -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.