resource bundles: remove redundant handler (IDEA-258166)

no need to unexpectedly select first file in a bundle during rename, automatic renamer would suggest to rename them all anyway

GitOrigin-RevId: 85a52f48d157f0ef8c498c2743f1d213055be82c
This commit is contained in:
Anna Kozlova
2020-12-18 20:19:26 +00:00
committed by intellij-monorepo-bot
parent c62db841c0
commit 155212625a
2 changed files with 0 additions and 47 deletions
@@ -56,7 +56,6 @@
<lang.syntaxHighlighter language="Properties" implementationClass="com.intellij.lang.properties.PropertiesHighlighter"/>
<lang.parserDefinition language="Properties" implementationClass="com.intellij.lang.properties.parsing.PropertiesParserDefinition"/>
<renameHandler implementation="com.intellij.lang.properties.refactoring.rename.ResourceBundleFromProjectViewRenameHandler"/>
<automaticRenamerFactory implementation="com.intellij.lang.properties.refactoring.rename.ResourceBundleRenamerFactory"/>
<renamePsiElementProcessor implementation="com.intellij.lang.properties.refactoring.rename.RenamePropertyProcessor"/>
<stubElementTypeHolder class="com.intellij.lang.properties.parsing.PropertiesElementTypes"/>
@@ -1,46 +0,0 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.lang.properties.refactoring.rename;
import com.intellij.lang.properties.ResourceBundle;
import com.intellij.lang.properties.editor.ResourceBundleUtil;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.refactoring.RefactoringActionHandlerFactory;
import com.intellij.refactoring.rename.RenameHandler;
import org.jetbrains.annotations.NotNull;
/**
* @author Dmitry Batkovich
*/
public class ResourceBundleFromProjectViewRenameHandler implements RenameHandler {
@Override
public boolean isAvailableOnDataContext(@NotNull DataContext dataContext) {
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return false;
}
final ResourceBundle bundle = ResourceBundleUtil.getResourceBundleFromDataContext(dataContext);
if (bundle == null || bundle.getPropertiesFiles().size() < 2) {
return false;
}
return PlatformDataKeys.FILE_EDITOR.getData(dataContext) == null;
}
@Override
public void invoke(final @NotNull Project project, Editor editor, final PsiFile file, DataContext dataContext) {
final ResourceBundle resourceBundle = ResourceBundleUtil.getResourceBundleFromDataContext(dataContext);
assert resourceBundle != null;
RefactoringActionHandlerFactory.getInstance().createRenameHandler().invoke(project, new PsiElement[] {resourceBundle.getDefaultPropertiesFile().getContainingFile()}, dataContext);
}
@Override
public void invoke(@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext) {
invoke(project, null, null, dataContext);
}
}