mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Seconds -> milliseconds
This commit is contained in:
parent
3eb550ac62
commit
dd23a2c513
@ -25,9 +25,10 @@ import qualified TreeSitter.Node as TS
|
||||
import qualified TreeSitter.Parser as TS
|
||||
import qualified TreeSitter.Tree as TS
|
||||
|
||||
newtype Timeout = Seconds Int
|
||||
newtype Timeout = Milliseconds Int
|
||||
|
||||
-- Change this to putStrLn if you want to debug the locking/cancellation code.
|
||||
-- TODO: Someday we should run this all in Eff so that we can 'trace'.
|
||||
dbg :: String -> IO ()
|
||||
dbg = const (pure ())
|
||||
|
||||
@ -54,8 +55,8 @@ runParser parser blobSource = unsafeUseAsCStringLen (sourceBytes blobSource) $
|
||||
-- | Parse 'Source' with the given 'TS.Language' and return its AST.
|
||||
-- Returns Nothing if the operation timed out.
|
||||
parseToAST :: (Bounded grammar, Enum grammar) => Timeout -> Ptr TS.Language -> Blob -> IO (Maybe (AST [] grammar))
|
||||
parseToAST (Seconds s) language Blob{..} = bracket TS.ts_parser_new TS.ts_parser_delete $ \ parser -> do
|
||||
let parserTimeout = s * 1000000
|
||||
parseToAST (Milliseconds s) language Blob{..} = bracket TS.ts_parser_new TS.ts_parser_delete $ \ parser -> do
|
||||
let parserTimeout = s * 1000
|
||||
|
||||
TS.ts_parser_halt_on_error parser (CBool 1)
|
||||
TS.ts_parser_set_language parser language
|
||||
|
@ -185,7 +185,7 @@ data ParserCancelled = ParserTimedOut deriving (Show, Typeable)
|
||||
instance Exception ParserCancelled
|
||||
|
||||
defaultTimeout :: Timeout
|
||||
defaultTimeout = Seconds 5
|
||||
defaultTimeout = Milliseconds 5000
|
||||
|
||||
-- | Parse a 'Blob' in 'IO'.
|
||||
runParser :: Members '[Reader Options, Telemetry, Exc SomeException, IO, Trace] effs => Blob -> Parser term -> Eff effs term
|
||||
|
Loading…
Reference in New Issue
Block a user