diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index aad725e94..2feb29c44 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -186,6 +186,7 @@ toTermName source term = case unwrap term of S.Commented _ _ -> termNameFromChildren term (toList $ unwrap term) S.Module identifier _ -> toTermName' identifier S.Import identifier _ -> toTermName' identifier + S.Export expr -> intercalate ", " $ termNameFromSource <$> expr where toTermName' = toTermName source termNameFromChildren term children = termNameFromRange (unionRangesFrom (range term) (range <$> children)) termNameFromSource term = termNameFromRange (range term) @@ -310,6 +311,7 @@ instance HasCategory Category where C.Empty -> "empty statement" C.Module -> "module statement" C.Import -> "import statement" + C.Export -> "export statement" instance HasField fields Category => HasCategory (SyntaxTerm leaf fields) where toCategoryName = toCategoryName . category . extract diff --git a/src/Language/JavaScript.hs b/src/Language/JavaScript.hs index d8eba9564..c07798127 100644 --- a/src/Language/JavaScript.hs +++ b/src/Language/JavaScript.hs @@ -68,6 +68,7 @@ termConstructor source sourceSpan name range children ("class", [ identifier, superclass, definitions ]) -> S.Class identifier (Just superclass) (toList (unwrap definitions)) ("class", [ identifier, definitions ]) -> S.Class identifier Nothing (toList (unwrap definitions)) ("import_statement", [ statements, identifier ] ) -> S.Import identifier statements + ("export_statement", [ statements ] ) -> S.Export (toList (unwrap statements)) _ | name `elem` forStatements, Just (exprs, body) <- unsnoc children -> S.For exprs body _ | name `elem` operators -> S.Operator children _ | name `elem` functions -> case children of @@ -144,6 +145,7 @@ categoryForJavaScriptProductionName name = case name of "bitwise_op" -> BitwiseOperator "rel_op" -> RelationalOperator "import_statement" -> Import + "export_statement" -> Export _ -> Other name toVarDecl :: (HasField fields Category) => Term (S.Syntax Text) (Record fields) -> Term (S.Syntax Text) (Record fields) diff --git a/src/Syntax.hs b/src/Syntax.hs index 5c1f44fcc..aa4863ea4 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -75,6 +75,7 @@ data Syntax a f -- | A module with an identifier, and a list of syntaxes. | Module { moduleId:: f, moduleBody :: [f] } | Import f f + | Export [f] deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable)