本文整理汇总了C#中ITreeNode.GetProject方法的典型用法代码示例。如果您正苦于以下问题:C# ITreeNode.GetProject方法的具体用法?C# ITreeNode.GetProject怎么用?C# ITreeNode.GetProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITreeNode
的用法示例。
在下文中一共展示了ITreeNode.GetProject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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)
{
//.........这里部分代码省略.........