From 92f0aa618bd3878c95f4da6536f2b1c3b6887562 Mon Sep 17 00:00:00 2001 From: Javier Neira Date: Wed, 25 Sep 2019 15:28:56 +0200 Subject: [PATCH 01/36] Fix code renaming in windows (#1392) * Taking in account terms between backquote and single quote * Add comment --- src/Haskell/Ide/Engine/Plugin/GhcMod.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs index ab994f179..057b1af22 100644 --- a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs +++ b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs @@ -310,9 +310,12 @@ extractRenamableTerms msg . T.lines singleSuggestions = T.splitOn "), " -- Each suggestion is comma delimited isKnownSymbol t = " (imported from" `T.isInfixOf` t || " (line " `T.isInfixOf` t - getEnclosed = T.dropWhile (== '‘') - . T.dropWhileEnd (== '’') - . T.dropAround (\c -> c /= '‘' && c /= '’') + getEnclosed' b e = T.dropWhile (== b) + . T.dropWhileEnd (== e) + . T.dropAround (\c -> c /= b && c /= e) + getEnclosed txt = case getEnclosed' '‘' '’' txt of + "" -> getEnclosed' '`' '\'' txt -- Needed for windows + enc -> enc extractRedundantImport :: T.Text -> Maybe T.Text extractRedundantImport msg = From b6de0a78349d40643b6348a087044c51eb8d981e Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 26 Sep 2019 11:41:42 +0200 Subject: [PATCH 02/36] Use the new key format in one line --- .azure/linux-stack.yml | 5 +---- .azure/macos-stack.yml | 5 +---- .azure/windows-stack.yml | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.azure/linux-stack.yml b/.azure/linux-stack.yml index 5b88f37b4..ee5705ae2 100644 --- a/.azure/linux-stack.yml +++ b/.azure/linux-stack.yml @@ -30,10 +30,7 @@ jobs: steps: - task: CacheBeta@0 inputs: - key: | - "cache" - $(Agent.OS) - $(Build.SourcesDirectory)/$(YAML_FILE) + key: stack-root | $(Agent.OS) | $(Build.SourcesDirectory)/$(YAML_FILE) path: .azure-cache cacheHitVar: CACHE_RESTORED displayName: "Download cache" diff --git a/.azure/macos-stack.yml b/.azure/macos-stack.yml index fa005842f..c139e5baa 100644 --- a/.azure/macos-stack.yml +++ b/.azure/macos-stack.yml @@ -26,10 +26,7 @@ jobs: steps: - task: CacheBeta@0 inputs: - key: | - "cache" - $(Agent.OS) - $(Build.SourcesDirectory)/$(YAML_FILE) + key: stack-root | $(Agent.OS) | $(Build.SourcesDirectory)/$(YAML_FILE) path: .azure-cache cacheHitVar: CACHE_RESTORED displayName: "Download cache" diff --git a/.azure/windows-stack.yml b/.azure/windows-stack.yml index 1dec036dc..5bdacce5f 100644 --- a/.azure/windows-stack.yml +++ b/.azure/windows-stack.yml @@ -29,10 +29,7 @@ jobs: steps: - task: CacheBeta@0 inputs: - key: | - "stack-root" - $(Agent.OS) - $(Build.SourcesDirectory)/$(YAML_FILE) + key: stack-root | $(Agent.OS) | $(Build.SourcesDirectory)/$(YAML_FILE) path: $(STACK_ROOT) displayName: "Cache stack-root" - task: CacheBeta@0 From e2396f715562e9a302dc4376d2a69a3e4f146003 Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 30 Sep 2019 13:31:20 +0200 Subject: [PATCH 03/36] Extract extractTerm to extend handling of win delims --- src/Haskell/Ide/Engine/Plugin/GhcMod.hs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs index 057b1af22..59b98eb67 100644 --- a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs +++ b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs @@ -304,24 +304,27 @@ extractRenamableTerms msg | "ot in scope:" `T.isInfixOf` msg = extractSuggestions msg | otherwise = [] where - extractSuggestions = map getEnclosed + extractSuggestions = map extractTerm . concatMap singleSuggestions . filter isKnownSymbol . T.lines singleSuggestions = T.splitOn "), " -- Each suggestion is comma delimited isKnownSymbol t = " (imported from" `T.isInfixOf` t || " (line " `T.isInfixOf` t - getEnclosed' b e = T.dropWhile (== b) - . T.dropWhileEnd (== e) - . T.dropAround (\c -> c /= b && c /= e) - getEnclosed txt = case getEnclosed' '‘' '’' txt of - "" -> getEnclosed' '`' '\'' txt -- Needed for windows - enc -> enc + +extractTerm :: T.Text -> T.Text +extractTerm txt = + case extract '‘' '’' txt of + "" -> extract '`' '\'' txt -- Needed for windows + term -> term + where extract b e = T.dropWhile (== b) + . T.dropWhileEnd (== e) + . T.dropAround (\c -> c /= b && c /= e) extractRedundantImport :: T.Text -> Maybe T.Text extractRedundantImport msg = if ("The import of " `T.isPrefixOf` firstLine || "The qualified import of " `T.isPrefixOf` firstLine) && " is redundant" `T.isSuffixOf` firstLine - then Just $ T.init $ T.tail $ T.dropWhileEnd (/= '’') $ T.dropWhile (/= '‘') firstLine + then Just $ extractTerm firstLine else Nothing where firstLine = case T.lines msg of @@ -398,9 +401,6 @@ extractUnusedTerm msg = extractTerm <$> stripMessageStart msg where stripMessageStart = T.stripPrefix "Defined but not used:" . T.strip - extractTerm = T.dropWhile (== '‘') - . T.dropWhileEnd (== '’') - . T.dropAround (\c -> c /= '‘' && c /= '’') -- --------------------------------------------------------------------- From 3efbee30cddac4f40ebb350f126280e04f90d2d0 Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 30 Sep 2019 13:32:33 +0200 Subject: [PATCH 04/36] Fix extractImportableTerm for windows handling os specific delims --- src/Haskell/Ide/Engine/Plugin/HsImport.hs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Haskell/Ide/Engine/Plugin/HsImport.hs b/src/Haskell/Ide/Engine/Plugin/HsImport.hs index ea28eef27..a4d35abad 100644 --- a/src/Haskell/Ide/Engine/Plugin/HsImport.hs +++ b/src/Haskell/Ide/Engine/Plugin/HsImport.hs @@ -483,17 +483,19 @@ extractImportableTerm dirtyMsg = do $ T.unlines $ map T.strip $ T.lines + $ T.replace "* " "" -- Needed for Windows $ T.replace "• " "" dirtyMsg - extractedTerm = asum - [ importMsg - >>= T.stripPrefix "Variable not in scope: " - >>= \name -> Just (name, Import Symbol) - , importMsg - >>= T.stripPrefix "Not in scope: type constructor or class ‘" - >>= \name -> Just (T.init name, Import Type) - , importMsg - >>= T.stripPrefix "Data constructor not in scope: " - >>= \name -> Just (name, Import Constructor)] + extractTerm prefix symTy = + importMsg + >>= T.stripPrefix prefix + >>= \name -> Just (name, Import symTy) + extractType b = + extractTerm ("Not in scope: type constructor or class " <> b) Type + extractedTerm = asum + [ extractTerm "Variable not in scope: " Symbol + , extractType "‘" + , extractType "`" -- Needed for windows + , extractTerm "Data constructor not in scope: " Constructor] From 38cf06b9d290cdaafef24e0ae8f62c9dd5dac3e8 Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 30 Sep 2019 13:33:29 +0200 Subject: [PATCH 05/36] Fix extractModuleName for windows handling os specific delims --- src/Haskell/Ide/Engine/Plugin/Package.hs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Haskell/Ide/Engine/Plugin/Package.hs b/src/Haskell/Ide/Engine/Plugin/Package.hs index 7076295bd..931523acb 100644 --- a/src/Haskell/Ide/Engine/Plugin/Package.hs +++ b/src/Haskell/Ide/Engine/Plugin/Package.hs @@ -338,11 +338,19 @@ codeActionProvider plId docId _ context = do -- | Extract a module name from an error message. extractModuleName :: T.Text -> Maybe Package extractModuleName msg - | T.isPrefixOf "Could not find module " msg = Just $ T.tail $ T.init nameAndQuotes - | T.isPrefixOf "Could not load module " msg = Just $ T.tail $ T.init nameAndQuotes + | T.isPrefixOf "Could not find module " msg = Just $ extractTerm line + | T.isPrefixOf "Could not load module " msg = Just $ extractTerm line | otherwise = Nothing where line = head $ T.lines msg - nameAndQuotes = T.dropWhileEnd (/= '’') $ T.dropWhile (/= '‘') line + +extractTerm :: T.Text -> T.Text +extractTerm txt = + case extract '‘' '’' txt of + "" -> extract '`' '\'' txt -- Needed for windows + term -> term + where extract b e = T.dropWhile (== b) + . T.dropWhileEnd (== e) + . T.dropAround (\c -> c /= b && c /= e) -- Example error messages {- GHC 8.6.2 error message is From 8cc09e6d1602f5c9a493b869342ebdd164a1ed46 Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 30 Sep 2019 14:24:28 +0200 Subject: [PATCH 06/36] Move extractTerm to HieExtras and reuse it --- src/Haskell/Ide/Engine/Plugin/GhcMod.hs | 15 +++------------ src/Haskell/Ide/Engine/Plugin/Package.hs | 14 +++----------- src/Haskell/Ide/Engine/Support/HieExtras.hs | 13 +++++++++++++ 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs index 59b98eb67..b4874f532 100644 --- a/src/Haskell/Ide/Engine/Plugin/GhcMod.hs +++ b/src/Haskell/Ide/Engine/Plugin/GhcMod.hs @@ -304,27 +304,18 @@ extractRenamableTerms msg | "ot in scope:" `T.isInfixOf` msg = extractSuggestions msg | otherwise = [] where - extractSuggestions = map extractTerm + extractSuggestions = map Hie.extractTerm . concatMap singleSuggestions . filter isKnownSymbol . T.lines singleSuggestions = T.splitOn "), " -- Each suggestion is comma delimited isKnownSymbol t = " (imported from" `T.isInfixOf` t || " (line " `T.isInfixOf` t -extractTerm :: T.Text -> T.Text -extractTerm txt = - case extract '‘' '’' txt of - "" -> extract '`' '\'' txt -- Needed for windows - term -> term - where extract b e = T.dropWhile (== b) - . T.dropWhileEnd (== e) - . T.dropAround (\c -> c /= b && c /= e) - extractRedundantImport :: T.Text -> Maybe T.Text extractRedundantImport msg = if ("The import of " `T.isPrefixOf` firstLine || "The qualified import of " `T.isPrefixOf` firstLine) && " is redundant" `T.isSuffixOf` firstLine - then Just $ extractTerm firstLine + then Just $ Hie.extractTerm firstLine else Nothing where firstLine = case T.lines msg of @@ -397,7 +388,7 @@ extractMissingSignature msg = extractSignature <$> stripMessageStart msg extractSignature = T.strip extractUnusedTerm :: T.Text -> Maybe T.Text -extractUnusedTerm msg = extractTerm <$> stripMessageStart msg +extractUnusedTerm msg = Hie.extractTerm <$> stripMessageStart msg where stripMessageStart = T.stripPrefix "Defined but not used:" . T.strip diff --git a/src/Haskell/Ide/Engine/Plugin/Package.hs b/src/Haskell/Ide/Engine/Plugin/Package.hs index 931523acb..9afe43372 100644 --- a/src/Haskell/Ide/Engine/Plugin/Package.hs +++ b/src/Haskell/Ide/Engine/Plugin/Package.hs @@ -9,6 +9,7 @@ module Haskell.Ide.Engine.Plugin.Package where import Haskell.Ide.Engine.MonadTypes import qualified Haskell.Ide.Engine.Plugin.Hoogle as Hoogle import Haskell.Ide.Engine.PluginUtils +import Haskell.Ide.Engine.Support.HieExtras as Hie import GHC.Generics import GHC.Exts import Control.Lens @@ -338,20 +339,11 @@ codeActionProvider plId docId _ context = do -- | Extract a module name from an error message. extractModuleName :: T.Text -> Maybe Package extractModuleName msg - | T.isPrefixOf "Could not find module " msg = Just $ extractTerm line - | T.isPrefixOf "Could not load module " msg = Just $ extractTerm line + | T.isPrefixOf "Could not find module " msg = Just $ Hie.extractTerm line + | T.isPrefixOf "Could not load module " msg = Just $ Hie.extractTerm line | otherwise = Nothing where line = head $ T.lines msg -extractTerm :: T.Text -> T.Text -extractTerm txt = - case extract '‘' '’' txt of - "" -> extract '`' '\'' txt -- Needed for windows - term -> term - where extract b e = T.dropWhile (== b) - . T.dropWhileEnd (== e) - . T.dropAround (\c -> c /= b && c /= e) - -- Example error messages {- GHC 8.6.2 error message is diff --git a/src/Haskell/Ide/Engine/Support/HieExtras.hs b/src/Haskell/Ide/Engine/Support/HieExtras.hs index 7b32d1241..b6cbb0a63 100644 --- a/src/Haskell/Ide/Engine/Support/HieExtras.hs +++ b/src/Haskell/Ide/Engine/Support/HieExtras.hs @@ -12,6 +12,7 @@ module Haskell.Ide.Engine.Support.HieExtras , getSymbolsAtPoint , getReferencesInDoc , getModule + , extractTerm , findDef , findTypeDef , showName @@ -230,6 +231,18 @@ getModule df n = do let pkg = showName . packageName <$> lookupPackage df uid return (pkg, T.pack $ moduleNameString $ moduleName m) +-- | Extract a term from a compiler message. +-- It looks for terms delimited between '‘' and '’' falling back to '`' and '\'' +-- (the used ones in Windows systems). +extractTerm :: T.Text -> T.Text +extractTerm txt = + case extract '‘' '’' txt of + "" -> extract '`' '\'' txt -- Needed for windows + term -> term + where extract b e = T.dropWhile (== b) + . T.dropWhileEnd (== e) + . T.dropAround (\c -> c /= b && c /= e) + -- --------------------------------------------------------------------- -- | Return the type definition of the symbol at the given position. From 538508774ac867a8f4d7bb61e591383b171fe964 Mon Sep 17 00:00:00 2001 From: Javier Neira Date: Tue, 1 Oct 2019 10:33:39 +0200 Subject: [PATCH 07/36] Handling Windows specific delimiters in func tests (#1400) --- test/functional/FunctionalCodeActionsSpec.hs | 26 ++++++++++++-------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/test/functional/FunctionalCodeActionsSpec.hs b/test/functional/FunctionalCodeActionsSpec.hs index 5d763870c..9c7750a52 100644 --- a/test/functional/FunctionalCodeActionsSpec.hs +++ b/test/functional/FunctionalCodeActionsSpec.hs @@ -221,11 +221,12 @@ spec = describe "code actions" $ do -- ignore the first empty hlint diagnostic publish [_,diag:_] <- count 2 waitForDiagnostics - if ghcVersion == GHC86 - then - liftIO $ diag ^. L.message `shouldSatisfy` T.isPrefixOf "Could not load module \8216Data.Text\8217" - else - liftIO $ diag ^. L.message `shouldSatisfy` T.isPrefixOf "Could not find module ‘Data.Text’" + let prefixes = [ "Could not load module `Data.Text'" -- Windows && GHC >= 8.6 + , "Could not find module `Data.Text'" -- Windows + , "Could not load module ‘Data.Text’" -- GHC >= 8.6 + , "Could not find module ‘Data.Text’" + ] + in liftIO $ diag ^. L.message `shouldSatisfy` \m -> any (`T.isPrefixOf` m) prefixes acts <- getAllCodeActions doc let (CACodeAction action:_) = acts @@ -247,10 +248,12 @@ spec = describe "code actions" $ do -- ignore the first empty hlint diagnostic publish [_,diag:_] <- count 2 waitForDiagnostics - let preds = [ T.isPrefixOf "Could not load module ‘Codec.Compression.GZip’" - , T.isPrefixOf "Could not find module ‘Codec.Compression.GZip’" - ] - in liftIO $ diag ^. L.message `shouldSatisfy` \x -> any (\f -> f x) preds + let prefixes = [ "Could not load module `Codec.Compression.GZip'" -- Windows && GHC >= 8.6 + , "Could not find module `Codec.Compression.GZip'" -- Windows + , "Could not load module ‘Codec.Compression.GZip’" -- GHC >= 8.6 + , "Could not find module ‘Codec.Compression.GZip’" + ] + in liftIO $ diag ^. L.message `shouldSatisfy` \m -> any (`T.isPrefixOf` m) prefixes mActions <- getAllCodeActions doc let allActions = map fromAction mActions @@ -279,7 +282,10 @@ spec = describe "code actions" $ do -- ignore the first empty hlint diagnostic publish [_,diag:_] <- count 2 waitForDiagnostics - liftIO $ diag ^. L.message `shouldSatisfy` T.isPrefixOf "The import of ‘Data.List’ is redundant" + let prefixes = [ "The import of `Data.List' is redundant" -- Windows + , "The import of ‘Data.List’ is redundant" + ] + in liftIO $ diag ^. L.message `shouldSatisfy` \m -> any (`T.isPrefixOf` m) prefixes mActions <- getAllCodeActions doc From 2060ffbe7438224ba88142603aa767d639533b53 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Thu, 3 Oct 2019 23:33:52 +0100 Subject: [PATCH 08/36] Use haskell-lsp(-types) 0.16 --- haskell-ide-engine.cabal | 10 +++++----- hie-plugin-api/hie-plugin-api.cabal | 2 +- src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs | 8 ++++---- stack-8.2.2.yaml | 6 +++--- stack-8.4.2.yaml | 6 +++--- stack-8.4.3.yaml | 6 +++--- stack-8.4.4.yaml | 6 +++--- stack-8.6.1.yaml | 6 +++--- stack-8.6.2.yaml | 6 +++--- stack-8.6.3.yaml | 6 +++--- stack-8.6.4.yaml | 6 +++--- stack-8.6.5.yaml | 6 +++--- stack.yaml | 6 +++--- test/dispatcher/Main.hs | 2 +- test/functional/DeferredSpec.hs | 2 +- test/functional/DiagnosticsSpec.hs | 2 +- test/functional/FunctionalCodeActionsSpec.hs | 4 ++-- test/functional/FunctionalLiquidSpec.hs | 4 ++-- test/unit/ApplyRefactPluginSpec.hs | 9 +++++---- 19 files changed, 52 insertions(+), 51 deletions(-) diff --git a/haskell-ide-engine.cabal b/haskell-ide-engine.cabal index 405e7b3f8..4e746183b 100644 --- a/haskell-ide-engine.cabal +++ b/haskell-ide-engine.cabal @@ -71,8 +71,8 @@ library , gitrev >= 1.1 , haddock-api , haddock-library - , haskell-lsp == 0.15.* - , haskell-lsp-types == 0.15.* + , haskell-lsp == 0.16.* + , haskell-lsp-types == 0.16.* , haskell-src-exts , hie-plugin-api , hoogle >= 5.0.13 @@ -199,7 +199,7 @@ test-suite unit-test , free , ghc , haskell-ide-engine - , haskell-lsp-types >= 0.15.0.0 + , haskell-lsp-types == 0.16.* , hie-test-utils , hie-plugin-api , hoogle > 5.0.11 @@ -287,8 +287,8 @@ test-suite func-test , filepath , lsp-test >= 0.6.0.0 , haskell-ide-engine - , haskell-lsp-types == 0.15.* - , haskell-lsp == 0.15.* + , haskell-lsp-types == 0.16.* + , haskell-lsp == 0.16.* , hie-test-utils , hie-plugin-api , hspec diff --git a/hie-plugin-api/hie-plugin-api.cabal b/hie-plugin-api/hie-plugin-api.cabal index d6a4e7ed4..de48b7ea9 100644 --- a/hie-plugin-api/hie-plugin-api.cabal +++ b/hie-plugin-api/hie-plugin-api.cabal @@ -45,7 +45,7 @@ library , ghc , ghc-mod-core >= 5.9.0.0 , ghc-project-types >= 5.9.0.0 - , haskell-lsp == 0.15.* + , haskell-lsp == 0.16.* , hslogger , monad-control , mtl diff --git a/src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs b/src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs index 6589bc276..df848d0a9 100644 --- a/src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs +++ b/src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs @@ -148,7 +148,7 @@ parseErrorToDiagnostic (Hlint.ParseError l msg contents) = [Diagnostic { _range = srcLoc2Range l , _severity = Just DsInfo -- Not displayed - , _code = Just "parser" + , _code = Just (LSP.StringValue "parser") , _source = Just "hlint" , _message = T.unlines [T.pack msg,T.pack contents] , _relatedInformation = Nothing @@ -192,7 +192,7 @@ hintToDiagnostic idea = Diagnostic { _range = ss2Range (ideaSpan idea) , _severity = Just (hintSeverityMap $ ideaSeverity idea) - , _code = Just (T.pack $ ideaHint idea) + , _code = Just (LSP.StringValue $ T.pack $ ideaHint idea) , _source = Just "hlint" , _message = idea2Message idea , _relatedInformation = Nothing @@ -315,7 +315,7 @@ codeActionProvider plId docId _ context = IdeResultOk <$> hlintActions hlintActions = catMaybes <$> mapM mkHlintAction (filter validCommand diags) -- |Some hints do not have an associated refactoring - validCommand (LSP.Diagnostic _ _ (Just code) (Just "hlint") _ _) = + validCommand (LSP.Diagnostic _ _ (Just (LSP.StringValue code)) (Just "hlint") _ _) = case code of "Eta reduce" -> False _ -> True @@ -324,7 +324,7 @@ codeActionProvider plId docId _ context = IdeResultOk <$> hlintActions LSP.List diags = context ^. LSP.diagnostics mkHlintAction :: LSP.Diagnostic -> IdeM (Maybe LSP.CodeAction) - mkHlintAction diag@(LSP.Diagnostic (LSP.Range start _) _s (Just code) (Just "hlint") m _) = + mkHlintAction diag@(LSP.Diagnostic (LSP.Range start _) _s (Just (LSP.StringValue code)) (Just "hlint") m _) = Just . codeAction <$> mkLspCommand plId "applyOne" title (Just args) where codeAction cmd = LSP.CodeAction title (Just LSP.CodeActionRefactor) (Just (LSP.List [diag])) Nothing (Just cmd) diff --git a/stack-8.2.2.yaml b/stack-8.2.2.yaml index 8dffe2c8c..6f716ede3 100644 --- a/stack-8.2.2.yaml +++ b/stack-8.2.2.yaml @@ -20,14 +20,14 @@ extra-deps: - ghc-exactprint-0.5.8.2 - haddock-api-2.18.1 - haddock-library-1.4.4 -- haskell-lsp-0.15.0.0 -- haskell-lsp-types-0.15.0.0 +- haskell-lsp-0.16.0.0 +- haskell-lsp-types-0.16.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.1.17 # last hlint supporting GHC 8.2 - hoogle-5.0.17.9 - hsimport-0.8.8 -- lsp-test-0.6.0.0 +- lsp-test-0.7.0.0 - monad-dijkstra-0.1.1.2 - pretty-show-1.8.2 - rope-utf16-splay-0.3.1.0 diff --git a/stack-8.4.2.yaml b/stack-8.4.2.yaml index 5dee67768..85c616ffb 100644 --- a/stack-8.4.2.yaml +++ b/stack-8.4.2.yaml @@ -19,14 +19,14 @@ extra-deps: - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.20.0 - haddock-library-1.6.0 -- haskell-lsp-0.15.0.0 -- haskell-lsp-types-0.15.0.0 +- haskell-lsp-0.16.0.0 +- haskell-lsp-types-0.16.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.6.0.0 +- lsp-test-0.7.0.0 - monad-dijkstra-0.1.1.2 - pretty-show-1.8.2 - rope-utf16-splay-0.3.1.0 diff --git a/stack-8.4.3.yaml b/stack-8.4.3.yaml index 353c946bc..f129f64af 100644 --- a/stack-8.4.3.yaml +++ b/stack-8.4.3.yaml @@ -19,14 +19,14 @@ extra-deps: - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.20.0 - haddock-library-1.6.0 -- haskell-lsp-0.15.0.0 -- haskell-lsp-types-0.15.0.0 +- haskell-lsp-0.16.0.0 +- haskell-lsp-types-0.16.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.6.0.0 +- lsp-test-0.7.0.0 - monad-dijkstra-0.1.1.2 - pretty-show-1.8.2 - rope-utf16-splay-0.3.1.0 diff --git a/stack-8.4.4.yaml b/stack-8.4.4.yaml index 0b3baa3bc..4e8256b38 100644 --- a/stack-8.4.4.yaml +++ b/stack-8.4.4.yaml @@ -18,14 +18,14 @@ extra-deps: - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.20.0 - haddock-library-1.6.0 -- haskell-lsp-0.15.0.0 -- haskell-lsp-types-0.15.0.0 +- haskell-lsp-0.16.0.0 +- haskell-lsp-types-0.16.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.6.0.0 +- lsp-test-0.7.0.0 - monad-dijkstra-0.1.1.2 - optparse-simple-0.1.0 - pretty-show-1.9.5 diff --git a/stack-8.6.1.yaml b/stack-8.6.1.yaml index 9dc480ccb..df3b9ee45 100644 --- a/stack-8.6.1.yaml +++ b/stack-8.6.1.yaml @@ -21,14 +21,14 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.21.0 -- haskell-lsp-0.15.0.0 -- haskell-lsp-types-0.15.0.0 +- haskell-lsp-0.16.0.0 +- haskell-lsp-types-0.16.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.6.0.0 +- lsp-test-0.7.0.0 - monad-dijkstra-0.1.1.2 - monad-memo-0.4.1 - monoid-subclasses-0.4.6.1 diff --git a/stack-8.6.2.yaml b/stack-8.6.2.yaml index b57ac5bf4..35e3f9604 100644 --- a/stack-8.6.2.yaml +++ b/stack-8.6.2.yaml @@ -17,14 +17,14 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.21.0 -- haskell-lsp-0.15.0.0 -- haskell-lsp-types-0.15.0.0 +- haskell-lsp-0.16.0.0 +- haskell-lsp-types-0.16.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.6.0.0 +- lsp-test-0.7.0.0 - monad-dijkstra-0.1.1.2 - monad-memo-0.4.1 - multistate-0.8.0.1 diff --git a/stack-8.6.3.yaml b/stack-8.6.3.yaml index 0fc3dc998..9c29fdc7a 100644 --- a/stack-8.6.3.yaml +++ b/stack-8.6.3.yaml @@ -17,14 +17,14 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.21.0 -- haskell-lsp-0.15.0.0 -- haskell-lsp-types-0.15.0.0 +- haskell-lsp-0.16.0.0 +- haskell-lsp-types-0.16.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.6.0.0 +- lsp-test-0.7.0.0 - monad-dijkstra-0.1.1.2 - monad-memo-0.4.1 - multistate-0.8.0.1 diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index c8612a809..d8f27c8d4 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -17,13 +17,13 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.22.0 -- haskell-lsp-0.15.0.0 -- haskell-lsp-types-0.15.0.0 +- haskell-lsp-0.16.0.0 +- haskell-lsp-types-0.16.0.0 - haskell-src-exts-1.21.0 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.6.0.0 +- lsp-test-0.7.0.0 - monad-dijkstra-0.1.1.2@rev:1 - monad-memo-0.4.1 - multistate-0.8.0.1 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 4f4ee7386..46ecdfb1a 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -17,13 +17,13 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.22.0 -- haskell-lsp-0.15.0.0 -- haskell-lsp-types-0.15.0.0 +- haskell-lsp-0.16.0.0 +- haskell-lsp-types-0.16.0.0 - haskell-src-exts-1.21.0 - hlint-2.2.2 - hsimport-0.10.0 - hoogle-5.0.17.9 -- lsp-test-0.6.0.0 +- lsp-test-0.7.0.0 - monad-dijkstra-0.1.1.2@rev:1 - monad-memo-0.4.1 - multistate-0.8.0.1 diff --git a/stack.yaml b/stack.yaml index 1b6cdfebd..b8f0ae23d 100644 --- a/stack.yaml +++ b/stack.yaml @@ -18,11 +18,11 @@ extra-deps: - floskell-0.10.1 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.22.0 -- haskell-lsp-0.15.0.0 -- haskell-lsp-types-0.15.0.0 +- haskell-lsp-0.16.0.0 +- haskell-lsp-types-0.16.0.0 - hlint-2.2.2 - hsimport-0.10.0 -- lsp-test-0.6.0.0 +- lsp-test-0.7.0.0 - monad-dijkstra-0.1.1.2@rev:1 - syz-0.2.0.0 - temporary-1.2.1.1 diff --git a/test/dispatcher/Main.hs b/test/dispatcher/Main.hs index dacd786f4..0fe09ff73 100644 --- a/test/dispatcher/Main.hs +++ b/test/dispatcher/Main.hs @@ -249,7 +249,7 @@ funcSpec = describe "functional dispatch" $ do [ Diagnostic (Range (Position 9 6) (Position 10 18)) (Just DsInfo) - (Just "Redundant do") + (Just (StringValue "Redundant do")) (Just "hlint") "Redundant do\nFound:\n do putStrLn \"hello\"\nWhy not:\n putStrLn \"hello\"\n" Nothing diff --git a/test/functional/DeferredSpec.hs b/test/functional/DeferredSpec.hs index 1ad189c25..060f2afe5 100644 --- a/test/functional/DeferredSpec.hs +++ b/test/functional/DeferredSpec.hs @@ -115,7 +115,7 @@ spec = do [ Diagnostic (Range (Position 9 6) (Position 10 18)) (Just DsInfo) - (Just "Redundant do") + (Just (StringValue "Redundant do")) (Just "hlint") "Redundant do\nFound:\n do putStrLn \"hello\"\nWhy not:\n putStrLn \"hello\"\n" Nothing diff --git a/test/functional/DiagnosticsSpec.hs b/test/functional/DiagnosticsSpec.hs index bfd613e1b..a5459908e 100644 --- a/test/functional/DiagnosticsSpec.hs +++ b/test/functional/DiagnosticsSpec.hs @@ -35,7 +35,7 @@ spec = describe "diagnostics providers" $ do length diags `shouldBe` 2 reduceDiag ^. LSP.range `shouldBe` Range (Position 1 0) (Position 1 12) reduceDiag ^. LSP.severity `shouldBe` Just DsInfo - reduceDiag ^. LSP.code `shouldBe` Just "Eta reduce" + reduceDiag ^. LSP.code `shouldBe` Just (StringValue "Eta reduce") reduceDiag ^. LSP.source `shouldBe` Just "hlint" diags2a <- waitForDiagnostics diff --git a/test/functional/FunctionalCodeActionsSpec.hs b/test/functional/FunctionalCodeActionsSpec.hs index 9c7750a52..60c6c993a 100644 --- a/test/functional/FunctionalCodeActionsSpec.hs +++ b/test/functional/FunctionalCodeActionsSpec.hs @@ -34,7 +34,7 @@ spec = describe "code actions" $ do length diags `shouldBe` 2 reduceDiag ^. L.range `shouldBe` Range (Position 1 0) (Position 1 12) reduceDiag ^. L.severity `shouldBe` Just DsInfo - reduceDiag ^. L.code `shouldBe` Just "Eta reduce" + reduceDiag ^. L.code `shouldBe` Just (StringValue "Eta reduce") reduceDiag ^. L.source `shouldBe` Just "hlint" (CACodeAction ca:_) <- getAllCodeActions doc @@ -79,7 +79,7 @@ spec = describe "code actions" $ do length diags `shouldBe` 2 reduceDiag ^. L.range `shouldBe` Range (Position 1 0) (Position 1 12) reduceDiag ^. L.severity `shouldBe` Just DsInfo - reduceDiag ^. L.code `shouldBe` Just "Eta reduce" + reduceDiag ^. L.code `shouldBe` Just (StringValue "Eta reduce") reduceDiag ^. L.source `shouldBe` Just "hlint" (CACodeAction ca:_) <- getAllCodeActions doc diff --git a/test/functional/FunctionalLiquidSpec.hs b/test/functional/FunctionalLiquidSpec.hs index d8d735db4..b1f7fc29e 100644 --- a/test/functional/FunctionalLiquidSpec.hs +++ b/test/functional/FunctionalLiquidSpec.hs @@ -33,7 +33,7 @@ spec = describe "liquid haskell diagnostics" $ do length diags `shouldBe` 2 reduceDiag ^. range `shouldBe` Range (Position 5 18) (Position 5 22) reduceDiag ^. severity `shouldBe` Just DsHint - reduceDiag ^. code `shouldBe` Just "Use negate" + reduceDiag ^. code `shouldBe` Just (StringValue "Use negate") reduceDiag ^. source `shouldBe` Just "hlint" -- liftIO $ putStrLn "b" @@ -77,7 +77,7 @@ spec = describe "liquid haskell diagnostics" $ do length diags `shouldBe` 2 reduceDiag ^. range `shouldBe` Range (Position 5 18) (Position 5 22) reduceDiag ^. severity `shouldBe` Just DsHint - reduceDiag ^. code `shouldBe` Just "Use negate" + reduceDiag ^. code `shouldBe` Just (StringValue "Use negate") reduceDiag ^. source `shouldBe` Just "hlint" -- Enable liquid haskell plugin and disable hlint diff --git a/test/unit/ApplyRefactPluginSpec.hs b/test/unit/ApplyRefactPluginSpec.hs index 4a91d0fee..37c7f6997 100644 --- a/test/unit/ApplyRefactPluginSpec.hs +++ b/test/unit/ApplyRefactPluginSpec.hs @@ -8,6 +8,7 @@ import qualified Data.Text as T import Haskell.Ide.Engine.Plugin.ApplyRefact import Haskell.Ide.Engine.MonadTypes import Haskell.Ide.Engine.PluginUtils +import Language.Haskell.LSP.Types import System.Directory import TestUtils @@ -74,13 +75,13 @@ applyRefactSpec = do , _diagnostics = List $ [ Diagnostic (Range (Position 1 7) (Position 1 25)) (Just DsHint) - (Just "Redundant bracket") + (Just (StringValue "Redundant bracket")) (Just "hlint") "Redundant bracket\nFound:\n (putStrLn \"hello\")\nWhy not:\n putStrLn \"hello\"\n" Nothing , Diagnostic (Range (Position 3 8) (Position 3 15)) (Just DsHint) - (Just "Redundant bracket") + (Just (StringValue "Redundant bracket")) (Just "hlint") "Redundant bracket\nFound:\n (x + 1)\nWhy not:\n x + 1\n" Nothing @@ -103,7 +104,7 @@ applyRefactSpec = do [Diagnostic {_range = Range { _start = Position {_line = 12, _character = 23} , _end = Position {_line = 12, _character = 100000}} , _severity = Just DsInfo - , _code = Just "parser" + , _code = Just (StringValue "parser") , _source = Just "hlint" , _message = T.pack filePathNoUri <> ":13:24: error:\n Operator applied to too few arguments: +\n data instance Sing (z :: (a :~: b)) where\n> SRefl :: Sing Refl +\n\n" , _relatedInformation = Nothing }]} @@ -140,7 +141,7 @@ applyRefactSpec = do , _diagnostics = List [ Diagnostic (Range (Position 3 11) (Position 3 20)) (Just DsInfo) - (Just "Redundant bracket") + (Just (StringValue "Redundant bracket")) (Just "hlint") "Redundant bracket\nFound:\n (\"hello\")\nWhy not:\n \"hello\"\n" Nothing From c281205ee44aa307a1274d7dfe064b2d347be46e Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Fri, 4 Oct 2019 18:56:24 +0100 Subject: [PATCH 09/36] Fix GHC 8.2.2 build --- test/unit/ApplyRefactPluginSpec.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/ApplyRefactPluginSpec.hs b/test/unit/ApplyRefactPluginSpec.hs index 37c7f6997..ac5445f45 100644 --- a/test/unit/ApplyRefactPluginSpec.hs +++ b/test/unit/ApplyRefactPluginSpec.hs @@ -112,7 +112,7 @@ applyRefactSpec = do [Diagnostic {_range = Range { _start = Position {_line = 13, _character = 0} , _end = Position {_line = 13, _character = 100000}} , _severity = Just DsInfo - , _code = Just "parser" + , _code = Just (StringValue "parser") , _source = Just "hlint" , _message = "Parse error: virtual }\n data instance Sing (z :: (a :~: b)) where\n SRefl :: Sing Refl +\n> \n\n" , _relatedInformation = Nothing }]} From 2ca7474ca6bf8a92e225a26c3dfb024c529d0737 Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 8 Oct 2019 12:02:07 +0200 Subject: [PATCH 10/36] Add confirmation messages to install cabal and install hie with cabal --- install/src/Cabal.hs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/install/src/Cabal.hs b/install/src/Cabal.hs index 68f530049..f4699416d 100644 --- a/install/src/Cabal.hs +++ b/install/src/Cabal.hs @@ -57,11 +57,20 @@ cabalInstallHie versionNumber = do , "--overwrite-policy=always" ] ++ installMethod + + let minorVerExe = "hie-" ++ versionNumber <.> exe + majorVerExe = "hie-" ++ dropExtension versionNumber <.> exe + liftIO $ do - copyFile (localBin "hie" <.> exe) - (localBin "hie-" ++ versionNumber <.> exe) - copyFile (localBin "hie" <.> exe) - (localBin "hie-" ++ dropExtension versionNumber <.> exe) + copyFile (localBin "hie" <.> exe) (localBin minorVerExe) + copyFile (localBin "hie" <.> exe) (localBin majorVerExe) + + printLine $ "Copied executables " + ++ ("hie-wrapper" <.> exe) ++ ", " + ++ ("hie" <.> exe) ++ ", " + ++ majorVerExe ++ " and " + ++ minorVerExe + ++ " to " ++ localBin installCabal :: Action () installCabal = do @@ -70,9 +79,11 @@ installCabal = do c <- liftIO (findExecutable "cabal") when (isJust c) checkCabal return $ isJust c - + -- install `cabal-install` if not already installed - unless cabalExeOk $ execStackShake_ ["install", "cabal-install"] + if cabalExeOk + then printLine "There is already a cabal executable in $PATH with the required minimum version." + else execStackShake_ ["install", "cabal-install"] -- | check `cabal` has the required version checkCabal :: Action () From fcb30e1f792206c70122dd52e228eb6fea53332e Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 8 Oct 2019 12:02:46 +0200 Subject: [PATCH 11/36] Add stack-install-cabal target --- install/src/Help.hs | 8 ++++++++ install/src/HieInstall.hs | 1 + 2 files changed, 9 insertions(+) diff --git a/install/src/Help.hs b/install/src/Help.hs index bb9e65363..7a8b347e6 100644 --- a/install/src/Help.hs +++ b/install/src/Help.hs @@ -10,6 +10,7 @@ import Env import Print import Version import BuildSystem +import Cabal printUsage :: Action () printUsage = do @@ -83,6 +84,7 @@ helpMessage versions@BuildableVersions {..} = do , stackTarget buildAllTarget , stackTarget buildDataTarget ] + ++ (if isRunFromStack then [stackTarget installCabalTarget] else []) ++ map (stackTarget . hieTarget) stackVersions cabalTargets = @@ -136,6 +138,12 @@ cabalGhcsTarget = , "Show all GHC versions that can be installed via `cabal-build` and `cabal-build-all`." ) +installCabalTarget :: TargetDescription +installCabalTarget = + ( "install-cabal" + , "Install the cabal executable. It will install the required minimum version for hie (currently " ++ versionToString requiredCabalVersion ++ ") if it isn't already present in $PATH" + ) + -- | Creates a message of the form "a, b, c and d", where a,b,c,d are GHC versions. -- If there is no GHC in the list of `hieVersions` allVersionMessage :: [String] -> String diff --git a/install/src/HieInstall.hs b/install/src/HieInstall.hs index 223dde39b..58ed14138 100644 --- a/install/src/HieInstall.hs +++ b/install/src/HieInstall.hs @@ -91,6 +91,7 @@ defaultMain = do ) -- stack specific targets + when isRunFromStack (phony "stack-install-cabal" (need ["cabal"])) phony "stack-build" (need (reverse $ map ("stack-hie-" ++) hieVersions)) phony "stack-build-all" (need ["build-data", "build"]) phony "stack-build-data" $ do From d5c50b995b9d650b8c6916ba1c57363e5220dbcf Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 9 Oct 2019 14:58:29 +0200 Subject: [PATCH 12/36] Install and run cabal found in user original $PATH --- install/hie-install.cabal | 1 + install/src/Cabal.hs | 13 +++++++++---- install/src/Stack.hs | 36 ++++++++++++++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/install/hie-install.cabal b/install/hie-install.cabal index 287b56f6a..342f87695 100644 --- a/install/hie-install.cabal +++ b/install/hie-install.cabal @@ -21,6 +21,7 @@ library build-depends: base >= 4.9 && < 5 , shake == 0.17.8 , directory + , filepath , extra , text default-extensions: LambdaCase diff --git a/install/src/Cabal.hs b/install/src/Cabal.hs index f4699416d..edcc90d1e 100644 --- a/install/src/Cabal.hs +++ b/install/src/Cabal.hs @@ -12,17 +12,21 @@ import System.Directory ( findExecutable , copyFile ) +import BuildSystem import Version import Print import Env import Stack - +import Debug.Trace execCabal :: CmdResult r => [String] -> Action r -execCabal = command [] "cabal" +execCabal = execCabalWithOriginalPath execCabal_ :: [String] -> Action () -execCabal_ = command_ [] "cabal" +execCabal_ = execCabalWithOriginalPath + +execCabalWithOriginalPath :: CmdResult r => [String] -> Action r +execCabalWithOriginalPath = withOriginalPath . (command [] "cabal") cabalBuildData :: Action () cabalBuildData = do @@ -76,7 +80,8 @@ installCabal :: Action () installCabal = do -- try to find existing `cabal` executable with appropriate version cabalExeOk <- do - c <- liftIO (findExecutable "cabal") + c <- withOriginalPath (liftIO (findExecutable "cabal")) + liftIO $ traceIO $ show c when (isJust c) checkCabal return $ isJust c diff --git a/install/src/Stack.hs b/install/src/Stack.hs index 279bfe9ca..1ad8c192b 100644 --- a/install/src/Stack.hs +++ b/install/src/Stack.hs @@ -4,13 +4,15 @@ import Development.Shake import Development.Shake.Command import Development.Shake.FilePath import Control.Monad +import Data.List import System.Directory ( copyFile ) - +import System.FilePath ( searchPathSeparator ) +import System.Environment ( lookupEnv, setEnv, getEnvironment ) +import BuildSystem import Version import Print import Env - stackBuildHie :: VersionNumber -> Action () stackBuildHie versionNumber = execStackWithGhc_ versionNumber ["build"] `actionOnException` liftIO (putStrLn stackBuildFailMsg) @@ -96,3 +98,33 @@ stackBuildFailMsg = ++ "Try running `stack clean` and restart the build\n" ++ "If this does not work, open an issue at \n" ++ "\thttps://github.com/haskell/haskell-ide-engine" + +-- | Run actions with the original user path, without stack additions +withOriginalPath :: Action a -> Action a +withOriginalPath action = do + mbPath <- liftIO (lookupEnv "PATH") + + case (mbPath,isRunFromStack) of + + (Just paths, True) -> do + snapshotDir <- trimmedStdout <$> execStackShake ["path", "--snapshot-install-root"] + + let origPaths = removePathsContaining snapshotDir paths + + liftIO (setEnv "PATH" origPaths) + + a <- action + + liftIO (setEnv "PATH" paths) + + return a + + otherwise -> action + + where removePathsContaining str path = + intercalate [searchPathSeparator] (filter (not.(isInfixOf str)) (splitPaths path)) + splitPaths s = + case dropWhile (== searchPathSeparator) s of + "" -> [] + s' -> w : words s'' + where (w, s'') = break (== searchPathSeparator) s' From 5e216282c0518baa0e23c601e91d1d8724286ae0 Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 10 Oct 2019 11:20:32 +0200 Subject: [PATCH 13/36] Some refactorings --- install/src/Cabal.hs | 25 +++++++++++-------------- install/src/HieInstall.hs | 2 +- install/src/Stack.hs | 5 +++-- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/install/src/Cabal.hs b/install/src/Cabal.hs index edcc90d1e..48487cf37 100644 --- a/install/src/Cabal.hs +++ b/install/src/Cabal.hs @@ -17,7 +17,6 @@ import Version import Print import Env import Stack -import Debug.Trace execCabal :: CmdResult r => [String] -> Action r execCabal = execCabalWithOriginalPath @@ -76,19 +75,17 @@ cabalInstallHie versionNumber = do ++ minorVerExe ++ " to " ++ localBin -installCabal :: Action () -installCabal = do +installCabalWithStack :: Action () +installCabalWithStack = do -- try to find existing `cabal` executable with appropriate version - cabalExeOk <- do - c <- withOriginalPath (liftIO (findExecutable "cabal")) - liftIO $ traceIO $ show c - when (isJust c) checkCabal - return $ isJust c - - -- install `cabal-install` if not already installed - if cabalExeOk - then printLine "There is already a cabal executable in $PATH with the required minimum version." - else execStackShake_ ["install", "cabal-install"] + mbc <- withOriginalPath (liftIO (findExecutable "cabal")) + + case mbc of + Just c -> do + checkCabal + printLine "There is already a cabal executable in $PATH with the required minimum version." + -- install `cabal-install` if not already installed + Nothing -> execStackShake_ ["install", "cabal-install"] -- | check `cabal` has the required version checkCabal :: Action () @@ -122,7 +119,7 @@ cabalInstallNotSuportedFailMsg = -- | Error message when the `cabal` binary is an older version cabalInstallIsOldFailMsg :: String -> String cabalInstallIsOldFailMsg cabalVersion = - "The `cabal` executable is outdated.\n" + "The `cabal` executable found in $PATH is outdated.\n" ++ "found version is `" ++ cabalVersion ++ "`.\n" diff --git a/install/src/HieInstall.hs b/install/src/HieInstall.hs index 58ed14138..50773c7a1 100644 --- a/install/src/HieInstall.hs +++ b/install/src/HieInstall.hs @@ -63,7 +63,7 @@ defaultMain = do want ["short-help"] -- general purpose targets phony "submodules" updateSubmodules - phony "cabal" installCabal + phony "cabal" installCabalWithStack phony "short-help" shortHelpMessage phony "all" shortHelpMessage phony "help" (helpMessage versions) diff --git a/install/src/Stack.hs b/install/src/Stack.hs index 1ad8c192b..a1163cc7e 100644 --- a/install/src/Stack.hs +++ b/install/src/Stack.hs @@ -104,7 +104,7 @@ withOriginalPath :: Action a -> Action a withOriginalPath action = do mbPath <- liftIO (lookupEnv "PATH") - case (mbPath,isRunFromStack) of + case (mbPath, isRunFromStack) of (Just paths, True) -> do snapshotDir <- trimmedStdout <$> execStackShake ["path", "--snapshot-install-root"] @@ -122,7 +122,8 @@ withOriginalPath action = do otherwise -> action where removePathsContaining str path = - intercalate [searchPathSeparator] (filter (not.(isInfixOf str)) (splitPaths path)) + joinPaths (filter (not.(isInfixOf str)) (splitPaths path)) + joinPaths = intercalate [searchPathSeparator] splitPaths s = case dropWhile (== searchPathSeparator) s of "" -> [] From 0037450d7f61d63f8b4a1c0a7862e1c270af7d0a Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 10 Oct 2019 11:35:55 +0200 Subject: [PATCH 14/36] Remove unused import --- install/src/Cabal.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/install/src/Cabal.hs b/install/src/Cabal.hs index 48487cf37..17709f0b2 100644 --- a/install/src/Cabal.hs +++ b/install/src/Cabal.hs @@ -12,7 +12,6 @@ import System.Directory ( findExecutable , copyFile ) -import BuildSystem import Version import Print import Env From da3f7771a9cfb721b0632b77ceff83a1976ba354 Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 10 Oct 2019 12:36:36 +0200 Subject: [PATCH 15/36] Validate cabal after trying to install it --- install/src/HieInstall.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/src/HieInstall.hs b/install/src/HieInstall.hs index 50773c7a1..b05f1714d 100644 --- a/install/src/HieInstall.hs +++ b/install/src/HieInstall.hs @@ -117,9 +117,9 @@ defaultMain = do forM_ ghcVersions (\version -> phony ("cabal-hie-" ++ version) $ do - validateCabalNewInstallIsSupported need ["submodules"] need ["cabal"] + validateCabalNewInstallIsSupported cabalBuildHie version cabalInstallHie version ) From d1e442b6083848b3586a15e16ecb3a4bdcedb659 Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 11 Oct 2019 06:36:35 +0200 Subject: [PATCH 16/36] Take in account local cache dir --- install/src/Stack.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/install/src/Stack.hs b/install/src/Stack.hs index a1163cc7e..1d90dd589 100644 --- a/install/src/Stack.hs +++ b/install/src/Stack.hs @@ -6,7 +6,7 @@ import Development.Shake.FilePath import Control.Monad import Data.List import System.Directory ( copyFile ) -import System.FilePath ( searchPathSeparator ) +import System.FilePath ( searchPathSeparator, () ) import System.Environment ( lookupEnv, setEnv, getEnvironment ) import BuildSystem import Version @@ -108,22 +108,24 @@ withOriginalPath action = do (Just paths, True) -> do snapshotDir <- trimmedStdout <$> execStackShake ["path", "--snapshot-install-root"] - - let origPaths = removePathsContaining snapshotDir paths + localInstallDir <- trimmedStdout <$> execStackShake ["path", "--local-install-dir"] - liftIO (setEnv "PATH" origPaths) + let cacheBinPaths = [snapshotDir "bin", localInstallDir "bin"] + let origPaths = removePathsContaining cacheBinPaths paths + liftIO (setEnv "PATH" origPaths) a <- action - liftIO (setEnv "PATH" paths) - return a otherwise -> action - where removePathsContaining str path = - joinPaths (filter (not.(isInfixOf str)) (splitPaths path)) + where removePathsContaining strs path = + joinPaths (filter (not . containsAny) (splitPaths path)) + where containsAny p = any (`isInfixOf` p) strs + joinPaths = intercalate [searchPathSeparator] + splitPaths s = case dropWhile (== searchPathSeparator) s of "" -> [] From 5c58cd8204eedfadbd601429c597dc5e61416a4e Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Sun, 13 Oct 2019 17:45:23 +0100 Subject: [PATCH 17/36] Making tests more robust --- test/functional/CompletionSpec.hs | 48 +++++++++---------- test/functional/DiagnosticsSpec.hs | 3 +- test/functional/HighlightSpec.hs | 2 +- test/functional/HoverSpec.hs | 2 +- test/functional/ProgressSpec.hs | 21 ++++---- .../addPackageTest/cabal-exe/AddPackage.hs | 3 +- test/utils/TestUtils.hs | 2 +- 7 files changed, 42 insertions(+), 39 deletions(-) diff --git a/test/functional/CompletionSpec.hs b/test/functional/CompletionSpec.hs index 136fdb5c1..cce4d22d2 100644 --- a/test/functional/CompletionSpec.hs +++ b/test/functional/CompletionSpec.hs @@ -16,7 +16,7 @@ spec :: Spec spec = describe "completions" $ do it "works" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "put" _ <- applyEdit doc te @@ -38,7 +38,7 @@ spec = describe "completions" $ do it "completes imports" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 1 17) (Position 1 26)) "Data.M" _ <- applyEdit doc te @@ -52,7 +52,7 @@ spec = describe "completions" $ do it "completes qualified imports" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 2 17) (Position 1 25)) "Dat" _ <- applyEdit doc te @@ -66,7 +66,7 @@ spec = describe "completions" $ do it "completes language extensions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 0 24) (Position 0 31)) "" _ <- applyEdit doc te @@ -79,7 +79,7 @@ spec = describe "completions" $ do it "completes pragmas" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 0 4) (Position 0 34)) "" _ <- applyEdit doc te @@ -94,7 +94,7 @@ spec = describe "completions" $ do it "completes pragmas no close" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 0 4) (Position 0 24)) "" _ <- applyEdit doc te @@ -109,7 +109,7 @@ spec = describe "completions" $ do it "completes options pragma" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 0 4) (Position 0 34)) "OPTIONS" _ <- applyEdit doc te @@ -127,7 +127,7 @@ spec = describe "completions" $ do it "completes ghc options pragma values" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 0 0) (Position 0 0)) "{-# OPTIONS_GHC -Wno-red #-}\n" _ <- applyEdit doc te @@ -144,14 +144,14 @@ spec = describe "completions" $ do it "completes with no prefix" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics compls <- getCompletions doc (Position 5 7) liftIO $ filter ((== "!!") . (^. label)) compls `shouldNotSatisfy` null -- See https://github.com/haskell/haskell-ide-engine/issues/903 it "strips compiler generated stuff from completions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "DupRecFields.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 0) (Position 5 2)) "acc" _ <- applyEdit doc te @@ -167,7 +167,7 @@ spec = describe "completions" $ do describe "contexts" $ do it "only provides type suggestions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Context.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics compls <- getCompletions doc (Position 2 17) liftIO $ do compls `shouldContainCompl` "Integer" @@ -175,7 +175,7 @@ spec = describe "completions" $ do it "only provides type suggestions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Context.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics compls <- getCompletions doc (Position 3 9) liftIO $ do compls `shouldContainCompl` "abs" @@ -184,7 +184,7 @@ spec = describe "completions" $ do -- This currently fails if it takes too long to typecheck the module -- it "completes qualified type suggestions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do -- doc <- openDoc "Context.hs" "haskell" - -- _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + -- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics -- let te = TextEdit (Range (Position 2 17) (Position 2 17)) " -> Conc." -- _ <- applyEdit doc te -- compls <- getCompletions doc (Position 2 26) @@ -195,7 +195,7 @@ spec = describe "completions" $ do it "have implicit foralls on basic polymorphic types" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 9)) "id" _ <- applyEdit doc te compls <- getCompletions doc (Position 5 9) @@ -207,7 +207,7 @@ spec = describe "completions" $ do it "have implicit foralls with multiple type variables" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "flip" _ <- applyEdit doc te compls <- getCompletions doc (Position 5 11) @@ -220,7 +220,7 @@ spec = describe "completions" $ do describe "snippets" $ do it "work for argumentless constructors" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "Nothing" _ <- applyEdit doc te @@ -233,7 +233,7 @@ spec = describe "completions" $ do it "work for polymorphic types" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "fold" _ <- applyEdit doc te @@ -250,7 +250,7 @@ spec = describe "completions" $ do it "work for complex types" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "mapM" _ <- applyEdit doc te @@ -267,7 +267,7 @@ spec = describe "completions" $ do it "work for infix functions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "even `filte" _ <- applyEdit doc te @@ -282,7 +282,7 @@ spec = describe "completions" $ do it "work for infix functions in backticks" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "even `filte`" _ <- applyEdit doc te @@ -297,7 +297,7 @@ spec = describe "completions" $ do it "work for qualified infix functions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "\"\" `Data.List.interspe" _ <- applyEdit doc te @@ -312,7 +312,7 @@ spec = describe "completions" $ do it "work for qualified infix functions in backticks" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "\"\" `Data.List.interspe`" _ <- applyEdit doc te @@ -328,7 +328,7 @@ spec = describe "completions" $ do it "respects lsp configuration" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let config = object ["languageServerHaskell" .= (object ["completionSnippetsOn" .= False])] @@ -338,7 +338,7 @@ spec = describe "completions" $ do it "respects client capabilities" $ runSession hieCommand noSnippetsCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics checkNoSnippets doc where diff --git a/test/functional/DiagnosticsSpec.hs b/test/functional/DiagnosticsSpec.hs index a5459908e..c52056d37 100644 --- a/test/functional/DiagnosticsSpec.hs +++ b/test/functional/DiagnosticsSpec.hs @@ -2,6 +2,7 @@ module DiagnosticsSpec where +import Control.Applicative.Combinators import Control.Lens hiding (List) import Control.Monad.IO.Class import Data.Aeson (toJSON) @@ -87,7 +88,7 @@ spec = describe "diagnostics providers" $ do let te = TextEdit (Range (Position 0 0) (Position 0 13)) "" _ <- applyEdit doc te - noDiagnostics + skipManyTill loggingNotification noDiagnostics sendNotification TextDocumentDidSave (DidSaveTextDocumentParams doc) diags2 <- waitForDiagnostics diff --git a/test/functional/HighlightSpec.hs b/test/functional/HighlightSpec.hs index 35a8ef934..3b0de3349 100644 --- a/test/functional/HighlightSpec.hs +++ b/test/functional/HighlightSpec.hs @@ -12,7 +12,7 @@ spec :: Spec spec = describe "highlight" $ it "works" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "Highlight.hs" "haskell" - _ <- skipManyTill loggingNotification $ count 2 noDiagnostics + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics highlights <- getHighlights doc (Position 2 2) liftIO $ do let hls = diff --git a/test/functional/HoverSpec.hs b/test/functional/HoverSpec.hs index f3553c17a..54816e63a 100644 --- a/test/functional/HoverSpec.hs +++ b/test/functional/HoverSpec.hs @@ -15,7 +15,7 @@ spec :: Spec spec = describe "hover" $ it "works" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "Hover.hs" "haskell" - _ <- skipManyTill loggingNotification $ count 2 noDiagnostics + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics Just h <- getHover doc (Position 1 19) liftIO $ do h ^. range `shouldBe` Just (Range (Position 1 16) (Position 1 19)) diff --git a/test/functional/ProgressSpec.hs b/test/functional/ProgressSpec.hs index a42659cfb..e4b88d343 100644 --- a/test/functional/ProgressSpec.hs +++ b/test/functional/ProgressSpec.hs @@ -32,28 +32,29 @@ spec = describe "window/progress" $ do startNotification ^. L.params . L.title `shouldBe` "Typechecking ApplyRefact2.hs" startNotification ^. L.params . L.id `shouldBe` "0" - doneNotification <- message :: Session ProgressDoneNotification + doneNotification <- skipManyTill loggingNotification (message :: Session ProgressDoneNotification) liftIO $ doneNotification ^. L.params . L.id `shouldBe` "0" -- the ghc-mod diagnostics - _ <- publishDiagnosticsNotification + _ <- skipManyTill loggingNotification publishDiagnosticsNotification -- Test incrementing ids sendNotification TextDocumentDidSave (DidSaveTextDocumentParams doc) -- hlint notifications - _ <- publishDiagnosticsNotification + _ <- skipManyTill loggingNotification publishDiagnosticsNotification - startNotification' <- message :: Session ProgressStartNotification + startNotification' <- skipManyTill loggingNotification (message :: Session ProgressStartNotification) liftIO $ do startNotification' ^. L.params . L.title `shouldBe` "Typechecking ApplyRefact2.hs" startNotification' ^. L.params . L.id `shouldBe` "1" - doneNotification' <- message :: Session ProgressDoneNotification + doneNotification' <- skipManyTill loggingNotification (message :: Session ProgressDoneNotification) liftIO $ doneNotification' ^. L.params . L.id `shouldBe` "1" -- the ghc-mod diagnostics - const () <$> publishDiagnosticsNotification + const () <$> skipManyTill loggingNotification publishDiagnosticsNotification + it "sends indefinite progress notifications with liquid" $ -- Testing that Liquid Haskell sends progress notifications runSession hieCommand progressCaps "test/testdata" $ do @@ -62,13 +63,13 @@ spec = describe "window/progress" $ do skipMany loggingNotification -- Initial hlint notifications - _ <- publishDiagnosticsNotification + _ <- skipManyTill loggingNotification publishDiagnosticsNotification _ <- message :: Session ProgressStartNotification _ <- message :: Session ProgressDoneNotification -- the ghc-mod diagnostics - _ <- publishDiagnosticsNotification + _ <- skipManyTill loggingNotification publishDiagnosticsNotification -- Enable liquid haskell plugin let config = def { liquidOn = True, hlintOn = False } @@ -78,7 +79,7 @@ spec = describe "window/progress" $ do sendNotification TextDocumentDidSave (DidSaveTextDocumentParams doc) -- hlint notifications - _ <- publishDiagnosticsNotification + _ <- skipManyTill loggingNotification publishDiagnosticsNotification let startPred (NotProgressStart m) = m ^. L.params . L.title == "Running Liquid Haskell on Evens.hs" @@ -92,4 +93,4 @@ spec = describe "window/progress" $ do return () progressCaps :: ClientCapabilities -progressCaps = fullCaps { _window = Just (WindowClientCapabilities (Just True)) } \ No newline at end of file +progressCaps = fullCaps { _window = Just (WindowClientCapabilities (Just True)) } diff --git a/test/testdata/addPackageTest/cabal-exe/AddPackage.hs b/test/testdata/addPackageTest/cabal-exe/AddPackage.hs index 963020508..e1bbc6678 100644 --- a/test/testdata/addPackageTest/cabal-exe/AddPackage.hs +++ b/test/testdata/addPackageTest/cabal-exe/AddPackage.hs @@ -1,2 +1,3 @@ import Data.Text -foo = pack "I'm a Text" \ No newline at end of file +foo = pack "I'm a Text" +main = putStrLn "hello" diff --git a/test/utils/TestUtils.hs b/test/utils/TestUtils.hs index 99f415b35..571170fe8 100644 --- a/test/utils/TestUtils.hs +++ b/test/utils/TestUtils.hs @@ -136,7 +136,7 @@ ghcVersion = GHCPre84 stackYaml :: FilePath stackYaml = #if (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,6,5,0))) - "stack.yaml" + "stack-8.6.5.yaml" #elif (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,6,4,0))) "stack-8.6.4.yaml" #elif (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,6,3,0))) From b5e388af80c829bdab8cdc749db8d28492cbff7a Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 14 Oct 2019 13:16:23 +0200 Subject: [PATCH 18/36] Correct stack local install path and use a more precise name for the ugly hack --- install/src/Cabal.hs | 4 ++-- install/src/Stack.hs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/install/src/Cabal.hs b/install/src/Cabal.hs index 17709f0b2..0c0ca380d 100644 --- a/install/src/Cabal.hs +++ b/install/src/Cabal.hs @@ -24,7 +24,7 @@ execCabal_ :: [String] -> Action () execCabal_ = execCabalWithOriginalPath execCabalWithOriginalPath :: CmdResult r => [String] -> Action r -execCabalWithOriginalPath = withOriginalPath . (command [] "cabal") +execCabalWithOriginalPath = withoutStackCachedBinaries . (command [] "cabal") cabalBuildData :: Action () cabalBuildData = do @@ -77,7 +77,7 @@ cabalInstallHie versionNumber = do installCabalWithStack :: Action () installCabalWithStack = do -- try to find existing `cabal` executable with appropriate version - mbc <- withOriginalPath (liftIO (findExecutable "cabal")) + mbc <- withoutStackCachedBinaries (liftIO (findExecutable "cabal")) case mbc of Just c -> do diff --git a/install/src/Stack.hs b/install/src/Stack.hs index 1d90dd589..eef3126a6 100644 --- a/install/src/Stack.hs +++ b/install/src/Stack.hs @@ -99,16 +99,16 @@ stackBuildFailMsg = ++ "If this does not work, open an issue at \n" ++ "\thttps://github.com/haskell/haskell-ide-engine" --- | Run actions with the original user path, without stack additions -withOriginalPath :: Action a -> Action a -withOriginalPath action = do +-- |Run actions without the stack cached binaries +withoutStackCachedBinaries :: Action a -> Action a +withoutStackCachedBinaries action = do mbPath <- liftIO (lookupEnv "PATH") case (mbPath, isRunFromStack) of (Just paths, True) -> do snapshotDir <- trimmedStdout <$> execStackShake ["path", "--snapshot-install-root"] - localInstallDir <- trimmedStdout <$> execStackShake ["path", "--local-install-dir"] + localInstallDir <- trimmedStdout <$> execStackShake ["path", "--local-install-root"] let cacheBinPaths = [snapshotDir "bin", localInstallDir "bin"] let origPaths = removePathsContaining cacheBinPaths paths From 78ec15dd4142956a7ba9b4599cbea501386524d5 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Mon, 14 Oct 2019 20:49:12 +0100 Subject: [PATCH 19/36] Use current stack exe for circleci tests --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 798cdf129..431b64f66 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,6 +26,10 @@ defaults: &defaults - stack-cache-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }} - stack-cache-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "resolver.txt" }} + - run: + name: Stack upgrade + command: stack upgrade + - run: name: Stack setup command: stack -j 2 --stack-yaml=${STACK_FILE} setup From 5e58c510f015931b168abd99cb5207fc6acb417c Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Mon, 14 Oct 2019 22:57:22 +0100 Subject: [PATCH 20/36] Tweak test names --- test/unit/PackagePluginSpec.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit/PackagePluginSpec.hs b/test/unit/PackagePluginSpec.hs index 76f69c36e..2944958ce 100644 --- a/test/unit/PackagePluginSpec.hs +++ b/test/unit/PackagePluginSpec.hs @@ -47,7 +47,7 @@ packageSpec = do let fp = testdata cabal packageType <- findPackageType fp packageType `shouldBe` CabalPackage "add-package-test.cabal" - it "Find no project description if none is present " $ do + it "Find no project description if none is present" $ do let fp = cwd testdata "invalid" packageType <- findPackageType fp packageType `shouldBe` NoPackage @@ -55,7 +55,7 @@ packageSpec = do let fp = testdata "unknownPath" findPackageType fp `shouldThrow` anyIOException describe "Add the package to the correct file" $ do - it "Add package to .cabal to executable component" + it "Adds package to .cabal to executable component" $ withCurrentDirectory (testdata "cabal-exe") $ do let @@ -167,7 +167,7 @@ packageSpec = do testCommand testPlugins act "package" "add" args res - it "Add package to package.yaml to executable component" + it "Adds package to package.yaml to executable component" $ withCurrentDirectory (testdata "hpack-exe") $ do let From 8046e48d83c4f31a4c40a0482b639a2581ba899b Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Mon, 14 Oct 2019 22:57:42 +0100 Subject: [PATCH 21/36] Explicitly log the args passed to MainHie --- app/MainHie.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/MainHie.hs b/app/MainHie.hs index 9976bd89d..e08278eb0 100644 --- a/app/MainHie.hs +++ b/app/MainHie.hs @@ -119,6 +119,8 @@ run opts = do logm $ "Run entered for HIE(" ++ progName ++ ") " ++ version d <- getCurrentDirectory logm $ "Current directory:" ++ d + args <- getArgs + logm $ "args:" ++ show args let vomitOptions = defaultOptions { boLogging = BlVomit} let defaultOpts = if optGhcModVomit opts then vomitOptions else defaultOptions From dbff14b5ef3393e80a5d2b64d3ecd7f213b8e0dc Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Tue, 15 Oct 2019 21:41:06 +0100 Subject: [PATCH 22/36] Revert to stack 1.9.3 Stack 2.1.3 does not build cabal-helper properly on initial run. --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 431b64f66..362d70112 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,9 +26,9 @@ defaults: &defaults - stack-cache-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }} - stack-cache-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "resolver.txt" }} - - run: - name: Stack upgrade - command: stack upgrade + # - run: + # name: Stack upgrade + # command: stack upgrade - run: name: Stack setup From 7ab685b91a70e74058b8c0f4d9cb041e40a1c5ae Mon Sep 17 00:00:00 2001 From: Javier Neira Date: Wed, 16 Oct 2019 08:59:57 +0200 Subject: [PATCH 23/36] Add instructions about install cabal with stack and update instructions to run the build script with cabal on windows --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 091b72853..0a1d4aba7 100644 --- a/README.md +++ b/README.md @@ -212,12 +212,22 @@ The install-script can be invoked via `cabal` instead of `stack` with the comman cabal v2-run ./install.hs --project-file install/shake.project ``` -Running the script with cabal on windows seems to have some issues and is currently not fully supported. +Running the script with cabal on windows requires a cabal version greater or equal to `3.0.0.0`. Unfortunately, it is still required to have `stack` installed so that the install-script can locate the `local-bin` directory (on Linux `~/.local/bin`) and copy the `hie` binaries to `hie-x.y.z`, which is required for the `hie-wrapper` to function as expected. For brevity, only the `stack`-based commands are presented in the following sections. +##### Install cabal using stack + +Although you can use hie for stack based projects (those which have a `stack.yaml` in the project base directory) without having cabal installed, you will need it for cabal based projects (with only a `.cabal` file or a `cabal.project` one in the project base directory). + +You can install an appropiate cabal version using stack by running: + +```bash +stack ./install.hs stack-install-cabal +``` + ##### Install specific GHC Version Install **Nightly** (and hoogle docs): From 60c0df26d1f7544f84fdc9ead0234c367d11d83d Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Sun, 20 Oct 2019 21:53:27 +0100 Subject: [PATCH 24/36] Update haskell-lsp to 0.17 Together with haskell-lsp-types and lsp-test This now supports LSP spec 3.15 --- haskell-ide-engine.cabal | 12 +++--- hie-plugin-api/hie-plugin-api.cabal | 2 +- stack-8.2.2.yaml | 6 +-- stack-8.4.2.yaml | 6 +-- stack-8.4.3.yaml | 6 +-- stack-8.4.4.yaml | 6 +-- stack-8.6.1.yaml | 6 +-- stack-8.6.2.yaml | 6 +-- stack-8.6.3.yaml | 6 +-- stack-8.6.4.yaml | 6 +-- stack-8.6.5.yaml | 6 +-- stack.yaml | 6 +-- test/functional/CommandSpec.hs | 2 +- test/functional/DeferredSpec.hs | 12 +++--- test/functional/FormatSpec.hs | 14 +++---- test/functional/FunctionalCodeActionsSpec.hs | 4 +- test/functional/ProgressSpec.hs | 41 ++++++++++++-------- test/unit/JsonSpec.hs | 6 ++- 18 files changed, 83 insertions(+), 70 deletions(-) diff --git a/haskell-ide-engine.cabal b/haskell-ide-engine.cabal index 4e746183b..7bbd6b3c4 100644 --- a/haskell-ide-engine.cabal +++ b/haskell-ide-engine.cabal @@ -71,8 +71,8 @@ library , gitrev >= 1.1 , haddock-api , haddock-library - , haskell-lsp == 0.16.* - , haskell-lsp-types == 0.16.* + , haskell-lsp == 0.17.* + , haskell-lsp-types == 0.17.* , haskell-src-exts , hie-plugin-api , hoogle >= 5.0.13 @@ -199,7 +199,7 @@ test-suite unit-test , free , ghc , haskell-ide-engine - , haskell-lsp-types == 0.16.* + , haskell-lsp-types == 0.17.* , hie-test-utils , hie-plugin-api , hoogle > 5.0.11 @@ -285,10 +285,10 @@ test-suite func-test , data-default , directory , filepath - , lsp-test >= 0.6.0.0 + , lsp-test >= 0.8.0.0 , haskell-ide-engine - , haskell-lsp-types == 0.16.* - , haskell-lsp == 0.16.* + , haskell-lsp-types == 0.17.* + , haskell-lsp == 0.17.* , hie-test-utils , hie-plugin-api , hspec diff --git a/hie-plugin-api/hie-plugin-api.cabal b/hie-plugin-api/hie-plugin-api.cabal index de48b7ea9..1c4ed1ac1 100644 --- a/hie-plugin-api/hie-plugin-api.cabal +++ b/hie-plugin-api/hie-plugin-api.cabal @@ -45,7 +45,7 @@ library , ghc , ghc-mod-core >= 5.9.0.0 , ghc-project-types >= 5.9.0.0 - , haskell-lsp == 0.16.* + , haskell-lsp == 0.17.* , hslogger , monad-control , mtl diff --git a/stack-8.2.2.yaml b/stack-8.2.2.yaml index 6f716ede3..a36b72f07 100644 --- a/stack-8.2.2.yaml +++ b/stack-8.2.2.yaml @@ -20,14 +20,14 @@ extra-deps: - ghc-exactprint-0.5.8.2 - haddock-api-2.18.1 - haddock-library-1.4.4 -- haskell-lsp-0.16.0.0 -- haskell-lsp-types-0.16.0.0 +- haskell-lsp-0.17.0.0 +- haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.1.17 # last hlint supporting GHC 8.2 - hoogle-5.0.17.9 - hsimport-0.8.8 -- lsp-test-0.7.0.0 +- lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - pretty-show-1.8.2 - rope-utf16-splay-0.3.1.0 diff --git a/stack-8.4.2.yaml b/stack-8.4.2.yaml index 85c616ffb..f1aa155a8 100644 --- a/stack-8.4.2.yaml +++ b/stack-8.4.2.yaml @@ -19,14 +19,14 @@ extra-deps: - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.20.0 - haddock-library-1.6.0 -- haskell-lsp-0.16.0.0 -- haskell-lsp-types-0.16.0.0 +- haskell-lsp-0.17.0.0 +- haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.7.0.0 +- lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - pretty-show-1.8.2 - rope-utf16-splay-0.3.1.0 diff --git a/stack-8.4.3.yaml b/stack-8.4.3.yaml index f129f64af..959961048 100644 --- a/stack-8.4.3.yaml +++ b/stack-8.4.3.yaml @@ -19,14 +19,14 @@ extra-deps: - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.20.0 - haddock-library-1.6.0 -- haskell-lsp-0.16.0.0 -- haskell-lsp-types-0.16.0.0 +- haskell-lsp-0.17.0.0 +- haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.7.0.0 +- lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - pretty-show-1.8.2 - rope-utf16-splay-0.3.1.0 diff --git a/stack-8.4.4.yaml b/stack-8.4.4.yaml index 4e8256b38..99b74e812 100644 --- a/stack-8.4.4.yaml +++ b/stack-8.4.4.yaml @@ -18,14 +18,14 @@ extra-deps: - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.20.0 - haddock-library-1.6.0 -- haskell-lsp-0.16.0.0 -- haskell-lsp-types-0.16.0.0 +- haskell-lsp-0.17.0.0 +- haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.7.0.0 +- lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - optparse-simple-0.1.0 - pretty-show-1.9.5 diff --git a/stack-8.6.1.yaml b/stack-8.6.1.yaml index df3b9ee45..404751b15 100644 --- a/stack-8.6.1.yaml +++ b/stack-8.6.1.yaml @@ -21,14 +21,14 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.21.0 -- haskell-lsp-0.16.0.0 -- haskell-lsp-types-0.16.0.0 +- haskell-lsp-0.17.0.0 +- haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.7.0.0 +- lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - monad-memo-0.4.1 - monoid-subclasses-0.4.6.1 diff --git a/stack-8.6.2.yaml b/stack-8.6.2.yaml index 35e3f9604..a8be3341d 100644 --- a/stack-8.6.2.yaml +++ b/stack-8.6.2.yaml @@ -17,14 +17,14 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.21.0 -- haskell-lsp-0.16.0.0 -- haskell-lsp-types-0.16.0.0 +- haskell-lsp-0.17.0.0 +- haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.7.0.0 +- lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - monad-memo-0.4.1 - multistate-0.8.0.1 diff --git a/stack-8.6.3.yaml b/stack-8.6.3.yaml index 9c29fdc7a..f5fe0c1d1 100644 --- a/stack-8.6.3.yaml +++ b/stack-8.6.3.yaml @@ -17,14 +17,14 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.21.0 -- haskell-lsp-0.16.0.0 -- haskell-lsp-types-0.16.0.0 +- haskell-lsp-0.17.0.0 +- haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.7.0.0 +- lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - monad-memo-0.4.1 - multistate-0.8.0.1 diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index d8f27c8d4..7b702e00f 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -17,13 +17,13 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.22.0 -- haskell-lsp-0.16.0.0 -- haskell-lsp-types-0.16.0.0 +- haskell-lsp-0.17.0.0 +- haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 -- lsp-test-0.7.0.0 +- lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2@rev:1 - monad-memo-0.4.1 - multistate-0.8.0.1 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 46ecdfb1a..51c065f4b 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -17,13 +17,13 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.22.0 -- haskell-lsp-0.16.0.0 -- haskell-lsp-types-0.16.0.0 +- haskell-lsp-0.17.0.0 +- haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - hlint-2.2.2 - hsimport-0.10.0 - hoogle-5.0.17.9 -- lsp-test-0.7.0.0 +- lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2@rev:1 - monad-memo-0.4.1 - multistate-0.8.0.1 diff --git a/stack.yaml b/stack.yaml index b8f0ae23d..465c436b1 100644 --- a/stack.yaml +++ b/stack.yaml @@ -18,11 +18,11 @@ extra-deps: - floskell-0.10.1 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.22.0 -- haskell-lsp-0.16.0.0 -- haskell-lsp-types-0.16.0.0 +- haskell-lsp-0.17.0.0 +- haskell-lsp-types-0.17.0.0 - hlint-2.2.2 - hsimport-0.10.0 -- lsp-test-0.7.0.0 +- lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2@rev:1 - syz-0.2.0.0 - temporary-1.2.1.1 diff --git a/test/functional/CommandSpec.hs b/test/functional/CommandSpec.hs index c85fa0654..fbeb6c8d0 100644 --- a/test/functional/CommandSpec.hs +++ b/test/functional/CommandSpec.hs @@ -24,7 +24,7 @@ spec = describe "commands" $ do it "get de-prefixed" $ runSession hieCommand fullCaps "test/testdata/" $ do ResponseMessage _ _ _ (Just err) <- request WorkspaceExecuteCommand - (ExecuteCommandParams "1234:package:add" (Just (List []))) :: Session ExecuteCommandResponse + (ExecuteCommandParams "1234:package:add" (Just (List [])) Nothing) :: Session ExecuteCommandResponse let ResponseError _ msg _ = err -- We expect an error message about the dud arguments, but should pickup "add" and "package" liftIO $ msg `shouldSatisfy` T.isInfixOf "while parsing args for add in plugin package" diff --git a/test/functional/DeferredSpec.hs b/test/functional/DeferredSpec.hs index 060f2afe5..1676f74cf 100644 --- a/test/functional/DeferredSpec.hs +++ b/test/functional/DeferredSpec.hs @@ -25,18 +25,18 @@ spec = do it "do not affect hover requests" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "FuncTest.hs" "haskell" - id1 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2)) + id1 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2) Nothing) skipMany anyNotification hoverRsp <- message :: Session HoverResponse liftIO $ hoverRsp ^? result . _Just . _Just . contents `shouldBe` Nothing liftIO $ hoverRsp ^. LSP.id `shouldBe` responseId id1 - id2 <- sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc) + id2 <- sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc Nothing) symbolsRsp <- skipManyTill anyNotification message :: Session DocumentSymbolsResponse liftIO $ symbolsRsp ^. LSP.id `shouldBe` responseId id2 - id3 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2)) + id3 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2) Nothing) hoverRsp2 <- skipManyTill anyNotification message :: Session HoverResponse liftIO $ hoverRsp2 ^. LSP.id `shouldBe` responseId id3 @@ -44,8 +44,8 @@ spec = do liftIO $ contents2 `shouldNotSatisfy` null -- Now that we have cache the following request should be instant - let highlightParams = TextDocumentPositionParams doc (Position 7 0) - highlightRsp <- request TextDocumentDocumentHighlight highlightParams :: Session DocumentHighlightsResponse + let highlightParams = TextDocumentPositionParams doc (Position 7 0) Nothing + highlightRsp <- request TextDocumentDocumentHighlight highlightParams let (Just (List locations)) = highlightRsp ^. result liftIO $ locations `shouldBe` [ DocumentHighlight { _range = Range @@ -126,7 +126,7 @@ spec = do let args' = H.fromList [("pos", toJSON (Position 7 0)), ("file", toJSON testUri)] args = List [Object args'] - executeRsp <- request WorkspaceExecuteCommand (ExecuteCommandParams "hare:demote" (Just args)) + executeRsp <- request WorkspaceExecuteCommand (ExecuteCommandParams "hare:demote" (Just args) Nothing) liftIO $ executeRsp ^. result `shouldBe` Just (Object H.empty) editReq <- message :: Session ApplyWorkspaceEditRequest diff --git a/test/functional/FormatSpec.hs b/test/functional/FormatSpec.hs index fbbe919cb..2b8524617 100644 --- a/test/functional/FormatSpec.hs +++ b/test/functional/FormatSpec.hs @@ -30,7 +30,7 @@ spec = do doc <- openDoc "Format.hs" "haskell" formatRange doc (FormattingOptions 5 True) (Range (Position 4 0) (Position 7 19)) documentContents doc >>= liftIO . (`shouldBe` formattedRangeTabSize5) - + describe "formatting provider" $ do let formatLspConfig provider = object [ "languageServerHaskell" .= object ["formattingProvider" .= (provider :: Value)] ] @@ -42,7 +42,7 @@ spec = do formatDoc doc (FormattingOptions 2 True) documentContents doc >>= liftIO . (`shouldBe` orig) - + formatRange doc (FormattingOptions 2 True) (Range (Position 1 0) (Position 3 10)) documentContents doc >>= liftIO . (`shouldBe` orig) @@ -60,18 +60,18 @@ spec = do sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "brittany")) formatDoc doc (FormattingOptions 2 True) documentContents doc >>= liftIO . (`shouldBe` formattedBrittanyPostFloskell) - + describe "brittany" $ do it "formats a document with LF endings" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "BrittanyLF.hs" "haskell" - let opts = DocumentFormattingParams doc (FormattingOptions 4 True) + let opts = DocumentFormattingParams doc (FormattingOptions 4 True) Nothing ResponseMessage _ _ (Just edits) _ <- request TextDocumentFormatting opts liftIO $ edits `shouldBe` [TextEdit (Range (Position 0 0) (Position 3 0)) "foo :: Int -> String -> IO ()\nfoo x y = do\n print x\n return 42\n"] it "formats a document with CRLF endings" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "BrittanyCRLF.hs" "haskell" - let opts = DocumentFormattingParams doc (FormattingOptions 4 True) + let opts = DocumentFormattingParams doc (FormattingOptions 4 True) Nothing ResponseMessage _ _ (Just edits) _ <- request TextDocumentFormatting opts liftIO $ edits `shouldBe` [TextEdit (Range (Position 0 0) (Position 3 0)) "foo :: Int -> String -> IO ()\nfoo x y = do\n print x\n return 42\n"] @@ -79,7 +79,7 @@ spec = do it "formats a range with LF endings" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "BrittanyLF.hs" "haskell" let range = Range (Position 1 0) (Position 2 22) - opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True) + opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True) Nothing ResponseMessage _ _ (Just edits) _ <- request TextDocumentRangeFormatting opts liftIO $ edits `shouldBe` [TextEdit (Range (Position 1 0) (Position 3 0)) "foo x y = do\n print x\n return 42\n"] @@ -87,7 +87,7 @@ spec = do it "formats a range with CRLF endings" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "BrittanyCRLF.hs" "haskell" let range = Range (Position 1 0) (Position 2 22) - opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True) + opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True) Nothing ResponseMessage _ _ (Just edits) _ <- request TextDocumentRangeFormatting opts liftIO $ edits `shouldBe` [TextEdit (Range (Position 1 0) (Position 3 0)) "foo x y = do\n print x\n return 42\n"] diff --git a/test/functional/FunctionalCodeActionsSpec.hs b/test/functional/FunctionalCodeActionsSpec.hs index 60c6c993a..59b2c7db6 100644 --- a/test/functional/FunctionalCodeActionsSpec.hs +++ b/test/functional/FunctionalCodeActionsSpec.hs @@ -503,9 +503,9 @@ spec = describe "code actions" $ do doc <- openDoc "CodeActionOnly.hs" "haskell" _ <- count 2 waitForDiagnostics -- need to wait for both hlint and ghcmod diags <- getCurrentDiagnostics doc - let params = CodeActionParams doc (Range (Position 2 10) (Position 4 0)) caContext + let params = CodeActionParams doc (Range (Position 2 10) (Position 4 0)) caContext Nothing caContext = CodeActionContext (List diags) (Just (List [CodeActionRefactorInline])) - ResponseMessage _ _ (Just (List res)) _ <- request TextDocumentCodeAction params :: Session CodeActionResponse + ResponseMessage _ _ (Just (List res)) _ <- request TextDocumentCodeAction params let cas = map fromAction res kinds = map (^. L.kind) cas liftIO $ do diff --git a/test/functional/ProgressSpec.hs b/test/functional/ProgressSpec.hs index e4b88d343..f0fdfc702 100644 --- a/test/functional/ProgressSpec.hs +++ b/test/functional/ProgressSpec.hs @@ -16,7 +16,7 @@ import Test.Hspec import TestUtils spec :: Spec -spec = describe "window/progress" $ do +spec = describe "window/workDoneProgress" $ do it "sends indefinite progress notifications" $ -- Testing that ghc-mod sends progress notifications runSession hieCommand progressCaps "test/testdata" $ do @@ -27,13 +27,17 @@ spec = describe "window/progress" $ do -- Initial hlint notifications _ <- publishDiagnosticsNotification - startNotification <- message :: Session ProgressStartNotification + createRequest <- message :: Session WorkDoneProgressCreateRequest liftIO $ do - startNotification ^. L.params . L.title `shouldBe` "Typechecking ApplyRefact2.hs" - startNotification ^. L.params . L.id `shouldBe` "0" + createRequest ^. L.params `shouldBe` WorkDoneProgressCreateParams (ProgressNumericToken 0) - doneNotification <- skipManyTill loggingNotification (message :: Session ProgressDoneNotification) - liftIO $ doneNotification ^. L.params . L.id `shouldBe` "0" + startNotification <- message :: Session WorkDoneProgressBeginNotification + liftIO $ do + startNotification ^. L.params . L.value . L.title `shouldBe` "Typechecking ApplyRefact2.hs" + startNotification ^. L.params . L.token `shouldBe` (ProgressNumericToken 0) + + doneNotification <- skipManyTill loggingNotification (message :: Session WorkDoneProgressEndNotification) + liftIO $ doneNotification ^. L.params . L.token `shouldBe` (ProgressNumericToken 0) -- the ghc-mod diagnostics _ <- skipManyTill loggingNotification publishDiagnosticsNotification @@ -44,13 +48,17 @@ spec = describe "window/progress" $ do -- hlint notifications _ <- skipManyTill loggingNotification publishDiagnosticsNotification - startNotification' <- skipManyTill loggingNotification (message :: Session ProgressStartNotification) + createRequest' <- skipManyTill loggingNotification (message :: Session WorkDoneProgressCreateRequest) + liftIO $ do + createRequest' ^. L.params `shouldBe` WorkDoneProgressCreateParams (ProgressNumericToken 1) + + startNotification' <- message :: Session WorkDoneProgressBeginNotification liftIO $ do - startNotification' ^. L.params . L.title `shouldBe` "Typechecking ApplyRefact2.hs" - startNotification' ^. L.params . L.id `shouldBe` "1" + startNotification' ^. L.params . L.value . L.title `shouldBe` "Typechecking ApplyRefact2.hs" + startNotification' ^. L.params . L.token `shouldBe` (ProgressNumericToken 1) - doneNotification' <- skipManyTill loggingNotification (message :: Session ProgressDoneNotification) - liftIO $ doneNotification' ^. L.params . L.id `shouldBe` "1" + doneNotification' <- skipManyTill loggingNotification (message :: Session WorkDoneProgressEndNotification) + liftIO $ doneNotification' ^. L.params . L.token `shouldBe` (ProgressNumericToken 1) -- the ghc-mod diagnostics const () <$> skipManyTill loggingNotification publishDiagnosticsNotification @@ -65,8 +73,9 @@ spec = describe "window/progress" $ do -- Initial hlint notifications _ <- skipManyTill loggingNotification publishDiagnosticsNotification - _ <- message :: Session ProgressStartNotification - _ <- message :: Session ProgressDoneNotification + _ <- message :: Session WorkDoneProgressCreateRequest + _ <- message :: Session WorkDoneProgressBeginNotification + _ <- message :: Session WorkDoneProgressEndNotification -- the ghc-mod diagnostics _ <- skipManyTill loggingNotification publishDiagnosticsNotification @@ -81,11 +90,11 @@ spec = describe "window/progress" $ do -- hlint notifications _ <- skipManyTill loggingNotification publishDiagnosticsNotification - let startPred (NotProgressStart m) = - m ^. L.params . L.title == "Running Liquid Haskell on Evens.hs" + let startPred (NotWorkDoneProgressBegin m) = + m ^. L.params . L.value . L.title == "Running Liquid Haskell on Evens.hs" startPred _ = False - let donePred (NotProgressDone _) = True + let donePred (NotWorkDoneProgressEnd _) = True donePred _ = False _ <- skipManyTill anyMessage $ between (satisfy startPred) (satisfy donePred) $ diff --git a/test/unit/JsonSpec.hs b/test/unit/JsonSpec.hs index 2fe2e4f12..43d001c67 100644 --- a/test/unit/JsonSpec.hs +++ b/test/unit/JsonSpec.hs @@ -12,6 +12,7 @@ import Haskell.Ide.Engine.Plugin.GhcMod import Haskell.Ide.Engine.Plugin.HaRe import Haskell.Ide.Engine.Support.HieExtras import Haskell.Ide.Engine.Config +import Language.Haskell.LSP.Types import Data.Aeson import Test.Hspec @@ -87,7 +88,10 @@ instance Arbitrary TextDocumentIdentifier where arbitrary = TextDocumentIdentifier <$> arbitrary instance Arbitrary TextDocumentPositionParams where - arbitrary = TextDocumentPositionParams <$> arbitrary <*> arbitrary + arbitrary = TextDocumentPositionParams <$> arbitrary <*> arbitrary <*> arbitrary + +instance Arbitrary ProgressToken where + arbitrary = oneof [ProgressTextToken <$> arbitrary, ProgressNumericToken <$> arbitrary] instance Arbitrary IdeErrorCode where arbitrary = arbitraryBoundedEnum From 172a557e8a13ec6973ddbc7088f6c9c4918284a1 Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 21 Oct 2019 14:23:17 +0200 Subject: [PATCH 25/36] Merge branch 'master' using haskell-lsp-0.17 --- .circleci/config.yml | 4 ++ README.md | 12 +++- app/MainHie.hs | 2 + haskell-ide-engine.cabal | 12 ++-- hie-plugin-api/hie-plugin-api.cabal | 2 +- install/hie-install.cabal | 1 + install/src/Cabal.hs | 46 +++++++----- install/src/Help.hs | 8 +++ install/src/HieInstall.hs | 5 +- install/src/Stack.hs | 39 +++++++++- stack-8.2.2.yaml | 6 +- stack-8.4.2.yaml | 6 +- stack-8.4.3.yaml | 6 +- stack-8.4.4.yaml | 6 +- stack-8.6.1.yaml | 6 +- stack-8.6.2.yaml | 6 +- stack-8.6.3.yaml | 6 +- stack-8.6.4.yaml | 6 +- stack-8.6.5.yaml | 6 +- stack.yaml | 6 +- test/functional/CommandSpec.hs | 2 +- test/functional/CompletionSpec.hs | 48 ++++++------- test/functional/DeferredSpec.hs | 12 ++-- test/functional/DiagnosticsSpec.hs | 3 +- test/functional/FormatSpec.hs | 14 ++-- test/functional/FunctionalCodeActionsSpec.hs | 4 +- test/functional/HighlightSpec.hs | 2 +- test/functional/HoverSpec.hs | 2 +- test/functional/ProgressSpec.hs | 72 ++++++++++--------- .../addPackageTest/cabal-exe/AddPackage.hs | 3 +- test/unit/JsonSpec.hs | 6 +- test/unit/PackagePluginSpec.hs | 6 +- test/utils/TestUtils.hs | 2 +- 33 files changed, 225 insertions(+), 142 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 798cdf129..362d70112 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,6 +26,10 @@ defaults: &defaults - stack-cache-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }} - stack-cache-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "resolver.txt" }} + # - run: + # name: Stack upgrade + # command: stack upgrade + - run: name: Stack setup command: stack -j 2 --stack-yaml=${STACK_FILE} setup diff --git a/README.md b/README.md index 7a41506b5..5e5b6a677 100644 --- a/README.md +++ b/README.md @@ -214,12 +214,22 @@ The install-script can be invoked via `cabal` instead of `stack` with the comman cabal v2-run ./install.hs --project-file install/shake.project ``` -Running the script with cabal on windows seems to have some issues and is currently not fully supported. +Running the script with cabal on windows requires a cabal version greater or equal to `3.0.0.0`. Unfortunately, it is still required to have `stack` installed so that the install-script can locate the `local-bin` directory (on Linux `~/.local/bin`) and copy the `hie` binaries to `hie-x.y.z`, which is required for the `hie-wrapper` to function as expected. For brevity, only the `stack`-based commands are presented in the following sections. +##### Install cabal using stack + +Although you can use hie for stack based projects (those which have a `stack.yaml` in the project base directory) without having cabal installed, you will need it for cabal based projects (with only a `.cabal` file or a `cabal.project` one in the project base directory). + +You can install an appropiate cabal version using stack by running: + +```bash +stack ./install.hs stack-install-cabal +``` + ##### Install specific GHC Version Install **Nightly** (and hoogle docs): diff --git a/app/MainHie.hs b/app/MainHie.hs index 1e79ee96b..a9c2c84af 100644 --- a/app/MainHie.hs +++ b/app/MainHie.hs @@ -129,6 +129,8 @@ run opts = do progName <- getProgName logm $ "Run entered for HIE(" ++ progName ++ ") " ++ version logm $ "Current directory:" ++ d + args <- getArgs + logm $ "args:" ++ show args let initOpts = defaultCradleOpts { cradleOptsVerbosity = verbosity } verbosity = if optBiosVerbose opts then Verbose else Silent diff --git a/haskell-ide-engine.cabal b/haskell-ide-engine.cabal index 66098d6db..0e46f5404 100644 --- a/haskell-ide-engine.cabal +++ b/haskell-ide-engine.cabal @@ -70,8 +70,8 @@ library , gitrev >= 1.1 , haddock-api , haddock-library - , haskell-lsp == 0.16.* - , haskell-lsp-types == 0.16.* + , haskell-lsp == 0.17.* + , haskell-lsp-types == 0.17.* , haskell-src-exts , hie-plugin-api , hoogle >= 5.0.13 @@ -204,7 +204,7 @@ test-suite unit-test , free , ghc , haskell-ide-engine - , haskell-lsp-types == 0.16.* + , haskell-lsp-types == 0.17.* , hie-test-utils , hie-plugin-api , hoogle > 5.0.11 @@ -290,10 +290,10 @@ test-suite func-test , data-default , directory , filepath - , lsp-test >= 0.6.0.0 + , lsp-test >= 0.8.0.0 , haskell-ide-engine - , haskell-lsp-types == 0.16.* - , haskell-lsp == 0.16.* + , haskell-lsp-types == 0.17.* + , haskell-lsp == 0.17.* , hie-test-utils , hie-plugin-api , hspec diff --git a/hie-plugin-api/hie-plugin-api.cabal b/hie-plugin-api/hie-plugin-api.cabal index 3caa08e88..d77d5f4cb 100644 --- a/hie-plugin-api/hie-plugin-api.cabal +++ b/hie-plugin-api/hie-plugin-api.cabal @@ -51,7 +51,7 @@ library , ghc , hie-bios , ghc-project-types >= 5.9.0.0 - , haskell-lsp == 0.16.* + , haskell-lsp == 0.17.* , hslogger , unliftio , monad-control diff --git a/install/hie-install.cabal b/install/hie-install.cabal index 287b56f6a..342f87695 100644 --- a/install/hie-install.cabal +++ b/install/hie-install.cabal @@ -21,6 +21,7 @@ library build-depends: base >= 4.9 && < 5 , shake == 0.17.8 , directory + , filepath , extra , text default-extensions: LambdaCase diff --git a/install/src/Cabal.hs b/install/src/Cabal.hs index 68f530049..0c0ca380d 100644 --- a/install/src/Cabal.hs +++ b/install/src/Cabal.hs @@ -17,12 +17,14 @@ import Print import Env import Stack - execCabal :: CmdResult r => [String] -> Action r -execCabal = command [] "cabal" +execCabal = execCabalWithOriginalPath execCabal_ :: [String] -> Action () -execCabal_ = command_ [] "cabal" +execCabal_ = execCabalWithOriginalPath + +execCabalWithOriginalPath :: CmdResult r => [String] -> Action r +execCabalWithOriginalPath = withoutStackCachedBinaries . (command [] "cabal") cabalBuildData :: Action () cabalBuildData = do @@ -57,22 +59,32 @@ cabalInstallHie versionNumber = do , "--overwrite-policy=always" ] ++ installMethod - liftIO $ do - copyFile (localBin "hie" <.> exe) - (localBin "hie-" ++ versionNumber <.> exe) - copyFile (localBin "hie" <.> exe) - (localBin "hie-" ++ dropExtension versionNumber <.> exe) -installCabal :: Action () -installCabal = do + let minorVerExe = "hie-" ++ versionNumber <.> exe + majorVerExe = "hie-" ++ dropExtension versionNumber <.> exe + + liftIO $ do + copyFile (localBin "hie" <.> exe) (localBin minorVerExe) + copyFile (localBin "hie" <.> exe) (localBin majorVerExe) + + printLine $ "Copied executables " + ++ ("hie-wrapper" <.> exe) ++ ", " + ++ ("hie" <.> exe) ++ ", " + ++ majorVerExe ++ " and " + ++ minorVerExe + ++ " to " ++ localBin + +installCabalWithStack :: Action () +installCabalWithStack = do -- try to find existing `cabal` executable with appropriate version - cabalExeOk <- do - c <- liftIO (findExecutable "cabal") - when (isJust c) checkCabal - return $ isJust c + mbc <- withoutStackCachedBinaries (liftIO (findExecutable "cabal")) - -- install `cabal-install` if not already installed - unless cabalExeOk $ execStackShake_ ["install", "cabal-install"] + case mbc of + Just c -> do + checkCabal + printLine "There is already a cabal executable in $PATH with the required minimum version." + -- install `cabal-install` if not already installed + Nothing -> execStackShake_ ["install", "cabal-install"] -- | check `cabal` has the required version checkCabal :: Action () @@ -106,7 +118,7 @@ cabalInstallNotSuportedFailMsg = -- | Error message when the `cabal` binary is an older version cabalInstallIsOldFailMsg :: String -> String cabalInstallIsOldFailMsg cabalVersion = - "The `cabal` executable is outdated.\n" + "The `cabal` executable found in $PATH is outdated.\n" ++ "found version is `" ++ cabalVersion ++ "`.\n" diff --git a/install/src/Help.hs b/install/src/Help.hs index bb9e65363..7a8b347e6 100644 --- a/install/src/Help.hs +++ b/install/src/Help.hs @@ -10,6 +10,7 @@ import Env import Print import Version import BuildSystem +import Cabal printUsage :: Action () printUsage = do @@ -83,6 +84,7 @@ helpMessage versions@BuildableVersions {..} = do , stackTarget buildAllTarget , stackTarget buildDataTarget ] + ++ (if isRunFromStack then [stackTarget installCabalTarget] else []) ++ map (stackTarget . hieTarget) stackVersions cabalTargets = @@ -136,6 +138,12 @@ cabalGhcsTarget = , "Show all GHC versions that can be installed via `cabal-build` and `cabal-build-all`." ) +installCabalTarget :: TargetDescription +installCabalTarget = + ( "install-cabal" + , "Install the cabal executable. It will install the required minimum version for hie (currently " ++ versionToString requiredCabalVersion ++ ") if it isn't already present in $PATH" + ) + -- | Creates a message of the form "a, b, c and d", where a,b,c,d are GHC versions. -- If there is no GHC in the list of `hieVersions` allVersionMessage :: [String] -> String diff --git a/install/src/HieInstall.hs b/install/src/HieInstall.hs index 223dde39b..b05f1714d 100644 --- a/install/src/HieInstall.hs +++ b/install/src/HieInstall.hs @@ -63,7 +63,7 @@ defaultMain = do want ["short-help"] -- general purpose targets phony "submodules" updateSubmodules - phony "cabal" installCabal + phony "cabal" installCabalWithStack phony "short-help" shortHelpMessage phony "all" shortHelpMessage phony "help" (helpMessage versions) @@ -91,6 +91,7 @@ defaultMain = do ) -- stack specific targets + when isRunFromStack (phony "stack-install-cabal" (need ["cabal"])) phony "stack-build" (need (reverse $ map ("stack-hie-" ++) hieVersions)) phony "stack-build-all" (need ["build-data", "build"]) phony "stack-build-data" $ do @@ -116,9 +117,9 @@ defaultMain = do forM_ ghcVersions (\version -> phony ("cabal-hie-" ++ version) $ do - validateCabalNewInstallIsSupported need ["submodules"] need ["cabal"] + validateCabalNewInstallIsSupported cabalBuildHie version cabalInstallHie version ) diff --git a/install/src/Stack.hs b/install/src/Stack.hs index 279bfe9ca..eef3126a6 100644 --- a/install/src/Stack.hs +++ b/install/src/Stack.hs @@ -4,13 +4,15 @@ import Development.Shake import Development.Shake.Command import Development.Shake.FilePath import Control.Monad +import Data.List import System.Directory ( copyFile ) - +import System.FilePath ( searchPathSeparator, () ) +import System.Environment ( lookupEnv, setEnv, getEnvironment ) +import BuildSystem import Version import Print import Env - stackBuildHie :: VersionNumber -> Action () stackBuildHie versionNumber = execStackWithGhc_ versionNumber ["build"] `actionOnException` liftIO (putStrLn stackBuildFailMsg) @@ -96,3 +98,36 @@ stackBuildFailMsg = ++ "Try running `stack clean` and restart the build\n" ++ "If this does not work, open an issue at \n" ++ "\thttps://github.com/haskell/haskell-ide-engine" + +-- |Run actions without the stack cached binaries +withoutStackCachedBinaries :: Action a -> Action a +withoutStackCachedBinaries action = do + mbPath <- liftIO (lookupEnv "PATH") + + case (mbPath, isRunFromStack) of + + (Just paths, True) -> do + snapshotDir <- trimmedStdout <$> execStackShake ["path", "--snapshot-install-root"] + localInstallDir <- trimmedStdout <$> execStackShake ["path", "--local-install-root"] + + let cacheBinPaths = [snapshotDir "bin", localInstallDir "bin"] + let origPaths = removePathsContaining cacheBinPaths paths + + liftIO (setEnv "PATH" origPaths) + a <- action + liftIO (setEnv "PATH" paths) + return a + + otherwise -> action + + where removePathsContaining strs path = + joinPaths (filter (not . containsAny) (splitPaths path)) + where containsAny p = any (`isInfixOf` p) strs + + joinPaths = intercalate [searchPathSeparator] + + splitPaths s = + case dropWhile (== searchPathSeparator) s of + "" -> [] + s' -> w : words s'' + where (w, s'') = break (== searchPathSeparator) s' diff --git a/stack-8.2.2.yaml b/stack-8.2.2.yaml index b0a657cdc..b35b6b43e 100644 --- a/stack-8.2.2.yaml +++ b/stack-8.2.2.yaml @@ -22,14 +22,14 @@ extra-deps: - ghc-exactprint-0.5.8.2 - haddock-api-2.18.1 - haddock-library-1.4.4 -- haskell-lsp-0.16.0.0 -- haskell-lsp-types-0.16.0.0 +- haskell-lsp-0.17.0.0 +- haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.1.17 # last hlint supporting GHC 8.2 - hoogle-5.0.17.9 - hsimport-0.8.8 -- lsp-test-0.7.0.0 +- lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - pretty-show-1.8.2 - rope-utf16-splay-0.3.1.0 diff --git a/stack-8.4.2.yaml b/stack-8.4.2.yaml index d5bf8fc9e..45c984411 100644 --- a/stack-8.4.2.yaml +++ b/stack-8.4.2.yaml @@ -21,14 +21,14 @@ extra-deps: - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.20.0 - haddock-library-1.6.0 - - haskell-lsp-0.16.0.0 - - haskell-lsp-types-0.16.0.0 + - haskell-lsp-0.17.0.0 + - haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 - - lsp-test-0.7.0.0 + - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - pretty-show-1.8.2 - rope-utf16-splay-0.3.1.0 diff --git a/stack-8.4.3.yaml b/stack-8.4.3.yaml index 36f70a58a..f7ad4d2cd 100644 --- a/stack-8.4.3.yaml +++ b/stack-8.4.3.yaml @@ -21,14 +21,14 @@ extra-deps: - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.20.0 - haddock-library-1.6.0 - - haskell-lsp-0.16.0.0 - - haskell-lsp-types-0.16.0.0 + - haskell-lsp-0.17.0.0 + - haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 - - lsp-test-0.7.0.0 + - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - pretty-show-1.8.2 - rope-utf16-splay-0.3.1.0 diff --git a/stack-8.4.4.yaml b/stack-8.4.4.yaml index 0bb6403d5..86537792b 100644 --- a/stack-8.4.4.yaml +++ b/stack-8.4.4.yaml @@ -20,14 +20,14 @@ extra-deps: - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.20.0 - haddock-library-1.6.0 - - haskell-lsp-0.16.0.0 - - haskell-lsp-types-0.16.0.0 + - haskell-lsp-0.17.0.0 + - haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 - - lsp-test-0.7.0.0 + - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - optparse-simple-0.1.0 - pretty-show-1.9.5 diff --git a/stack-8.6.1.yaml b/stack-8.6.1.yaml index 48d153910..7b80cd30f 100644 --- a/stack-8.6.1.yaml +++ b/stack-8.6.1.yaml @@ -23,14 +23,14 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.21.0 - - haskell-lsp-0.16.0.0 - - haskell-lsp-types-0.16.0.0 + - haskell-lsp-0.17.0.0 + - haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 - - lsp-test-0.7.0.0 + - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - monad-memo-0.4.1 - monoid-subclasses-0.4.6.1 diff --git a/stack-8.6.2.yaml b/stack-8.6.2.yaml index 032a43d58..b9ad01374 100644 --- a/stack-8.6.2.yaml +++ b/stack-8.6.2.yaml @@ -19,14 +19,14 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.21.0 - - haskell-lsp-0.16.0.0 - - haskell-lsp-types-0.16.0.0 + - haskell-lsp-0.17.0.0 + - haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 - - lsp-test-0.7.0.0 + - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - monad-memo-0.4.1 - multistate-0.8.0.1 diff --git a/stack-8.6.3.yaml b/stack-8.6.3.yaml index 67938f3d6..47ccb70c9 100644 --- a/stack-8.6.3.yaml +++ b/stack-8.6.3.yaml @@ -19,14 +19,14 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.21.0 - - haskell-lsp-0.16.0.0 - - haskell-lsp-types-0.16.0.0 + - haskell-lsp-0.17.0.0 + - haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - haskell-src-exts-util-0.2.5 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 - - lsp-test-0.7.0.0 + - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - monad-memo-0.4.1 - multistate-0.8.0.1 diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index ff524c7b3..3d932e85e 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -19,13 +19,13 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.22.0 - - haskell-lsp-0.16.0.0 - - haskell-lsp-types-0.16.0.0 + - haskell-lsp-0.17.0.0 + - haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - hlint-2.2.2 - hoogle-5.0.17.9 - hsimport-0.10.0 - - lsp-test-0.7.0.0 + - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2@rev:1 - monad-memo-0.4.1 - multistate-0.8.0.1 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index a428cd12a..78db10bc4 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -19,13 +19,13 @@ extra-deps: - floskell-0.10.0 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.22.0 - - haskell-lsp-0.16.0.0 - - haskell-lsp-types-0.16.0.0 + - haskell-lsp-0.17.0.0 + - haskell-lsp-types-0.17.0.0 - haskell-src-exts-1.21.0 - hlint-2.2.2 - hsimport-0.10.0 - hoogle-5.0.17.9 - - lsp-test-0.7.0.0 + - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2@rev:1 - monad-memo-0.4.1 - multistate-0.8.0.1 diff --git a/stack.yaml b/stack.yaml index cce3790a0..c95cc4cbc 100644 --- a/stack.yaml +++ b/stack.yaml @@ -20,11 +20,11 @@ extra-deps: - floskell-0.10.1 - ghc-lib-parser-8.8.0.20190723 - haddock-api-2.22.0 -- haskell-lsp-0.16.0.0 -- haskell-lsp-types-0.16.0.0 +- haskell-lsp-0.17.0.0 +- haskell-lsp-types-0.17.0.0 - hlint-2.2.2 - hsimport-0.10.0 -- lsp-test-0.7.0.0 +- lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2@rev:1 - syz-0.2.0.0 - temporary-1.2.1.1 diff --git a/test/functional/CommandSpec.hs b/test/functional/CommandSpec.hs index c85fa0654..fbeb6c8d0 100644 --- a/test/functional/CommandSpec.hs +++ b/test/functional/CommandSpec.hs @@ -24,7 +24,7 @@ spec = describe "commands" $ do it "get de-prefixed" $ runSession hieCommand fullCaps "test/testdata/" $ do ResponseMessage _ _ _ (Just err) <- request WorkspaceExecuteCommand - (ExecuteCommandParams "1234:package:add" (Just (List []))) :: Session ExecuteCommandResponse + (ExecuteCommandParams "1234:package:add" (Just (List [])) Nothing) :: Session ExecuteCommandResponse let ResponseError _ msg _ = err -- We expect an error message about the dud arguments, but should pickup "add" and "package" liftIO $ msg `shouldSatisfy` T.isInfixOf "while parsing args for add in plugin package" diff --git a/test/functional/CompletionSpec.hs b/test/functional/CompletionSpec.hs index 136fdb5c1..cce4d22d2 100644 --- a/test/functional/CompletionSpec.hs +++ b/test/functional/CompletionSpec.hs @@ -16,7 +16,7 @@ spec :: Spec spec = describe "completions" $ do it "works" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "put" _ <- applyEdit doc te @@ -38,7 +38,7 @@ spec = describe "completions" $ do it "completes imports" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 1 17) (Position 1 26)) "Data.M" _ <- applyEdit doc te @@ -52,7 +52,7 @@ spec = describe "completions" $ do it "completes qualified imports" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 2 17) (Position 1 25)) "Dat" _ <- applyEdit doc te @@ -66,7 +66,7 @@ spec = describe "completions" $ do it "completes language extensions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 0 24) (Position 0 31)) "" _ <- applyEdit doc te @@ -79,7 +79,7 @@ spec = describe "completions" $ do it "completes pragmas" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 0 4) (Position 0 34)) "" _ <- applyEdit doc te @@ -94,7 +94,7 @@ spec = describe "completions" $ do it "completes pragmas no close" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 0 4) (Position 0 24)) "" _ <- applyEdit doc te @@ -109,7 +109,7 @@ spec = describe "completions" $ do it "completes options pragma" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 0 4) (Position 0 34)) "OPTIONS" _ <- applyEdit doc te @@ -127,7 +127,7 @@ spec = describe "completions" $ do it "completes ghc options pragma values" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 0 0) (Position 0 0)) "{-# OPTIONS_GHC -Wno-red #-}\n" _ <- applyEdit doc te @@ -144,14 +144,14 @@ spec = describe "completions" $ do it "completes with no prefix" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics compls <- getCompletions doc (Position 5 7) liftIO $ filter ((== "!!") . (^. label)) compls `shouldNotSatisfy` null -- See https://github.com/haskell/haskell-ide-engine/issues/903 it "strips compiler generated stuff from completions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "DupRecFields.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 0) (Position 5 2)) "acc" _ <- applyEdit doc te @@ -167,7 +167,7 @@ spec = describe "completions" $ do describe "contexts" $ do it "only provides type suggestions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Context.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics compls <- getCompletions doc (Position 2 17) liftIO $ do compls `shouldContainCompl` "Integer" @@ -175,7 +175,7 @@ spec = describe "completions" $ do it "only provides type suggestions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Context.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics compls <- getCompletions doc (Position 3 9) liftIO $ do compls `shouldContainCompl` "abs" @@ -184,7 +184,7 @@ spec = describe "completions" $ do -- This currently fails if it takes too long to typecheck the module -- it "completes qualified type suggestions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do -- doc <- openDoc "Context.hs" "haskell" - -- _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + -- _ <- count 2 $ skipManyTill loggingNotification noDiagnostics -- let te = TextEdit (Range (Position 2 17) (Position 2 17)) " -> Conc." -- _ <- applyEdit doc te -- compls <- getCompletions doc (Position 2 26) @@ -195,7 +195,7 @@ spec = describe "completions" $ do it "have implicit foralls on basic polymorphic types" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 9)) "id" _ <- applyEdit doc te compls <- getCompletions doc (Position 5 9) @@ -207,7 +207,7 @@ spec = describe "completions" $ do it "have implicit foralls with multiple type variables" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "flip" _ <- applyEdit doc te compls <- getCompletions doc (Position 5 11) @@ -220,7 +220,7 @@ spec = describe "completions" $ do describe "snippets" $ do it "work for argumentless constructors" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "Nothing" _ <- applyEdit doc te @@ -233,7 +233,7 @@ spec = describe "completions" $ do it "work for polymorphic types" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "fold" _ <- applyEdit doc te @@ -250,7 +250,7 @@ spec = describe "completions" $ do it "work for complex types" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "mapM" _ <- applyEdit doc te @@ -267,7 +267,7 @@ spec = describe "completions" $ do it "work for infix functions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "even `filte" _ <- applyEdit doc te @@ -282,7 +282,7 @@ spec = describe "completions" $ do it "work for infix functions in backticks" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "even `filte`" _ <- applyEdit doc te @@ -297,7 +297,7 @@ spec = describe "completions" $ do it "work for qualified infix functions" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "\"\" `Data.List.interspe" _ <- applyEdit doc te @@ -312,7 +312,7 @@ spec = describe "completions" $ do it "work for qualified infix functions in backticks" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let te = TextEdit (Range (Position 5 7) (Position 5 24)) "\"\" `Data.List.interspe`" _ <- applyEdit doc te @@ -328,7 +328,7 @@ spec = describe "completions" $ do it "respects lsp configuration" $ runSession hieCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics let config = object ["languageServerHaskell" .= (object ["completionSnippetsOn" .= False])] @@ -338,7 +338,7 @@ spec = describe "completions" $ do it "respects client capabilities" $ runSession hieCommand noSnippetsCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" - _ <- skipManyTill loggingNotification (count 2 noDiagnostics) + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics checkNoSnippets doc where diff --git a/test/functional/DeferredSpec.hs b/test/functional/DeferredSpec.hs index be9df63b5..9c8cf6b55 100644 --- a/test/functional/DeferredSpec.hs +++ b/test/functional/DeferredSpec.hs @@ -25,18 +25,18 @@ spec = do it "do not affect hover requests" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "FuncTest.hs" "haskell" - id1 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2)) + id1 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2) Nothing) skipMany anyNotification hoverRsp <- message :: Session HoverResponse liftIO $ hoverRsp ^? result . _Just . _Just . contents `shouldBe` Nothing liftIO $ hoverRsp ^. LSP.id `shouldBe` responseId id1 - id2 <- sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc) + id2 <- sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc Nothing) symbolsRsp <- skipManyTill anyNotification message :: Session DocumentSymbolsResponse liftIO $ symbolsRsp ^. LSP.id `shouldBe` responseId id2 - id3 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2)) + id3 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2) Nothing) hoverRsp2 <- skipManyTill anyNotification message :: Session HoverResponse liftIO $ hoverRsp2 ^. LSP.id `shouldBe` responseId id3 @@ -44,8 +44,8 @@ spec = do liftIO $ contents2 `shouldNotSatisfy` null -- Now that we have cache the following request should be instant - let highlightParams = TextDocumentPositionParams doc (Position 7 0) - highlightRsp <- request TextDocumentDocumentHighlight highlightParams :: Session DocumentHighlightsResponse + let highlightParams = TextDocumentPositionParams doc (Position 7 0) Nothing + highlightRsp <- request TextDocumentDocumentHighlight highlightParams let (Just (List locations)) = highlightRsp ^. result liftIO $ locations `shouldBe` [ DocumentHighlight { _range = Range @@ -128,7 +128,7 @@ spec = do let args' = H.fromList [("pos", toJSON (Position 7 0)), ("file", toJSON testUri)] args = List [Object args'] - executeRsp <- request WorkspaceExecuteCommand (ExecuteCommandParams "hare:demote" (Just args)) + executeRsp <- request WorkspaceExecuteCommand (ExecuteCommandParams "hare:demote" (Just args) Nothing) liftIO $ executeRsp ^. result `shouldBe` Just (Object H.empty) editReq <- message :: Session ApplyWorkspaceEditRequest diff --git a/test/functional/DiagnosticsSpec.hs b/test/functional/DiagnosticsSpec.hs index 0b3b84d8e..d9444ed9e 100644 --- a/test/functional/DiagnosticsSpec.hs +++ b/test/functional/DiagnosticsSpec.hs @@ -2,6 +2,7 @@ module DiagnosticsSpec where +import Control.Applicative.Combinators import Control.Lens hiding (List) import Control.Monad.IO.Class import Data.Aeson (toJSON) @@ -87,7 +88,7 @@ spec = describe "diagnostics providers" $ do let te = TextEdit (Range (Position 0 0) (Position 0 13)) "" _ <- applyEdit doc te - noDiagnostics + skipManyTill loggingNotification noDiagnostics sendNotification TextDocumentDidSave (DidSaveTextDocumentParams doc) diags2 <- waitForDiagnostics diff --git a/test/functional/FormatSpec.hs b/test/functional/FormatSpec.hs index fbbe919cb..2b8524617 100644 --- a/test/functional/FormatSpec.hs +++ b/test/functional/FormatSpec.hs @@ -30,7 +30,7 @@ spec = do doc <- openDoc "Format.hs" "haskell" formatRange doc (FormattingOptions 5 True) (Range (Position 4 0) (Position 7 19)) documentContents doc >>= liftIO . (`shouldBe` formattedRangeTabSize5) - + describe "formatting provider" $ do let formatLspConfig provider = object [ "languageServerHaskell" .= object ["formattingProvider" .= (provider :: Value)] ] @@ -42,7 +42,7 @@ spec = do formatDoc doc (FormattingOptions 2 True) documentContents doc >>= liftIO . (`shouldBe` orig) - + formatRange doc (FormattingOptions 2 True) (Range (Position 1 0) (Position 3 10)) documentContents doc >>= liftIO . (`shouldBe` orig) @@ -60,18 +60,18 @@ spec = do sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "brittany")) formatDoc doc (FormattingOptions 2 True) documentContents doc >>= liftIO . (`shouldBe` formattedBrittanyPostFloskell) - + describe "brittany" $ do it "formats a document with LF endings" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "BrittanyLF.hs" "haskell" - let opts = DocumentFormattingParams doc (FormattingOptions 4 True) + let opts = DocumentFormattingParams doc (FormattingOptions 4 True) Nothing ResponseMessage _ _ (Just edits) _ <- request TextDocumentFormatting opts liftIO $ edits `shouldBe` [TextEdit (Range (Position 0 0) (Position 3 0)) "foo :: Int -> String -> IO ()\nfoo x y = do\n print x\n return 42\n"] it "formats a document with CRLF endings" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "BrittanyCRLF.hs" "haskell" - let opts = DocumentFormattingParams doc (FormattingOptions 4 True) + let opts = DocumentFormattingParams doc (FormattingOptions 4 True) Nothing ResponseMessage _ _ (Just edits) _ <- request TextDocumentFormatting opts liftIO $ edits `shouldBe` [TextEdit (Range (Position 0 0) (Position 3 0)) "foo :: Int -> String -> IO ()\nfoo x y = do\n print x\n return 42\n"] @@ -79,7 +79,7 @@ spec = do it "formats a range with LF endings" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "BrittanyLF.hs" "haskell" let range = Range (Position 1 0) (Position 2 22) - opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True) + opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True) Nothing ResponseMessage _ _ (Just edits) _ <- request TextDocumentRangeFormatting opts liftIO $ edits `shouldBe` [TextEdit (Range (Position 1 0) (Position 3 0)) "foo x y = do\n print x\n return 42\n"] @@ -87,7 +87,7 @@ spec = do it "formats a range with CRLF endings" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "BrittanyCRLF.hs" "haskell" let range = Range (Position 1 0) (Position 2 22) - opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True) + opts = DocumentRangeFormattingParams doc range (FormattingOptions 4 True) Nothing ResponseMessage _ _ (Just edits) _ <- request TextDocumentRangeFormatting opts liftIO $ edits `shouldBe` [TextEdit (Range (Position 1 0) (Position 3 0)) "foo x y = do\n print x\n return 42\n"] diff --git a/test/functional/FunctionalCodeActionsSpec.hs b/test/functional/FunctionalCodeActionsSpec.hs index c77ace61f..ef176d4d1 100644 --- a/test/functional/FunctionalCodeActionsSpec.hs +++ b/test/functional/FunctionalCodeActionsSpec.hs @@ -503,9 +503,9 @@ spec = describe "code actions" $ do doc <- openDoc "CodeActionOnly.hs" "haskell" _ <- count 2 waitForDiagnostics -- need to wait for both hlint and ghcmod diags <- getCurrentDiagnostics doc - let params = CodeActionParams doc (Range (Position 2 10) (Position 4 0)) caContext + let params = CodeActionParams doc (Range (Position 2 10) (Position 4 0)) caContext Nothing caContext = CodeActionContext (List diags) (Just (List [CodeActionRefactorInline])) - ResponseMessage _ _ (Just (List res)) _ <- request TextDocumentCodeAction params :: Session CodeActionResponse + ResponseMessage _ _ (Just (List res)) _ <- request TextDocumentCodeAction params let cas = map fromAction res kinds = map (^. L.kind) cas liftIO $ do diff --git a/test/functional/HighlightSpec.hs b/test/functional/HighlightSpec.hs index 35a8ef934..3b0de3349 100644 --- a/test/functional/HighlightSpec.hs +++ b/test/functional/HighlightSpec.hs @@ -12,7 +12,7 @@ spec :: Spec spec = describe "highlight" $ it "works" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "Highlight.hs" "haskell" - _ <- skipManyTill loggingNotification $ count 2 noDiagnostics + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics highlights <- getHighlights doc (Position 2 2) liftIO $ do let hls = diff --git a/test/functional/HoverSpec.hs b/test/functional/HoverSpec.hs index f3553c17a..54816e63a 100644 --- a/test/functional/HoverSpec.hs +++ b/test/functional/HoverSpec.hs @@ -15,7 +15,7 @@ spec :: Spec spec = describe "hover" $ it "works" $ runSession hieCommand fullCaps "test/testdata" $ do doc <- openDoc "Hover.hs" "haskell" - _ <- skipManyTill loggingNotification $ count 2 noDiagnostics + _ <- count 2 $ skipManyTill loggingNotification noDiagnostics Just h <- getHover doc (Position 1 19) liftIO $ do h ^. range `shouldBe` Just (Range (Position 1 16) (Position 1 19)) diff --git a/test/functional/ProgressSpec.hs b/test/functional/ProgressSpec.hs index 2e41037f5..f0fdfc702 100644 --- a/test/functional/ProgressSpec.hs +++ b/test/functional/ProgressSpec.hs @@ -16,7 +16,7 @@ import Test.Hspec import TestUtils spec :: Spec -spec = describe "window/progress" $ do +spec = describe "window/workDoneProgress" $ do it "sends indefinite progress notifications" $ -- Testing that ghc-mod sends progress notifications runSession hieCommand progressCaps "test/testdata" $ do @@ -24,44 +24,44 @@ spec = describe "window/progress" $ do skipMany loggingNotification - startNotification <- message :: Session ProgressStartNotification + -- Initial hlint notifications + _ <- publishDiagnosticsNotification + + createRequest <- message :: Session WorkDoneProgressCreateRequest liftIO $ do - startNotification ^. L.params . L.title `shouldBe` "Initialising Cradle" - startNotification ^. L.params . L.id `shouldBe` "0" + createRequest ^. L.params `shouldBe` WorkDoneProgressCreateParams (ProgressNumericToken 0) - reportNotification <- message :: Session ProgressReportNotification + startNotification <- message :: Session WorkDoneProgressBeginNotification liftIO $ do - reportNotification ^. L.params . L.message `shouldBe` Just "Main" - reportNotification ^. L.params . L.id `shouldBe` "0" + startNotification ^. L.params . L.value . L.title `shouldBe` "Typechecking ApplyRefact2.hs" + startNotification ^. L.params . L.token `shouldBe` (ProgressNumericToken 0) - -- may produce diagnostics - skipMany publishDiagnosticsNotification + doneNotification <- skipManyTill loggingNotification (message :: Session WorkDoneProgressEndNotification) + liftIO $ doneNotification ^. L.params . L.token `shouldBe` (ProgressNumericToken 0) - doneNotification <- message :: Session ProgressDoneNotification - liftIO $ doneNotification ^. L.params . L.id `shouldBe` "0" - - -- Initial hlint notifications - _ <- publishDiagnosticsNotification + -- the ghc-mod diagnostics + _ <- skipManyTill loggingNotification publishDiagnosticsNotification -- Test incrementing ids sendNotification TextDocumentDidSave (DidSaveTextDocumentParams doc) - startNotification' <- message :: Session ProgressStartNotification + -- hlint notifications + _ <- skipManyTill loggingNotification publishDiagnosticsNotification + + createRequest' <- skipManyTill loggingNotification (message :: Session WorkDoneProgressCreateRequest) liftIO $ do - startNotification' ^. L.params . L.title `shouldBe` "loading" - startNotification' ^. L.params . L.id `shouldBe` "1" + createRequest' ^. L.params `shouldBe` WorkDoneProgressCreateParams (ProgressNumericToken 1) - reportNotification' <- message :: Session ProgressReportNotification + startNotification' <- message :: Session WorkDoneProgressBeginNotification liftIO $ do - reportNotification' ^. L.params . L.message `shouldBe` Just "Main" - reportNotification' ^. L.params . L.id `shouldBe` "1" + startNotification' ^. L.params . L.value . L.title `shouldBe` "Typechecking ApplyRefact2.hs" + startNotification' ^. L.params . L.token `shouldBe` (ProgressNumericToken 1) - doneNotification' <- message :: Session ProgressDoneNotification - liftIO $ doneNotification' ^. L.params . L.id `shouldBe` "1" + doneNotification' <- skipManyTill loggingNotification (message :: Session WorkDoneProgressEndNotification) + liftIO $ doneNotification' ^. L.params . L.token `shouldBe` (ProgressNumericToken 1) - -- hlint notifications - _ <- publishDiagnosticsNotification - return () + -- the ghc-mod diagnostics + const () <$> skipManyTill loggingNotification publishDiagnosticsNotification it "sends indefinite progress notifications with liquid" $ -- Testing that Liquid Haskell sends progress notifications @@ -70,9 +70,15 @@ spec = describe "window/progress" $ do skipMany loggingNotification - -- Initial project setup progress notifications - _ <- message :: Session ProgressStartNotification - _ <- message :: Session ProgressDoneNotification + -- Initial hlint notifications + _ <- skipManyTill loggingNotification publishDiagnosticsNotification + + _ <- message :: Session WorkDoneProgressCreateRequest + _ <- message :: Session WorkDoneProgressBeginNotification + _ <- message :: Session WorkDoneProgressEndNotification + + -- the ghc-mod diagnostics + _ <- skipManyTill loggingNotification publishDiagnosticsNotification -- Enable liquid haskell plugin let config = def { liquidOn = True, hlintOn = False } @@ -82,15 +88,13 @@ spec = describe "window/progress" $ do sendNotification TextDocumentDidSave (DidSaveTextDocumentParams doc) -- hlint notifications - -- TODO: potential race between typechecking, e.g. context intialisation - -- TODO: and disabling hlint notifications - -- _ <- publishDiagnosticsNotification + _ <- skipManyTill loggingNotification publishDiagnosticsNotification - let startPred (NotProgressStart m) = - m ^. L.params . L.title == "Running Liquid Haskell on Evens.hs" + let startPred (NotWorkDoneProgressBegin m) = + m ^. L.params . L.value . L.title == "Running Liquid Haskell on Evens.hs" startPred _ = False - let donePred (NotProgressDone _) = True + let donePred (NotWorkDoneProgressEnd _) = True donePred _ = False _ <- skipManyTill anyMessage $ between (satisfy startPred) (satisfy donePred) $ diff --git a/test/testdata/addPackageTest/cabal-exe/AddPackage.hs b/test/testdata/addPackageTest/cabal-exe/AddPackage.hs index 963020508..e1bbc6678 100644 --- a/test/testdata/addPackageTest/cabal-exe/AddPackage.hs +++ b/test/testdata/addPackageTest/cabal-exe/AddPackage.hs @@ -1,2 +1,3 @@ import Data.Text -foo = pack "I'm a Text" \ No newline at end of file +foo = pack "I'm a Text" +main = putStrLn "hello" diff --git a/test/unit/JsonSpec.hs b/test/unit/JsonSpec.hs index 6b13ee182..12e1af9c5 100644 --- a/test/unit/JsonSpec.hs +++ b/test/unit/JsonSpec.hs @@ -12,6 +12,7 @@ import Haskell.Ide.Engine.Plugin.Generic import Haskell.Ide.Engine.Plugin.HaRe import Haskell.Ide.Engine.Support.HieExtras import Haskell.Ide.Engine.Config +import Language.Haskell.LSP.Types import Data.Aeson import Test.Hspec @@ -87,7 +88,10 @@ instance Arbitrary TextDocumentIdentifier where arbitrary = TextDocumentIdentifier <$> arbitrary instance Arbitrary TextDocumentPositionParams where - arbitrary = TextDocumentPositionParams <$> arbitrary <*> arbitrary + arbitrary = TextDocumentPositionParams <$> arbitrary <*> arbitrary <*> arbitrary + +instance Arbitrary ProgressToken where + arbitrary = oneof [ProgressTextToken <$> arbitrary, ProgressNumericToken <$> arbitrary] instance Arbitrary IdeErrorCode where arbitrary = arbitraryBoundedEnum diff --git a/test/unit/PackagePluginSpec.hs b/test/unit/PackagePluginSpec.hs index 488a8ca55..d9b950858 100644 --- a/test/unit/PackagePluginSpec.hs +++ b/test/unit/PackagePluginSpec.hs @@ -47,7 +47,7 @@ packageSpec = do let fp = testdata cabal packageType <- findPackageType fp packageType `shouldBe` CabalPackage "add-package-test.cabal" - it "Find no project description if none is present " $ do + it "Find no project description if none is present" $ do let fp = cwd testdata "invalid" packageType <- findPackageType fp packageType `shouldBe` NoPackage @@ -55,7 +55,7 @@ packageSpec = do let fp = testdata "unknownPath" findPackageType fp `shouldThrow` anyIOException describe "Add the package to the correct file" $ do - it "Add package to .cabal to executable component" + it "Adds package to .cabal to executable component" $ withCurrentDirectory (testdata "cabal-exe") $ do let @@ -167,7 +167,7 @@ packageSpec = do testCommand testPlugins act "package" "add" args res - it "Add package to package.yaml to executable component" + it "Adds package to package.yaml to executable component" $ withCurrentDirectory (testdata "hpack-exe") $ do let diff --git a/test/utils/TestUtils.hs b/test/utils/TestUtils.hs index d99f32c38..75b7cf67a 100644 --- a/test/utils/TestUtils.hs +++ b/test/utils/TestUtils.hs @@ -135,7 +135,7 @@ ghcVersion = GHCPre84 stackYaml :: FilePath stackYaml = #if (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,6,5,0))) - "stack.yaml" + "stack-8.6.5.yaml" #elif (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,6,4,0))) "stack-8.6.4.yaml" #elif (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,6,3,0))) From e53b22104b258e58af67c950c913936a773c7f6f Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Mon, 21 Oct 2019 21:32:26 +0100 Subject: [PATCH 26/36] Bump resolvers and deps brittany-0.12.1 floskell-0.10.1 hlint-2.2.3 hsimport-0.11.0 --- stack-8.4.2.yaml | 14 +++++++------- stack-8.4.3.yaml | 14 +++++++------- stack-8.4.4.yaml | 14 +++++++------- stack-8.6.1.yaml | 18 ++++++++++-------- stack-8.6.2.yaml | 18 ++++++++++-------- stack-8.6.3.yaml | 14 +++++++------- stack-8.6.4.yaml | 14 +++++++------- stack-8.6.5.yaml | 22 +++++++++------------- stack.yaml | 12 ++++++------ 9 files changed, 70 insertions(+), 70 deletions(-) diff --git a/stack-8.4.2.yaml b/stack-8.4.2.yaml index f1aa155a8..f7d20a309 100644 --- a/stack-8.4.2.yaml +++ b/stack-8.4.2.yaml @@ -10,22 +10,22 @@ extra-deps: - ./submodules/ghc-mod/core - ./submodules/ghc-mod/ghc-project-types -- brittany-0.12.0.0 +- brittany-0.12.1.0 - base-compat-0.9.3 - cabal-plan-0.3.0.0 - constrained-dynamic-0.1.0.0 -- floskell-0.10.0 +- floskell-0.10.1 - ghc-exactprint-0.5.8.2 -- ghc-lib-parser-8.8.0.20190723 +- ghc-lib-parser-8.8.1 - haddock-api-2.20.0 - haddock-library-1.6.0 - haskell-lsp-0.17.0.0 - haskell-lsp-types-0.17.0.0 -- haskell-src-exts-1.21.0 +- haskell-src-exts-1.21.1 - haskell-src-exts-util-0.2.5 -- hlint-2.2.2 -- hoogle-5.0.17.9 -- hsimport-0.10.0 +- hlint-2.2.3 +- hoogle-5.0.17.11 +- hsimport-0.11.0 - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - pretty-show-1.8.2 diff --git a/stack-8.4.3.yaml b/stack-8.4.3.yaml index 959961048..728ba2efd 100644 --- a/stack-8.4.3.yaml +++ b/stack-8.4.3.yaml @@ -11,21 +11,21 @@ extra-deps: - ./submodules/ghc-mod/ghc-project-types - base-compat-0.9.3 -- brittany-0.12.0.0 +- brittany-0.12.1.0 - cabal-plan-0.3.0.0 - constrained-dynamic-0.1.0.0 -- floskell-0.10.0 +- floskell-0.10.1 - ghc-exactprint-0.5.8.2 -- ghc-lib-parser-8.8.0.20190723 +- ghc-lib-parser-8.8.1 - haddock-api-2.20.0 - haddock-library-1.6.0 - haskell-lsp-0.17.0.0 - haskell-lsp-types-0.17.0.0 -- haskell-src-exts-1.21.0 +- haskell-src-exts-1.21.1 - haskell-src-exts-util-0.2.5 -- hlint-2.2.2 -- hoogle-5.0.17.9 -- hsimport-0.10.0 +- hlint-2.2.3 +- hoogle-5.0.17.11 +- hsimport-0.11.0 - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - pretty-show-1.8.2 diff --git a/stack-8.4.4.yaml b/stack-8.4.4.yaml index 99b74e812..05258f8d0 100644 --- a/stack-8.4.4.yaml +++ b/stack-8.4.4.yaml @@ -10,21 +10,21 @@ extra-deps: - ./submodules/ghc-mod/core - ./submodules/ghc-mod/ghc-project-types -- brittany-0.12.0.0 +- brittany-0.12.1.0 - cabal-plan-0.4.0.0 - constrained-dynamic-0.1.0.0 -- floskell-0.10.0 +- floskell-0.10.1 - ghc-exactprint-0.5.8.2 -- ghc-lib-parser-8.8.0.20190723 +- ghc-lib-parser-8.8.1 - haddock-api-2.20.0 - haddock-library-1.6.0 - haskell-lsp-0.17.0.0 - haskell-lsp-types-0.17.0.0 -- haskell-src-exts-1.21.0 +- haskell-src-exts-1.21.1 - haskell-src-exts-util-0.2.5 -- hlint-2.2.2 -- hoogle-5.0.17.9 -- hsimport-0.10.0 +- hlint-2.2.3 +- hoogle-5.0.17.11 +- hsimport-0.11.0 - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - optparse-simple-0.1.0 diff --git a/stack-8.6.1.yaml b/stack-8.6.1.yaml index 404751b15..08b24e7be 100644 --- a/stack-8.6.1.yaml +++ b/stack-8.6.1.yaml @@ -11,23 +11,24 @@ extra-deps: - ./submodules/ghc-mod/ghc-project-types - apply-refact-0.6.0.0 -- brittany-0.12.0.0 -- butcher-1.3.2.1 +- brittany-0.12.1.0 +- butcher-1.3.2.3 - cabal-install-2.4.0.0 - cabal-plan-0.4.0.0 - constrained-dynamic-0.1.0.0 - czipwith-1.0.1.1 - data-tree-print-0.1.0.2 -- floskell-0.10.0 -- ghc-lib-parser-8.8.0.20190723 +- deque-0.4.3 +- floskell-0.10.1 +- ghc-lib-parser-8.8.1 - haddock-api-2.21.0 - haskell-lsp-0.17.0.0 - haskell-lsp-types-0.17.0.0 -- haskell-src-exts-1.21.0 +- haskell-src-exts-1.21.1 - haskell-src-exts-util-0.2.5 -- hlint-2.2.2 -- hoogle-5.0.17.9 -- hsimport-0.10.0 +- hlint-2.2.3 +- hoogle-5.0.17.11 +- hsimport-0.11.0 - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - monad-memo-0.4.1 @@ -36,6 +37,7 @@ extra-deps: - primes-0.2.1.0 - resolv-0.1.1.2 - rope-utf16-splay-0.3.1.0 +- strict-list-0.1.5 - syz-0.2.0.0 - temporary-1.2.1.1 # To make build work in windows 7 diff --git a/stack-8.6.2.yaml b/stack-8.6.2.yaml index a8be3341d..8228d8591 100644 --- a/stack-8.6.2.yaml +++ b/stack-8.6.2.yaml @@ -10,25 +10,27 @@ extra-deps: - ./submodules/ghc-mod/core - ./submodules/ghc-mod/ghc-project-types -- brittany-0.12.0.0 -- butcher-1.3.2.1 +- brittany-0.12.1.0 +- butcher-1.3.2.3 - cabal-plan-0.4.0.0 - constrained-dynamic-0.1.0.0 -- floskell-0.10.0 -- ghc-lib-parser-8.8.0.20190723 +- deque-0.4.3 +- floskell-0.10.1 +- ghc-lib-parser-8.8.1 - haddock-api-2.21.0 - haskell-lsp-0.17.0.0 - haskell-lsp-types-0.17.0.0 -- haskell-src-exts-1.21.0 +- haskell-src-exts-1.21.1 - haskell-src-exts-util-0.2.5 -- hlint-2.2.2 -- hoogle-5.0.17.9 -- hsimport-0.10.0 +- hlint-2.2.3 +- hoogle-5.0.17.11 +- hsimport-0.11.0 - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - monad-memo-0.4.1 - multistate-0.8.0.1 - rope-utf16-splay-0.3.1.0 +- strict-list-0.1.5 - syz-0.2.0.0 - temporary-1.2.1.1 # To make build work in windows 7 diff --git a/stack-8.6.3.yaml b/stack-8.6.3.yaml index f5fe0c1d1..a7d8a85c2 100644 --- a/stack-8.6.3.yaml +++ b/stack-8.6.3.yaml @@ -10,20 +10,20 @@ extra-deps: - ./submodules/ghc-mod/core - ./submodules/ghc-mod/ghc-project-types -- brittany-0.12.0.0 +- brittany-0.12.1.0 - butcher-1.3.2.1 - cabal-plan-0.4.0.0 - constrained-dynamic-0.1.0.0 -- floskell-0.10.0 -- ghc-lib-parser-8.8.0.20190723 +- floskell-0.10.1 +- ghc-lib-parser-8.8.1 - haddock-api-2.21.0 - haskell-lsp-0.17.0.0 - haskell-lsp-types-0.17.0.0 -- haskell-src-exts-1.21.0 +- haskell-src-exts-1.21.1 - haskell-src-exts-util-0.2.5 -- hlint-2.2.2 -- hoogle-5.0.17.9 -- hsimport-0.10.0 +- hlint-2.2.3 +- hoogle-5.0.17.11 +- hsimport-0.11.0 - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2 - monad-memo-0.4.1 diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index 7b702e00f..adea017a2 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -10,19 +10,19 @@ extra-deps: - ./submodules/ghc-mod/core - ./submodules/ghc-mod/ghc-project-types -- brittany-0.12.0.0 +- brittany-0.12.1.0 - butcher-1.3.2.1 - cabal-plan-0.4.0.0 - constrained-dynamic-0.1.0.0 -- floskell-0.10.0 -- ghc-lib-parser-8.8.0.20190723 +- floskell-0.10.1 +- ghc-lib-parser-8.8.1 - haddock-api-2.22.0 - haskell-lsp-0.17.0.0 - haskell-lsp-types-0.17.0.0 -- haskell-src-exts-1.21.0 -- hlint-2.2.2 -- hoogle-5.0.17.9 -- hsimport-0.10.0 +- haskell-src-exts-1.21.1 +- hlint-2.2.3 +- hoogle-5.0.17.11 +- hsimport-0.11.0 - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2@rev:1 - monad-memo-0.4.1 diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 51c065f4b..3bf0af29f 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -1,4 +1,4 @@ -resolver: lts-13.30 +resolver: lts-14.11 packages: - . - hie-plugin-api @@ -10,27 +10,23 @@ extra-deps: - ./submodules/ghc-mod/core - ./submodules/ghc-mod/ghc-project-types -- brittany-0.12.0.0 -- butcher-1.3.2.1 +- ansi-terminal-0.8.2 +- ansi-wl-pprint-0.6.8.2 +- brittany-0.12.1.0 - cabal-plan-0.4.0.0 - constrained-dynamic-0.1.0.0 -- floskell-0.10.0 -- ghc-lib-parser-8.8.0.20190723 +- floskell-0.10.1 +- ghc-lib-parser-8.8.1 - haddock-api-2.22.0 - haskell-lsp-0.17.0.0 - haskell-lsp-types-0.17.0.0 -- haskell-src-exts-1.21.0 -- hlint-2.2.2 -- hsimport-0.10.0 -- hoogle-5.0.17.9 +- hlint-2.2.3 +- hsimport-0.11.0 +- hoogle-5.0.17.11 - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2@rev:1 -- monad-memo-0.4.1 -- multistate-0.8.0.1 -- rope-utf16-splay-0.3.1.0 - syz-0.2.0.0 - temporary-1.2.1.1 -- yaml-0.8.32 flags: haskell-ide-engine: diff --git a/stack.yaml b/stack.yaml index 465c436b1..a5db7b88e 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: nightly-2019-07-31 # GHC 8.6.5 +resolver: nightly-2019-09-21 # Last GHC 8.6.5 packages: - . - hie-plugin-api @@ -12,21 +12,21 @@ extra-deps: - ansi-terminal-0.8.2 - ansi-wl-pprint-0.6.8.2 -- brittany-0.12.0.0 +- brittany-0.12.1.0 - cabal-plan-0.4.0.0 - constrained-dynamic-0.1.0.0 - floskell-0.10.1 -- ghc-lib-parser-8.8.0.20190723 +- ghc-lib-parser-8.8.1 - haddock-api-2.22.0 - haskell-lsp-0.17.0.0 - haskell-lsp-types-0.17.0.0 -- hlint-2.2.2 -- hsimport-0.10.0 +- hlint-2.2.3 +- hsimport-0.11.0 - lsp-test-0.8.0.0 - monad-dijkstra-0.1.1.2@rev:1 - syz-0.2.0.0 - temporary-1.2.1.1 -- yaml-0.8.32 +# - yaml-0.8.32 flags: haskell-ide-engine: From 41cfce08b7758c4f6be75790423c8fe071510658 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Mon, 21 Oct 2019 21:55:03 +0100 Subject: [PATCH 27/36] Clean up comment from yaml file --- stack.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/stack.yaml b/stack.yaml index a5db7b88e..0acbf41fa 100644 --- a/stack.yaml +++ b/stack.yaml @@ -26,7 +26,6 @@ extra-deps: - monad-dijkstra-0.1.1.2@rev:1 - syz-0.2.0.0 - temporary-1.2.1.1 -# - yaml-0.8.32 flags: haskell-ide-engine: From f5614720279b55ddf1044b484f6b9981577b0daa Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 22 Oct 2019 13:05:22 +0200 Subject: [PATCH 28/36] Integrate changes from hie-bios --- test/functional/ProgressSpec.hs | 45 +++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/test/functional/ProgressSpec.hs b/test/functional/ProgressSpec.hs index f0fdfc702..b1a49da78 100644 --- a/test/functional/ProgressSpec.hs +++ b/test/functional/ProgressSpec.hs @@ -24,44 +24,52 @@ spec = describe "window/workDoneProgress" $ do skipMany loggingNotification - -- Initial hlint notifications - _ <- publishDiagnosticsNotification - createRequest <- message :: Session WorkDoneProgressCreateRequest liftIO $ do createRequest ^. L.params `shouldBe` WorkDoneProgressCreateParams (ProgressNumericToken 0) startNotification <- message :: Session WorkDoneProgressBeginNotification liftIO $ do - startNotification ^. L.params . L.value . L.title `shouldBe` "Typechecking ApplyRefact2.hs" + startNotification ^. L.params . L.value . L.title `shouldBe` "Initialising Cradle" startNotification ^. L.params . L.token `shouldBe` (ProgressNumericToken 0) - doneNotification <- skipManyTill loggingNotification (message :: Session WorkDoneProgressEndNotification) + reportNotification <- message :: Session WorkDoneProgressReportNotification + liftIO $ do + reportNotification ^. L.params . L.value . L.message `shouldBe` Just "Main" + reportNotification ^. L.params . L.token `shouldBe` (ProgressNumericToken 0) + + -- may produce diagnostics + skipMany publishDiagnosticsNotification + + doneNotification <- message :: Session WorkDoneProgressEndNotification liftIO $ doneNotification ^. L.params . L.token `shouldBe` (ProgressNumericToken 0) - -- the ghc-mod diagnostics - _ <- skipManyTill loggingNotification publishDiagnosticsNotification + -- Initial hlint notifications + _ <- publishDiagnosticsNotification -- Test incrementing ids sendNotification TextDocumentDidSave (DidSaveTextDocumentParams doc) - -- hlint notifications - _ <- skipManyTill loggingNotification publishDiagnosticsNotification - createRequest' <- skipManyTill loggingNotification (message :: Session WorkDoneProgressCreateRequest) liftIO $ do createRequest' ^. L.params `shouldBe` WorkDoneProgressCreateParams (ProgressNumericToken 1) startNotification' <- message :: Session WorkDoneProgressBeginNotification liftIO $ do - startNotification' ^. L.params . L.value . L.title `shouldBe` "Typechecking ApplyRefact2.hs" + startNotification' ^. L.params . L.value . L.title `shouldBe` "Initialising Cradle" startNotification' ^. L.params . L.token `shouldBe` (ProgressNumericToken 1) - doneNotification' <- skipManyTill loggingNotification (message :: Session WorkDoneProgressEndNotification) + reportNotification' <- message :: Session WorkDoneProgressReportNotification + liftIO $ do + reportNotification' ^. L.params . L.value . L.message `shouldBe` Just "Main" + reportNotification' ^. L.params . L.token `shouldBe` (ProgressNumericToken 1) + + doneNotification' <- message :: Session WorkDoneProgressEndNotification liftIO $ doneNotification' ^. L.params . L.token `shouldBe` (ProgressNumericToken 1) - -- the ghc-mod diagnostics - const () <$> skipManyTill loggingNotification publishDiagnosticsNotification + -- Initial hlint notifications + _ <- publishDiagnosticsNotification + return () it "sends indefinite progress notifications with liquid" $ -- Testing that Liquid Haskell sends progress notifications @@ -70,14 +78,11 @@ spec = describe "window/workDoneProgress" $ do skipMany loggingNotification - -- Initial hlint notifications - _ <- skipManyTill loggingNotification publishDiagnosticsNotification - _ <- message :: Session WorkDoneProgressCreateRequest _ <- message :: Session WorkDoneProgressBeginNotification _ <- message :: Session WorkDoneProgressEndNotification - -- the ghc-mod diagnostics + -- the hie-bios diagnostics _ <- skipManyTill loggingNotification publishDiagnosticsNotification -- Enable liquid haskell plugin @@ -88,7 +93,9 @@ spec = describe "window/workDoneProgress" $ do sendNotification TextDocumentDidSave (DidSaveTextDocumentParams doc) -- hlint notifications - _ <- skipManyTill loggingNotification publishDiagnosticsNotification + -- TODO: potential race between typechecking, e.g. context intialisation + -- TODO: and disabling hlint notifications + -- _ <- skipManyTill loggingNotification publishDiagnosticsNotification let startPred (NotWorkDoneProgressBegin m) = m ^. L.params . L.value . L.title == "Running Liquid Haskell on Evens.hs" From 627bf2d797aab5c38210835074f787b58d1f47a7 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Tue, 22 Oct 2019 17:57:35 +0100 Subject: [PATCH 29/36] Prevent CircleCI OOM on "Install Hoogle" step --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 362d70112..0858f26e8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,7 +40,7 @@ defaults: &defaults - run: name: Install Hoogle - command: stack --stack-yaml=${STACK_FILE} install hoogle + command: stack -j 1 --stack-yaml=${STACK_FILE} install hoogle - run: name: Build (we need the exe for tests) From 3a17fce3820e7b443459fbbe7567ac07c1c0ec03 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Tue, 22 Oct 2019 21:56:16 +0100 Subject: [PATCH 30/36] Preparing 0.13 release --- Changelog.md | 83 +++++++++++++++++++++++++++++ haskell-ide-engine.cabal | 2 +- hie-plugin-api/hie-plugin-api.cabal | 2 +- 3 files changed, 85 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index b8f7b7631..c610a620f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,86 @@ +# 0.13.0.0 + +- Bump resolvers and deps `lts-14.11` for GHC 8.6.5, and +`nightly-2019-09-21` for nightyly build, the last one to support GHC +8.6.5. + + Key deps updated + - brittany-0.12.1 + - floskell-0.10.1 + - hlint-2.2.3 + - hsimport-0.11.0 + + ([#1419](https://github.com/haskell/haskell-ide-engine/pull/1419), by @alanz) + +- Update haskell-lsp to 0.17 +([#1418](https://github.com/haskell/haskell-ide-engine/pull/1418), by @alanz) + +- Add instructions about install cabal with stack in the README +([#1414](https://github.com/haskell/haskell-ide-engine/pull/1414), by @jneira) + +- Robust tests +([#1413](https://github.com/haskell/haskell-ide-engine/pull/1413), by @alanz) + +- Find and run cabal in user original $PATH +([#1406](https://github.com/haskell/haskell-ide-engine/pull/1406), by @jneira) + +- Add stack-install-cabal target and confirmation messages +([#1405](https://github.com/haskell/haskell-ide-engine/pull/1405), by @jneira) + +- Haskell lsp 0.16 +([#1402](https://github.com/haskell/haskell-ide-engine/pull/1402), by @alanz) + +- Handling Windows specific delimiters in func tests +([#1400](https://github.com/haskell/haskell-ide-engine/pull/1400), by @jneira) + +- Fix more code actions in windows +([#1399](https://github.com/haskell/haskell-ide-engine/pull/1399), by @jneira) + +- Upgrade network to 3.0.1.1 +([#1395](https://github.com/haskell/haskell-ide-engine/pull/1395), by @jneira) + +- Use the new key format in one line for azure cache +([#1394](https://github.com/haskell/haskell-ide-engine/pull/1394), by @jneira) + +- Fix code renaming in windows +([#1392](https://github.com/haskell/haskell-ide-engine/pull/1392), by @jneira) + +- Add CodeTriage badge +([#1381](https://github.com/haskell/haskell-ide-engine/pull/1381), by @NickSeagull) + +- Add support for building with cabal-3.0.0.0 +([#1379](https://github.com/haskell/haskell-ide-engine/pull/1379), by @jneira) + +- Refactor backtick aware completion +([#1377](https://github.com/haskell/haskell-ide-engine/pull/1377), by @fendor) + +- Add different Contexts for Module, import etc... +([#1375](https://github.com/haskell/haskell-ide-engine/pull/1375), by @fendor) + +- Do not traverse into Generated bindings when creating TypeMap +([#1372](https://github.com/haskell/haskell-ide-engine/pull/1372), by @fendor) + +- Readme: Mention cabal configure and restarting HIE for troubleshooting +([#1370](https://github.com/haskell/haskell-ide-engine/pull/1370), by @Infinisil) + +- Split out completion from HieExtras +([#1369](https://github.com/haskell/haskell-ide-engine/pull/1369), by @bubba) + +- Remove cabal check from stack builds +([#1368](https://github.com/haskell/haskell-ide-engine/pull/1368), by @ollef) + +- Recommend Coc over LanguageClient-neovim +([#1367](https://github.com/haskell/haskell-ide-engine/pull/1367), by @Avi-D-coder) + +- Install: Fix broken stack-build target and fix cabal run help msg +([#1363](https://github.com/haskell/haskell-ide-engine/pull/1363), by @fendor) + +- Fix error message if outdated cabal dependency +([#1361](https://github.com/haskell/haskell-ide-engine/pull/1361), by @fendor) + +- Made hlint dependency properly depend on version of ghc. +([#1355](https://github.com/haskell/haskell-ide-engine/pull/1355), by @LinuxUser404) + # 0.12.0.0 - Monthly resolver bump, `lts-13.30` for GHC 8.6.5, and `nightly-2019-07-31` for diff --git a/haskell-ide-engine.cabal b/haskell-ide-engine.cabal index 7bbd6b3c4..a17abbbec 100644 --- a/haskell-ide-engine.cabal +++ b/haskell-ide-engine.cabal @@ -1,5 +1,5 @@ name: haskell-ide-engine -version: 0.12.0.0 +version: 0.13.0.0 synopsis: Provide a common engine to power any Haskell IDE description: Please see README.md homepage: http://github.com/githubuser/haskell-ide-engine#readme diff --git a/hie-plugin-api/hie-plugin-api.cabal b/hie-plugin-api/hie-plugin-api.cabal index 1c4ed1ac1..02759d407 100644 --- a/hie-plugin-api/hie-plugin-api.cabal +++ b/hie-plugin-api/hie-plugin-api.cabal @@ -1,5 +1,5 @@ name: hie-plugin-api -version: 0.12.0.0 +version: 0.13.0.0 synopsis: Haskell IDE API for plugin communication license: BSD3 license-file: LICENSE From 582ff056c9b2480834859a61ed81ae1db97d106b Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 23 Oct 2019 11:34:04 +0200 Subject: [PATCH 31/36] Add intermediate progress report notification --- test/functional/ProgressSpec.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/functional/ProgressSpec.hs b/test/functional/ProgressSpec.hs index b1a49da78..6edc2875d 100644 --- a/test/functional/ProgressSpec.hs +++ b/test/functional/ProgressSpec.hs @@ -78,8 +78,9 @@ spec = describe "window/workDoneProgress" $ do skipMany loggingNotification - _ <- message :: Session WorkDoneProgressCreateRequest + _ <- message :: Session WorkDoneProgressCreateRequest _ <- message :: Session WorkDoneProgressBeginNotification + _ <- message :: Session WorkDoneProgressReportNotification _ <- message :: Session WorkDoneProgressEndNotification -- the hie-bios diagnostics From 1cf6ab7cf6f53b87cbca8bb9ba702098efb560db Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 23 Oct 2019 11:39:34 +0200 Subject: [PATCH 32/36] Correct progress title of second request --- test/functional/ProgressSpec.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/ProgressSpec.hs b/test/functional/ProgressSpec.hs index 6edc2875d..aaede8ff5 100644 --- a/test/functional/ProgressSpec.hs +++ b/test/functional/ProgressSpec.hs @@ -56,7 +56,7 @@ spec = describe "window/workDoneProgress" $ do startNotification' <- message :: Session WorkDoneProgressBeginNotification liftIO $ do - startNotification' ^. L.params . L.value . L.title `shouldBe` "Initialising Cradle" + startNotification' ^. L.params . L.value . L.title `shouldBe` "loading" startNotification' ^. L.params . L.token `shouldBe` (ProgressNumericToken 1) reportNotification' <- message :: Session WorkDoneProgressReportNotification From 82227085589d535d5cfb4d1167e03d04a65a764f Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 23 Oct 2019 14:06:23 +0200 Subject: [PATCH 33/36] Bump up cabal-helper to master --- submodules/cabal-helper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/cabal-helper b/submodules/cabal-helper index 447814db7..a1c4a3746 160000 --- a/submodules/cabal-helper +++ b/submodules/cabal-helper @@ -1 +1 @@ -Subproject commit 447814db7ecda25afa13a7a699a72c5223649d98 +Subproject commit a1c4a3746311055c2100471aeb98606345496eb3 From 9c58f50cf1944dba4dd971dd105a97d37d79be31 Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 23 Oct 2019 14:06:45 +0200 Subject: [PATCH 34/36] Ignore cabal.project.freeze --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ac2acc891..05da255bc 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,7 @@ /test/testdata/wErrorTest/stack.yaml TAGS cabal-dev/ +cabal.project.freeze cabal.sandbox.config dist-newstyle/ dist From 79b8c3f670cf58c8380b8fa6643a50186b9008a8 Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 23 Oct 2019 14:07:15 +0200 Subject: [PATCH 35/36] Add clock-0.7.2 to stack-8.6.5.yaml --- stack-8.6.5.yaml | 1 + stack.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 20eb9aa92..221657800 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -14,6 +14,7 @@ extra-deps: - brittany-0.12.1.0 - bytestring-trie-0.2.5.0 - cabal-plan-0.5.0.0 +- clock-0.7.2 - constrained-dynamic-0.1.0.0 - floskell-0.10.1 - ghc-lib-parser-8.8.1 diff --git a/stack.yaml b/stack.yaml index aa13f1565..f89d66346 100644 --- a/stack.yaml +++ b/stack.yaml @@ -15,6 +15,7 @@ extra-deps: - ansi-wl-pprint-0.6.8.2 - brittany-0.12.1.0 - cabal-plan-0.5.0.0 +- clock-0.7.2 - constrained-dynamic-0.1.0.0 - floskell-0.10.1 - ghc-lib-parser-8.8.1 @@ -27,7 +28,6 @@ extra-deps: - monad-dijkstra-0.1.1.2@rev:1 - syz-0.2.0.0 - temporary-1.2.1.1 -- clock-0.7.2 # - hie-bios-0.2.1@sha256:5f98a3516ce65e0a3ffd88bf6fb416b04cc084371d0fbf0e1762780de1d652ce,3219 From baee740d59b4c4fdbd12add10eb5bdd2b260b7bc Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 23 Oct 2019 14:49:48 +0200 Subject: [PATCH 36/36] Remove unused import that caused build error with stack --- hie-plugin-api/Haskell/Ide/Engine/Cradle.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/hie-plugin-api/Haskell/Ide/Engine/Cradle.hs b/hie-plugin-api/Haskell/Ide/Engine/Cradle.hs index ffbdc41e0..9a41d8f7e 100644 --- a/hie-plugin-api/Haskell/Ide/Engine/Cradle.hs +++ b/hie-plugin-api/Haskell/Ide/Engine/Cradle.hs @@ -13,7 +13,6 @@ import Data.Function ((&)) import qualified Data.List.NonEmpty as NonEmpty import Data.List.NonEmpty (NonEmpty) import System.FilePath -import System.Directory import qualified Data.Map as M import Data.List (inits, sortOn, isPrefixOf, find) import Data.Maybe (listToMaybe)