Table of Contents

Class ResolveRule<TSemanticElement, TReference>

Namespace
NMF.AnyText.Model
Assembly
NMF.AnyText.Core.dll

Denotes the base class for a rule that resolves elements

public abstract class ResolveRule<TSemanticElement, TReference> : QuoteRule

Type Parameters

TSemanticElement
TReference
Inheritance
ResolveRule<TSemanticElement, TReference>
Derived
Inherited Members

Properties

ApplyOverReplace

Indicates whether a replace rather than apply is required on update

protected virtual bool ApplyOverReplace { get; }

Property Value

bool

IsReference

True, if the application of this rule denotes a reference

public override bool IsReference { get; }

Property Value

bool

ResolveDelayLevel

Gets the delay level

protected virtual byte ResolveDelayLevel { get; }

Property Value

byte

Remarks

Reference are resolved in layers, one after the other.

TryResolveOnActivate

Determines, whether the rule should attempt to resolve references directly when a rule application gets activated

protected virtual bool TryResolveOnActivate { get; }

Property Value

bool

Methods

Apply(ParseContext, TSemanticElement, TReference)

Applies the given value to the provided context element

protected abstract void Apply(ParseContext context, TSemanticElement contextElement, TReference propertyValue)

Parameters

context ParseContext

the parse context in which this operation is performed

contextElement TSemanticElement

the element to which the value should be applied

propertyValue TReference

the value to apply

CreateCompletionEntry(TReference, object, RuleApplication, ParsePosition, ParseContext)

Creates the completion entry for the given reference

protected virtual CompletionEntry CreateCompletionEntry(TReference reference, object semanticContext, RuleApplication ruleApplication, ParsePosition position, ParseContext context)

Parameters

reference TReference

the referenced element

semanticContext object

the semantic context

ruleApplication RuleApplication

the rule application for which to calculate the completion entry

position ParsePosition

the position of the request

context ParseContext

the parse context in which the completion is requested

Returns

CompletionEntry

CreateRuleApplication(RuleApplication, ParseContext)

Creates the rule application for this rule

protected override RuleApplication CreateRuleApplication(RuleApplication app, ParseContext context)

Parameters

app RuleApplication

the inner rule application

context ParseContext

the parse context

Returns

RuleApplication

the new rule application

GetCandidates(object, string, ParseContext)

Gets the candidates to resolve the given input straing

protected virtual IEnumerable<TReference> GetCandidates(object contextElement, string input, ParseContext context)

Parameters

contextElement object

the context element in which the element should be resolved

input string

the input string

context ParseContext

the parse context in which candidates are resolved

Returns

IEnumerable<TReference>

A collection of potential references

Remarks

In case the parse tree was not successful, the context element may be of a different type than TSemanticElement.

GetHoverText(RuleApplication, Parser, ParsePosition)

Retrieves the hover text for a symbol at a given position in the document, if available.

public override string GetHoverText(RuleApplication ruleApplication, Parser document, ParsePosition position)

Parameters

ruleApplication RuleApplication

The rule application context that is used to process the document.

document Parser

The document being parsed.

position ParsePosition

The position in the document where the hover text is requested.

Returns

string

A string containing the hover text, or null if no matching symbol or hover text is found.

GetReferenceString(TReference, object, ParseContext)

Gets the printed reference for the given object

protected virtual string GetReferenceString(TReference reference, object contextElement, ParseContext context)

Parameters

reference TReference

the referenced object

contextElement object

the semantic context element

context ParseContext

the parse context

Returns

string

a string representation

Invalidate(RuleApplication, ParseContext)

Invalidates the given rule application, checking for potential errors

public override void Invalidate(RuleApplication ruleApplication, ParseContext context)

Parameters

ruleApplication RuleApplication

the rule application to invalidate

context ParseContext

the parse context in which the rule application is invalidated

OnActivate(RuleApplication, ParseContext)

Gets called when a rule application is activated

protected override void OnActivate(RuleApplication application, ParseContext context)

Parameters

application RuleApplication

the rule application that is activated

context ParseContext

the context in which the rule application is activated

OnDeactivate(RuleApplication, ParseContext)

Gets called when a rule application is deactivated

protected override void OnDeactivate(RuleApplication application, ParseContext context)

Parameters

application RuleApplication

the rule application that is deactivated

context ParseContext

the context in which the rule application is deactivated

OnValueChange(RuleApplication, ParseContext, RuleApplication)

Gets called when the value of a rule application changes

protected override bool OnValueChange(RuleApplication application, ParseContext context, RuleApplication oldRuleApplication)

Parameters

application RuleApplication

the rule application for which the value changed

context ParseContext

the context in which the value changed

oldRuleApplication RuleApplication

the old rule application

Returns

bool

true, if the rule processed the value change, otherwise false (in which case the value change is propagated)

Replace(ParseContext, TSemanticElement, TReference, TReference)

Replaces the provided old element with the provided new element

protected virtual void Replace(ParseContext context, TSemanticElement contextElement, TReference oldValue, TReference newValue)

Parameters

context ParseContext

the parse context in which this operation is performed

contextElement TSemanticElement

the element to which the value should be applied

oldValue TReference

the old value

newValue TReference

the value to apply

SuggestCompletions(ParseContext, RuleApplication, string, ParsePosition)

Suggests useful code completions

public override IEnumerable<CompletionEntry> SuggestCompletions(ParseContext context, RuleApplication ruleApplication, string fragment, ParsePosition position)

Parameters

context ParseContext
ruleApplication RuleApplication
fragment string
position ParsePosition

Returns

IEnumerable<CompletionEntry>

TryResolveReference(TSemanticElement, string, ParseContext, out TReference)

Resolves the given input

protected virtual bool TryResolveReference(TSemanticElement contextElement, string input, ParseContext context, out TReference resolved)

Parameters

contextElement TSemanticElement

the element in the context of which the string is resolved

input string

the textual reference

context ParseContext

the context in which the element is resolved

resolved TReference

the resolved reference or the default

Returns

bool

true, if the reference could be resolved, otherwise false

Unapply(ParseContext, TSemanticElement, TReference)

Unapplies the given value to the provided context element

protected abstract void Unapply(ParseContext context, TSemanticElement contextElement, TReference propertyValue)

Parameters

context ParseContext

the parse context in which this operation is performed

contextElement TSemanticElement

the element to which the value should be unapplied

propertyValue TReference

the value to unapply