Skip to content

Commit 0cea12e

Browse files
committed
Relocated list of OccName prefixes from the Completions plugin to the CoreFile module. Updated the check for GHC-generated OccName prefixes in AtPoint to use the shared list of OccName prefixes.
1 parent 92d5a99 commit 0cea12e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,17 @@ stripPrefix :: T.Text -> T.Text
770770
stripPrefix name = T.takeWhile (/=':') $ fromMaybe name $
771771
getFirst $ foldMap (First . (`T.stripPrefix` name)) occNamePrefixes
772772

773-
mkRecordSnippetCompItem :: Uri -> Maybe T.Text -> T.Text -> [T.Text] -> Provenance -> Maybe (LImportDecl GhcPs) -> CompItem
774-
mkRecordSnippetCompItem uri parent ctxStr compl importedFrom imp = r
773+
safeTyThingForRecord :: TyThing -> Maybe (T.Text, [T.Text])
774+
safeTyThingForRecord (AnId _) = Nothing
775+
safeTyThingForRecord (AConLike dc) =
776+
let ctxStr = printOutputable . occName . conLikeName $ dc
777+
field_names = T.pack . unpackFS . flLabel <$> conLikeFieldLabels dc
778+
in
779+
Just (ctxStr, field_names)
780+
safeTyThingForRecord _ = Nothing
781+
782+
mkRecordSnippetCompItem :: Uri -> Maybe T.Text -> T.Text -> [T.Text] -> Provenance -> SpanDoc -> Maybe (LImportDecl GhcPs) -> CompItem
783+
mkRecordSnippetCompItem uri parent ctxStr compl importedFrom docs imp = r
775784
where
776785
r = CI {
777786
compKind = CiSnippet

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import Development.IDE.Core.PositionMapping
3434
import Development.IDE.Core.RuleTypes
3535
import Development.IDE.GHC.Compat
3636
import qualified Development.IDE.GHC.Compat.Util as Util
37+
import Development.IDE.GHC.CoreFile (occNamePrefixes)
3738
import Development.IDE.GHC.Util (printOutputable)
3839
import Development.IDE.Spans.Common
3940
import Development.IDE.Types.Options

0 commit comments

Comments
 (0)