mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 06:51:17 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -17,7 +17,7 @@ package com.intellij.execution.junit2.info;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiPackage;
|
||||
@@ -29,7 +29,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Date: 2/20/12
|
||||
*/
|
||||
public class LocationUtil {
|
||||
public static boolean isJarAttached(@NotNull Location location, final PsiPackage aPackage, final String fqn) {
|
||||
public static boolean isJarAttached(@NotNull Location location, @NotNull final PsiPackage aPackage, final String fqn) {
|
||||
return isJarAttached(location, fqn, aPackage.getDirectories());
|
||||
}
|
||||
|
||||
public static boolean isJarAttached(@NotNull Location location,
|
||||
final String fqn,
|
||||
final PsiDirectory[] directories) {
|
||||
final JavaPsiFacade facade = JavaPsiFacade.getInstance(location.getProject());
|
||||
boolean testngJarFound = false;
|
||||
final Module locationModule = location.getModule();
|
||||
@@ -37,8 +43,8 @@ public class LocationUtil {
|
||||
testngJarFound = facade.findClass(fqn, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(locationModule, true)) != null;
|
||||
}
|
||||
else {
|
||||
for (PsiDirectory directory : aPackage.getDirectories()) {
|
||||
final Module module = ModuleUtil.findModuleForFile(directory.getVirtualFile(), location.getProject());
|
||||
for (PsiDirectory directory : directories) {
|
||||
final Module module = ModuleUtilCore.findModuleForFile(directory.getVirtualFile(), location.getProject());
|
||||
if (module != null) {
|
||||
if (facade.findClass(fqn, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, true)) != null) {
|
||||
testngJarFound = true;
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.projectImport.ProjectFormatPanel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -38,7 +39,7 @@ import java.io.File;
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Jul 17, 2007
|
||||
*/
|
||||
public class ProjectNameStep extends ModuleWizardStep {
|
||||
public class ProjectNameStep extends SettingsStep {
|
||||
private final JPanel myPanel;
|
||||
protected final JPanel myAdditionalContentPanel;
|
||||
protected NamePathComponent myNamePathComponent;
|
||||
@@ -169,4 +170,25 @@ public class ProjectNameStep extends ModuleWizardStep {
|
||||
|
||||
return shouldContinue;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getSettingsPanel() {
|
||||
return getComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getExpertSettingsPanel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsStep addField(String label, JComponent field) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsStep addExpertPanel(JComponent panel) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.util.newProjectWizard.ProjectSettingsStep">
|
||||
<grid id="807b" binding="myModulePanel" layout-manager="GridBagLayout">
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="893" height="453"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="8a2b7" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" 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="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="1.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e6ad1" class="javax.swing.JTextField" binding="myModuleName">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="1f996" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="e6ad1"/>
|
||||
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.name.title"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4af6e" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myModuleContentRoot">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="c4851" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="4af6e"/>
|
||||
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.root.title"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="83a50" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myModuleFileLocation">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<preferredSize width="280" height="20"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a4319" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="83a50"/>
|
||||
<text resource-bundle="messages/ProjectBundle" key="project.new.wizard.module.file.title"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="fa640" binding="myHeader" 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="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<visible value="true"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="8ada9" binding="myExpertPanel" layout-manager="GridBagLayout">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,313 @@
|
||||
/*
|
||||
* 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.ide.util.newProjectWizard;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.highlighter.ModuleFileType;
|
||||
import com.intellij.ide.util.BrowseFilesListener;
|
||||
import com.intellij.ide.util.newProjectWizard.modes.CreateFromTemplateMode;
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.ide.util.projectWizard.ProjectWizardUtil;
|
||||
import com.intellij.ide.util.projectWizard.SettingsStep;
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
|
||||
public class ProjectSettingsStep extends ProjectNameStep {
|
||||
private JPanel myModulePanel;
|
||||
private JTextField myModuleName;
|
||||
private TextFieldWithBrowseButton myModuleContentRoot;
|
||||
private TextFieldWithBrowseButton myModuleFileLocation;
|
||||
private JPanel myHeader;
|
||||
private JPanel myExpertPanel;
|
||||
|
||||
private boolean myModuleNameChangedByUser = false;
|
||||
private boolean myModuleNameDocListenerEnabled = true;
|
||||
|
||||
private boolean myContentRootChangedByUser = false;
|
||||
private boolean myContentRootDocListenerEnabled = true;
|
||||
|
||||
private boolean myImlLocationChangedByUser = false;
|
||||
private boolean myImlLocationDocListenerEnabled = true;
|
||||
|
||||
|
||||
public ProjectSettingsStep(final WizardContext wizardContext) {
|
||||
super(wizardContext, null);
|
||||
myAdditionalContentPanel.add(myModulePanel,
|
||||
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1, 1, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
|
||||
myHeader.setVisible(myWizardContext.isCreatingNewProject() && !isCreateFromTemplateMode());
|
||||
myNamePathComponent.getNameComponent().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
protected void textChanged(final DocumentEvent e) {
|
||||
if (!myModuleNameChangedByUser) {
|
||||
setModuleName(myNamePathComponent.getNameValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
myModuleContentRoot.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.content.root.chooser.title"), ProjectBundle.message("project.new.wizard.module.content.root.chooser.description"),
|
||||
myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);
|
||||
|
||||
myNamePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
protected void textChanged(final DocumentEvent e) {
|
||||
if (!myContentRootChangedByUser) {
|
||||
setModuleContentRoot(myNamePathComponent.getPath());
|
||||
}
|
||||
}
|
||||
});
|
||||
myModuleName.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
protected void textChanged(final DocumentEvent e) {
|
||||
if (myModuleNameDocListenerEnabled) {
|
||||
myModuleNameChangedByUser = true;
|
||||
}
|
||||
String path = getDefaultBaseDir(wizardContext);
|
||||
final String moduleName = getModuleName();
|
||||
if (path.length() > 0 && !Comparing.strEqual(moduleName, myNamePathComponent.getNameValue())) {
|
||||
path += "/" + moduleName;
|
||||
}
|
||||
if (!myContentRootChangedByUser) {
|
||||
final boolean f = myModuleNameChangedByUser;
|
||||
myModuleNameChangedByUser = true;
|
||||
setModuleContentRoot(path);
|
||||
myModuleNameChangedByUser = f;
|
||||
}
|
||||
if (!myImlLocationChangedByUser) {
|
||||
setImlFileLocation(path);
|
||||
}
|
||||
}
|
||||
});
|
||||
myModuleContentRoot.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
protected void textChanged(final DocumentEvent e) {
|
||||
if (myContentRootDocListenerEnabled) {
|
||||
myContentRootChangedByUser = true;
|
||||
}
|
||||
if (!myImlLocationChangedByUser) {
|
||||
setImlFileLocation(getModuleContentRoot());
|
||||
}
|
||||
if (!myModuleNameChangedByUser) {
|
||||
final String path = FileUtil.toSystemIndependentName(getModuleContentRoot());
|
||||
final int idx = path.lastIndexOf("/");
|
||||
|
||||
boolean f = myContentRootChangedByUser;
|
||||
myContentRootChangedByUser = true;
|
||||
|
||||
boolean i = myImlLocationChangedByUser;
|
||||
myImlLocationChangedByUser = true;
|
||||
|
||||
setModuleName(idx >= 0 ? path.substring(idx + 1) : "");
|
||||
|
||||
myContentRootChangedByUser = f;
|
||||
myImlLocationChangedByUser = i;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
myModuleFileLocation.addBrowseFolderListener(ProjectBundle.message("project.new.wizard.module.file.chooser.title"), ProjectBundle.message("project.new.wizard.module.file.description"),
|
||||
myWizardContext.getProject(), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR);
|
||||
myModuleFileLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
protected void textChanged(final DocumentEvent e) {
|
||||
if (myImlLocationDocListenerEnabled) {
|
||||
myImlLocationChangedByUser = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
myNamePathComponent.getPathComponent().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
protected void textChanged(final DocumentEvent e) {
|
||||
if (!myImlLocationChangedByUser) {
|
||||
setImlFileLocation(myNamePathComponent.getPath());
|
||||
}
|
||||
}
|
||||
});
|
||||
if (wizardContext.isCreatingNewProject()) {
|
||||
setModuleName(myNamePathComponent.getNameValue());
|
||||
setModuleContentRoot(myNamePathComponent.getPath());
|
||||
setImlFileLocation(myNamePathComponent.getPath());
|
||||
} else {
|
||||
final Project project = wizardContext.getProject();
|
||||
assert project != null;
|
||||
VirtualFile baseDir = project.getBaseDir();
|
||||
if (baseDir != null) { //e.g. was deleted
|
||||
final String baseDirPath = baseDir.getPath();
|
||||
String moduleName = ProjectWizardUtil.findNonExistingFileName(baseDirPath, "untitled", "");
|
||||
String contentRoot = baseDirPath + "/" + moduleName;
|
||||
if (!Comparing.strEqual(project.getName(), wizardContext.getProjectName()) && !wizardContext.isCreatingNewProject() && wizardContext.getProjectName() != null) {
|
||||
moduleName = ProjectWizardUtil.findNonExistingFileName(wizardContext.getProjectFileDirectory(), wizardContext.getProjectName(), "");
|
||||
contentRoot = wizardContext.getProjectFileDirectory();
|
||||
}
|
||||
setModuleName(moduleName);
|
||||
setModuleContentRoot(contentRoot);
|
||||
setImlFileLocation(contentRoot);
|
||||
myModuleName.select(0, moduleName.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String getModuleContentRoot() {
|
||||
return myModuleContentRoot.getText();
|
||||
}
|
||||
|
||||
private boolean isCreateFromTemplateMode() {
|
||||
return myMode instanceof CreateFromTemplateMode;
|
||||
}
|
||||
|
||||
private String getDefaultBaseDir(WizardContext wizardContext) {
|
||||
if (wizardContext.isCreatingNewProject()) {
|
||||
return myNamePathComponent.getPath();
|
||||
} else {
|
||||
final Project project = wizardContext.getProject();
|
||||
assert project != null;
|
||||
final VirtualFile baseDir = project.getBaseDir();
|
||||
if (baseDir != null) {
|
||||
return baseDir.getPath();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myWizardContext.isCreatingNewProject() ? super.getPreferredFocusedComponent() : myModuleName;
|
||||
}
|
||||
|
||||
private void setImlFileLocation(final String path) {
|
||||
myImlLocationDocListenerEnabled = false;
|
||||
myModuleFileLocation.setText(FileUtil.toSystemDependentName(path));
|
||||
myImlLocationDocListenerEnabled = true;
|
||||
}
|
||||
|
||||
private void setModuleContentRoot(final String path) {
|
||||
myContentRootDocListenerEnabled = false;
|
||||
myModuleContentRoot.setText(FileUtil.toSystemDependentName(path));
|
||||
myContentRootDocListenerEnabled = true;
|
||||
}
|
||||
|
||||
private void setModuleName(String moduleName) {
|
||||
myModuleNameDocListenerEnabled = false;
|
||||
myModuleName.setText(moduleName);
|
||||
myModuleNameDocListenerEnabled = true;
|
||||
}
|
||||
|
||||
public void updateDataModel() {
|
||||
|
||||
super.updateDataModel();
|
||||
|
||||
final ModuleBuilder builder = (ModuleBuilder)myWizardContext.getProjectBuilder();
|
||||
assert builder != null;
|
||||
final String moduleName = getModuleName();
|
||||
builder.setName(moduleName);
|
||||
builder.setModuleFilePath(
|
||||
FileUtil.toSystemIndependentName(myModuleFileLocation.getText()) + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
|
||||
builder.setContentEntryPath(FileUtil.toSystemIndependentName(getModuleContentRoot()));
|
||||
}
|
||||
|
||||
public boolean validate() throws ConfigurationException {
|
||||
final String moduleName = getModuleName();
|
||||
if (!myWizardContext.isCreatingNewProject()) {
|
||||
final String moduleFileDirectory = myModuleFileLocation.getText();
|
||||
if (moduleFileDirectory.length() == 0) {
|
||||
throw new ConfigurationException("Enter module file location");
|
||||
}
|
||||
if (moduleName.length() == 0) {
|
||||
throw new ConfigurationException("Enter a module name");
|
||||
}
|
||||
|
||||
if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.module.file"), moduleFileDirectory,
|
||||
myImlLocationChangedByUser)) {
|
||||
return false;
|
||||
}
|
||||
if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.module.content.root"), getModuleContentRoot(),
|
||||
myContentRootChangedByUser)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
File moduleFile = new File(moduleFileDirectory, moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
|
||||
if (moduleFile.exists()) {
|
||||
int answer = Messages.showYesNoDialog(IdeBundle.message("prompt.overwrite.project.file", moduleFile.getAbsolutePath(), IdeBundle.message("project.new.wizard.module.identification")),
|
||||
IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon());
|
||||
if (answer != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Project project = myWizardContext.getProject();
|
||||
if (project != null) {
|
||||
final Module module;
|
||||
final ProjectStructureConfigurable fromConfigurable = ProjectStructureConfigurable.getInstance(project);
|
||||
if (fromConfigurable != null) {
|
||||
module = fromConfigurable.getModulesConfig().getModule(moduleName);
|
||||
}
|
||||
else {
|
||||
module = ModuleManager.getInstance(project).findModuleByName(moduleName);
|
||||
}
|
||||
if (module != null) {
|
||||
throw new ConfigurationException("Module \'" + moduleName + "\' already exist in project. Please, specify another name.");
|
||||
}
|
||||
}
|
||||
return !myWizardContext.isCreatingNewProject() || super.validate();
|
||||
}
|
||||
|
||||
protected String getModuleName() {
|
||||
return myModuleName.getText().trim();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getSettingsPanel() {
|
||||
return myWizardContext.isCreatingNewProject() ? myNamePathComponent : myModulePanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getExpertSettingsPanel() {
|
||||
return myWizardContext.isCreatingNewProject() ? myModulePanel : myExpertPanel.getComponentCount() == 0 ? null : myExpertPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsStep addField(String label, JComponent field) {
|
||||
JComponent settingsPanel = getSettingsPanel();
|
||||
|
||||
JLabel jLabel = new JBLabel(label);
|
||||
jLabel.setLabelFor(field);
|
||||
settingsPanel.add(jLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.WEST,
|
||||
GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
||||
settingsPanel.add(field, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsStep addExpertPanel(JComponent panel) {
|
||||
JComponent settingsPanel = myExpertPanel;
|
||||
settingsPanel.add(panel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -70,5 +70,7 @@ public class SelectTemplateSettings implements PersistentStateComponent<SelectTe
|
||||
@Tag("treeState")
|
||||
public Element myElement = new Element(STATE_ELEMENT_NAME);
|
||||
|
||||
public boolean EXPERT_MODE = false;
|
||||
|
||||
private TreeState myTreeState = new TreeState();
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<text value="Please select desired template from the list"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="e5cc3" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="e5cc3" layout-manager="GridLayoutManager" row-count="3" 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="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -82,11 +82,19 @@
|
||||
<properties>
|
||||
<contentType value="text/html"/>
|
||||
<editable value="false"/>
|
||||
<text value="<html> <head> </head> <body> </body> </html> "/>
|
||||
<text value="<html> <head> </head> <body> <p style="margin-top: 0"> </p> </body> </html> "/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="5d4a2" binding="myExpertPlaceholder" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
|
||||
@@ -15,11 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ide.util.newProjectWizard;
|
||||
|
||||
import com.intellij.ide.highlighter.ModuleFileType;
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
|
||||
import com.intellij.ide.util.projectWizard.ProjectWizardStepFactory;
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.ide.util.projectWizard.*;
|
||||
import com.intellij.ide.util.treeView.AlphaComparator;
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.ide.util.treeView.TreeState;
|
||||
@@ -32,7 +28,6 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.platform.ProjectTemplate;
|
||||
import com.intellij.platform.ProjectTemplatesFactory;
|
||||
@@ -40,9 +35,7 @@ import com.intellij.platform.templates.ArchivedTemplatesFactory;
|
||||
import com.intellij.platform.templates.EmptyModuleTemplatesFactory;
|
||||
import com.intellij.psi.codeStyle.MinusculeMatcher;
|
||||
import com.intellij.psi.codeStyle.NameUtil;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.SearchTextField;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.speedSearch.ElementFilter;
|
||||
import com.intellij.ui.treeStructure.*;
|
||||
import com.intellij.ui.treeStructure.filtered.FilteringTreeBuilder;
|
||||
@@ -77,10 +70,12 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
private SearchTextField mySearchField;
|
||||
private JTextPane myDescriptionPane;
|
||||
private JPanel myDescriptionPanel;
|
||||
private JPanel myExpertPlaceholder;
|
||||
private HideableTitledPanel myExpertPanel = new HideableTitledPanel("E&xpert Settings", false);
|
||||
|
||||
private final WizardContext myContext;
|
||||
private final StepSequence mySequence;
|
||||
private ModuleWizardStep mySettingsStep;
|
||||
private SettingsStep mySettingsStep;
|
||||
|
||||
private final ElementFilter.Active.Impl<SimpleNode> myFilter;
|
||||
private final FilteringTreeBuilder myBuilder;
|
||||
@@ -92,6 +87,7 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
myContext = context;
|
||||
mySequence = sequence;
|
||||
Messages.installHyperlinkSupport(myDescriptionPane);
|
||||
myExpertPlaceholder.add(myExpertPanel, BorderLayout.CENTER);
|
||||
|
||||
ProjectTemplatesFactory[] factories = ProjectTemplatesFactory.EP_NAME.getExtensions();
|
||||
final MultiMap<String, ProjectTemplate> groups = new MultiMap<String, ProjectTemplate>();
|
||||
@@ -190,7 +186,7 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
myModuleBuilder = template == null ? null : template.createModuleBuilder();
|
||||
mySettingsStep = myModuleBuilder == null ? null : myModuleBuilder.createSettingsStep(myContext);
|
||||
if (mySettingsStep == null) {
|
||||
mySettingsStep = ProjectWizardStepFactory.getInstance().createNameAndLocationStep(myContext);
|
||||
mySettingsStep = ProjectWizardStepFactory.getInstance().createSettingsStep(myContext);
|
||||
}
|
||||
setupPanels(template);
|
||||
mySequence.setType(myModuleBuilder == null ? null : myModuleBuilder.getBuilderId());
|
||||
@@ -209,7 +205,7 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
});
|
||||
myDescriptionPanel.setVisible(false);
|
||||
mySettingsPanel.setVisible(false);
|
||||
|
||||
myExpertPanel.setVisible(false);
|
||||
|
||||
new AnAction() {
|
||||
@Override
|
||||
@@ -241,33 +237,37 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void setupPanels(@Nullable ProjectTemplate template) {
|
||||
if (mySettingsPanel.getComponentCount() > 0) {
|
||||
mySettingsPanel.remove(0);
|
||||
}
|
||||
myExpertPanel.setContentComponent(null);
|
||||
JComponent expertSettingsPanel = null;
|
||||
String description = null;
|
||||
if (template != null) {
|
||||
if (mySettingsStep != null) {
|
||||
mySettingsPanel.add(mySettingsStep.getComponent(), BorderLayout.NORTH);
|
||||
mySettingsPanel.add(mySettingsStep.getSettingsPanel(), BorderLayout.NORTH);
|
||||
expertSettingsPanel = mySettingsStep.getExpertSettingsPanel();
|
||||
if (expertSettingsPanel != null) {
|
||||
expertSettingsPanel.setBorder(IdeBorderFactory.createEmptyBorder(5, IdeBorderFactory.TITLED_BORDER_INDENT, 5, 0));
|
||||
myExpertPanel.setContentComponent(expertSettingsPanel);
|
||||
}
|
||||
}
|
||||
mySettingsPanel.setVisible(mySettingsStep != null);
|
||||
String description = template.getDescription();
|
||||
description = template.getDescription();
|
||||
if (StringUtil.isNotEmpty(description)) {
|
||||
StringBuilder sb = new StringBuilder("<html><body><font face=\"Verdana\" ");
|
||||
sb.append(SystemInfo.isMac ? "" : "size=\"-1\"").append('>');
|
||||
sb.append(description).append("</font></body></html>");
|
||||
description = sb.toString();
|
||||
myDescriptionPane.setText(description);
|
||||
}
|
||||
}
|
||||
|
||||
myDescriptionPane.setText(description);
|
||||
myDescriptionPanel.setVisible(StringUtil.isNotEmpty(description));
|
||||
}
|
||||
else {
|
||||
mySettingsPanel.setVisible(false);
|
||||
myDescriptionPanel.setVisible(false);
|
||||
}
|
||||
mySettingsPanel.setVisible(mySettingsStep != null);
|
||||
myExpertPanel.setVisible(expertSettingsPanel != null);
|
||||
myDescriptionPanel.setVisible(StringUtil.isNotEmpty(description));
|
||||
mySettingsPanel.revalidate();
|
||||
mySettingsPanel.repaint();
|
||||
}
|
||||
@@ -275,12 +275,15 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
@Override
|
||||
public void updateStep() {
|
||||
myBuilder.queueUpdate();
|
||||
myExpertPanel.setOn(SelectTemplateSettings.getInstance().EXPERT_MODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStepLeaving() {
|
||||
TreeState state = TreeState.createOn(myTemplatesTree, (DefaultMutableTreeNode)myTemplatesTree.getModel().getRoot());
|
||||
SelectTemplateSettings.getInstance().setTreeState(state);
|
||||
SelectTemplateSettings settings = SelectTemplateSettings.getInstance();
|
||||
settings.setTreeState(state);
|
||||
settings.EXPERT_MODE = myExpertPanel.isExpanded();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -374,18 +377,10 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
|
||||
@Override
|
||||
public void updateDataModel() {
|
||||
myContext.setProjectBuilder(myModuleBuilder);
|
||||
if (mySettingsStep != null) {
|
||||
mySettingsStep.updateDataModel();
|
||||
}
|
||||
final ModuleBuilder builder = myModuleBuilder;
|
||||
if (builder != null) {
|
||||
String name = myContext.getProjectName();
|
||||
builder.setName(name);
|
||||
String directory = myContext.getProjectFileDirectory();
|
||||
builder.setModuleFilePath(
|
||||
FileUtil.toSystemIndependentName(directory + "/" + name + ModuleFileType.DOT_DEFAULT_EXTENSION));
|
||||
builder.setContentEntryPath(directory);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -287,8 +287,8 @@ public class SourcePathsStep extends AbstractStepWithProgress<List<JavaModuleSou
|
||||
@Nullable
|
||||
private String getSourceDirectoryPath() {
|
||||
final String contentEntryPath = getContentRootPath();
|
||||
final String dirName = myTfSourceDirectoryName.getText().trim().replace(File.separatorChar, '/');
|
||||
if (contentEntryPath != null) {
|
||||
final String dirName = myTfSourceDirectoryName.getText().trim().replace(File.separatorChar, '/');
|
||||
return dirName.length() > 0? contentEntryPath + "/" + dirName : contentEntryPath;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.ide.util.projectWizard.JavaSettingsStep">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="5" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="31"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="1cc8f" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="mySourcePath">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="src"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="445f5" class="com.intellij.ui.components.JBCheckBox" binding="myCreateSourceRoot" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="true"/>
|
||||
<text value="&Create source root:"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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.ide.util.projectWizard;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.util.BrowseFilesListener;
|
||||
import com.intellij.ide.util.newProjectWizard.ProjectSettingsStep;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkType;
|
||||
import com.intellij.openapi.roots.ui.configuration.JdkComboBox;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
|
||||
import com.intellij.openapi.ui.ComponentWithBrowseButton;
|
||||
import com.intellij.openapi.ui.TextComponentAccessor;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 10/23/12
|
||||
*/
|
||||
public class JavaSettingsStep extends ProjectSettingsStep {
|
||||
|
||||
private final ModuleBuilder myModuleBuilder;
|
||||
private JBCheckBox myCreateSourceRoot;
|
||||
private TextFieldWithBrowseButton mySourcePath;
|
||||
private JPanel myPanel;
|
||||
private final JdkComboBox myJdkComboBox;
|
||||
|
||||
public JavaSettingsStep(WizardContext wizardContext, ModuleBuilder moduleBuilder, Condition<SdkType> sdkFilter) {
|
||||
super(wizardContext);
|
||||
myModuleBuilder = moduleBuilder;
|
||||
|
||||
ProjectSdksModel model = new ProjectSdksModel();
|
||||
Project project = wizardContext.getProject();
|
||||
model.reset(project, sdkFilter);
|
||||
myJdkComboBox = new JdkComboBox(model, sdkFilter);
|
||||
JButton button = new JButton("\u001BNew...");
|
||||
myJdkComboBox.setSetupButton(button, project, model,
|
||||
project == null ? new JdkComboBox.NoneJdkComboBoxItem() : new JdkComboBox.ProjectJdkComboBoxItem(),
|
||||
null,
|
||||
false);
|
||||
JPanel jdkPanel = new JPanel(new BorderLayout(SystemInfo.isMac? 0 : 2, 0));
|
||||
jdkPanel.add(myJdkComboBox);
|
||||
jdkPanel.add(button, BorderLayout.EAST);
|
||||
addField("Project \u001BSDK:", jdkPanel);
|
||||
|
||||
if (moduleBuilder instanceof JavaModuleBuilder) {
|
||||
ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener =
|
||||
new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
|
||||
IdeBundle.message("prompt.select.source.directory"), null, mySourcePath, project, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR,
|
||||
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
|
||||
@Override
|
||||
protected void onFileChoosen(VirtualFile chosenFile) {
|
||||
String contentEntryPath = myModuleBuilder.getContentEntryPath();
|
||||
String path = chosenFile.getPath();
|
||||
if (contentEntryPath != null) {
|
||||
|
||||
int i = StringUtil.commonPrefixLength(contentEntryPath, path);
|
||||
mySourcePath.setText(path.substring(i));
|
||||
}
|
||||
else {
|
||||
mySourcePath.setText(path);
|
||||
}
|
||||
}
|
||||
};
|
||||
mySourcePath.addBrowseFolderListener(project, listener);
|
||||
myCreateSourceRoot.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mySourcePath.setEnabled(myCreateSourceRoot.isSelected());
|
||||
}
|
||||
});
|
||||
addExpertPanel(myPanel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDataModel() {
|
||||
super.updateDataModel();
|
||||
Sdk jdk = myJdkComboBox.getSelectedJdk();
|
||||
myWizardContext.setProjectJdk(jdk);
|
||||
if (myModuleBuilder instanceof JavaModuleBuilder && myCreateSourceRoot.isSelected()) {
|
||||
String contentEntryPath = myModuleBuilder.getContentEntryPath();
|
||||
if (contentEntryPath != null) {
|
||||
final String dirName = mySourcePath.getText().trim().replace(File.separatorChar, '/');
|
||||
String text = dirName.length() > 0? contentEntryPath + "/" + dirName : contentEntryPath;
|
||||
((JavaModuleBuilder)myModuleBuilder).setSourcePaths(Collections.singletonList(Pair.create(text, "")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -24,6 +24,7 @@ import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -136,4 +137,14 @@ public class ProjectWizardStepFactoryImpl extends ProjectWizardStepFactory {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsStep createSettingsStep(WizardContext context) {
|
||||
return new ProjectSettingsStep(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsStep createJavaSettingsStep(final WizardContext context, final ModuleBuilder moduleBuilder, Condition<SdkType> sdkFilter) {
|
||||
return new JavaSettingsStep(context, moduleBuilder, sdkFilter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,14 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkType;
|
||||
import com.intellij.openapi.projectRoots.SdkTypeId;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.JdkListConfigurable;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
|
||||
import com.intellij.openapi.ui.ComboBoxWithWidePopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Conditions;
|
||||
import com.intellij.ui.ScreenUtil;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.Consumer;
|
||||
@@ -49,7 +51,7 @@ import java.util.List;
|
||||
public class JdkComboBox extends ComboBoxWithWidePopup {
|
||||
|
||||
@Nullable
|
||||
private final Condition<Sdk> myFilter;
|
||||
private final Condition<SdkType> myFilter;
|
||||
@Nullable
|
||||
private final Condition<SdkType> myCreationFilter;
|
||||
|
||||
@@ -58,9 +60,14 @@ public class JdkComboBox extends ComboBoxWithWidePopup {
|
||||
}
|
||||
|
||||
public JdkComboBox(@NotNull final ProjectSdksModel jdkModel,
|
||||
@Nullable Condition<Sdk> filter,
|
||||
Condition<SdkType> filter) {
|
||||
this(jdkModel, filter, filter);
|
||||
}
|
||||
|
||||
public JdkComboBox(@NotNull final ProjectSdksModel jdkModel,
|
||||
@Nullable Condition<SdkType> filter,
|
||||
@Nullable Condition<SdkType> creationFilter) {
|
||||
super(new JdkComboBoxModel(jdkModel, filter));
|
||||
super(new JdkComboBoxModel(jdkModel, getSdkFilter(filter)));
|
||||
myFilter = filter;
|
||||
myCreationFilter = creationFilter;
|
||||
setRenderer(new ProjectJdkListRenderer() {
|
||||
@@ -114,7 +121,7 @@ public class JdkComboBox extends ComboBoxWithWidePopup {
|
||||
}
|
||||
|
||||
public void setSetupButton(final JButton setUpButton,
|
||||
final Project project,
|
||||
@Nullable final Project project,
|
||||
final ProjectSdksModel jdksModel,
|
||||
final JdkComboBoxItem firstItem,
|
||||
@Nullable final Condition<Sdk> additionalSetup,
|
||||
@@ -124,7 +131,7 @@ public class JdkComboBox extends ComboBoxWithWidePopup {
|
||||
}
|
||||
|
||||
public void setSetupButton(final JButton setUpButton,
|
||||
final Project project,
|
||||
@Nullable final Project project,
|
||||
final ProjectSdksModel jdksModel,
|
||||
final JdkComboBoxItem firstItem,
|
||||
@Nullable final Condition<Sdk> additionalSetup,
|
||||
@@ -132,13 +139,15 @@ public class JdkComboBox extends ComboBoxWithWidePopup {
|
||||
setUpButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final JdkListConfigurable configurable = JdkListConfigurable.getInstance(project);
|
||||
DefaultActionGroup group = new DefaultActionGroup();
|
||||
jdksModel.createAddActions(group, JdkComboBox.this, new Consumer<Sdk>() {
|
||||
@Override
|
||||
public void consume(final Sdk jdk) {
|
||||
configurable.addJdkNode(jdk, false);
|
||||
reloadModel(firstItem, project);
|
||||
if (project != null) {
|
||||
final JdkListConfigurable configurable = JdkListConfigurable.getInstance(project);
|
||||
configurable.addJdkNode(jdk, false);
|
||||
}
|
||||
reloadModel(new JdkComboBoxItem(jdk), project);
|
||||
setSelectedJdk(jdk); //restore selection
|
||||
if (additionalSetup != null) {
|
||||
if (additionalSetup.value(jdk)) { //leave old selection
|
||||
@@ -241,14 +250,18 @@ public class JdkComboBox extends ComboBoxWithWidePopup {
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadModel(JdkComboBoxItem firstItem, Project project) {
|
||||
public void reloadModel(JdkComboBoxItem firstItem, @Nullable Project project) {
|
||||
final DefaultComboBoxModel model = ((DefaultComboBoxModel)getModel());
|
||||
if (project == null) {
|
||||
model.addElement(firstItem);
|
||||
return;
|
||||
}
|
||||
model.removeAllElements();
|
||||
model.addElement(firstItem);
|
||||
final ProjectSdksModel projectJdksModel = ProjectStructureConfigurable.getInstance(project).getProjectJdksModel();
|
||||
List<Sdk> projectJdks = new ArrayList<Sdk>(projectJdksModel.getProjectSdks().values());
|
||||
if (myFilter != null) {
|
||||
projectJdks = ContainerUtil.filter(projectJdks, myFilter);
|
||||
projectJdks = ContainerUtil.filter(projectJdks, getSdkFilter(myFilter));
|
||||
}
|
||||
Collections.sort(projectJdks, new Comparator<Sdk>() {
|
||||
@Override
|
||||
@@ -262,10 +275,10 @@ public class JdkComboBox extends ComboBoxWithWidePopup {
|
||||
}
|
||||
|
||||
private static class JdkComboBoxModel extends DefaultComboBoxModel {
|
||||
public JdkComboBoxModel(final ProjectSdksModel jdksModel, final @Nullable Condition<Sdk> filter) {
|
||||
public JdkComboBoxModel(final ProjectSdksModel jdksModel, Condition<Sdk> sdkFilter) {
|
||||
Sdk[] jdks = jdksModel.getSdks();
|
||||
if (filter != null) {
|
||||
final List<Sdk> filtered = ContainerUtil.filter(jdks, filter);
|
||||
if (sdkFilter != null) {
|
||||
final List<Sdk> filtered = ContainerUtil.filter(jdks, sdkFilter);
|
||||
jdks = filtered.toArray(new Sdk[filtered.size()]);
|
||||
}
|
||||
Arrays.sort(jdks, new Comparator<Sdk>() {
|
||||
@@ -285,7 +298,17 @@ public class JdkComboBox extends ComboBoxWithWidePopup {
|
||||
return (JdkComboBoxItem)super.getElementAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Condition<Sdk> getSdkFilter(@Nullable final Condition<SdkType> filter) {
|
||||
return filter == null ? Conditions.<Sdk>alwaysTrue() : new Condition<Sdk>() {
|
||||
@Override
|
||||
public boolean value(Sdk sdk) {
|
||||
SdkTypeId type = sdk.getSdkType();
|
||||
return type instanceof SdkType && filter.value((SdkType)type);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static class JdkComboBoxItem {
|
||||
private final Sdk myJdk;
|
||||
|
||||
|
||||
+1
-15
@@ -18,11 +18,9 @@ package com.intellij.codeInsight.completion;
|
||||
import com.intellij.codeInsight.ExpectedTypeInfo;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupItem;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.statistics.JavaStatisticsManager;
|
||||
import com.intellij.psi.statistics.StatisticsInfo;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -37,19 +35,6 @@ public class JavaCompletionStatistician extends CompletionStatistician{
|
||||
return StatisticsInfo.EMPTY;
|
||||
}
|
||||
|
||||
final ExpectedTypeInfo[] infos = JavaCompletionUtil.EXPECTED_TYPES.getValue(location);
|
||||
if (infos != null && infos.length > 0) {
|
||||
final boolean primitivesOnly = ContainerUtil.and(infos, new Condition<ExpectedTypeInfo>() {
|
||||
@Override
|
||||
public boolean value(final ExpectedTypeInfo info) {
|
||||
return info.getType() instanceof PsiPrimitiveType;
|
||||
}
|
||||
});
|
||||
if (primitivesOnly) {
|
||||
return StatisticsInfo.EMPTY; //collecting statistics on primitive types usually has only negative effects
|
||||
}
|
||||
}
|
||||
|
||||
LookupItem item = element.as(LookupItem.CLASS_CONDITION_KEY);
|
||||
if (item == null) return null;
|
||||
|
||||
@@ -58,6 +43,7 @@ public class JavaCompletionStatistician extends CompletionStatistician{
|
||||
if (o instanceof PsiMember) {
|
||||
String key2 = JavaStatisticsManager.getMemberUseKey2((PsiMember)o);
|
||||
if (o instanceof PsiClass) {
|
||||
final ExpectedTypeInfo[] infos = JavaCompletionUtil.EXPECTED_TYPES.getValue(location);
|
||||
PsiType expectedType = infos != null && infos.length > 0 ? infos[0].getDefaultType() : null;
|
||||
return new StatisticsInfo(JavaStatisticsManager.getAfterNewKey(expectedType), key2);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -92,11 +92,9 @@ public class PreferByKindWeigher extends LookupElementWeigher {
|
||||
final PsiAnnotation annotation = PsiTreeUtil.getParentOfType(position, PsiAnnotation.class);
|
||||
assert annotation != null;
|
||||
PsiAnnotationOwner owner = annotation.getOwner();
|
||||
if (owner instanceof PsiModifierList || owner instanceof PsiTypeElement ||
|
||||
owner instanceof PsiMethodReceiver || owner instanceof PsiTypeParameter) {
|
||||
PsiElement member = ((PsiElement)owner).getParent();
|
||||
final String[] elementTypeFields = PsiAnnotationImpl
|
||||
.getApplicableElementTypeFields(owner instanceof PsiModifierList ? member : (PsiElement)owner);
|
||||
if (owner instanceof PsiModifierList || owner instanceof PsiTypeElement || owner instanceof PsiTypeParameter) {
|
||||
PsiElement member = owner instanceof PsiModifierList ? ((PsiElement)owner).getParent() : (PsiElement)owner;
|
||||
final String[] elementTypeFields = PsiAnnotationImpl.getApplicableElementTypeFields(member);
|
||||
return new Condition<PsiClass>() {
|
||||
@Override
|
||||
public boolean value(PsiClass psiClass) {
|
||||
|
||||
+1
-1
@@ -254,7 +254,7 @@ public class AnnotationsHighlightUtil {
|
||||
@Nullable
|
||||
public static HighlightInfo checkApplicability(final PsiAnnotation annotation) {
|
||||
PsiAnnotationOwner owner = annotation.getOwner();
|
||||
if (owner instanceof PsiModifierList || owner instanceof PsiTypeElement || owner instanceof PsiMethodReceiver || owner instanceof PsiTypeParameter) {
|
||||
if (owner instanceof PsiModifierList || owner instanceof PsiTypeElement || owner instanceof PsiTypeParameter) {
|
||||
PsiJavaCodeReferenceElement nameRef = annotation.getNameReferenceElement();
|
||||
if (nameRef == null) {
|
||||
return null;
|
||||
|
||||
+1
-1
@@ -634,7 +634,7 @@ public class GenericsHighlightUtil {
|
||||
type instanceof PsiWildcardType && ((PsiWildcardType)type).getBound() instanceof PsiPrimitiveType) {
|
||||
final PsiElement element = new PsiMatcherImpl(typeElement)
|
||||
.parent(PsiMatchers.hasClass(PsiReferenceParameterList.class))
|
||||
.parent(PsiMatchers.hasClass(PsiJavaCodeReferenceElement.class))
|
||||
.parent(PsiMatchers.hasClass(PsiJavaCodeReferenceElement.class, PsiNewExpression.class))
|
||||
.getElement();
|
||||
if (element == null) return null;
|
||||
|
||||
|
||||
+9
-5
@@ -836,11 +836,15 @@ public class HighlightClassUtil {
|
||||
PsiClass targetClass = aClass.getSuperClass();
|
||||
if (targetClass == null) return null;
|
||||
PsiExpression qualifier = superCall.getMethodExpression().getQualifierExpression();
|
||||
if (qualifier != null && PsiUtil.isInnerClass(targetClass)) {
|
||||
PsiClass outerClass = targetClass.getContainingClass();
|
||||
if (outerClass != null) {
|
||||
PsiClassType outerType = JavaPsiFacade.getInstance(project).getElementFactory().createType(outerClass);
|
||||
return HighlightUtil.checkAssignability(outerType, null, qualifier, qualifier);
|
||||
if (qualifier != null) {
|
||||
if (PsiUtil.isInnerClass(targetClass)) {
|
||||
PsiClass outerClass = targetClass.getContainingClass();
|
||||
if (outerClass != null) {
|
||||
PsiClassType outerType = JavaPsiFacade.getInstance(project).getElementFactory().createType(outerClass);
|
||||
return HighlightUtil.checkAssignability(outerType, null, qualifier, qualifier);
|
||||
}
|
||||
} else {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, qualifier, "'" + HighlightUtil.formatClass(targetClass) + "' is not an inner class");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
+6
@@ -1236,6 +1236,12 @@ public class HighlightMethodUtil {
|
||||
}
|
||||
if (classReference != null && aClass.hasModifierProperty(PsiModifier.PROTECTED) && callingProtectedConstructorFromDerivedClass(constructorCall, aClass)) {
|
||||
holder.add(buildAccessProblem(classReference, typeResolveResult, aClass));
|
||||
} else if (aClass.isInterface() && constructorCall instanceof PsiNewExpression) {
|
||||
final PsiReferenceParameterList typeArgumentList = ((PsiNewExpression)constructorCall).getTypeArgumentList();
|
||||
if (typeArgumentList.getTypeArguments().length > 0) {
|
||||
holder.add(HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, typeArgumentList,
|
||||
"Anonymous class implements interface; cannot have type arguments"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
+2
-1
@@ -61,7 +61,8 @@ public class ExtendsListFix extends LocalQuickFixAndIntentionActionOnPsiElement
|
||||
messageKey = toAdd ? "add.interface.to.implements.list" : "remove.interface.from.implements.list";
|
||||
}
|
||||
|
||||
myName = QuickFixBundle.message(messageKey, aClass.getName(), classToExtendFrom == null ? "" : classToExtendFrom.getQualifiedName());
|
||||
myName = QuickFixBundle.message(messageKey, aClass.getName(), classToExtendFrom == null ? "" : classToExtendFrom instanceof PsiTypeParameter ? classToExtendFrom.getName()
|
||||
: classToExtendFrom.getQualifiedName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,16 +16,16 @@
|
||||
package com.intellij.openapi.module;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.util.projectWizard.JavaModuleBuilder;
|
||||
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
|
||||
import com.intellij.ide.util.projectWizard.ProjectWizardStepFactory;
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.ide.util.projectWizard.*;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkType;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkType;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
@@ -103,8 +103,13 @@ public class JavaModuleType extends ModuleType<JavaModuleBuilder> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ModuleWizardStep createSettingsStep(WizardContext context) {
|
||||
return ProjectWizardStepFactory.getInstance().createNameAndLocationStep(context);
|
||||
public SettingsStep createSettingsStep(WizardContext context, ModuleBuilder moduleBuilder) {
|
||||
return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(context, moduleBuilder, new Condition<SdkType>() {
|
||||
@Override
|
||||
public boolean value(SdkType sdk) {
|
||||
return sdk instanceof JavaSdkType;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static Icon getJavaModuleIcon() {
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.intellij.psi.codeStyle.arrangement.MemberOrderService;
|
||||
import com.intellij.psi.impl.compiled.ClsClassImpl;
|
||||
import com.intellij.psi.impl.source.codeStyle.ImportHelper;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -184,7 +185,7 @@ public class JavaPsiImplementationHelperImpl extends JavaPsiImplementationHelper
|
||||
MemberOrderService service = ServiceManager.getService(MemberOrderService.class);
|
||||
PsiElement anchor = service.getAnchor(member, settings.getCommonSettings(JavaLanguage.INSTANCE), aClass);
|
||||
|
||||
if (anchor != null && anchor.getNextSibling() == aClass.getRBrace()) {
|
||||
if (anchor != null && PsiTreeUtil.skipSiblingsForward(anchor, PsiWhiteSpace.class) == aClass.getRBrace()) {
|
||||
// Given member should be inserted as the last child.
|
||||
return aClass.getRBrace();
|
||||
}
|
||||
|
||||
@@ -395,11 +395,6 @@ public class LightMethodBuilder extends LightElement implements PsiMethod, Origi
|
||||
return getContainingFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiMethodReceiver getMethodReceiver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiType getReturnTypeNoResolve() {
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -63,11 +64,14 @@ public class RenameJavaClassProcessor extends RenamePsiElementProcessor {
|
||||
final UsageInfo[] usages, final RefactoringElementListener listener) throws IncorrectOperationException {
|
||||
PsiClass aClass = (PsiClass) element;
|
||||
ArrayList<UsageInfo> postponedCollisions = new ArrayList<UsageInfo>();
|
||||
List<MemberHidesOuterMemberUsageInfo> hidesOut = new ArrayList<MemberHidesOuterMemberUsageInfo>();
|
||||
// rename all references
|
||||
for (final UsageInfo usage : usages) {
|
||||
if (usage instanceof ResolvableCollisionUsageInfo) {
|
||||
if (usage instanceof CollidingClassImportUsageInfo) {
|
||||
((CollidingClassImportUsageInfo)usage).getImportStatement().delete();
|
||||
} else if (usage instanceof MemberHidesOuterMemberUsageInfo) {
|
||||
hidesOut.add((MemberHidesOuterMemberUsageInfo)usage);
|
||||
}
|
||||
else {
|
||||
postponedCollisions.add(usage);
|
||||
@@ -100,6 +104,13 @@ public class RenameJavaClassProcessor extends RenamePsiElementProcessor {
|
||||
collision.resolveCollision();
|
||||
}
|
||||
|
||||
for (MemberHidesOuterMemberUsageInfo usage : hidesOut) {
|
||||
PsiJavaCodeReferenceElement collidingRef = (PsiJavaCodeReferenceElement)usage.getElement();
|
||||
/* PsiReferenceExpression ref = RenameJavaMemberProcessor.createQualifiedMemberReference(aClass, collidingRef);
|
||||
collidingRef.replace(ref);*/
|
||||
}
|
||||
|
||||
|
||||
listener.elementRenamed(aClass);
|
||||
}
|
||||
|
||||
@@ -190,6 +201,33 @@ public class RenameJavaClassProcessor extends RenamePsiElementProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (aClass instanceof PsiTypeParameter) {
|
||||
final PsiTypeParameterListOwner owner = ((PsiTypeParameter)aClass).getOwner();
|
||||
if (owner instanceof PsiClass) {
|
||||
final PsiClass[] supers = ((PsiClass)owner).getSupers();
|
||||
for (PsiClass superClass : supers) {
|
||||
if (newName.equals(superClass.getName())) {
|
||||
final ClassCollisionsDetector classCollisionsDetector = new ClassCollisionsDetector(aClass);
|
||||
for (PsiReference reference : ReferencesSearch.search(superClass, new LocalSearchScope(superClass))) {
|
||||
classCollisionsDetector.addClassCollisions(reference.getElement(), newName, result);
|
||||
}
|
||||
}
|
||||
PsiClass[] inners = superClass.getInnerClasses();
|
||||
for (final PsiClass inner : inners) {
|
||||
if (newName.equals(inner.getName())) {
|
||||
ReferencesSearch.search(inner).forEach(new Processor<PsiReference>() {
|
||||
public boolean process(final PsiReference reference) {
|
||||
PsiElement refElement = reference.getElement();
|
||||
if (refElement instanceof PsiReferenceExpression && ((PsiReferenceExpression)refElement).isQualified()) return true;
|
||||
MemberHidesOuterMemberUsageInfo info = new MemberHidesOuterMemberUsageInfo(refElement, aClass);
|
||||
result.add(info);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,10 +65,8 @@ public class GenericsUtil {
|
||||
|
||||
if (type1 instanceof PsiArrayType && type2 instanceof PsiArrayType) {
|
||||
final PsiType componentType = getLeastUpperBound(((PsiArrayType)type1).getComponentType(),
|
||||
((PsiArrayType)type2).getComponentType(), manager);
|
||||
if (componentType != null) {
|
||||
return componentType.createArrayType();
|
||||
}
|
||||
((PsiArrayType)type2).getComponentType(), compared, manager);
|
||||
return componentType.createArrayType();
|
||||
}
|
||||
if (type1 instanceof PsiIntersectionType) {
|
||||
Set<PsiType> newConjuncts = new LinkedHashSet<PsiType>();
|
||||
|
||||
@@ -207,9 +207,6 @@ public interface PsiMethod extends PsiMember, PsiNameIdentifierOwner, PsiModifie
|
||||
@NotNull
|
||||
HierarchicalMethodSignature getHierarchicalMethodSignature();
|
||||
|
||||
@Nullable
|
||||
PsiMethodReceiver getMethodReceiver();
|
||||
|
||||
@Nullable
|
||||
PsiType getReturnTypeNoResolve();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
/** @deprecated obsolete (to remove in IDEA 13) */
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public interface PsiMethodReceiver extends PsiAnnotationOwner, PsiParameter {
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@ package com.intellij.psi.util;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootModificationTracker;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -933,7 +932,9 @@ public class TypeConversionUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean typesAgree(PsiType typeLeft, PsiType typeRight, boolean allowUncheckedConversion) {
|
||||
private static final RecursionGuard ourGuard = RecursionManager.createGuard("isAssignable");
|
||||
|
||||
public static boolean typesAgree(PsiType typeLeft, PsiType typeRight, final boolean allowUncheckedConversion) {
|
||||
if (typeLeft instanceof PsiWildcardType) {
|
||||
final PsiWildcardType leftWildcard = (PsiWildcardType)typeLeft;
|
||||
final PsiType leftBound = leftWildcard.getBound();
|
||||
@@ -949,7 +950,18 @@ public class TypeConversionUtil {
|
||||
return rightWildcard.isExtends() && isAssignable(leftBound, rightWildcard.getBound(), allowUncheckedConversion);
|
||||
}
|
||||
else { //isSuper
|
||||
return rightWildcard.isSuper() && isAssignable(rightWildcard.getBound(), leftBound, allowUncheckedConversion);
|
||||
if (rightWildcard.isSuper()) {
|
||||
final Boolean assignable = ourGuard.doPreventingRecursion(rightWildcard, true, new NotNullComputable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
return isAssignable(rightWildcard.getBound(), leftBound, allowUncheckedConversion);
|
||||
}
|
||||
});
|
||||
if (assignable != null && assignable.booleanValue()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -333,7 +333,7 @@ public class DeclarationParser {
|
||||
}
|
||||
|
||||
if (!expect(builder, JavaTokenType.IDENTIFIER)) {
|
||||
if ((context == Context.CODE_BLOCK) && modListInfo.second) {
|
||||
if ((context == Context.CODE_BLOCK) && Boolean.TRUE.equals(modListInfo.second)) {
|
||||
declaration.rollbackTo();
|
||||
return null;
|
||||
}
|
||||
@@ -408,17 +408,6 @@ public class DeclarationParser {
|
||||
|
||||
eatBrackets(builder, constructor, "expected.semicolon");
|
||||
|
||||
if (builder.getTokenType() == JavaTokenType.AT) {
|
||||
final PsiBuilder.Marker receiver = builder.mark();
|
||||
final PsiBuilder.Marker annotations = parseAnnotations(builder);
|
||||
if (annotations != null) {
|
||||
done(receiver, JavaElementType.METHOD_RECEIVER);
|
||||
}
|
||||
else {
|
||||
receiver.drop();
|
||||
}
|
||||
}
|
||||
|
||||
myParser.getReferenceParser().parseReferenceList(builder, JavaTokenType.THROWS_KEYWORD, JavaElementType.THROWS_LIST, JavaTokenType.COMMA);
|
||||
|
||||
final boolean hasDefault = expect(builder, JavaTokenType.DEFAULT_KEYWORD);
|
||||
@@ -565,8 +554,6 @@ public class DeclarationParser {
|
||||
}
|
||||
}
|
||||
|
||||
// todo: false positive
|
||||
//noinspection ConstantConditions
|
||||
if (invalidElements != null) {
|
||||
invalidElements.error(errorMessage);
|
||||
}
|
||||
@@ -608,7 +595,7 @@ public class DeclarationParser {
|
||||
typeInfo = myParser.getReferenceParser().parseTypeInfo(builder, flags);
|
||||
|
||||
if (typeInfo == null) {
|
||||
if (modListInfo.second) {
|
||||
if (Boolean.TRUE.equals(modListInfo.second)) {
|
||||
param.rollbackTo();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -13,10 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
@@ -28,6 +24,9 @@ import com.intellij.psi.impl.PsiManagerImpl;
|
||||
import com.intellij.psi.impl.compiled.ClsFileImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class ClassFileViewProvider extends SingleRootFileViewProvider {
|
||||
public ClassFileViewProvider(@NotNull final PsiManager manager, @NotNull final VirtualFile file) {
|
||||
super(manager, file);
|
||||
@@ -47,7 +46,7 @@ public class ClassFileViewProvider extends SingleRootFileViewProvider {
|
||||
int dotIndex = name.lastIndexOf('.');
|
||||
if (dotIndex < 0) dotIndex = name.length();
|
||||
int index = name.lastIndexOf('$', dotIndex);
|
||||
if (index >= 0) return null;
|
||||
if (index > 0) return null; // todo: read actual class name from file
|
||||
|
||||
return new ClsFileImpl((PsiManagerImpl)PsiManager.getInstance(project), this);
|
||||
}
|
||||
|
||||
@@ -432,10 +432,7 @@ public class ClsMethodImpl extends ClsRepositoryPsiElement<PsiMethodStub> implem
|
||||
public SearchScope getUseScope() {
|
||||
return PsiImplUtil.getMemberUseScope(this);
|
||||
}
|
||||
@Override
|
||||
public PsiMethodReceiver getMethodReceiver() {
|
||||
return null; //todo parse cls
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getReturnTypeNoResolve() {
|
||||
return getReturnType();
|
||||
@@ -445,5 +442,4 @@ public class ClsMethodImpl extends ClsRepositoryPsiElement<PsiMethodStub> implem
|
||||
protected boolean isVisibilitySupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -256,11 +256,6 @@ public class LightMethod extends LightElement implements PsiMethod {
|
||||
return getContainingClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiMethodReceiver getMethodReceiver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getReturnTypeNoResolve() {
|
||||
return getReturnType();
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
|
||||
import com.intellij.psi.impl.java.stubs.PsiMethodStub;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.impl.source.tree.CompositeElement;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaSharedImplUtil;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
@@ -159,13 +158,6 @@ public class PsiMethodImpl extends JavaStubPsiElement<PsiMethodStub> implements
|
||||
return PsiSuperMethodImplUtil.getHierarchicalMethodSignature(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiMethodReceiver getMethodReceiver() {
|
||||
ASTNode node = getNode().findChildByType(JavaElementType.METHOD_RECEIVER);
|
||||
if (node == null) return null;
|
||||
return (PsiMethodReceiver)node.getPsi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement setName(@NotNull String name) throws IncorrectOperationException{
|
||||
PsiImplUtil.setName(getNameIdentifier(), name);
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* 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.psi.impl.source;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.CompositePsiElement;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
public class PsiMethodReceiverImpl extends CompositePsiElement implements PsiMethodReceiver {
|
||||
public PsiMethodReceiverImpl() {
|
||||
super(JavaElementType.METHOD_RECEIVER);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiElement getDeclarationScope() {
|
||||
return getParent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVarArgs() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiAnnotation[] getAnnotations() {
|
||||
return getChildrenAsPsiElements(ElementType.ANNOTATIONS, PsiAnnotation.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) {
|
||||
return PsiImplUtil.findAnnotation(this, qualifiedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiType getType() {
|
||||
return JavaPsiFacade.getElementFactory(getProject()).createType(((PsiMethod)getParent()).getContainingClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiTypeElement getTypeElement() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiExpression getInitializer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasInitializer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void normalizeDeclaration() throws IncorrectOperationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object computeConstantValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiIdentifier getNameIdentifier() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "this";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiModifierList getModifierList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasModifierProperty(@NonNls @NotNull String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiAnnotation[] getApplicableAnnotations() {
|
||||
return getAnnotations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType getTypeNoResolve() {
|
||||
return getType();
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,6 @@ public interface JavaElementType {
|
||||
IElementType LABELED_STATEMENT = new JavaCompositeElementType("LABELED_STATEMENT", PsiLabeledStatementImpl.class);
|
||||
IElementType ASSERT_STATEMENT = new JavaCompositeElementType("ASSERT_STATEMENT", PsiAssertStatementImpl.class);
|
||||
IElementType ANNOTATION_ARRAY_INITIALIZER = new JavaCompositeElementType("ANNOTATION_ARRAY_INITIALIZER", PsiArrayInitializerMemberValueImpl.class);
|
||||
IElementType METHOD_RECEIVER = new JavaCompositeElementType("METHOD_RECEIVER", PsiMethodReceiverImpl.class);
|
||||
|
||||
class ICodeBlockElementType extends IErrorCounterReparseableElementType implements ICompositeElementType, ILightLazyParseableElementType {
|
||||
private ICodeBlockElementType() {
|
||||
|
||||
+4
-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.
|
||||
@@ -123,7 +123,9 @@ public class PsiAnnotationImpl extends JavaStubPsiElement<PsiAnnotationStub> imp
|
||||
if (parent instanceof PsiTypeElement) {
|
||||
return ((PsiTypeElement)parent).getOwner(this);
|
||||
}
|
||||
if (parent instanceof PsiMethodReceiver || parent instanceof PsiTypeParameter) return (PsiAnnotationOwner)parent;
|
||||
if (parent instanceof PsiTypeParameter) {
|
||||
return (PsiAnnotationOwner)parent;
|
||||
}
|
||||
PsiElement member = parent.getParent();
|
||||
String[] elementTypeFields = getApplicableElementTypeFields(member);
|
||||
if (elementTypeFields == null) return null;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
class AbstractSet<T> {
|
||||
public boolean contains(T t) {}
|
||||
}
|
||||
|
||||
class MySet<T> extends AbstractSet<T> {
|
||||
public boolean containsAll(Collection<?> c) {}
|
||||
}
|
||||
|
||||
public class Foo {
|
||||
MySet<String> set;
|
||||
void foo() {
|
||||
if (set.<caret>
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
class A {
|
||||
class S {
|
||||
}
|
||||
|
||||
class C extends S {
|
||||
C(A c) {
|
||||
c.super();
|
||||
}
|
||||
C(B b) {
|
||||
b.super();
|
||||
}
|
||||
}
|
||||
}
|
||||
class B extends A {}
|
||||
|
||||
class A1 {
|
||||
static class S {
|
||||
}
|
||||
|
||||
class C extends S {
|
||||
C(A1 c) {
|
||||
<error descr="'A1.S' is not an inner class">c</error>.super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class C2 {
|
||||
C2(String c){
|
||||
<error descr="'java.lang.Object' is not an inner class">c</error>.super();
|
||||
}
|
||||
}
|
||||
|
||||
class A3 {
|
||||
class S {
|
||||
}
|
||||
|
||||
class C extends S {
|
||||
C(String c) {
|
||||
<error descr="Incompatible types. Found: 'java.lang.String', required: 'A3'">c</error>.super();
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -14,4 +14,13 @@ class C extends A
|
||||
C.this.super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class C1 {
|
||||
class B1 {}
|
||||
class D1 extends C1.B1 {
|
||||
D1() {
|
||||
C1.this.super();
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class A<T> {
|
||||
class B{}
|
||||
}
|
||||
class C<T> extends A<T> {
|
||||
{
|
||||
B[] o = <error descr="Generic array creation">{}</error>;
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,6 @@ abstract class C {
|
||||
|
||||
@Anno(nested = {@Anno, @Anno})
|
||||
void notWrong() { }
|
||||
}
|
||||
}
|
||||
|
||||
class B extends <error descr="Annotations are not allowed here">@Deprecated</error> Object{}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
class A1<T> {}
|
||||
class B1<T extends A1<? super A1<? super T>>>{
|
||||
{
|
||||
T a = null;
|
||||
<error descr="Incompatible types. Found: 'T', required: 'A1<? super T>'">A1<? super T> b = a;</error>
|
||||
}
|
||||
}
|
||||
|
||||
class A<T> {}
|
||||
class B<T extends A<? super A<? super T>>> {
|
||||
|
||||
void bar(T x){
|
||||
foo(x);
|
||||
}
|
||||
void foo(A<? super T> x){}
|
||||
void foo(Object x){}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
abstract class A {
|
||||
abstract <S, T extends Iterable<S>> void foo();
|
||||
|
||||
{
|
||||
foo();
|
||||
}
|
||||
}
|
||||
|
||||
class X{
|
||||
<T extends Enum<T>> void foo(){
|
||||
foo();
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
abstract class A<S> {
|
||||
abstract <T extends S> void foo();
|
||||
void bar(A<? super Exception> x){
|
||||
x.<<error descr="Type parameter 'String[]' is not within its bound; should extend 'capture<? super java.lang.Exception>'">String[]</error>>foo();
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class A<T> {
|
||||
<S extends A<? extends T>> void foo(){}
|
||||
void bar(A<?> a){
|
||||
a.<<error descr="Type parameter 'A' is not within its bound; should extend 'A<capture<?>>'">A<?></error>>foo();
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class C<<warning descr="Type parameter 'T' is never used">T</warning>>{}
|
||||
class A<<warning descr="Type parameter 'S' is never used">S</warning>,<warning descr="Type parameter 'T' is never used">T</warning>> {}
|
||||
class B<S,T extends C<S>> extends A<S,T> {
|
||||
void foo(B<?,?> x){
|
||||
bar(x);
|
||||
}
|
||||
<S, T> void bar(A<S,T> x){
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
class A<T> {}
|
||||
|
||||
interface IA{
|
||||
<T> void foo(A<? extends T[]> x);
|
||||
}
|
||||
interface IB{
|
||||
<T> int foo(A<? extends T> x);
|
||||
}
|
||||
class C {
|
||||
<T extends IA & IB> void bar(T x, A<String[]> y){
|
||||
<error descr="Incompatible types. Found: 'void', required: 'int'">int z = x.foo(y);</error>
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class A<S> {
|
||||
void bar(A<? super Exception> x, A<? super Throwable> y){
|
||||
foo(x, y);
|
||||
}
|
||||
|
||||
<T> T foo(A<? super T> x, A<? super T> y){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class A<T> {
|
||||
Exception[] bar(A<? super Exception[]> x, A<? super Throwable[]> y){
|
||||
return this.foo(x, y);
|
||||
}
|
||||
|
||||
<T> T foo(A<? super T> x, A<? super T> y){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class A<T> {
|
||||
A<A<? extends T>> foo(){
|
||||
return null;
|
||||
}
|
||||
|
||||
void bar(A<?> x){
|
||||
baz<error descr="'baz(A<A<?>>)' in 'A' cannot be applied to '(A<A<capture<?>>>)'">(x.foo())</error>;
|
||||
}
|
||||
|
||||
<S> void baz(A<A<? extends S>> x){}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
class A<K>{
|
||||
void foo(A<A<A<String>>> b){ <error descr="Inferred type 'A<java.lang.String>' for type parameter 'S' is not within its bound; should extend 'A<java.lang.Object>'">bar(b)</error>; }
|
||||
<U, S extends A<U>, T extends A<S>> void bar(A<T> a){}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
|
||||
class D<T> {
|
||||
void foo(D<D<?>> x){ this.bar(x); }
|
||||
<T extends Throwable> void bar(D<? super D<T>> x){}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
interface IA {
|
||||
<T extends Cloneable & Iterable> void foo(T x);
|
||||
<T extends Iterable & Cloneable> void foo(T x);
|
||||
}
|
||||
|
||||
abstract class A<T extends Throwable> {
|
||||
abstract <T extends Comparable<?> & Iterable> void foo(T x, A<?> y);
|
||||
abstract <T extends Iterable & Comparable<?>> void foo(T x, A<? extends Throwable> y);
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
|
||||
interface IA {
|
||||
<T> void a(Iterable<String> x);
|
||||
}
|
||||
|
||||
interface IB {
|
||||
<T> void a(Iterable x);
|
||||
}
|
||||
|
||||
<error descr="'a(Iterable)' in 'IB' clashes with 'a(Iterable<String>)' in 'IA'; both methods have same erasure, yet neither overrides the other">abstract class C implements IA, IB</error> {}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
class A<S> {
|
||||
<T> T foo(T x, S y){
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
class B<S> extends A<S> {
|
||||
Object foo(Object x, Object y){
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
<error descr="'foo(T, S)' in 'A' clashes with 'foo(Object, Object)' in 'B'; both methods have same erasure, yet neither overrides the other">class C extends B<String></error> {
|
||||
@Override
|
||||
<T> T foo(T x, String y) {
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'T'">return super.foo(x, y);</error>
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
abstract class C{
|
||||
abstract <T> T foo(T x, T y);
|
||||
|
||||
{
|
||||
Long s = (Long) foo(1,1L);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
abstract class A{
|
||||
abstract <S extends Number & Comparable<?>, T extends Number & Comparable<? extends S>> T foo(
|
||||
Comparable<? extends T> x,
|
||||
Comparable<? extends T> y);
|
||||
|
||||
{
|
||||
foo(1, 1L);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class B<T,S>{}
|
||||
abstract class A<T> {
|
||||
abstract B<T,T> foo();
|
||||
<T> void baz(B<T,T> b){}
|
||||
void bar(A<?> a){
|
||||
baz(a.foo());
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
abstract class A<T>{
|
||||
abstract <S> S foo(S x, S y);
|
||||
<S extends Number & Comparable<? extends Number>> void baz(A<S> a){}
|
||||
|
||||
void bar(A<Long> x, A<Integer> y){
|
||||
baz(foo(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
abstract class A1<T>{
|
||||
abstract <S> S foo(S x, S y);
|
||||
<T extends Number & Comparable<?>, S extends Number & Comparable<? extends T>> void baz(A1<S> a){}
|
||||
|
||||
void bar(A1<Long> x, A1<Integer> y){
|
||||
baz(foo(x, y));
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
abstract class A<T>{
|
||||
abstract <S> S foo(S x, S y);
|
||||
<S extends Number & Comparable<?>> void baz(A<S> a){}
|
||||
|
||||
void bar(A<Long> x, A<Integer> y){
|
||||
baz(foo(x, y));
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import java.util.*;
|
||||
abstract class A {
|
||||
abstract <T> T baz(List<? super List<? super T>> a);
|
||||
|
||||
void bar(List<List<?>> x){
|
||||
String s = baz(x);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class A1{
|
||||
abstract <T> T baz(List<? super T> a);
|
||||
|
||||
void bar(List<?> x){
|
||||
String o = baz<error descr="'baz(java.util.List<? super java.lang.String>)' in 'A1' cannot be applied to '(java.util.List<capture<?>>)'">(x)</error>;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import java.util.*;
|
||||
interface C<T> extends List<List<T>>{}
|
||||
abstract class A {
|
||||
abstract <T> T baz(List<? super List<? super T>> a);
|
||||
|
||||
void bar(C<?> x){
|
||||
baz<error descr="'baz(java.util.List<? super java.util.List<? super java.lang.Object>>)' in 'A' cannot be applied to '(C<capture<?>>)'">(x)</error>;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
interface I<T>{}
|
||||
interface A extends I<A[]>{}
|
||||
interface B extends I<B[]>{}
|
||||
|
||||
abstract class c{
|
||||
abstract <T> T baz(T x, T y);
|
||||
|
||||
void bar(A x, B y){
|
||||
baz(x, y);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import java.util.List;
|
||||
|
||||
abstract class X {
|
||||
abstract <T> void copy(List<T> dest, List<? extends T> src);
|
||||
|
||||
void foo(List<? super Throwable> x, List<? extends Exception> y){
|
||||
copy(x, y);
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class C<T extends C<? extends C<? extends T>>>{
|
||||
void foo(C<?> x){
|
||||
<error descr="Inferred type '? extends C<? extends C<capture<?>>>' for type parameter 'T' is not within its bound; should extend 'C<? extends C<? extends C<capture<?>>>>'">bar(x)</error>;
|
||||
}
|
||||
<T extends C<? extends T>> void bar(C<T> x){}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
abstract class A {
|
||||
abstract void foo(Enum<?> x);
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
void foo(Enum<? extends Enum<?>> x) { }
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
void foo(){}
|
||||
}
|
||||
|
||||
class D extends C{
|
||||
static <T> void foo(){}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
abstract class A {
|
||||
abstract <T> T foo();
|
||||
|
||||
{
|
||||
int x = foo();
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class A {
|
||||
<T> A(T x) {}
|
||||
|
||||
{
|
||||
new <<error descr="Actual type argument and inferred type contradict each other">String</error>>A(1);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
class A {
|
||||
<T> A() {}
|
||||
|
||||
{
|
||||
new <<error descr="Type argument cannot be of primitive type">int</error>>A();
|
||||
}
|
||||
}
|
||||
|
||||
class B<T> {
|
||||
{
|
||||
new B<<error descr="Type argument cannot be of primitive type">int</error>>();
|
||||
B.<<error descr="Type argument cannot be of primitive type">int</error>>m();
|
||||
}
|
||||
|
||||
<S> void m(){}
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
abstract class A<T, S extends T>
|
||||
{
|
||||
abstract S bar();
|
||||
void foo(A<Cloneable[], ? extends Throwable[]> a)
|
||||
{
|
||||
int x = a.bar().length;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class C
|
||||
{
|
||||
Object x = new <error descr="Anonymous class implements interface; cannot have type arguments"><Integer></error> D() { };
|
||||
Object x1 = new <Integer> P() { };
|
||||
Object x2 = new <Integer> U() { };
|
||||
Object x3 = new <error descr="Anonymous class implements interface; cannot have type arguments"><Integer></error> I() { };
|
||||
interface D{}
|
||||
abstract class P {}
|
||||
}
|
||||
|
||||
interface I {}
|
||||
class U {}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Create Constructor" "true"
|
||||
public enum ReportType {
|
||||
AGING("Aging");
|
||||
|
||||
ReportType(String aging) {
|
||||
<selection>//To change body of created methods use File | Settings | File Templates.</selection>
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Create Constructor" "true"
|
||||
public enum ReportType {
|
||||
AGING("Aging")<caret>
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package pkg;
|
||||
|
||||
class $BuckClass {
|
||||
|
||||
$BuckClass() { /* compiled code */ }
|
||||
|
||||
static pkg.$BuckClass getInstance() { /* compiled code */ }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package pkg;
|
||||
|
||||
final enum EmptyEnum {
|
||||
;
|
||||
public static pkg.EmptyEnum[] values() { /* compiled code */ }
|
||||
|
||||
public static pkg.EmptyEnum valueOf(java.lang.String s) { /* compiled code */ }
|
||||
|
||||
private EmptyEnum() { /* compiled code */ }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package pkg;
|
||||
|
||||
interface ExtMethods {
|
||||
|
||||
void m1();
|
||||
|
||||
void m2() { /* compiled code */ }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package pkg;
|
||||
|
||||
class MethodReceiver {
|
||||
|
||||
MethodReceiver() { /* compiled code */ }
|
||||
|
||||
void m(int i) { /* compiled code */ }
|
||||
|
||||
static @interface A {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package pkg;
|
||||
|
||||
@pkg.PkgAnno
|
||||
interface $$package-info /* Real name is 'package-info' */ {
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
package pkg;
|
||||
|
||||
class $BuckClass {
|
||||
static $BuckClass getInstance() { return null; }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package pkg;
|
||||
|
||||
enum EmptyEnum { }
|
||||
@@ -0,0 +1,6 @@
|
||||
package pkg;
|
||||
|
||||
interface ExtMethods {
|
||||
void m1();
|
||||
void m2() default { System.out.println("Hello there."); }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package pkg;
|
||||
|
||||
class MethodReceiver {
|
||||
@interface A { }
|
||||
void m(@A MethodReceiver this, int i) { System.out.println("i=" + i); }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package pkg;
|
||||
|
||||
@interface PkgAnno { }
|
||||
@@ -0,0 +1,2 @@
|
||||
@PkgAnno
|
||||
package pkg;
|
||||
@@ -1,5 +1,5 @@
|
||||
class C<@D T extends @F Object> extends @F Object {
|
||||
@F int @F[] methodf() @F throws @F Exception {
|
||||
@F int @F[] methodf() throws @F Exception {
|
||||
a = this instanceof @F C;
|
||||
C<@F @G C> c = new @Q C<@F C>();
|
||||
c = (@F Object)c;
|
||||
|
||||
@@ -93,16 +93,6 @@ PsiJavaFile:TypeAnno.java
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(METHOD_RECEIVER)
|
||||
PsiAnnotation
|
||||
PsiJavaToken:AT('@')
|
||||
PsiJavaCodeReferenceElement:F
|
||||
PsiIdentifier:F('F')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiAnnotationParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceList
|
||||
PsiKeyword:throws('throws')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -93,16 +93,6 @@ PsiJavaFile:TypeAnno.java
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(METHOD_RECEIVER)
|
||||
PsiAnnotation
|
||||
PsiJavaToken:AT('@')
|
||||
PsiJavaCodeReferenceElement:F
|
||||
PsiIdentifier:F('F')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiAnnotationParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiReferenceList
|
||||
PsiKeyword:throws('throws')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
+12
@@ -474,4 +474,16 @@ import java.lang.annotation.Target;
|
||||
checkPreferredItems 0, 'myStep', 'myCurrentStep'
|
||||
}
|
||||
|
||||
public void testIfConditionStats() {
|
||||
invokeCompletion(getTestName(false) + ".java")
|
||||
myFixture.completeBasic()
|
||||
myFixture.type('cont')
|
||||
assertPreferredItems 1, 'contains', 'containsAll'
|
||||
myFixture.lookup.currentItem = myFixture.lookupElements[0]
|
||||
myFixture.type('\nc)) {\nif (set.')
|
||||
myFixture.completeBasic()
|
||||
myFixture.type('cont')
|
||||
assertPreferredItems 0, 'contains', 'containsAll'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -150,11 +150,42 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA89771() throws Exception { doTest(false); }
|
||||
public void testIDEA89801() throws Exception { doTest(false); }
|
||||
public void testIDEA67681() throws Exception { doTest(false); }
|
||||
public void testIDEA67599() throws Exception { doTest(false); }
|
||||
public void testIDEA57668() throws Exception { doTest(false); }
|
||||
public void testIDEA57667() throws Exception { doTest(false); }
|
||||
public void testIDEA57650() throws Exception { doTest(false); }
|
||||
public void testIDEA57378() throws Exception { doTest(false); }
|
||||
public void testIDEA57557() throws Exception { doTest(false); }
|
||||
public void testIDEA57563() throws Exception { doTest(false); }
|
||||
public void testIDEA57275() throws Exception { doTest(false); }
|
||||
public void testIDEA57533() throws Exception { doTest(false); }
|
||||
public void testIDEA57509() throws Exception { doTest(false); }
|
||||
public void testIDEA57410() throws Exception { doTest(false); }
|
||||
public void testIDEA57411() throws Exception { doTest(false); }
|
||||
public void testIDEA57484() throws Exception { doTest(false); }
|
||||
public void testIDEA57485() throws Exception { doTest(false); }
|
||||
public void testIDEA57486() throws Exception { doTest(false); }
|
||||
public void testIDEA57492() throws Exception { doTest(false); }
|
||||
public void testIDEA57493() throws Exception { doTest(false); }
|
||||
public void testIDEA57495() throws Exception { doTest(false); }
|
||||
public void testIDEA57494() throws Exception { doTest(false); }
|
||||
public void testIDEA57496() throws Exception { doTest(false); }
|
||||
public void testIDEA57264() throws Exception { doTest(false); }
|
||||
public void testIDEA57315() throws Exception { doTest(false); }
|
||||
public void testIDEA57346() throws Exception { doTest(false); }
|
||||
public void testIDEA57284() throws Exception { doTest(false); }
|
||||
public void testIDEA57286() throws Exception { doTest(false); }
|
||||
public void testIDEA57307() throws Exception { doTest(true); }
|
||||
public void testIDEA57308() throws Exception { doTest(false); }
|
||||
public void testIDEA57310() throws Exception { doTest(false); }
|
||||
public void testIDEA57311() throws Exception { doTest(false); }
|
||||
public void testIDEA57309() throws Exception { doTest(false); }
|
||||
public void testInconvertibleTypes() throws Exception { doTest(false); }
|
||||
public void testIncompatibleReturnType() throws Exception { doTest(false); }
|
||||
public void testContinueInferenceAfterFirstRawResult() throws Exception { doTest(false); }
|
||||
public void testStaticOverride() throws Exception { doTest(false); }
|
||||
public void testTypeArgumentsGivenOnRawType() throws Exception { doTest(false); }
|
||||
public void testTypeArgumentsGivenOnAnonymousClassCreation() throws Exception { doTest(false); }
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
|
||||
+1
@@ -149,6 +149,7 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testTryWithResourcesWarn() throws Exception { doTest(true, false, new DefUseInspection()); }
|
||||
public void testSafeVarargsApplicability() throws Exception { doTest(true, false); }
|
||||
public void testUncheckedGenericsArrayCreation() throws Exception { doTest(true, false); }
|
||||
public void testGenericsArrayCreation() throws Exception { doTest(false, false); }
|
||||
public void testPreciseRethrow() throws Exception { doTest(false, false); }
|
||||
public void testImprovedCatchAnalysis() throws Exception { doTest(true, false); }
|
||||
public void testPolymorphicTypeCast() throws Exception { doTest(true, false); }
|
||||
|
||||
@@ -358,4 +358,5 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testRegexp() throws Exception { doTest(false, false); }
|
||||
public void testUnsupportedFeatures() throws Exception { doTest(false, false); }
|
||||
public void testThisBeforeSuper() throws Exception { doTest(false, false); }
|
||||
public void testExplicitConstructorInvocation() throws Exception { doTest(false, false); }
|
||||
}
|
||||
|
||||
+1
-13
@@ -16,8 +16,6 @@
|
||||
package com.intellij.lang.java.parser.annotationParsing;
|
||||
|
||||
import com.intellij.lang.java.parser.JavaParsingTestCase;
|
||||
import com.intellij.psi.PsiErrorElement;
|
||||
import com.intellij.psi.PsiRecursiveElementVisitor;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
@@ -40,15 +38,5 @@ public class AnnotationParsingTest extends JavaParsingTestCase {
|
||||
public void testQualifiedAnnotation() { doTest(true); }
|
||||
public void testEnumSmartTypeCompletion() { doTest(true); }
|
||||
public void testErrors() { doTest(true); }
|
||||
|
||||
public void testTypeAnno() {
|
||||
doTest(true);
|
||||
myFile.accept(new PsiRecursiveElementVisitor() {
|
||||
@Override
|
||||
public void visitErrorElement(PsiErrorElement element) {
|
||||
fail(element.getErrorDescription());
|
||||
super.visitErrorElement(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
public void testTypeAnno() { doTest(true); }
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class DeclarationParserTest extends JavaParsingTestCase {
|
||||
" @Preliminary(a=A.B\n#, b=c) public class TimeTravel {} }", false, false); }
|
||||
public void testTypeAnno() {
|
||||
doParserTest("{ class C<@D T extends @F Object> extends @F Object {\n" +
|
||||
" @F int @F[] method() @F throws @F Exception {\n" +
|
||||
" @F int @F[] method() throws @F Exception {\n" +
|
||||
" a = this instanceof @F C;\n" +
|
||||
" C<@F @G C> c = new @Q C<@F C>();\n" +
|
||||
" c = (@F Object)c;\n" +
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user