Skip to content

Commit

Permalink
Remove manual parsing in getCompletions
Browse files Browse the repository at this point in the history
  • Loading branch information
xsebek committed Jun 4, 2022
1 parent ee25e2c commit 277faef
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions ghcide/src/Development/IDE/Plugin/Completions/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -579,23 +579,11 @@ getCompletions
| Just (ImportHidingContext moduleName) <- maybeContext
= moduleImportListCompletions moduleName

-- TODO: Is manual parsing ever needed or is context always present for module?
-- If possible only keep the above.
| "import " `T.isPrefixOf` fullLine
, Just moduleName <- getModuleName fullLine
, "(" `T.isInfixOf` fullLine
= moduleImportListCompletions $ T.unpack moduleName

-- ------------------------------------------------------------------------
-- IMPORT MODULENAM|
| Just (ImportContext _moduleName) <- maybeContext
= filtImportCompls

-- TODO: Can we avoid this manual parsing?
-- If possible only keep the above.
| "import " `T.isPrefixOf` fullLine
= filtImportCompls

-- ------------------------------------------------------------------------
-- {-# LA| #-}
-- we leave this condition here to avoid duplications and return empty list
Expand Down Expand Up @@ -707,10 +695,6 @@ getCompletions
funs = map (show . name) $ HashSet.toList funcs
in filterModuleExports moduleName $ map T.pack funs

-- manually parse in case we don't have completion context ("import [qualified ]ModuleName")
getModuleName :: T.Text -> Maybe T.Text
getModuleName line = filter (/= "qualified") (T.words line) !? 1

filtImportCompls :: [Scored CompletionItem]
filtImportCompls = filtListWith (mkImportCompl enteredQual) importableModules

Expand Down

0 comments on commit 277faef

Please sign in to comment.