@@ -206,13 +206,13 @@ mkAdditionalEditsCommand :: PluginId -> ExtendImport -> IO Command
206
206
mkAdditionalEditsCommand pId edits =
207
207
mkLspCommand pId (CommandId extendImportCommandId) " extend import" (Just [toJSON edits])
208
208
209
- mkNameCompItem :: Uri -> Maybe T. Text -> Name -> ModuleName -> Maybe Type -> Maybe Backtick -> SpanDoc -> Maybe (LImportDecl GhcPs ) -> CompItem
209
+ mkNameCompItem :: Uri -> Maybe T. Text -> OccName -> ModuleName -> Maybe Type -> Maybe Backtick -> SpanDoc -> Maybe (LImportDecl GhcPs ) -> CompItem
210
210
mkNameCompItem doc thingParent origName origMod thingType isInfix docs ! imp = CI {.. }
211
211
where
212
- compKind = occNameToComKind typeText $ occName origName
212
+ compKind = occNameToComKind typeText origName
213
213
importedFrom = Right $ showModName origMod
214
- isTypeCompl = isTcOcc $ occName origName
215
- label = showGhc origName
214
+ isTypeCompl = isTcOcc origName
215
+ label = stripPrefix $ showGhc origName
216
216
insertText = case isInfix of
217
217
Nothing -> case getArgText <$> thingType of
218
218
Nothing -> label
@@ -345,10 +345,10 @@ cacheDataProducer uri packageState curMod globalEnv inScopeEnv limports deps = d
345
345
toCompItem :: Parent -> Module -> ModuleName -> Name -> Maybe (LImportDecl GhcPs ) -> IO [CompItem ]
346
346
toCompItem par m mn n imp' = do
347
347
docs <- getDocumentationTryGhc packageState curMod deps n
348
- let mbParent = case par of
349
- NoParent -> Nothing
350
- ParentIs n -> Just ( showNameWithoutUniques n)
351
- FldParent n _ -> Just ( showNameWithoutUniques n)
348
+ let ( mbParent, originName) = case par of
349
+ NoParent -> ( Nothing , nameOccName n)
350
+ ParentIs n' -> ( Just $ showNameWithoutUniques n', nameOccName n)
351
+ FldParent n' lbl -> ( Just $ showNameWithoutUniques n', maybe (nameOccName n) mkVarOccFS lbl )
352
352
tys <- catchSrcErrors (hsc_dflags packageState) " completion" $ do
353
353
name' <- lookupName packageState m n
354
354
return ( name' >>= safeTyThingType
@@ -361,7 +361,7 @@ cacheDataProducer uri packageState curMod globalEnv inScopeEnv limports deps = d
361
361
[mkRecordSnippetCompItem uri mbParent ctxStr flds (ppr mn) docs imp']
362
362
_ -> []
363
363
364
- return $ mkNameCompItem uri mbParent n mn ty Nothing docs imp'
364
+ return $ mkNameCompItem uri mbParent originName mn ty Nothing docs imp'
365
365
: recordCompls
366
366
367
367
(unquals,quals) <- getCompls rdrElts
@@ -588,7 +588,7 @@ getCompletions plId ideOpts CC {allModNamesAsNS, unqualCompls, qualCompls, impor
588
588
-> return $ filtPragmaCompls (pragmaSuffix fullLine)
589
589
| otherwise -> do
590
590
let uniqueFiltCompls = nubOrdOn insertText filtCompls
591
- compls <- mapM (mkCompl plId ideOpts . stripAutoGenerated ) uniqueFiltCompls
591
+ compls <- mapM (mkCompl plId ideOpts) uniqueFiltCompls
592
592
return $ filtModNameCompls
593
593
++ filtKeywordCompls
594
594
++ map ( toggleSnippets caps withSnippets) compls
@@ -657,16 +657,11 @@ openingBacktick line prefixModule prefixText Position { _character }
657
657
658
658
-- | Under certain circumstance GHC generates some extra stuff that we
659
659
-- don't want in the autocompleted symbols
660
- stripAutoGenerated :: CompItem -> CompItem
661
- stripAutoGenerated ci =
662
- ci {label = stripPrefix (label ci)}
663
660
{- When e.g. DuplicateRecordFields is enabled, compiler generates
664
661
names like "$sel:accessor:One" and "$sel:accessor:Two" to disambiguate record selectors
665
662
https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/DuplicateRecordFields#Implementation
666
663
-}
667
-
668
664
-- TODO: Turn this into an alex lexer that discards prefixes as if they were whitespace.
669
-
670
665
stripPrefix :: T. Text -> T. Text
671
666
stripPrefix name = T. takeWhile (/= ' :' ) $ go prefixes
672
667
where
0 commit comments