当前位置: 首页>>代码示例>>Java>>正文


Java PsiAnnotation.getParameterList方法代码示例

本文整理汇总了Java中com.intellij.psi.PsiAnnotation.getParameterList方法的典型用法代码示例。如果您正苦于以下问题:Java PsiAnnotation.getParameterList方法的具体用法?Java PsiAnnotation.getParameterList怎么用?Java PsiAnnotation.getParameterList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.PsiAnnotation的用法示例。


在下文中一共展示了PsiAnnotation.getParameterList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeDefaultAnnotation

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
protected void removeDefaultAnnotation(@NotNull PsiModifierListOwner targetElement, @NotNull Class<? extends Annotation> annotationClass) {
  final PsiAnnotation psiAnnotation = PsiAnnotationSearchUtil.findAnnotation(targetElement, annotationClass);
  if (null != psiAnnotation) {
    boolean hasOnlyDefaultValues = true;

    final PsiAnnotationParameterList psiAnnotationParameterList = psiAnnotation.getParameterList();
    for (PsiNameValuePair nameValuePair : psiAnnotationParameterList.getAttributes()) {
      if (null != psiAnnotation.findDeclaredAttributeValue(nameValuePair.getName())) {
        hasOnlyDefaultValues = false;
        break;
      }
    }

    if (hasOnlyDefaultValues) {
      psiAnnotation.delete();
    }
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:19,代码来源:BaseLombokHandler.java

示例2: getValueStringFromAnnotationWithDefault

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
public static AnnotationValueElement getValueStringFromAnnotationWithDefault(PsiAnnotation annotation) {
  final PsiAnnotationParameterList parameterList = annotation.getParameterList();
  final PsiNameValuePair[] attributes = parameterList.getAttributes();
  final PsiElement logicalElement = getImmediateOwnerElement(annotation);

  if (logicalElement == null) {
    return null;
  }

  final String value;
  final PsiElement errorElement;

  if (attributes.length == 0) {
    value = getNameOfElement(logicalElement);
    errorElement = annotation;
  }
  else {
    final String text = attributes[0].getText();
    value = text.substring(1, text.length() - 1);
    errorElement = attributes[0];
  }

  return new AnnotationValueElement(value, errorElement);
}
 
开发者ID:errai,项目名称:errai-intellij-idea-plugin,代码行数:25,代码来源:Util.java

示例3: getOnX

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
@NotNull
public static Collection<String> getOnX(@NotNull PsiAnnotation psiAnnotation, @NotNull String parameterName) {
  PsiAnnotationMemberValue onXValue = psiAnnotation.findAttributeValue(parameterName);
  if (!(onXValue instanceof PsiAnnotation)) {
    return Collections.emptyList();
  }
  Collection<PsiAnnotation> annotations = PsiAnnotationUtil.getAnnotationValues((PsiAnnotation) onXValue, "value", PsiAnnotation.class);
  Collection<String> annotationStrings = new ArrayList<String>();
  for (PsiAnnotation annotation : annotations) {
    PsiAnnotationParameterList params = annotation.getParameterList();
    annotationStrings.add(PsiAnnotationSearchUtil.getSimpleNameOf(annotation) + params.getText());
  }
  return annotationStrings;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:15,代码来源:LombokProcessorUtil.java

示例4: findDefaultValue

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
public static PsiElement findDefaultValue(PsiAnnotation annotation){
    final PsiAnnotationParameterList parameters = annotation.getParameterList();
    final PsiNameValuePair[] pairs = parameters.getAttributes();
    for(PsiNameValuePair pair : pairs){
        final String name = pair.getName();
        if("value".equals(name) || name == null){
            return pair.getValue();
        }
    }
    return null;
}
 
开发者ID:consulo,项目名称:consulo-google-guice,代码行数:12,代码来源:AnnotationUtils.java

示例5: buildVisitor

import com.intellij.psi.PsiAnnotation; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(
    @NotNull final com.intellij.codeInspection.ProblemsHolder holder, boolean isOnTheFly) {
  return new EndpointPsiElementVisitor() {

    @Override
    public void visitAnnotation(PsiAnnotation annotation) {
      if (annotation == null) {
        return;
      }

      if (!GctConstants.APP_ENGINE_ANNOTATION_API.equals(annotation.getQualifiedName())) {
        return;
      }

      // Need to check for user added attributes because default values are used when not
      // specified by user and we are only interested in the user specified values
      PsiAnnotationParameterList parameterList = annotation.getParameterList();
      if (parameterList.getAttributes().length == 0) {
        return;
      }

      PsiAnnotationMemberValue annotationMemberValue =
          annotation.findAttributeValue(API_NAME_ATTRIBUTE);
      if (annotationMemberValue == null) {
        return;
      }

      String nameValueWithQuotes = annotationMemberValue.getText();
      String nameValue = EndpointUtilities.removeBeginningAndEndingQuotes(nameValueWithQuotes);

      // Empty API name is valid
      if (nameValue.isEmpty()) {
        return;
      }

      if (!API_NAME_PATTERN.matcher(nameValue).matches()) {
        holder.registerProblem(
            annotationMemberValue,
            "Invalid api name: it must start with a lower case letter and consists only of "
                + "letter and digits",
            new MyQuickFix());
      }
    }
  };
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:48,代码来源:ApiNameInspection.java


注:本文中的com.intellij.psi.PsiAnnotation.getParameterList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。