-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"Operator" was too specific and did not accurately represent non-operator identifiers such as function and variable names. "Name" is more versatile and appropriately covers both operators and identifiers.
- Loading branch information
Showing
10 changed files
with
86 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{-# LANGUAGE RecordWildCards #-} | ||
|
||
module HIndent.Ast.Name.Prefix | ||
( PrefixName | ||
, mkPrefixName | ||
) where | ||
|
||
import Data.Maybe | ||
import qualified GHC.Types.Name as GHC | ||
import qualified GHC.Types.Name.Reader as GHC | ||
import qualified GHC.Unit.Module as GHC | ||
import HIndent.Ast.NodeComments | ||
import {-# SOURCE #-} HIndent.Pretty | ||
import HIndent.Pretty.Combinators | ||
import HIndent.Pretty.NodeComments | ||
|
||
data PrefixName = PrefixName | ||
{ name :: String | ||
, moduleName :: Maybe GHC.ModuleName | ||
, parentheses :: Bool | ||
} | ||
|
||
instance CommentExtraction PrefixName where | ||
nodeComments PrefixName {} = NodeComments [] [] [] | ||
|
||
instance Pretty PrefixName where | ||
pretty' PrefixName {..} = | ||
wrap $ hDotSep $ catMaybes [pretty <$> moduleName, Just $ string name] | ||
where | ||
wrap = | ||
if parentheses | ||
then parens | ||
else id | ||
|
||
mkPrefixName :: GHC.RdrName -> PrefixName | ||
mkPrefixName (GHC.Unqual name) = | ||
PrefixName (showOutputable name) Nothing (parensNeeded name) | ||
mkPrefixName (GHC.Qual modName name) = | ||
PrefixName (showOutputable name) (Just modName) (parensNeeded name) | ||
mkPrefixName (GHC.Orig {}) = | ||
error "This AST node should not appear in the parser output." | ||
mkPrefixName (GHC.Exact name) = | ||
PrefixName (showOutputable name) Nothing (parensNeeded $ GHC.occName name) | ||
|
||
parensNeeded :: GHC.OccName -> Bool | ||
parensNeeded = GHC.isSymOcc |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters