Skip to content

Commit

Permalink
Merge pull request #395 from Quasilyte/quasilyte/emptyFallthrough
Browse files Browse the repository at this point in the history
replace fallthrough statements with case clause lists
  • Loading branch information
chris-ramon committed Sep 11, 2018
2 parents 65dbc73 + e923a57 commit 4f37645
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
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

0 comments on commit 4f37645

Please sign in to comment.