mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
parserForLanguage does not take its argument in Maybe.
This commit is contained in:
parent
32055efa42
commit
2f05a32997
@ -54,9 +54,8 @@ data Parser term where
|
||||
LineByLineParser :: Parser (Term Syntax (Record DefaultFields))
|
||||
|
||||
-- | Return a 'Language'-specific 'Parser', if one exists, falling back to the 'LineByLineParser'.
|
||||
parserForLanguage :: Maybe Language -> Parser (Term Syntax (Record DefaultFields))
|
||||
parserForLanguage Nothing = LineByLineParser
|
||||
parserForLanguage (Just language) = case language of
|
||||
parserForLanguage :: Language -> Parser (Term Syntax (Record DefaultFields))
|
||||
parserForLanguage language = case language of
|
||||
Go -> TreeSitterParser tree_sitter_go
|
||||
JavaScript -> TreeSitterParser tree_sitter_typescript
|
||||
JSON -> TreeSitterParser tree_sitter_json
|
||||
|
@ -62,7 +62,7 @@ parseBlob renderer blob@Blob{..} = case (renderer, blobLanguage) of
|
||||
(IdentityTermRenderer, Just Language.Python) -> pure Nothing
|
||||
(IdentityTermRenderer, Just Language.TypeScript) -> pure Nothing
|
||||
(IdentityTermRenderer, _) -> Just <$> parse syntaxParser blob
|
||||
where syntaxParser = parserForLanguage blobLanguage
|
||||
where syntaxParser = maybe LineByLineParser parserForLanguage blobLanguage
|
||||
|
||||
|
||||
diffBlobPairs :: Output output => DiffRenderer output -> [Both Blob] -> Task ByteString
|
||||
@ -101,7 +101,7 @@ diffBlobPair renderer blobs = case (renderer, effectiveLanguage) of
|
||||
(SExpressionDiffRenderer, _) -> run (parse syntaxParser) diffSyntaxTerms (renderSExpressionDiff . bimap keepCategory keepCategory)
|
||||
(IdentityDiffRenderer, _) -> run (\ blob -> parse syntaxParser blob >>= decorate (syntaxDeclarationAlgebra blob)) diffSyntaxTerms Just
|
||||
where effectiveLanguage = runBothWith (<|>) (blobLanguage <$> blobs)
|
||||
syntaxParser = parserForLanguage effectiveLanguage
|
||||
syntaxParser = maybe LineByLineParser parserForLanguage effectiveLanguage
|
||||
|
||||
run :: Functor syntax => (Blob -> Task (Term syntax ann)) -> (Term syntax ann -> Term syntax ann -> Diff syntax ann ann) -> (Diff syntax ann ann -> output) -> Task output
|
||||
run parse diff renderer = distributeFor blobs parse >>= runBothWith (diffTermPair blobs diff) >>= render renderer
|
||||
|
Loading…
Reference in New Issue
Block a user