Table of Contents

Class RuleApplication

Namespace
NMF.AnyText.Rules
Assembly
NMF.AnyText.Core.dll

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 Rule

the rule that was matched

length ParsePositionDelta

the length of the rule application

examinedTo ParsePositionDelta

the amount of text that was analyzed to come to the conclusion of this rule application

Exceptions

InvalidOperationException

Properties

Children

Gets the child rule applications

public virtual IEnumerable<RuleApplication> Children { get; }

Property Value

IEnumerable<RuleApplication>

Comments

Gets a collection of comments for this rule application

public List<RuleApplication> Comments { get; }

Property Value

List<RuleApplication>

ContextElement

Gets the element that denotes the context for this rule application

public virtual object ContextElement { get; }

Property Value

object

CurrentPosition

Gets the last position of this rule application

public ParsePosition CurrentPosition { get; }

Property Value

ParsePosition

DiagnosticItems

Gets a collection of diagnostic items related to this rule application

public IEnumerable<DiagnosticItem> DiagnosticItems { get; }

Property Value

IEnumerable<DiagnosticItem>

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

ParsePositionDelta

IsActive

True, if the rule application is part of the current parse tree

public bool IsActive { get; }

Property Value

bool

IsPositive

True, if the rule application was successful, otherwise false

public virtual bool IsPositive { get; }

Property Value

bool

Length

the length of the rule application

public ParsePositionDelta Length { get; protected set; }

Property Value

ParsePositionDelta

Parent

Gets the parent rule application in the parse tree

public RuleApplication Parent { get; }

Property Value

RuleApplication

PotentialError

Denotes a potential error to improve error reporting

public virtual RuleApplication PotentialError { get; }

Property Value

RuleApplication

Rule

The rule that was matched

public Rule Rule { get; }

Property Value

Rule

ScopeLength

the amount of characters that influence the current rule application

public ParsePositionDelta ScopeLength { get; }

Property Value

ParsePositionDelta

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

object

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 ParseContext

the 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 ParseContext

the 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 RuleApplication

the rule application to which the rule should be applied

context ParseContext

the 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 ParseContext

the 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 ParsePosition

The position

rule Rule

The 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 ParsePosition

the 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 ParseContext

the 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 T

the 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 RuleApplication

the changed rule application (either this or a child in the parse tree)

context ParseContext

the parse context

oldValueApplication RuleApplication

the rule application with the old value

Validate(ParseContext)

Validates the rule semantically

public virtual void Validate(ParseContext context)

Parameters

context ParseContext

the 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 PrettyPrintWriter

the writer to which the rule application should be written

context ParseContext

the parse context