Safe Haskell | None |
---|---|
Language | Haskell2010 |
A module for preparing the representation of the AST for pretty printing.
- prepareAST :: StringBuffer -> Ann UModule dom RangeStage -> Ann UModule dom SrcTemplateStage
- prepareASTCpp :: StringBuffer -> Ann UModule dom RangeStage -> Ann UModule dom SrcTemplateStage
- placeComments :: RangeInfo stage => Map ApiAnnKey [SrcSpan] -> Map SrcSpan [Located AnnotationComment] -> Ann UModule dom stage -> Ann UModule dom stage
- getNormalComments :: Map SrcSpan [Located AnnotationComment] -> Map SrcSpan [Located AnnotationComment]
- getPragmaComments :: Map SrcSpan [Located AnnotationComment] -> Map String [Located String]
- child :: SpanInfo SrcTemplateStage
- opt :: OptionalInfo SrcTemplateStage
- list :: ListInfo SrcTemplateStage
- after :: AfterBefore i => String -> i -> i
- followedBy :: AfterBefore i => String -> i -> i
- relativeIndented :: RelativeIndent i => Int -> i -> i
- minimumIndented :: MinimumIndent i => Int -> i -> i
- separatedBy :: String -> ListInfo SrcTemplateStage -> ListInfo SrcTemplateStage
- indented :: ListInfo SrcTemplateStage -> ListInfo SrcTemplateStage
- (<>) :: SpanInfo SrcTemplateStage -> SpanInfo SrcTemplateStage -> SpanInfo SrcTemplateStage
- sourceTemplateNodeRange :: Simple Lens (SpanInfo SrcTemplateStage) SrcSpan
- sourceTemplateNodeElems :: Simple Lens (SpanInfo SrcTemplateStage) [SourceTemplateElem]
- sourceTemplateListRange :: Simple Lens (ListInfo SrcTemplateStage) SrcSpan
- srcTmpListBefore :: Simple Lens (ListInfo SrcTemplateStage) String
- srcTmpListAfter :: Simple Lens (ListInfo SrcTemplateStage) String
- srcTmpDefaultSeparator :: Simple Lens (ListInfo SrcTemplateStage) String
- srcTmpIndented :: Simple Lens (ListInfo SrcTemplateStage) (Maybe [Bool])
- srcTmpSeparators :: Simple Lens (ListInfo SrcTemplateStage) [([SourceTemplateTextElem], SrcSpan)]
- sourceTemplateOptRange :: Simple Lens (OptionalInfo SrcTemplateStage) SrcSpan
- srcTmpOptBefore :: Simple Lens (OptionalInfo SrcTemplateStage) String
- srcTmpOptAfter :: Simple Lens (OptionalInfo SrcTemplateStage) String
- data SourceTemplateElem
- sourceTemplateTextElem :: Partial SourceTemplateElem SourceTemplateElem [SourceTemplateTextElem] [SourceTemplateTextElem]
- sourceTemplateTextRange :: Partial SourceTemplateElem SourceTemplateElem SrcSpan SrcSpan
- data SourceTemplateTextElem
- = NormalText { }
- | StayingText { }
- sourceTemplateText :: Lens SourceTemplateTextElem SourceTemplateTextElem String String
- isStayingText :: SourceTemplateTextElem -> Bool
- rangeToSource :: SourceInfoTraversal node => StringBuffer -> Ann node dom RngTemplateStage -> Ann node dom SrcTemplateStage
- fixRanges :: SourceInfoTraversal node => Ann node dom RangeStage -> Ann node dom NormRangeStage
- cutUpRanges :: forall node dom. SourceInfoTraversal node => Ann node dom NormRangeStage -> Ann node dom RngTemplateStage
- getLocIndices :: SourceInfoTraversal e => Ann e dom RngTemplateStage -> Set (RealSrcLoc, Int)
- mapLocIndices :: Ord k => StringBuffer -> Set (RealSrcLoc, k) -> Map k String
- fixMainRange :: StringBuffer -> Ann UModule dom RangeStage -> Ann UModule dom RangeStage
- extractStayingElems :: SourceInfoTraversal node => Ann node dom SrcTemplateStage -> Ann node dom SrcTemplateStage
Documentation
prepareAST :: StringBuffer -> Ann UModule dom RangeStage -> Ann UModule dom SrcTemplateStage Source #
Prepares the AST for pretty printing
prepareASTCpp :: StringBuffer -> Ann UModule dom RangeStage -> Ann UModule dom SrcTemplateStage Source #
placeComments :: RangeInfo stage => Map ApiAnnKey [SrcSpan] -> Map SrcSpan [Located AnnotationComment] -> Ann UModule dom stage -> Ann UModule dom stage Source #
Puts comments in the nodes they should be attached to. Watches for lexical tokens that may divide the comment and the supposed element. Leaves the AST in a state where parent nodes does not contain all of their children.
getNormalComments :: Map SrcSpan [Located AnnotationComment] -> Map SrcSpan [Located AnnotationComment] Source #
getPragmaComments :: Map SrcSpan [Located AnnotationComment] -> Map String [Located String] Source #
after :: AfterBefore i => String -> i -> i Source #
Put the given string before the element if it is not empty
followedBy :: AfterBefore i => String -> i -> i Source #
The given string should follow the element if it is not empty
relativeIndented :: RelativeIndent i => Int -> i -> i Source #
The element should be indented relatively to its parent
minimumIndented :: MinimumIndent i => Int -> i -> i Source #
The elements should be indented at least to the given number of spaces
separatedBy :: String -> ListInfo SrcTemplateStage -> ListInfo SrcTemplateStage Source #
The elements of the list should be separated by the given string by default (might be overridden)
indented :: ListInfo SrcTemplateStage -> ListInfo SrcTemplateStage Source #
The elements of the list should be indented on the same column
(<>) :: SpanInfo SrcTemplateStage -> SpanInfo SrcTemplateStage -> SpanInfo SrcTemplateStage Source #
Concatenates two source templates to produce a new template with all child elements.
srcTmpIndented :: Simple Lens (ListInfo SrcTemplateStage) (Maybe [Bool]) Source #
srcTmpSeparators :: Simple Lens (ListInfo SrcTemplateStage) [([SourceTemplateTextElem], SrcSpan)] Source #
data SourceTemplateElem Source #
An element of a source template for a singleton AST node.
sourceTemplateTextElem :: Partial SourceTemplateElem SourceTemplateElem [SourceTemplateTextElem] [SourceTemplateTextElem] Source #
rangeToSource :: SourceInfoTraversal node => StringBuffer -> Ann node dom RngTemplateStage -> Ann node dom SrcTemplateStage Source #
fixRanges :: SourceInfoTraversal node => Ann node dom RangeStage -> Ann node dom NormRangeStage Source #
Modifies ranges to contain their children
cutUpRanges :: forall node dom. SourceInfoTraversal node => Ann node dom NormRangeStage -> Ann node dom RngTemplateStage Source #
Creates a source template from the ranges and the input file. All source ranges must be good ranges.
getLocIndices :: SourceInfoTraversal e => Ann e dom RngTemplateStage -> Set (RealSrcLoc, Int) Source #
Assigns an index (in the order they are used) for each range
mapLocIndices :: Ord k => StringBuffer -> Set (RealSrcLoc, k) -> Map k String Source #
Partitions the source file in the order where the parts are used in the AST
fixMainRange :: StringBuffer -> Ann UModule dom RangeStage -> Ann UModule dom RangeStage Source #
extractStayingElems :: SourceInfoTraversal node => Ann node dom SrcTemplateStage -> Ann node dom SrcTemplateStage Source #
Marks template elements in the AST that should always be present in the source code, regardless of their containing elements being deleted. Currently it recognizes CPP pragmas (lines starting with #) This function should only be applied to an AST if CPP is enabled.