Skip to content

Commit 3c52743

Browse files
July541michaelpj
andauthored
Should no related code lens if the module name is correct (#2826)
* Should no code lens if the module name is correct * Rerun tests * Rerun tests * Try remove hls-eval-plugin known-broken in ghc-9.2 * Rerun tests * Apply more accurate test name Co-authored-by: Michael Peyton Jones <[email protected]> Co-authored-by: Michael Peyton Jones <[email protected]>
1 parent 1079d07 commit 3c52743

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed

plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import Development.IDE (GetParsedModule (GetParsedModule),
3636
import Development.IDE.GHC.Compat (GenLocated (L), getSessionDynFlags,
3737
hsmodName, importPaths, locA,
3838
pattern RealSrcSpan,
39-
pm_parsed_source, unLoc)
39+
pm_parsed_source, unLoc, moduleNameString)
4040
import Ide.Types
4141
import Language.LSP.Server
4242
import Language.LSP.Types hiding
@@ -140,7 +140,7 @@ codeModuleName :: IdeState -> NormalizedFilePath -> IO (Maybe (Range, T.Text))
140140
codeModuleName state nfp = runMaybeT $ do
141141
pm <- MaybeT . runAction "ModuleName.GetParsedModule" state $ use GetParsedModule nfp
142142
L (locA -> (RealSrcSpan l _)) m <- MaybeT . pure . hsmodName . unLoc $ pm_parsed_source pm
143-
pure (realSrcSpanToRange l, T.pack $ show m)
143+
pure (realSrcSpanToRange l, T.pack $ moduleNameString m)
144144

145145
-- traceAs :: Show a => String -> a -> a
146146
-- traceAs lbl a = trace (lbl ++ " = " ++ show a) a

plugins/hls-module-name-plugin/test/Main.hs

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ tests =
3737
[CodeLens { _command = Just c }] <- getCodeLenses doc
3838
executeCommand c
3939
void $ skipManyTill anyMessage (message SWorkspaceApplyEdit)
40+
, testCase "Should not show code lens if the module name is correct" $
41+
runSessionWithServer moduleNamePlugin testDataDir $ do
42+
doc <- openDoc "CorrectName.hs" "haskell"
43+
lenses <- getCodeLenses doc
44+
liftIO $ lenses @?= []
45+
closeDoc doc
4046
]
4147

4248
goldenWithModuleName :: TestName -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module CorrectName where

plugins/hls-module-name-plugin/test/testdata/hie.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ cradle:
55
- "TEmptyModule"
66
- "TWrongModuleName"
77
- "mainlike"
8+
- "CorrectName"

test/functional/Progress.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ tests =
3333
let path = "diagnostics" </> "Foo.hs"
3434
_ <- openDoc path "haskell"
3535
expectProgressMessages [pack ("Setting up testdata (for " ++ path ++ ")"), "Processing", "Indexing"] []
36-
, knownBrokenForGhcVersions [GHC92] "No evaluation status with GHC 9.2" $ requiresEvalPlugin $ testCase "eval plugin sends progress reports" $
36+
, requiresEvalPlugin $ testCase "eval plugin sends progress reports" $
3737
runSession hlsCommand progressCaps "plugins/hls-eval-plugin/test/testdata" $ do
3838
doc <- openDoc "T1.hs" "haskell"
3939
lspId <- sendRequest STextDocumentCodeLens (CodeLensParams Nothing Nothing doc)

0 commit comments

Comments
 (0)