-
-
Notifications
You must be signed in to change notification settings - Fork 396
Restore eval plugin build for GHC 9.2 #2669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8a18a3d
tests: Test for eval plugin now show correct line in output
guibou 4588a7e
Restore eval plugin build for GHC 9.2
guibou 06fcd81
fix: remove unused log mecanism
guibou d1dafb7
Refactor: move pragma to compat module
guibou 20144c6
refactor: Remove now useless dependency
guibou 2721114
fix: remove an unused import
guibou c949c4c
Disable a test for eval plugin for GHC 9.2
guibou 4dcca04
fix: type +v actually also works with GHC 9.0
guibou d4ceacf
Merge branch 'master' into fix_ghc92_eval_plugin
guibou 8f0c1e8
Merge branch 'master' into fix_ghc92_eval_plugin
pepeiborra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,6 @@ constraints: | |
+ignore-plugins-ghc-bounds | ||
-brittany | ||
-class | ||
-eval | ||
-haddockComments | ||
-hlint | ||
-retrie | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,7 +79,6 @@ library | |
, pretty-simple | ||
, QuickCheck | ||
, safe-exceptions | ||
, temporary | ||
, text | ||
, time | ||
, transformers | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,9 @@ import Development.IDE.GHC.Compat | |
import qualified Development.IDE.GHC.Compat as SrcLoc | ||
import qualified Development.IDE.GHC.Compat.Util as FastString | ||
import Development.IDE.Graph (alwaysRerun) | ||
#if MIN_VERSION_ghc(9,2,0) | ||
import GHC.Parser.Annotation | ||
#endif | ||
import Ide.Plugin.Eval.Types | ||
|
||
|
||
|
@@ -53,22 +56,44 @@ queueForEvaluation ide nfp = do | |
EvaluatingVar var <- getIdeGlobalState ide | ||
modifyIORef var (Set.insert nfp) | ||
|
||
#if MIN_VERSION_ghc(9,0,0) | ||
#if MIN_VERSION_ghc(9,2,0) | ||
getAnnotations :: Development.IDE.GHC.Compat.Located HsModule -> [LEpaComment] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe nest these two in a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll address that in a followup commit. |
||
getAnnotations (L _ m@(HsModule { hsmodAnn = anns'})) = | ||
priorComments annComments <> getFollowingComments annComments | ||
<> concatMap getCommentsForDecl (hsmodImports m) | ||
<> concatMap getCommentsForDecl (hsmodDecls m) | ||
where | ||
annComments = epAnnComments anns' | ||
|
||
getCommentsForDecl :: GenLocated (SrcSpanAnn' (EpAnn ann)) e | ||
-> [LEpaComment] | ||
getCommentsForDecl (L (SrcSpanAnn (EpAnn _ _ cs) _) _) = priorComments cs <> getFollowingComments cs | ||
getCommentsForDecl (L (SrcSpanAnn (EpAnnNotUsed) _) _) = [] | ||
|
||
apiAnnComments' :: ParsedModule -> [SrcLoc.RealLocated EpaCommentTok] | ||
apiAnnComments' pm = do | ||
L span (EpaComment c _) <- getAnnotations $ pm_parsed_source pm | ||
pure (L (anchor span) c) | ||
|
||
pattern RealSrcSpanAlready :: SrcLoc.RealSrcSpan -> SrcLoc.RealSrcSpan | ||
pattern RealSrcSpanAlready x = x | ||
guibou marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#elif MIN_VERSION_ghc(9,0,0) | ||
apiAnnComments' :: ParsedModule -> [SrcLoc.RealLocated AnnotationComment] | ||
apiAnnComments' = apiAnnRogueComments . pm_annotations | ||
|
||
pattern RealSrcSpanAlready :: SrcLoc.RealSrcSpan -> SrcLoc.RealSrcSpan | ||
pattern RealSrcSpanAlready x = x | ||
apiAnnComments' :: SrcLoc.ApiAnns -> [SrcLoc.RealLocated AnnotationComment] | ||
apiAnnComments' = apiAnnRogueComments | ||
#else | ||
apiAnnComments' :: SrcLoc.ApiAnns -> [SrcLoc.Located AnnotationComment] | ||
apiAnnComments' = concat . Map.elems . snd | ||
apiAnnComments' :: ParsedModule -> [SrcLoc.Located AnnotationComment] | ||
apiAnnComments' = concat . Map.elems . snd . pm_annotations | ||
|
||
pattern RealSrcSpanAlready :: SrcLoc.RealSrcSpan -> SrcSpan | ||
pattern RealSrcSpanAlready x = SrcLoc.RealSrcSpan x Nothing | ||
#endif | ||
|
||
evalParsedModuleRule :: Rules () | ||
evalParsedModuleRule = defineEarlyCutoff $ RuleNoDiagnostics $ \GetEvalComments nfp -> do | ||
(ParsedModule{..}, posMap) <- useWithStale_ GetParsedModuleWithComments nfp | ||
(pm, posMap) <- useWithStale_ GetParsedModuleWithComments nfp | ||
let comments = foldMap (\case | ||
L (RealSrcSpanAlready real) bdy | ||
| FastString.unpackFS (srcSpanFile real) == | ||
|
@@ -80,14 +105,14 @@ evalParsedModuleRule = defineEarlyCutoff $ RuleNoDiagnostics $ \GetEvalComments | |
-- since Haddock parsing is unset explicitly in 'getParsedModuleWithComments', | ||
-- we can concentrate on these two | ||
case bdy of | ||
AnnLineComment cmt -> | ||
EpaLineComment cmt -> | ||
mempty { lineComments = Map.singleton curRan (RawLineComment cmt) } | ||
AnnBlockComment cmt -> | ||
EpaBlockComment cmt -> | ||
mempty { blockComments = Map.singleton curRan $ RawBlockComment cmt } | ||
_ -> mempty | ||
_ -> mempty | ||
) | ||
$ apiAnnComments' pm_annotations | ||
$ apiAnnComments' pm | ||
-- we only care about whether the comments are null | ||
-- this is valid because the only dependent is NeedsCompilation | ||
fingerPrint = fromString $ if nullComments comments then "" else "1" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{-# LANGUAGE DataKinds, TypeOperators #-} | ||
module T10 where | ||
import GHC.TypeNats ( type (+) ) | ||
|
||
type Dummy = 1 + 1 | ||
|
||
-- >>> type N = 1 | ||
-- >>> type M = 40 | ||
-- >>> :kind! N + M + 1 | ||
-- N + M + 1 :: Natural | ||
-- = 42 |
11 changes: 11 additions & 0 deletions
11
plugins/hls-eval-plugin/test/testdata/T10.ghc92.expected.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{-# LANGUAGE DataKinds, TypeOperators #-} | ||
module T10 where | ||
import GHC.TypeNats ( type (+) ) | ||
|
||
type Dummy = 1 + 1 | ||
|
||
-- >>> type N = 1 | ||
-- >>> type M = 40 | ||
-- >>> :kind! N + M + 1 | ||
-- N + M + 1 :: Natural | ||
-- = 42 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module T11 where | ||
|
||
-- >>> :kind! a | ||
-- Not in scope: type variable `a' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module T11 where | ||
|
||
-- >>> :kind! a | ||
-- Not in scope: type variable `a' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suspicious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is. Previously the
err
was filled by the logging architecture (see discussion here: #2669 (comment)) and @pepeiborra agreed that it can be removed. We can pull the thread even more by removing thiserr
value, changing the return type fromEither
toMaybe
. I tried to reduce the amount of changes in order to restore this plugin.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's something to do in a follow-up PR, please leave a comment. Otherwise future readers (possibly future you :) ) will be mystified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the simplest thing to do is fill the
err
withasS loadResult
, or something even simpler like "failed to load module". I feel like it will be hard to change theEither
to aMaybe
becausetype CommandFunction idestate a = ideState a -> LspM Conflg (Either ResponseError Value)
, unless we're changingCommandFunction
which would change lots of things should just put some reason in there instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I'll address that in a followup commit.