mirror of
https://github.com/github/semantic.git
synced 2024-12-11 08:45:48 +03:00
Cherry-pick d51d7a3aee4c3f8dbf3b54d0d83154506542c408
This commit is contained in:
parent
692bc8ec96
commit
e56374f8ba
@ -119,12 +119,14 @@ syntaxDeclarationAlgebra Blob{..} (a :< r) = case r of
|
||||
where getSource = toText . flip Source.slice blobSource . byteRange . extract
|
||||
|
||||
-- | Compute 'Declaration's for methods and functions.
|
||||
declarationAlgebra :: (Declaration.Function :< fs, Declaration.Method :< fs, Syntax.Error :< fs, Apply1 Functor fs, HasField fields Range, HasField fields Span)
|
||||
declarationAlgebra :: (Declaration.Function :< fs, Declaration.Method :< fs, Syntax.Error :< fs, Syntax.Empty :< fs, Apply1 Functor fs, HasField fields Range, HasField fields Span)
|
||||
=> Blob
|
||||
-> RAlgebra (TermF (Union fs) (Record fields)) (Term (Union fs) (Record fields)) (Maybe Declaration)
|
||||
declarationAlgebra blob@Blob{..} (a :< r)
|
||||
| Just (Declaration.Function _ (identifier, _) _ _) <- prj r = Just $ FunctionDeclaration (getSource (extract identifier))
|
||||
| Just (Declaration.Method _ _ (identifier, _) _ _) <- prj r = Just $ MethodDeclaration (getSource (extract identifier))
|
||||
| Just (Declaration.Method _ (receiver, _) (identifier, _) _ _) <- prj r
|
||||
, Just Syntax.Empty <- prj (unwrap receiver) = Just $ MethodDeclaration (getSource (extract identifier))
|
||||
| Just (Declaration.Method _ (receiver, _) (identifier, _) _ _) <- prj r = Just $ MethodDeclaration (getSource (extract receiver) <> "." <> getSource (extract identifier))
|
||||
| Just err@Syntax.Error{} <- prj r = Just $ ErrorDeclaration (T.pack (formatError False False blob (Syntax.unError (sourceSpan a) err))) blobLanguage
|
||||
| otherwise = Nothing
|
||||
where getSource = toText . flip Source.slice blobSource . byteRange
|
||||
|
@ -35,6 +35,7 @@ diffWithParser :: (HasField fields Data.Span.Span,
|
||||
Error :< fs,
|
||||
Declaration.Method :< fs,
|
||||
Declaration.Function :< fs,
|
||||
Empty :< fs,
|
||||
Apply1 Eq1 fs, Apply1 Show1 fs,
|
||||
Apply1 Traversable fs, Apply1 Functor fs,
|
||||
Apply1 Foldable fs, Apply1 Diffable fs,
|
||||
|
Loading…
Reference in New Issue
Block a user