diff --git a/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaMethodProcessor.java index 8923b587e423..e4ac3ce780ac 100644 --- a/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaMethodProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaMethodProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -263,6 +263,15 @@ public class RenameJavaMethodProcessor extends RenameJavaMemberProcessor { final PsiMethod method = (PsiMethod) element; OverridingMethodsSearch.search(method, scope, true).forEach(new Processor() { public boolean process(PsiMethod overrider) { + if (overrider instanceof PsiMirrorElement) { + final PsiElement prototype = ((PsiMirrorElement)overrider).getPrototype(); + if (prototype instanceof PsiMethod) { + overrider = (PsiMethod)prototype; + } + } + + if (overrider instanceof SyntheticElement) return true; + final String overriderName = overrider.getName(); final String baseName = method.getName(); final String newOverriderName = RefactoringUtil.suggestNewOverriderName(overriderName, baseName, newName); diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy index 63c2c6162fc8..c08fdf281582 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.jetbrains.plugins.groovy.refactoring.rename import com.intellij.openapi.util.text.StringUtil @@ -639,6 +654,38 @@ class Inheritor extends Bassse { super() } } +''') + } + } + + void testOverridenMethodWithOptionalParams() { + myFixture.with { + configureByText(GroovyFileType.GROOVY_FILE_TYPE, '''\ +class Base { + void foo(){} +} + +class Inheritor extends Base { + void foo(int x = 5) {} +} + +new Base().foo() +new Inheritor().foo() +new Inheritor().foo(2) +''') + renameElementAtCaret('bar') + checkResult('''\ +class Base { + void bar(){} +} + +class Inheritor extends Base { + void bar(int x = 5) {} +} + +new Base().bar() +new Inheritor().bar() +new Inheritor().bar(2) ''') } }