Skip to content

Commit 332d29a

Browse files
authored
Merge branch 'master' into 4049-optimization-to-semantic-tokens-extracting-logic
2 parents ff1307b + cd959ae commit 332d29a

File tree

8 files changed

+40
-19
lines changed

8 files changed

+40
-19
lines changed

ghcide/ghcide.cabal

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ flag pedantic
4242

4343
common warnings
4444
ghc-options:
45-
-Wall -Wincomplete-uni-patterns -Wunused-packages
45+
-Wall
46+
-Wincomplete-uni-patterns
47+
-Wunused-packages
48+
-Wno-name-shadowing
4649
-Wno-unticked-promoted-constructors
4750
-fno-ignore-asserts
4851

@@ -216,12 +219,7 @@ library
216219
-- finished purging the warnings, so some are set to not be errors
217220
-- for now
218221
ghc-options:
219-
-Werror -Wwarn=unused-packages -Wwarn=unrecognised-pragmas
220-
-Wwarn=dodgy-imports -Wwarn=missing-signatures
221-
-Wwarn=duplicate-exports -Wwarn=dodgy-exports
222-
-Wwarn=incomplete-patterns -Wwarn=overlapping-patterns
223-
-Wwarn=incomplete-record-updates
224-
-Wwarn=ambiguous-fields
222+
-Werror -Wwarn=unused-packages
225223

226224
if flag(ekg)
227225
build-depends:
@@ -238,7 +236,6 @@ executable ghcide-test-preprocessor
238236
import: warnings
239237
default-language: GHC2021
240238
hs-source-dirs: test/preprocessor
241-
ghc-options: -Wno-name-shadowing
242239
main-is: Main.hs
243240
build-depends: base >=4 && <5
244241

@@ -253,7 +250,7 @@ executable ghcide
253250
import: warnings
254251
default-language: GHC2021
255252
hs-source-dirs: exe
256-
ghc-options: -threaded -rtsopts "-with-rtsopts=-I0 -A128M -T" -Wno-name-shadowing
253+
ghc-options: -threaded -rtsopts "-with-rtsopts=-I0 -A128M -T"
257254

258255

259256
-- allow user RTS overrides
@@ -352,7 +349,7 @@ test-suite ghcide-tests
352349
build-depends: ghc-typelits-knownnat
353350

354351
hs-source-dirs: test/cabal test/exe test/src
355-
ghc-options: -threaded -O0 -Wno-name-shadowing
352+
ghc-options: -threaded -O0
356353

357354
main-is: Main.hs
358355
other-modules:

ghcide/src/Development/IDE/Core/Rules.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ mainRule recorder RulesConfig{..} = do
12701270
reportImportCyclesRule recorder
12711271
typeCheckRule recorder
12721272
getDocMapRule recorder
1273-
loadGhcSession recorder def{fullModuleGraph}
1273+
loadGhcSession recorder GhcSessionDepsConfig{fullModuleGraph}
12741274
getModIfaceFromDiskRule recorder
12751275
getModIfaceFromDiskAndIndexRule recorder
12761276
getModIfaceRule recorder

