Java Code Examples for com.intellij.psi.util.PropertyUtil#findPropertySetter()

The following examples show how to use com.intellij.psi.util.PropertyUtil#findPropertySetter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RefactorSetterHandler.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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();
      }
    }
  }
}
 
Example 2
Source File: RefactorSetterHandler.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected List<EncapsulatableClassMember> getEncapsulatableClassMembers(PsiClass psiClass) {
  final List<EncapsulatableClassMember> result = new ArrayList<>();
  for (PsiField field : psiClass.getFields()) {
    if (null != PropertyUtil.findPropertySetter(psiClass, field.getName(), false, false)) {
      result.add(new PsiFieldMember(field));
    }
  }
  return result;
}
 
Example 3
Source File: LombokSetterHandler.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void processClass(@NotNull PsiClass psiClass) {
  final Map<PsiField, PsiMethod> fieldMethodMap = new HashMap<>();
  for (PsiField psiField : psiClass.getFields()) {
    PsiMethod propertySetter = PropertyUtil.findPropertySetter(psiClass, psiField.getName(), psiField.hasModifierProperty(PsiModifier.STATIC), false);

    if (null != propertySetter) {
      fieldMethodMap.put(psiField, propertySetter);
    }
  }

  processIntern(fieldMethodMap, psiClass, Setter.class);
}