LocalQuickFix[] (PsiElement location, GroovyResolveResult resolveResult) { final PsiElement element = resolveResult.getElement(); if (!(element instanceof PsiMember refElement)) return GroovyFix.EMPTY_ARRAY; if (refElement instanceof PsiCompiledElement) return GroovyFix.EMPTY_ARRAY; PsiModifierList modifierList = refElement.getModifierList(); if (modifierList == null) return GroovyFix.EMPTY_ARRAY; List<LocalQuickFix> fixes = new ArrayList<>(); try { Project project = refElement.getProject(); JavaPsiFacade facade = JavaPsiFacade.getInstance(project); PsiModifierList modifierListCopy = facade.getElementFactory().createFieldFromText("int a;", null).getModifierList(); assert modifierListCopy != null; modifierListCopy.setModifierProperty(PsiModifier.STATIC, modifierList.hasModifierProperty(PsiModifier.STATIC)); String minModifier = PsiModifier.PROTECTED; if (refElement.hasModifierProperty(PsiModifier.PROTECTED)) { minModifier = PsiModifier.PUBLIC; } String[] modifiers = {PsiModifier.PROTECTED, PsiModifier.PUBLIC, PsiModifier.PACKAGE_LOCAL}; PsiClass accessObjectClass = PsiTreeUtil.getParentOfType(location, PsiClass.class, false); if (accessObjectClass == null) { final PsiFile file = location.getContainingFile(); if (!(file instanceof GroovyFile)) return GroovyFix.EMPTY_ARRAY; accessObjectClass = ((GroovyFile)file).getScriptClass(); } for (int i = ArrayUtil.indexOf(modifiers, minModifier); i < modifiers.length; i++) { String modifier = modifiers[i]; modifierListCopy.setModifierProperty(modifier, true); if (facade.getResolveHelper().isAccessible(refElement, modifierListCopy, location, accessObjectClass, null)) { fixes.add(new GrModifierFix(refElement, modifier, true, true, GrModifierFix.MODIFIER_LIST_OWNER)); } } } catch (IncorrectOperationException e) { LOG.error(e); } return fixes.toArray(LocalQuickFix.EMPTY_ARRAY); }