Skip to content

Commit 5a15721

Browse files
July541fendor
authored andcommitted
Remove redundant CPP
1 parent 8dfb753 commit 5a15721

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import Data.List (intercalate)
2828
import Data.Maybe (catMaybes)
2929
import Data.Text (Text)
3030
import qualified Data.Text as T
31-
import Data.Version (Version, showVersion)
3231
import Development.IDE hiding (pluginHandlers)
3332
import Development.IDE.GHC.Compat as Compat hiding (Cpp, Warning,
3433
hang, vcat)
@@ -50,10 +49,6 @@ import System.Process.Run (cwd, proc)
5049
import System.Process.Text (readCreateProcessWithExitCode)
5150
import Text.Read (readMaybe)
5251

53-
#if MIN_VERSION_fourmolu(0,12,0)
54-
import qualified Paths_fourmolu as Fourmolu
55-
#endif
56-
5752
descriptor :: Recorder (WithPriority LogEvent) -> PluginId -> PluginDescriptor IdeState
5853
descriptor recorder plId =
5954
(defaultPluginDescriptor plId)
@@ -81,11 +76,7 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
8176
(pure . Left . PluginInternalError . T.pack . show)
8277
$ runExceptT $ cliHandler fileOpts
8378
else do
84-
#if MIN_VERSION_fourmolu(0,12,0)
85-
logWith recorder Info $ LogBuiltinVersion $ Just Fourmolu.version
86-
#else
87-
logWith recorder Info $ LogBuiltinVersion Nothing
88-
#endif
79+
logWith recorder Debug $ LogCompiledInVersion VERSION_fourmolu
8980
let format fourmoluConfig = ExceptT $
9081
bimap (PluginInternalError . T.pack . show) (InL . makeDiffTextEdit contents)
9182
#if MIN_VERSION_fourmolu(0,11,0)
@@ -141,12 +132,12 @@ provider recorder plId ideState typ contents fp fo = ExceptT $ withIndefinitePro
141132
traverse (readMaybe @Int . T.unpack) $ T.splitOn "." v
142133
case version of
143134
Just v -> do
144-
logWith recorder Info $ LogExternalVersion v
135+
logWith recorder Debug $ LogExternalVersion v
145136
pure CLIVersionInfo
146137
{ noCabal = v >= [0, 7]
147138
}
148139
Nothing -> do
149-
logWith recorder Info $ LogExternalVersion []
140+
logWith recorder Debug $ LogExternalVersion []
150141
logWith recorder Warning $ NoVersion out
151142
pure CLIVersionInfo
152143
{ noCabal = True
@@ -175,7 +166,7 @@ data LogEvent
175166
| ConfigPath FilePath
176167
| NoConfigPath [FilePath]
177168
| StdErr Text
178-
| LogBuiltinVersion (Maybe Version)
169+
| LogCompiledInVersion String
179170
| LogExternalVersion [Int]
180171
deriving (Show)
181172

@@ -186,8 +177,11 @@ instance Pretty LogEvent where
186177
NoConfigPath ps -> "No " <> pretty configFileName <> " found in any of:"
187178
<> line <> indent 2 (vsep (map (pretty . show) ps))
188179
StdErr t -> "Fourmolu stderr:" <> line <> indent 2 (pretty t)
189-
LogBuiltinVersion v -> "Using builtin fourmolu" <> pretty (maybe "" showVersion v)
190-
LogExternalVersion v -> "Using external fourmolu" <> pretty (intercalate "." $ map show v)
180+
LogCompiledInVersion v -> "Using compiled in fourmolu-" <> pretty v
181+
LogExternalVersion v ->
182+
"Using external fourmolu"
183+
<> if null v then "" else "-"
184+
<> pretty (intercalate "." $ map show v)
191185

192186
convertDynFlags :: DynFlags -> [String]
193187
convertDynFlags df =

0 commit comments

Comments
 (0)