本文整理汇总了C#中IReference.GetTreeNode方法的典型用法代码示例。如果您正苦于以下问题:C# IReference.GetTreeNode方法的具体用法?C# IReference.GetTreeNode怎么用?C# IReference.GetTreeNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReference
的用法示例。
在下文中一共展示了IReference.GetTreeNode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: MakeCallExtension
public void MakeCallExtension(IReference reference)
{
var treeNode = reference.GetTreeNode();
if (!treeNode.IsVB9Supported()) return;
var referenceExpression = treeNode as IReferenceExpression;
if (referenceExpression == null) return;
IIndexExpression byExpression = IndexExpressionNavigator.GetByExpression(referenceExpression);
if (byExpression == null) return;
IVBArgument vbArgument = null;
int index = 0;
using (var enumerator = byExpression.ArgumentList.Arguments.GetEnumerator()) {
while (enumerator.MoveNext()) {
var current = enumerator.Current;
var matchingParameter = current.GetMatchingParameter();
if (matchingParameter != null && matchingParameter.Element.IndexOf() == 0) {
vbArgument = current;
break;
}
++index;
}
}
if (vbArgument == null) return;
IVBExpression vbExpression = null;
var expressionArgument = vbArgument as IExpressionArgument;
if (expressionArgument != null)
vbExpression = expressionArgument.Expression;
if (vbExpression == null) return;
var indexExpression1 =
(IIndexExpression) VBElementFactory.GetInstance(treeNode.GetPsiModule())
.CreateExpression("$0." + reference.GetName() + "()", new object[] { vbExpression });
indexExpression1.SetArgumentList(byExpression.ArgumentList);
indexExpression1.RemoveArgument(indexExpression1.Arguments[index]);
byExpression.ReplaceBy(indexExpression1);
}
示例3: 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"));
}
示例4: ProcessParameterReference
public override void ProcessParameterReference(IReference reference)
{
Driver.AddConflict(new UnsupportedLanguageConflict(reference.GetTreeNode(), "parameter usage",
ConflictSeverity.Error));
}
示例5: ProcessUsage
public override MethodInvocation ProcessUsage(IReference reference)
{
// when something goes wrong just add conflict
Driver.AddConflict(new UnsupportedLanguageConflict(reference.GetTreeNode(), "usage", ConflictSeverity.Error));
return null;
}