diff --git a/java/java-analysis-impl/src/com/intellij/openapi/roots/impl/JavaModuleExternalPathsImpl.java b/java/java-analysis-impl/src/com/intellij/openapi/roots/impl/JavaModuleExternalPathsImpl.java index 9f1488a712a4..9e481ee68126 100644 --- a/java/java-analysis-impl/src/com/intellij/openapi/roots/impl/JavaModuleExternalPathsImpl.java +++ b/java/java-analysis-impl/src/com/intellij/openapi/roots/impl/JavaModuleExternalPathsImpl.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2018 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.openapi.roots.impl; import com.intellij.openapi.roots.*; @@ -25,7 +11,6 @@ import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager; import com.intellij.util.ArrayUtil; import gnu.trove.THashMap; import org.jdom.Element; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.serialization.java.JpsJavaModelSerializerExtension; @@ -35,16 +20,21 @@ import java.util.Map; * @author nik */ public class JavaModuleExternalPathsImpl extends JavaModuleExternalPaths { - @NonNls private static final String ROOT_ELEMENT = JpsJavaModelSerializerExtension.ROOT_TAG; - private final Map myOrderRootPointerContainers = new THashMap<>(); - private JavaModuleExternalPathsImpl mySource; + private static final String ROOT_ELEMENT = JpsJavaModelSerializerExtension.ROOT_TAG; + private final Map myOrderRootPointerContainers = new THashMap<>(); + private final JavaModuleExternalPathsImpl mySource; + + @SuppressWarnings("unused") public JavaModuleExternalPathsImpl() { + this(null); } - public JavaModuleExternalPathsImpl(JavaModuleExternalPathsImpl source) { + private JavaModuleExternalPathsImpl(JavaModuleExternalPathsImpl source) { mySource = source; - copyContainersFrom(source); + if (source != null) { + copyContainersFrom(source); + } } @Override @@ -111,6 +101,7 @@ public class JavaModuleExternalPathsImpl extends JavaModuleExternalPaths { } @Override + @SuppressWarnings("deprecation") public void readExternal(@NotNull Element element) throws InvalidDataException { for (PersistentOrderRootType orderRootType : OrderRootType.getAllPersistentTypes()) { String paths = orderRootType.getModulePathsName(); @@ -126,6 +117,7 @@ public class JavaModuleExternalPathsImpl extends JavaModuleExternalPaths { } @Override + @SuppressWarnings("deprecation") public void writeExternal(@NotNull Element element) throws WriteExternalException { for (OrderRootType orderRootType : myOrderRootPointerContainers.keySet()) { VirtualFilePointerContainer container = myOrderRootPointerContainers.get(orderRootType); @@ -169,6 +161,5 @@ public class JavaModuleExternalPathsImpl extends JavaModuleExternalPaths { } @Override - public void dispose() { - } -} + public void dispose() { } +} \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaModuleProcessor.java b/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaModuleProcessor.java index 8ed34dfc22a2..e9d67b5ee142 100644 --- a/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaModuleProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/rename/RenameJavaModuleProcessor.java @@ -21,10 +21,12 @@ public class RenameJavaModuleProcessor extends RenamePsiElementProcessor { } @Override - public void findCollisions(@NotNull PsiElement element, @NotNull String newName, @NotNull Map allRenames, @NotNull List result) { + public void findCollisions(@NotNull PsiElement element, + @NotNull String newName, + @NotNull Map allRenames, + @NotNull List result) { Project project = element.getProject(); - PsiJavaModule existing = ContainerUtil.getFirstItem( - JavaModuleNameIndex.getInstance().get(newName, project, ProjectScope.getProjectScope(project))); + PsiJavaModule existing = ContainerUtil.getFirstItem(JavaModuleNameIndex.getInstance().get(newName, project, ProjectScope.getProjectScope(project))); if (existing != null) { result.add(new UnresolvableCollisionUsageInfo(element, existing) { @Override diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/AutomaticRenamingDialog.form b/platform/lang-impl/src/com/intellij/refactoring/rename/AutomaticRenamingDialog.form index b17b2e48e36b..ecfcf7c624a7 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/AutomaticRenamingDialog.form +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/AutomaticRenamingDialog.form @@ -20,14 +20,6 @@ - - - - - - - - @@ -37,7 +29,7 @@ - + @@ -51,21 +43,12 @@ - + - - - - - - - - - @@ -75,10 +58,27 @@ + + + + + + + + + + + + + + + + + diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/AutomaticRenamingDialog.java b/platform/lang-impl/src/com/intellij/refactoring/rename/AutomaticRenamingDialog.java index 975cd51f5762..3b439e8d7c93 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/AutomaticRenamingDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/AutomaticRenamingDialog.java @@ -1,24 +1,8 @@ -/* - * Copyright 2000-2016 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. - */ - +// Copyright 2000-2018 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.refactoring.rename; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.InputValidatorEx; @@ -41,6 +25,7 @@ import com.intellij.ui.table.JBTable; import com.intellij.usageView.UsageInfo; import com.intellij.usages.UsageViewPresentation; import com.intellij.usages.impl.UsagePreviewPanel; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -55,47 +40,39 @@ import java.util.List; * @author dsl */ public class AutomaticRenamingDialog extends DialogWrapper { - private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.rename.AutomaticRenamingDialog"); private static final int CHECK_COLUMN = 0; private static final int OLD_NAME_COLUMN = 1; private static final int NEW_NAME_COLUMN = 2; + + private final Project myProject; private final AutomaticRenamer myRenamer; - private boolean[] myShouldRename; - private String[] myNewNames; - private PsiNamedElement[] myRenames; + private final boolean[] myShouldRename; + private final String[] myNewNames; + private final PsiNamedElement[] myRenames; private final MyTableModel myTableModel; - private JBTable myTable; - private JPanel myPanelForPreview; - private JButton mySelectAllButton; - private JButton myUnselectAllButton; + private JPanel myPanel; private JSplitPane mySplitPane; - private final Project myProject; - private final UsagePreviewPanel myUsagePreviewPanel; - private final JLabel myUsageFileLabel; + private JBTable myTable; + private JButton mySelectAllButton; + private JButton myUnselectAllButton; + private JPanel myPanelForPreview; + private UsagePreviewPanel myUsagePreviewPanel; + private JLabel myUsageFileLabel; private ListSelectionListener myListSelectionListener; - public AutomaticRenamingDialog(Project project, AutomaticRenamer renamer) { + public AutomaticRenamingDialog(@NotNull Project project, @NotNull AutomaticRenamer renamer) { super(project, true); myProject = project; myRenamer = renamer; - myUsagePreviewPanel = new UsagePreviewPanel(myProject, new UsageViewPresentation()); - myUsageFileLabel = new JLabel(); - populateData(); - myTableModel = new MyTableModel(renamer.allowChangeSuggestedName()); - setTitle(myRenamer.getDialogTitle()); - init(); - } - private void populateData() { - final Map renames = myRenamer.getRenames(); + Map renames = renamer.getRenames(); List temp = new ArrayList<>(); - for (final PsiNamedElement namedElement : renames.keySet()) { - final String newName = renames.get(namedElement); + for (PsiNamedElement namedElement : renames.keySet()) { + String newName = renames.get(namedElement); if (newName != null) temp.add(namedElement); } - myRenames = temp.toArray(PsiNamedElement.EMPTY_ARRAY); Arrays.sort(myRenames, (e1, e2) -> Comparing.compare(e1.getName(), e2.getName())); @@ -105,11 +82,21 @@ public class AutomaticRenamingDialog extends DialogWrapper { } myShouldRename = new boolean[myRenames.length]; - if (myRenamer.isSelectedByDefault()) { - for(int i=0; i handleChanges()); myTable.addMouseListener(new PopupHandler() { @Override public void invokePopup(Component comp, int x, int y) { - final int[] selectionRows = myTable.getSelectedRows(); - if (selectionRows != null) { + if (myTable.getSelectedRows() != null) { compoundPopup().show(comp, x, y); } } }); - final TableColumnModel columnModel = myTable.getColumnModel(); + TableColumnModel columnModel = myTable.getColumnModel(); columnModel.getColumn(CHECK_COLUMN).setCellRenderer(new BooleanTableCellRenderer()); - TableUtil.setupCheckboxColumn(columnModel.getColumn(CHECK_COLUMN)); - + TableUtil.setupCheckboxColumn(columnModel.getColumn(CHECK_COLUMN), 0); columnModel.getColumn(NEW_NAME_COLUMN).setCellEditor(new StringTableCellEditor(myProject)); + mySelectAllButton.addActionListener(e -> { for (int i = 0; i < myShouldRename.length; i++) { myShouldRename[i] = true; @@ -182,6 +172,7 @@ public class AutomaticRenamingDialog extends DialogWrapper { } fireDataChanged(); }); + myListSelectionListener = e -> { myUsageFileLabel.setText(""); int index = myTable.getSelectionModel().getLeadSelectionIndex(); @@ -211,7 +202,7 @@ public class AutomaticRenamingDialog extends DialogWrapper { GuiUtils.replaceJSplitPaneWithIDEASplitter(myPanel); if (myTableModel.getRowCount() != 0) { - myTable.getSelectionModel().addSelectionInterval(0,0); + myTable.getSelectionModel().addSelectionInterval(0, 0); } return myPanel; } @@ -273,11 +264,6 @@ public class AutomaticRenamingDialog extends DialogWrapper { } } - private void createUIComponents() { - myTable = new JBTable(); - myTable.setRowHeight(myTable.getFontMetrics(UIManager.getFont("Table.font").deriveFont(Font.BOLD)).getHeight() + 4); - } - private class MyTableModel extends AbstractTableModel { private final boolean myAllowRename; @@ -297,7 +283,7 @@ public class AutomaticRenamingDialog extends DialogWrapper { @Override public Object getValueAt(int rowIndex, int columnIndex) { - switch(columnIndex) { + switch (columnIndex) { case CHECK_COLUMN: return myShouldRename[rowIndex]; case OLD_NAME_COLUMN: @@ -305,22 +291,19 @@ public class AutomaticRenamingDialog extends DialogWrapper { case NEW_NAME_COLUMN: return myNewNames[rowIndex]; default: - LOG.assertTrue(false); return null; } } @Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - switch(columnIndex) { + switch (columnIndex) { case CHECK_COLUMN: myShouldRename[rowIndex] = ((Boolean)aValue).booleanValue(); break; case NEW_NAME_COLUMN: - myNewNames[rowIndex] = (String) aValue; + myNewNames[rowIndex] = (String)aValue; break; - default: - LOG.assertTrue(false); } handleChanges(); } @@ -332,17 +315,21 @@ public class AutomaticRenamingDialog extends DialogWrapper { @Override public Class getColumnClass(int columnIndex) { - switch(columnIndex) { - case CHECK_COLUMN: return Boolean.class; - case OLD_NAME_COLUMN: return String.class; - case NEW_NAME_COLUMN: return String.class; - default: return null; + switch (columnIndex) { + case CHECK_COLUMN: + return Boolean.class; + case OLD_NAME_COLUMN: + return String.class; + case NEW_NAME_COLUMN: + return String.class; + default: + return null; } } @Override public String getColumnName(int column) { - switch(column) { + switch (column) { case OLD_NAME_COLUMN: return RefactoringBundle.message("automatic.renamer.enity.name.column", myRenamer.entityName()); case NEW_NAME_COLUMN: @@ -378,7 +365,6 @@ public class AutomaticRenamingDialog extends DialogWrapper { } public abstract static class RenameSelectedAction extends AnAction { - private final JTable myTable; private final AbstractTableModel myModel; @@ -387,36 +373,34 @@ public class AutomaticRenamingDialog extends DialogWrapper { myTable = table; myModel = model; } - + @Override public void actionPerformed(AnActionEvent e) { - final int[] selectedRows = myTable.getSelectedRows(); - - final String newName = Messages.showInputDialog(myTable, "New name", "Rename Selected", null, - (String)myModel.getValueAt(selectedRows[0], NEW_NAME_COLUMN), - new InputValidatorEx() { - @Override - public boolean checkInput(String inputString) { - return getErrorText(inputString) == null; - } + int[] selectedRows = myTable.getSelectedRows(); + String initial = (String)myModel.getValueAt(selectedRows[0], NEW_NAME_COLUMN); + String newName = Messages.showInputDialog(myTable, "New name", "Rename Selected", null, initial, new InputValidatorEx() { + @Override + public boolean checkInput(String inputString) { + return getErrorText(inputString) == null; + } - @Override - public boolean canClose(String inputString) { - return checkInput(inputString); - } + @Override + public boolean canClose(String inputString) { + return checkInput(inputString); + } - @Nullable - @Override - public String getErrorText(String inputString) { - final int selectedRow = myTable.getSelectedRow(); - if (!isValidName(inputString, selectedRow)) { - return "Identifier \'" + inputString + "\' is invalid"; - } - return null; - } - }); + @Nullable + @Override + public String getErrorText(String inputString) { + final int selectedRow = myTable.getSelectedRow(); + if (!isValidName(inputString, selectedRow)) { + return "Identifier \'" + inputString + "\' is invalid"; + } + return null; + } + }); if (newName == null) return; - + for (int i : selectedRows) { myModel.setValueAt(newName, i, NEW_NAME_COLUMN); } @@ -425,12 +409,12 @@ public class AutomaticRenamingDialog extends DialogWrapper { myTable.getSelectionModel().addSelectionInterval(row, row); } } - + protected abstract boolean isValidName(String inputString, int selectedRow); - + @Override public void update(AnActionEvent e) { e.getPresentation().setEnabled(myTable.getSelectedRows().length > 0); } } -} +} \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java index 3d5731cfdd4b..b10db3122ea2 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java @@ -1,19 +1,4 @@ -/* - * Copyright 2000-2016 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. - */ - +// Copyright 2000-2018 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.refactoring.rename; import com.intellij.lang.findUsages.DescriptiveNameUtil; @@ -52,7 +37,6 @@ import com.intellij.usageView.UsageViewUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -81,14 +65,13 @@ public class RenameProcessor extends BaseRefactoringProcessor { public RenameProcessor(Project project, @NotNull PsiElement element, - @NotNull @NonNls String newName, + @NotNull String newName, boolean isSearchInComments, boolean isSearchTextOccurrences) { super(project); myPrimaryElement = element; assertNonCompileElement(element); - //assertValidName(element, newName); mySearchInComments = isSearchInComments; mySearchTextOccurrences = isSearchTextOccurrences; @@ -231,10 +214,6 @@ public class RenameProcessor extends BaseRefactoringProcessor { public static void assertNonCompileElement(PsiElement element) { LOG.assertTrue(!(element instanceof PsiCompiledElement), element); } - - private void assertValidName(PsiElement element, String newName) { - LOG.assertTrue(RenameUtil.isValidName(myProject, element, newName), "element: " + element + ", newName: " + newName); - } private boolean findRenamedVariables(final List variableUsages) { for (Iterator iterator = myRenamers.iterator(); iterator.hasNext(); ) { @@ -251,8 +230,7 @@ public class RenameProcessor extends BaseRefactoringProcessor { } }); - return ProgressManager.getInstance() - .runProcessWithProgressSynchronously(runnable, RefactoringBundle.message("searching.for.variables"), true, myProject); + return ProgressManager.getInstance().runProcessWithProgressSynchronously(runnable, RefactoringBundle.message("searching.for.variables"), true, myProject); } protected boolean showAutomaticRenamingDialog(AutomaticRenamer automaticVariableRenamer) { @@ -288,19 +266,17 @@ public class RenameProcessor extends BaseRefactoringProcessor { @NotNull public UsageInfo[] findUsages() { myRenamers.clear(); - ArrayList result = new ArrayList<>(); + List result = new ArrayList<>(); - List elements = new ArrayList<>(myAllRenames.keySet()); - //noinspection ForLoopReplaceableByForEach - for (int i = 0; i < elements.size(); i++) { - PsiElement element = elements.get(i); + for (PsiElement element : new ArrayList<>(myAllRenames.keySet())) { if (element == null) { LOG.error("primary: " + myPrimaryElement + "; renamers: " + myRenamers); continue; } - final String newName = myAllRenames.get(element); - final UsageInfo[] usages = RenameUtil.findUsages(element, newName, mySearchInComments, mySearchTextOccurrences, myAllRenames); - final List usagesList = Arrays.asList(usages); + + String newName = myAllRenames.get(element); + UsageInfo[] usages = RenameUtil.findUsages(element, newName, mySearchInComments, mySearchTextOccurrences, myAllRenames); + List usagesList = Arrays.asList(usages); result.addAll(usagesList); for (AutomaticRenamerFactory factory : myRenamerFactories) { @@ -315,6 +291,7 @@ public class RenameProcessor extends BaseRefactoringProcessor { } } } + UsageInfo[] usageInfos = result.toArray(UsageInfo.EMPTY_ARRAY); usageInfos = UsageViewUtil.removeDuplicatedUsages(usageInfos); return usageInfos; @@ -336,10 +313,7 @@ public class RenameProcessor extends BaseRefactoringProcessor { @Override protected boolean isPreviewUsages(@NotNull UsageInfo[] usages) { - if (myForceShowPreview) return true; - if (super.isPreviewUsages(usages)) return true; - if (UsageViewUtil.reportNonRegularUsages(usages, myProject)) return true; - return false; + return myForceShowPreview || super.isPreviewUsages(usages) || UsageViewUtil.reportNonRegularUsages(usages, myProject); } @Nullable @@ -403,20 +377,16 @@ public class RenameProcessor extends BaseRefactoringProcessor { if (!mySkippedUsages.isEmpty()) { if (!ApplicationManager.getApplication().isUnitTestMode() && !ApplicationManager.getApplication().isHeadlessEnvironment()) { ApplicationManager.getApplication().invokeLater(() -> { - final IdeFrame ideFrame = WindowManager.getInstance().getIdeFrame(myProject); + IdeFrame ideFrame = WindowManager.getInstance().getIdeFrame(myProject); if (ideFrame != null) { - StatusBarEx statusBar = (StatusBarEx)ideFrame.getStatusBar(); - HyperlinkListener listener = new HyperlinkListener() { - @Override - public void hyperlinkUpdate(HyperlinkEvent e) { - if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return; - Messages.showMessageDialog("Following usages were safely skipped:
" + - StringUtil.join(mySkippedUsages, unresolvableCollisionUsageInfo -> unresolvableCollisionUsageInfo.getDescription(), "
") + - "", "Not All Usages Were Renamed", null); - } + String message = "Unable to rename certain usages. Browse"; + HyperlinkListener listener = e -> { + if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return; + String skipped = StringUtil.join(mySkippedUsages, unresolvableCollisionUsageInfo -> unresolvableCollisionUsageInfo.getDescription(), "
"); + Messages.showMessageDialog("Following usages were safely skipped:
" + skipped + "", "Not All Usages Were Renamed", null); }; - statusBar.notifyProgressByBalloon(MessageType.WARNING, "Unable to rename certain usages. Browse", null, listener); + statusBar.notifyProgressByBalloon(MessageType.WARNING, message, null, listener); } }, ModalityState.NON_MODAL); } @@ -486,4 +456,4 @@ public class RenameProcessor extends BaseRefactoringProcessor { public void setCommandName(final String commandName) { myCommandName = commandName; } -} +} \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/naming/AutomaticRenamer.java b/platform/lang-impl/src/com/intellij/refactoring/rename/naming/AutomaticRenamer.java index 797333b5f96a..c07f028ced78 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/naming/AutomaticRenamer.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/naming/AutomaticRenamer.java @@ -1,19 +1,4 @@ -/* - * Copyright 2000-2015 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. - */ - +// Copyright 2000-2018 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.refactoring.rename.naming; import com.intellij.openapi.diagnostic.Logger; @@ -34,6 +19,7 @@ import java.util.*; */ public abstract class AutomaticRenamer { private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.rename.naming.AutomaticRenamer"); + private final LinkedHashMap myRenames = new LinkedHashMap<>(); protected final List myElements; @@ -42,11 +28,7 @@ public abstract class AutomaticRenamer { } public boolean hasAnythingToRename() { - final Collection strings = myRenames.values(); - for (final String s : strings) { - if (s != null) return true; - } - return false; + return myRenames.values().stream().anyMatch(Objects::nonNull); } public void findUsages(List result, final boolean searchInStringsAndComments, final boolean searchInNonJavaFiles) { @@ -114,7 +96,7 @@ public abstract class AutomaticRenamer { return myRenames.get(namedElement); } - public Map getRenames() { + public Map getRenames() { return Collections.unmodifiableMap(myRenames); } @@ -184,4 +166,4 @@ public abstract class AutomaticRenamer { public abstract String getDialogDescription(); public abstract String entityName(); -} +} \ No newline at end of file diff --git a/platform/platform-resources-en/src/messages/RefactoringBundle.properties b/platform/platform-resources-en/src/messages/RefactoringBundle.properties index bde578f50941..28e3b31a1c63 100644 --- a/platform/platform-resources-en/src/messages/RefactoringBundle.properties +++ b/platform/platform-resources-en/src/messages/RefactoringBundle.properties @@ -572,7 +572,7 @@ move.file.0=Move file {0} move.directory.0=Move directory {0} move.files.to.directory.label=To directory: the.file.will.be.moved.to.this.directory=File will be moved to this directory -searching.for.variables=Searching for variables +searching.for.variables=Searching for Variables searching.for.duplicates=Searching for Duplicates... no.usages.can.be.replaced=No usages of {0} \ncan be replaced with usages of {1} turn.refs.to.super.command=Replacing usages of {0} with {1}