本文整理汇总了C#中ITreeNode.GetContainingNode方法的典型用法代码示例。如果您正苦于以下问题:C# ITreeNode.GetContainingNode方法的具体用法?C# ITreeNode.GetContainingNode怎么用?C# ITreeNode.GetContainingNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITreeNode
的用法示例。
在下文中一共展示了ITreeNode.GetContainingNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitLoop
private void VisitLoop(ITreeNode loop, IHighlightingConsumer consumer)
{
var function = loop.GetContainingNode<IJsFunctionLike>();
var accessAnalizer = new VariableCollector();
loop.ProcessThisAndDescendants(accessAnalizer);
var accessToExternalModifiedClosure = accessAnalizer.Variables
.GroupBy(r => r.DeclaredElement)
.Select(g => g.ToArray())
.Where(l => HasExternallyModifiedClosure(function, l))
.SelectMany(l => l)
.Where(r => r.FunctionLike != function)
.Select(info => info.Node);
foreach (var expression in accessToExternalModifiedClosure)
{
consumer.AddHighlighting(new AccessToModifiedClosureWarning(expression), expression.GetHighlightingRange(), File);
}
}
示例2: CreatePsiRuleTarget
public CreatePsiRuleTarget(PsiRuleReference reference)
{
myReference = reference;
myElement = reference.GetTreeNode();
string name = reference.GetName();
var node = myElement.NextSibling;
while (node != null)
{
if (!node.IsWhitespaceToken())
{
if (!(node is IRuleParameters))
{
break;
}
var child = node.FirstChild;
while (child != null)
{
if (!child.IsWhitespaceToken())
{
if (child is IRuleBraceParameters)
{
myHasBraceParameters = true;
}
if (child is IRuleBracketParameters)
{
CollectVariableParameters(child as IRuleBracketParameters);
}
}
child = child.NextSibling;
}
break;
}
node = node.NextSibling;
}
myDeclaration = PsiElementFactory.GetInstance(myElement.GetPsiModule()).CreateRuleDeclaration(name, myHasBraceParameters, myVariableParameters);
Anchor = myElement.GetContainingNode<IRuleDeclaration>();
}
示例3: GetNullReferenceState
/// <summary>
/// Gets the state of the expression null reference.
/// </summary>
/// <param name="treeNode">The element.</param>
/// <param name="declaredElement">The declared element.</param>
/// <param name="statement">The statement.</param>
/// <returns>Returns the expression null reference state.</returns>
private CodeAnnotationAttribute GetNullReferenceState(ITreeNode treeNode, IDeclaredElement declaredElement, IDeclarationStatement statement)
{
var project = treeNode.GetProject();
if (project == null)
{
return CodeAnnotationAttribute.Undefined;
}
var projectFile = project.ProjectFile;
if (projectFile == null)
{
return CodeAnnotationAttribute.Undefined;
}
var functionDeclaration = treeNode.GetContainingNode<ICSharpFunctionDeclaration>(true);
if (functionDeclaration == null)
{
return CodeAnnotationAttribute.Undefined;
}
var builder = new CSharpControlFlowBuilder();
var graf = builder.GraphFromNode(functionDeclaration, null, true) as ICSharpControlFlowGraph;
if (graf == null)
{
return CodeAnnotationAttribute.Undefined;
}
var inspect = graf.Inspect(ValueAnalysisMode.OPTIMISTIC);
var position = this.FindPosition(graf.BodyElement.Children, statement);
if (position == null)
{
return CodeAnnotationAttribute.Undefined;
}
position = this.FindFollowing(position);
if (position == null)
{
return CodeAnnotationAttribute.Undefined;
}
var result = inspect.GetVariableStateAt(position, declaredElement);
switch (result)
{
case CSharpControlFlowNullReferenceState.NOT_NULL:
return CodeAnnotationAttribute.NotNull;
case CSharpControlFlowNullReferenceState.NULL:
return CodeAnnotationAttribute.CanBeNull;
case CSharpControlFlowNullReferenceState.MAY_BE_NULL:
return CodeAnnotationAttribute.CanBeNull;
}
return CodeAnnotationAttribute.Undefined;
/*
var block = treeNode.GetContainingNode<IBlock>(true);
if (block == null)
{
return CodeAnnotationAttribute.Undefined;
}
var project = treeNode.GetProject();
if (project == null)
{
return CodeAnnotationAttribute.Undefined;
}
var projectFile = project.ProjectFile;
if (projectFile == null)
{
return CodeAnnotationAttribute.Undefined;
}
var factory = CSharpElementFactory.GetInstance(treeNode.GetPsiModule());
var statement = factory.CreateStatement("if(" + name + " == null) { }");
var ifStatement = block.AddStatementAfter(statement, (ICSharpStatement)anchorStatement) as IIfStatement;
if (ifStatement == null)
{
return CodeAnnotationAttribute.Undefined;
}
var equalityExpression = ifStatement.Condition as IEqualityExpression;
if (equalityExpression == null)
{
return CodeAnnotationAttribute.Undefined;
}
var referenceExpression = equalityExpression.LeftOperand as IReferenceExpression;
if (referenceExpression == null)
{
//.........这里部分代码省略.........