@Override public void findCollisions( PsiElement element, String newName, Map<? extends PsiElement, String> allRenames, List<UsageInfo> result) { super.findCollisions(element, newName, allRenames, result); }
@Override public void findCollisions( PsiElement element, String newName, Map<? extends PsiElement, String> allRenames, List<UsageInfo> result) { List<UsageInfo> collisions = new ArrayList<>(); for (UsageInfo info : result) { if (!(info instanceof MoveRenameUsageInfo)) continue; final PsiElement infoElement = info.getElement(); final PsiElement referencedElement = ((MoveRenameUsageInfo) info).getReferencedElement(); if (!(infoElement instanceof GrReferenceExpression)) continue; final GrReferenceExpression refExpr = (GrReferenceExpression) infoElement; if (!(referencedElement instanceof GrField || refExpr.advancedResolve().isInvokedOnProperty())) continue; if (!(refExpr.getParent() instanceof GrCall)) continue; final PsiType[] argTypes = PsiUtil.getArgumentTypes(refExpr, false); final PsiType[] typeArguments = refExpr.getTypeArguments(); final MethodResolverProcessor processor = new MethodResolverProcessor(newName, refExpr, false, null, argTypes, typeArguments); final PsiMethod resolved = ResolveUtil.resolveExistingElement(refExpr, processor, PsiMethod.class); if (resolved == null) continue; collisions.add( new UnresolvableCollisionUsageInfo(resolved, refExpr) { @Override public String getDescription() { return GroovyRefactoringBundle.message( "usage.will.be.overriden.by.method", refExpr.getParent().getText(), PsiFormatUtil.formatMethod( resolved, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME, PsiFormatUtilBase.SHOW_TYPE)); } }); } result.addAll(collisions); super.findCollisions(element, newName, allRenames, result); }
@Override public void findExistingNameConflicts( PsiElement element, String newName, MultiMap<PsiElement, String> conflicts) { super.findExistingNameConflicts(element, newName, conflicts); GrField field = (GrField) element; final PsiClass containingClass = field.getContainingClass(); if (containingClass == null) return; final PsiMethod getter = GroovyPropertyUtils.findGetterForField(field); if (getter instanceof GrAccessorMethod) { final PsiMethod newGetter = PropertyUtil.findPropertyGetter( containingClass, newName, field.hasModifierProperty(PsiModifier.STATIC), true); if (newGetter != null && !(newGetter instanceof GrAccessorMethod)) { conflicts.putValue( newGetter, GroovyRefactoringBundle.message( "implicit.getter.will.by.overriden.by.method", field.getName(), newGetter.getName())); } } final PsiMethod setter = GroovyPropertyUtils.findSetterForField(field); if (setter instanceof GrAccessorMethod) { final PsiMethod newSetter = PropertyUtil.findPropertySetter( containingClass, newName, field.hasModifierProperty(PsiModifier.STATIC), true); if (newSetter != null && !(newSetter instanceof GrAccessorMethod)) { conflicts.putValue( newSetter, GroovyRefactoringBundle.message( "implicit.setter.will.by.overriden.by.method", field.getName(), newSetter.getName())); } } }