本文整理汇总了Java中consulo.dotnet.psi.DotNetAttributeUtil类的典型用法代码示例。如果您正苦于以下问题:Java DotNetAttributeUtil类的具体用法?Java DotNetAttributeUtil怎么用?Java DotNetAttributeUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DotNetAttributeUtil类属于consulo.dotnet.psi包,在下文中一共展示了DotNetAttributeUtil类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getAdditionalModifiers
import consulo.dotnet.psi.DotNetAttributeUtil; //导入依赖的package包/类
@RequiredReadAction
private static CSharpModifier[] getAdditionalModifiers(int index, DotNetLikeMethodDeclaration parent, DotNetVariable variable)
{
if(index == 0)
{
PsiElement msilElement = parent.getOriginalElement();
// we can use mirror due ExtensionAttribute is in ban list
if(DotNetAttributeUtil.hasAttribute(msilElement, DotNetTypes.System.Runtime.CompilerServices.ExtensionAttribute))
{
return new CSharpModifier[]{CSharpModifier.THIS};
}
}
DotNetModifierList modifierList = variable.getModifierList();
if(modifierList != null && modifierList.hasModifier(MsilTokens.BRACKET_OUT_KEYWORD))
{
DotNetType type = variable.getType();
if(type instanceof MsilTypeByRefImpl)
{
return new CSharpModifier[]{CSharpModifier.OUT};
}
}
return CSharpModifier.EMPTY_ARRAY;
}
示例3: 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);
}
}
示例4: weigh
import consulo.dotnet.psi.DotNetAttributeUtil; //导入依赖的package包/类
@RequiredReadAction
@Override
public Comparable weigh(@NotNull PsiElement psiElement, @NotNull ProximityLocation proximityLocation)
{
if(DotNetAttributeUtil.hasAttribute(psiElement, DotNetTypes.System.ObsoleteAttribute))
{
return Access.OBSOLETE;
}
return Access.NORMAL;
}
示例5: highlightNamed
import consulo.dotnet.psi.DotNetAttributeUtil; //导入依赖的package包/类
@Nullable
@RequiredReadAction
public static HighlightInfo highlightNamed(@NotNull HighlightInfoHolder holder, @Nullable PsiElement element, @Nullable PsiElement target, @Nullable PsiElement owner)
{
if(target == null || element == null)
{
return null;
}
IElementType elementType = target.getNode().getElementType();
if(CSharpTokenSets.KEYWORDS.contains(elementType)) // don't highlight keywords
{
return null;
}
if(isMethodRef(owner, element))
{
HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(target).textAttributes(CSharpHighlightKey.METHOD_REF).create();
holder.add(highlightInfo);
}
TextAttributesKey defaultTextAttributeKey = getDefaultTextAttributeKey(element, target);
if(defaultTextAttributeKey == null)
{
return null;
}
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(target).textAttributes(defaultTextAttributeKey).create();
holder.add(info);
if(!(target instanceof CSharpIdentifier) && DotNetAttributeUtil.hasAttribute(element, DotNetTypes.System.ObsoleteAttribute))
{
holder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(target).textAttributes(CodeInsightColors.DEPRECATED_ATTRIBUTES).create());
}
return info;
}
示例6: isObsolete
import consulo.dotnet.psi.DotNetAttributeUtil; //导入依赖的package包/类
@RequiredReadAction
public boolean isObsolete()
{
return myLikeMethod instanceof DotNetModifierListOwner && DotNetAttributeUtil.hasAttribute((PsiElement) myLikeMethod, DotNetTypes.System.ObsoleteAttribute);
}
示例7: consumeType
import consulo.dotnet.psi.DotNetAttributeUtil; //导入依赖的package包/类
@RequiredReadAction
private static void consumeType(final CompletionParameters completionParameters,
CSharpReferenceExpression referenceExpression,
Consumer<LookupElement> consumer,
boolean insideUsingList,
DotNetTypeDeclaration someType)
{
final String parentQName = someType.getPresentableParentQName();
if(StringUtil.isEmpty(parentQName))
{
return;
}
String presentationText = MsilHelper.cutGenericMarker(someType.getName());
int genericCount;
DotNetGenericParameter[] genericParameters = someType.getGenericParameters();
if((genericCount = genericParameters.length) > 0)
{
presentationText += "<" + StringUtil.join(genericParameters, parameter -> parameter.getName(), ", ");
presentationText += ">";
}
String lookupString = insideUsingList ? someType.getPresentableQName() : someType.getName();
if(lookupString == null)
{
return;
}
lookupString = MsilHelper.cutGenericMarker(lookupString);
DotNetQualifiedElement targetElementForLookup = someType;
CSharpMethodDeclaration methodDeclaration = someType.getUserData(CSharpResolveUtil.DELEGATE_METHOD_TYPE);
if(methodDeclaration != null)
{
targetElementForLookup = methodDeclaration;
}
LookupElementBuilder builder = LookupElementBuilder.create(targetElementForLookup, lookupString);
builder = builder.withPresentableText(presentationText);
builder = builder.withIcon(IconDescriptorUpdaters.getIcon(targetElementForLookup, Iconable.ICON_FLAG_VISIBILITY));
builder = builder.withTypeText(parentQName, true);
final InsertHandler<LookupElement> ltGtInsertHandler = genericCount == 0 ? null : LtGtInsertHandler.getInstance(genericCount > 0);
if(insideUsingList)
{
builder = builder.withInsertHandler(ltGtInsertHandler);
}
else
{
builder = builder.withInsertHandler(new InsertHandler<LookupElement>()
{
@Override
@RequiredWriteAction
public void handleInsert(InsertionContext context, LookupElement item)
{
if(ltGtInsertHandler != null)
{
ltGtInsertHandler.handleInsert(context, item);
}
context.commitDocument();
new AddUsingAction(completionParameters.getEditor(), context.getFile(), Collections.<NamespaceReference>singleton(new NamespaceReference(parentQName, null))).execute();
}
});
}
if(DotNetAttributeUtil.hasAttribute(someType, DotNetTypes.System.ObsoleteAttribute))
{
builder = builder.withStrikeoutness(true);
}
CSharpTypeLikeLookupElement element = CSharpTypeLikeLookupElement.create(builder, DotNetGenericExtractor.EMPTY, referenceExpression);
element.putUserData(CSharpNoVariantsDelegator.NOT_IMPORTED, Boolean.TRUE);
consumer.consume(element);
}
示例8: isDeprecated
import consulo.dotnet.psi.DotNetAttributeUtil; //导入依赖的package包/类
@Override
protected boolean isDeprecated()
{
T value = getValue();
return value != null && value.isValid() && DotNetAttributeUtil.hasAttribute(value, DotNetTypes.System.ObsoleteAttribute);
}
示例9: 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();
}
}
}