Skip to content

Commit 6179208

Browse files
committed
Revert partial changes from #2483
Instead of using a low-level `is_ident` that only works on ascii characters. Instead match directly on the '_' character. The original functionality has been restored (using `isAlpha` instead). This commit removes the now unneccessary `is_ident` compat layer
1 parent da0379b commit 6179208

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

ghcide/src/Development/IDE/GHC/Compat/Util.hs

-4
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ module Development.IDE.GHC.Compat.Util (
6969
stringToStringBuffer,
7070
nextChar,
7171
atEnd,
72-
-- * Char
73-
is_ident
7472
) where
7573

7674
#if MIN_VERSION_ghc(9,0,0)
@@ -83,7 +81,6 @@ import GHC.Data.FastString
8381
import GHC.Data.Maybe
8482
import GHC.Data.Pair
8583
import GHC.Data.StringBuffer
86-
import GHC.Parser.CharClass (is_ident)
8784
import GHC.Types.Unique
8885
import GHC.Types.Unique.DFM
8986
import GHC.Utils.Fingerprint
@@ -93,7 +90,6 @@ import GHC.Utils.Panic hiding (try)
9390
#else
9491
import Bag
9592
import BooleanFormula
96-
import Ctype (is_ident)
9793
import EnumSet
9894
import qualified Exception
9995
import FastString

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

+7-5
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ import qualified Data.Rope.UTF16 as Rope
4141
import qualified Data.Set as S
4242
import qualified Data.Text as T
4343
import Data.Tuple.Extra (fst3)
44-
import Development.IDE.Core.RuleTypes
4544
import Development.IDE.Core.Rules
45+
import Development.IDE.Core.RuleTypes
4646
import Development.IDE.Core.Service
4747
import Development.IDE.GHC.Compat
4848
import Development.IDE.GHC.Compat.Util
@@ -1606,8 +1606,10 @@ rangesForBindingImport _ _ = []
16061606
wrapOperatorInParens :: String -> String
16071607
wrapOperatorInParens x =
16081608
case uncons x of
1609-
Just (h, _t) -> if is_ident h then x else "(" <> x <> ")"
1610-
Nothing -> mempty
1609+
-- see #2483 and #2859
1610+
Just ('_', _t) -> x
1611+
Just (h, _t) -> if isAlpha h then x else "(" <> x <> ")"
1612+
Nothing -> mempty
16111613

16121614
smallerRangesForBindingExport :: [LIE GhcPs] -> String -> [Range]
16131615
smallerRangesForBindingExport lies b =
@@ -1763,8 +1765,8 @@ renderImportStyle (ImportAllConstructors p) = p <> "(..)"
17631765

17641766
-- | Used for extending import lists
17651767
unImportStyle :: ImportStyle -> (Maybe String, String)
1766-
unImportStyle (ImportTopLevel x) = (Nothing, T.unpack x)
1767-
unImportStyle (ImportViaParent x y) = (Just $ T.unpack y, T.unpack x)
1768+
unImportStyle (ImportTopLevel x) = (Nothing, T.unpack x)
1769+
unImportStyle (ImportViaParent x y) = (Just $ T.unpack y, T.unpack x)
17681770
unImportStyle (ImportAllConstructors x) = (Just $ T.unpack x, wildCardSymbol)
17691771

17701772

0 commit comments

Comments
 (0)