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:
parent
6199444e91
commit
3ca3d9f035
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user