ghcide/src/Development/IDE/GHC/Compat/Parser.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE PatternSynonyms #-}
3-
{-# HLINT ignore "Unused LANGUAGE pragma" #-}
43

54
-- | Parser compatibility module.
65
module Development.IDE.GHC.Compat.Parser (

ghcide/src/Development/IDE/LSP/Outline.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,10 @@ documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (ForD _ x)) = Just
190190
{ _name = case x of
191191
ForeignImport{} -> name
192192
ForeignExport{} -> name
193-
XForeignDecl{} -> "?"
194193
, _kind = SymbolKind_Object
195194
, _detail = case x of
196195
ForeignImport{} -> Just "import"
197196
ForeignExport{} -> Just "export"
198-
XForeignDecl{} -> Nothing
199197
}
200198
where name = printOutputable $ unLoc $ fd_name x
201199

ghcide/src/Development/IDE/Spans/AtPoint.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,10 @@ defRowToSymbolInfo _ = Nothing
439439

440440
pointCommand :: HieASTs t -> Position -> (HieAST t -> a) -> [a]
441441
pointCommand hf pos k =
442-
catMaybes $ M.elems $ flip M.mapWithKey (getAsts hf) $ \fs ast ->
442+
M.elems $ flip M.mapMaybeWithKey (getAsts hf) $ \fs ast ->
443443
-- Since GHC 9.2:
444444
-- getAsts :: Map HiePath (HieAst a)
445-
-- type HiePath = LexialFastString
445+
-- type HiePath = LexicalFastString
446446
--
447447
-- but before:
448448
-- getAsts :: Map HiePath (HieAst a)

plugins/hls-class-plugin/src/Ide/Plugin/Class/CodeAction.hs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ codeAction recorder state plId (CodeActionParams _ _ docId _ context) = do
159159
$ listToMaybe
160160
$ mapMaybe listToMaybe
161161
$ pointCommand hf instancePosition
162-
( (Map.keys . Map.filter isClassNodeIdentifier . getNodeIds)
162+
( (Map.keys . Map.filterWithKey isClassNodeIdentifier . getNodeIds)
163163
<=< nodeChildren
164164
)
165165

@@ -198,8 +198,10 @@ codeAction recorder state plId (CodeActionParams _ _ docId _ context) = do
198198
_ -> fail "Ide.Plugin.Class.findClassFromIdentifier"
199199
findClassFromIdentifier _ (Left _) = throwError (PluginInternalError "Ide.Plugin.Class.findClassIdentifier")
200200

201-
isClassNodeIdentifier :: IdentifierDetails a -> Bool
202-
isClassNodeIdentifier ident = (isNothing . identType) ident && Use `Set.member` identInfo ident
201+
-- see https://hackage.haskell.org/package/ghc-9.8.1/docs/src/GHC.Types.Name.Occurrence.html#mkClassDataConOcc
202+
isClassNodeIdentifier :: Identifier -> IdentifierDetails a -> Bool
203+
isClassNodeIdentifier (Right i) ident | 'C':':':_ <- unpackFS $ occNameFS $ occName i = (isNothing . identType) ident && Use `Set.member` identInfo ident
204+
isClassNodeIdentifier _ _ = False
203205

204206
isClassMethodWarning :: T.Text -> Bool
205207
isClassMethodWarning = T.isPrefixOf "• No explicit implementation for"

plugins/hls-class-plugin/test/Main.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module Main
99
( main
1010
) where
1111

12+
import Control.Exception (catch)
1213
import Control.Lens (Prism', prism', view, (^.),
1314
(^..), (^?))
1415
import Control.Monad (void)
@@ -120,6 +121,17 @@ codeLensTests = testGroup
120121
doc <- openDoc "TH.hs" "haskell"
121122
lens <- getAndResolveCodeLenses doc
122123
liftIO $ length lens @?= 0
124+
, testCase "Do not construct error action!, Ticket3942one" $ do
125+
runSessionWithServer def classPlugin testDataDir $ do
126+
doc <- openDoc "Ticket3942one.hs" "haskell"
127+
_ <- waitForDiagnosticsFromSource doc (T.unpack sourceTypecheck)
128+
lens <- getAllCodeActions doc
129+
-- should switch to `liftIO $ length lens @?= 2, when Ticket3942 is entirely fixed`
130+
-- current fix is just to make sure the code does not throw an exception that would mess up
131+
-- the client UI.
132+
liftIO $ length lens > 0 @?= True
133+
`catch` \(e :: SessionException) -> do
134+
liftIO $ assertFailure $ "classPluginTestError: "++ show e
123135
, goldenCodeLens "Apply code lens" "CodeLensSimple" 1
124136
, goldenCodeLens "Apply code lens for local class" "LocalClassDefine" 0
125137
, goldenCodeLens "Apply code lens on the same line" "Inline" 0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{-# LANGUAGE DeriveAnyClass #-}
2+
3+
module Ticket3942one where
4+
5+
class C a where
6+
foo :: a -> Int
7+
8+
newtype Foo = MkFoo Int deriving (C)
9+
instance Show Foo where
10+
11+
12+
main :: IO ()
13+
main = return ()

0 commit comments

Comments
 (0)