当前位置: 首页>>代码示例>>C#>>正文


C# ITreeNode.GetContainingNode方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:vitrilo,项目名称:ReSharper.ReTS,代码行数:18,代码来源:ReJsHighlightingStageProcess.cs

示例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>();
    }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:41,代码来源:CreatePsiRuleTarget.cs

示例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)
      {
//.........这里部分代码省略.........
开发者ID:JakobChristensen,项目名称:Resharper.CodeAnnotations,代码行数:101,代码来源:CodeAnnotation.cs


注:本文中的ITreeNode.GetContainingNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。