mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (warnings; formatting)
This commit is contained in:
+15
-24
@@ -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<OrderRootType, VirtualFilePointerContainer> myOrderRootPointerContainers = new THashMap<>();
|
||||
private JavaModuleExternalPathsImpl mySource;
|
||||
private static final String ROOT_ELEMENT = JpsJavaModelSerializerExtension.ROOT_TAG;
|
||||
|
||||
private final Map<OrderRootType, VirtualFilePointerContainer> 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() { }
|
||||
}
|
||||
@@ -21,10 +21,12 @@ public class RenameJavaModuleProcessor extends RenamePsiElementProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findCollisions(@NotNull PsiElement element, @NotNull String newName, @NotNull Map<? extends PsiElement, String> allRenames, @NotNull List<UsageInfo> result) {
|
||||
public void findCollisions(@NotNull PsiElement element,
|
||||
@NotNull String newName,
|
||||
@NotNull Map<? extends PsiElement, String> allRenames,
|
||||
@NotNull List<UsageInfo> 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
|
||||
|
||||
+19
-19
@@ -20,14 +20,6 @@
|
||||
</properties>
|
||||
<border type="empty"/>
|
||||
<children>
|
||||
<grid id="30730" binding="myPanelForPreview" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<splitpane position="right"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="177e3" layout-manager="GridBagLayout">
|
||||
<constraints>
|
||||
<splitpane position="left"/>
|
||||
@@ -37,7 +29,7 @@
|
||||
<children>
|
||||
<scrollpane id="86224" class="com.intellij.ui.components.JBScrollPane">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="6" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="1.0" weighty="1.0"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
@@ -51,21 +43,12 @@
|
||||
</scrollpane>
|
||||
<grid id="6e08e" layout-manager="GridBagLayout">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="6" vsize-policy="3" hsize-policy="3" anchor="4" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="4" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="1217e" class="javax.swing.JButton" binding="myUnselectAllButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<gridbag top="0" left="5" bottom="0" right="0" weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/RefactoringBundle" key="unselect.all.button"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c4746" class="javax.swing.JButton" binding="mySelectAllButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||
@@ -75,10 +58,27 @@
|
||||
<text resource-bundle="messages/RefactoringBundle" key="select.all.button"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="1217e" class="javax.swing.JButton" binding="myUnselectAllButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<gridbag top="0" left="5" bottom="0" right="0" weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/RefactoringBundle" key="unselect.all.button"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="30730" binding="myPanelForPreview" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<splitpane position="right"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</splitpane>
|
||||
</children>
|
||||
|
||||
+82
-98
@@ -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<PsiNamedElement, String> renames = myRenamer.getRenames();
|
||||
Map<PsiNamedElement, String> renames = renamer.getRenames();
|
||||
|
||||
List<PsiNamedElement> 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<myShouldRename.length; i++) {
|
||||
myShouldRename [i] = true;
|
||||
if (renamer.isSelectedByDefault()) {
|
||||
for (int i = 0; i < myShouldRename.length; i++) {
|
||||
myShouldRename[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
myTableModel = new MyTableModel(renamer.allowChangeSuggestedName());
|
||||
|
||||
setTitle(renamer.getDialogTitle());
|
||||
init();
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
myTable = new JBTable();
|
||||
myTable.setRowHeight(myTable.getFontMetrics(UIManager.getFont("Table.font").deriveFont(Font.BOLD)).getHeight() + 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,8 +119,9 @@ public class AutomaticRenamingDialog extends DialogWrapper {
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
super.show();
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
super.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleChanges() {
|
||||
@@ -151,24 +139,26 @@ public class AutomaticRenamingDialog extends DialogWrapper {
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
myUsagePreviewPanel = new UsagePreviewPanel(myProject, new UsageViewPresentation());
|
||||
myUsageFileLabel = new JLabel();
|
||||
|
||||
myTable.setModel(myTableModel);
|
||||
myTableModel.getSpaceAction().register();
|
||||
myTableModel.addTableModelListener(e -> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<UsageInfo> variableUsages) {
|
||||
for (Iterator<AutomaticRenamer> 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<UsageInfo> result = new ArrayList<>();
|
||||
List<UsageInfo> result = new ArrayList<>();
|
||||
|
||||
List<PsiElement> 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<UsageInfo> usagesList = Arrays.asList(usages);
|
||||
|
||||
String newName = myAllRenames.get(element);
|
||||
UsageInfo[] usages = RenameUtil.findUsages(element, newName, mySearchInComments, mySearchTextOccurrences, myAllRenames);
|
||||
List<UsageInfo> 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("<html>Following usages were safely skipped:<br>" +
|
||||
StringUtil.join(mySkippedUsages, unresolvableCollisionUsageInfo -> unresolvableCollisionUsageInfo.getDescription(), "<br>") +
|
||||
"</html>", "Not All Usages Were Renamed", null);
|
||||
}
|
||||
String message = "<html><body>Unable to rename certain usages. <a href=\"\">Browse</a></body></html>";
|
||||
HyperlinkListener listener = e -> {
|
||||
if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return;
|
||||
String skipped = StringUtil.join(mySkippedUsages, unresolvableCollisionUsageInfo -> unresolvableCollisionUsageInfo.getDescription(), "<br>");
|
||||
Messages.showMessageDialog("<html>Following usages were safely skipped:<br>" + skipped + "</html>", "Not All Usages Were Renamed", null);
|
||||
};
|
||||
statusBar.notifyProgressByBalloon(MessageType.WARNING, "<html><body>Unable to rename certain usages. <a href=\"\">Browse</a></body></html>", 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-23
@@ -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<PsiNamedElement, String> myRenames = new LinkedHashMap<>();
|
||||
protected final List<PsiNamedElement> myElements;
|
||||
|
||||
@@ -42,11 +28,7 @@ public abstract class AutomaticRenamer {
|
||||
}
|
||||
|
||||
public boolean hasAnythingToRename() {
|
||||
final Collection<String> 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<UsageInfo> result, final boolean searchInStringsAndComments, final boolean searchInNonJavaFiles) {
|
||||
@@ -114,7 +96,7 @@ public abstract class AutomaticRenamer {
|
||||
return myRenames.get(namedElement);
|
||||
}
|
||||
|
||||
public Map<PsiNamedElement,String> getRenames() {
|
||||
public Map<PsiNamedElement, String> getRenames() {
|
||||
return Collections.unmodifiableMap(myRenames);
|
||||
}
|
||||
|
||||
@@ -184,4 +166,4 @@ public abstract class AutomaticRenamer {
|
||||
public abstract String getDialogDescription();
|
||||
|
||||
public abstract String entityName();
|
||||
}
|
||||
}
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user