From 90d3172dfec30a7569f95b32479ae97af73b8b2e Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sun, 13 Aug 2023 16:32:53 -0700 Subject: [PATCH] Add a newSystemInterface to go with the rest of the new* constructors --- shellcheck.hs | 2 +- src/ShellCheck/Interface.hs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/shellcheck.hs b/shellcheck.hs index 4e8a155..6be9bb1 100644 --- a/shellcheck.hs +++ b/shellcheck.hs @@ -396,7 +396,7 @@ ioInterface options files = do inputs <- mapM normalize files cache <- newIORef emptyCache configCache <- newIORef ("", Nothing) - return SystemInterface { + return (newSystemInterface :: SystemInterface IO) { siReadFile = get cache inputs, siFindSource = findSourceFile inputs (sourcePaths options), siGetConfig = getConfig configCache diff --git a/src/ShellCheck/Interface.hs b/src/ShellCheck/Interface.hs index 7528559..077212f 100644 --- a/src/ShellCheck/Interface.hs +++ b/src/ShellCheck/Interface.hs @@ -39,11 +39,12 @@ module ShellCheck.Interface , ColorOption(ColorAuto, ColorAlways, ColorNever) , TokenComment(tcId, tcComment, tcFix) , emptyCheckResult - , newParseResult - , newAnalysisSpec , newAnalysisResult + , newAnalysisSpec , newFormatterOptions + , newParseResult , newPosition + , newSystemInterface , newTokenComment , mockedSystemInterface , mockRcFile @@ -135,6 +136,14 @@ newParseSpec = ParseSpec { psShellTypeOverride = Nothing } +newSystemInterface :: Monad m => SystemInterface m +newSystemInterface = + SystemInterface { + siReadFile = \_ _ -> return $ Left "Not implemented", + siFindSource = \_ _ _ name -> return name, + siGetConfig = \_ -> return Nothing + } + -- Parser input and output data ParseSpec = ParseSpec { psFilename :: String, @@ -311,7 +320,7 @@ data ColorOption = -- For testing mockedSystemInterface :: [(String, String)] -> SystemInterface Identity -mockedSystemInterface files = SystemInterface { +mockedSystemInterface files = (newSystemInterface :: SystemInterface Identity) { siReadFile = rf, siFindSource = fs, siGetConfig = const $ return Nothing