1
1
mirror of https://github.com/github/semantic.git synced 2025-01-02 20:41:38 +03:00

Add Diff Summary support for Export Syntax

This commit is contained in:
Rick Winfrey 2016-10-06 15:46:59 -05:00
parent 6199444e91
commit 3ca3d9f035
3 changed files with 5 additions and 0 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)