mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -19,7 +19,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.ex.temp.TempFileSystem;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScopes;
|
||||
import com.intellij.util.indexing.*;
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
import org.intellij.images.fileTypes.ImageFileTypeManager;
|
||||
@@ -71,7 +71,8 @@ public class ImageInfoIndex extends SingleEntryFileBasedIndexExtension<ImageInfo
|
||||
}
|
||||
|
||||
public static void processValues(VirtualFile virtualFile, FileBasedIndex.ValueProcessor<ImageInfo> processor, Project project) {
|
||||
FileBasedIndex.getInstance().processValues(INDEX_ID, Math.abs(FileBasedIndex.getFileId(virtualFile)), virtualFile, processor, GlobalSearchScope.fileScope(project, virtualFile));
|
||||
FileBasedIndex.getInstance().processValues(INDEX_ID, Math.abs(FileBasedIndex.getFileId(virtualFile)), virtualFile, processor, GlobalSearchScopes
|
||||
.fileScope(project, virtualFile));
|
||||
}
|
||||
|
||||
public DataExternalizer<ImageInfo> getValueExternalizer() {
|
||||
|
||||
+4
-2
@@ -60,6 +60,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScopes;
|
||||
import com.intellij.util.Chunk;
|
||||
import com.intellij.util.cls.ClsFormatException;
|
||||
import gnu.trove.THashMap;
|
||||
@@ -345,7 +346,7 @@ public class BackendCompilerWrapper {
|
||||
return; // should not invoke javac with empty sources list
|
||||
}
|
||||
|
||||
ModuleType moduleType = chunk.getModules()[0].getModuleType();
|
||||
ModuleType moduleType = ModuleType.get(chunk.getModules()[0]);
|
||||
if (!(chunk.getJdk().getSdkType() instanceof JavaSdkType) &&
|
||||
!(moduleType instanceof JavaModuleType || moduleType.createModuleBuilder() instanceof JavaModuleBuilder)) {
|
||||
// TODO
|
||||
@@ -584,7 +585,8 @@ public class BackendCompilerWrapper {
|
||||
final String packagePrefix, final List<File> filesToRefresh, final Map<String, Collection<TranslatingCompiler.OutputItem>> results) throws CacheCorruptedException {
|
||||
final Ref<CacheCorruptedException> exRef = new Ref<CacheCorruptedException>(null);
|
||||
final ModuleFileIndex fileIndex = ModuleRootManager.getInstance(module).getFileIndex();
|
||||
final GlobalSearchScope srcRootScope = GlobalSearchScope.moduleScope(module).intersectWith(GlobalSearchScope.directoryScope(myProject, sourceRoot, true));
|
||||
final GlobalSearchScope srcRootScope = GlobalSearchScope.moduleScope(module).intersectWith(
|
||||
GlobalSearchScopes.directoryScope(myProject, sourceRoot, true));
|
||||
|
||||
final ContentIterator contentIterator = new ContentIterator() {
|
||||
public boolean processFile(final VirtualFile child) {
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ class ChangedConstantsDependencyProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
final PsiSearchHelper psiSearchHelper = PsiManager.getInstance(myProject).getSearchHelper();
|
||||
final PsiSearchHelper psiSearchHelper = PsiSearchHelper.SERVICE.getInstance(myProject);
|
||||
|
||||
final Ref<CacheCorruptedException> exRef = new Ref<CacheCorruptedException>(null);
|
||||
final long analysisStart = System.currentTimeMillis();
|
||||
|
||||
+41
-40
@@ -13,12 +13,10 @@ import com.intellij.openapi.ui.ex.MultiLineLabel;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.TableUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.ui.ItemRemovable;
|
||||
import com.intellij.util.ui.Table;
|
||||
import com.intellij.util.ui.EditableModel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -50,9 +48,8 @@ public class AnnotationProcessorsConfigurable implements SearchableConfigurable
|
||||
private TextFieldWithBrowseButton myProcessorPathField;
|
||||
private ProcessorTableModel myProcessorsModel;
|
||||
private JCheckBox myCbEnableProcessing;
|
||||
private JButton myRemoveButton;
|
||||
private Table myProcessorTable;
|
||||
private JButton myAddButton;
|
||||
private JBTable myProcessorTable;
|
||||
private JPanel myProcessorPanel;
|
||||
|
||||
public AnnotationProcessorsConfigurable(final Project project) {
|
||||
myProject = project;
|
||||
@@ -110,16 +107,28 @@ public class AnnotationProcessorsConfigurable implements SearchableConfigurable
|
||||
final JPanel processorTablePanel = new JPanel(new BorderLayout());
|
||||
myProcessorsModel = new ProcessorTableModel();
|
||||
processorTablePanel.setBorder(IdeBorderFactory.createTitledBorder("Annotation Processors", false, false, true));
|
||||
myProcessorTable = new Table(myProcessorsModel);
|
||||
myProcessorTable = new JBTable(myProcessorsModel);
|
||||
myProcessorTable.getEmptyText().setText("No processors configured");
|
||||
myProcessorPanel = ToolbarDecorator.createDecorator(myProcessorTable)
|
||||
.disableUpAction()
|
||||
.disableDownAction()
|
||||
.setAddAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton anActionButton) {
|
||||
final TableCellEditor cellEditor = myProcessorTable.getCellEditor();
|
||||
if (cellEditor != null) {
|
||||
cellEditor.stopCellEditing();
|
||||
}
|
||||
final ProcessorTableModel model = (ProcessorTableModel)myProcessorTable.getModel();
|
||||
model.addRow();
|
||||
TableUtil.editCellAt(myProcessorTable, model.getRowCount() - 1, ProcessorTableRow.NAME_COLUMN);
|
||||
}
|
||||
})
|
||||
.createPanel();
|
||||
|
||||
processorTablePanel.add(ScrollPaneFactory.createScrollPane(myProcessorTable), BorderLayout.CENTER);
|
||||
final JPanel buttons = new JPanel(new GridBagLayout());
|
||||
myAddButton = new JButton("Add");
|
||||
buttons.add(myAddButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
|
||||
myRemoveButton = new JButton("Remove");
|
||||
buttons.add(myRemoveButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 0), 0, 0));
|
||||
processorTablePanel.add(buttons, BorderLayout.EAST);
|
||||
|
||||
|
||||
processorTablePanel.add(myProcessorPanel, BorderLayout.CENTER);
|
||||
processorTablePanel.setPreferredSize(new Dimension(processorTablePanel.getPreferredSize().width, 50));
|
||||
|
||||
myModulesTable = new ProcessedModulesTable(myProject);
|
||||
@@ -157,23 +166,6 @@ public class AnnotationProcessorsConfigurable implements SearchableConfigurable
|
||||
}
|
||||
}
|
||||
});
|
||||
myAddButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final TableCellEditor cellEditor = myProcessorTable.getCellEditor();
|
||||
if (cellEditor != null) {
|
||||
cellEditor.stopCellEditing();
|
||||
}
|
||||
final ProcessorTableModel model = (ProcessorTableModel)myProcessorTable.getModel();
|
||||
final int inserdedIndex = model.addRow();
|
||||
TableUtil.editCellAt(myProcessorTable, inserdedIndex, ProcessorTableRow.NAME_COLUMN);
|
||||
}
|
||||
});
|
||||
|
||||
myRemoveButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
TableUtil.removeSelectedItems(myProcessorTable);
|
||||
}
|
||||
});
|
||||
|
||||
myCbEnableProcessing.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
@@ -192,8 +184,14 @@ public class AnnotationProcessorsConfigurable implements SearchableConfigurable
|
||||
myRbClasspath.setEnabled(enabled);
|
||||
myRbProcessorsPath.setEnabled(enabled);
|
||||
myProcessorPathField.setEnabled(enabled && useProcessorpath);
|
||||
myRemoveButton.setEnabled(enabled && myProcessorTable.getSelectedRow() >= 0);
|
||||
myAddButton.setEnabled(enabled);
|
||||
final AnActionButton addButton = ToolbarDecorator.findAddButton(myProcessorPanel);
|
||||
if (addButton != null) {
|
||||
addButton.setEnabled(enabled);
|
||||
}
|
||||
final AnActionButton removeButton = ToolbarDecorator.findRemoveButton(myProcessorPanel);
|
||||
if (removeButton != null) {
|
||||
removeButton.setEnabled(enabled && myProcessorTable.getSelectedRow() >= 0);
|
||||
}
|
||||
myProcessorTable.setEnabled(enabled);
|
||||
final JTableHeader header = myProcessorTable.getTableHeader();
|
||||
if (header != null) {
|
||||
@@ -278,7 +276,7 @@ public class AnnotationProcessorsConfigurable implements SearchableConfigurable
|
||||
public void disposeUIResources() {
|
||||
}
|
||||
|
||||
private static class ProcessorTableModel extends AbstractTableModel implements ItemRemovable{
|
||||
private static class ProcessorTableModel extends AbstractTableModel implements EditableModel {
|
||||
private final java.util.List<ProcessorTableRow> myRows = new ArrayList<ProcessorTableRow>();
|
||||
|
||||
public String getColumnName(int column) {
|
||||
@@ -333,11 +331,14 @@ public class AnnotationProcessorsConfigurable implements SearchableConfigurable
|
||||
fireTableRowsDeleted(idx, idx);
|
||||
}
|
||||
|
||||
public int addRow() {
|
||||
@Override
|
||||
public void exchangeRows(int oldIndex, int newIndex) {
|
||||
}
|
||||
|
||||
public void addRow() {
|
||||
myRows.add(new ProcessorTableRow());
|
||||
final int inserted = myRows.size() - 1;
|
||||
fireTableRowsInserted(inserted, inserted);
|
||||
return inserted;
|
||||
final int index = myRows.size() - 1;
|
||||
fireTableRowsInserted(index, index);
|
||||
}
|
||||
|
||||
public void setProcessorMap(Map<String, String> processorMap) {
|
||||
|
||||
@@ -17,45 +17,40 @@ package com.intellij.compiler.options;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.SpeedSearchBase;
|
||||
import com.intellij.ui.TableUtil;
|
||||
import com.intellij.util.ui.ItemRemovable;
|
||||
import com.intellij.util.ui.Table;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.ui.EditableModel;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class ProcessedModulesTable extends JPanel {
|
||||
private Table myTable = null;
|
||||
private JBTable myTable = null;
|
||||
private MyTableModel myTableModel = null;
|
||||
|
||||
public ProcessedModulesTable(final Project project) {
|
||||
super(new BorderLayout());
|
||||
|
||||
myTableModel = new MyTableModel();
|
||||
myTable = new Table(myTableModel);
|
||||
myTableModel = new MyTableModel(project);
|
||||
myTable = new JBTable(myTableModel);
|
||||
myTable.getEmptyText().setText("No modules configured");
|
||||
|
||||
//myTable.setShowGrid(false);
|
||||
myTable.setIntercellSpacing(new Dimension(0, 0));
|
||||
myTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
||||
myTable.setColumnSelectionAllowed(false);
|
||||
JScrollPane pane = ScrollPaneFactory.createScrollPane(myTable);
|
||||
pane.setPreferredSize(new Dimension(100, 155));
|
||||
|
||||
final TableColumnModel columnModel = myTable.getColumnModel();
|
||||
|
||||
@@ -73,42 +68,13 @@ public class ProcessedModulesTable extends JPanel {
|
||||
moduleColumn.setHeaderValue("Module");
|
||||
moduleColumn.setCellRenderer(new MyElementColumnCellRenderer());
|
||||
|
||||
add(pane, BorderLayout.CENTER);
|
||||
final JPanel panel = ToolbarDecorator.createDecorator(myTable)
|
||||
.disableUpDownActions()
|
||||
.setPreferredSize(new Dimension(100, 155))
|
||||
.createPanel();
|
||||
add(panel, BorderLayout.CENTER);
|
||||
|
||||
final JButton addButton = new JButton("Add");
|
||||
addButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final Set<Module> projectModules = new HashSet<Module>(Arrays.asList(ModuleManager.getInstance(project).getModules()));
|
||||
projectModules.removeAll(myTableModel.getAllModules());
|
||||
final ChooseModulesDialog chooser = new ChooseModulesDialog(ProcessedModulesTable.this, new ArrayList<Module>(projectModules), "ChooseModule");
|
||||
chooser.show();
|
||||
if (chooser.isOK()) {
|
||||
final List<Module> chosen = chooser.getChosenElements();
|
||||
for (Module module : chosen) {
|
||||
myTableModel.addElement(module, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
final JButton removeButton = new JButton("Remove");
|
||||
myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
removeButton.setEnabled(myTable.getSelectedRowCount() > 0);
|
||||
}
|
||||
});
|
||||
removeButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
TableUtil.removeSelectedItems(myTable);
|
||||
}
|
||||
});
|
||||
|
||||
final JPanel buttonPanel = new JPanel(new GridBagLayout());
|
||||
buttonPanel.add(addButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 6, 0, 0), 0, 0));
|
||||
buttonPanel.add(removeButton, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(5, 6, 0, 0), 0, 0));
|
||||
add(buttonPanel, BorderLayout.EAST);
|
||||
|
||||
final SpeedSearchBase<Table> speedSearch = new SpeedSearchBase<Table>(myTable) {
|
||||
final SpeedSearchBase<JBTable> speedSearch = new SpeedSearchBase<JBTable>(myTable) {
|
||||
public int getSelectedIndex() {
|
||||
return myTable.getSelectedRow();
|
||||
}
|
||||
@@ -291,11 +257,16 @@ public class ProcessedModulesTable extends JPanel {
|
||||
return myTableModel.getModuleAt(row);
|
||||
}
|
||||
|
||||
private final class MyTableModel extends AbstractTableModel implements ItemRemovable {
|
||||
private final class MyTableModel extends AbstractTableModel implements EditableModel {
|
||||
private final List<Module> myElements = new ArrayList<Module>();
|
||||
private final Map<Module, String> myDirNameMap = new HashMap<Module, String>();
|
||||
public final int ELEMENT_COLUMN_INDEX = 0;
|
||||
public final int DIRNAME_COLUMN_INDEX = 1;
|
||||
private final Project myProject;
|
||||
|
||||
private MyTableModel(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public void sort(Comparator<Module> comparator) {
|
||||
Collections.sort(myElements, comparator);
|
||||
@@ -323,12 +294,30 @@ public class ProcessedModulesTable extends JPanel {
|
||||
fireTableRowsInserted(row, row);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRow() {
|
||||
final Set<Module> projectModules = new HashSet<Module>(Arrays.asList(ModuleManager.getInstance(myProject).getModules()));
|
||||
projectModules.removeAll(getAllModules());
|
||||
final ChooseModulesDialog chooser = new ChooseModulesDialog(ProcessedModulesTable.this, new ArrayList<Module>(projectModules), "ChooseModule");
|
||||
chooser.show();
|
||||
if (chooser.isOK()) {
|
||||
final List<Module> chosen = chooser.getChosenElements();
|
||||
for (Module module : chosen) {
|
||||
addElement(module, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeRow(int idx) {
|
||||
final Module element = myElements.remove(idx);
|
||||
myDirNameMap.remove(element);
|
||||
fireTableRowsDeleted(idx, idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exchangeRows(int oldIndex, int newIndex) {
|
||||
}
|
||||
|
||||
public void removeElement(Module element) {
|
||||
final boolean reallyRemoved = myElements.remove(element);
|
||||
if (reallyRemoved) {
|
||||
@@ -432,7 +421,7 @@ public class ProcessedModulesTable extends JPanel {
|
||||
}
|
||||
component.setEnabled(ProcessedModulesTable.this.isEnabled());
|
||||
if (component instanceof JLabel) {
|
||||
final Icon icon = module != null ? module.getModuleType().getNodeIcon(false) : null;
|
||||
final Icon icon = module != null ? ModuleType.get(module).getNodeIcon(false) : null;
|
||||
JLabel label = (JLabel)component;
|
||||
label.setIcon(icon);
|
||||
label.setDisabledIcon(icon);
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.compiler.CompilerMessageCategory;
|
||||
import com.intellij.openapi.compiler.make.BuildRecipe;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
@@ -119,7 +120,7 @@ public class DeploymentUtilImpl extends DeploymentUtil {
|
||||
}
|
||||
|
||||
public void reportDeploymentDescriptorDoesNotExists(ConfigFile descriptor, CompileContext context, Module module) {
|
||||
final String description = module.getModuleType().getName() + " '" + module.getName() + '\'';
|
||||
final String description = ModuleType.get(module).getName() + " '" + module.getName() + '\'';
|
||||
String descriptorPath = VfsUtil.urlToPath(descriptor.getUrl());
|
||||
final String message =
|
||||
CompilerBundle.message("message.text.compiling.item.deployment.descriptor.could.not.be.found", description, descriptorPath);
|
||||
@@ -130,7 +131,7 @@ public class DeploymentUtilImpl extends DeploymentUtil {
|
||||
if (new File(VfsUtil.urlToPath(descriptor.getUrl())).exists()) {
|
||||
String message = getConfigFileErrorMessage(descriptor);
|
||||
if (message != null) {
|
||||
final String moduleDescription = module.getModuleType().getName() + " '" + module.getName() + '\'';
|
||||
final String moduleDescription = ModuleType.get(module).getName() + " '" + module.getName() + '\'';
|
||||
compileContext.addMessage(CompilerMessageCategory.ERROR,
|
||||
CompilerBundle.message("message.text.compiling.module.message", moduleDescription, message),
|
||||
descriptor.getUrl(), -1, -1);
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@ package com.intellij.packaging.impl.artifacts;
|
||||
|
||||
import com.intellij.ide.ui.ListCellRendererWrapper;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesAlphaComparator;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
@@ -165,7 +166,7 @@ public class JarArtifactFromModulesDialog extends DialogWrapper {
|
||||
@Override
|
||||
public void customize(JList list, Module value, int index, boolean selected, boolean hasFocus) {
|
||||
if (value != null) {
|
||||
setIcon(value.getModuleType().getNodeIcon(false));
|
||||
setIcon(ModuleType.get(value).getNodeIcon(false));
|
||||
setText(value.getName());
|
||||
}
|
||||
else {
|
||||
|
||||
+3
-2
@@ -20,6 +20,7 @@ import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModulePointer;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.packaging.ui.ArtifactEditorContext;
|
||||
import com.intellij.packaging.ui.PackagingElementWeights;
|
||||
import com.intellij.packaging.ui.TreeNodePresentation;
|
||||
@@ -70,8 +71,8 @@ public class ModuleElementPresentation extends TreeNodePresentation {
|
||||
presentationData.setIcons(PlatformIcons.TEST_SOURCE_FOLDER);
|
||||
}
|
||||
else if (module != null) {
|
||||
presentationData.setOpenIcon(module.getModuleType().getNodeIcon(true));
|
||||
presentationData.setClosedIcon(module.getModuleType().getNodeIcon(false));
|
||||
presentationData.setOpenIcon(ModuleType.get(module).getNodeIcon(true));
|
||||
presentationData.setClosedIcon(ModuleType.get(module).getNodeIcon(false));
|
||||
}
|
||||
String moduleName;
|
||||
if (module != null) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.execution.configurations.ModuleBasedConfiguration;
|
||||
import com.intellij.ide.ui.ListCellRendererWrapper;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.module.ModuleTypeManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiClass;
|
||||
@@ -66,7 +67,7 @@ public class ConfigurationModuleSelector {
|
||||
public void customize(final JList list, final Object value, final int index, final boolean selected, final boolean hasFocus) {
|
||||
if (value instanceof Module) {
|
||||
final Module module = (Module)value;
|
||||
setIcon(module.getModuleType().getNodeIcon(true));
|
||||
setIcon(ModuleType.get(module).getNodeIcon(true));
|
||||
setText(module.getName());
|
||||
}
|
||||
else if (value == null) {
|
||||
@@ -91,7 +92,7 @@ public class ConfigurationModuleSelector {
|
||||
}
|
||||
|
||||
public static boolean isModuleAccepted(final Module module) {
|
||||
return ModuleTypeManager.getInstance().isClasspathProvider(module.getModuleType());
|
||||
return ModuleTypeManager.getInstance().isClasspathProvider(ModuleType.get(module));
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class FrameworkSupportUtil {
|
||||
}
|
||||
|
||||
public static List<FrameworkSupportProvider> getProviders(@NotNull Module module) {
|
||||
return getProviders(module.getModuleType(), module);
|
||||
return getProviders(ModuleType.get(module), module);
|
||||
}
|
||||
|
||||
private static List<FrameworkSupportProvider> getProviders(@NotNull ModuleType moduleType, @Nullable Module module) {
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ package com.intellij.openapi.roots.ui.configuration;
|
||||
import com.intellij.openapi.module.JavaModuleType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleConfigurationEditor;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -27,7 +28,7 @@ public class DefaultModuleEditorsProvider implements ModuleConfigurationEditorPr
|
||||
public ModuleConfigurationEditor[] createEditors(ModuleConfigurationState state) {
|
||||
ModifiableRootModel rootModel = state.getRootModel();
|
||||
Module module = rootModel.getModule();
|
||||
if (!(module.getModuleType() instanceof JavaModuleType)) {
|
||||
if (!(ModuleType.get(module) instanceof JavaModuleType)) {
|
||||
return ModuleConfigurationEditor.EMPTY;
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -68,7 +68,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
private final UIState myUiState = new UIState();
|
||||
private Splitter mySplitter;
|
||||
private JComponent myToolbarComponent;
|
||||
@NonNls private static final String CATEGORY = "category";
|
||||
@NonNls public static final String CATEGORY = "category";
|
||||
private JComponent myToFocus;
|
||||
private boolean myWasUiDisposed;
|
||||
private ConfigurationErrorsComponent myErrorsComponent;
|
||||
@@ -324,6 +324,10 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
}
|
||||
}
|
||||
|
||||
public void hideSidePanel() {
|
||||
mySplitter.getFirstComponent().setVisible(false);
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
if (!myWasIntialized) return;
|
||||
final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject);
|
||||
|
||||
+3
-2
@@ -17,6 +17,7 @@ package com.intellij.openapi.roots.ui.configuration.artifacts.sourceItems;
|
||||
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.roots.DependencyScope;
|
||||
import com.intellij.openapi.roots.ModuleOrderEntry;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
@@ -122,8 +123,8 @@ public class ModuleSourceItemGroup extends PackagingSourceItem {
|
||||
@Override
|
||||
public void render(@NotNull PresentationData presentationData, SimpleTextAttributes mainAttributes,
|
||||
SimpleTextAttributes commentAttributes) {
|
||||
presentationData.setClosedIcon(myModule.getModuleType().getNodeIcon(false));
|
||||
presentationData.setOpenIcon(myModule.getModuleType().getNodeIcon(true));
|
||||
presentationData.setClosedIcon(ModuleType.get(myModule).getNodeIcon(false));
|
||||
presentationData.setOpenIcon(ModuleType.get(myModule).getNodeIcon(true));
|
||||
presentationData.addText(myModule.getName(), mainAttributes);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.roots.ModuleRootEvent;
|
||||
@@ -617,7 +618,7 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
return new CellAppearance() {
|
||||
@Override
|
||||
public void customize(SimpleColoredComponent component) {
|
||||
component.setIcon(myModule.getModuleType().getNodeIcon(false));
|
||||
component.setIcon(ModuleType.get(myModule).getNodeIcon(false));
|
||||
component.append("<This Module>", SimpleTextAttributes.SYNTHETIC_ATTRIBUTES);
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -24,6 +24,7 @@ import com.intellij.ide.util.ChooseElementsDialog;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog;
|
||||
@@ -68,7 +69,7 @@ class AddFacetOfTypeAction extends DumbAwareAction {
|
||||
final ProjectFacetsConfigurator facetsConfigurator = myContext.getModulesConfigurator().getFacetsConfigurator();
|
||||
List<Facet> suitableParents = new ArrayList<Facet>();
|
||||
for (Module module : myContext.getModules()) {
|
||||
if (type.isSuitableModuleType(module.getModuleType())) {
|
||||
if (type.isSuitableModuleType(ModuleType.get(module))) {
|
||||
suitableParents.addAll(facetsConfigurator.getFacetsByType(module, underlyingType));
|
||||
}
|
||||
}
|
||||
@@ -104,7 +105,7 @@ class AddFacetOfTypeAction extends DumbAwareAction {
|
||||
final Iterator<Module> iterator = suitableModules.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Module module = iterator.next();
|
||||
if (!type.isSuitableModuleType(module.getModuleType()) || (type.isOnlyOneFacetAllowed() && facetsConfigurator.hasFacetOfType(module, null, type.getId()))) {
|
||||
if (!type.isSuitableModuleType(ModuleType.get(module)) || (type.isOnlyOneFacetAllowed() && facetsConfigurator.hasFacetOfType(module, null, type.getId()))) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
@@ -139,7 +140,7 @@ class AddFacetOfTypeAction extends DumbAwareAction {
|
||||
|
||||
private static boolean hasSuitableModules(StructureConfigurableContext context, FacetType type) {
|
||||
for (Module module : context.getModules()) {
|
||||
if (type.isSuitableModuleType(module.getModuleType())) {
|
||||
if (type.isSuitableModuleType(ModuleType.get(module))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+36
-21
@@ -368,12 +368,7 @@ public abstract class BaseStructureConfigurable extends MasterDetailsComponent i
|
||||
if (object instanceof MyNode) {
|
||||
final NamedConfigurable namedConfigurable = ((MyNode)object).getConfigurable();
|
||||
if (namedConfigurable != null) {
|
||||
final Object editableObject = namedConfigurable.getEditableObject();
|
||||
if (editableObject instanceof Sdk || editableObject instanceof Module || editableObject instanceof Facet || editableObject instanceof Artifact) return true;
|
||||
if (editableObject instanceof Library) {
|
||||
final LibraryTable table = ((Library)editableObject).getTable();
|
||||
return table == null || table.isEditable();
|
||||
}
|
||||
return canBeRemoved(namedConfigurable.getEditableObject());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -402,23 +397,43 @@ public abstract class BaseStructureConfigurable extends MasterDetailsComponent i
|
||||
final MyNode node = (MyNode)last;
|
||||
final NamedConfigurable configurable = node.getConfigurable();
|
||||
final Object editableObject = configurable.getEditableObject();
|
||||
if (editableObject instanceof Sdk) {
|
||||
removeJdk((Sdk)editableObject);
|
||||
}
|
||||
else if (editableObject instanceof Module) {
|
||||
if (!removeModule((Module)editableObject)) return false;
|
||||
}
|
||||
else if (editableObject instanceof Facet) {
|
||||
if (removeFacet((Facet)editableObject).isEmpty()) return false;
|
||||
}
|
||||
else if (editableObject instanceof Library) {
|
||||
if (!removeLibrary((Library)editableObject)) return false;
|
||||
}
|
||||
else if (editableObject instanceof Artifact) {
|
||||
removeArtifact((Artifact)editableObject);
|
||||
}
|
||||
|
||||
return removeObject(editableObject);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean canBeRemoved(final Object editableObject) {
|
||||
if (editableObject instanceof Sdk ||
|
||||
editableObject instanceof Module ||
|
||||
editableObject instanceof Facet ||
|
||||
editableObject instanceof Artifact) {
|
||||
return true;
|
||||
}
|
||||
if (editableObject instanceof Library) {
|
||||
final LibraryTable table = ((Library)editableObject).getTable();
|
||||
return table == null || table.isEditable();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean removeObject(final Object editableObject) {
|
||||
// todo keep only removeModule() and removeFacet() here because other removeXXX() are empty here and overridden in subclasses? Override removeObject() instead?
|
||||
if (editableObject instanceof Sdk) {
|
||||
removeJdk((Sdk)editableObject);
|
||||
}
|
||||
else if (editableObject instanceof Module) {
|
||||
if (!removeModule((Module)editableObject)) return false;
|
||||
}
|
||||
else if (editableObject instanceof Facet) {
|
||||
if (removeFacet((Facet)editableObject).isEmpty()) return false;
|
||||
}
|
||||
else if (editableObject instanceof Library) {
|
||||
if (!removeLibrary((Library)editableObject)) return false;
|
||||
}
|
||||
else if (editableObject instanceof Artifact) {
|
||||
removeArtifact((Artifact)editableObject);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void removeArtifact(Artifact artifact) {
|
||||
|
||||
+1
-1
@@ -181,7 +181,7 @@ public class FacetEditorFacadeImpl implements FacetEditorFacade {
|
||||
@Nullable
|
||||
public ModuleType getSelectedModuleType() {
|
||||
final Module module = getSelectedModule();
|
||||
return module != null ? module.getModuleType() : null;
|
||||
return module != null ? ModuleType.get(module) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+3
-2
@@ -18,6 +18,7 @@ package com.intellij.openapi.roots.ui.configuration.projectRoot;
|
||||
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.module.ModuleWithNameAlreadyExists;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
@@ -91,11 +92,11 @@ public class ModuleConfigurable extends ProjectStructureElementConfigurable<Modu
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
return myModule.getModuleType().getNodeIcon(false);
|
||||
return ModuleType.get(myModule).getNodeIcon(false);
|
||||
}
|
||||
|
||||
public Icon getIcon(final boolean open) {
|
||||
return myModule.getModuleType().getNodeIcon(open);
|
||||
return ModuleType.get(myModule).getNodeIcon(open);
|
||||
}
|
||||
|
||||
public Module getModule() {
|
||||
|
||||
+92
-6
@@ -54,6 +54,7 @@ import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.NamedConfigurable;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
@@ -218,8 +219,9 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
for (final Module module : modules) {
|
||||
ModuleConfigurable configurable = new ModuleConfigurable(myContext.myModulesConfigurator, module, TREE_UPDATER);
|
||||
final MyNode moduleNode = new MyNode(configurable);
|
||||
final boolean facetsExist = myFacetEditorFacade.addFacetsNodes(module, moduleNode);
|
||||
if (facetsExist) {
|
||||
boolean nodesAdded = myFacetEditorFacade.addFacetsNodes(module, moduleNode);
|
||||
nodesAdded |= addNodesFromExtensions(module, moduleNode);
|
||||
if (nodesAdded) {
|
||||
myTree.setShowsRootHandles(true);
|
||||
}
|
||||
final String[] groupPath = myPlainMode ? null : myContext.myModulesConfigurator.getModuleModel().getModuleGroupPath(module);
|
||||
@@ -254,6 +256,14 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
//myProjectNode.add(myLevel2Nodes.get(LibraryTablesRegistrar.PROJECT_LEVEL));
|
||||
}
|
||||
|
||||
private boolean addNodesFromExtensions(final Module module, final MyNode moduleNode) {
|
||||
boolean nodesAdded= false;
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
nodesAdded |= extension.addModuleNodeChildren(module, moduleNode, TREE_UPDATER);
|
||||
}
|
||||
return nodesAdded;
|
||||
}
|
||||
|
||||
public boolean updateProjectTree(final Module[] modules, final ModuleGroup group) {
|
||||
if (myRoot.getChildCount() == 0) return false; //isn't visible
|
||||
final MyNode [] nodes = new MyNode[modules.length];
|
||||
@@ -290,6 +300,7 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
addNode(moduleNode, moduleGroupNode);
|
||||
}
|
||||
myFacetEditorFacade.addFacetsNodes((Module)moduleNode.getConfigurable().getEditableObject(), moduleNode);
|
||||
addNodesFromExtensions((Module)moduleNode.getConfigurable().getEditableObject(), moduleNode);
|
||||
}
|
||||
((DefaultTreeModel)myTree.getModel()).reload(myRoot);
|
||||
return true;
|
||||
@@ -326,6 +337,9 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
|
||||
public void reset() {
|
||||
super.reset();
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
extension.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -335,10 +349,24 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
checkApply(roots, ProjectBundle.message("rename.message.prefix.module"), ProjectBundle.message("rename.module.title"));
|
||||
|
||||
if (myContext.myModulesConfigurator.isModified()) myContext.myModulesConfigurator.apply();
|
||||
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
extension.apply();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return myContext.myModulesConfigurator.isModified();
|
||||
if (myContext.myModulesConfigurator.isModified()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
if (extension.isModified()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
@@ -346,6 +374,10 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
myFacetEditorFacade.clearMaps(true);
|
||||
myContext.myModulesConfigurator.disposeUIResources();
|
||||
ModuleStructureConfigurable.super.disposeUIResources();
|
||||
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
extension.disposeUIResources();
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {}
|
||||
@@ -494,6 +526,7 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
if (parent == null) parent = myRoot;
|
||||
addNode(node, parent);
|
||||
myFacetEditorFacade.addFacetsNodes(module, node);
|
||||
addNodesFromExtensions(module, node);
|
||||
((DefaultTreeModel)myTree.getModel()).reload(parent);
|
||||
selectNodeInTree(node);
|
||||
final ProjectStructureDaemonAnalyzer daemonAnalyzer = myContext.getDaemonAnalyzer();
|
||||
@@ -545,6 +578,43 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
PlatformIcons.OPENED_MODULE_GROUP_ICON, PlatformIcons.CLOSED_MODULE_GROUP_ICON);
|
||||
}
|
||||
|
||||
protected boolean canBeRemoved(final Object editableObject) {
|
||||
if (super.canBeRemoved(editableObject)) {
|
||||
return true;
|
||||
}
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
if (extension.canBeRemoved(editableObject)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean removeObject(final Object editableObject) {
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
if (extension.removeObject(editableObject)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.removeObject(editableObject);
|
||||
}
|
||||
|
||||
private boolean canBeCopiedByExtension(final NamedConfigurable confugurable) {
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
if (extension.canBeCopied(confugurable)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void copyByExtension(final NamedConfigurable configurable) {
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
extension.copy(configurable, TREE_UPDATER);
|
||||
}
|
||||
}
|
||||
|
||||
private class MyDataProviderWrapper extends JPanel implements DataProvider {
|
||||
public MyDataProviderWrapper(final JComponent component) {
|
||||
super(new BorderLayout());
|
||||
@@ -659,6 +729,15 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
result.addAll(libraryActions);
|
||||
}
|
||||
|
||||
final Computable<Object> selectedObjectRetriever = new Computable<Object>() {
|
||||
public Object compute() {
|
||||
return getSelectedObject();
|
||||
}
|
||||
};
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
result.addAll(extension.createAddActions(selectedObjectRetriever, TREE_UPDATER));
|
||||
}
|
||||
|
||||
return result.toArray(new AnAction[result.size()]);
|
||||
}
|
||||
};
|
||||
@@ -679,6 +758,10 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
List<Facet> removed = modulesConfigurator.getFacetsConfigurator().removeAllFacets(module);
|
||||
FacetStructureConfigurable.getInstance(myProject).removeFacetNodes(removed);
|
||||
myContext.getDaemonAnalyzer().removeElement(new ModuleProjectStructureElement(myContext, module));
|
||||
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
extension.moduleRemoved(module);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -771,7 +854,7 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
}
|
||||
|
||||
public ModuleType getModuleType() {
|
||||
return rootModel.getModule().getModuleType();
|
||||
return ModuleType.get(rootModel.getModule());
|
||||
}
|
||||
};
|
||||
builder.setName(component.getNameValue());
|
||||
@@ -785,6 +868,9 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
LOG.error(e1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
copyByExtension(namedConfigurable);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(final AnActionEvent e) {
|
||||
@@ -792,12 +878,12 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
if (selectionPaths == null || selectionPaths.length != 1) {
|
||||
e.getPresentation().setEnabled(false);
|
||||
} else {
|
||||
e.getPresentation().setEnabled(getSelectedConfugurable() instanceof ModuleConfigurable);
|
||||
final NamedConfigurable selectedConfigurable = getSelectedConfugurable();
|
||||
e.getPresentation().setEnabled(selectedConfigurable instanceof ModuleConfigurable || canBeCopiedByExtension(selectedConfigurable));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class AddModuleAction extends AnAction implements DumbAware {
|
||||
public AddModuleAction() {
|
||||
super(ProjectBundle.message("add.new.module.text.full"), null, IconLoader.getIcon("/actions/modul.png"));
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package com.intellij.openapi.roots.ui.configuration.projectRoot;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.ui.MasterDetailsComponent;
|
||||
import com.intellij.openapi.ui.NamedConfigurable;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public abstract class ModuleStructureExtension {
|
||||
|
||||
public static final ExtensionPointName<ModuleStructureExtension> EP_NAME =
|
||||
ExtensionPointName.create("com.intellij.configuration.ModuleStructureExtension");
|
||||
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
public boolean addModuleNodeChildren(Module module, MasterDetailsComponent.MyNode moduleNode, Runnable treeNodeNameUpdater) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//public void moduleAdded(final Module module, final Runnable treeNodeNameUpdater) {
|
||||
//}
|
||||
|
||||
public void moduleRemoved(final Module module) {
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void apply() throws ConfigurationException {
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
}
|
||||
|
||||
public boolean canBeRemoved(final Object editableObject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeObject(final Object editableObject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Collection<AnAction> createAddActions(final Computable<Object> selectedObjectRetriever, final Runnable treeNodeNameUpdater) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public boolean canBeCopied(final NamedConfigurable confugurable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void copy(final NamedConfigurable confugurable, final Runnable treeNodeNameUpdater) {
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package com.intellij.openapi.roots.ui.configuration.projectRoot.daemon;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.roots.ModuleRootModel;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.impl.OrderEntryUtil;
|
||||
@@ -81,6 +82,6 @@ public class UsageInModuleClasspath extends ProjectStructureElementUsage {
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return myModule.getModuleType().getNodeIcon(false);
|
||||
return ModuleType.get(myModule).getNodeIcon(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,9 @@ public class ExpectedTypesProvider {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
MyParentVisitor visitor = new MyParentVisitor(expr, forCompletion, classProvider, voidable, usedAfter);
|
||||
parent.accept(visitor);
|
||||
if (parent != null) {
|
||||
parent.accept(visitor);
|
||||
}
|
||||
return visitor.getResult();
|
||||
}
|
||||
|
||||
|
||||
@@ -537,8 +537,8 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
|
||||
// some classes may have references from within XML outside dependent modules, e.g. our actions
|
||||
if (member instanceof PsiClass) scope = scope.uniteWith(GlobalSearchScope.projectScope(myProject));
|
||||
|
||||
PsiSearchHelper.SearchCostResult cheapEnough = myFile.getManager().getSearchHelper().isCheapEnoughToSearch(name, scope, myFile,
|
||||
progress);
|
||||
PsiSearchHelper.SearchCostResult cheapEnough = PsiSearchHelper.SERVICE.getInstance(myFile.getProject())
|
||||
.isCheapEnoughToSearch(name, scope, myFile, progress);
|
||||
if (cheapEnough == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) return false;
|
||||
|
||||
//search usages if it cheap
|
||||
|
||||
@@ -1168,6 +1168,9 @@ public class HighlightUtil {
|
||||
if (staticParent != null && isInstanceReference(place)) {
|
||||
QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createModifierListFix(staticParent, PsiModifier.STATIC, false, false));
|
||||
}
|
||||
if (place instanceof PsiReferenceExpression && refElement instanceof PsiField) {
|
||||
QuickFixAction.registerQuickFixAction(errorResult, new CreateFieldFromUsageFix((PsiReferenceExpression)place));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isInstanceReference(PsiJavaCodeReferenceElement place) {
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -59,7 +60,7 @@ public class AddNewArrayExpressionFix implements IntentionAction {
|
||||
@NonNls String text = "new " + type.getPresentableText() + "[]{}";
|
||||
PsiNewExpression newExpr = (PsiNewExpression) factory.createExpressionFromText(text, null);
|
||||
newExpr.getArrayInitializer().replace(myInitializer);
|
||||
newExpr = (PsiNewExpression) manager.getCodeStyleManager().reformat(newExpr);
|
||||
newExpr = (PsiNewExpression) CodeStyleManager.getInstance(manager.getProject()).reformat(newExpr);
|
||||
myInitializer.replace(newExpr);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -23,6 +23,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
@@ -118,7 +119,7 @@ public class BringVariableIntoScopeFix implements IntentionAction {
|
||||
LOG.assertTrue(commonParent != null);
|
||||
PsiDeclarationStatement added = (PsiDeclarationStatement)commonParent.addBefore(newDeclaration, child);
|
||||
PsiLocalVariable addedVar = (PsiLocalVariable)added.getDeclaredElements()[0];
|
||||
manager.getCodeStyleManager().reformat(commonParent);
|
||||
CodeStyleManager.getInstance(manager.getProject()).reformat(commonParent);
|
||||
|
||||
//Leave initializer assignment
|
||||
PsiExpression initializer = myOutOfScopeVariable.getInitializer();
|
||||
@@ -126,7 +127,7 @@ public class BringVariableIntoScopeFix implements IntentionAction {
|
||||
PsiExpressionStatement assignment = (PsiExpressionStatement)JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createStatementFromText(myOutOfScopeVariable
|
||||
.getName() + "= e;", null);
|
||||
((PsiAssignmentExpression)assignment.getExpression()).getRExpression().replace(initializer);
|
||||
assignment = (PsiExpressionStatement)manager.getCodeStyleManager().reformat(assignment);
|
||||
assignment = (PsiExpressionStatement)CodeStyleManager.getInstance(manager.getProject()).reformat(assignment);
|
||||
PsiDeclarationStatement declStatement = PsiTreeUtil.getParentOfType(myOutOfScopeVariable, PsiDeclarationStatement.class);
|
||||
LOG.assertTrue(declStatement != null);
|
||||
PsiElement parent = declStatement.getParent();
|
||||
|
||||
+3
-3
@@ -109,15 +109,15 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction, HighP
|
||||
if (myTargetMethod.getContainingClass().findMethodsByName(targetMethodName, true).length == 1) {
|
||||
if (newParams.size() == 1) {
|
||||
final ParameterInfoImpl p = newParams.iterator().next();
|
||||
return "Add " + p.getTypeText() + " as " + (ArrayUtil.find(myNewParametersInfo, p) + 1) + " parameter to method " + targetMethodName;
|
||||
return QuickFixBundle.message("add.parameter.from.usage.text", p.getTypeText(), (ArrayUtil.find(myNewParametersInfo, p) + 1), targetMethodName);
|
||||
}
|
||||
if (removedParams.size() == 1) {
|
||||
final ParameterInfoImpl p = removedParams.iterator().next();
|
||||
return "Remove " + (p.getOldIndex() + 1) + " parameter from method " + targetMethodName;
|
||||
return QuickFixBundle.message("remove.parameter.from.usage.text", (p.getOldIndex() + 1), targetMethodName);
|
||||
}
|
||||
if (changedParams.size() == 1) {
|
||||
final ParameterInfoImpl p = changedParams.iterator().next();
|
||||
return "Change " + (p.getOldIndex() + 1)+ " parameter of method " +targetMethodName + " from " + myTargetMethod.getParameterList().getParameters()[p.getOldIndex()].getType().getPresentableText() + " to " + p.getTypeText();
|
||||
return QuickFixBundle.message("change.parameter.from.usage.text", (p.getOldIndex() + 1), targetMethodName, myTargetMethod.getParameterList().getParameters()[p.getOldIndex()].getType().getPresentableText(), p.getTypeText());
|
||||
}
|
||||
}
|
||||
return "<html> Change signature of " + targetMethodName + "(" + buf.toString() + ")</html>";
|
||||
|
||||
-6
@@ -22,7 +22,6 @@ import com.intellij.codeInsight.template.Template;
|
||||
import com.intellij.codeInsight.template.TemplateBuilderImpl;
|
||||
import com.intellij.codeInsight.template.TemplateEditingAdapter;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.undo.UndoUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -32,7 +31,6 @@ import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -54,10 +52,6 @@ public class CreateFieldFromUsageFix extends CreateVarFromUsageFix {
|
||||
}
|
||||
|
||||
protected void invokeImpl(final PsiClass targetClass) {
|
||||
if (CreateFromUsageUtils.isValidReference(myReferenceExpression, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Project project = myReferenceExpression.getProject();
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
|
||||
|
||||
|
||||
+1
-1
@@ -342,7 +342,7 @@ public class CreateFromUsageUtils {
|
||||
classKind == CLASS ? elementFactory.createClass(name) :
|
||||
elementFactory.createEnum(name);
|
||||
CreateFromUsageBaseFix.setupGenericParameters(result, referenceElement);
|
||||
result = (PsiClass)manager.getCodeStyleManager().reformat(result);
|
||||
result = (PsiClass)CodeStyleManager.getInstance(manager.getProject()).reformat(result);
|
||||
return (PsiClass) psiClass.add(result);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ public abstract class CreateVarFromUsageFix extends CreateFromUsageBaseFix {
|
||||
|
||||
protected boolean isValidElement(PsiElement element) {
|
||||
PsiReferenceExpression expression = (PsiReferenceExpression) element;
|
||||
return CreateFromUsageUtils.isValidReference(expression, true);
|
||||
return CreateFromUsageUtils.isValidReference(expression, false);
|
||||
}
|
||||
|
||||
protected PsiElement getElement() {
|
||||
@@ -48,7 +48,7 @@ public abstract class CreateVarFromUsageFix extends CreateFromUsageBaseFix {
|
||||
if (parent instanceof PsiMethodCallExpression) return null;
|
||||
|
||||
if (myReferenceExpression.getReferenceNameElement() != null) {
|
||||
if (!CreateFromUsageUtils.isValidReference(myReferenceExpression, true)) {
|
||||
if (!CreateFromUsageUtils.isValidReference(myReferenceExpression, false)) {
|
||||
return myReferenceExpression;
|
||||
}
|
||||
}
|
||||
|
||||
+32
-4
@@ -17,14 +17,21 @@
|
||||
package com.intellij.codeInsight.generation.surroundWith;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.rename.inplace.VariableInplaceRenameHandler;
|
||||
import com.intellij.refactoring.rename.inplace.VariableInplaceRenamer;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -37,10 +44,12 @@ public class JavaWithRunnableSurrounder extends JavaStatementsSurrounder{
|
||||
return CodeInsightBundle.message("surround.with.runnable.template");
|
||||
}
|
||||
|
||||
public TextRange surroundStatements(Project project, Editor editor, PsiElement container, PsiElement[] statements) throws IncorrectOperationException{
|
||||
public TextRange surroundStatements(Project project, final Editor editor, PsiElement container, PsiElement[] statements) throws IncorrectOperationException{
|
||||
PsiManager manager = container.getManager();
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
|
||||
CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
|
||||
final String baseName = "runnable";
|
||||
final String uniqueName = JavaCodeStyleManager.getInstance(project).suggestUniqueVariableName(baseName, container, false);
|
||||
|
||||
@NonNls String text = "Runnable runnable = new Runnable(){\npublic void run(){\n}};";
|
||||
PsiDeclarationStatement declarationStatement = (PsiDeclarationStatement)factory.createStatementFromText(text, null);
|
||||
@@ -48,7 +57,12 @@ public class JavaWithRunnableSurrounder extends JavaStatementsSurrounder{
|
||||
|
||||
declarationStatement = (PsiDeclarationStatement)container.addAfter(declarationStatement, statements[statements.length - 1]);
|
||||
|
||||
PsiVariable variable = (PsiVariable)declarationStatement.getDeclaredElements()[0];
|
||||
final PsiVariable variable = (PsiVariable)declarationStatement.getDeclaredElements()[0];
|
||||
|
||||
if (!Comparing.strEqual(uniqueName, baseName)) {
|
||||
variable.setName(uniqueName);
|
||||
}
|
||||
|
||||
PsiNewExpression newExpression = (PsiNewExpression)variable.getInitializer();
|
||||
PsiElement[] children = newExpression.getChildren();
|
||||
PsiAnonymousClass anonymousClass = (PsiAnonymousClass)children[children.length - 1];
|
||||
@@ -59,8 +73,22 @@ public class JavaWithRunnableSurrounder extends JavaStatementsSurrounder{
|
||||
|
||||
makeVariablesFinal(body, body);
|
||||
|
||||
TextRange range = variable.getNameIdentifier().getTextRange();
|
||||
return range;
|
||||
final int textOffset = variable.getNameIdentifier().getTextOffset();
|
||||
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
|
||||
editor.getCaretModel().moveToOffset(textOffset);
|
||||
new VariableInplaceRenamer(variable, editor){
|
||||
@Override
|
||||
protected void moveOffsetAfter(boolean success) {
|
||||
super.moveOffsetAfter(success);
|
||||
if (success) {
|
||||
final PsiNamedElement renamedVariable = getVariable();
|
||||
if (renamedVariable != null) {
|
||||
editor.getCaretModel().moveToOffset(renamedVariable.getTextRange().getEndOffset());
|
||||
}
|
||||
}
|
||||
}
|
||||
}.performInplaceRename();
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void makeVariablesFinal(PsiElement scope, PsiCodeBlock body) throws IncorrectOperationException{
|
||||
|
||||
+1
-1
@@ -225,7 +225,7 @@ public class ColorChooserIntentionAction extends PsiElementBaseIntentionAction {
|
||||
+ (color.getAlpha() < 255 ? ", " + color.getAlpha() : "")
|
||||
+")", expression);
|
||||
final PsiElement insertedElement = expression.replace(newCall);
|
||||
final CodeStyleManager codeStyleManager = manager.getCodeStyleManager();
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject());
|
||||
codeStyleManager.reformat(insertedElement);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiConcatenationUtil;
|
||||
@@ -78,7 +79,7 @@ public class ConcatenationToMessageFormatAction implements IntentionAction {
|
||||
argumentList.add(arrayArg);
|
||||
}
|
||||
call = (PsiMethodCallExpression) JavaCodeStyleManager.getInstance(project).shortenClassReferences(call);
|
||||
call = (PsiMethodCallExpression) element.getManager().getCodeStyleManager().reformat(call);
|
||||
call = (PsiMethodCallExpression) CodeStyleManager.getInstance(element.getManager().getProject()).reformat(call);
|
||||
concatenation.replace(call);
|
||||
}
|
||||
|
||||
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* 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 com.intellij.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.highlighting.HighlightManager;
|
||||
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.EditorColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringStack;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import gnu.trove.TIntProcedure;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class ExpandStaticImportAction extends PsiElementBaseIntentionAction {
|
||||
private static final Logger LOG = Logger.getInstance("#" + ExpandStaticImportAction.class.getName());
|
||||
private static final String REPLACE_THIS_OCCURRENCE = "Replace this occurrence and keep the method";
|
||||
private static final String REPLACE_ALL_AND_DELETE_IMPORT = "Replace all and delete the import";
|
||||
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return "Expand Static Import";
|
||||
}
|
||||
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(element)) return false;
|
||||
final PsiElement parent = element.getParent();
|
||||
if (!(element instanceof PsiIdentifier) || !(parent instanceof PsiJavaCodeReferenceElement)) {
|
||||
return false;
|
||||
}
|
||||
final PsiJavaCodeReferenceElement referenceElement = (PsiJavaCodeReferenceElement)parent;
|
||||
final PsiElement resolveScope = referenceElement.advancedResolve(true).getCurrentFileResolveScope();
|
||||
if (resolveScope instanceof PsiImportStaticStatement) {
|
||||
final PsiClass targetClass = ((PsiImportStaticStatement)resolveScope).resolveTargetClass();
|
||||
if (targetClass == null) return false;
|
||||
setText("Expand static import to " + targetClass.getName() + "." + referenceElement.getReferenceName());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void invoke(final Project project, final PsiFile file, final Editor editor, PsiElement element) {
|
||||
if (!CodeInsightUtilBase.prepareFileForWrite(file)) return;
|
||||
|
||||
final PsiJavaCodeReferenceElement refExpr = (PsiJavaCodeReferenceElement)element.getParent();
|
||||
|
||||
final PsiImportStaticStatement staticImport = (PsiImportStaticStatement)refExpr.advancedResolve(true).getCurrentFileResolveScope();
|
||||
|
||||
|
||||
final List<PsiJavaCodeReferenceElement> expressionToExpand = new ArrayList<PsiJavaCodeReferenceElement>();
|
||||
file.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitReferenceElement(PsiJavaCodeReferenceElement expression) {
|
||||
if (refExpr != expression) {
|
||||
final PsiElement resolveScope = expression.advancedResolve(true).getCurrentFileResolveScope();
|
||||
if (resolveScope == staticImport) {
|
||||
expressionToExpand.add(expression);
|
||||
}
|
||||
}
|
||||
super.visitElement(expression);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (expressionToExpand.isEmpty()) {
|
||||
expand(refExpr, staticImport);
|
||||
staticImport.delete();
|
||||
}
|
||||
else {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
replaceAllAndDeleteImport(expressionToExpand, refExpr, staticImport);
|
||||
}
|
||||
else {
|
||||
final BaseListPopupStep<String> step =
|
||||
new BaseListPopupStep<String>("Multiple Similar Calls Found",
|
||||
new String[]{REPLACE_THIS_OCCURRENCE, REPLACE_ALL_AND_DELETE_IMPORT}) {
|
||||
@Override
|
||||
public PopupStep onChosen(final String selectedValue, boolean finalChoice) {
|
||||
new WriteCommandAction(project, ExpandStaticImportAction.this.getText()) {
|
||||
@Override
|
||||
protected void run(Result result) throws Throwable {
|
||||
if (selectedValue == REPLACE_THIS_OCCURRENCE) {
|
||||
expand(refExpr, staticImport);
|
||||
}
|
||||
else {
|
||||
replaceAllAndDeleteImport(expressionToExpand, refExpr, staticImport);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
return FINAL_CHOICE;
|
||||
}
|
||||
};
|
||||
JBPopupFactory.getInstance().createListPopup(step).showInBestPositionFor(editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void replaceAllAndDeleteImport(List<PsiJavaCodeReferenceElement> expressionToExpand,
|
||||
PsiJavaCodeReferenceElement refExpr,
|
||||
PsiImportStaticStatement staticImport) {
|
||||
expressionToExpand.add(refExpr);
|
||||
Collections.sort(expressionToExpand, new Comparator<PsiJavaCodeReferenceElement>() {
|
||||
@Override
|
||||
public int compare(PsiJavaCodeReferenceElement o1, PsiJavaCodeReferenceElement o2) {
|
||||
return o2.getTextOffset() - o1.getTextOffset();
|
||||
}
|
||||
});
|
||||
for (PsiJavaCodeReferenceElement expression : expressionToExpand) {
|
||||
expand(expression, staticImport);
|
||||
}
|
||||
staticImport.delete();
|
||||
}
|
||||
|
||||
private static void expand(PsiJavaCodeReferenceElement refExpr, PsiImportStaticStatement staticImport) {
|
||||
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(refExpr.getProject());
|
||||
final PsiReferenceExpression referenceExpression = elementFactory.createReferenceExpression(staticImport.resolveTargetClass());
|
||||
if (refExpr instanceof PsiReferenceExpression) {
|
||||
((PsiReferenceExpression)refExpr).setQualifierExpression(referenceExpression);
|
||||
}
|
||||
else {
|
||||
refExpr.replace(elementFactory.createReferenceFromText(referenceExpression.getText() + "." + refExpr.getText(), refExpr));
|
||||
}
|
||||
}
|
||||
|
||||
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
|
||||
invoke(project, file, editor, element);
|
||||
}
|
||||
}
|
||||
+23
-27
@@ -47,10 +47,7 @@ import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class ImplementAbstractMethodHandler {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.ImplementAbstractMethodHandler");
|
||||
@@ -107,18 +104,17 @@ public class ImplementAbstractMethodHandler {
|
||||
}
|
||||
|
||||
if (result[0].length == 1) {
|
||||
implementInClass(result[0][0]);
|
||||
implementInClass(new Object[] {result[0][0]});
|
||||
return;
|
||||
}
|
||||
|
||||
myList = new JBList(result[0]);
|
||||
myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
myList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
final Runnable runnable = new Runnable(){
|
||||
public void run() {
|
||||
int index = myList.getSelectedIndex();
|
||||
if (index < 0) return;
|
||||
PsiElement element = (PsiElement)myList.getSelectedValue();
|
||||
implementInClass(element);
|
||||
implementInClass(myList.getSelectedValues());
|
||||
}
|
||||
};
|
||||
final PsiElementListCellRenderer<PsiElement> elementListCellRenderer = new MyPsiElementListCellRenderer(result[0]);
|
||||
@@ -133,31 +129,31 @@ public class ImplementAbstractMethodHandler {
|
||||
showInBestPositionFor(myEditor);
|
||||
}
|
||||
|
||||
private void implementInClass(final PsiElement psiClassOrEnumConstant) {
|
||||
if (!psiClassOrEnumConstant.isValid()) return;
|
||||
|
||||
final Document document = PsiDocumentManager.getInstance(myProject).getDocument(psiClassOrEnumConstant.getContainingFile());
|
||||
if (!FileDocumentManager.getInstance().requestWriting(document, myProject)) {
|
||||
MessagesEx.fileIsReadOnly(myProject, psiClassOrEnumConstant.getContainingFile().getVirtualFile()).showNow();
|
||||
return;
|
||||
private void implementInClass(final Object[] selection) {
|
||||
for (Object o : selection) {
|
||||
if (!((PsiElement)o).isValid()) return;
|
||||
}
|
||||
|
||||
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
|
||||
public void run() {
|
||||
final LinkedHashSet<PsiClass> classes = new LinkedHashSet<PsiClass>();
|
||||
for (Object o : selection) {
|
||||
if (o instanceof PsiEnumConstant) {
|
||||
classes.add(((PsiEnumConstant)o).getOrCreateInitializingClass());
|
||||
}
|
||||
else {
|
||||
classes.add((PsiClass)o);
|
||||
}
|
||||
}
|
||||
if (!CodeInsightUtilBase.preparePsiElementsForWrite(classes)) return;
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
PsiClass psiClass;
|
||||
if (psiClassOrEnumConstant instanceof PsiEnumConstant) {
|
||||
psiClass = ((PsiEnumConstant)psiClassOrEnumConstant).getOrCreateInitializingClass();
|
||||
} else {
|
||||
psiClass = (PsiClass)psiClassOrEnumConstant;
|
||||
for (PsiClass psiClass : classes) {
|
||||
try {
|
||||
OverrideImplementUtil.overrideOrImplement(psiClass, myMethod);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
CodeInsightUtilBase.prepareFileForWrite(psiClass.getContainingFile());
|
||||
OverrideImplementUtil.overrideOrImplement(psiClass, myMethod);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -16,11 +16,15 @@
|
||||
package com.intellij.codeInsight.template;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.highlighter.JavaFileHighlighter;
|
||||
import com.intellij.lang.StdLanguages;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
@@ -62,4 +66,14 @@ public class JavaCodeContextType extends TemplateContextType {
|
||||
return new JavaFileHighlighter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Document createDocument(CharSequence text, Project project) {
|
||||
if (project == null) {
|
||||
return super.createDocument(text, project);
|
||||
}
|
||||
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
|
||||
final PsiElementFactory factory = psiFacade.getElementFactory();
|
||||
final JavaCodeFragment fragment = factory.createCodeBlockCodeFragment((String)text, psiFacade.findPackage(""), true);
|
||||
return PsiDocumentManager.getInstance(project).getDocument(fragment);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -388,7 +388,7 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool {
|
||||
ProgressManager.getInstance().runProcess(new Runnable() {
|
||||
public void run() {
|
||||
final RefFilter filter = new StrictUnreferencedFilter(UnusedDeclarationInspection.this);
|
||||
final PsiSearchHelper helper = PsiManager.getInstance(getRefManager().getProject()).getSearchHelper();
|
||||
final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(getRefManager().getProject());
|
||||
getRefManager().iterate(new RefJavaVisitor() {
|
||||
@Override public void visitElement(final RefEntity refEntity) {
|
||||
if (refEntity instanceof RefClass && filter.accepts((RefClass)refEntity)) {
|
||||
|
||||
+2
-1
@@ -31,6 +31,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.*;
|
||||
@@ -153,7 +154,7 @@ public class GlobalJavaInspectionContextImpl extends GlobalJavaInspectionContext
|
||||
for (Module module : modules) {
|
||||
if (ModuleRootManager.getInstance(module).isSdkInherited()) {
|
||||
anyModuleUsesProjectSdk = true;
|
||||
if (module.getModuleType().isValidSdk(module, projectSdk)) {
|
||||
if (ModuleType.get(module).isValidSdk(module, projectSdk)) {
|
||||
anyModuleAcceptsSdk = true;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -48,6 +48,7 @@ import com.intellij.psi.PsiCompiledElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiRecursiveElementVisitor;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScopes;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.PackageSetFactory;
|
||||
import com.intellij.psi.search.scope.packageSet.ParsingException;
|
||||
@@ -94,7 +95,7 @@ public class UnusedLibrariesInspection extends DescriptorProviderInspection {
|
||||
GlobalSearchScope searchScope;
|
||||
try {
|
||||
@NonNls final String libsName = "libs";
|
||||
searchScope = GlobalSearchScope.filterScope(project, new NamedScope(libsName, PackageSetFactory.getInstance().compile("lib:*..*")));
|
||||
searchScope = GlobalSearchScopes.filterScope(project, new NamedScope(libsName, PackageSetFactory.getInstance().compile("lib:*..*")));
|
||||
}
|
||||
catch (ParsingException e) {
|
||||
//can't be
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public class UnusedParametersInspection extends GlobalJavaInspectionTool {
|
||||
processor.ignoreElement(entryPoint);
|
||||
}
|
||||
|
||||
final PsiSearchHelper helper = PsiManager.getInstance(project).getSearchHelper();
|
||||
final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(project);
|
||||
final AnalysisScope scope = manager.getScope();
|
||||
manager.iterate(new RefJavaVisitor() {
|
||||
@Override public void visitElement(RefEntity refEntity) {
|
||||
|
||||
+22
-8
@@ -25,6 +25,7 @@ import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
|
||||
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
|
||||
import com.intellij.lang.java.JavaCommenter;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
@@ -39,6 +40,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.controlFlow.*;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -229,14 +231,11 @@ public class FieldCanBeLocalInspection extends BaseLocalInspectionTool {
|
||||
}
|
||||
|
||||
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
final PsiExpression qualifier = expression.getQualifierExpression();
|
||||
if (qualifier == null || qualifier instanceof PsiThisExpression) {
|
||||
final PsiElement resolved = expression.resolve();
|
||||
if (resolved instanceof PsiField) {
|
||||
final PsiField field = (PsiField)resolved;
|
||||
if (aClass.equals(field.getContainingClass())) {
|
||||
candidates.remove(field);
|
||||
}
|
||||
final PsiElement resolved = expression.resolve();
|
||||
if (resolved instanceof PsiField) {
|
||||
final PsiField field = (PsiField)resolved;
|
||||
if (aClass.equals(field.getContainingClass())) {
|
||||
candidates.remove(field);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +264,7 @@ public class FieldCanBeLocalInspection extends BaseLocalInspectionTool {
|
||||
PsiField myField = PsiTreeUtil.getParentOfType(element, PsiField.class);
|
||||
if (myField == null || !myField.isValid()) return; //weird. should not get here when field becomes invalid
|
||||
|
||||
final PsiDocComment docComment = myField.getDocComment();
|
||||
final Collection<PsiReference> refs = ReferencesSearch.search(myField).findAll();
|
||||
if (refs.isEmpty()) return;
|
||||
Set<PsiReference> refsSet = new HashSet<PsiReference>(refs);
|
||||
@@ -311,6 +311,20 @@ public class FieldCanBeLocalInspection extends BaseLocalInspectionTool {
|
||||
}
|
||||
|
||||
if (newDeclaration != null) {
|
||||
if (docComment != null) {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
for (PsiElement psiElement : docComment.getDescriptionElements()) {
|
||||
buf.append(psiElement.getText());
|
||||
}
|
||||
if (buf.length() > 0) {
|
||||
final JavaCommenter commenter = new JavaCommenter();
|
||||
final PsiComment comment = JavaPsiFacade.getElementFactory(project)
|
||||
.createCommentFromText(commenter.getBlockCommentPrefix() +
|
||||
buf.toString() +
|
||||
commenter.getBlockCommentSuffix(), newDeclaration);
|
||||
newDeclaration.getParent().addBefore(comment, newDeclaration);
|
||||
}
|
||||
}
|
||||
final PsiFile psiFile = myField.getContainingFile();
|
||||
final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
|
||||
if (editor != null && IJSwingUtilities.hasFocus(editor.getComponent())) {
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.PsiNonJavaFileReferenceProcessor;
|
||||
import com.intellij.psi.search.PsiSearchHelper;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -418,7 +419,7 @@ public class VisibilityInspection extends GlobalJavaInspectionTool {
|
||||
String qualifiedName = ownerClass.getElement().getQualifiedName();
|
||||
if (qualifiedName != null) {
|
||||
final Project project = manager.getProject();
|
||||
PsiManager.getInstance(project).getSearchHelper()
|
||||
PsiSearchHelper.SERVICE.getInstance(project)
|
||||
.processUsagesInNonJavaFiles(qualifiedName, new PsiNonJavaFileReferenceProcessor() {
|
||||
public boolean process(PsiFile file, int startOffset, int endOffset) {
|
||||
entryPointsManager.addEntryPoint(refMethod, false);
|
||||
|
||||
@@ -21,12 +21,11 @@ import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.PsiSearchHelper;
|
||||
import com.intellij.psi.util.MethodSignatureUtil;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.StateRestoringCheckBox;
|
||||
import com.intellij.usageView.UsageViewUtil;
|
||||
|
||||
@@ -83,13 +82,9 @@ public abstract class JavaFindUsagesDialog<T extends JavaFindUsagesOptions> exte
|
||||
}
|
||||
}
|
||||
|
||||
private PsiManager getPsiManager() {
|
||||
return myPsiElement.getManager();
|
||||
}
|
||||
|
||||
protected boolean isInFileOnly() {
|
||||
return super.isInFileOnly() ||
|
||||
myPsiElement != null && getPsiManager().getSearchHelper().getUseScope(myPsiElement)instanceof LocalSearchScope;
|
||||
myPsiElement != null && PsiSearchHelper.SERVICE.getInstance(myPsiElement.getProject()).getUseScope(myPsiElement)instanceof LocalSearchScope;
|
||||
}
|
||||
|
||||
public void configureLabelComponent(final SimpleColoredComponent coloredComponent) {
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.lang.refactoring.RefactoringSupportProvider;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.PsiSearchHelper;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
@@ -107,7 +108,7 @@ public class JavaRefactoringSupportProvider extends RefactoringSupportProvider {
|
||||
public static boolean mayRenameInplace(PsiElement elementToRename, final PsiElement nameSuggestionContext) {
|
||||
if (nameSuggestionContext != null && nameSuggestionContext.getContainingFile() != elementToRename.getContainingFile()) return false;
|
||||
if (!(elementToRename instanceof PsiLocalVariable) && !(elementToRename instanceof PsiParameter) && !(elementToRename instanceof PsiTypeParameter)) return false;
|
||||
SearchScope useScope = elementToRename.getManager().getSearchHelper().getUseScope(elementToRename);
|
||||
SearchScope useScope = PsiSearchHelper.SERVICE.getInstance(elementToRename.getProject()).getUseScope(elementToRename);
|
||||
if (!(useScope instanceof LocalSearchScope)) return false;
|
||||
PsiElement[] scopeElements = ((LocalSearchScope) useScope).getScope();
|
||||
if (scopeElements.length > 1 && // assume there are no elements with use scopes with holes in them
|
||||
|
||||
@@ -56,7 +56,8 @@ public class ClassFileViewProvider extends SingleRootFileViewProvider {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SingleRootFileViewProvider createCopy(final LightVirtualFile copy) {
|
||||
@Override
|
||||
public SingleRootFileViewProvider createCopy(final VirtualFile copy) {
|
||||
return new ClassFileViewProvider(getManager(), copy, false);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package com.intellij.psi.impl;
|
||||
import com.intellij.ide.IconProvider;
|
||||
import com.intellij.ide.projectView.impl.ProjectRootsUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
@@ -56,7 +57,7 @@ public class JavaDirectoryIconProvider extends IconProvider implements DumbAware
|
||||
else if (isContentRoot) {
|
||||
Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(vFile);
|
||||
if (module != null) {
|
||||
symbolIcon = module.getModuleType().getNodeIcon(isOpen);
|
||||
symbolIcon = ModuleType.get(module).getNodeIcon(isOpen);
|
||||
}
|
||||
else {
|
||||
symbolIcon = isOpen ? PlatformIcons.CONTENT_ROOT_ICON_OPEN : PlatformIcons.CONTENT_ROOT_ICON_CLOSED;
|
||||
|
||||
@@ -186,8 +186,8 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
|
||||
if (fields.length < 1) {
|
||||
throw new IncorrectOperationException("Field was not created " + text);
|
||||
}
|
||||
final PsiField field = fields[0];
|
||||
JavaCodeStyleManager.getInstance(myManager.getProject()).shortenClassReferences(field);
|
||||
PsiField field = fields[0];
|
||||
field = (PsiField)JavaCodeStyleManager.getInstance(myManager.getProject()).shortenClassReferences(field);
|
||||
return (PsiField)CodeStyleManager.getInstance(myManager.getProject()).reformat(field);
|
||||
}
|
||||
|
||||
@@ -199,9 +199,18 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
|
||||
throw new IncorrectOperationException("Cannot create method with type \"null\".");
|
||||
}
|
||||
|
||||
final PsiJavaFile aFile = createDummyJavaFile(join("class _Dummy_ { public " + returnType.getCanonicalText(), " ", name, "() {} }"));
|
||||
final PsiMethod method = aFile.getClasses()[0].getMethods()[0];
|
||||
JavaCodeStyleManager.getInstance(myManager.getProject()).shortenClassReferences(method);
|
||||
final String canonicalText = returnType.getCanonicalText();
|
||||
final PsiJavaFile aFile = createDummyJavaFile(join("class _Dummy_ { public " + canonicalText, " ", name, "() {} }"));
|
||||
final PsiClass[] classes = aFile.getClasses();
|
||||
if (classes.length < 1) {
|
||||
throw new IncorrectOperationException("Class was not created. Method name: " + name + "; return type: " + canonicalText);
|
||||
}
|
||||
final PsiMethod[] methods = classes[0].getMethods();
|
||||
if (methods.length < 1) {
|
||||
throw new IncorrectOperationException("Method was not created. Method name: " + name + "; return type: " + canonicalText);
|
||||
}
|
||||
PsiMethod method = methods[0];
|
||||
method = (PsiMethod)JavaCodeStyleManager.getInstance(myManager.getProject()).shortenClassReferences(method);
|
||||
return (PsiMethod)CodeStyleManager.getInstance(myManager.getProject()).reformat(method);
|
||||
}
|
||||
|
||||
@@ -230,12 +239,12 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
|
||||
}
|
||||
|
||||
final String text = join(type.getCanonicalText() + " " + name);
|
||||
final PsiParameter parameter = createParameterFromText(text, null);
|
||||
PsiParameter parameter = createParameterFromText(text, null);
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(myManager.getProject());
|
||||
PsiUtil.setModifierProperty(parameter, PsiModifier.FINAL,
|
||||
CodeStyleSettingsManager.getSettings(myManager.getProject()).GENERATE_FINAL_PARAMETERS);
|
||||
markGenerated(parameter);
|
||||
JavaCodeStyleManager.getInstance(myManager.getProject()).shortenClassReferences(parameter);
|
||||
parameter = (PsiParameter)JavaCodeStyleManager.getInstance(myManager.getProject()).shortenClassReferences(parameter);
|
||||
return (PsiParameter)codeStyleManager.reformat(parameter);
|
||||
}
|
||||
|
||||
@@ -264,21 +273,13 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
|
||||
final PsiTypeParameter[] typeParameters = aClass.getTypeParameters();
|
||||
assert typeParameters.length == 1 : aClass;
|
||||
|
||||
final Map<PsiTypeParameter, PsiType> map = Collections.singletonMap(typeParameters[0], parameter);
|
||||
return createType(aClass, createSubstitutor(map));
|
||||
return createType(aClass, PsiSubstitutor.EMPTY.put(typeParameters[0], parameter));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiClassType createType(@NotNull final PsiClass aClass, final PsiType... parameters) {
|
||||
final PsiTypeParameter[] typeParameters = aClass.getTypeParameters();
|
||||
assert parameters.length == typeParameters.length;
|
||||
|
||||
final Map<PsiTypeParameter, PsiType> map = new java.util.HashMap<PsiTypeParameter, PsiType>();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
map.put(typeParameters[i], parameters[i]);
|
||||
}
|
||||
return createType(aClass, createSubstitutor(map));
|
||||
return createType(aClass, PsiSubstitutor.EMPTY.putAll(aClass, parameters));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.impl.source.DummyHolder;
|
||||
import com.intellij.psi.impl.source.DummyHolderFactory;
|
||||
import com.intellij.psi.impl.source.JavaDummyElement;
|
||||
@@ -407,7 +408,7 @@ public class PsiJavaParserFacadeImpl extends PsiParserFacadeImpl implements PsiJ
|
||||
throw new IncorrectOperationException("Incorrect catch section '" + text + "'. Parsed element: " + element);
|
||||
}
|
||||
setupCatchBlock(exceptionName, context, (PsiCatchSection)element);
|
||||
return (PsiCatchSection)myManager.getCodeStyleManager().reformat(element);
|
||||
return (PsiCatchSection)CodeStyleManager.getInstance(myManager.getProject()).reformat(element);
|
||||
}
|
||||
|
||||
private void setupCatchBlock(final String exceptionName, @Nullable final PsiElement context, final PsiCatchSection psiCatchSection)
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -30,7 +31,7 @@ public class LightVariableBuilder<T extends LightVariableBuilder> extends LightE
|
||||
setNavigationElement(navigationElement);
|
||||
}
|
||||
|
||||
public LightVariableBuilder(PsiManager manager, @NotNull String name, @NotNull PsiType type, Language language) {
|
||||
public LightVariableBuilder(PsiManager manager, @Nullable String name, @NotNull PsiType type, Language language) {
|
||||
super(manager, language);
|
||||
myName = name;
|
||||
myType = type;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.intellij.psi.impl.search;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerImpl;
|
||||
@@ -35,12 +37,23 @@ public class AnnotatedElementsSearcher implements QueryExecutor<PsiModifierListO
|
||||
Class<? extends PsiModifierListOwner>[] types = p.getTypes();
|
||||
|
||||
final GlobalSearchScope scope = useScope instanceof GlobalSearchScope ? (GlobalSearchScope)useScope : null;
|
||||
final Collection<? extends PsiElement> annotations = JavaAnnotationIndex.getInstance().get(annClass.getName(), annClass.getProject(), scope);
|
||||
final Collection<? extends PsiElement> annotations = ApplicationManager.getApplication().runReadAction(
|
||||
new Computable<Collection<? extends PsiElement>>() {
|
||||
@Override
|
||||
public Collection<? extends PsiElement> compute() {
|
||||
return JavaAnnotationIndex.getInstance().get(annClass.getName(), annClass.getProject(), scope);
|
||||
}
|
||||
});
|
||||
for (PsiElement elt : annotations) {
|
||||
if (notAnnotation(elt)) continue;
|
||||
|
||||
PsiAnnotation ann = (PsiAnnotation)elt;
|
||||
final PsiJavaCodeReferenceElement ref = ann.getNameReferenceElement();
|
||||
final PsiAnnotation ann = (PsiAnnotation)elt;
|
||||
final PsiJavaCodeReferenceElement ref = ApplicationManager.getApplication().runReadAction(new Computable<PsiJavaCodeReferenceElement>() {
|
||||
@Override
|
||||
public PsiJavaCodeReferenceElement compute() {
|
||||
return ann.getNameReferenceElement();
|
||||
}
|
||||
});
|
||||
if (ref == null) continue;
|
||||
|
||||
PsiElement parent = ann.getParent();
|
||||
@@ -56,7 +69,12 @@ public class AnnotatedElementsSearcher implements QueryExecutor<PsiModifierListO
|
||||
throw new PsiInvalidElementAccessException(candidate);
|
||||
}
|
||||
|
||||
if (!psiManager.areElementsEquivalent(ref.resolve(), annClass)) continue;
|
||||
if (!psiManager.areElementsEquivalent(ApplicationManager.getApplication().runReadAction(new Computable<PsiElement>() {
|
||||
@Override
|
||||
public PsiElement compute() {
|
||||
return ref.resolve();
|
||||
}
|
||||
}), annClass)) continue;
|
||||
if (useScope instanceof GlobalSearchScope &&
|
||||
!((GlobalSearchScope)useScope).contains(candidate.getContainingFile().getVirtualFile())) {
|
||||
continue;
|
||||
|
||||
@@ -79,7 +79,7 @@ public class AnnotatedPackagesSearcher implements QueryExecutor<PsiPackage, Anno
|
||||
}
|
||||
}
|
||||
|
||||
PsiSearchHelper helper = psiManager.getSearchHelper();
|
||||
PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(psiManager.getProject());
|
||||
final GlobalSearchScope infoFilesFilter = new PackageInfoFilesOnly();
|
||||
|
||||
GlobalSearchScope infoFiles =
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.psi.PsiElementFactory;
|
||||
import com.intellij.psi.PsiPackageStatement;
|
||||
import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScopes;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -52,7 +53,7 @@ public class PsiJavaFileImpl extends PsiJavaFileBaseImpl {
|
||||
if (file != null && !(file instanceof LightVirtualFile)) {
|
||||
final ProjectFileIndex index = ProjectRootManager.getInstance(getProject()).getFileIndex();
|
||||
if (!index.isInSource(file) && !index.isInLibraryClasses(file)) {
|
||||
return GlobalSearchScope.fileScope(this);
|
||||
return GlobalSearchScopes.fileScope(this);
|
||||
}
|
||||
}
|
||||
return super.getResolveScope();
|
||||
|
||||
@@ -52,7 +52,7 @@ public class SourceUtil {
|
||||
parenthExpr.rawAddChildren(ASTFactory.leaf(JavaTokenType.RPARENTH, ")"));
|
||||
|
||||
try {
|
||||
CodeStyleManager codeStyleManager = manager.getCodeStyleManager();
|
||||
CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject());
|
||||
parenthExpr =
|
||||
(CompositeElement)SourceTreeToPsiMap.psiElementToTree(
|
||||
codeStyleManager.reformat(SourceTreeToPsiMap.treeElementToPsi(parenthExpr)));
|
||||
|
||||
+3
-2
@@ -779,8 +779,9 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
|
||||
PsiReferenceList methodThrowsList = (PsiReferenceList)method.getThrowsList().replace(throwsList);
|
||||
methodThrowsList = (PsiReferenceList)JavaCodeStyleManager.getInstance(method.getProject()).shortenClassReferences(methodThrowsList);
|
||||
method.getManager().getCodeStyleManager().reformatRange(method, method.getParameterList().getTextRange().getEndOffset(),
|
||||
methodThrowsList.getTextRange().getEndOffset());
|
||||
CodeStyleManager.getInstance(method.getManager().getProject())
|
||||
.reformatRange(method, method.getParameterList().getTextRange().getEndOffset(),
|
||||
methodThrowsList.getTextRange().getEndOffset());
|
||||
}
|
||||
|
||||
private static void fixJavadocsForChangedMethod(PsiMethod method, JavaChangeInfo changeInfo, int newParamsLength) throws IncorrectOperationException {
|
||||
|
||||
@@ -392,7 +392,7 @@ public class ExtractClassProcessor extends FixableUsagesRefactoringProcessor {
|
||||
private void buildDelegate() {
|
||||
final PsiManager manager = sourceClass.getManager();
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
|
||||
final CodeStyleManager codeStyleManager = manager.getCodeStyleManager();
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject());
|
||||
@NonNls final StringBuilder fieldBuffer = new StringBuilder();
|
||||
final String delegateVisibility = calculateDelegateVisibility();
|
||||
if (delegateVisibility.length() > 0) fieldBuffer.append(delegateVisibility).append(' ');
|
||||
@@ -691,7 +691,7 @@ public class ExtractClassProcessor extends FixableUsagesRefactoringProcessor {
|
||||
if (directory != null) {
|
||||
final PsiFile newFile = PsiFileFactory.getInstance(project).createFileFromText(newClassName + ".java", classString);
|
||||
final PsiElement addedFile = directory.add(newFile);
|
||||
final CodeStyleManager codeStyleManager = manager.getCodeStyleManager();
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject());
|
||||
final PsiElement shortenedFile = JavaCodeStyleManager.getInstance(project).shortenClassReferences(addedFile);
|
||||
return ((PsiJavaFile)codeStyleManager.reformat(shortenedFile)).getClasses()[0];
|
||||
} else {
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -57,7 +56,7 @@ public class InlineMethodDialog extends InlineOptionsDialog {
|
||||
|
||||
private void initOccurrencesNumber(PsiMethod method) {
|
||||
final ProgressManager progressManager = ProgressManager.getInstance();
|
||||
final PsiSearchHelper searchHelper = method.getManager().getSearchHelper();
|
||||
final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(method.getProject());
|
||||
final GlobalSearchScope scope = GlobalSearchScope.projectScope(method.getProject());
|
||||
final boolean isCheapToSearch =
|
||||
searchHelper.isCheapEnoughToSearch(method.getName(), scope, null, progressManager.getProgressIndicator()) != PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES;
|
||||
|
||||
+8
@@ -291,4 +291,12 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
|
||||
public void setReplaceAllOccurrences(boolean replaceAll) {
|
||||
myPanel.setReplaceAllOccurrences(replaceAll);
|
||||
}
|
||||
|
||||
public PsiMethod getMethodToIntroduceParameter() {
|
||||
return myMethod;
|
||||
}
|
||||
|
||||
public PsiMethod getMethodToSearchFor() {
|
||||
return myMethodToSearchFor;
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -182,8 +182,15 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R
|
||||
private void chooseMethodToIntroduceParameter(final Editor editor,
|
||||
final List<PsiMethod> validEnclosingMethods,
|
||||
final Introducer introducer) {
|
||||
final AbstractInplaceIntroducer inplaceIntroducer = AbstractInplaceIntroducer.getActiveIntroducer(editor);
|
||||
if (inplaceIntroducer instanceof InplaceIntroduceParameterPopup) {
|
||||
final InplaceIntroduceParameterPopup introduceParameterPopup = (InplaceIntroduceParameterPopup)inplaceIntroducer;
|
||||
introducer.introduceParameter(introduceParameterPopup.getMethodToIntroduceParameter(),
|
||||
introduceParameterPopup.getMethodToSearchFor());
|
||||
return;
|
||||
}
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
final JCheckBox superMethod = new JCheckBox("Use super method of", true);
|
||||
final JCheckBox superMethod = new JCheckBox("Use super method", true);
|
||||
superMethod.setMnemonic('U');
|
||||
panel.add(superMethod, BorderLayout.SOUTH);
|
||||
final JBList list = new JBList(validEnclosingMethods.toArray());
|
||||
|
||||
+10
-6
@@ -150,13 +150,13 @@ public class OldReferenceResolver {
|
||||
}
|
||||
}
|
||||
|
||||
if (subj instanceof PsiField && PsiTreeUtil.isAncestor(clss, scope, false)) {
|
||||
if (subj instanceof PsiField && PsiTreeUtil.isAncestor(scope, clss, false)) {
|
||||
// probably replacing field with a getter
|
||||
if (myReplaceFieldsWithGetters != IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE) {
|
||||
if (myReplaceFieldsWithGetters == IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL ||
|
||||
myReplaceFieldsWithGetters == IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE &&
|
||||
!JavaPsiFacade.getInstance(myProject).getResolveHelper().isAccessible((PsiMember)subj, newExpr, null)) {
|
||||
newExpr = replaceFieldWithGetter(newExpr, (PsiField)subj);
|
||||
newExpr = replaceFieldWithGetter(newExpr, (PsiField)subj, oldRef.getQualifierExpression() == null && !((PsiField)subj).hasModifierProperty(PsiModifier.STATIC));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public class OldReferenceResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private PsiElement replaceFieldWithGetter(PsiElement expr, PsiField psiField) throws IncorrectOperationException {
|
||||
private PsiElement replaceFieldWithGetter(PsiElement expr, PsiField psiField, boolean qualify) throws IncorrectOperationException {
|
||||
if (RefactoringUtil.isAssignmentLHS(expr)) {
|
||||
// todo: warning
|
||||
return expr;
|
||||
@@ -228,9 +228,13 @@ public class OldReferenceResolver {
|
||||
String id = getter.getName();
|
||||
String qualifier = null;
|
||||
if (newExpr instanceof PsiReferenceExpression) {
|
||||
final PsiExpression qualifierExpression = ((PsiReferenceExpression)newExpr).getQualifierExpression();
|
||||
if (qualifierExpression != null) {
|
||||
qualifier = qualifierExpression.getText();
|
||||
if (qualify) {
|
||||
qualifier = getInstanceRef(factory).getText();
|
||||
} else {
|
||||
final PsiExpression qualifierExpression = ((PsiReferenceExpression)newExpr).getQualifierExpression();
|
||||
if (qualifierExpression != null) {
|
||||
qualifier = qualifierExpression.getText();
|
||||
}
|
||||
}
|
||||
}
|
||||
PsiMethodCallExpression getterCall =
|
||||
|
||||
+5
-5
@@ -164,7 +164,7 @@ public class IntroduceParameterObjectProcessor extends FixableUsagesRefactoringP
|
||||
if (myUseExistingClass && existingClass != null) {
|
||||
myExistingClassCompatibleConstructor = existingClassIsCompatible(existingClass, parameters);
|
||||
}
|
||||
findUsagesForMethod(method, usages);
|
||||
findUsagesForMethod(method, usages, true);
|
||||
|
||||
if (myUseExistingClass && existingClass != null && !(paramsNeedingGetters.isEmpty() && paramsNeedingSetters.isEmpty())) {
|
||||
usages.add(new AppendAccessorsUsageInfo(existingClass, myGenerateAccessors, paramsNeedingGetters, paramsNeedingSetters, parameters));
|
||||
@@ -172,7 +172,7 @@ public class IntroduceParameterObjectProcessor extends FixableUsagesRefactoringP
|
||||
|
||||
final PsiMethod[] overridingMethods = OverridingMethodsSearch.search(method, method.getUseScope(), true).toArray(PsiMethod.EMPTY_ARRAY);
|
||||
for (PsiMethod siblingMethod : overridingMethods) {
|
||||
findUsagesForMethod(siblingMethod, usages);
|
||||
findUsagesForMethod(siblingMethod, usages, false);
|
||||
}
|
||||
|
||||
if (myNewVisibility != null) {
|
||||
@@ -180,7 +180,7 @@ public class IntroduceParameterObjectProcessor extends FixableUsagesRefactoringP
|
||||
}
|
||||
}
|
||||
|
||||
private void findUsagesForMethod(PsiMethod overridingMethod, List<FixableUsageInfo> usages) {
|
||||
private void findUsagesForMethod(PsiMethod overridingMethod, List<FixableUsageInfo> usages, boolean changeSignature) {
|
||||
final PsiCodeBlock body = overridingMethod.getBody();
|
||||
final String baseParameterName = StringUtil.decapitalize(className);
|
||||
final String fixedParamName =
|
||||
@@ -188,7 +188,7 @@ public class IntroduceParameterObjectProcessor extends FixableUsagesRefactoringP
|
||||
? JavaCodeStyleManager.getInstance(myProject).suggestUniqueVariableName(baseParameterName, body.getLBrace(), true)
|
||||
: JavaCodeStyleManager.getInstance(myProject).propertyNameToVariableName(baseParameterName, VariableKind.PARAMETER);
|
||||
|
||||
usages.add(new MergeMethodArguments(overridingMethod, className, packageName, fixedParamName, paramsToMerge, typeParams, keepMethodAsDelegate, myCreateInnerClass ? method.getContainingClass() : null));
|
||||
usages.add(new MergeMethodArguments(overridingMethod, className, packageName, fixedParamName, paramsToMerge, typeParams, keepMethodAsDelegate, myCreateInnerClass ? method.getContainingClass() : null, changeSignature));
|
||||
|
||||
final ParamUsageVisitor visitor = new ParamUsageVisitor(overridingMethod, paramsToMerge);
|
||||
overridingMethod.accept(visitor);
|
||||
@@ -279,7 +279,7 @@ public class IntroduceParameterObjectProcessor extends FixableUsagesRefactoringP
|
||||
|
||||
if (directory != null) {
|
||||
|
||||
final CodeStyleManager codeStyleManager = method.getManager().getCodeStyleManager();
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(method.getManager().getProject());
|
||||
final PsiElement shortenedFile = JavaCodeStyleManager.getInstance(newFile.getProject()).shortenClassReferences(newFile);
|
||||
final PsiElement reformattedFile = codeStyleManager.reformat(shortenedFile);
|
||||
return ((PsiJavaFile)directory.add(reformattedFile)).getClasses()[0];
|
||||
|
||||
+14
-8
@@ -22,6 +22,8 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.impl.source.PsiImmediateClassType;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor;
|
||||
import com.intellij.refactoring.changeSignature.ParameterInfoImpl;
|
||||
@@ -36,6 +38,7 @@ import java.util.*;
|
||||
public class MergeMethodArguments extends FixableUsageInfo {
|
||||
private final PsiMethod method;
|
||||
private final PsiClass myContainingClass;
|
||||
private final boolean myChangeSignature;
|
||||
private final boolean myKeepMethodAsDelegate;
|
||||
private final List<PsiTypeParameter> typeParams;
|
||||
private final String className;
|
||||
@@ -50,7 +53,7 @@ public class MergeMethodArguments extends FixableUsageInfo {
|
||||
String parameterName,
|
||||
int[] paramsToMerge,
|
||||
List<PsiTypeParameter> typeParams,
|
||||
final boolean keepMethodAsDelegate, final PsiClass containingClass) {
|
||||
final boolean keepMethodAsDelegate, final PsiClass containingClass, boolean changeSignature) {
|
||||
super(method);
|
||||
this.paramsToMerge = paramsToMerge;
|
||||
this.packageName = packageName;
|
||||
@@ -58,7 +61,8 @@ public class MergeMethodArguments extends FixableUsageInfo {
|
||||
this.parameterName = parameterName;
|
||||
this.method = method;
|
||||
myContainingClass = containingClass;
|
||||
lastParamIsVararg = method.isVarArgs();
|
||||
myChangeSignature = changeSignature;
|
||||
lastParamIsVararg = method.isVarArgs() && isParameterToMerge(method.getParameterList().getParametersCount() - 1);
|
||||
myKeepMethodAsDelegate = keepMethodAsDelegate;
|
||||
this.typeParams = new ArrayList<PsiTypeParameter>(typeParams);
|
||||
}
|
||||
@@ -111,12 +115,14 @@ public class MergeMethodArguments extends FixableUsageInfo {
|
||||
public void run() {
|
||||
final PsiMethod psiMethod = meth.getElement();
|
||||
if (psiMethod == null) return;
|
||||
final ChangeSignatureProcessor changeSignatureProcessor =
|
||||
new ChangeSignatureProcessor(psiMethod.getProject(), psiMethod,
|
||||
myKeepMethodAsDelegate, null, psiMethod.getName(),
|
||||
psiMethod.getReturnType(),
|
||||
parametersInfo.toArray(new ParameterInfoImpl[parametersInfo.size()]));
|
||||
changeSignatureProcessor.run();
|
||||
if (myChangeSignature) {
|
||||
final ChangeSignatureProcessor changeSignatureProcessor =
|
||||
new ChangeSignatureProcessor(psiMethod.getProject(), psiMethod,
|
||||
myKeepMethodAsDelegate, null, psiMethod.getName(),
|
||||
psiMethod.getReturnType(),
|
||||
parametersInfo.toArray(new ParameterInfoImpl[parametersInfo.size()]));
|
||||
changeSignatureProcessor.run();
|
||||
}
|
||||
}
|
||||
};
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
|
||||
+1
-1
@@ -144,7 +144,7 @@ public class MakeClassStaticProcessor extends MakeMethodOrClassStaticProcessor<P
|
||||
final PsiReferenceExpression refExpr = (PsiReferenceExpression)factory.createExpressionFromText(fieldName, body);
|
||||
if (refExpr.resolve() != null) fieldName = "this." + fieldName;
|
||||
PsiStatement statement = factory.createStatementFromText(fieldName + "=" + parameterName + ";", null);
|
||||
statement = (PsiStatement)manager.getCodeStyleManager().reformat(statement);
|
||||
statement = (PsiStatement)CodeStyleManager.getInstance(manager.getProject()).reformat(statement);
|
||||
body.add(statement);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.refactoring.move;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -60,7 +61,7 @@ public class MoveInstanceMembersUtil {
|
||||
if (expression instanceof PsiThisExpression) {
|
||||
final PsiJavaCodeReferenceElement thisQualifier = ((PsiThisExpression)expression).getQualifier();
|
||||
PsiClass thisClass = thisQualifier == null ? PsiTreeUtil.getParentOfType(expression, PsiClass.class, true) : ((PsiClass)thisQualifier.resolve());
|
||||
if (thisClass != null) {
|
||||
if (thisClass != null && !PsiTreeUtil.isAncestor( refMember,thisClass, false)) {
|
||||
addReferencedMember(map, thisClass, null);
|
||||
}
|
||||
}
|
||||
@@ -168,7 +169,7 @@ public class MoveInstanceMembersUtil {
|
||||
initializerCopy = newExpression;
|
||||
}
|
||||
((PsiAssignmentExpression)statement.getExpression()).getRExpression().replace(initializerCopy);
|
||||
statement = (PsiExpressionStatement)field.getManager().getCodeStyleManager().reformat(statement);
|
||||
statement = (PsiExpressionStatement)CodeStyleManager.getInstance(field.getManager().getProject()).reformat(statement);
|
||||
body.add(statement);
|
||||
initializer.delete();
|
||||
}
|
||||
|
||||
+1
-1
@@ -372,7 +372,7 @@ public class MoveInstanceMethodProcessor extends BaseRefactoringProcessor{
|
||||
body.accept(new JavaRecursiveElementVisitor() {
|
||||
@Override public void visitThisExpression(PsiThisExpression expression) {
|
||||
final PsiClass classReferencedByThis = MoveInstanceMembersUtil.getClassReferencedByThis(expression);
|
||||
if (classReferencedByThis != null) {
|
||||
if (classReferencedByThis != null && !PsiTreeUtil.isAncestor(myMethod, classReferencedByThis, false)) {
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(myProject).getElementFactory();
|
||||
String paramName = getParameterNameToCreate(classReferencedByThis);
|
||||
try {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class MutationUtils {
|
||||
factory.createTypeFromText(newExpression, null);
|
||||
final PsiTypeElement newTypeElement = factory.createTypeElement(newType);
|
||||
final PsiElement insertedElement = typeElement.replace(newTypeElement);
|
||||
final CodeStyleManager codeStyleManager = mgr.getCodeStyleManager();
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(mgr.getProject());
|
||||
final PsiElement shortenedElement = JavaCodeStyleManager.getInstance(mgr.getProject()).shortenClassReferences(insertedElement);
|
||||
codeStyleManager.reformat(shortenedElement);
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class MutationUtils {
|
||||
final PsiExpression newCall =
|
||||
factory.createExpressionFromText(newExpression, null);
|
||||
final PsiElement insertedElement = exp.replace(newCall);
|
||||
final CodeStyleManager codeStyleManager = mgr.getCodeStyleManager();
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(mgr.getProject());
|
||||
final PsiElement shortenedElement = JavaCodeStyleManager.getInstance(mgr.getProject()).shortenClassReferences(insertedElement);
|
||||
codeStyleManager.reformat(shortenedElement);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class MutationUtils {
|
||||
return;
|
||||
}
|
||||
final PsiElement insertedElement = exp.replace(newCall);
|
||||
final CodeStyleManager codeStyleManager = mgr.getCodeStyleManager();
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(mgr.getProject());
|
||||
final PsiElement shortenedElement =JavaCodeStyleManager.getInstance(mgr.getProject()).shortenClassReferences(insertedElement);
|
||||
codeStyleManager.reformat(shortenedElement);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class MutationUtils {
|
||||
final PsiJavaCodeReferenceElement newReference =
|
||||
factory.createReferenceElementByFQClassName(className, scope);
|
||||
final PsiElement insertedElement = reference.replace(newReference);
|
||||
final CodeStyleManager codeStyleManager = mgr.getCodeStyleManager();
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(mgr.getProject());
|
||||
final PsiElement shortenedElement = JavaCodeStyleManager.getInstance(mgr.getProject()).shortenClassReferences(insertedElement);
|
||||
codeStyleManager.reformat(shortenedElement);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class MutationUtils {
|
||||
final PsiStatement newCall =
|
||||
factory.createStatementFromText(newStatement, null);
|
||||
final PsiElement insertedElement = statement.replace(newCall);
|
||||
final CodeStyleManager codeStyleManager = mgr.getCodeStyleManager();
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(mgr.getProject());
|
||||
final PsiElement shortenedElement = JavaCodeStyleManager.getInstance(mgr.getProject()).shortenClassReferences(insertedElement);
|
||||
codeStyleManager.reformat(shortenedElement);
|
||||
}
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ public class ReplaceConstructorWithBuilderProcessor extends FixableUsagesRefacto
|
||||
|
||||
if (directory != null) {
|
||||
|
||||
final CodeStyleManager codeStyleManager = PsiManager.getInstance(myProject).getCodeStyleManager();
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(PsiManager.getInstance(myProject).getProject());
|
||||
final PsiJavaFile reformattedFile = (PsiJavaFile)codeStyleManager.reformat(JavaCodeStyleManager.getInstance(newFile.getProject()).shortenClassReferences(newFile));
|
||||
|
||||
if (directory.findFile(reformattedFile.getName()) != null) return reformattedFile.getClasses()[0];
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ public abstract class TurnRefsToSuperProcessorBase extends BaseRefactoringProces
|
||||
super(project);
|
||||
mySuperClassName = superClassName;
|
||||
myManager = PsiManager.getInstance(project);
|
||||
mySearchHelper = myManager.getSearchHelper();
|
||||
mySearchHelper = PsiSearchHelper.SERVICE.getInstance(myManager.getProject());
|
||||
myManager = PsiManager.getInstance(myProject);
|
||||
myReplaceInstanceOf = replaceInstanceOf;
|
||||
}
|
||||
|
||||
+2
-2
@@ -670,7 +670,7 @@ public class SystemBuilder {
|
||||
final PsiElement declarationScope = parameter.getDeclarationScope();
|
||||
if (declarationScope instanceof PsiMethod) {
|
||||
final PsiMethod method = (PsiMethod)declarationScope;
|
||||
final PsiSearchHelper helper = myManager.getSearchHelper();
|
||||
final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(myManager.getProject());
|
||||
SearchScope scope = getScope(helper, method);
|
||||
|
||||
for (PsiReference ref : ReferencesSearch.search(method, scope, true)) {
|
||||
@@ -914,7 +914,7 @@ public class SystemBuilder {
|
||||
}
|
||||
|
||||
public ReductionSystem build(final HashSet<PsiElement> victims) {
|
||||
final PsiSearchHelper helper = myManager.getSearchHelper();
|
||||
final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(myManager.getProject());
|
||||
|
||||
ReductionSystem system = new ReductionSystem(myProject, victims, myTypes, myTypeVariableFactory, mySettings);
|
||||
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScopes;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -145,7 +145,7 @@ public class TypeMigrationDialog extends RefactoringDialog {
|
||||
if (VisibilityUtil.compare(VisibilityUtil.getVisibilityModifier(modifierList), PsiModifier.PRIVATE) < 0) return null;
|
||||
}
|
||||
|
||||
for (PsiReference reference : ReferencesSearch.search(root, GlobalSearchScope.fileScope(root.getContainingFile()))) {
|
||||
for (PsiReference reference : ReferencesSearch.search(root, GlobalSearchScopes.fileScope(root.getContainingFile()))) {
|
||||
final PsiElement element = reference.getElement();
|
||||
final PsiExpression expr = PsiTreeUtil.getParentOfType(element, PsiExpression.class, false);
|
||||
if (expr != null) {
|
||||
|
||||
@@ -142,7 +142,7 @@ public class FieldConflictsResolver {
|
||||
expressionFromText = (PsiReferenceExpression)factory.createExpressionFromText("A." + member.getName(), null);
|
||||
expressionFromText.setQualifierExpression(factory.createReferenceExpression(qualifyingClass));
|
||||
}
|
||||
CodeStyleManager codeStyleManager = manager.getCodeStyleManager();
|
||||
CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject());
|
||||
expressionFromText = (PsiReferenceExpression)codeStyleManager.reformat(expressionFromText);
|
||||
return (PsiReferenceExpression)referenceExpression.replace(expressionFromText);
|
||||
}
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@ package com.intellij.refactoring.util.duplicates;
|
||||
|
||||
import com.intellij.codeInsight.PsiEquivalenceUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
/**
|
||||
@@ -54,6 +55,6 @@ public class ConditionalReturnStatementValue implements ReturnValue {
|
||||
final PsiExpression condition = statement.getCondition();
|
||||
assert condition != null;
|
||||
condition.replace(methodCallExpression);
|
||||
return (PsiStatement)statement.getManager().getCodeStyleManager().reformat(statement);
|
||||
return (PsiStatement)CodeStyleManager.getInstance(statement.getManager().getProject()).reformat(statement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package com.intellij.refactoring.util.duplicates;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -36,7 +37,7 @@ public abstract class GotoReturnValue implements ReturnValue {
|
||||
final PsiExpression condition = statement.getCondition();
|
||||
assert condition != null;
|
||||
condition.replace(methodCallExpression);
|
||||
return (PsiStatement)statement.getManager().getCodeStyleManager().reformat(statement);
|
||||
return (PsiStatement)CodeStyleManager.getInstance(statement.getManager().getProject()).reformat(statement);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
|
||||
+1
-1
@@ -259,7 +259,7 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
|
||||
|
||||
try {
|
||||
final PsiJavaFile psiFile = (PsiJavaFile)PsiFileFactory.getInstance(project).createFileFromText(className + ".java", classString);
|
||||
final CodeStyleManager codeStyleManager = manager.getCodeStyleManager();
|
||||
final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject());
|
||||
if (myCreateInnerClass) {
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
final PsiElement innerClass = containingClass.add(psiFile.getClasses()[0]);
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Remove 1 parameter from method f" "true"
|
||||
// "Remove 1st parameter from method 'f'" "true"
|
||||
class A {
|
||||
void f() {}
|
||||
public void foo() {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add String as 2 parameter to method set" "true"
|
||||
// "Add 'String' as 2nd parameter to method 'set'" "true"
|
||||
import java.util.List;
|
||||
|
||||
public class X<T> {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add char as 2 parameter to method f" "true"
|
||||
// "Add 'char' as 2nd parameter to method 'f'" "true"
|
||||
class A {
|
||||
void f(int i, char c, String s) {}
|
||||
public void foo() {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Remove 2 parameter from method f" "true"
|
||||
// "Remove 2nd parameter from method 'f'" "true"
|
||||
class A {
|
||||
void f(int i, int i2) {}
|
||||
public void foo() {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Change 2 parameter of method f from String to int" "true"
|
||||
// "Change 2nd parameter of method 'f' from 'String' to 'int'" "true"
|
||||
class A {
|
||||
void f(int i, int s, int i2) {}
|
||||
public void foo() {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add int as 2 parameter to method f" "true"
|
||||
// "Add 'int' as 2nd parameter to method 'f'" "true"
|
||||
public class S {
|
||||
void f(int k, int i, int... args) {
|
||||
f(1,1,null)<caret>;// -> f(1,1,null)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add Foo<TypeParamName> as 1 parameter to method Bar" "true"
|
||||
// "Add 'Foo<TypeParamName>' as 1st parameter to method 'Bar'" "true"
|
||||
public class Bar {
|
||||
Bar(Foo<TypeParamName> typeParamNameFoo, String args) {
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add Foo<TypeParamName> as 1 parameter to method bar" "true"
|
||||
// "Add 'Foo<TypeParamName>' as 1st parameter to method 'bar'" "true"
|
||||
public class Bar {
|
||||
static void bar(Foo<TypeParamName> typeParamNameFoo, String args) {
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add int as 1 parameter to method f" "true"
|
||||
// "Add 'int' as 1st parameter to method 'f'" "true"
|
||||
public class S {
|
||||
void f(int i, String args) {
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add Inner1 as 1 parameter to method Inner2" "true"
|
||||
// "Add 'Inner1' as 1st parameter to method 'Inner2'" "true"
|
||||
class CoolTest {
|
||||
class Inner1 {}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add String as 1 parameter to method f" "true"
|
||||
// "Add 'String' as 1st parameter to method 'f'" "true"
|
||||
public class S {
|
||||
void f(String s, int... args) {
|
||||
f("",1,1);
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add String as 1 parameter to method f" "true"
|
||||
// "Add 'String' as 1st parameter to method 'f'" "true"
|
||||
public class S {
|
||||
void f(String s, int... args) {
|
||||
f("",null);
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Remove 1 parameter from method f" "true"
|
||||
// "Remove 1st parameter from method 'f'" "true"
|
||||
class A {
|
||||
void f(int i) {}
|
||||
public void foo() {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add String as 2 parameter to method set" "true"
|
||||
// "Add 'String' as 2nd parameter to method 'set'" "true"
|
||||
import java.util.List;
|
||||
|
||||
public class X<T> {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add char as 2 parameter to method f" "true"
|
||||
// "Add 'char' as 2nd parameter to method 'f'" "true"
|
||||
class A {
|
||||
void f(int i,String s) {}
|
||||
public void foo() {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Remove 2 parameter from method f" "true"
|
||||
// "Remove 2nd parameter from method 'f'" "true"
|
||||
class A {
|
||||
void f(int i, String s, int i2) {}
|
||||
public void foo() {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Change 2 parameter of method f from String to int" "true"
|
||||
// "Change 2nd parameter of method 'f' from 'String' to 'int'" "true"
|
||||
class A {
|
||||
void f(int i, String s, int i2) {}
|
||||
public void foo() {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add int as 2 parameter to method f" "true"
|
||||
// "Add 'int' as 2nd parameter to method 'f'" "true"
|
||||
public class S {
|
||||
void f(int k, int... args) {
|
||||
f(1,1,null)<caret>;// -> f(1,1,null)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add Foo<TypeParamName> as 1 parameter to method Bar" "true"
|
||||
// "Add 'Foo<TypeParamName>' as 1st parameter to method 'Bar'" "true"
|
||||
public class Bar {
|
||||
Bar(String args) {
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add Foo<TypeParamName> as 1 parameter to method bar" "true"
|
||||
// "Add 'Foo<TypeParamName>' as 1st parameter to method 'bar'" "true"
|
||||
public class Bar {
|
||||
static void bar(String args) {
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add int as 1 parameter to method f" "false"
|
||||
// "Add 'int' as 1st parameter to method 'f'" "false"
|
||||
public class Foo {
|
||||
void foo(Bar f) {
|
||||
f.f<caret>(2);
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add int as 1 parameter to method f" "true"
|
||||
// "Add 'int' as 1st parameter to method 'f'" "true"
|
||||
public class S {
|
||||
void f(String args) {
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Change 1 parameter of method parseInt from String to int" "false"
|
||||
// "Change 1st parameter of method 'parseInt' from 'String' to 'int'" "false"
|
||||
class A {
|
||||
public void foo() {
|
||||
<caret>Integer.parseInt(1);
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add Inner1 as 1 parameter to method Inner2" "true"
|
||||
// "Add 'Inner1' as 1st parameter to method 'Inner2'" "true"
|
||||
class CoolTest {
|
||||
class Inner1 {}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add String as 1 parameter to method f" "true"
|
||||
// "Add 'String' as 1st parameter to method 'f'" "true"
|
||||
public class S {
|
||||
void f(int... args) {
|
||||
f("",1,1)<caret>;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add String as 1 parameter to method f" "true"
|
||||
// "Add 'String' as 1st parameter to method 'f'" "true"
|
||||
public class S {
|
||||
void f(int... args) {
|
||||
f("",null)<caret>;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Add String as 2nd parameter to method f" "false"
|
||||
// "Add 'String' as 2nd parameter to method 'f'" "false"
|
||||
public class S {
|
||||
void f(int... args) {
|
||||
f(1,1, "")<caret>;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user