本文整理汇总了Java中consulo.dotnet.psi.DotNetAttribute类的典型用法代码示例。如果您正苦于以下问题:Java DotNetAttribute类的具体用法?Java DotNetAttribute怎么用?Java DotNetAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DotNetAttribute类属于consulo.dotnet.psi包,在下文中一共展示了DotNetAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compute
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@Nullable
@Override
@RequiredReadAction
protected ClassSignature compute()
{
DotNetAttribute attribute = DotNetAttributeUtil.findAttribute(myTypeDeclaration, IKvmAttributes.SignatureAttribute);
if(attribute instanceof MsilCustomAttribute)
{
MsilCustomAttributeArgumentList customAttributeArgumentList = MsilCustomAttributeStubber.build((MsilCustomAttribute) attribute);
List<MsiCustomAttributeValue> constructorArguments = customAttributeArgumentList.getConstructorArguments();
if(constructorArguments.size() != 1)
{
return null;
}
Object value = constructorArguments.get(0).getValue();
if(!(value instanceof String))
{
return null;
}
return new ClassSignature((String) value);
}
return null;
}
示例2: getAttributes
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@RequiredReadAction
@NotNull
@Override
public DotNetAttribute[] getAttributes()
{
DotNetAttributeList[] attributeLists = getAttributeLists();
if(attributeLists.length == 0)
{
return DotNetAttribute.EMPTY_ARRAY;
}
List<DotNetAttribute> attributes = new ArrayList<>();
for(DotNetAttributeList attributeList : attributeLists)
{
Collections.addAll(attributes, attributeList.getAttributes());
}
return attributes.isEmpty() ? DotNetAttribute.EMPTY_ARRAY : attributes.toArray(new DotNetAttribute[attributes.size()]);
}
示例3: getAttributes
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@NotNull
@Override
public DotNetAttribute[] getAttributes()
{
DotNetAttributeList[] attributeLists = getAttributeLists();
if(attributeLists.length == 0)
{
return DotNetAttribute.EMPTY_ARRAY;
}
List<DotNetAttribute> attributes = new ArrayList<>();
for(DotNetAttributeList attributeList : attributeLists)
{
Collections.addAll(attributes, attributeList.getAttributes());
}
return attributes.isEmpty() ? DotNetAttribute.EMPTY_ARRAY : attributes.toArray(new DotNetAttribute[attributes.size()]);
}
示例4: process
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@RequiredReadAction
private static void process(@NotNull ProblemsHolder holder, @Nullable PsiElement range, @NotNull PsiElement target)
{
if(range == null)
{
return;
}
// #hasAttribute() is cache result, #findAttribute() not
if(DotNetAttributeUtil.hasAttribute(target, DotNetTypes.System.ObsoleteAttribute))
{
DotNetAttribute attribute = DotNetAttributeUtil.findAttribute(target, DotNetTypes.System.ObsoleteAttribute);
if(attribute == null)
{
return;
}
String message = getMessage(attribute);
if(message == null)
{
message = CSharpInspectionBundle.message("target.is.obsolete", CSharpElementTreeNode.getPresentableText((PsiNamedElement) target));
}
holder.registerProblem(range, message, ProblemHighlightType.LIKE_DEPRECATED);
}
}
示例5: getAttributes
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@RequiredReadAction
@NotNull
@Override
public DotNetAttribute[] getAttributes()
{
DotNetModifierList modifierList = getModifierList();
if(modifierList != null)
{
return modifierList.getAttributes();
}
return DotNetAttribute.EMPTY_ARRAY;
}
示例6: getAttributes
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@RequiredReadAction
@NotNull
@Override
public DotNetAttribute[] getAttributes()
{
return DotNetAttribute.EMPTY_ARRAY;
}
示例7: hasAttribute
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@RequiredReadAction
private static boolean hasAttribute(DotNetModifierList modifierList, String qName)
{
for(DotNetAttribute attribute : modifierList.getAttributes())
{
DotNetTypeDeclaration typeDeclaration = attribute.resolveToType();
if(typeDeclaration != null && Comparing.equal(typeDeclaration.getPresentableQName(), qName))
{
return true;
}
}
return false;
}
示例8: addAdditionalAttribute
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
public void addAdditionalAttribute(@NotNull DotNetAttribute attribute)
{
if(myAdditionalAttributes.isEmpty())
{
myAdditionalAttributes = new ArrayList<>(5);
}
myAdditionalAttributes.add(attribute);
}
示例9: getAttributes
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@RequiredReadAction
@NotNull
@Override
public DotNetAttribute[] getAttributes()
{
DotNetAttribute[] oldAttributes = myModifierList.getAttributes();
List<DotNetAttribute> attributes = new ArrayList<>(oldAttributes.length + myAdditionalAttributes.size());
for(DotNetAttribute oldAttribute : oldAttributes)
{
DotNetTypeDeclaration resolvedType = oldAttribute.resolveToType();
if(resolvedType != null && ArrayUtil.contains(resolvedType.getVmQName(), ourAttributeBans))
{
continue;
}
attributes.add(oldAttribute);
}
attributes.addAll(myAdditionalAttributes);
ExternalAttributeHolder holder = myAttributeHolderValue.getValue();
if(holder != null)
{
List<ExternalAttributeNode> nodes = findAttributes(holder);
for(ExternalAttributeNode node : nodes)
{
CSharpLightAttributeWithSelfTypeBuilder builder = new CSharpLightAttributeWithSelfTypeBuilder(myModifierList, node.getName());
for(ExternalAttributeArgumentNode argumentNode : node.getArguments())
{
builder.addParameterExpression(argumentNode.toJavaObject());
}
attributes.add(builder);
}
}
return attributes.toArray(new DotNetAttribute[attributes.size()]);
}
示例10: getAttributes
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@RequiredReadAction
@NotNull
@Override
public DotNetAttribute[] getAttributes()
{
return myOriginal.getAttributes();
}
示例11: findSingleAttributeValue
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@Nullable
public static <T> T findSingleAttributeValue(@NotNull PsiElement owner, @NotNull String qName, @NotNull Class<T> clazz)
{
DotNetAttribute attribute = findAttribute(owner, qName);
if(!(attribute instanceof CSharpAttribute))
{
return null;
}
DotNetExpression[] parameterExpressions = ((CSharpAttribute) attribute).getParameterExpressions();
if(parameterExpressions.length == 0)
{
return null;
}
return new ConstantExpressionEvaluator(parameterExpressions[0]).getValueAs(clazz);
}
示例12: getLanguageId
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@Nullable
@Override
public String getLanguageId(@NotNull DotNetAttribute attribute)
{
if(!(attribute instanceof CSharpAttribute))
{
return null;
}
DotNetExpression[] parameterExpressions = ((CSharpAttribute) attribute).getParameterExpressions();
if(parameterExpressions.length == 0)
{
return null;
}
return new ConstantExpressionEvaluator(parameterExpressions[0]).getValueAs(String.class);
}
示例13: getAttributes
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@RequiredReadAction
@NotNull
@Override
public DotNetAttribute[] getAttributes()
{
PsiElement parentByStub = getParentByStub();
if(parentByStub instanceof MsilClassEntry)
{
return ((MsilClassEntry) parentByStub).getAttributes();
}
else if(parentByStub instanceof MsilMethodEntry)
{
return ((MsilMethodEntry) parentByStub).getAttributes();
}
else if(parentByStub instanceof MsilFieldEntry)
{
return ((MsilFieldEntry) parentByStub).getAttributes();
}
else if(parentByStub instanceof MsilPropertyEntry)
{
return ((MsilPropertyEntry) parentByStub).getAttributes();
}
else if(parentByStub instanceof MsilParameter)
{
MsilParameterList parameterList = getStubOrPsiParentOfType(MsilParameterList.class);
MsilMethodEntry methodEntry = getStubOrPsiParentOfType(MsilMethodEntry.class);
assert parameterList != null;
assert methodEntry != null;
int i = ArrayUtil.indexOf(parameterList.getParameters(), parentByStub);
assert i != -1;
return methodEntry.getParameterAttributes(i);
}
return DotNetAttribute.EMPTY_ARRAY;
}
示例14: process
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@RequiredReadAction
@Override
public void process(@NotNull CSharpResolveOptions options,
@NotNull DotNetGenericExtractor defaultExtractor,
@Nullable PsiElement forceQualifierElement,
@NotNull Processor<ResolveResult> processor)
{
PsiElement element = options.getElement();
DotNetTypeRef resolvedTypeRef = null;
CSharpFieldOrPropertySetBlock block = PsiTreeUtil.getParentOfType(element, CSharpFieldOrPropertySetBlock.class);
if(block != null)
{
PsiElement parent = block.getParent();
if(parent instanceof CSharpShortObjectInitializerExpressionImpl)
{
resolvedTypeRef = ((CSharpShortObjectInitializerExpressionImpl) parent).toTypeRef(true);
}
}
if(resolvedTypeRef == null)
{
CSharpCallArgumentListOwner callArgumentListOwner = PsiTreeUtil.getParentOfType(element, CSharpCallArgumentListOwner.class);
if(callArgumentListOwner instanceof CSharpNewExpression)
{
resolvedTypeRef = ((CSharpNewExpression) callArgumentListOwner).toTypeRef(false);
}
else if(callArgumentListOwner instanceof DotNetAttribute)
{
resolvedTypeRef = ((DotNetAttribute) callArgumentListOwner).toTypeRef();
}
else
{
resolvedTypeRef = DotNetTypeRef.ERROR_TYPE;
}
}
if(resolvedTypeRef == DotNetTypeRef.ERROR_TYPE)
{
return;
}
DotNetTypeResolveResult typeResolveResult = resolvedTypeRef.resolve();
PsiElement typeElement = typeResolveResult.getElement();
if(typeElement == null)
{
return;
}
DotNetGenericExtractor genericExtractor = typeResolveResult.getGenericExtractor();
StubScopeProcessor scopeProcessor = CSharpReferenceExpressionImplUtil.createMemberProcessor(options, processor);
ResolveState state = ResolveState.initial();
state = state.put(CSharpResolveUtil.EXTRACTOR, genericExtractor);
state = state.put(CSharpResolveUtil.SELECTOR, options.getSelector());
CSharpResolveUtil.walkChildren(scopeProcessor, typeElement, false, true, state);
}
示例15: getMessage
import consulo.dotnet.psi.DotNetAttribute; //导入依赖的package包/类
@RequiredReadAction
public static String getMessage(DotNetAttribute attribute)
{
if(attribute instanceof CSharpAttribute)
{
CSharpCallArgumentList parameterList = ((CSharpAttribute) attribute).getParameterList();
if(parameterList == null)
{
return null;
}
DotNetExpression[] expressions = parameterList.getExpressions();
if(expressions.length == 0)
{
for(CSharpFieldOrPropertySet namedCallArgument : parameterList.getSets())
{
if(namedCallArgument instanceof CSharpNamedFieldOrPropertySet)
{
CSharpReferenceExpression argumentNameReference = (CSharpReferenceExpression) namedCallArgument.getNameElement();
if("Message".equals(argumentNameReference.getReferenceName()))
{
return new ConstantExpressionEvaluator(namedCallArgument.getValueExpression()).getValueAs(String.class);
}
}
}
}
else
{
DotNetExpression expression = expressions[0];
return new ConstantExpressionEvaluator(expression).getValueAs(String.class);
}
}
else if(attribute instanceof MsilCustomAttribute)
{
MsilCustomAttributeArgumentList attributeArgumentList = MsilCustomAttributeStubber.build((MsilCustomAttribute) attribute);
List<MsiCustomAttributeValue> constructorArguments = attributeArgumentList.getConstructorArguments();
if(!constructorArguments.isEmpty())
{
MsiCustomAttributeValue msiCustomAttributeValue = constructorArguments.get(0);
Object value = msiCustomAttributeValue.getValue();
if(value instanceof String)
{
return (String) value;
}
}
}
return null;
}