@@ -755,23 +755,21 @@ suggestExportUnusedTopBinding srcOpt ParsedModule{pm_parsed_source = L _ HsModul
755
755
opLetter :: T. Text
756
756
opLetter = " :!#$%&*+./<=>?@\\ ^|-~"
757
757
758
- parenthesizeIfNeeds :: Bool -> T. Text -> T. Text
759
- parenthesizeIfNeeds needsTypeKeyword x
760
- | T. any (c == ) opLetter = (if needsTypeKeyword then " type " else " " ) <> " (" <> x <> " )"
761
- | otherwise = x
762
- where
763
- c = T. head x
764
-
765
758
matchWithDiagnostic :: Range -> Located (IdP GhcPs ) -> Bool
766
759
matchWithDiagnostic Range {_start= l,_end= r} x =
767
760
let loc = fmap _start . getLocatedRange $ x
768
761
in loc >= Just l && loc <= Just r
769
762
770
763
printExport :: ExportsAs -> T. Text -> T. Text
771
- printExport ExportName x = parenthesizeIfNeeds False x
772
- printExport ExportPattern x = " pattern " <> parenthesizeIfNeeds False x
773
- printExport ExportFamily x = parenthesizeIfNeeds True x
774
- printExport ExportAll x = parenthesizeIfNeeds True x <> " (..)"
764
+ printExport ea name = prefix <> parenthesizedName <> suffix
765
+ where
766
+ parenthesizedName = if T. any (firstChar == ) opLetter then " (" <> name <> " )" else name
767
+ firstChar = T. head name
768
+ (prefix, suffix) = case ea of
769
+ ExportName -> (" " , " " )
770
+ ExportPattern -> (" pattern " , " " )
771
+ ExportFamily -> (" type " , " " )
772
+ ExportAll -> (" type " , " (..)" )
775
773
776
774
isTopLevel :: SrcSpan -> Bool
777
775
isTopLevel span = fmap (_character . _start) (srcSpanToRange span ) == Just 0
0 commit comments