Class RuleApplication
Denotes the application of a rule
public abstract class RuleApplication
- Inheritance
-
RuleApplication
- Derived
- Inherited Members
Constructors
RuleApplication(Rule, ParsePositionDelta, ParsePositionDelta)
Creates a new instance
protected RuleApplication(Rule rule, ParsePositionDelta length, ParsePositionDelta examinedTo)
Parameters
ruleRulethe rule that was matched
lengthParsePositionDeltathe length of the rule application
examinedToParsePositionDeltathe amount of text that was analyzed to come to the conclusion of this rule application
Exceptions
- InvalidOperationException
thrown if the length is negative
Properties
Children
Gets the child rule applications
public virtual IEnumerable<RuleApplication> Children { get; }
Property Value
Comments
Gets a collection of comments for this rule application
public List<RuleApplication> Comments { get; }
Property Value
ContextElement
Gets the element that denotes the context for this rule application
public virtual object ContextElement { get; }
Property Value
CurrentPosition
Gets the last position of this rule application
public ParsePosition CurrentPosition { get; }
Property Value
DiagnosticItems
Gets a collection of diagnostic items related to this rule application
public IEnumerable<DiagnosticItem> DiagnosticItems { get; }
Property Value
ExaminedTo
the amount of text that was analyzed to come to the conclusion of this rule application
public ParsePositionDelta ExaminedTo { get; protected set; }
Property Value
IsActive
True, if the rule application is part of the current parse tree
public bool IsActive { get; }
Property Value
IsPositive
True, if the rule application was successful, otherwise false
public virtual bool IsPositive { get; }
Property Value
IsRecovered
Determines whether this rule application contains a recovery
public bool IsRecovered { get; protected set; }
Property Value
Length
the length of the rule application
public ParsePositionDelta Length { get; protected set; }
Property Value
Parent
Gets the parent rule application in the parse tree
public RuleApplication Parent { get; }
Property Value
PotentialError
Denotes a potential error to improve error reporting
public virtual RuleApplication PotentialError { get; }
Property Value
Rule
The rule that was matched
public Rule Rule { get; }
Property Value
ScopeLength
the amount of characters that influence the current rule application
public ParsePositionDelta ScopeLength { get; }
Property Value
Remarks
for positive rule applications, this is the length, for negative rule applications it is the examination length
SemanticElement
Gets the semantic element of the rule application
public virtual object SemanticElement { get; }
Property Value
Methods
Activate(ParseContext, bool)
Activates the rule application, i.e. marks it as part of the current parse tree
public virtual void Activate(ParseContext context, bool initial)
Parameters
contextParseContextthe context in which the parse tree exists
initialboolflag to indicate whether the activation is part of the initial parse
AddDocumentSymbol(ParseContext, ICollection<DocumentSymbol>, IEnumerable<DocumentSymbol>)
Adds a document symbol to a list
public virtual void AddDocumentSymbol(ParseContext context, ICollection<DocumentSymbol> result, IEnumerable<DocumentSymbol> children)
Parameters
contextParseContextthe parse context
resultICollection<DocumentSymbol>the list to add the document symbol to
childrenIEnumerable<DocumentSymbol>the children symbols of the document symbol
AddParseErrors(ParseContext)
Gets a collection of parse errors represented by this rule application
public virtual void AddParseErrors(ParseContext context)
Parameters
contextParseContextthe parse context in which the parse errors are requested
ApplyTo(RuleApplication, ParseContext)
Applies the structure of the current rule application to the given other rule application
public abstract RuleApplication ApplyTo(RuleApplication other, ParseContext context)
Parameters
otherRuleApplicationthe rule application to which the rule should be applied
contextParseContextthe parse context
Returns
- RuleApplication
the merged rule application
CalculateIndex(RuleApplication)
Calculates an insertion index
public virtual int CalculateIndex(RuleApplication ruleApplication)
Parameters
ruleApplicationRuleApplicationthe rule application for which to calculate the index
Returns
- int
an index or -1, if no index could be found
CalculateIndex(RuleApplication, Stack<Rule>)
Calculates an insertion index
public virtual int CalculateIndex(RuleApplication ruleApplication, Stack<Rule> ruleStack)
Parameters
ruleApplicationRuleApplicationthe rule application for which to calculate the index
ruleStackStack<Rule>a rule stack that needs to match
Returns
- int
an index or -1, if no index could be found
CodeLenses(Predicate<CodeLensApplication>)
Calculates the code lenses matching the given predicate
public ICollection<CodeLensApplication> CodeLenses(Predicate<CodeLensApplication> predicate = null)
Parameters
predicatePredicate<CodeLensApplication>A predicate to filter code lenses or null
Returns
- ICollection<CodeLensApplication>
A collection of code lenses
Deactivate(ParseContext)
Deactivates the rule application, i.e. unmarks it as part of the parse tree
public virtual void Deactivate(ParseContext context)
Parameters
contextParseContextthe context in which the parse tree exists
FindChildAt(ParsePosition, Rule)
Gets the child rule application at the given position
public virtual RuleApplication FindChildAt(ParsePosition position, Rule rule)
Parameters
positionParsePositionThe position
ruleRuleThe expected rule of the child
Returns
- RuleApplication
The child at the given position or null
GetFirstInnerLiteral()
Calculates the first literal within this rule application
public abstract LiteralRuleApplication GetFirstInnerLiteral()
Returns
- LiteralRuleApplication
the first literal rule application or null
GetFirstReferenceOrDefinition()
Gets the first reference or definition rule in the upward parse tree starting from this rule application
public RuleApplication GetFirstReferenceOrDefinition()
Returns
- RuleApplication
The rule application of the reference or definition rule
GetIdentifier()
Gets the first contained rule application that represents an identifier
public virtual RuleApplication GetIdentifier()
Returns
- RuleApplication
The rule application for the literal rule representing the identifier
GetLastInnerLiteral()
Calculates the last literal within this rule application
public abstract LiteralRuleApplication GetLastInnerLiteral()
Returns
- LiteralRuleApplication
the last literal rule application or null
GetLiteralAt(ParsePosition, bool)
Gets the literal at the given position
public abstract RuleApplication GetLiteralAt(ParsePosition position, bool onlyActive = false)
Parameters
positionParsePositionthe position
onlyActiveboolwhether to only return an active rule application (default: false)
Returns
- RuleApplication
the literal rule application or null, if there is no literal there
GetValue(ParseContext)
Gets the parsed newPosition under the given context
public abstract object GetValue(ParseContext context)
Parameters
contextParseContextthe parse context
Returns
- object
the parsed newPosition
IsStack(Stack<Rule>)
Determines whether the rule application contains a tree of the given rule stack
public virtual bool IsStack(Stack<Rule> ruleStack)
Parameters
Returns
- bool
true, if the application contains a tree of the given rule stack, otherwise false
IterateLiterals(Action<LiteralRuleApplication>)
Iterate over all literals
public void IterateLiterals(Action<LiteralRuleApplication> action)
Parameters
actionAction<LiteralRuleApplication>the action that should be performed for all literals
IterateLiterals(Action<LiteralRuleApplication>, bool)
Iterate over all literals
public abstract void IterateLiterals(Action<LiteralRuleApplication> action, bool includeFailures)
Parameters
actionAction<LiteralRuleApplication>the action that should be performed for all literals
includeFailuresbooltrue, if failed rule applications should be considered, otherwise false
IterateLiterals<T>(Action<LiteralRuleApplication, T>, T)
Iterate over all literals
public void IterateLiterals<T>(Action<LiteralRuleApplication, T> action, T parameter)
Parameters
actionAction<LiteralRuleApplication, T>the action that should be performed for all literals
parameterTthe parameter
Type Parameters
Tthe parameter type
IterateLiterals<T>(Action<LiteralRuleApplication, T>, T, bool)
Iterate over all literals
public abstract void IterateLiterals<T>(Action<LiteralRuleApplication, T> action, T parameter, bool includeFailures)
Parameters
actionAction<LiteralRuleApplication, T>the action that should be performed for all literals
parameterTthe parameter
includeFailuresbooltrue, if failed rule applications should be considered, otherwise false
Type Parameters
Tthe parameter type
OnValueChange(RuleApplication, ParseContext, RuleApplication)
Gets called when the newPosition of the given rule application changes
protected virtual void OnValueChange(RuleApplication changedChild, ParseContext context, RuleApplication oldValueApplication)
Parameters
changedChildRuleApplicationthe changed rule application (either this or a child in the parse tree)
contextParseContextthe parse context
oldValueApplicationRuleApplicationthe rule application with the old value
Recover(RuleApplication, ParseContext, out ParsePosition)
Tries to recover the given rule application
public virtual RuleApplication Recover(RuleApplication currentRoot, ParseContext context, out ParsePosition position)
Parameters
currentRootRuleApplicationthe current root rule application
contextParseContextthe parse context in which a recovery is attempted
positionParsePositionthe parse position after recovery
Returns
- RuleApplication
the recovered rule application
ReplaceChild(RuleApplication, RuleApplication)
Replaces the given child rule application with the given new child
public virtual void ReplaceChild(RuleApplication childApplication, RuleApplication newChild)
Parameters
childApplicationRuleApplicationthe child rule application
newChildRuleApplicationa new child
SetupPrettyPrinter(PrettyPrintWriter)
Setup the given pretty printer
public void SetupPrettyPrinter(PrettyPrintWriter writer)
Parameters
writerPrettyPrintWriter
Validate(ParseContext)
Validates the rule semantically
public virtual void Validate(ParseContext context)
Parameters
contextParseContextthe parse context in which the rule is validated
Write(PrettyPrintWriter, ParseContext)
Writes the given rule application to the provided text writer
public abstract void Write(PrettyPrintWriter writer, ParseContext context)
Parameters
writerPrettyPrintWriterthe writer to which the rule application should be written
contextParseContextthe parse context