mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' into upsource-master
This commit is contained in:
@@ -42,7 +42,6 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.ModuleAdapter;
|
||||
import com.intellij.openapi.project.ModuleListener;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.ui.InputValidator;
|
||||
@@ -105,6 +104,9 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
private final Map<String, String> myModuleNames = new HashMap<String, String>();
|
||||
private boolean myAddNotNullAssertions = true;
|
||||
|
||||
@Nullable
|
||||
private String myBytecodeTargetLevel = null; // null means compiler default
|
||||
private final Map<String, String> myModuleBytecodeTarget = new java.util.HashMap<String, String>();
|
||||
|
||||
public CompilerConfigurationImpl(Project project, ModuleManager moduleManager) {
|
||||
myProject = project;
|
||||
@@ -148,6 +150,35 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
}
|
||||
}
|
||||
|
||||
public void setProjectBytecodeTarget(@Nullable String level) {
|
||||
myBytecodeTargetLevel = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getProjectBytecodeTarget() {
|
||||
return myBytecodeTargetLevel;
|
||||
}
|
||||
|
||||
public void setModulesBytecodeTargetMap(@NotNull Map<String, String> mapping) {
|
||||
myModuleBytecodeTarget.clear();
|
||||
myModuleBytecodeTarget.putAll(mapping);
|
||||
}
|
||||
|
||||
public Map<String, String> getModulesBytecodeTargetMap() {
|
||||
return myModuleBytecodeTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getBytecodeTargetLevel(Module module) {
|
||||
final String level = myModuleBytecodeTarget.get(module.getName());
|
||||
if (level != null) {
|
||||
return "".equals(level)? null : level;
|
||||
}
|
||||
return myBytecodeTargetLevel;
|
||||
}
|
||||
|
||||
private void loadDefaultWildcardPatterns() {
|
||||
if (!myWildcardPatterns.isEmpty()) {
|
||||
removeWildcardPatterns();
|
||||
@@ -210,7 +241,9 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
}
|
||||
|
||||
private void createCompilers() {
|
||||
if (JAVAC_EXTERNAL_BACKEND != null) return;
|
||||
if (JAVAC_EXTERNAL_BACKEND != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
JAVAC_EXTERNAL_BACKEND = new JavacCompiler(myProject);
|
||||
myRegisteredCompilers.add(JAVAC_EXTERNAL_BACKEND);
|
||||
@@ -528,6 +561,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
@NonNls private static final String EXCLUDE_FROM_COMPILE = "excludeFromCompile";
|
||||
@NonNls private static final String RESOURCE_EXTENSIONS = "resourceExtensions";
|
||||
@NonNls private static final String ANNOTATION_PROCESSING = "annotationProcessing";
|
||||
@NonNls private static final String BYTECODE_TARGET_LEVEL = "bytecodeTargetLevel";
|
||||
@NonNls private static final String WILDCARD_RESOURCE_PATTERNS = "wildcardResourcePatterns";
|
||||
@NonNls private static final String ENTRY = "entry";
|
||||
@NonNls private static final String NAME = "name";
|
||||
@@ -622,6 +656,24 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myBytecodeTargetLevel = null;
|
||||
myModuleBytecodeTarget.clear();
|
||||
final Element bytecodeTargetElement = parentNode.getChild(BYTECODE_TARGET_LEVEL);
|
||||
if (bytecodeTargetElement != null) {
|
||||
myBytecodeTargetLevel = bytecodeTargetElement.getAttributeValue("target");
|
||||
for (Element elem : (Collection<Element>)bytecodeTargetElement.getChildren("module")) {
|
||||
final String name = elem.getAttributeValue("name");
|
||||
if (name == null) {
|
||||
continue;
|
||||
}
|
||||
final String target = elem.getAttributeValue("target");
|
||||
if (target == null) {
|
||||
continue;
|
||||
}
|
||||
myModuleBytecodeTarget.put(name, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,6 +744,30 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
moduleElement.setAttribute("generatedDirName", dirName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!StringUtil.isEmpty(myBytecodeTargetLevel) || !myModuleBytecodeTarget.isEmpty()) {
|
||||
final Element bytecodeTarget = new Element(BYTECODE_TARGET_LEVEL);
|
||||
parentNode.addContent(bytecodeTarget);
|
||||
if (!StringUtil.isEmpty(myBytecodeTargetLevel)) {
|
||||
bytecodeTarget.setAttribute("target", myBytecodeTargetLevel);
|
||||
}
|
||||
if (!myModuleBytecodeTarget.isEmpty()) {
|
||||
final List<String> moduleNames = new ArrayList<String>(myModuleBytecodeTarget.keySet());
|
||||
Collections.sort(moduleNames, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
return o1.compareTo(o2);
|
||||
}
|
||||
});
|
||||
for (String name : moduleNames) {
|
||||
final Element moduleElement = new Element("module");
|
||||
bytecodeTarget.addContent(moduleElement);
|
||||
moduleElement.setAttribute("name", name);
|
||||
final String value = myModuleBytecodeTarget.get(name);
|
||||
moduleElement.setAttribute("target", value != null? value : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull @NonNls
|
||||
@@ -706,7 +782,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
|
||||
/**
|
||||
* @param defaultCompiler The compiler that is passed as a parameter to setDefaultCompiler()
|
||||
* must be one of the registered compilers in compiler configuration.
|
||||
* must be one of the registered compilers in compiler configuration.
|
||||
* Otherwise because of lazy compiler initialization, the value of default compiler will point to some other compiler instance
|
||||
*/
|
||||
public void setDefaultCompiler(BackendCompiler defaultCompiler) {
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
package com.intellij.compiler.impl;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.impl.javaCompiler.ModuleChunk;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
@@ -158,6 +160,33 @@ public class CompilerUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void addTargetCommandLineSwitch(final ModuleChunk chunk, final List<String> commandLine) {
|
||||
String optionValue = null;
|
||||
CompilerConfiguration config = null;
|
||||
final Module[] modules = chunk.getModules();
|
||||
for (Module module : modules) {
|
||||
if (config == null) {
|
||||
config = CompilerConfiguration.getInstance(module.getProject());
|
||||
}
|
||||
final String moduleTarget = config.getBytecodeTargetLevel(module);
|
||||
if (moduleTarget == null) {
|
||||
continue;
|
||||
}
|
||||
if (optionValue == null) {
|
||||
optionValue = moduleTarget;
|
||||
}
|
||||
else {
|
||||
if (moduleTarget.compareTo(optionValue) < 0) {
|
||||
optionValue = moduleTarget; // use the lower possible target among modules that form the chunk
|
||||
}
|
||||
}
|
||||
}
|
||||
if (optionValue != null) {
|
||||
commandLine.add("-target");
|
||||
commandLine.add(optionValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addSourceCommandLineSwitch(final Sdk jdk, LanguageLevel chunkLanguageLevel, @NonNls final List<String> commandLine) {
|
||||
final String versionString = jdk.getVersionString();
|
||||
if (StringUtil.isEmpty(versionString)) {
|
||||
|
||||
+1
@@ -190,6 +190,7 @@ public class BackendCompilerWrapper {
|
||||
// validate encodings
|
||||
if (chunk.getModuleCount() > 1) {
|
||||
validateEncoding(chunk, chunkPresentableName);
|
||||
// todo: validation for bytecode target?
|
||||
}
|
||||
|
||||
runTransformingCompilers(chunk);
|
||||
|
||||
+1
@@ -164,6 +164,7 @@ public class EclipseCompiler extends ExternalCompiler {
|
||||
boolean quoteBootClasspath) throws IOException {
|
||||
final Sdk jdk = chunk.getJdk();
|
||||
CompilerUtil.addSourceCommandLineSwitch(jdk, chunk.getLanguageLevel(), commandLine);
|
||||
CompilerUtil.addTargetCommandLineSwitch(chunk, commandLine);
|
||||
|
||||
final String bootCp = chunk.getCompilationBootClasspath();
|
||||
|
||||
|
||||
+1
@@ -363,6 +363,7 @@ public class JavacCompiler extends ExternalCompiler {
|
||||
|
||||
LanguageLevel languageLevel = chunk.getLanguageLevel();
|
||||
CompilerUtil.addSourceCommandLineSwitch(jdk, languageLevel, commandLine);
|
||||
CompilerUtil.addTargetCommandLineSwitch(chunk, commandLine);
|
||||
|
||||
commandLine.add("-verbose");
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.compiler.options.JavaCompilersTab">
|
||||
<grid id="3d361" binding="myPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="3d361" binding="myPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="63" y="62" width="325" height="176"/>
|
||||
@@ -36,15 +36,24 @@
|
||||
<xy id="12adb" binding="myContentPanel" layout-manager="XYLayout" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</xy>
|
||||
<vspacer id="2d580">
|
||||
<grid id="a6152" binding="myTargetOptionsPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<vspacer id="7c703">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
|
||||
@@ -45,6 +45,7 @@ public class JavaCompilersTab implements SearchableConfigurable, Configurable.No
|
||||
private JPanel myPanel;
|
||||
private JPanel myContentPanel;
|
||||
private JComboBox myCompiler;
|
||||
private JPanel myTargetOptionsPanel;
|
||||
private final CardLayout myCardLayout;
|
||||
|
||||
private final Project myProject;
|
||||
@@ -52,6 +53,7 @@ public class JavaCompilersTab implements SearchableConfigurable, Configurable.No
|
||||
private BackendCompiler mySelectedCompiler;
|
||||
private final CompilerConfigurationImpl myCompilerConfiguration;
|
||||
private final Collection<Configurable> myConfigurables;
|
||||
private final TargetOptionsComponent myTargetLevelComponent;
|
||||
|
||||
public JavaCompilersTab(final Project project, Collection<BackendCompiler> compilers, BackendCompiler defaultCompiler) {
|
||||
myProject = project;
|
||||
@@ -62,6 +64,10 @@ public class JavaCompilersTab implements SearchableConfigurable, Configurable.No
|
||||
myCardLayout = new CardLayout();
|
||||
myContentPanel.setLayout(myCardLayout);
|
||||
|
||||
myTargetOptionsPanel.setLayout(new BorderLayout());
|
||||
myTargetLevelComponent = new TargetOptionsComponent(project);
|
||||
myTargetOptionsPanel.add(myTargetLevelComponent, BorderLayout.CENTER);
|
||||
|
||||
for (BackendCompiler compiler : compilers) {
|
||||
Configurable configurable = compiler.createConfigurable();
|
||||
myConfigurables.add(configurable);
|
||||
@@ -118,6 +124,12 @@ public class JavaCompilersTab implements SearchableConfigurable, Configurable.No
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!Comparing.equal(myTargetLevelComponent.getProjectBytecodeTarget(), myCompilerConfiguration.getProjectBytecodeTarget())) {
|
||||
return true;
|
||||
}
|
||||
if (!Comparing.equal(myTargetLevelComponent.getModulesBytecodeTargetMap(), myCompilerConfiguration.getModulesBytecodeTargetMap())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -126,6 +138,12 @@ public class JavaCompilersTab implements SearchableConfigurable, Configurable.No
|
||||
configurable.apply();
|
||||
}
|
||||
myCompilerConfiguration.setDefaultCompiler(mySelectedCompiler);
|
||||
myCompilerConfiguration.setProjectBytecodeTarget(myTargetLevelComponent.getProjectBytecodeTarget());
|
||||
myCompilerConfiguration.setModulesBytecodeTargetMap(myTargetLevelComponent.getModulesBytecodeTargetMap());
|
||||
|
||||
myTargetLevelComponent.setProjectBytecodeTargetLevel(myCompilerConfiguration.getProjectBytecodeTarget());
|
||||
myTargetLevelComponent.setModuleTargetLevels(myCompilerConfiguration.getModulesBytecodeTargetMap());
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
CompileServerManager.getInstance().sendReloadRequest(myProject);
|
||||
@@ -139,6 +157,8 @@ public class JavaCompilersTab implements SearchableConfigurable, Configurable.No
|
||||
configurable.reset();
|
||||
}
|
||||
selectCompiler(myCompilerConfiguration.getDefaultCompiler());
|
||||
myTargetLevelComponent.setProjectBytecodeTargetLevel(myCompilerConfiguration.getProjectBytecodeTarget());
|
||||
myTargetLevelComponent.setModuleTargetLevels(myCompilerConfiguration.getModulesBytecodeTargetMap());
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
|
||||
@@ -0,0 +1,398 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.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.ui.ComboBox;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.AnActionButtonRunnable;
|
||||
import com.intellij.ui.TableUtil;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.ui.ItemRemovable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicComboBoxEditor;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.TableColumn;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 5/9/12
|
||||
*/
|
||||
public class TargetOptionsComponent extends JPanel {
|
||||
private static final String[] KNOWN_TARGETS = new String[] {"1.1", "1.2", "1.3","1.4","1.5", "1.6", "1.7", "1.8"};
|
||||
private static final String COMPILER_DEFAULT = "JDK default";
|
||||
|
||||
private ComboBox myCbProjectTargetLevel;
|
||||
private JBTable myTable;
|
||||
private final Project myProject;
|
||||
|
||||
public TargetOptionsComponent(Project project) {
|
||||
super(new GridBagLayout());
|
||||
myProject = project;
|
||||
//setBorder(BorderFactory.createTitledBorder("Bytecode target level"));
|
||||
myCbProjectTargetLevel = createTargetOptionsCombo();
|
||||
|
||||
myTable = new JBTable(new TargetLevelTableModel());
|
||||
myTable.setRowHeight(22);
|
||||
myTable.getEmptyText().setText("All modules will be compiled with project bytecode version");
|
||||
|
||||
final TableColumn moduleColumn = myTable.getColumnModel().getColumn(0);
|
||||
moduleColumn.setHeaderValue("Module");
|
||||
moduleColumn.setCellRenderer(new ModuleCellRenderer());
|
||||
|
||||
final TableColumn targetLevelColumn = myTable.getColumnModel().getColumn(1);
|
||||
final String columnTitle = "Target bytecode version";
|
||||
targetLevelColumn.setHeaderValue(columnTitle);
|
||||
targetLevelColumn.setCellEditor(new TargetLevelCellEditor());
|
||||
targetLevelColumn.setCellRenderer(new TargetLevelCellRenderer());
|
||||
final int width = myTable.getFontMetrics(myTable.getFont()).stringWidth(columnTitle) + 10;
|
||||
targetLevelColumn.setPreferredWidth(width);
|
||||
targetLevelColumn.setMinWidth(width);
|
||||
targetLevelColumn.setMaxWidth(width);
|
||||
|
||||
add(new JLabel("Project bytecode version (leave blank for jdk default): "),
|
||||
constraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE));
|
||||
add(myCbProjectTargetLevel, constraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NONE));
|
||||
add(new JLabel("Per-module bytecode version:"), constraints(0, 1, 2, 1, 1.0, 0.0, GridBagConstraints.NONE));
|
||||
final JPanel tableComp = ToolbarDecorator.createDecorator(myTable)
|
||||
.disableUpAction()
|
||||
.disableDownAction()
|
||||
.setAddAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton anActionButton) {
|
||||
addModules();
|
||||
}
|
||||
})
|
||||
.setRemoveAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton anActionButton) {
|
||||
removeSelectedModules();
|
||||
}
|
||||
}).createPanel();
|
||||
|
||||
tableComp.setPreferredSize(new Dimension(myTable.getWidth(), 150));
|
||||
add(tableComp, constraints(0, 2, 2, 1, 1.0, 1.0, GridBagConstraints.BOTH));
|
||||
}
|
||||
|
||||
private void removeSelectedModules() {
|
||||
final int[] rows = myTable.getSelectedRows();
|
||||
if (rows.length > 0) {
|
||||
TableUtil.removeSelectedItems(myTable);
|
||||
}
|
||||
}
|
||||
|
||||
private void addModules() {
|
||||
final TargetLevelTableModel model = (TargetLevelTableModel)myTable.getModel();
|
||||
final List<Module> items = new ArrayList<Module>(Arrays.asList(ModuleManager.getInstance(myProject).getModules()));
|
||||
Set<Module> alreadyAdded = new HashSet<Module>();
|
||||
for (TargetLevelTableModel.Item item : model.getItems()) {
|
||||
alreadyAdded.add(item.module);
|
||||
}
|
||||
for (Iterator<Module> it = items.iterator(); it.hasNext(); ) {
|
||||
Module module = it.next();
|
||||
if (alreadyAdded.contains(module)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
Collections.sort(items, new Comparator<Module>() {
|
||||
@Override
|
||||
public int compare(Module o1, Module o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
});
|
||||
final ChooseModulesDialog chooser = new ChooseModulesDialog(this, items, "Choose module");
|
||||
chooser.show();
|
||||
final List<Module> elements = chooser.getChosenElements();
|
||||
if (!elements.isEmpty()) {
|
||||
model.addItems(elements);
|
||||
}
|
||||
}
|
||||
|
||||
public void setProjectBytecodeTargetLevel(String level) {
|
||||
myCbProjectTargetLevel.setSelectedItem(level == null? "" : level);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getProjectBytecodeTarget() {
|
||||
final String item = ((String)myCbProjectTargetLevel.getSelectedItem()).trim();
|
||||
return "".equals(item)? null : item;
|
||||
}
|
||||
|
||||
public Map<String, String> getModulesBytecodeTargetMap() {
|
||||
TargetLevelTableModel model = (TargetLevelTableModel)myTable.getModel();
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
for (TargetLevelTableModel.Item item : model.getItems()) {
|
||||
map.put(item.module.getName(), item.targetLevel);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setModuleTargetLevels(Map<String, String> moduleLevels) {
|
||||
final Map<Module, String> map = new HashMap<Module, String>();
|
||||
for (Module module : ModuleManager.getInstance(myProject).getModules()) {
|
||||
final String target = moduleLevels.get(module.getName());
|
||||
if (target != null) {
|
||||
map.put(module, target);
|
||||
}
|
||||
}
|
||||
((TargetLevelTableModel)myTable.getModel()).setItems(map);
|
||||
}
|
||||
|
||||
private static GridBagConstraints constraints(final int gridx, final int gridy, final int gridwidth, final int gridheight, final double weightx, final double weighty, final int fill) {
|
||||
return new GridBagConstraints(gridx, gridy, gridwidth, gridheight, weightx, weighty, GridBagConstraints.WEST, fill, new Insets(5, 5, 0, 0), 0, 0);
|
||||
}
|
||||
|
||||
private static final class TargetLevelTableModel extends AbstractTableModel implements ItemRemovable{
|
||||
private final List<Item> myItems = new ArrayList<Item>();
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return myItems.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return columnIndex != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
final Item item = myItems.get(rowIndex);
|
||||
return columnIndex == 0? item.module : item.targetLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
||||
final Item item = myItems.get(rowIndex);
|
||||
item.targetLevel = ((String)aValue).trim();
|
||||
fireTableCellUpdated(rowIndex, columnIndex);
|
||||
}
|
||||
|
||||
//public void addItem(Module module) {
|
||||
// final int size = myItems.size();
|
||||
// myItems.add(new Item(module.getName()));
|
||||
// fireTableRowsInserted(size, size);
|
||||
//}
|
||||
|
||||
public void addItems(Collection<Module> modules) {
|
||||
for (Module module : modules) {
|
||||
myItems.add(new Item(module));
|
||||
}
|
||||
sorItems();
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
private void sorItems() {
|
||||
Collections.sort(myItems, new Comparator<Item>() {
|
||||
@Override
|
||||
public int compare(Item o1, Item o2) {
|
||||
return o1.module.getName().compareTo(o2.module.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<Item> getItems() {
|
||||
return myItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRow(int idx) {
|
||||
myItems.remove(idx);
|
||||
}
|
||||
|
||||
public void setItems(Map<Module, String> items) {
|
||||
myItems.clear();
|
||||
for (Map.Entry<Module, String> entry : items.entrySet()) {
|
||||
myItems.add(new Item(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
sorItems();
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
private static final class Item {
|
||||
final Module module;
|
||||
String targetLevel = "";
|
||||
|
||||
Item(Module module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
Item(Module module, String targetLevel) {
|
||||
this.module = module;
|
||||
this.targetLevel = targetLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final class TargetLevelComboboxModel extends AbstractListModel implements ComboBoxModel{
|
||||
|
||||
private final List<String> myOptions = new ArrayList<String>();
|
||||
private String mySelectedItem = "";
|
||||
|
||||
TargetLevelComboboxModel() {
|
||||
//myOptions.add("");
|
||||
for (int i = KNOWN_TARGETS.length - 1; i >= 0; i--) {
|
||||
myOptions.add(KNOWN_TARGETS[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return myOptions.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedItem(Object anItem) {
|
||||
mySelectedItem = toModelItem((String)anItem);
|
||||
fireContentsChanged(this, 0, myOptions.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSelectedItem() {
|
||||
return mySelectedItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
return myOptions.get(index);
|
||||
}
|
||||
|
||||
private String toModelItem(String item) {
|
||||
item = item.trim();
|
||||
for (String option : myOptions) {
|
||||
if (option.equals(item)) {
|
||||
return option;
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
private static ComboBox createTargetOptionsCombo() {
|
||||
final ComboBox combo = new ComboBox(new TargetLevelComboboxModel());
|
||||
//combo.setRenderer(new DefaultListCellRenderer() {
|
||||
// @Override
|
||||
// public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
// try {
|
||||
// return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
// }
|
||||
// finally {
|
||||
// //if ("".equals(value)) {
|
||||
// // setText(COMPILER_DEFAULT);
|
||||
// //}
|
||||
// }
|
||||
// }
|
||||
//});
|
||||
combo.setEditable(true);
|
||||
combo.setEditor(new BasicComboBoxEditor() {
|
||||
@Override
|
||||
protected JTextField createEditorComponent() {
|
||||
return new HintTextField(COMPILER_DEFAULT, 10);
|
||||
}
|
||||
});
|
||||
return combo;
|
||||
}
|
||||
|
||||
private static class ModuleCellRenderer extends DefaultTableCellRenderer {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
try {
|
||||
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
}
|
||||
finally {
|
||||
final Module module = (Module)value;
|
||||
setText(module.getName());
|
||||
setIcon(ModuleType.get(module).getNodeIcon(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class TargetLevelCellEditor extends DefaultCellEditor {
|
||||
private TargetLevelCellEditor() {
|
||||
super(createTargetOptionsCombo());
|
||||
setClickCountToStart(0);
|
||||
}
|
||||
}
|
||||
|
||||
private static class TargetLevelCellRenderer extends DefaultTableCellRenderer {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
final Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
if (component instanceof JLabel) {
|
||||
final JLabel comp = (JLabel)component;
|
||||
comp.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
if ("".equals(value)) {
|
||||
comp.setForeground(Color.gray);
|
||||
comp.setText(COMPILER_DEFAULT);
|
||||
}
|
||||
else {
|
||||
comp.setForeground(table.getForeground());
|
||||
}
|
||||
}
|
||||
return component;
|
||||
}
|
||||
}
|
||||
|
||||
static class HintTextField extends JTextField {
|
||||
private final char[] myHint;
|
||||
|
||||
public HintTextField(final String hint) {
|
||||
this(hint, 0);
|
||||
}
|
||||
|
||||
public HintTextField(final String hint, final int columns) {
|
||||
super(hint, columns);
|
||||
myHint = hint.toCharArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
final boolean isFocused = isFocusOwner();
|
||||
if (!isFocused && getText().isEmpty()) {
|
||||
final Color oldColor = g.getColor();
|
||||
final Font oldFont = g.getFont();
|
||||
try {
|
||||
g.setColor(Color.gray);
|
||||
//g.setFont(oldFont.deriveFont(Font.ITALIC));
|
||||
final FontMetrics metrics = g.getFontMetrics();
|
||||
int x = Math.abs(getWidth() - metrics.charsWidth(myHint, 0, myHint.length)) / 2;
|
||||
int y = Math.abs(getHeight() - metrics.getHeight()) / 2 + metrics.getAscent();
|
||||
g.drawChars(myHint, 0, myHint.length, x, y);
|
||||
}
|
||||
finally {
|
||||
g.setColor(oldColor);
|
||||
g.setFont(oldFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ package com.intellij.compiler;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -26,6 +27,12 @@ public abstract class CompilerConfiguration {
|
||||
// need this flag for profiling purposes. In production code is always set to 'true'
|
||||
public static final boolean MAKE_ENABLED = true;
|
||||
|
||||
@Nullable
|
||||
public abstract String getProjectBytecodeTarget();
|
||||
|
||||
@Nullable
|
||||
public abstract String getBytecodeTargetLevel(Module module);
|
||||
|
||||
public static CompilerConfiguration getInstance(Project project) {
|
||||
return project.getComponent(CompilerConfiguration.class);
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -37,6 +37,7 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ModuleRootModel;
|
||||
import com.intellij.openapi.roots.impl.ModuleRootManagerImpl;
|
||||
import com.intellij.openapi.roots.impl.ProjectRootManagerImpl;
|
||||
import com.intellij.openapi.roots.ui.configuration.actions.ModuleDeleteProvider;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
|
||||
@@ -310,7 +311,7 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change
|
||||
public void run() {
|
||||
try {
|
||||
final ModifiableRootModel[] rootModels = models.toArray(new ModifiableRootModel[models.size()]);
|
||||
projectRootManager.multiCommit(myModuleModel, rootModels);
|
||||
ModuleRootManagerImpl.multiCommit(rootModels, myModuleModel);
|
||||
myModuleModelCommitted = true;
|
||||
myFacetsConfigurator.commitFacets();
|
||||
|
||||
|
||||
+1
@@ -498,6 +498,7 @@ public class HighlightMethodUtil {
|
||||
AddTypeArgumentsFix.REGISTRAR.registerCastActions(methodCandidates, methodCall, highlightInfo, fixRange);
|
||||
registerMethodAccessLevelIntentions(methodCandidates, methodCall, list, highlightInfo);
|
||||
ChangeMethodSignatureFromUsageFix.registerIntentions(methodCandidates, list, highlightInfo, fixRange);
|
||||
RemoveRedundantArgumentsFix.registerIntentions(methodCandidates, list, highlightInfo, fixRange);
|
||||
ConvertDoubleToFloatFix.registerIntentions(methodCandidates, list, highlightInfo, fixRange);
|
||||
WrapExpressionFix.registerWrapAction(methodCandidates, list.getExpressions(), highlightInfo);
|
||||
ChangeParameterClassFix.registerQuickFixActions(methodCall, list, highlightInfo);
|
||||
|
||||
+25
-5
@@ -76,19 +76,39 @@ public class CreateGetterOrSetterFix implements IntentionAction, LowPriorityActi
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
if (!myField.isValid()) return false;
|
||||
PsiClass aClass = myField.getContainingClass();
|
||||
|
||||
final PsiClass aClass = myField.getContainingClass();
|
||||
if (aClass == null) {
|
||||
return false;
|
||||
}
|
||||
if (myCreateGetter && PropertyUtil.findPropertyGetter(aClass, myPropertyName, myField.hasModifierProperty(PsiModifier.STATIC), false) != null) {
|
||||
return false;
|
||||
|
||||
if (myCreateGetter){
|
||||
if (isStaticFinal(myField) || PropertyUtil.findPropertyGetter(aClass, myPropertyName, isStatic(myField), false) != null){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (myCreateSetter && PropertyUtil.findPropertySetter(aClass, myPropertyName, myField.hasModifierProperty(PsiModifier.STATIC), false) != null) {
|
||||
return false;
|
||||
|
||||
if (myCreateSetter){
|
||||
if(isFinal(myField) || PropertyUtil.findPropertySetter(aClass, myPropertyName, isStatic(myField), false) != null){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isFinal(@NotNull PsiField field){
|
||||
return field.hasModifierProperty(PsiModifier.FINAL);
|
||||
}
|
||||
|
||||
private static boolean isStatic(@NotNull PsiField field){
|
||||
return field.hasModifierProperty(PsiModifier.STATIC);
|
||||
}
|
||||
|
||||
private static boolean isStaticFinal(@NotNull PsiField field){
|
||||
return isStatic(field) && isFinal(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
if (!CodeInsightUtilBase.preparePsiElementForWrite(myField)) return;
|
||||
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Danila Ponomarenko
|
||||
*/
|
||||
public class RemoveRedundantArgumentsFix implements IntentionAction {
|
||||
private final PsiMethod myTargetMethod;
|
||||
private final PsiExpression[] myArguments;
|
||||
private final PsiSubstitutor mySubstitutor;
|
||||
|
||||
private RemoveRedundantArgumentsFix(@NotNull PsiMethod targetMethod,
|
||||
@NotNull PsiExpression[] arguments,
|
||||
@NotNull PsiSubstitutor substitutor) {
|
||||
myTargetMethod = targetMethod;
|
||||
myArguments = arguments;
|
||||
mySubstitutor = substitutor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return QuickFixBundle.message("remove.redundant.arguments.text", HighlightUtil.formatMethod(myTargetMethod));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return QuickFixBundle.message("remove.redundant.arguments.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
if (!myTargetMethod.isValid() || myTargetMethod.getContainingClass() == null) return false;
|
||||
for (PsiExpression expression : myArguments) {
|
||||
if (!expression.isValid()) return false;
|
||||
}
|
||||
if (!mySubstitutor.isValid()) return false;
|
||||
|
||||
return findRedundantArgument(myArguments, myTargetMethod.getParameterList().getParameters(), mySubstitutor) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiExpression[] findRedundantArgument(@NotNull PsiExpression[] arguments,
|
||||
@NotNull PsiParameter[] parameters,
|
||||
@NotNull PsiSubstitutor substitutor) {
|
||||
if (arguments.length <= parameters.length) return null;
|
||||
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
final PsiExpression argument = arguments[i];
|
||||
final PsiParameter parameter = parameters[i];
|
||||
|
||||
final PsiType argumentType = argument.getType();
|
||||
if (argumentType == null) return null;
|
||||
final PsiType parameterType = substitutor.substitute(parameter.getType());
|
||||
|
||||
if (!TypeConversionUtil.isAssignable(parameterType, argumentType)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return Arrays.copyOfRange(arguments, parameters.length, arguments.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
if (!CodeInsightUtilBase.prepareFileForWrite(file)) return;
|
||||
final PsiExpression[] redundantArguments = findRedundantArgument(myArguments, myTargetMethod.getParameterList().getParameters(), mySubstitutor);
|
||||
if (redundantArguments != null) {
|
||||
for (PsiExpression argument : redundantArguments) {
|
||||
argument.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void registerIntentions(@NotNull JavaResolveResult[] candidates,
|
||||
@NotNull PsiExpressionList arguments,
|
||||
@NotNull HighlightInfo highlightInfo,
|
||||
TextRange fixRange) {
|
||||
for (JavaResolveResult candidate : candidates) {
|
||||
registerIntention(arguments, highlightInfo, fixRange, candidate, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerIntention(@NotNull PsiExpressionList arguments,
|
||||
@NotNull HighlightInfo highlightInfo,
|
||||
TextRange fixRange,
|
||||
@NotNull JavaResolveResult candidate,
|
||||
@NotNull PsiElement context) {
|
||||
if (!candidate.isStaticsScopeCorrect()) return;
|
||||
PsiMethod method = (PsiMethod)candidate.getElement();
|
||||
PsiSubstitutor substitutor = candidate.getSubstitutor();
|
||||
if (method != null && context.getManager().isInProject(method)) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new RemoveRedundantArgumentsFix(method, arguments.getExpressions(), substitutor));
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -27,6 +27,7 @@ import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.impl.ModuleRootManagerImpl;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
@@ -118,9 +119,10 @@ public class PsiPackageImplementationHelperImpl extends PsiPackageImplementation
|
||||
}
|
||||
|
||||
if (!modelsToCommit.isEmpty()) {
|
||||
ProjectRootManager.getInstance(psiPackage.getProject()).multiCommit(
|
||||
modelsToCommit.toArray(new ModifiableRootModel[modelsToCommit.size()])
|
||||
);
|
||||
ModifiableRootModel[] rootModels = modelsToCommit.toArray(new ModifiableRootModel[modelsToCommit.size()]);
|
||||
if (rootModels.length > 0) {
|
||||
ModuleRootManagerImpl.multiCommit(rootModels, ModuleManager.getInstance(rootModels[0].getProject()).getModifiableModel());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
+9
-3
@@ -27,6 +27,7 @@ import com.intellij.psi.util.MethodSignatureUtil;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.turnRefsToSuper.TurnRefsToSuperProcessorBase;
|
||||
import com.intellij.refactoring.util.DocCommentPolicy;
|
||||
import com.intellij.refactoring.util.RefactoringUIUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.refactoring.util.classMembers.MemberInfo;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
@@ -127,9 +128,14 @@ public abstract class ExtractSuperBaseProcessor extends TurnRefsToSuperProcessor
|
||||
myClass.setName(myNewClassName);
|
||||
PsiClass superClass = extractSuper(superClassName);
|
||||
final PsiDirectory initialDirectory = myClass.getContainingFile().getContainingDirectory();
|
||||
if (myTargetDirectory != initialDirectory) {
|
||||
myTargetDirectory.add(myClass.getContainingFile().copy());
|
||||
myClass.getContainingFile().delete();
|
||||
try {
|
||||
if (myTargetDirectory != initialDirectory) {
|
||||
myTargetDirectory.add(myClass.getContainingFile().copy());
|
||||
myClass.getContainingFile().delete();
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
RefactoringUIUtil.processIncorrectOperation(myProject, e);
|
||||
}
|
||||
for (final UsageInfo usage : usages) {
|
||||
if (usage instanceof BindToOldUsageInfo) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -32,7 +32,6 @@ import org.jetbrains.annotations.PropertyKey;
|
||||
import static com.intellij.lang.PsiBuilderUtil.expect;
|
||||
import static com.intellij.lang.PsiBuilderUtil.nextTokenType;
|
||||
import static com.intellij.lang.java.parser.JavaParserUtil.*;
|
||||
import static com.intellij.lang.java.parser.JavaParserUtil.exprType;
|
||||
|
||||
|
||||
public class DeclarationParser {
|
||||
@@ -59,12 +58,6 @@ public class DeclarationParser {
|
||||
myStatementParser = new StatementParser(this, myExpressionParser, myReferenceParser);
|
||||
}
|
||||
|
||||
protected DeclarationParser(ReferenceParser referenceParser, ExpressionParser expressionParser, StatementParser statementParser) {
|
||||
myReferenceParser = referenceParser;
|
||||
myExpressionParser = expressionParser;
|
||||
myStatementParser = statementParser;
|
||||
}
|
||||
|
||||
public ReferenceParser getReferenceParser() {
|
||||
return myReferenceParser;
|
||||
}
|
||||
@@ -184,7 +177,7 @@ public class DeclarationParser {
|
||||
myExpressionParser.parseArgumentList(builder);
|
||||
}
|
||||
else {
|
||||
JavaParserUtil.emptyElement(builder, JavaElementType.EXPRESSION_LIST);
|
||||
emptyElement(builder, JavaElementType.EXPRESSION_LIST);
|
||||
}
|
||||
|
||||
if (builder.getTokenType() == JavaTokenType.LBRACE) {
|
||||
@@ -312,7 +305,7 @@ public class DeclarationParser {
|
||||
}
|
||||
idPos.rollbackTo();
|
||||
if (typeParams == null) {
|
||||
JavaParserUtil.emptyElement(builder, JavaElementType.TYPE_PARAMETER_LIST);
|
||||
emptyElement(builder, JavaElementType.TYPE_PARAMETER_LIST);
|
||||
}
|
||||
builder.advanceLexer();
|
||||
if (builder.getTokenType() != JavaTokenType.LPARENTH) {
|
||||
@@ -371,7 +364,7 @@ public class DeclarationParser {
|
||||
if (builder.getTokenType() == JavaTokenType.LPARENTH) {
|
||||
if (context == Context.CLASS || context == Context.ANNOTATION_INTERFACE) { // method
|
||||
if (typeParams == null) {
|
||||
JavaParserUtil.emptyElement(type, JavaElementType.TYPE_PARAMETER_LIST);
|
||||
emptyElement(type, JavaElementType.TYPE_PARAMETER_LIST);
|
||||
}
|
||||
return parseMethodFromLeftParenth(builder, declaration, (context == Context.ANNOTATION_INTERFACE), false);
|
||||
}
|
||||
@@ -608,7 +601,7 @@ public class DeclarationParser {
|
||||
}
|
||||
else {
|
||||
error(builder, JavaErrorMessages.message("expected.type"));
|
||||
JavaParserUtil.emptyElement(builder, JavaElementType.TYPE);
|
||||
emptyElement(builder, JavaElementType.TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -404,7 +404,7 @@ public class ExpressionParser {
|
||||
final PsiBuilder.Marker refExpr = expr.precede();
|
||||
myReferenceParser.parseReferenceParameterList(builder, false, false);
|
||||
|
||||
if (!JavaParserUtil.expectOrError(builder, JavaTokenType.IDENTIFIER, "expected.identifier")) {
|
||||
if (!expectOrError(builder, JavaTokenType.IDENTIFIER, "expected.identifier")) {
|
||||
refExpr.done(JavaElementType.REFERENCE_EXPRESSION);
|
||||
startMarker.drop();
|
||||
return refExpr;
|
||||
@@ -726,7 +726,7 @@ public class ExpressionParser {
|
||||
}
|
||||
bracketCount++;
|
||||
|
||||
if (!JavaParserUtil.expectOrError(builder, JavaTokenType.RBRACKET, "expected.rbracket")) {
|
||||
if (!expectOrError(builder, JavaTokenType.RBRACKET, "expected.rbracket")) {
|
||||
newExpr.done(JavaElementType.NEW_EXPRESSION);
|
||||
return newExpr;
|
||||
}
|
||||
@@ -812,7 +812,7 @@ public class ExpressionParser {
|
||||
}
|
||||
}
|
||||
|
||||
final boolean closed = JavaParserUtil.expectOrError(builder, JavaTokenType.RPARENTH, "expected.rparen");
|
||||
final boolean closed = expectOrError(builder, JavaTokenType.RPARENTH, "expected.rparen");
|
||||
|
||||
list.done(JavaElementType.EXPRESSION_LIST);
|
||||
if (!closed) {
|
||||
@@ -822,7 +822,7 @@ public class ExpressionParser {
|
||||
}
|
||||
|
||||
private static void emptyExpression(final PsiBuilder builder) {
|
||||
JavaParserUtil.emptyElement(builder, JavaElementType.EMPTY_EXPRESSION);
|
||||
emptyElement(builder, JavaElementType.EMPTY_EXPRESSION);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -106,8 +106,8 @@ public class FileParser {
|
||||
}
|
||||
|
||||
if (impListInfo.second && firstDeclarationOk == Boolean.TRUE) {
|
||||
impListInfo.first.setCustomEdgeTokenBinders(JavaParserUtil.PRECEDING_COMMENT_BINDER, null); // pass comments behind fake import list
|
||||
firstDeclaration.setCustomEdgeTokenBinders(JavaParserUtil.SPECIAL_PRECEDING_COMMENT_BINDER, null);
|
||||
impListInfo.first.setCustomEdgeTokenBinders(PRECEDING_COMMENT_BINDER, null); // pass comments behind fake import list
|
||||
firstDeclaration.setCustomEdgeTokenBinders(SPECIAL_PRECEDING_COMMENT_BINDER, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -209,9 +209,7 @@ public class ReferenceParser {
|
||||
typeInfo.isParameterized = parseReferenceParameterList(builder, true, diamonds);
|
||||
}
|
||||
else {
|
||||
if (!isStaticImport || builder.getTokenType() == JavaTokenType.DOT) {
|
||||
emptyElement(builder, JavaElementType.REFERENCE_PARAMETER_LIST);
|
||||
}
|
||||
emptyElement(builder, JavaElementType.REFERENCE_PARAMETER_LIST);
|
||||
}
|
||||
|
||||
boolean hasIdentifier;
|
||||
@@ -261,7 +259,7 @@ public class ReferenceParser {
|
||||
if (parameterList) {
|
||||
typeInfo.isParameterized = parseReferenceParameterList(builder, true, diamonds);
|
||||
}
|
||||
else if (!isStaticImport || builder.getTokenType() == JavaTokenType.DOT) {
|
||||
else {
|
||||
emptyElement(builder, JavaElementType.REFERENCE_PARAMETER_LIST);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ public class ClsJavaCodeReferenceElementImpl extends ClsElementImpl implements P
|
||||
int index = 0;
|
||||
for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable((PsiClass)resolve)) {
|
||||
if (index >= myTypeParameters.length) {
|
||||
substitutionMap.put(parameter, null);
|
||||
if (parameter.getOwner() == resolve) substitutionMap.put(parameter, null);
|
||||
}
|
||||
else {
|
||||
substitutionMap.put(parameter, myTypeParameters[index].getType());
|
||||
|
||||
+5
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -65,25 +65,16 @@ public class PsiImportStaticReferenceElementImpl extends CompositePsiElement imp
|
||||
@Override
|
||||
public final ASTNode findChildByRole(int role) {
|
||||
LOG.assertTrue(ChildRole.isUnique(role));
|
||||
switch(role){
|
||||
switch (role) {
|
||||
default:
|
||||
return null;
|
||||
|
||||
case ChildRole.REFERENCE_NAME:
|
||||
if (getLastChildNode().getElementType() == JavaTokenType.IDENTIFIER){
|
||||
return getLastChildNode();
|
||||
}
|
||||
else{
|
||||
return null;
|
||||
}
|
||||
return findChildByType(JavaTokenType.IDENTIFIER);
|
||||
|
||||
case ChildRole.QUALIFIER:
|
||||
if (getFirstChildNode().getElementType() == JavaElementType.JAVA_CODE_REFERENCE){
|
||||
return getFirstChildNode();
|
||||
}
|
||||
else{
|
||||
return null;
|
||||
}
|
||||
final TreeElement node = getFirstChildNode();
|
||||
return node.getElementType() == JavaElementType.JAVA_CODE_REFERENCE ? node : null;
|
||||
|
||||
case ChildRole.DOT:
|
||||
return findChildByType(JavaTokenType.DOT);
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
void foo(){
|
||||
Properties properties = System.getProperties();
|
||||
final Map<String, String> systemProperties = <error descr="Inconvertible types; cannot cast 'java.util.Properties' to 'java.util.Map<java.lang.String,java.lang.String>'">(Map<String, String>) properties</error>;
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Create getter for 's'" "true"
|
||||
class A {
|
||||
private String s;
|
||||
|
||||
public String getS() {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Create getter and setter for 's'" "true"
|
||||
class A {
|
||||
private String s;
|
||||
|
||||
public String getS() {
|
||||
return s;
|
||||
}
|
||||
|
||||
public void setS(String s) {
|
||||
this.s = s;
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Create setter for 's'" "true"
|
||||
class A {
|
||||
private String s;
|
||||
|
||||
public void setS(String s) {
|
||||
this.s = s;
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Create getter for 's'" "true"
|
||||
class A {
|
||||
private String <caret>s;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Create getter and setter for 's'" "true"
|
||||
class A {
|
||||
private String <caret>s;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Create setter for 's'" "true"
|
||||
class A {
|
||||
private String <caret>s;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Create getter and setter for 's'" "false"
|
||||
class A {
|
||||
private final String <caret>s;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Create getter and setter for 's'" "false"
|
||||
class A {
|
||||
private final static String <caret>s;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Create setter for 's'" "false"
|
||||
class A {
|
||||
private final static String <caret>s;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Create setter for 's'" "false"
|
||||
class A {
|
||||
private final String <caret>s;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Create setter for 's'" "false"
|
||||
class A {
|
||||
private final static String <caret>s;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Remove redundant arguments to match 'method(int, Integer)'" "true"
|
||||
class A {
|
||||
public A() {
|
||||
method(new Integer(5), 5);
|
||||
}
|
||||
|
||||
private void method(int i, Integer i2) {
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Remove redundant arguments to match 'method(int, T)'" "true"
|
||||
class A {
|
||||
public A() {
|
||||
method(5, new Exception());
|
||||
}
|
||||
|
||||
private <T extends Exception> void method(int i, T t) {
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Remove redundant arguments to match 'method(int, String)'" "true"
|
||||
class A {
|
||||
public A() {
|
||||
method(5, "");
|
||||
}
|
||||
|
||||
private void method(int s, String s2) {
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Remove redundant arguments to match 'method(int, Integer)'" "true"
|
||||
class A {
|
||||
public A() {
|
||||
method(new Integer(5), 5,<caret> "", new String());
|
||||
}
|
||||
|
||||
private void method(int i, Integer i2) {
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Remove redundant arguments to match 'method(int, T)'" "true"
|
||||
class A {
|
||||
public A() {
|
||||
method(5,<caret> new Exception(), new Exception(), "", 3);
|
||||
}
|
||||
|
||||
private <T extends Exception> void method(int i, T t) {
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Remove redundant arguments to match 'method(int, String)'" "true"
|
||||
class A {
|
||||
public A() {
|
||||
method(5, "",<caret> 10);
|
||||
}
|
||||
|
||||
private void method(int s, String s2) {
|
||||
}
|
||||
}
|
||||
@@ -22,4 +22,6 @@ PsiJavaFile:StaticImport1.java
|
||||
<empty list>
|
||||
PsiJavaToken:DOT('.')
|
||||
PsiIdentifier:sort('sort')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
@@ -22,4 +22,6 @@ PsiJavaFile:StaticImport1.java
|
||||
<empty list>
|
||||
PsiJavaToken:DOT('.')
|
||||
PsiIdentifier:sort('sort')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
@@ -7,5 +7,7 @@ PsiJavaFile:UnclosedImport3.java
|
||||
PsiWhiteSpace(' ')
|
||||
PsiImportStaticReferenceElement:a
|
||||
PsiIdentifier:a('a')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiErrorElement:';' expected
|
||||
<empty list>
|
||||
@@ -135,6 +135,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIllegalGenericTypeInInstanceof() throws Exception {doTest(false);}
|
||||
public void testIDEA57339() throws Exception {doTest(false);}
|
||||
public void testIDEA57340() throws Exception {doTest(false);}
|
||||
public void testInconvertibleTypes() throws Exception {doTest(false);}
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.daemon.quickFix;
|
||||
|
||||
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
|
||||
|
||||
/**
|
||||
* @author Danila Ponomarenko
|
||||
*/
|
||||
public class CreateGetterOrSetterTest extends LightQuickFixTestCase {
|
||||
public void test() throws Exception {
|
||||
enableInspectionTool(new UnusedSymbolLocalInspection());
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/createGetterOrSetter";
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
public class RemoveRedundantArgumentTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception { doAllTests(); }
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/removeRedundantArgument";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -20,9 +20,7 @@ import com.intellij.lang.LanguageASTFactory;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.lang.java.JavaParserDefinition;
|
||||
import com.intellij.mock.MockModule;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.roots.impl.LanguageLevelProjectExtensionImpl;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
@@ -42,10 +40,7 @@ import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public abstract class JavaParsingTestCase extends ParsingTestCase {
|
||||
|
||||
private Module myModule;
|
||||
private LanguageLevel myLanguageLevel;
|
||||
|
||||
@SuppressWarnings({"JUnitTestCaseWithNonTrivialConstructors"})
|
||||
@@ -68,17 +63,9 @@ public abstract class JavaParsingTestCase extends ParsingTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myModule = new MockModule(getProject(), getTestRootDisposable());
|
||||
myLanguageLevel = LanguageLevel.JDK_1_6;
|
||||
getProject().registerService(LanguageLevelProjectExtension.class, new LanguageLevelProjectExtensionImpl(getProject()));
|
||||
addExplicitExtension(LanguageASTFactory.INSTANCE, JavaLanguage.INSTANCE, new JavaASTFactory());
|
||||
try {
|
||||
registerApplicationService((Class<Object>)Class.forName("com.intellij.psi.jsp.JspSpiUtil"),
|
||||
Class.forName("com.intellij.jsp.impl.JspSpiUtilImpl").newInstance());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// jsp not available
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,18 +78,12 @@ public abstract class JavaParsingTestCase extends ParsingTestCase {
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
myModule = null;
|
||||
}
|
||||
|
||||
protected interface TestParser {
|
||||
void parse(PsiBuilder builder);
|
||||
}
|
||||
|
||||
public Module getModule() {
|
||||
return myModule;
|
||||
}
|
||||
|
||||
|
||||
protected void doParserTest(final String text, final TestParser parser) {
|
||||
final String name = getTestName(false);
|
||||
myFile = createPsiFile(name, text, parser);
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.roots;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
@@ -12,8 +27,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
|
||||
import com.intellij.openapi.roots.impl.ModuleRootManagerImpl;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -115,7 +129,7 @@ public class MultiModuleEditingTest extends ModuleTestCase {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ProjectRootManagerEx.getInstanceEx(myProject).multiCommit(moduleModel, new ModifiableRootModel[]{rootModelB, rootModelA});
|
||||
ModuleRootManagerImpl.multiCommit(new ModifiableRootModel[]{rootModelB, rootModelA}, moduleModel);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -152,7 +166,7 @@ public class MultiModuleEditingTest extends ModuleTestCase {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ProjectRootManager.getInstance(myProject).multiCommit(moduleModel, new ModifiableRootModel[]{rootModelB});
|
||||
ModuleRootManagerImpl.multiCommit(new ModifiableRootModel[]{rootModelB}, moduleModel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,12 +1,29 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.roots;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkModificator;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.impl.ModuleRootManagerImpl;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
@@ -74,7 +91,10 @@ public class RootsChangedTest extends ModuleTestCase {
|
||||
final ModifiableRootModel rootModelB = ModuleRootManager.getInstance(moduleB).getModifiableModel();
|
||||
rootModelA.setSdk(jdk);
|
||||
rootModelB.setSdk(jdk);
|
||||
ProjectRootManager.getInstance(myProject).multiCommit(new ModifiableRootModel[]{rootModelA, rootModelB});
|
||||
ModifiableRootModel[] rootModels = new ModifiableRootModel[]{rootModelA, rootModelB};
|
||||
if (rootModels.length > 0) {
|
||||
ModuleRootManagerImpl.multiCommit(rootModels, ModuleManager.getInstance(rootModels[0].getProject()).getModifiableModel());
|
||||
}
|
||||
assertEventsCount(1);
|
||||
|
||||
final SdkModificator sdkModificator = jdk.getSdkModificator();
|
||||
@@ -106,7 +126,10 @@ public class RootsChangedTest extends ModuleTestCase {
|
||||
final ModifiableRootModel rootModelB = ModuleRootManager.getInstance(moduleB).getModifiableModel();
|
||||
rootModelA.inheritSdk();
|
||||
rootModelB.inheritSdk();
|
||||
ProjectRootManager.getInstance(myProject).multiCommit(new ModifiableRootModel[]{rootModelA, rootModelB});
|
||||
ModifiableRootModel[] rootModels = new ModifiableRootModel[]{rootModelA, rootModelB};
|
||||
if (rootModels.length > 0) {
|
||||
ModuleRootManagerImpl.multiCommit(rootModels, ModuleManager.getInstance(rootModels[0].getProject()).getModifiableModel());
|
||||
}
|
||||
assertEventsCount(1);
|
||||
|
||||
ProjectRootManager.getInstance(myProject).setProjectSdk(jdk);
|
||||
@@ -138,7 +161,10 @@ public class RootsChangedTest extends ModuleTestCase {
|
||||
rootModelB.addLibraryEntry(libraryA);
|
||||
rootModelA.addInvalidLibrary("Q", libraryTable.getTableLevel());
|
||||
rootModelB.addInvalidLibrary("Q", libraryTable.getTableLevel());
|
||||
ProjectRootManager.getInstance(myProject).multiCommit(new ModifiableRootModel[]{rootModelA, rootModelB});
|
||||
ModifiableRootModel[] rootModels = new ModifiableRootModel[]{rootModelA, rootModelB};
|
||||
if (rootModels.length > 0) {
|
||||
ModuleRootManagerImpl.multiCommit(rootModels, ModuleManager.getInstance(rootModels[0].getProject()).getModifiableModel());
|
||||
}
|
||||
assertEventsCount(1);
|
||||
|
||||
final Library.ModifiableModel libraryModifiableModel2 = libraryA.getModifiableModel();
|
||||
@@ -195,7 +221,10 @@ public class RootsChangedTest extends ModuleTestCase {
|
||||
final Library libraryQ = libraryTable.createLibrary("Q");
|
||||
assertEventsCount(0);
|
||||
|
||||
ProjectRootManager.getInstance(myProject).multiCommit(new ModifiableRootModel[]{rootModelA, rootModelB});
|
||||
ModifiableRootModel[] rootModels = new ModifiableRootModel[]{rootModelA, rootModelB};
|
||||
if (rootModels.length > 0) {
|
||||
ModuleRootManagerImpl.multiCommit(rootModels, ModuleManager.getInstance(rootModels[0].getProject()).getModifiableModel());
|
||||
}
|
||||
assertEventsCount(1);
|
||||
|
||||
libraryTable.removeLibrary(libraryQ);
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user