From 2bb7ec94ac514c7a07342216f0bf7be547d2fe5d Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 11 Jan 2017 15:10:12 -0800 Subject: [PATCH] Add field declaration mapping --- src/Language/Go.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Language/Go.hs b/src/Language/Go.hs index 26e0456f8..4c7017f60 100644 --- a/src/Language/Go.hs +++ b/src/Language/Go.hs @@ -43,6 +43,7 @@ termConstructor source sourceSpan name range children _ = case name of "type_declaration" -> toTypeDecls children "type_spec" -> toTypeDecl children "struct_type" -> toStruct children + "field_declaration" -> toFieldDecl children "expression_switch_statement" -> case Prologue.break isCaseClause children of (clauses, cases) -> do @@ -121,7 +122,10 @@ termConstructor source sourceSpan name range children _ = case name of [ty] -> withCategory Struct (S.Struct (Just ty) []) [ty, values] -> withCategory Struct (S.Struct (Just ty) (toList $ unwrap values)) rest -> withRanges range Error rest $ S.Error rest - + toFieldDecl = \case + [identifier, ty] -> withCategory FieldDecl (S.FieldDecl identifier (Just ty)) + [identifier] -> withCategory FieldDecl (S.FieldDecl identifier Nothing) + rest -> withRanges range Error rest $ S.Error rest toExpression f = \case [expr] -> f expr