Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement stripPrefix via T.stripPrefix #2645

Merged
merged 1 commit into from Jan 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 3 additions & 6 deletions ghcide/src/Development/IDE/Plugin/Completions/Logic.hs
Expand Up @@ -31,6 +31,7 @@ import Data.Function (on)
import Data.Functor
import qualified Data.HashMap.Strict as HM
import qualified Data.HashSet as HashSet
import Data.Monoid (First(..))
import Data.Ord (Down (Down))
import qualified Data.Set as Set
import Development.IDE.Core.Compile
Expand Down Expand Up @@ -757,12 +758,8 @@ openingBacktick line prefixModule prefixText Position { _character=(fromIntegral
-}
-- TODO: Turn this into an alex lexer that discards prefixes as if they were whitespace.
stripPrefix :: T.Text -> T.Text
stripPrefix name = T.takeWhile (/=':') $ go prefixes
where
go [] = name
go (p:ps)
| T.isPrefixOf p name = T.drop (T.length p) name
| otherwise = go ps
stripPrefix name = T.takeWhile (/=':') $ fromMaybe name $
getFirst $ foldMap (First . (`T.stripPrefix` name)) prefixes

-- | Prefixes that can occur in a GHC OccName
prefixes :: [T.Text]
Expand Down