Class ResolveRule<TSemanticElement, TReference>
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
IsReference
True, if the application of this rule denotes a reference
public override bool IsReference { get; }
Property Value
ResolveDelayLevel
Gets the delay level
protected virtual byte ResolveDelayLevel { get; }
Property Value
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
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
ParseContextthe parse context in which this operation is performed
contextElement
TSemanticElementthe element to which the value should be applied
propertyValue
TReferencethe 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
TReferencethe referenced element
semanticContext
objectthe semantic context
ruleApplication
RuleApplicationthe rule application for which to calculate the completion entry
position
ParsePositionthe position of the request
context
ParseContextthe parse context in which the completion is requested
Returns
CreateRuleApplication(RuleApplication, ParseContext)
Creates the rule application for this rule
protected override RuleApplication CreateRuleApplication(RuleApplication app, ParseContext context)
Parameters
app
RuleApplicationthe inner rule application
context
ParseContextthe 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
objectthe context element in which the element should be resolved
input
stringthe input string
context
ParseContextthe 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
RuleApplicationThe rule application context that is used to process the document.
document
ParserThe document being parsed.
position
ParsePositionThe 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
TReferencethe referenced object
contextElement
objectthe semantic context element
context
ParseContextthe 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
RuleApplicationthe rule application to invalidate
context
ParseContextthe 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
RuleApplicationthe rule application that is activated
context
ParseContextthe 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
RuleApplicationthe rule application that is deactivated
context
ParseContextthe 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
RuleApplicationthe rule application for which the value changed
context
ParseContextthe context in which the value changed
oldRuleApplication
RuleApplicationthe 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
ParseContextthe parse context in which this operation is performed
contextElement
TSemanticElementthe element to which the value should be applied
oldValue
TReferencethe old value
newValue
TReferencethe 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
ParseContextruleApplication
RuleApplicationfragment
stringposition
ParsePosition
Returns
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
TSemanticElementthe element in the context of which the string is resolved
input
stringthe textual reference
context
ParseContextthe context in which the element is resolved
resolved
TReferencethe 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
ParseContextthe parse context in which this operation is performed
contextElement
TSemanticElementthe element to which the value should be unapplied
propertyValue
TReferencethe value to unapply