mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-67376 Groovy: Renaming does not rename usages of private java field/methods in groovy files
This commit is contained in:
@@ -214,6 +214,8 @@
|
||||
<debuggerClassFilterProvider implementation="org.jetbrains.plugins.groovy.debugger.filters.GroovyDebuggerClassFilterProvider"/>
|
||||
<stackFrameFilter implementation="org.jetbrains.plugins.groovy.debugger.filters.GroovyDebuggerClassFilterProvider"/>
|
||||
|
||||
<useScopeEnlarger implementation="org.jetbrains.plugins.groovy.lang.psi.impl.search.GrPrivateFieldScopeEnlarger"/>
|
||||
|
||||
<debuggerEditorTextProvider language="Groovy" implementationClass="org.jetbrains.plugins.groovy.debugger.GroovyEditorTextProvider"/>
|
||||
|
||||
<xdebugger.settings implementation="org.jetbrains.plugins.groovy.debugger.filters.GroovyDebuggerSettings"/>
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.lang.psi.impl.search;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.search.UseScopeEnlarger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public class GrPrivateFieldScopeEnlarger extends UseScopeEnlarger {
|
||||
@Override
|
||||
public SearchScope getAdditionalUseScope(@NotNull PsiElement element) {
|
||||
if (element instanceof PsiField && ((PsiField)element).hasModifierProperty(PsiModifier.PRIVATE)) {
|
||||
final PsiManagerEx psiManager = (PsiManagerEx)element.getManager();
|
||||
final GlobalSearchScope maximalUseScope = psiManager.getFileManager().getUseScope(element);
|
||||
return new GrSourceFilterScope(maximalUseScope);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -425,6 +425,21 @@ class Foo {
|
||||
assertTrue false
|
||||
}
|
||||
|
||||
public void testRenameJavaPrivateField() {
|
||||
myFixture.addFileToProject "Foo.java", """
|
||||
public class Foo {
|
||||
private int field;
|
||||
}"""
|
||||
myFixture.configureByText "Bar.groovy", """
|
||||
print new Foo(field: 2)
|
||||
"""
|
||||
myFixture.renameElement myFixture.findClass("Foo").fields[0], "anotherOneName"
|
||||
|
||||
myFixture.checkResult """
|
||||
print new Foo(anotherOneName: 2)
|
||||
"""
|
||||
}
|
||||
|
||||
private def doInplaceRenameTest() {
|
||||
String prefix = TestUtils.getTestDataPath() + "groovy/refactoring/rename/" + getTestName(false)
|
||||
myFixture.configureByFile prefix + ".groovy";
|
||||
|
||||
Reference in New Issue
Block a user