diff --git a/src/Parsing/TreeSitter.hs b/src/Parsing/TreeSitter.hs index f61217b83..41bc30987 100644 --- a/src/Parsing/TreeSitter.hs +++ b/src/Parsing/TreeSitter.hs @@ -1,5 +1,11 @@ -{-# LANGUAGE DataKinds, DeriveGeneric, FlexibleContexts, GADTs, LambdaCase, RecordWildCards, ScopedTypeVariables, - TypeOperators #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeOperators #-} module Parsing.TreeSitter ( TSParseException (..) , Duration(..) @@ -7,16 +13,19 @@ module Parsing.TreeSitter , parseToPreciseAST ) where -import Prologue - -import Control.Carrier.Reader -import qualified Control.Exception as Exc -import Foreign -import Foreign.C.Types (CBool (..)) +import Control.Carrier.Reader +import Control.Exception as Exc +import Control.Monad +import Control.Monad.IO.Class +import Data.Functor.Foldable +import Foreign +import Foreign.C.Types (CBool (..)) +import GHC.Generics import Data.AST (AST, Node (Node)) import Data.Blob import Data.Duration +import Data.Maybe.Exts import Data.Term import Source.Loc import qualified Source.Source as Source @@ -67,7 +76,7 @@ parseToPreciseAST parseTimeout unmarshalTimeout language blob = runParse parseTi withTimeout :: IO a -> IO a withTimeout action = System.timeout (toMicroseconds unmarshalTimeout) action >>= maybeM (Exc.throw UnmarshalTimedOut) -instance Exception TSParseException where +instance Exc.Exception TSParseException where displayException = \case ParserTimedOut -> "tree-sitter: parser timed out" IncompatibleVersions -> "tree-sitter: incompatible versions"