• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java PsiAnnotationOwner类的典型用法和代码示例

java 2次浏览

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

PsiAnnotationOwner类属于com.intellij.psi包,在下文中一共展示了PsiAnnotationOwner类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: checkArgumentList

点赞 3

import com.intellij.psi.PsiAnnotationOwner; //导入依赖的package包/类
@Override
public boolean checkArgumentList(@NotNull AnnotationHolder holder, @NotNull GrAnnotation annotation) {
  if (!GroovyCommonClassNames.GROOVY_LANG_DELEGATES_TO.equals(annotation.getQualifiedName())) return false;

  final PsiAnnotationMemberValue valueAttribute = annotation.findAttributeValue("value");

  if (valueAttribute == null) {
    final PsiAnnotationOwner owner = annotation.getOwner();
    if (owner instanceof GrModifierList) {
      final PsiElement parent1 = ((GrModifierList)owner).getParent();
      if (parent1 instanceof GrParameter) {
        final PsiElement parent = parent1.getParent();
        if (parent instanceof GrParameterList) {
          for (GrParameter parameter : ((GrParameterList)parent).getParameters()) {
            if (parameter.getModifierList().findAnnotation(GroovyCommonClassNames.GROOVY_LANG_DELEGATES_TO_TARGET) != null) {
              return true;
            }
          }
        }
      }
    }
  }

  return false;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:26,
代码来源:DelegatesToAnnotationChecker.java

示例2: checkApplicability

点赞 3

import com.intellij.psi.PsiAnnotationOwner; //导入依赖的package包/类
public void checkApplicability(@NotNull GrAnnotation annotation, @Nullable PsiAnnotationOwner owner) {
  final GrCodeReferenceElement ref = annotation.getClassReference();
  final PsiElement resolved = ref.resolve();

  if (resolved == null) return;
  assert resolved instanceof PsiClass;

  PsiClass anno = (PsiClass)resolved;
  String qname = anno.getQualifiedName();
  if (!anno.isAnnotationType() && GrAnnotationCollector.findAnnotationCollector(anno) == null) {
    if (qname != null) {
      myHolder.createErrorAnnotation(ref, GroovyBundle.message("class.is.not.annotation", qname));
    }
    return;
  }

  for (CustomAnnotationChecker checker : CustomAnnotationChecker.EP_NAME.getExtensions()) {
    if (checker.checkApplicability(myHolder, annotation)) return;
  }

  String description = CustomAnnotationChecker.isAnnotationApplicable(annotation, owner);
  if (description != null) {
    myHolder.createErrorAnnotation(ref, description).registerFix(new GrRemoveAnnotationIntention());
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:26,
代码来源:AnnotationChecker.java

示例3: getConfigAnnotation

点赞 2

import com.intellij.psi.PsiAnnotationOwner; //导入依赖的package包/类
Optional<PsiAnnotation> getConfigAnnotation(@NotNull PsiModifierListOwner psiModifierListOwner) {
    return Optional.ofNullable(psiModifierListOwner.getModifierList())
            .map(PsiAnnotationOwner::getAnnotations)
            .map(Arrays::stream)
            .map(stream -> stream.filter(annotation -> Optional.ofNullable(annotation.getNameReferenceElement())
                    .map(PsiReference::resolve)
                    .map(psiElement -> psiElement == configAnnotationClass)
                    .orElse(false)
            ))
            .flatMap(Stream::findFirst);
}
 

开发者ID:seedstack,
项目名称:intellij-plugin,
代码行数:12,
代码来源:CoffigResolver.java

示例4: getPathAnnotation

点赞 2

import com.intellij.psi.PsiAnnotationOwner; //导入依赖的package包/类
private PsiAnnotation getPathAnnotation(PsiClass pathAnnotationClass, @NotNull PsiModifierListOwner psiModifierListOwner) {
    return Optional.ofNullable(psiModifierListOwner.getModifierList())
            .map(PsiAnnotationOwner::getAnnotations)
            .map(Arrays::stream)
            .map(stream -> stream.filter(annotation -> Optional.ofNullable(annotation.getNameReferenceElement())
                    .map(PsiReference::resolve)
                    .map(psiElement -> psiElement == pathAnnotationClass)
                    .orElse(false)
            ))
            .flatMap(Stream::findFirst)
            .orElse(null);
}
 

开发者ID:seedstack,
项目名称:intellij-plugin,
代码行数:13,
代码来源:ResourceNode.java

示例5: checkScriptField

点赞 2

import com.intellij.psi.PsiAnnotationOwner; //导入依赖的package包/类
private static void checkScriptField(AnnotationHolder holder, GrAnnotation annotation) {
  final PsiAnnotationOwner owner = annotation.getOwner();
  final GrMember container = PsiTreeUtil.getParentOfType(((PsiElement)owner), GrMember.class);
  if (container != null) {
    if (container.getContainingClass() instanceof GroovyScriptClass) {
      holder.createErrorAnnotation(annotation, GroovyBundle.message("annotation.field.can.only.be.used.within.a.script.body"));
    }
    else {
      holder.createErrorAnnotation(annotation, GroovyBundle.message("annotation.field.can.only.be.used.within.a.script"));
    }
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:13,
代码来源:FieldAnnotationChecker.java

示例6: checkArgumentList

点赞 2

import com.intellij.psi.PsiAnnotationOwner; //导入依赖的package包/类
@Override
public boolean checkArgumentList(@NotNull AnnotationHolder holder, @NotNull GrAnnotation annotation) {
  if (!"griffon.transform.PropertyListener".equals(annotation.getQualifiedName())) return false;

  final GrAnnotationNameValuePair[] attributes = annotation.getParameterList().getAttributes();
  if (attributes.length != 1) return false;

  final GrAnnotationNameValuePair attribute = attributes[0];
  final GrAnnotationMemberValue value = attribute.getValue();

  final PsiAnnotationOwner owner = annotation.getOwner();
  if (owner instanceof GrField) {
    if (value instanceof GrClosableBlock) {
      return true;
    }
  }
  else if (owner instanceof GrTypeDefinition) {
    if (value instanceof GrReferenceExpression) {
      final PsiElement resolved = ((GrReferenceExpression)value).resolve();
      if (resolved instanceof GrField) {
        final PsiClass containingClass = ((GrField)resolved).getContainingClass();
        if (annotation.getManager().areElementsEquivalent((PsiElement)owner, containingClass)) {
          return true;
        }
      }
    }
  }

  return false;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:31,
代码来源:GriffonPropertyListenerAnnotationChecker.java

示例7: findAnnotationQuick

点赞 2

import com.intellij.psi.PsiAnnotationOwner; //导入依赖的package包/类
@Nullable
private static PsiAnnotation findAnnotationQuick(@Nullable PsiAnnotationOwner annotationOwner, @NotNull String qualifiedName) {
  if (annotationOwner == null) {
    return null;
  }

  PsiAnnotation[] annotations = annotationOwner.getAnnotations();
  if (annotations.length == 0) {
    return null;
  }

  final String shortName = StringUtil.getShortName(qualifiedName);

  for (PsiAnnotation annotation : annotations) {
    PsiJavaCodeReferenceElement referenceElement = annotation.getNameReferenceElement();
    if (null != referenceElement) {
      final String referenceName = referenceElement.getReferenceName();
      if (shortName.equals(referenceName)) {

        if (referenceElement.isQualified() && referenceElement instanceof SourceJavaCodeReference) {
          String possibleFullQualifiedName = ((SourceJavaCodeReference) referenceElement).getClassNameText();
          if (qualifiedName.equals(possibleFullQualifiedName)) {
            return annotation;
          }
        }

        final String annotationQualifiedName = getAndCacheFQN(annotation, referenceName);
        if (qualifiedName.equals(annotationQualifiedName)) {
          return annotation;
        }
      }
    }
  }

  return null;
}
 

开发者ID:mplushnikov,
项目名称:lombok-intellij-plugin,
代码行数:37,
代码来源:PsiAnnotationSearchUtil.java

示例8: getOwner

点赞 2

import com.intellij.psi.PsiAnnotationOwner; //导入依赖的package包/类
@Override
public PsiAnnotationOwner getOwner()
{
	return (PsiAnnotationOwner) getParent();//todo
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:6,
代码来源:ClsAnnotationImpl.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)