本文整理汇总了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();
}
}
}
}
示例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();
}
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}