use of com.intellij.refactoring.openapi.impl.JavaRenameRefactoringImpl in project intellij-community by JetBrains.
the class JavaFXRenameTest method testStaticPropertyMethod.
public void testStaticPropertyMethod() throws Exception {
final String className = "container.MyCustomContainer";
final String methodName = "setStaticProp";
final String newName = "setNewMethodName";
myFixture.configureByFiles(getTestName(true) + ".fxml", className.replace('.', '/') + ".java");
final PsiClass psiClass = myFixture.findClass(className);
assertNotNull(psiClass);
final PsiMethod[] methods = psiClass.findMethodsByName(methodName, false);
assertEquals(1, methods.length);
final PsiMethod method = methods[0];
final RenameRefactoring rename = new JavaRenameRefactoringImpl(getProject(), method, newName, false, false);
rename.run();
myFixture.checkResultByFile(getTestName(true) + "_after.fxml");
assertMethodExists(psiClass, newName);
}
use of com.intellij.refactoring.openapi.impl.JavaRenameRefactoringImpl in project intellij-community by JetBrains.
the class JavaFxPropertyRenameHandler method doRename.
private static void doRename(JavaFxPropertyReference reference, String newName, final boolean searchInComments, boolean isPreview) {
final PsiElement psiElement = JavaFxPropertyElement.fromReference(reference);
if (psiElement == null)
return;
final RenameRefactoring rename = new JavaRenameRefactoringImpl(psiElement.getProject(), psiElement, newName, searchInComments, false);
rename.setPreviewUsages(isPreview);
final Map<PsiElement, String> elementsToRename = getElementsToRename(reference, newName);
elementsToRename.forEach(rename::addElement);
rename.run();
}
use of com.intellij.refactoring.openapi.impl.JavaRenameRefactoringImpl in project intellij-community by JetBrains.
the class BeanPropertyRenameHandler method doRename.
public static void doRename(@NotNull final BeanProperty property, final String newName, final boolean searchInComments, boolean isPreview) {
final PsiElement psiElement = property.getPsiElement();
final RenameRefactoring rename = new JavaRenameRefactoringImpl(psiElement.getProject(), psiElement, newName, searchInComments, false);
rename.setPreviewUsages(isPreview);
final PsiMethod setter = property.getSetter();
if (setter != null) {
final String setterName = PropertyUtil.suggestSetterName(newName);
rename.addElement(setter, setterName);
final PsiParameter[] setterParameters = setter.getParameterList().getParameters();
if (setterParameters.length == 1) {
final JavaCodeStyleManager manager = JavaCodeStyleManager.getInstance(psiElement.getProject());
final String suggestedParameterName = manager.propertyNameToVariableName(property.getName(), VariableKind.PARAMETER);
if (suggestedParameterName.equals(setterParameters[0].getName())) {
rename.addElement(setterParameters[0], manager.propertyNameToVariableName(newName, VariableKind.PARAMETER));
}
}
}
final PsiMethod getter = property.getGetter();
if (getter != null) {
final String getterName = PropertyUtil.suggestGetterName(newName, getter.getReturnType());
rename.addElement(getter, getterName);
}
rename.run();
}
use of com.intellij.refactoring.openapi.impl.JavaRenameRefactoringImpl in project intellij-community by JetBrains.
the class JavaFxPropertyRenameHandler method doRenameFxId.
public static void doRenameFxId(XmlAttributeValue fxIdValueElement, String newName, boolean searchInComments, boolean previewUsages) {
final RenameRefactoring rename = new JavaRenameRefactoringImpl(fxIdValueElement.getProject(), fxIdValueElement, newName, searchInComments, false);
rename.setPreviewUsages(previewUsages);
final PsiField nestedControllerField = getNestedControllerField(fxIdValueElement);
if (nestedControllerField != null) {
rename.addElement(nestedControllerField, newName + FxmlConstants.CONTROLLER_SUFFIX);
}
rename.run();
}
Aggregations