File tree 2 files changed +47
-5
lines changed
plugins/default/src/Ide/Plugin
2 files changed +47
-5
lines changed Original file line number Diff line number Diff line change @@ -99,12 +99,26 @@ findPragma str = concatMap check possiblePragmas
99
99
where
100
100
check p = [p | T. isInfixOf p str]
101
101
102
+ -- We exclude the Strict extension as it causes many false positives, see
103
+ -- the discussion at https://github.com/haskell/ghcide/pull/638
104
+ --
105
+ -- We don't include the No- variants, as GHC never suggests disabling an
106
+ -- extension in an error message.
107
+ possiblePragmas :: [T. Text ]
108
+ possiblePragmas =
109
+ [ name
110
+ | FlagSpec {flagSpecName = T. pack -> name} <- xFlags
111
+ , " Strict" /= name
112
+ ]
113
+
102
114
-- ---------------------------------------------------------------------
103
115
104
- -- | Possible Pragma names.
105
- -- See discussion at https://github.com/haskell/ghcide/pull/638
106
- possiblePragmas :: [T. Text ]
107
- possiblePragmas = [name | FlagSpec {flagSpecName = T. pack -> name} <- xFlags, " Strict" /= name]
116
+ -- | All language pragmas, including the No- variants
117
+ allPragmas :: [T. Text ]
118
+ allPragmas = concat
119
+ [ [name, " No" <> name]
120
+ | FlagSpec {flagSpecName = T. pack -> name} <- xFlags
121
+ ]
108
122
109
123
-- ---------------------------------------------------------------------
110
124
@@ -120,7 +134,7 @@ completion lspFuncs _ide complParams = do
120
134
where
121
135
result (Just pfix)
122
136
| " {-# LANGUAGE" `T.isPrefixOf` VFS. fullLine pfix
123
- = Completions $ List $ map buildCompletion possiblePragmas
137
+ = Completions $ List $ map buildCompletion allPragmas
124
138
| otherwise
125
139
= Completions $ List []
126
140
result Nothing = Completions $ List []
Original file line number Diff line number Diff line change @@ -94,6 +94,34 @@ tests = testGroup "completions" [
94
94
item ^. label @?= " OverloadedStrings"
95
95
item ^. kind @?= Just CiKeyword
96
96
97
+ , testCase " completes the Strict language extension" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
98
+ doc <- openDoc " Completion.hs" " haskell"
99
+
100
+ _ <- waitForDiagnostics
101
+
102
+ let te = TextEdit (Range (Position 0 13 ) (Position 0 31 )) " Str"
103
+ _ <- applyEdit doc te
104
+
105
+ compls <- getCompletions doc (Position 0 24 )
106
+ let item = head $ filter ((== " Strict" ) . (^. label)) compls
107
+ liftIO $ do
108
+ item ^. label @?= " Strict"
109
+ item ^. kind @?= Just CiKeyword
110
+
111
+ , testCase " completes No- language extensions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
112
+ doc <- openDoc " Completion.hs" " haskell"
113
+
114
+ _ <- waitForDiagnostics
115
+
116
+ let te = TextEdit (Range (Position 0 13 ) (Position 0 31 )) " NoOverload"
117
+ _ <- applyEdit doc te
118
+
119
+ compls <- getCompletions doc (Position 0 24 )
120
+ let item = head $ filter ((== " NoOverloadedStrings" ) . (^. label)) compls
121
+ liftIO $ do
122
+ item ^. label @?= " NoOverloadedStrings"
123
+ item ^. kind @?= Just CiKeyword
124
+
97
125
, testCase " completes pragmas" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
98
126
doc <- openDoc " Completion.hs" " haskell"
99
127
You can’t perform that action at this time.
0 commit comments