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


C# LanguageElement.GetDeclaration方法代码示例

本文整理汇总了C#中LanguageElement.GetDeclaration方法的典型用法代码示例。如果您正苦于以下问题:C# LanguageElement.GetDeclaration方法的具体用法?C# LanguageElement.GetDeclaration怎么用?C# LanguageElement.GetDeclaration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LanguageElement的用法示例。


在下文中一共展示了LanguageElement.GetDeclaration方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsMethodCall

        private bool IsMethodCall(LanguageElement Item)
        {
            if (Item is MethodCall)
            {
                // Calls which discard any returned value.
                return true;
            }
            if (Item is MethodCallExpression)
            {
                // Method calls which are themselves passed to other methods.
                return true;
            }
            // C# requires parenthesis for it's method calls. This makes identifying method calls very easy.
            // Other languages (VB.Net for example) do not share this requirement.
            // References to Methods and Variables end up looking exactly the same to the parser.
            // ElementReferenceExpressions may potentially refer to Methods.
            if (!(Item is ElementReferenceExpression))
                return false;

            // This forces us to locate the declaration of the item the reference points at.
            // Once there we can confirm if the Item in question is a Method.
            if (!(Item.GetDeclaration() is IMethodElement))
                return false;

            // Finally we need to confirm that the method reference is in fact a call.
            // We do this by eliminating the other purpose of a method reference: That of a Method pointer.
            // No parent AddressOf operator. Therefore not a method pointer.
            if (!(Item.Parent is AddressOfExpression))
                return true;
            return false;
        }
开发者ID:RoryBecker,项目名称:CodeRushPluginExamples,代码行数:31,代码来源:PlugIn1.cs

示例2: IsValidSelection

        protected override bool IsValidSelection(LanguageElement element, TextViewSelection selection)
        {
            if ((element == null) || (selection == null))
                return false;
            if (selection.Exists)
                return false;
            var creationExpression = element.Parent as ObjectCreationExpression;

            return creationExpression != null && element.GetDeclaration() == null;
        }
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:10,代码来源:DeclareClassInSpecificProject.cs

示例3: GetElementDeclaration

    private static IElement GetElementDeclaration(LanguageElement element)
    {
      IElement declaration;

      if (elementIsReference(element.ElementType))
        declaration = element.GetDeclaration();
      else
        declaration = element;

      if (declaration != null && elementTypeIsSupported(declaration.ElementType))
        return declaration;

      return null;
    }
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:14,代码来源:NavigateToDefinition.cs

示例4: IsValidReferenceAndQualifier

    private bool IsValidReferenceAndQualifier(LanguageElement activeRerence, out ITypeElement callerType, out Expression qualifier)
    {
      qualifier = null;
      callerType = null;
      if (!(activeRerence is IHasQualifier))
        return false;

      // should be undeclared....
      IElement declaration = activeRerence.GetDeclaration(false);
      if (declaration != null)
        return false;


      qualifier = (activeRerence as IHasQualifier).Qualifier;
      if (qualifier is MethodReferenceExpression)
        qualifier = (qualifier as MethodReferenceExpression).Qualifier;
      if (qualifier == null)
        return false;

      callerType = qualifier.Resolve(ParserServices.SourceTreeResolver) as ITypeElement;
      if (callerType == null)
        return false;

      return true;
    }
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:25,代码来源:PlugIn1.cs

示例5: IsClass

 /// <summary>
 /// Is class
 /// </summary>
 private static bool IsClass(LanguageElement element)
 {
     IElement declaration = element.GetDeclaration();
     return (declaration as IClassElement) != null;
 } // IsClass
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:8,代码来源:EasyGotoPlugIn.cs

示例6: GetValidDeclaration

    private static IWithParameters GetValidDeclaration(LanguageElement originalCall)
    {
      if (originalCall == null)
        return null;

      IElement declaration = originalCall.GetDeclaration(false);
      if (declaration is IMethodElement)
        return declaration as IWithParameters;
      IEventElement eventElement = declaration as IEventElement;
      if (eventElement != null && eventElement.Type != null)
      {
        return eventElement.Type.Resolve(ParserServices.SourceTreeResolver) as IWithParameters;
      }
      return null;
    }
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:15,代码来源:NamedParametersPlugIn.cs

示例7: GetTypeDeclarationForElement

 private TypeDeclaration GetTypeDeclarationForElement(LanguageElement element)
 {
     return element.GetDeclaration() as TypeDeclaration;
 }
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:4,代码来源:MoveTypeToFileInSpecificProjectPlugin.cs


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