1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 14:54:16 +03:00

🔥 the language field for no lang exceptions.

This commit is contained in:
Rob Rix 2017-11-21 12:48:58 -05:00
parent e41da0fed4
commit f2a29b35f3

View File

@ -24,7 +24,6 @@ import Data.Syntax.Algebra
import Data.Term
import Data.Typeable
import Interpreter
import qualified Language
import Parser
import Renderer
import Semantic.Task as Task
@ -61,9 +60,9 @@ parseBlob renderer blob@Blob{..} = case (renderer, blobLanguage) of
| Just (SomeParser parser) <- someParser (Proxy :: Proxy '[HasDeclaration, Foldable, Functor]) <$> lang ->
parse parser blob >>= decorate (declarationAlgebra blob) >>= render (renderToTags blob)
_ -> throwError (SomeException (NoLanguageForBlob blobPath blobLanguage))
_ -> throwError (SomeException (NoLanguageForBlob blobPath))
data NoLanguageForBlob = NoLanguageForBlob FilePath (Maybe Language.Language)
data NoLanguageForBlob = NoLanguageForBlob FilePath
deriving (Eq, Exception, Ord, Show, Typeable)
@ -89,7 +88,7 @@ diffBlobPair renderer blobs = case (renderer, effectiveLanguage) of
| Just (SomeParser parser) <- someParser (Proxy :: Proxy '[ConstructorName, Diffable, Eq1, Foldable, Functor, GAlign, Show1, Traversable]) <$> lang ->
run (decorate constructorLabel . (Nil <$) <=< parse parser) diffTerms renderSExpressionDiff
_ -> throwError (SomeException (NoLanguageForBlob effectivePath effectiveLanguage))
_ -> throwError (SomeException (NoLanguageForBlob effectivePath))
where (effectivePath, effectiveLanguage) = case runJoin blobs of
(Blob { blobLanguage = Just lang, blobPath = path }, _) -> (path, Just lang)
(_, Blob { blobLanguage = Just lang, blobPath = path }) -> (path, Just lang)