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
rule
Rulethe rule that was matched
length
ParsePositionDeltathe length of the rule application
examinedTo
ParsePositionDeltathe amount of text that was analyzed to come to the conclusion of this rule application
Exceptions
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
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)
Activates the rule application, i.e. marks it as part of the current parse tree
public virtual void Activate(ParseContext context)
Parameters
context
ParseContextthe context in which the parse tree exists
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
context
ParseContextthe parse context
result
ICollection<DocumentSymbol>the list to add the document symbol to
children
IEnumerable<DocumentSymbol>the children symbols of the document symbol
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
other
RuleApplicationthe rule application to which the rule should be applied
context
ParseContextthe parse context
Returns
- RuleApplication
the merged rule application
CodeLenses(Predicate<CodeLensApplication>)
Calculates the code lenses matching the given predicate
public ICollection<CodeLensApplication> CodeLenses(Predicate<CodeLensApplication> predicate = null)
Parameters
predicate
Predicate<CodeLensApplication>A predicate to filter code lenses or null
Returns
- ICollection<CodeLensApplication>
A collection of code lenses
CreateParseErrors()
Gets a collection of parse errors represented by this rule application
public virtual IEnumerable<DiagnosticItem> CreateParseErrors()
Returns
- IEnumerable<DiagnosticItem>
A collection of parse errors
Deactivate(ParseContext)
Deactivates the rule application, i.e. unmarks it as part of the parse tree
public virtual void Deactivate(ParseContext context)
Parameters
context
ParseContextthe 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
position
ParsePositionThe position
rule
RuleThe 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)
Gets the literal at the given position
public abstract RuleApplication GetLiteralAt(ParsePosition position)
Parameters
position
ParsePositionthe position
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
context
ParseContextthe parse context
Returns
- object
the parsed newPosition
IterateLiterals(Action<LiteralRuleApplication>)
Iterate over all literals
public abstract void IterateLiterals(Action<LiteralRuleApplication> action)
Parameters
action
Action<LiteralRuleApplication>the action that should be performed for all literals
IterateLiterals<T>(Action<LiteralRuleApplication, T>, T)
Iterate over all literals
public abstract void IterateLiterals<T>(Action<LiteralRuleApplication, T> action, T parameter)
Parameters
action
Action<LiteralRuleApplication, T>the action that should be performed for all literals
parameter
Tthe parameter
Type Parameters
T
the 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
changedChild
RuleApplicationthe changed rule application (either this or a child in the parse tree)
context
ParseContextthe parse context
oldValueApplication
RuleApplicationthe rule application with the old value
Validate(ParseContext)
Validates the rule semantically
public virtual void Validate(ParseContext context)
Parameters
context
ParseContextthe 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
writer
PrettyPrintWriterthe writer to which the rule application should be written
context
ParseContextthe parse context