本文整理汇总了Java中consulo.dotnet.psi.DotNetAttributeUtil.findAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java DotNetAttributeUtil.findAttribute方法的具体用法?Java DotNetAttributeUtil.findAttribute怎么用?Java DotNetAttributeUtil.findAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类consulo.dotnet.psi.DotNetAttributeUtil
的用法示例。
在下文中一共展示了DotNetAttributeUtil.findAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compute
import consulo.dotnet.psi.DotNetAttributeUtil; //导入方法依赖的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: process
import consulo.dotnet.psi.DotNetAttributeUtil; //导入方法依赖的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);
}
}
示例3: injectLanguages
import consulo.dotnet.psi.DotNetAttributeUtil; //导入方法依赖的package包/类
@Override
public void injectLanguages(@NotNull MultiHostRegistrar multiHostRegistrar, @NotNull PsiElement element)
{
DotNetCallArgumentList argumentList = (DotNetCallArgumentList) element;
DotNetCallArgumentListOwner owner = PsiTreeUtil.getParentOfType(element, DotNetCallArgumentListOwner.class);
if(owner == null)
{
return;
}
PsiElement psiElement = owner.resolveToCallable();
if(!(psiElement instanceof DotNetLikeMethodDeclaration))
{
return;
}
DotNetParameter[] parameters = ((DotNetLikeMethodDeclaration) psiElement).getParameters();
DotNetExpression[] expressions = argumentList.getExpressions();
for(int i = 0; i < parameters.length; i++)
{
DotNetParameter parameter = parameters[i];
DotNetAttribute attribute = DotNetAttributeUtil.findAttribute(parameter, "MustBe.Consulo.Attributes.InjectLanguageAttribute");
if(attribute != null)
{
DotNetExpression dotNetExpression = ArrayUtil2.safeGet(expressions, i);
if(dotNetExpression == null)
{
continue;
}
LanguageVersion languageVersion = findLanguageFromAttribute(attribute);
if(languageVersion == null)
{
continue;
}
TextRange textRangeForInject = findTextRangeForInject(dotNetExpression);
if(textRangeForInject == null)
{
continue;
}
multiHostRegistrar.startInjecting(languageVersion).addPlace("", "", (PsiLanguageInjectionHost) dotNetExpression, textRangeForInject).doneInjecting();
}
}
}