From 8f736a3445ec2f3372ef5dcfde149c6fc6677d06 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Tue, 12 Apr 2022 14:11:28 +0800 Subject: [PATCH 1/6] Should no code lens if the module name is correct --- plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs | 4 ++-- plugins/hls-module-name-plugin/test/Main.hs | 6 ++++++ plugins/hls-module-name-plugin/test/testdata/CorrectName.hs | 1 + plugins/hls-module-name-plugin/test/testdata/hie.yaml | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 plugins/hls-module-name-plugin/test/testdata/CorrectName.hs diff --git a/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs b/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs index c9d0d3aefb..9e91b6348d 100644 --- a/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs +++ b/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs @@ -36,7 +36,7 @@ import Development.IDE (GetParsedModule (GetParsedModule), import Development.IDE.GHC.Compat (GenLocated (L), getSessionDynFlags, hsmodName, importPaths, locA, pattern RealSrcSpan, - pm_parsed_source, unLoc) + pm_parsed_source, unLoc, moduleNameString) import Ide.Types import Language.LSP.Server import Language.LSP.Types hiding @@ -140,7 +140,7 @@ codeModuleName :: IdeState -> NormalizedFilePath -> IO (Maybe (Range, T.Text)) codeModuleName state nfp = runMaybeT $ do pm <- MaybeT . runAction "ModuleName.GetParsedModule" state $ use GetParsedModule nfp L (locA -> (RealSrcSpan l _)) m <- MaybeT . pure . hsmodName . unLoc $ pm_parsed_source pm - pure (realSrcSpanToRange l, T.pack $ show m) + pure (realSrcSpanToRange l, T.pack $ moduleNameString m) -- traceAs :: Show a => String -> a -> a -- traceAs lbl a = trace (lbl ++ " = " ++ show a) a diff --git a/plugins/hls-module-name-plugin/test/Main.hs b/plugins/hls-module-name-plugin/test/Main.hs index b6a35af926..671a3ad19a 100644 --- a/plugins/hls-module-name-plugin/test/Main.hs +++ b/plugins/hls-module-name-plugin/test/Main.hs @@ -37,6 +37,12 @@ tests = [CodeLens { _command = Just c }] <- getCodeLenses doc executeCommand c void $ skipManyTill anyMessage (message SWorkspaceApplyEdit) + , testCase "Should no code lens if the module name is correct" $ + runSessionWithServer moduleNamePlugin testDataDir $ do + doc <- openDoc "CorrectName.hs" "haskell" + lenses <- getCodeLenses doc + liftIO $ lenses @?= [] + closeDoc doc ] goldenWithModuleName :: TestName -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree diff --git a/plugins/hls-module-name-plugin/test/testdata/CorrectName.hs b/plugins/hls-module-name-plugin/test/testdata/CorrectName.hs new file mode 100644 index 0000000000..e78f2247a1 --- /dev/null +++ b/plugins/hls-module-name-plugin/test/testdata/CorrectName.hs @@ -0,0 +1 @@ +module CorrectName where diff --git a/plugins/hls-module-name-plugin/test/testdata/hie.yaml b/plugins/hls-module-name-plugin/test/testdata/hie.yaml index d9e8533d22..022fee55a1 100644 --- a/plugins/hls-module-name-plugin/test/testdata/hie.yaml +++ b/plugins/hls-module-name-plugin/test/testdata/hie.yaml @@ -5,3 +5,4 @@ cradle: - "TEmptyModule" - "TWrongModuleName" - "mainlike" + - "CorrectName" From cd8f88bdd80017412bfc3ca74e7e42a470d9f544 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Tue, 12 Apr 2022 14:33:40 +0800 Subject: [PATCH 2/6] Rerun tests From 9d51ed93cf8554680f0700f757530ef75aa51f83 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Tue, 12 Apr 2022 15:14:02 +0800 Subject: [PATCH 3/6] Rerun tests From 25ff620e2718584c89790da8fd723b3cbcbdd32c Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Tue, 12 Apr 2022 15:56:44 +0800 Subject: [PATCH 4/6] Try remove hls-eval-plugin known-broken in ghc-9.2 --- test/functional/Progress.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/Progress.hs b/test/functional/Progress.hs index 23f7d35362..e4f84f82ce 100644 --- a/test/functional/Progress.hs +++ b/test/functional/Progress.hs @@ -33,7 +33,7 @@ tests = let path = "diagnostics" "Foo.hs" _ <- openDoc path "haskell" expectProgressMessages [pack ("Setting up testdata (for " ++ path ++ ")"), "Processing", "Indexing"] [] - , knownBrokenForGhcVersions [GHC92] "No evaluation status with GHC 9.2" $ requiresEvalPlugin $ testCase "eval plugin sends progress reports" $ + , requiresEvalPlugin $ testCase "eval plugin sends progress reports" $ runSession hlsCommand progressCaps "plugins/hls-eval-plugin/test/testdata" $ do doc <- openDoc "T1.hs" "haskell" lspId <- sendRequest STextDocumentCodeLens (CodeLensParams Nothing Nothing doc) From cbba72a5c99dd6f55c6ff2d5a825af9a99b3d7c2 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Tue, 12 Apr 2022 16:38:50 +0800 Subject: [PATCH 5/6] Rerun tests From fdf695cc74118be1efcf2c0bc5495d6aa7041d91 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Wed, 13 Apr 2022 17:58:44 +0800 Subject: [PATCH 6/6] Apply more accurate test name Co-authored-by: Michael Peyton Jones --- plugins/hls-module-name-plugin/test/Main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hls-module-name-plugin/test/Main.hs b/plugins/hls-module-name-plugin/test/Main.hs index 671a3ad19a..ce0fa1e746 100644 --- a/plugins/hls-module-name-plugin/test/Main.hs +++ b/plugins/hls-module-name-plugin/test/Main.hs @@ -37,7 +37,7 @@ tests = [CodeLens { _command = Just c }] <- getCodeLenses doc executeCommand c void $ skipManyTill anyMessage (message SWorkspaceApplyEdit) - , testCase "Should no code lens if the module name is correct" $ + , testCase "Should not show code lens if the module name is correct" $ runSessionWithServer moduleNamePlugin testDataDir $ do doc <- openDoc "CorrectName.hs" "haskell" lenses <- getCodeLenses doc