Enhanced C#
Language of your choice: library documentation
|
Trivia injector customized for Enhanced C#. More...
Trivia injector customized for Enhanced C#.
How newline trivia works in EC# (mostly this is the same as StandardTriviaInjector):
else
has no representation in the syntax tree and may appear to the injector the same as a blank line. In this situation two newlines are attached to the child of #if at index 2, and one is deleted by this class so that there is only one newline before the second child. : base(...)
) get a newline before the colon by default, which can be suppressed with appendStatement. Note: These constructors have an unusual syntax tree which the standard trivia injector can't handle properly; see comment in DoneAttaching() for details. Public Member Functions | |
EcsTriviaInjector (IListSource< Token > sortedTrivia, ISourceFile sourceFile, int newlineTypeInt, string mlCommentPrefix, string mlCommentSuffix, string slCommentPrefix, bool topLevelIsBlock) | |
Public Member Functions inherited from Loyc.Syntax.StandardTriviaInjector | |
StandardTriviaInjector (IListSource< Token > sortedTrivia, ISourceFile sourceFile, int newlineTypeInt, string mlCommentPrefix, string mlCommentSuffix, string slCommentPrefix, bool topLevelIsBlock=true) | |
Initializes StandardTriviaInjector. More... | |
Public Member Functions inherited from Loyc.Syntax.AbstractTriviaInjector< Token > | |
AbstractTriviaInjector (IListSource< Trivia > sortedTrivia) | |
Initializes the SortedTrivia property. More... | |
IEnumerator< LNode > | Run (IEnumerator< LNode > nodes) |
Attaches trivia to the input nodes provided. More... | |
Protected Member Functions | |
override LNodeList | GetTriviaToAttach (LNode node, IListSource< Token > trivia, TriviaLocation loc, LNode parent, int indexInParent) |
override LNode | MakeTriviaAttribute (Token t) |
Called to transform a trivia token into a trivia attribute. More... | |
override LNode | DoneAttaching (LNode node, LNode parent, int indexInParent) |
This method is called after a node has been processed and any applicable trivia was attached. More... | |
Protected Member Functions inherited from Loyc.Syntax.StandardTriviaInjector | |
override LNodeList | GetTriviaToAttach (LNode node, IListSource< Token > trivia, TriviaLocation loc, LNode parent, int indexInParent) |
virtual bool | HasImplicitLeadingNewline (LNode child, LNode parent, int indexInParent) |
Called to find out if a newline is to be added implicitly before the current child of the specified node. More... | |
override bool | IsNewline (Token trivia) |
override SourceRange | GetRange (Token trivia) |
Protected Member Functions inherited from Loyc.Syntax.AbstractTriviaInjector< Token > | |
abstract LNodeList | GetTriviaToAttach (LNode node, IListSource< Trivia > trivia, TriviaLocation loc, LNode parent, int indexInParent) |
Derived class translates a list of trivia (tokens) into appropriate trivia attributes. This will be called for leading trivia before trailing trivia. More... | |
virtual void | ProcessChildrenOfOneLiner (ref LNode node) |
This method is called when a node has no newlines or comments within it (although the node may still have a leading or trailing comment). The method should add appendStatement trivia inside blocks in the node, if necessary. More... | |
abstract SourceRange | GetRange (Trivia trivia) |
Gets the SourceRange for an element of trivia. More... | |
abstract bool | IsNewline (Trivia trivia) |
Returns true if the trivia represents a newline, false otherwise. More... | |
virtual LNode | GetEmptyResultSet () |
A method called to create a virtual node, in order to apply trivia to a source file that is completely empty except for trivia. More... | |
IEnumerator< Pair< LNode, int > > | RunCore (IEnumerator< Pair< LNode, int >> nodes, LNode parent) |
Core trivia associaton algorithm. More... | |
Additional Inherited Members | |
Properties inherited from Loyc.Syntax.StandardTriviaInjector | |
ISourceFile | SourceFile [get, set] |
int | NewlineTypeInt [get, set] |
string | SLCommentPrefix [get, set] |
string | SLCommentSuffix [get, set] |
string | MLCommentPrefix [get, set] |
string | MLCommentSuffix [get, set] |
bool | TopLevelIsBlock [get, set] |
Properties inherited from Loyc.Syntax.AbstractTriviaInjector< Token > | |
IListSource< Trivia > | SortedTrivia [get, set] |
List of trivia to be injected by Run. Must be sorted. More... | |
int | NextIndex [get, set] |
Index of next trivia to be injected. More... | |
Static Protected Member Functions inherited from Loyc.Syntax.AbstractTriviaInjector< Token > | |
static IEnumerator< Pair< T, int > > | WithIndexes< T > (IEnumerator< T > e) |
|
inlineprotectedvirtual |
This method is called after a node has been processed and any applicable trivia was attached.
node | Node (after trivia attached) |
parent | Parent of node (old version, before changes to children are applied) |
indexInParent | Index of node within parent . |
node
or an altered version of node
.This method gives the derived class one final chance to rearrange or alter the interpretation of the attached trivia. Note that this method may be called on some nodes to which trivia was not attached, when siblings of the same parent had trivia attached.
Reimplemented from Loyc.Syntax.AbstractTriviaInjector< Token >.
References Loyc.Syntax.LNode.Args, Loyc.Syntax.CodeSymbols.Braces, Loyc.Syntax.LNode.Calls(), Loyc.Syntax.LNode.CallsMin(), Loyc.Syntax.LNode.Range, and Loyc.Syntax.LNode.Target.
|
inlineprotectedvirtual |
Called to transform a trivia token into a trivia attribute.
If a trivia token is not recognized, null is returned to ignore the trivia.
Reimplemented from Loyc.Syntax.StandardTriviaInjector.
References Loyc.Syntax.Lexing.Token.Range(), and Loyc.Syntax.Lexing.Token.Value.