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


Java PsiModifierList.addAnnotation方法代码示例

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


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

示例1: process

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
protected void process(List<ClassMember> classMembers) {
  for (ClassMember classMember : classMembers) {
    final PsiElementClassMember elementClassMember = (PsiElementClassMember) classMember;

    PsiField psiField = (PsiField) elementClassMember.getPsiElement();
    PsiMethod psiMethod = PropertyUtil.findPropertySetter(psiField.getContainingClass(), psiField.getName(), false, false);
    if (null != psiMethod) {
      PsiModifierList modifierList = psiField.getModifierList();
      if (null != modifierList) {
        PsiAnnotation psiAnnotation = modifierList.addAnnotation(Setter.class.getName());

        psiMethod.delete();
      }
    }
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:18,代码来源:RefactorSetterHandler.java

示例2: process

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@Override
  protected void process(List<ClassMember> classMembers) {
    for (ClassMember classMember : classMembers) {
      final PsiElementClassMember elementClassMember = (PsiElementClassMember) classMember;

      PsiField psiField = (PsiField) elementClassMember.getPsiElement();
      PsiMethod psiMethod = PropertyUtil.findPropertyGetter(psiField.getContainingClass(), psiField.getName(), false, false);

      if (null != psiMethod) {
        PsiModifierList modifierList = psiField.getModifierList();
        if (null != modifierList) {
          PsiAnnotation psiAnnotation = modifierList.addAnnotation(Getter.class.getName());
//          psiAnnotation.setDeclaredAttributeValue("value", )

          psiMethod.delete();
        }
      }
    }
  }
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:20,代码来源:RefactorGetterHandler.java

示例3: generateMemberPrototypes

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@NotNull
@Override
protected List<? extends GenerationInfo> generateMemberPrototypes(PsiClass aClass, ClassMember[] members) throws IncorrectOperationException {
    List<? extends GenerationInfo> memberPrototypes = super.generateMemberPrototypes(aClass, members);
    for (GenerationInfo memberPrototype : memberPrototypes) {
        PsiModifierList modifierList = memberPrototype.getPsiMember().getModifierList();
        if (modifierList != null) {
            modifierList.addAnnotation("javax.inject.Inject");
        }
    }
    return memberPrototypes;
}
 
开发者ID:phajduk,项目名称:dagger2-intellij-plugin,代码行数:13,代码来源:GenerateInjectedConstructorHandler.java

示例4: addOnXAnnotations

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
protected static void addOnXAnnotations(@Nullable PsiAnnotation processedAnnotation,
                                        @NotNull PsiModifierList modifierList,
                                        @NotNull String onXParameterName) {
  if (processedAnnotation == null) {
    return;
  }

  Collection<String> annotationsToAdd = LombokProcessorUtil.getOnX(processedAnnotation, onXParameterName);
  for (String annotation : annotationsToAdd) {
    modifierList.addAnnotation(annotation);
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:13,代码来源:AbstractProcessor.java

示例5: createSetterMethod

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
@NotNull
public PsiMethod createSetterMethod(@NotNull PsiField psiField, @NotNull PsiClass psiClass, @NotNull String methodModifier) {
  final String fieldName = psiField.getName();
  final PsiType psiFieldType = psiField.getType();
  final PsiAnnotation setterAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, Setter.class);

  final String methodName = getSetterName(psiField, PsiType.BOOLEAN.equals(psiFieldType));

  PsiType returnType = getReturnType(psiField);
  LombokLightMethodBuilder method = new LombokLightMethodBuilder(psiField.getManager(), methodName)
    .withMethodReturnType(returnType)
    .withContainingClass(psiClass)
    .withParameter(fieldName, psiFieldType)
    .withNavigationElement(psiField);
  if (StringUtil.isNotEmpty(methodModifier)) {
    method.withModifier(methodModifier);
  }
  boolean isStatic = psiField.hasModifierProperty(PsiModifier.STATIC);
  if (isStatic) {
    method.withModifier(PsiModifier.STATIC);
  }

  PsiParameter methodParameter = method.getParameterList().getParameters()[0];
  PsiModifierList methodParameterModifierList = methodParameter.getModifierList();
  if (null != methodParameterModifierList) {
    final Collection<String> annotationsToCopy = PsiAnnotationUtil.collectAnnotationsToCopy(psiField,
      LombokUtils.NON_NULL_PATTERN, LombokUtils.NULLABLE_PATTERN);
    for (String annotationFQN : annotationsToCopy) {
      methodParameterModifierList.addAnnotation(annotationFQN);
    }
    addOnXAnnotations(setterAnnotation, methodParameterModifierList, "onParam");
  }

  method.withBody(createCodeBlock(psiField, psiClass, returnType, isStatic, methodParameter));

  PsiModifierList methodModifierList = method.getModifierList();
  copyAnnotations(psiField, methodModifierList, LombokUtils.DEPRECATED_PATTERN);
  addOnXAnnotations(setterAnnotation, methodModifierList, "onMethod");

  return method;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:42,代码来源:SetterFieldProcessor.java

示例6: copyAnnotations

import com.intellij.psi.PsiModifierList; //导入方法依赖的package包/类
protected void copyAnnotations(final PsiField fromPsiElement, final PsiModifierList toModifierList, final Pattern... patterns) {
  final Collection<String> annotationsToCopy = PsiAnnotationUtil.collectAnnotationsToCopy(fromPsiElement, patterns);
  for (String annotationFQN : annotationsToCopy) {
    toModifierList.addAnnotation(annotationFQN);
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:7,代码来源:AbstractFieldProcessor.java


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