Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions plugins/hls-module-name-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ tests =
[CodeLens { _command = Just c }] <- getCodeLenses doc
executeCommand c
void $ skipManyTill anyMessage (message SWorkspaceApplyEdit)
, testCase "Should not show 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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module CorrectName where
1 change: 1 addition & 0 deletions plugins/hls-module-name-plugin/test/testdata/hie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ cradle:
- "TEmptyModule"
- "TWrongModuleName"
- "mainlike"
- "CorrectName"
2 changes: 1 addition & 1 deletion test/functional/Progress.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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" $
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not know how did it pass the previous tests.

, 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)
Expand Down