• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IDeclaredElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IDeclaredElement的典型用法代码示例。如果您正苦于以下问题:C# IDeclaredElement类的具体用法?C# IDeclaredElement怎么用?C# IDeclaredElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IDeclaredElement类属于命名空间,在下文中一共展示了IDeclaredElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetHighlightAttributeForReference

 protected override string GetHighlightAttributeForReference(IDeclaredElement element)
 {
     if (element is IDatabaseObjectDeclaredElement)
         return HighlightingAttributeIds.CONSTANT_IDENTIFIER_ATTRIBUTE;
     else
         return null;
 }
开发者ID:willrawls,项目名称:arp,代码行数:7,代码来源:DatabaseObjectsReferenceProcessor.cs


示例2: Wrap

        /// <summary>
        /// Obtains a reflection wrapper for a declared element.
        /// </summary>
        /// <param name="target">The element, or null if none.</param>
        /// <returns>The reflection wrapper, or null if none.</returns>
        public ICodeElementInfo Wrap(IDeclaredElement target)
        {
            if (target == null)
                return null;

            ITypeElement typeElement = target as ITypeElement;
            if (typeElement != null)
                return Wrap(typeElement);

            IFunction function = target as IFunction;
            if (function != null)
                return Wrap(function);

            IProperty property = target as IProperty;
            if (property != null)
                return Wrap(property);

            IField field = target as IField;
            if (field != null)
                return Wrap(field);

            IEvent @event = target as IEvent;
            if (@event != null)
                return Wrap(@event);

            IParameter parameter = target as IParameter;
            if (parameter != null)
                return Wrap(parameter);

            INamespace @namespace = target as INamespace;
            if (@namespace != null)
                return Reflector.WrapNamespace(@namespace.QualifiedName);

            return null;
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:40,代码来源:PsiReflectionPolicy6.cs


示例3: GetHighlightAttributeForReference

 protected override string GetHighlightAttributeForReference(IDeclaredElement element)
 {
     if (element is ModuleDeclaredElement)
         return HighlightingAttributeIds.NAMESPACE_IDENTIFIER_ATTRIBUTE;
     else
         return null;
 }
开发者ID:willrawls,项目名称:arp,代码行数:7,代码来源:ModulereferenceProcessor.cs


示例4: CanBeAnnotated

        protected override bool CanBeAnnotated(IDeclaredElement declaredElement, ITreeNode context, IPsiModule module)
        {
            var method = declaredElement as IMethod;
            if (method != null && IsAvailableForType(method.ReturnType, context))
            {
                return true;
            }

            var parameter = declaredElement as IParameter;
            if (parameter != null && IsAvailableForType(parameter.Type, context))
            {
                return true;
            }

            var property = declaredElement as IProperty;
            if (property != null && IsAvailableForType(property.Type, context))
            {
                return true;
            }

            var delegateType = declaredElement as IDelegate;
            if (delegateType != null && IsAvailableForType(delegateType.InvokeMethod.ReturnType, context))
            {
                return true;
            }

            var field = declaredElement as IField;
            if (field != null && IsAvailableForType(field.Type, context))
            {
                return true;
            }

            return false;
        }
开发者ID:prodot,项目名称:ReCommended-Extension,代码行数:34,代码来源:AnnotateWithItemNotNull.cs


示例5: CreateBehavior

        public BehaviorElement CreateBehavior(IDeclaredElement field)
        {
            var clazz = ((ITypeMember)field).GetContainingType() as IClass;
            if (clazz == null)
            {
                return null;
            }

            var context = this._cache.TryGetContext(clazz);
            if (context == null)
            {
                return null;
            }

            var fieldType = new NormalizedTypeName(field as ITypeOwner);

            var behavior = this.GetOrCreateBehavior(context,
                                               clazz.GetClrName(),
                                               field.ShortName,
                                               field.IsIgnored(),
                                               fieldType);

            foreach (var child in behavior.Children)
            {
                child.State = UnitTestElementState.Pending;
            }

            this._cache.AddBehavior(field, behavior);
            return behavior;
        }
开发者ID:JAllman,项目名称:machine.specifications.runner.resharper,代码行数:30,代码来源:BehaviorFactory.cs


示例6: FromDeclaredElement

        public static MemberWithAccess FromDeclaredElement(IDeclaredElement declaredElement)
        {
            Contract.Requires(declaredElement != null);

            var clrDeclaredElement = declaredElement as IClrDeclaredElement;
            if (clrDeclaredElement == null)
                return null;

            var accessRightsOwner = declaredElement as IAccessRightsOwner;
            if (accessRightsOwner == null)
                return null;


            var declaringTypeAccessRights = declaredElement.GetDeclarations()
                .FirstOrDefault()
                .With(x => x.GetContainingNode<IClassLikeDeclaration>())
                .With(x => (AccessRights?)x.GetAccessRights());

            if (declaringTypeAccessRights == null)
                return null;

            return new MemberWithAccess(clrDeclaredElement, declaringTypeAccessRights.Value,
                GetMemberType(declaredElement), 
                accessRightsOwner.GetAccessRights());
        }
开发者ID:remyblok,项目名称:ReSharperContractExtensions,代码行数:25,代码来源:MemberWithAccess.cs


示例7: GetPrimaryDeclaredElement

    public IDeclaredElement GetPrimaryDeclaredElement(IDeclaredElement declaredElement, IReference reference)
    {
      IDeclaredElement derivedElement = null;

      var method = declaredElement as IMethod;
      if (method != null)
      {
        derivedElement = DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForMethod(method);
      }


      var @class = declaredElement as IClass;
      if (@class != null)
        derivedElement = DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForClass(@class);

      var @interface = declaredElement as IInterface;
      if (@interface != null)
        derivedElement = DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForInterface(@interface);

      if(derivedElement != null)
      {
        return derivedElement;
      }
      return declaredElement;
    }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:25,代码来源:PsiPrimaryDeclaredElementForRenameProvider.cs


示例8: FindElement

        public Element FindElement(IDeclaredElement declared)
        {
            ITypeElement type = declared.GetTypeElement();
            if (type != null)
            {
                var assemblyFile = type.GetAssemblyFile();

                if (assemblyFile != null)
                {
                    return new Element(assemblyFile, type.CLRName, "");
                }
            }

            var member = declared.GetTypeMember();

            if (member != null)
            {
                var file = member.GetAssemblyFile();

                if (file != null)
                {
                    return new Element(
                        file,
                        member.GetContainingType().CLRName,
                        member.ShortName
                        );

                }
            }

            return Element.NotFound;
        }
开发者ID:ArildF,项目名称:RogueSharper,代码行数:32,代码来源:ElementFinder.cs


示例9: GetElementDescription

        public RichTextBlock GetElementDescription(IDeclaredElement element, DeclaredElementDescriptionStyle style,
            PsiLanguageType language, IPsiModule module = null)
        {
            if (!element.IsFromUnityProject())
                return null;

            var method = element as IMethod;
            if (method != null)
            {
                var eventFunction = myUnityApi.GetUnityEventFunction(method);
                if (eventFunction?.Description != null)
                    return new RichTextBlock(eventFunction.Description);
            }

            var parameter = element as IParameter;
            var owner = parameter?.ContainingParametersOwner as IMethod;
            if (owner != null)
            {
                var eventFunction = myUnityApi.GetUnityEventFunction(owner);
                var eventFunctionParameter = eventFunction?.GetParameter(parameter.ShortName);
                if (eventFunctionParameter?.Description != null)
                    return new RichTextBlock(eventFunctionParameter.Description);
            }

            return null;
        }
开发者ID:JetBrains,项目名称:resharper-unity,代码行数:26,代码来源:UnityEventFunctionDescriptionProvider.cs


示例10: GetElementDescription

        // This is the ReSharper 8.1 version
        public RichTextBlock GetElementDescription(IDeclaredElement element, DeclaredElementDescriptionStyle style,
                                                   PsiLanguageType language, IPsiModule module)
        {
            var attribute = element as IHtmlAttributeDeclaredElement;
            if (attribute == null)
                return null;

            var attributeDescription = GetAttributeDescription(attribute.ShortName);

            var block = new RichTextBlock();
            var typeDescription = new RichText(htmlDescriptionsCache.GetDescriptionForHtmlValueType(attribute.ValueType));
            if (style.IntendedDescriptionPlacement == DescriptionPlacement.AFTER_NAME &&
                (style.ShowSummary || style.ShowFullDescription))
                block.SplitAndAdd(typeDescription);

            string description = null;
            if (style.ShowSummary && attributeDescription != null)
                description = attributeDescription.Summary;
            else if (style.ShowFullDescription && attributeDescription != null)
                description = attributeDescription.Description;

            if (!string.IsNullOrEmpty(description))
                block.SplitAndAdd(description);

            if (style.IntendedDescriptionPlacement == DescriptionPlacement.ON_THE_NEW_LINE &&
                (style.ShowSummary || style.ShowFullDescription))
            {
                // TODO: Perhaps we should show Value: Expression for attributes that take an Angular expression, etc
                typeDescription.Prepend("Value: ");
                block.SplitAndAdd(typeDescription);
            }

            return block;
        }
开发者ID:jv9,项目名称:resharper-angularjs,代码行数:35,代码来源:AngularJsHtmlElementDescriptionProvider.cs


示例11: CreateBehavior

    public BehaviorElement CreateBehavior(IDeclaredElement field)
    {
      IClass clazz = ((ITypeMember)field).GetContainingType() as IClass;
      if (clazz == null)
      {
        return null;
      }

      ContextElement context;
      _cache.Classes.TryGetValue(clazz, out context);
      if (context == null)
      {
        return null;
      }

      string fullyQualifiedTypeName = null;
      if (field is ITypeOwner)
      {
          // Work around the difference in how the MetaData API and Psi API return different type strings for generics.
          TypeNameCache.TryGetValue(GetFirstGenericNormalizedTypeName(field), out fullyQualifiedTypeName);
      }

      return GetOrCreateBehavior(_provider,
#if RESHARPER_61
                                 _manager, _psiModuleManager, _cacheManager, 
#endif
                                 _project,
                                 _projectEnvoy,
                                 context,
                                 clazz.GetClrName(),
                                 field.ShortName,
                                 field.IsIgnored(),
                                 fullyQualifiedTypeName);
    }
开发者ID:kropp,项目名称:machine.specifications,代码行数:34,代码来源:BehaviorFactory.cs


示例12: GetDeclaredElementSearchDomain

        public ISearchDomain GetDeclaredElementSearchDomain(IDeclaredElement declaredElement)
        {
            if (declaredElement is NitraDeclaredElement)
            return mySearchDomainFactory.CreateSearchDomain(declaredElement.GetSolution(), false);

              return EmptySearchDomain.Instance;
        }
开发者ID:hwwang,项目名称:Nitra,代码行数:7,代码来源:NitraSearcherFactory.cs


示例13: CreateContextSpecification

    public ContextSpecificationElement CreateContextSpecification(IDeclaredElement field)
    {
#if RESHARPER_6
      IClass clazz = ((ITypeMember)field).GetContainingType() as IClass;
#else
      IClass clazz = field.GetContainingType() as IClass;
#endif
      if (clazz == null)
      {
        return null;
      }

      ContextElement context;
      _cache.Classes.TryGetValue(clazz, out context);
      if (context == null)
      {
        return null;
      }

      return GetOrCreateContextSpecification(_provider,
                                             _project,
                                             context,
                                             _projectEnvoy,
#if RESHARPER_6
                                             clazz.GetClrName().FullName,
#else
                                             clazz.CLRName,
#endif
                                             field.ShortName,
                                             clazz.GetTags(),
                                             field.IsIgnored());
    }
开发者ID:ChrisEdwards,项目名称:machine.specifications,代码行数:32,代码来源:ContextSpecificationFactory.cs


示例14: CreateContextSpecification

    public ContextSpecificationElement CreateContextSpecification(IDeclaredElement field)
    {
      var clazz = ((ITypeMember) field).GetContainingType() as IClass;
      if (clazz == null)
      {
        return null;
      }

      ContextElement context;
      _cache.Contexts.TryGetValue(clazz, out context);
      if (context == null)
      {
        return null;
      }

      return GetOrCreateContextSpecification(_provider,
                                             _manager,
                                             _psiModuleManager,
                                             _cacheManager,
                                             _project,
                                             context,
                                             _projectEnvoy,
                                             clazz.GetClrName().GetPersistent(),
                                             field.ShortName,
                                             field.IsIgnored());
    }
开发者ID:AnthonyMastrean,项目名称:machine.specifications,代码行数:26,代码来源:ContextSpecificationFactory.cs


示例15: IsCollectionInitializerAddMethod

    /// <summary>
    ///   Check if the member is visible as C# type member I.e. it skips accessors except to properties with parameters
    /// </summary>
    public static bool IsCollectionInitializerAddMethod(IDeclaredElement declaredElement)
    {
      var method = declaredElement as IMethod;
      if (method == null)
      {
        return false;
      }
      if (method.IsStatic)
      {
        return false;
      }
      if (method.ShortName != "Add")
      {
        return false;
      }

      ITypeElement containingType = method.GetContainingType();
      if (containingType == null)
      {
        return false;
      }

      if (method.Parameters.Any(parameter => parameter.Kind != ParameterKind.VALUE))
      {
        return false;
      }

      if (!containingType.IsDescendantOf(method.Module.GetPredefinedType().IEnumerable.GetTypeElement()))
      {
        return false;
      }

      return true;
    }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:37,代码来源:PsiDeclaredElementElementUtil.cs


示例16: GetImageId

 public IconId GetImageId(IDeclaredElement declaredElement, PsiLanguageType languageType, out bool canApplyExtensions)
 {
     canApplyExtensions = false;
     if (declaredElement is IAngularJsDeclaredElement)
         return LogoThemedIcons.Angularjs.Id;
     return null;
 }
开发者ID:redoz,项目名称:resharper-angularjs,代码行数:7,代码来源:AngularJsDeclaredElementIconProvider.cs


示例17: CreateAtomicRenames

 public override IEnumerable<AtomicRenameBase> CreateAtomicRenames(IDeclaredElement declaredElement, string newName, bool doNotAddBindingConflicts)
 {
   yield return new PsiAtomicRename(declaredElement, newName, doNotAddBindingConflicts);
   if (declaredElement is RuleDeclaration)
   {
     var ruleDeclaration = declaredElement as RuleDeclaration;
     ruleDeclaration.UpdateDerivedDeclaredElements();
     foreach (IDeclaredElement element in ruleDeclaration.DerivedParserMethods)
     {
       yield return new PsiDerivedElementRename(element, "parse" + NameToCamelCase(newName),
         doNotAddBindingConflicts);
     }
     foreach (IDeclaredElement element in ruleDeclaration.DerivedClasses)
     {
       yield return new PsiDerivedElementRename(element, NameToCamelCase(newName),
         doNotAddBindingConflicts);
     }
     foreach (IDeclaredElement element in ruleDeclaration.DerivedInterfaces)
     {
       yield return new PsiDerivedElementRename(element, ruleDeclaration.InterfacePrefix + NameToCamelCase(newName),
         doNotAddBindingConflicts);
     }
     foreach (IDeclaredElement element in ruleDeclaration.DerivedVisitorMethods)
     {
       yield return new PsiDerivedElementRename(element, ruleDeclaration.VisitorMethodPrefix + NameToCamelCase(newName) + ruleDeclaration.VisitorMethodSuffix,
         doNotAddBindingConflicts);
     }
   }
 }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:29,代码来源:PsiRenamesFactory.cs


示例18: Format

    /// <summary>
    /// Returns a string containing declared element text presentation made according to this presenter settings.
    ///              This method is usefull when additional processing is required for the returned string,
    ///              e.g. as is done in the following method:
    ///              
    /// <code>
    ///              RichText Foo(IMethod method)
    ///              {
    ///                DeclaredElementPresenterMarking marking;
    ///                RichTextParameters rtp = new RichTextParameters(ourFont);
    ///                // make rich text with declared element presentation
    ///                RichText result = new RichText(ourInvocableFormatter.Format(method, out marking),rtp);
    ///                // highlight name of declared element in rich text
    ///                result.SetColors(SystemColors.HighlightText,SystemColors.Info,marking.NameRange.StartOffset,marking.NameRange.EndOffset);
    ///                return result;
    ///              }
    ///              </code>
    /// </summary>
    /// <param name="style">The style.</param>
    /// <param name="element">Contains <see cref="T:JetBrains.ReSharper.Psi.IDeclaredElement" /> to provide string presentation of.</param>
    /// <param name="substitution">The substitution.</param>
    /// <param name="marking">Returns the markup of the string with a <see cref="T:JetBrains.ReSharper.Psi.IDeclaredElement" /> presentation.</param>
    /// <returns>System.String.</returns>
    public string Format(DeclaredElementPresenterStyle style, IDeclaredElement element, ISubstitution substitution, out DeclaredElementPresenterMarking marking)
    {
      marking = new DeclaredElementPresenterMarking();

      var itemDeclaredElement = (IItemDeclaredElement)element;
      var sb = new StringBuilder();
      
      if (style.ShowEntityKind != EntityKindForm.NONE)
      {
        marking.EntityKindRange = AppendString(sb, style.ShowEntityKind == EntityKindForm.NORMAL_IN_BRACKETS ? "[Item] " : "Item ");
      }
      
      if (style.ShowName != NameStyle.NONE)
      {
        if (style.ShowNameInQuotes)
        {
          sb.Append('"');
        }

        marking.NameRange = style.ShowName == NameStyle.SHORT || style.ShowName == NameStyle.SHORT_RAW ? AppendString(sb, itemDeclaredElement.ShortName) : AppendString(sb, itemDeclaredElement.ItemName);
        if (style.ShowNameInQuotes)
        {
          sb.Append('"');
        }
      }
      
      return sb.ToString();
    }
开发者ID:JakobChristensen,项目名称:Sitecore.Rocks.Resharper,代码行数:51,代码来源:ItemDeclaredElementPresenter.cs


示例19: IsEqualGeneric

        private bool IsEqualGeneric(IDeclaredElement element)
        {
            var topLevelTypeElement = DeclaredElementUtil.GetTopLevelTypeElement(element as IClrDeclaredElement);
            var elementSuperTypes = TypeElementUtil.GetAllSuperTypesReversed(topLevelTypeElement);
            var elementSuperTypeParams = GetTypeParametersFromTypes(elementSuperTypes).Where(x => x.Any());

            return new GenericSequenceEqualityComparer().Equals(elementSuperTypeParams.First(), _originTypeParams);
        }
开发者ID:jcdekoning,项目名称:Teapot,代码行数:8,代码来源:SearchGenericImplementationsRequest.cs


示例20: CanBeAnnotated

        protected override bool CanBeAnnotated(IDeclaredElement declaredElement, ITreeNode context, IPsiModule module)
        {
            var method = declaredElement as IMethod;

            return method != null &&
                   (!method.ReturnType.IsVoid() || method.Parameters.Any(parameter => parameter.AssertNotNull().Kind == ParameterKind.OUTPUT)) &&
                   method.Parameters.All(parameter => parameter.AssertNotNull().Kind != ParameterKind.REFERENCE);
        }
开发者ID:prodot,项目名称:ReCommended-Extension,代码行数:8,代码来源:AnnotateWithPure.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IDecoder类代码示例发布时间:2022-05-24
下一篇:
C# IDeclaration类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap