Skip to content

Commit 1f94c90

Browse files
committed
Refactor: rid off ProduceCompletions
1 parent d00c3aa commit 1f94c90

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

ghcide/src/Development/IDE/Plugin/Completions.hs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
module Development.IDE.Plugin.Completions
66
( descriptor
7-
, ProduceCompletions(..)
87
, LocalCompletions(..)
98
, NonLocalCompletions(..)
109
) where
@@ -49,11 +48,6 @@ descriptor plId = (defaultPluginDescriptor plId)
4948

5049
produceCompletions :: Rules ()
5150
produceCompletions = do
52-
define $ \ProduceCompletions file -> do
53-
local <- useWithStale LocalCompletions file
54-
nonLocal <- useWithStale NonLocalCompletions file
55-
let extract = fmap fst
56-
return ([], extract local <> extract nonLocal)
5751
define $ \LocalCompletions file -> do
5852
let uri = fromNormalizedUri $ normalizedFilePathToUri file
5953
pm <- useWithStale GetParsedModule file
@@ -103,16 +97,9 @@ dropListFromImportDecl iDecl = let
10397
in f <$> iDecl
10498

10599
-- | Produce completions info for a file
106-
type instance RuleResult ProduceCompletions = CachedCompletions
107100
type instance RuleResult LocalCompletions = CachedCompletions
108101
type instance RuleResult NonLocalCompletions = CachedCompletions
109102

110-
data ProduceCompletions = ProduceCompletions
111-
deriving (Eq, Show, Typeable, Generic)
112-
instance Hashable ProduceCompletions
113-
instance NFData ProduceCompletions
114-
instance Binary ProduceCompletions
115-
116103
data LocalCompletions = LocalCompletions
117104
deriving (Eq, Show, Typeable, Generic)
118105
instance Hashable LocalCompletions
@@ -142,12 +129,13 @@ getCompletionsLSP plId lsp ide
142129
let npath = toNormalizedFilePath' path
143130
(ideOpts, compls) <- runIdeAction "Completion" (shakeExtras ide) $ do
144131
opts <- liftIO $ getIdeOptionsIO $ shakeExtras ide
145-
compls <- useWithStaleFast ProduceCompletions npath
132+
localCompls <- useWithStaleFast LocalCompletions npath
133+
nonLocalCompls <- useWithStaleFast NonLocalCompletions npath
146134
pm <- useWithStaleFast GetParsedModule npath
147135
binds <- fromMaybe (mempty, zeroMapping) <$> useWithStaleFast GetBindings npath
148-
pure (opts, fmap (,pm,binds) compls )
136+
pure (opts, fmap (,pm,binds) ((fst <$> localCompls) <> (fst <$> nonLocalCompls)))
149137
case compls of
150-
Just ((cci', _), parsedMod, bindMap) -> do
138+
Just (cci', parsedMod, bindMap) -> do
151139
pfix <- VFS.getCompletionPrefix position cnts
152140
case (pfix, completionContext) of
153141
(Just (VFS.PosPrefixInfo _ "" _ _), Just CompletionContext { _triggerCharacter = Just "."})

0 commit comments

Comments
 (0)