Class ResolveRule<TSemanticElement, TReference>
Denotes the base class for a rule that resolves elements
public abstract class ResolveRule<TSemanticElement, TReference> : QuoteRule
Type Parameters
TSemanticElementTReference
- 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(RuleApplication, ParseContext, TSemanticElement, TReference, bool)
Applies the given value to the provided context element
protected abstract void Apply(RuleApplication ruleApplication, ParseContext context, TSemanticElement contextElement, TReference propertyValue, bool initial)
Parameters
ruleApplicationRuleApplicationthe rule application which should be applied
contextParseContextthe parse context in which this operation is performed
contextElementTSemanticElementthe element to which the value should be applied
propertyValueTReferencethe value to apply
initialboolA flag indicating whether the apply was called due to initial parse
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
referenceTReferencethe referenced element
semanticContextobjectthe semantic context
ruleApplicationRuleApplicationthe rule application for which to calculate the completion entry
positionParsePositionthe position of the request
contextParseContextthe parse context in which the completion is requested
Returns
CreateRuleApplication(RuleApplication, ParseContext, object)
Creates the rule application for this rule
protected override RuleApplication CreateRuleApplication(RuleApplication app, ParseContext context, object semanticElement = null)
Parameters
appRuleApplicationthe inner rule application
contextParseContextthe parse context
semanticElementobjectthe semantic element for which the rule application is created or null, if not yet known
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
contextElementobjectthe context element in which the element should be resolved
inputstringthe input string
contextParseContextthe 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
ruleApplicationRuleApplicationThe rule application context that is used to process the document.
documentParserThe document being parsed.
positionParsePositionThe 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
referenceTReferencethe referenced object
contextElementobjectthe semantic context element
contextParseContextthe 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
ruleApplicationRuleApplicationthe rule application to invalidate
contextParseContextthe parse context in which the rule application is invalidated
OnActivate(RuleApplication, ParseContext, bool)
Gets called when a rule application is activated
protected override void OnActivate(RuleApplication application, ParseContext context, bool initial)
Parameters
applicationRuleApplicationthe rule application that is activated
contextParseContextthe context in which the rule application is activated
initialboolflag indicating whether the activation happened due to initial parse
OnDeactivate(RuleApplication, ParseContext)
Gets called when a rule application is deactivated
protected override void OnDeactivate(RuleApplication application, ParseContext context)
Parameters
applicationRuleApplicationthe rule application that is deactivated
contextParseContextthe 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
applicationRuleApplicationthe rule application for which the value changed
contextParseContextthe context in which the value changed
oldRuleApplicationRuleApplicationthe old rule application
Returns
- bool
true, if the rule processed the value change, otherwise false (in which case the value change is propagated)
Replace(RuleApplication, ParseContext, TSemanticElement, TReference, TReference)
Replaces the provided old element with the provided new element
protected virtual void Replace(RuleApplication ruleApplication, ParseContext context, TSemanticElement contextElement, TReference oldValue, TReference newValue)
Parameters
ruleApplicationRuleApplicationthe rule application which should be applied
contextParseContextthe parse context in which this operation is performed
contextElementTSemanticElementthe element to which the value should be applied
oldValueTReferencethe old value
newValueTReferencethe 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
contextParseContextthe parse context
ruleApplicationRuleApplicationthe rule application for which a completion was queried
fragmentstringthe fragment available
positionParsePositionthe exact position
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
contextElementTSemanticElementthe element in the context of which the string is resolved
inputstringthe textual reference
contextParseContextthe context in which the element is resolved
resolvedTReferencethe resolved reference or the default
Returns
- bool
true, if the reference could be resolved, otherwise false
Unapply(RuleApplication, ParseContext, TSemanticElement, TReference)
Unapplies the given value to the provided context element
protected abstract void Unapply(RuleApplication ruleApplication, ParseContext context, TSemanticElement contextElement, TReference propertyValue)
Parameters
ruleApplicationRuleApplicationthe rule application which should be applied
contextParseContextthe parse context in which this operation is performed
contextElementTSemanticElementthe element to which the value should be unapplied
propertyValueTReferencethe value to unapply