本文整理汇总了C#中IReference.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# IReference.Resolve方法的具体用法?C# IReference.Resolve怎么用?C# IReference.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReference
的用法示例。
在下文中一共展示了IReference.Resolve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeCallShared
public void MakeCallShared(IReference reference)
{
var referenceExpression1 = reference.GetTreeNode() as IReferenceExpression;
if (referenceExpression1 == null || !reference.Resolve().Result.IsExtensionMethod()) return;
var byExpression = IndexExpressionNavigator.GetByExpression(referenceExpression1);
if (byExpression == null) return;
var substitution = reference.Resolve().Result.Substitution;
var referenceExpression2 = byExpression.Expression as IReferenceExpression;
if (referenceExpression2 == null) return;
var instance = VBElementFactory.GetInstance(referenceExpression1.GetPsiModule());
var vbExpression = referenceExpression2.QualifierExpression ?? instance.CreateExpression("me", new object[0]);
byExpression.AddArgumentAfter(instance.CreateArgument(vbExpression), null);
//byExpression.SetExpression(instance.CreateReferenceExpression(this.Executer.Method.ShortName, new object[0]));
//((IReferenceExpression)byExpression.Expression).Reference.BindTo((IDeclaredElement)this.Executer.Method);
//if (((IReferenceExpression)byExpression.Expression).Reference.BindTo((IDeclaredElement)this.Workflow.Method, substitution).CheckResolveResult() == ResolveErrorType.OK) return;
//this.Driver.AddConflict((IConflict)ReferenceConflict.CreateError(reference, "{0} can not be transformed correctly"));
}
示例2: ProcessUsage
public override MethodInvocation ProcessUsage(IReference reference)
{
var referenceExpression = reference.GetTreeNode() as IReferenceExpression;
if (referenceExpression == null)
{
Driver.AddConflict(ReferenceConflict.CreateError(reference, "{0} can not be updated correctly.", "Usage"));
return null;
}
bool isExtensionMethod = referenceExpression.IsExtensionMethod();
IInvocationExpression invocation = InvocationExpressionNavigator.GetByInvokedExpression(referenceExpression);
if (invocation == null)
{
Driver.AddConflict(ReferenceConflict.CreateError(reference, "{0} can not be updated correctly.", "Usage"));
return null;
}
ITreeNode element = GetArgument(invocation, isExtensionMethod);
var argument = element as ICSharpArgument;
IType type = argument != null ? GetTypeOfValue(argument.Value) : GetTypeOfValue(element);
if (type == null || !type.CanUseExplicitly(invocation))
{
Driver.AddConflict(ReferenceConflict.CreateError(
reference, "Arguemnt of {0} is not valid 'typeof' expression.", "usage"));
return null;
}
// we can rely on resolve result since method declaration is not yet changed.
ResolveResultWithInfo resolveResult = reference.Resolve();
ISubstitution substitution = resolveResult.Result.Substitution;
var method = resolveResult.DeclaredElement as IMethod;
if (method == null)
return null;
if (argument != null)
{
invocation.RemoveArgument(argument);
return new MethodInvocation(reference, type, method, substitution);
}
CSharpElementFactory factory = CSharpElementFactory.GetInstance(invocation.GetPsiModule());
IReferenceExpression newInvokedExpression =
invocation.InvokedExpression.ReplaceBy(factory.CreateReferenceExpression("$0", Executer.Method));
return new MethodInvocation(newInvokedExpression.Reference, type, method, substitution);
}
示例3: HighlightReference
protected virtual void HighlightReference(IElement element, IReference reference)
{
if (reference.ReferenceType == ReferenceType.TEXT
|| reference.ReferenceType == ReferenceType.REFERENCE_NAME
|| reference.ReferenceType == ReferenceType.LABEL)
{
ResolveResult resolveResult = reference.Resolve();
// TODO resolveResult.DeclaredElement == null [email protected] !!!
if (resolveResult.DeclaredElement != null)
{
DocumentRange range = reference.GetDocumentRange();
DocumentRange footerRange = XMLPSIUtils.GetFooterTagRange(element, range);
Highlight(range, resolveResult.DeclaredElement);
if (footerRange != DocumentRange.InvalidRange)
Highlight(footerRange, resolveResult.DeclaredElement);
}
}
}