Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace fallthrough statements with case clause lists #395

Merged
merged 2 commits into from Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions language/parser/parser.go
Expand Up @@ -601,9 +601,7 @@ func parseValueLiteral(parser *Parser, isConst bool) (ast.Value, error) {
Value: token.Value,
Loc: loc(parser, token.Start),
}), nil
case lexer.TokenKind[lexer.BLOCK_STRING]:
fallthrough
case lexer.TokenKind[lexer.STRING]:
case lexer.TokenKind[lexer.BLOCK_STRING], lexer.TokenKind[lexer.STRING]:
return parseStringLiteral(parser)
case lexer.TokenKind[lexer.NAME]:
if token.Value == "true" || token.Value == "false" {
Expand Down
10 changes: 2 additions & 8 deletions type_info.go
Expand Up @@ -206,11 +206,7 @@ func (ti *TypeInfo) Leave(node ast.Node) {
}
case kinds.Directive:
ti.directive = nil
case kinds.OperationDefinition:
fallthrough
case kinds.InlineFragment:
fallthrough
case kinds.FragmentDefinition:
case kinds.OperationDefinition, kinds.InlineFragment, kinds.FragmentDefinition:
// pop ti.typeStack
if len(ti.typeStack) > 0 {
_, ti.typeStack = ti.typeStack[len(ti.typeStack)-1], ti.typeStack[:len(ti.typeStack)-1]
Expand All @@ -226,9 +222,7 @@ func (ti *TypeInfo) Leave(node ast.Node) {
if len(ti.inputTypeStack) > 0 {
_, ti.inputTypeStack = ti.inputTypeStack[len(ti.inputTypeStack)-1], ti.inputTypeStack[:len(ti.inputTypeStack)-1]
}
case kinds.ListValue:
fallthrough
case kinds.ObjectField:
case kinds.ListValue, kinds.ObjectField:
// pop ti.inputTypeStack
if len(ti.inputTypeStack) > 0 {
_, ti.inputTypeStack = ti.inputTypeStack[len(ti.inputTypeStack)-1], ti.inputTypeStack[:len(ti.inputTypeStack)-1]
Expand Down
24 changes: 4 additions & 20 deletions util.go
Expand Up @@ -75,17 +75,9 @@ func getGraphType(tipe reflect.Type) Output {
switch kind {
case reflect.String:
return String
case reflect.Int:
fallthrough
case reflect.Int8:
fallthrough
case reflect.Int32:
fallthrough
case reflect.Int64:
case reflect.Int, reflect.Int8, reflect.Int32, reflect.Int64:
return Int
case reflect.Float32:
fallthrough
case reflect.Float64:
case reflect.Float32, reflect.Float64:
return Float
case reflect.Bool:
return Boolean
Expand All @@ -98,19 +90,11 @@ func getGraphType(tipe reflect.Type) Output {
func getGraphList(tipe reflect.Type) *List {
if tipe.Kind() == reflect.Slice {
switch tipe.Elem().Kind() {
case reflect.Int:
fallthrough
case reflect.Int8:
fallthrough
case reflect.Int32:
fallthrough
case reflect.Int64:
case reflect.Int, reflect.Int8, reflect.Int32, reflect.Int64:
return NewList(Int)
case reflect.Bool:
return NewList(Boolean)
case reflect.Float32:
fallthrough
case reflect.Float64:
case reflect.Float32, reflect.Float64:
return NewList(Float)
case reflect.String:
return NewList(String)
Expand Down