Skip to content

Commit

Permalink
renamed lexer.Literal to lexer.BasicLit
Browse files Browse the repository at this point in the history
  • Loading branch information
neelance committed May 23, 2017
1 parent 88c492b commit a9de617
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion internal/common/stringify.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func Stringify(v interface{}) string {
switch v := v.(type) {
case *lexer.Literal:
case *lexer.BasicLit:
return v.Text

case []interface{}:
Expand Down
2 changes: 1 addition & 1 deletion internal/common/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func parseValue(l *lexer.Lexer, constOnly bool) interface{} {
}
}

func UnmarshalLiteral(lit *lexer.Literal) interface{} {
func UnmarshalLiteral(lit *lexer.BasicLit) interface{} {
switch lit.Type {
case scanner.Int, scanner.Float:
value, err := strconv.ParseFloat(lit.Text, 64)
Expand Down
4 changes: 2 additions & 2 deletions internal/exec/resolvable/packer.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (p *ValuePacker) Pack(r *Request, value interface{}) (reflect.Value, error)
return reflect.Value{}, errors.Errorf("got null for non-null")
}

if lit, ok := value.(*lexer.Literal); ok {
if lit, ok := value.(*lexer.BasicLit); ok {
value = common.UnmarshalLiteral(lit)
}

Expand All @@ -282,7 +282,7 @@ func (p *unmarshalerPacker) Pack(r *Request, value interface{}) (reflect.Value,
return reflect.Value{}, errors.Errorf("got null for non-null")
}

if lit, ok := value.(*lexer.Literal); ok {
if lit, ok := value.(*lexer.BasicLit); ok {
value = common.UnmarshalLiteral(lit)
}

Expand Down
4 changes: 2 additions & 2 deletions internal/lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Lexer struct {
descComment string
}

type Literal struct {
type BasicLit struct {
Type rune
Text string
}
Expand Down Expand Up @@ -106,7 +106,7 @@ func (l *Lexer) ConsumeVariable() Variable {
}

func (l *Lexer) ConsumeLiteral() interface{} {
lit := &Literal{Type: l.next, Text: l.sc.TokenText()}
lit := &BasicLit{Type: l.next, Text: l.sc.TokenText()}
l.Consume()
if lit.Type == scanner.Ident && lit.Text == "null" {
return nil
Expand Down
4 changes: 2 additions & 2 deletions internal/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func validateValue(v interface{}, t common.Type) (bool, string) {
return true, ""
}

if v, ok := v.(*lexer.Literal); ok {
if v, ok := v.(*lexer.BasicLit); ok {
if validateLiteral(v, t) {
return true, ""
}
Expand Down Expand Up @@ -467,7 +467,7 @@ func validateValue(v interface{}, t common.Type) (bool, string) {
return false, fmt.Sprintf("Expected type %q, found %s.", t, common.Stringify(v))
}

func validateLiteral(v *lexer.Literal, t common.Type) bool {
func validateLiteral(v *lexer.BasicLit, t common.Type) bool {
switch t := t.(type) {
case *schema.Scalar:
switch t.Name {
Expand Down
4 changes: 2 additions & 2 deletions introspection/introspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (r *Field) DeprecationReason() *string {
if d == nil {
return nil
}
reason := common.UnmarshalLiteral(d.Args.MustGet("reason").Value.(*lexer.Literal)).(string)
reason := common.UnmarshalLiteral(d.Args.MustGet("reason").Value.(*lexer.BasicLit)).(string)
return &reason
}

Expand Down Expand Up @@ -282,7 +282,7 @@ func (r *EnumValue) DeprecationReason() *string {
if d == nil {
return nil
}
reason := common.UnmarshalLiteral(d.Args.MustGet("reason").Value.(*lexer.Literal)).(string)
reason := common.UnmarshalLiteral(d.Args.MustGet("reason").Value.(*lexer.BasicLit)).(string)
return &reason
}

Expand Down

0 comments on commit a9de617

Please sign in to comment.