本文整理汇总了C#中IDeclaredElement类的典型用法代码示例。如果您正苦于以下问题:C# IDeclaredElement类的具体用法?C# IDeclaredElement怎么用?C# IDeclaredElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDeclaredElement类属于命名空间,在下文中一共展示了IDeclaredElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHighlightAttributeForReference
protected override string GetHighlightAttributeForReference(IDeclaredElement element)
{
if (element is IDatabaseObjectDeclaredElement)
return HighlightingAttributeIds.CONSTANT_IDENTIFIER_ATTRIBUTE;
else
return null;
}
示例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;
}
示例3: GetHighlightAttributeForReference
protected override string GetHighlightAttributeForReference(IDeclaredElement element)
{
if (element is ModuleDeclaredElement)
return HighlightingAttributeIds.NAMESPACE_IDENTIFIER_ATTRIBUTE;
else
return null;
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例12: GetDeclaredElementSearchDomain
public ISearchDomain GetDeclaredElementSearchDomain(IDeclaredElement declaredElement)
{
if (declaredElement is NitraDeclaredElement)
return mySearchDomainFactory.CreateSearchDomain(declaredElement.GetSolution(), false);
return EmptySearchDomain.Instance;
}
示例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());
}
示例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());
}
示例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;
}