mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -360,7 +360,8 @@ public class BuildManager implements ApplicationComponent{
|
||||
|
||||
private void addMakeRequest(Runnable runnable) {
|
||||
myAlarm.cancelAllRequests();
|
||||
myAlarm.addRequest(runnable, MAKE_TRIGGER_DELAY);
|
||||
final int delay = Math.max(50, Registry.intValue("compiler.automake.trigger.delay", MAKE_TRIGGER_DELAY));
|
||||
myAlarm.addRequest(runnable, delay);
|
||||
}
|
||||
|
||||
private void runAutoMake() {
|
||||
|
||||
@@ -35,6 +35,7 @@ import junit.framework.Assert;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.util.JpsPathUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@@ -209,10 +210,10 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
|
||||
private CompilationLog compile(final ParameterizedRunnable<CompileStatusNotification> action) {
|
||||
final Ref<CompilationLog> result = Ref.create(null);
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
semaphore.down();
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
semaphore.down();
|
||||
|
||||
CompilerManagerImpl.testSetup();
|
||||
final CompileStatusNotification callback = new CompileStatusNotification() {
|
||||
@@ -240,14 +241,18 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
|
||||
}
|
||||
});
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
final long start = System.currentTimeMillis();
|
||||
while (!semaphore.waitFor(10)) {
|
||||
if (System.currentTimeMillis() - start > 60 * 1000) {
|
||||
throw new RuntimeException("timeout");
|
||||
}
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
}
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
|
||||
return result.get();
|
||||
}
|
||||
|
||||
@@ -799,11 +799,9 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
}
|
||||
|
||||
private void removeInvalidBreakpoints() {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
ArrayList<Breakpoint> toDelete = new ArrayList<Breakpoint>();
|
||||
|
||||
for (Iterator it = getBreakpoints().listIterator(); it.hasNext();) {
|
||||
Breakpoint breakpoint = (Breakpoint)it.next();
|
||||
for (Breakpoint breakpoint : getBreakpoints()) {
|
||||
if (!breakpoint.isValid()) {
|
||||
toDelete.add(breakpoint);
|
||||
}
|
||||
|
||||
@@ -89,19 +89,29 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
Messages.installHyperlinkSupport(myDescriptionPane);
|
||||
|
||||
ProjectTemplatesFactory[] factories = ProjectTemplatesFactory.EP_NAME.getExtensions();
|
||||
final MultiMap<String, ProjectTemplatesFactory> groups = new MultiMap<String, ProjectTemplatesFactory>();
|
||||
final MultiMap<String, ProjectTemplate> groups = new MultiMap<String, ProjectTemplate>();
|
||||
for (ProjectTemplatesFactory factory : factories) {
|
||||
for (String string : factory.getGroups()) {
|
||||
groups.putValue(string, factory);
|
||||
groups.putValues(string, Arrays.asList(factory.createTemplates(string, context)));
|
||||
}
|
||||
}
|
||||
final MultiMap<String, ProjectTemplate> sorted = new MultiMap<String, ProjectTemplate>();
|
||||
// put single leafs under "Other"
|
||||
for (Map.Entry<String, Collection<ProjectTemplate>> entry : groups.entrySet()) {
|
||||
if (entry.getValue().size() > 1 || ArchivedTemplatesFactory.CUSTOM_GROUP.equals(entry.getKey())) {
|
||||
sorted.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
else {
|
||||
sorted.putValues("Other", entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTreeStructure.Impl structure = new SimpleTreeStructure.Impl(new SimpleNode() {
|
||||
@Override
|
||||
public SimpleNode[] getChildren() {
|
||||
return ContainerUtil.map2Array(groups.entrySet(), NO_CHILDREN, new Function<Map.Entry<String, Collection<ProjectTemplatesFactory>>, SimpleNode>() {
|
||||
return ContainerUtil.map2Array(sorted.entrySet(), NO_CHILDREN, new Function<Map.Entry<String, Collection<ProjectTemplate>>, SimpleNode>() {
|
||||
@Override
|
||||
public SimpleNode fun(Map.Entry<String, Collection<ProjectTemplatesFactory>> entry) {
|
||||
public SimpleNode fun(Map.Entry<String, Collection<ProjectTemplate>> entry) {
|
||||
return new GroupNode(entry.getKey(), entry.getValue());
|
||||
}
|
||||
});
|
||||
@@ -171,33 +181,10 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
myTemplatesTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
if (mySettingsPanel.getComponentCount() > 0) {
|
||||
mySettingsPanel.remove(0);
|
||||
}
|
||||
ProjectTemplate template = getSelectedTemplate();
|
||||
if (template != null) {
|
||||
JComponent settingsPanel = template.getSettingsPanel();
|
||||
if (settingsPanel != null) {
|
||||
mySettingsPanel.add(settingsPanel, BorderLayout.NORTH);
|
||||
}
|
||||
mySettingsPanel.setVisible(settingsPanel != null);
|
||||
String description = template.getDescription();
|
||||
if (description != null) {
|
||||
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);
|
||||
myDescriptionPanel.setVisible(StringUtil.isNotEmpty(description));
|
||||
}
|
||||
else {
|
||||
mySettingsPanel.setVisible(false);
|
||||
myDescriptionPanel.setVisible(false);
|
||||
}
|
||||
mySettingsPanel.revalidate();
|
||||
mySettingsPanel.repaint();
|
||||
setupPanels(template);
|
||||
mySequence.setType(template == null ? null : template.createModuleBuilder().getBuilderId());
|
||||
myContext.requestWizardButtonsUpdate();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -213,13 +200,6 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
myDescriptionPanel.setVisible(false);
|
||||
mySettingsPanel.setVisible(false);
|
||||
|
||||
TreeState state = SelectTemplateSettings.getInstance().getTreeState();
|
||||
if (state != null) {
|
||||
state.applyTo(myTemplatesTree, (DefaultMutableTreeNode)myTemplatesTree.getModel().getRoot());
|
||||
}
|
||||
else {
|
||||
myBuilder.expandAll(null);
|
||||
}
|
||||
|
||||
new AnAction() {
|
||||
@Override
|
||||
@@ -234,12 +214,53 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
case KeyEvent.VK_DOWN:
|
||||
myTemplatesTree.setSelectionRow(row < myTemplatesTree.getRowCount() - 1 ? row + 1 : 0);
|
||||
break;
|
||||
case KeyEvent.VK_ENTER:
|
||||
myTemplatesTree.expandRow(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.registerCustomShortcutSet(new CustomShortcutSet(KeyEvent.VK_UP, KeyEvent.VK_DOWN, KeyEvent.VK_ENTER), mySearchField);
|
||||
}.registerCustomShortcutSet(new CustomShortcutSet(KeyEvent.VK_UP, KeyEvent.VK_DOWN), mySearchField);
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TreeState state = SelectTemplateSettings.getInstance().getTreeState();
|
||||
if (state != null) {
|
||||
state.applyTo(myTemplatesTree, (DefaultMutableTreeNode)myTemplatesTree.getModel().getRoot());
|
||||
}
|
||||
else {
|
||||
myBuilder.expandAll(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void setupPanels(@Nullable ProjectTemplate template) {
|
||||
if (mySettingsPanel.getComponentCount() > 0) {
|
||||
mySettingsPanel.remove(0);
|
||||
}
|
||||
if (template != null) {
|
||||
JComponent settingsPanel = template.getSettingsPanel();
|
||||
if (settingsPanel != null) {
|
||||
mySettingsPanel.add(settingsPanel, BorderLayout.NORTH);
|
||||
}
|
||||
mySettingsPanel.setVisible(settingsPanel != null);
|
||||
String 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);
|
||||
myDescriptionPanel.setVisible(StringUtil.isNotEmpty(description));
|
||||
}
|
||||
else {
|
||||
mySettingsPanel.setVisible(false);
|
||||
myDescriptionPanel.setVisible(false);
|
||||
}
|
||||
mySettingsPanel.revalidate();
|
||||
mySettingsPanel.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -368,23 +389,20 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
mySearchField = new SearchTextField(false);
|
||||
}
|
||||
|
||||
private class GroupNode extends SimpleNode {
|
||||
private static class GroupNode extends SimpleNode {
|
||||
private final String myGroup;
|
||||
private final Collection<ProjectTemplatesFactory> myFactories;
|
||||
private final Collection<ProjectTemplate> myTemplates;
|
||||
|
||||
public GroupNode(String group, Collection<ProjectTemplatesFactory> factories) {
|
||||
public GroupNode(String group, Collection<ProjectTemplate> templates) {
|
||||
myGroup = group;
|
||||
myFactories = factories;
|
||||
myTemplates = templates;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleNode[] getChildren() {
|
||||
List<SimpleNode> children = new ArrayList<SimpleNode>();
|
||||
for (ProjectTemplatesFactory factory : myFactories) {
|
||||
ProjectTemplate[] templates = factory.createTemplates(myGroup, myContext);
|
||||
for (ProjectTemplate template : templates) {
|
||||
children.add(new TemplateNode(template));
|
||||
}
|
||||
for (ProjectTemplate template : myTemplates) {
|
||||
children.add(new TemplateNode(template));
|
||||
}
|
||||
return children.toArray(new SimpleNode[children.size()]);
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ class WizardArrowUI extends BasicButtonUI {
|
||||
textRect.x = 2;
|
||||
textRect.y-=7;
|
||||
c.setForeground(UIUtil.getListForeground(myButton.isSelected()));
|
||||
GraphicsUtil.setupAntialiasing(g);
|
||||
paintText(g, c, textRect, myButton.getText());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,32 +15,16 @@
|
||||
*/
|
||||
package com.intellij.platform.templates;
|
||||
|
||||
import com.intellij.ide.util.newProjectWizard.modes.ImportImlMode;
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.module.ModuleWithNameAlreadyExists;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.ui.ValidationInfo;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
|
||||
import com.intellij.platform.ProjectTemplate;
|
||||
import com.intellij.platform.templates.github.ZipUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.zip.ZipEntry;
|
||||
@@ -74,11 +58,22 @@ public class ArchivedProjectTemplate implements ProjectTemplate {
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return readEntry(new Condition<ZipEntry>() {
|
||||
@Override
|
||||
public boolean value(ZipEntry entry) {
|
||||
return entry.getName().endsWith(DESCRIPTION_PATH);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String readEntry(Condition<ZipEntry> condition) {
|
||||
ZipInputStream stream = null;
|
||||
try {
|
||||
ZipInputStream stream = getStream();
|
||||
stream = getStream();
|
||||
ZipEntry entry;
|
||||
while ((entry = stream.getNextEntry()) != null) {
|
||||
if (entry.getName().endsWith(DESCRIPTION_PATH)) {
|
||||
if (condition.value(entry)) {
|
||||
return StreamUtil.readText(stream);
|
||||
}
|
||||
}
|
||||
@@ -86,58 +81,26 @@ public class ArchivedProjectTemplate implements ProjectTemplate {
|
||||
catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
finally {
|
||||
StreamUtil.closeStream(stream);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ModuleBuilder createModuleBuilder() {
|
||||
return new ModuleBuilder() {
|
||||
@Override
|
||||
public void setupRootModel(ModifiableRootModel modifiableRootModel) throws ConfigurationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleType getModuleType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
|
||||
throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
|
||||
final String path = getContentEntryPath();
|
||||
String iml;
|
||||
try {
|
||||
File dir = new File(path);
|
||||
ZipInputStream zipInputStream = getStream();
|
||||
ZipUtil.unzip(ProgressManager.getInstance().getProgressIndicator(), dir, zipInputStream);
|
||||
VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
|
||||
iml = ContainerUtil.find(dir.list(), new Condition<String>() {
|
||||
@Override
|
||||
public boolean value(String s) {
|
||||
return s.endsWith(".iml");
|
||||
}
|
||||
});
|
||||
new File(path, iml).renameTo(new File(getModuleFilePath()));
|
||||
RefreshQueue.getInstance().refresh(false, true, null, virtualFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return ImportImlMode.setUpLoader(getModuleFilePath()).createModule(moduleModel);
|
||||
}
|
||||
};
|
||||
return new TemplateModuleBuilder(this);
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ValidationInfo validateSettings() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private ZipInputStream getStream() throws IOException {
|
||||
ZipInputStream getStream() throws IOException {
|
||||
return new ZipInputStream(myArchivePath.openStream());
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class ArchivedTemplatesFactory implements ProjectTemplatesFactory {
|
||||
}
|
||||
|
||||
static String getCustomTemplatesPath() {
|
||||
return PathManager.getConfigPath() + "/projectTemplates";
|
||||
return PathManager.getConfigPath() + "/resources/projectTemplates";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -39,48 +39,65 @@ public class EmptyModuleTemplatesFactory implements ProjectTemplatesFactory {
|
||||
@NotNull
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return new String[] {GROUP_NAME};
|
||||
List<ModuleBuilder> builders = ModuleBuilder.getAllBuilders();
|
||||
return ContainerUtil.map2Array(builders, String.class, new Function<ModuleBuilder, String>() {
|
||||
@Override
|
||||
public String fun(ModuleBuilder builder) {
|
||||
return getGroupName(builder);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectTemplate[] createTemplates(String group, WizardContext context) {
|
||||
List<ModuleBuilder> builders = ModuleBuilder.getAllBuilders();
|
||||
return ContainerUtil.map2Array(builders, ProjectTemplate.class, new Function<ModuleBuilder, ProjectTemplate>() {
|
||||
@Override
|
||||
public ProjectTemplate fun(final ModuleBuilder builder) {
|
||||
return new ProjectTemplate() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return builder.getPresentableName();
|
||||
}
|
||||
for (ModuleBuilder builder : builders) {
|
||||
if (getGroupName(builder).equals(group)) return new ProjectTemplate[] {new EmptyModuleTemplate(builder)};
|
||||
}
|
||||
return new ProjectTemplate[0];
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return builder.getDescription();
|
||||
}
|
||||
private static String getGroupName(ModuleBuilder builder) {
|
||||
String name = builder.getPresentableName();
|
||||
return name.split(" ")[0];
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JComponent getSettingsPanel() {
|
||||
return null;
|
||||
}
|
||||
private static class EmptyModuleTemplate implements ProjectTemplate {
|
||||
private final ModuleBuilder myBuilder;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ModuleBuilder createModuleBuilder() {
|
||||
return builder;
|
||||
}
|
||||
public EmptyModuleTemplate(ModuleBuilder builder) {
|
||||
myBuilder = builder;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ValidationInfo validateSettings() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return myBuilder.getPresentableName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return myBuilder.getDescription();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JComponent getSettingsPanel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ModuleBuilder createModuleBuilder() {
|
||||
return myBuilder;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ValidationInfo validateSettings() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* 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.platform.templates;
|
||||
|
||||
import com.intellij.ide.util.newProjectWizard.modes.ImportImlMode;
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.openapi.module.*;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
|
||||
import com.intellij.platform.templates.github.ZipUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 10/19/12
|
||||
*/
|
||||
class TemplateModuleBuilder extends ModuleBuilder {
|
||||
private final ModuleType myType;
|
||||
private ArchivedProjectTemplate myTemplate;
|
||||
|
||||
public TemplateModuleBuilder(ArchivedProjectTemplate template) {
|
||||
myTemplate = template;
|
||||
myType = computeModuleType(myTemplate);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static ModuleType computeModuleType(ArchivedProjectTemplate template) {
|
||||
String iml = template.readEntry(new Condition<ZipEntry>() {
|
||||
@Override
|
||||
public boolean value(ZipEntry entry) {
|
||||
return entry.getName().endsWith(".iml");
|
||||
}
|
||||
});
|
||||
if (iml == null) return ModuleType.EMPTY;
|
||||
try {
|
||||
Document document = JDOMUtil.loadDocument(iml);
|
||||
String type = document.getRootElement().getAttributeValue(Module.ELEMENT_TYPE);
|
||||
return ModuleTypeManager.getInstance().findByID(type);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return ModuleType.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRootModel(ModifiableRootModel modifiableRootModel) throws ConfigurationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleType getModuleType() {
|
||||
return myType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
|
||||
throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
|
||||
final String path = getContentEntryPath();
|
||||
String iml;
|
||||
try {
|
||||
File dir = new File(path);
|
||||
ZipInputStream zipInputStream = myTemplate.getStream();
|
||||
ZipUtil.unzip(ProgressManager.getInstance().getProgressIndicator(), dir, zipInputStream);
|
||||
VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
|
||||
iml = ContainerUtil.find(dir.list(), new Condition<String>() {
|
||||
@Override
|
||||
public boolean value(String s) {
|
||||
return s.endsWith(".iml");
|
||||
}
|
||||
});
|
||||
new File(path, iml).renameTo(new File(getModuleFilePath()));
|
||||
RefreshQueue.getInstance().refresh(false, true, null, virtualFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return ImportImlMode.setUpLoader(getModuleFilePath()).createModule(moduleModel);
|
||||
}
|
||||
}
|
||||
@@ -1037,6 +1037,7 @@ public class ExpectedTypesProvider {
|
||||
@NotNull final PsiMethod method,
|
||||
@NotNull final PsiSubstitutor substitutor,
|
||||
@NotNull final Set<ExpectedTypeInfo> array) {
|
||||
LOG.assertTrue(substitutor.isValid());
|
||||
PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
if (!forCompletion && parameters.length != args.length) return;
|
||||
if (parameters.length <= index && !method.isVarArgs()) return;
|
||||
@@ -1172,6 +1173,7 @@ public class ExpectedTypesProvider {
|
||||
|
||||
private static PsiType getParameterType(@NotNull PsiParameter parameter, @NotNull PsiSubstitutor substitutor) {
|
||||
PsiType type = parameter.getType();
|
||||
LOG.assertTrue(type.isValid());
|
||||
if (parameter.isVarArgs()) {
|
||||
if (type instanceof PsiArrayType) {
|
||||
type = ((PsiArrayType)type).getComponentType();
|
||||
|
||||
+6
-2
@@ -376,11 +376,15 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor {
|
||||
|
||||
for (final PsiField field : fields) {
|
||||
if (field == element) continue;
|
||||
assert field.isValid();
|
||||
|
||||
assert field.isValid() : "invalid field: " + field;
|
||||
PsiType fieldType = field.getType();
|
||||
assert fieldType.isValid() : "invalid field type: " + field + "; " + fieldType;
|
||||
|
||||
final PsiModifierList modifierList = field.getModifierList();
|
||||
if (staticContext && (modifierList != null && !modifierList.hasModifierProperty(PsiModifier.STATIC))) continue;
|
||||
|
||||
if (field.getType().equals(varType)) {
|
||||
if (fieldType.equals(varType)) {
|
||||
final String getterName = PropertyUtil.suggestGetterName(field.getProject(), field);
|
||||
if ((psiClass.findMethodsByName(getterName, true).length == 0 ||
|
||||
psiClass.findMethodBySignature(PropertyUtil.generateGetterPrototype(field), true) == null)) {
|
||||
|
||||
+7
@@ -1280,16 +1280,23 @@ public class GenericsHighlightUtil {
|
||||
if (refParamList.getTypeArguments().length == 0) return null;
|
||||
JavaResolveResult resolveResult = null;
|
||||
PsiElement parent = refParamList.getParent();
|
||||
PsiElement qualifier = null;
|
||||
if (parent instanceof PsiJavaCodeReferenceElement) {
|
||||
resolveResult = ((PsiJavaCodeReferenceElement)parent).advancedResolve(false);
|
||||
qualifier = ((PsiJavaCodeReferenceElement)parent).getQualifier();
|
||||
}
|
||||
else if (parent instanceof PsiCallExpression) {
|
||||
resolveResult = ((PsiCallExpression)parent).resolveMethodGenerics();
|
||||
if (parent instanceof PsiMethodCallExpression) {
|
||||
final PsiReferenceExpression methodExpression = ((PsiMethodCallExpression)parent).getMethodExpression();
|
||||
qualifier = methodExpression.getQualifier();
|
||||
}
|
||||
}
|
||||
if (resolveResult != null) {
|
||||
PsiElement element = resolveResult.getElement();
|
||||
if (!(element instanceof PsiTypeParameterListOwner)) return null;
|
||||
if (((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.STATIC)) return null;
|
||||
if (qualifier instanceof PsiJavaCodeReferenceElement && ((PsiJavaCodeReferenceElement)qualifier).resolve() instanceof PsiTypeParameter) return null;
|
||||
PsiClass containingClass = ((PsiMember)element).getContainingClass();
|
||||
if (containingClass != null && PsiUtil.isRawSubstitutor(containingClass, resolveResult.getSubstitutor())) {
|
||||
if ((parent instanceof PsiCallExpression || parent instanceof PsiMethodReferenceExpression) && PsiUtil.isLanguageLevel7OrHigher(parent)) {
|
||||
|
||||
@@ -1819,13 +1819,13 @@ public class HighlightUtil {
|
||||
type = ((PsiReferenceExpression)qualifier).getType();
|
||||
referencedClass = PsiUtil.resolveClassInType(type);
|
||||
}
|
||||
else if (qualifier instanceof PsiThisExpression || qualifier == null) {
|
||||
@SuppressWarnings({"unchecked"}) PsiMethod parent = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiMember.class);
|
||||
resolved = parent;
|
||||
expression = qualifier == null ? expression : qualifier;
|
||||
else if (qualifier == null) {
|
||||
resolved = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiMember.class);
|
||||
if (resolved != null) {
|
||||
referencedClass = ((PsiMethod)resolved).getContainingClass();
|
||||
}
|
||||
} else if (qualifier instanceof PsiThisExpression) {
|
||||
referencedClass = PsiUtil.resolveClassInType(((PsiThisExpression)qualifier).getType());
|
||||
}
|
||||
}
|
||||
if (resolved instanceof PsiField) {
|
||||
|
||||
+19
-7
@@ -174,13 +174,25 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
|
||||
new AddAnnotationFix(anno, parameter, ArrayUtil.toStringArray(annoToRemove)));
|
||||
}
|
||||
else if (annotated.isDeclaredNullable && manager.isNotNull(parameter, false)) {
|
||||
final PsiIdentifier nameIdentifier2 = parameter.getNameIdentifier();
|
||||
assert nameIdentifier2 != null : parameter;
|
||||
holder.registerProblem(nameIdentifier2, InspectionsBundle.message(
|
||||
"inspection.nullable.problems.annotated.field.constructor.parameter.conflict", StringUtil.getShortName(anno),
|
||||
notNullSimpleName),
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
new AddAnnotationFix(anno, parameter, ArrayUtil.toStringArray(annoToRemove)));
|
||||
boolean usedAsQualifier = !ReferencesSearch.search(parameter).forEach(new Processor<PsiReference>() {
|
||||
@Override
|
||||
public boolean process(PsiReference reference) {
|
||||
final PsiElement element = reference.getElement();
|
||||
if (element instanceof PsiReferenceExpression && element.getParent() instanceof PsiReferenceExpression) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (!usedAsQualifier) {
|
||||
final PsiIdentifier nameIdentifier2 = parameter.getNameIdentifier();
|
||||
assert nameIdentifier2 != null : parameter;
|
||||
holder.registerProblem(nameIdentifier2, InspectionsBundle.message(
|
||||
"inspection.nullable.problems.annotated.field.constructor.parameter.conflict", StringUtil.getShortName(anno),
|
||||
notNullSimpleName),
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
new AddAnnotationFix(anno, parameter, ArrayUtil.toStringArray(annoToRemove)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
+1
-1
@@ -58,7 +58,7 @@ public class ClassInheritorsSearch extends ExtensibleQueryFactory<PsiClass, Clas
|
||||
|
||||
LOG.assertTrue(searchScope != null);
|
||||
|
||||
ProgressIndicator progress = ProgressIndicatorProvider.getInstance().getProgressIndicator();
|
||||
ProgressIndicator progress = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
if (progress != null) {
|
||||
progress.pushState();
|
||||
String className = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public class AllClassesSearchExecutor implements QueryExecutor<PsiClass, AllClas
|
||||
}
|
||||
});
|
||||
|
||||
final ProgressIndicator indicator = ProgressIndicatorProvider.getInstance().getProgressIndicator();
|
||||
final ProgressIndicator indicator = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
if (indicator != null) {
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
|
||||
@@ -583,7 +583,7 @@ public class PsiClassImplUtil {
|
||||
@NotNull PsiElementFactory elementFactory,
|
||||
@NotNull LanguageLevel languageLevel) {
|
||||
if (PsiUtil.isRawSubstitutor(aClass, substitutor)) {
|
||||
return elementFactory.createRawSubstitutor(candidateClass);
|
||||
return elementFactory.createRawSubstitutor(candidateClass).putAll(substitutor);
|
||||
}
|
||||
final PsiType containingType = elementFactory.createType(candidateClass, candidateSubstitutor, languageLevel);
|
||||
PsiType type = substitutor.substitute(containingType);
|
||||
|
||||
@@ -335,7 +335,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
|
||||
if (substitutorMap == null) substitutorMap = new HashMap<PsiTypeParameter, PsiType>();
|
||||
substitutorMap.put(parameter, null);
|
||||
}
|
||||
return baseSubstitutor.putAll(PsiSubstitutorImpl.createSubstitutor(substitutorMap));
|
||||
return PsiSubstitutorImpl.createSubstitutor(substitutorMap).putAll(baseSubstitutor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -305,7 +305,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
final ASTNode mirrorTreeElement = SourceTreeToPsiMap.psiElementToTree(mirror);
|
||||
|
||||
//IMPORTANT: do not take lock too early - FileDocumentManager.getInstance().saveToString() can run write action...
|
||||
final NonCancelableSection section = ProgressIndicatorProvider.getInstance().startNonCancelableSection();
|
||||
final NonCancelableSection section = ProgressIndicatorProvider.startNonCancelableSectionIfSupported();
|
||||
try {
|
||||
setMirror((TreeElement)mirrorTreeElement);
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ public class PsiImmediateClassType extends PsiClassType {
|
||||
myClass = aClass;
|
||||
myManager = aClass.getManager();
|
||||
mySubstitutor = substitutor;
|
||||
assert substitutor.isValid();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,6 +141,7 @@ public class PsiImmediateClassType extends PsiClassType {
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
if (myCanonicalText == null) {
|
||||
assert mySubstitutor.isValid();
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buildText(myClass, mySubstitutor, buffer, true, false);
|
||||
myCanonicalText = buffer.toString();
|
||||
@@ -207,12 +209,14 @@ public class PsiImmediateClassType extends PsiClassType {
|
||||
pineBuffer.append('<');
|
||||
for (int i = 0; i < typeParameters.length; i++) {
|
||||
PsiTypeParameter typeParameter = typeParameters[i];
|
||||
assert typeParameter.isValid();
|
||||
if (i > 0) pineBuffer.append(',');
|
||||
final PsiType substitutionResult = substitutor.substitute(typeParameter);
|
||||
if (substitutionResult == null) {
|
||||
pineBuffer = null;
|
||||
break;
|
||||
}
|
||||
assert substitutionResult.isValid();
|
||||
if (canonical) {
|
||||
if (internal) {
|
||||
pineBuffer.append(substitutionResult.getInternalCanonicalText());
|
||||
|
||||
+1
-1
@@ -216,8 +216,8 @@ public class PsiMethodCallExpressionImpl extends ExpressionPsiElement implements
|
||||
}
|
||||
if (is15OrHigher) {
|
||||
final PsiSubstitutor substitutor = result.getSubstitutor();
|
||||
if (PsiUtil.isRawSubstitutor(method, substitutor)) return TypeConversionUtil.erasure(ret);
|
||||
PsiType substitutedReturnType = substitutor.substitute(ret);
|
||||
if (substitutedReturnType == null) return TypeConversionUtil.erasure(ret);
|
||||
PsiType lowerBound = PsiType.NULL;
|
||||
if (substitutedReturnType instanceof PsiCapturedWildcardType) {
|
||||
lowerBound = ((PsiCapturedWildcardType)substitutedReturnType).getLowerBound();
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
class A
|
||||
{
|
||||
class B
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class C extends A
|
||||
{
|
||||
class D extends B
|
||||
{
|
||||
D(){
|
||||
C.this.super();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1723,7 +1723,7 @@ class SystemClassLoaderAction implements <error descr="Cannot resolve symbol 'Pr
|
||||
}
|
||||
|
||||
c = Class.forName<error descr="'forName(java.lang.String, boolean, java.lang.ClassLoader)' in 'java.lang.Class' cannot be applied to '(java.lang.String, boolean, ClassLoader)'">(cls, true, parent)</error>;
|
||||
ctor = c.getDeclaredConstructor(cp);
|
||||
<error descr="Incompatible types. Found: 'java.lang.reflect.Constructor<T>', required: 'Constructor'">ctor = c.getDeclaredConstructor(cp)</error>;
|
||||
sys = (ClassLoader) ctor.<error descr="Cannot resolve method 'newInstance(java.lang.Object[])'">newInstance</error>(params);
|
||||
Thread.currentThread().setContextClassLoader<error descr="'setContextClassLoader(java.lang.ClassLoader)' in 'java.lang.Thread' cannot be applied to '(ClassLoader)'">(sys)</error>;
|
||||
return sys;
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
class A<D> {
|
||||
abstract class C<S> {
|
||||
<T extends A> void foo(T.C<Integer> x) {
|
||||
Integer bar = x.bar();
|
||||
}
|
||||
|
||||
<T extends A> void foo1(A.C<error descr="Type arguments given on a raw type"><Integer></error> x) {
|
||||
Integer bar = x.bar();
|
||||
}
|
||||
|
||||
<T extends A> void foo2(A<String>.C<Integer> x) {
|
||||
Integer bar = x.bar();
|
||||
}
|
||||
|
||||
abstract S bar();
|
||||
}
|
||||
}
|
||||
|
||||
class A1 {
|
||||
abstract class C<S> {
|
||||
<T extends A1> void foo(T.C<Integer> x) {
|
||||
Integer bar = x.bar();
|
||||
}
|
||||
|
||||
<T extends A1> void foo1(A1.C<Integer> x) {
|
||||
Integer bar = x.bar();
|
||||
}
|
||||
|
||||
abstract S bar();
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>8</line>
|
||||
<description>Constructor parameter for @Nullable field is annotated @NotNull</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class Test {
|
||||
@Nullable private final String baseFile;
|
||||
@Nullable private final String baseFile1;
|
||||
|
||||
|
||||
public Test(@NotNull String baseFile) {
|
||||
this.baseFile = baseFile;
|
||||
this.baseFile1 = null;
|
||||
}
|
||||
|
||||
public Test(@NotNull String baseFile1, boolean a) {
|
||||
this.baseFile1 = baseFile1;
|
||||
if (baseFile1.contains("foo")) {
|
||||
this.baseFile = null;
|
||||
} else {
|
||||
this.baseFile = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,6 +151,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
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 testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ public class LightAdvHighlightingPerformanceTest extends LightDaemonAnalyzerTest
|
||||
|
||||
public void testAClassLoader() throws Exception {
|
||||
List<HighlightInfo> errors = doTest(Math.max(1000, 10000 - JobSchedulerImpl.CORES_COUNT * 1000));
|
||||
if (173 != errors.size()) {
|
||||
if (174 != errors.size()) {
|
||||
doTest(getFilePath("_hl"), false, false);
|
||||
fail("Actual: " + errors.size());
|
||||
}
|
||||
|
||||
@@ -357,4 +357,5 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testClassicRethrow() throws Exception { doTest(false, false); }
|
||||
public void testRegexp() throws Exception { doTest(false, false); }
|
||||
public void testUnsupportedFeatures() throws Exception { doTest(false, false); }
|
||||
public void testThisBeforeSuper() throws Exception { doTest(false, false); }
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public class NullableStuffInspectionTest extends InspectionTestCase {
|
||||
|
||||
public void testProblems() throws Exception{ doTest(); }
|
||||
public void testProblems2() throws Exception{ doTest(); }
|
||||
public void testNullableFieldNotnullParam() throws Exception{ doTest(); }
|
||||
public void testJdk14() throws Exception{ doTest14(); }
|
||||
|
||||
public void testGetterSetterProblems() throws Exception{ doTest(); }
|
||||
|
||||
@@ -49,6 +49,8 @@ public interface CompileContext extends UserDataHolder, MessageHandler {
|
||||
|
||||
long getCompilationStartStamp();
|
||||
|
||||
void updateCompilationStartStamp();
|
||||
|
||||
void markNonIncremental(ModuleBuildTarget target);
|
||||
|
||||
void clearNonIncrementalMark(ModuleBuildTarget target);
|
||||
|
||||
@@ -5,7 +5,8 @@ import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.*;
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.ProjectPaths;
|
||||
import org.jetbrains.jps.api.CanceledStatus;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.builders.logging.BuildLoggingManager;
|
||||
@@ -34,7 +35,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
|
||||
private final Set<ModuleBuildTarget> myNonIncrementalModules = new HashSet<ModuleBuildTarget>();
|
||||
|
||||
private final ProjectPaths myProjectPaths;
|
||||
private final long myCompilationStartStamp;
|
||||
private volatile long myCompilationStartStamp;
|
||||
private final ProjectDescriptor myProjectDescriptor;
|
||||
private final Map<String, String> myBuilderParams;
|
||||
private final CanceledStatus myCancelStatus;
|
||||
@@ -64,6 +65,11 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
|
||||
return myCompilationStartStamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCompilationStartStamp() {
|
||||
myCompilationStartStamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectPaths getProjectPaths() {
|
||||
return myProjectPaths;
|
||||
|
||||
@@ -466,6 +466,7 @@ public class IncProjectBuilder {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
context.updateCompilationStartStamp();
|
||||
pd.dataManager.closeSourceToOutputStorages(groupChunks);
|
||||
pd.dataManager.flush(true);
|
||||
}
|
||||
@@ -478,6 +479,7 @@ public class IncProjectBuilder {
|
||||
buildChunkIfAffected(context, scope, chunk);
|
||||
}
|
||||
finally {
|
||||
context.updateCompilationStartStamp();
|
||||
pd.dataManager.closeSourceToOutputStorages(Collections.singleton(chunk));
|
||||
pd.dataManager.flush(true);
|
||||
}
|
||||
|
||||
+1
-1
@@ -94,6 +94,6 @@ public abstract class ArtifactRootDescriptor extends BuildRootDescriptor {
|
||||
|
||||
@Override
|
||||
public boolean isGenerated() {
|
||||
return true;//todo[nik] we cannot detect if this root is generated by some other compiler (e.g. javac) so threat all roots as generated for now
|
||||
return false;//todo[nik] we cannot detect if this root is generated by some other compiler (e.g. javac) so treat all roots as non-generated for now
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.progress;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -33,8 +34,23 @@ public abstract class ProgressIndicatorProvider {
|
||||
|
||||
protected abstract void doCheckCanceled() throws ProcessCanceledException;
|
||||
|
||||
@Nullable
|
||||
public static ProgressIndicator getGlobalProgressIndicator() {
|
||||
return ourInstance != null ? ourInstance.getProgressIndicator() : null;
|
||||
}
|
||||
|
||||
public abstract NonCancelableSection startNonCancelableSection();
|
||||
|
||||
@NotNull
|
||||
public static NonCancelableSection startNonCancelableSectionIfSupported() {
|
||||
return ourInstance != null ? ourInstance.startNonCancelableSection() : new NonCancelableSection() {
|
||||
@Override
|
||||
public void done() {
|
||||
// do nothing
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean ourNeedToCheckCancel = false;
|
||||
public static void checkCanceled() throws ProcessCanceledException {
|
||||
// smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds
|
||||
|
||||
@@ -125,25 +125,7 @@ public class CoreApplicationEnvironment {
|
||||
registerApplicationExtensionPoint(ContentBasedFileSubstitutor.EP_NAME, ContentBasedFileSubstitutor.class);
|
||||
registerExtensionPoint(Extensions.getRootArea(), BinaryFileStubBuilders.EP_NAME, FileTypeExtensionPoint.class);
|
||||
|
||||
ProgressIndicatorProvider.ourInstance = new ProgressIndicatorProvider() {
|
||||
@Override
|
||||
public ProgressIndicator getProgressIndicator() {
|
||||
return new EmptyProgressIndicator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doCheckCanceled() throws ProcessCanceledException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonCancelableSection startNonCancelableSection() {
|
||||
return new NonCancelableSection() {
|
||||
@Override
|
||||
public void done() {
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
ProgressIndicatorProvider.ourInstance = createProgressIndicatorProvider();
|
||||
|
||||
myApplication.registerService(JobLauncher.class, new JobLauncher() {
|
||||
@Override
|
||||
@@ -194,6 +176,28 @@ public class CoreApplicationEnvironment {
|
||||
|
||||
}
|
||||
|
||||
protected ProgressIndicatorProvider createProgressIndicatorProvider() {
|
||||
return new ProgressIndicatorProvider() {
|
||||
@Override
|
||||
public ProgressIndicator getProgressIndicator() {
|
||||
return new EmptyProgressIndicator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doCheckCanceled() throws ProcessCanceledException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonCancelableSection startNonCancelableSection() {
|
||||
return new NonCancelableSection() {
|
||||
@Override
|
||||
public void done() {
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected VirtualFileSystem createJarFileSystem() {
|
||||
return new CoreJarFileSystem();
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class StubBasedPsiElementBase<T extends StubElement> extends ASTDelegateP
|
||||
synchronized (file.getStubLock()) {
|
||||
node = myNode;
|
||||
if (node == null) {
|
||||
NonCancelableSection criticalSection = ProgressIndicatorProvider.getInstance().startNonCancelableSection();
|
||||
NonCancelableSection criticalSection = ProgressIndicatorProvider.startNonCancelableSectionIfSupported();
|
||||
try {
|
||||
if (!file.isValid()) throw new PsiInvalidElementAccessException(this);
|
||||
FileElement treeElement = file.getTreeElement();
|
||||
|
||||
@@ -1053,8 +1053,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder, AS
|
||||
final MyTreeStructure treeStructure = new MyTreeStructure(newRoot, null);
|
||||
final MyComparator comparator = new MyComparator(getUserDataUnprotected(CUSTOM_COMPARATOR), treeStructure);
|
||||
|
||||
final ProgressIndicatorProvider provider = ProgressIndicatorProvider.getInstance();
|
||||
final ProgressIndicator indicator = provider != null ? provider.getProgressIndicator() : null;
|
||||
final ProgressIndicator indicator = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
BlockSupportImpl.diffTrees(oldRoot, builder, comparator, treeStructure, indicator);
|
||||
return diffLog;
|
||||
}
|
||||
|
||||
+1
-2
@@ -230,8 +230,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
|
||||
@Nullable
|
||||
protected static ProgressIndicator getProgressIndicator() {
|
||||
final ProgressIndicatorProvider progressManager = ProgressIndicatorProvider.getInstance();
|
||||
return progressManager != null ? progressManager.getProgressIndicator() : null;
|
||||
return ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
}
|
||||
|
||||
protected double getPercentageOfComponentsLoaded() {
|
||||
|
||||
@@ -119,7 +119,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
if (text.length() == 0) {
|
||||
throw new IllegalArgumentException("Cannot search for elements with empty text");
|
||||
}
|
||||
final ProgressIndicator progress = ProgressIndicatorProvider.getInstance().getProgressIndicator();
|
||||
final ProgressIndicator progress = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
if (searchScope instanceof GlobalSearchScope) {
|
||||
StringSearcher searcher = new StringSearcher(text, caseSensitively, true);
|
||||
|
||||
@@ -344,7 +344,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
if (qName.length() == 0) {
|
||||
throw new IllegalArgumentException("Cannot search for elements with empty text");
|
||||
}
|
||||
final ProgressIndicator progress = ProgressIndicatorProvider.getInstance().getProgressIndicator();
|
||||
final ProgressIndicator progress = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
|
||||
int dotIndex = qName.lastIndexOf('.');
|
||||
int dollarIndex = qName.lastIndexOf('$');
|
||||
@@ -487,7 +487,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
|
||||
appendCollectorsFromQueryRequests(collectors);
|
||||
|
||||
ProgressIndicator progress = ProgressIndicatorProvider.getInstance().getProgressIndicator();
|
||||
ProgressIndicator progress = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
do {
|
||||
final MultiMap<Set<IdIndexEntry>, RequestWithProcessor> globals = new MultiMap<Set<IdIndexEntry>, RequestWithProcessor>();
|
||||
final List<Computable<Boolean>> customs = ContainerUtil.newArrayList();
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.formatting;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Defines the indent and alignment settings which are applied to a new child block
|
||||
* added to a formatting model block. Used for auto-indenting when the Enter key is pressed.
|
||||
@@ -35,7 +37,7 @@ public class ChildAttributes {
|
||||
* @param childIndent the indent for the child block.
|
||||
* @param alignment the alignment for the child block.
|
||||
*/
|
||||
public ChildAttributes(final Indent childIndent, final Alignment alignment) {
|
||||
public ChildAttributes(@Nullable final Indent childIndent, @Nullable final Alignment alignment) {
|
||||
myChildIndent = childIndent;
|
||||
myAlignment = alignment;
|
||||
}
|
||||
@@ -45,6 +47,7 @@ public class ChildAttributes {
|
||||
*
|
||||
* @return the indent setting.
|
||||
*/
|
||||
@Nullable
|
||||
public Indent getChildIndent() {
|
||||
return myChildIndent;
|
||||
}
|
||||
@@ -54,6 +57,7 @@ public class ChildAttributes {
|
||||
*
|
||||
* @return the alignment setting.
|
||||
*/
|
||||
@Nullable
|
||||
public Alignment getAlignment() {
|
||||
return myAlignment;
|
||||
}
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ public final class QuickFixAction {
|
||||
doRegister(info, action, null, null, fixRange, null);
|
||||
}
|
||||
|
||||
public static void unregisterQuickFixAction(HighlightInfo info, Condition<IntentionAction> condition) {
|
||||
public static void unregisterQuickFixAction(@NotNull HighlightInfo info, Condition<IntentionAction> condition) {
|
||||
for (Iterator<Pair<HighlightInfo.IntentionActionDescriptor, TextRange>> it = info.quickFixActionRanges.iterator(); it.hasNext();) {
|
||||
Pair<HighlightInfo.IntentionActionDescriptor, TextRange> pair = it.next();
|
||||
if (condition.value(pair.first.getAction())) {
|
||||
|
||||
+2
-1
@@ -152,6 +152,7 @@ public class IntentionHintComponent extends JPanel implements Disposable, Scroll
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
myDisposed = true;
|
||||
myComponentHint.hide();
|
||||
super.hide();
|
||||
@@ -420,7 +421,7 @@ public class IntentionHintComponent extends JPanel implements Disposable, Scroll
|
||||
myPopupShown = true;
|
||||
}
|
||||
|
||||
private void recreateMyPopup(IntentionListStep step) {
|
||||
private void recreateMyPopup(@NotNull IntentionListStep step) {
|
||||
if (myPopup != null) {
|
||||
Disposer.dispose(myPopup);
|
||||
}
|
||||
|
||||
+22
-31
@@ -9,9 +9,6 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.platform.templates.github.DownloadUtil;
|
||||
import com.intellij.platform.templates.github.GeneratorException;
|
||||
import com.intellij.platform.templates.github.GithubTagInfo;
|
||||
@@ -53,36 +50,30 @@ public class GithubTagListProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Task.Backgroundable updateTagListAsynchronously(final GithubProjectGeneratorPeer peer) {
|
||||
public void updateTagListAsynchronously(final GithubProjectGeneratorPeer peer) {
|
||||
final String url = formatTagListDownloadUrl();
|
||||
Task.Backgroundable task =
|
||||
new Task.Backgroundable(null, "Updating versions of " + GithubTagListProvider.this.myRepositoryName + " repository...", true, null) {
|
||||
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
File cacheFile = getCacheFile();
|
||||
try {
|
||||
DownloadUtil.downloadAtomically(indicator, url, cacheFile, myUserName, myRepositoryName);
|
||||
final ImmutableSet<GithubTagInfo> infos = readTagsFromFile(cacheFile);
|
||||
peer.setErrorMessage(null);
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
peer.updateTagList(infos);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IOException e) {
|
||||
peer.setErrorMessage("Can not fetch tag list from '" + url + "'!");
|
||||
}
|
||||
catch (GeneratorException e) {
|
||||
peer.setErrorMessage(getGeneratorName() + " cache update failed");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
LOG.info(getGeneratorName() + " starting cache update from " + url + " ...");
|
||||
ProgressManager.getInstance().run(task);
|
||||
return task;
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
public void run() {
|
||||
File cacheFile = getCacheFile();
|
||||
try {
|
||||
DownloadUtil.downloadAtomically(null, url, cacheFile, myUserName, myRepositoryName);
|
||||
final ImmutableSet<GithubTagInfo> infos = readTagsFromFile(cacheFile);
|
||||
peer.setErrorMessage(null);
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
peer.updateTagList(infos);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IOException e) {
|
||||
peer.setErrorMessage("Can not fetch tag list from '" + url + "'!");
|
||||
}
|
||||
catch (GeneratorException e) {
|
||||
peer.setErrorMessage(getGeneratorName() + " cache update failed");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getGeneratorName() {
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM
|
||||
super.load();
|
||||
|
||||
final ModuleFileData storageData = getMainStorageData();
|
||||
final String moduleTypeId = storageData.myOptions.get(ModuleImpl.ELEMENT_TYPE);
|
||||
final String moduleTypeId = storageData.myOptions.get(Module.ELEMENT_TYPE);
|
||||
myModule.setOption(Module.ELEMENT_TYPE, ModuleTypeManager.getInstance().findByID(moduleTypeId).getId());
|
||||
|
||||
if (ApplicationManager.getApplication().isHeadlessEnvironment() || ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
|
||||
@@ -29,10 +29,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.objectTree.ObjectNode;
|
||||
import com.intellij.openapi.util.objectTree.ObjectTree;
|
||||
import com.intellij.openapi.util.objectTree.ObjectTreeListener;
|
||||
import com.intellij.openapi.vcs.history.TextTransferrable;
|
||||
import com.intellij.util.ui.TextTransferrable;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.debugger.UiDebuggerExtension;
|
||||
import com.intellij.ui.speedSearch.ElementFilter;
|
||||
|
||||
@@ -16,8 +16,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -121,7 +119,7 @@ public class DownloadUtil {
|
||||
}, new Producer<Boolean>() {
|
||||
@Override
|
||||
public Boolean produce() {
|
||||
return IOExceptionDialog.showErrorDialog("Download Error", "Can not download " + url + "");
|
||||
return IOExceptionDialog.showErrorDialog("Download Error", "Can not download '" + url + "'");
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -204,13 +202,7 @@ public class DownloadUtil {
|
||||
if (progress != null) {
|
||||
progress.setText2("Downloading " + location);
|
||||
}
|
||||
URL url = new URL(location);
|
||||
try {
|
||||
HttpConfigurable.getInstance().prepareURL(location);
|
||||
} catch (IOException e) {
|
||||
LOG.info("Can not prepareURL '" + location + "'", e);
|
||||
}
|
||||
URLConnection urlConnection = url.openConnection();
|
||||
HttpURLConnection urlConnection = HttpConfigurable.getInstance().openHttpConnection(location);
|
||||
try {
|
||||
int timeout = (int) TimeUnit.MINUTES.toMillis(2);
|
||||
urlConnection.setConnectTimeout(timeout);
|
||||
@@ -221,16 +213,21 @@ public class DownloadUtil {
|
||||
substituteContentLength(progress, originalText, contentLength);
|
||||
NetUtils.copyStreamContent(progress, in, output, contentLength);
|
||||
} catch (IOException e) {
|
||||
if (urlConnection instanceof HttpURLConnection) {
|
||||
HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
|
||||
LOG.warn("Can not download '" + location
|
||||
+ "', response code: " + httpURLConnection.getResponseCode()
|
||||
+ ", response message: " + httpURLConnection.getResponseMessage()
|
||||
+ ", headers: " + httpURLConnection.getHeaderFields()
|
||||
);
|
||||
}
|
||||
LOG.warn("Can not download '" + location
|
||||
+ "', response code: " + urlConnection.getResponseCode()
|
||||
+ ", response message: " + urlConnection.getResponseMessage()
|
||||
+ ", headers: " + urlConnection.getHeaderFields(),
|
||||
e
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
urlConnection.disconnect();
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Exception at disconnect()", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void substituteContentLength(@Nullable ProgressIndicator progress, @Nullable String text, int contentLengthInBytes) {
|
||||
|
||||
@@ -193,7 +193,7 @@ public class DetailViewImpl extends JPanel implements DetailView, UserDataHolder
|
||||
if (panel != null) {
|
||||
if (myDetailPanelWrapper == null) {
|
||||
myDetailPanelWrapper = new JPanel(new GridLayout(1, 1));
|
||||
myDetailPanelWrapper.setBorder(IdeBorderFactory.createEmptyBorder(5, 30, 5, 30));
|
||||
myDetailPanelWrapper.setBorder(IdeBorderFactory.createEmptyBorder(5, 30, 5, 5));
|
||||
myDetailPanelWrapper.add(panel);
|
||||
|
||||
add(myDetailPanelWrapper, BorderLayout.NORTH);
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupListener;
|
||||
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
|
||||
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
|
||||
import com.intellij.openapi.util.DimensionService;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.*;
|
||||
@@ -30,6 +31,7 @@ import com.intellij.ui.speedSearch.FilteringListModel;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -58,6 +60,7 @@ public class MasterDetailPopupBuilder implements MasterController {
|
||||
private boolean myCancelOnClickOutside;
|
||||
|
||||
private final DetailController myDetailController = new DetailController(this);
|
||||
private JSplitPane mySplitPane;
|
||||
|
||||
|
||||
public String getDimensionServiceKey() {
|
||||
@@ -152,11 +155,6 @@ public class MasterDetailPopupBuilder implements MasterController {
|
||||
setCancelOnClickOutside(myCancelOnClickOutside);
|
||||
|
||||
|
||||
if (myAddDetailViewToEast) {
|
||||
builder.
|
||||
setEastComponent((JComponent)myDetailView);
|
||||
}
|
||||
|
||||
if (myDoneRunnable != null) {
|
||||
|
||||
ActionListener actionListener = new ActionListener() {
|
||||
@@ -220,6 +218,11 @@ public class MasterDetailPopupBuilder implements MasterController {
|
||||
@Override
|
||||
public void onClosed(LightweightWindowEvent event) {
|
||||
myDetailView.clearEditor();
|
||||
if (mySplitPane != null) {
|
||||
final DimensionService dimensionService = DimensionService.getInstance();
|
||||
dimensionService.setSize(getSplitterDimensionKey(),
|
||||
new Dimension(mySplitPane.getDividerLocation(), 0));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -244,10 +247,10 @@ public class MasterDetailPopupBuilder implements MasterController {
|
||||
|
||||
private PopupChooserBuilder createInnerBuilder() {
|
||||
if (myChooserComponent instanceof JList) {
|
||||
return new PopupChooserBuilder((JList)myChooserComponent);
|
||||
return new MyPopupChooserBuilder((JList)myChooserComponent);
|
||||
}
|
||||
else if (myChooserComponent instanceof JTree) {
|
||||
return new PopupChooserBuilder((JTree)myChooserComponent);
|
||||
return new MyPopupChooserBuilder((JTree)myChooserComponent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -338,6 +341,9 @@ public class MasterDetailPopupBuilder implements MasterController {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!allowedToRemoveItems(getSelectedItems()) ) {
|
||||
return;
|
||||
}
|
||||
final Object[] items = getSelectedItems();
|
||||
JTree tree = (JTree)myChooserComponent;
|
||||
TreeUtil.removeSelected(tree);
|
||||
@@ -445,4 +451,40 @@ public class MasterDetailPopupBuilder implements MasterController {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private class MyPopupChooserBuilder extends PopupChooserBuilder {
|
||||
public MyPopupChooserBuilder(@NotNull JList list) {
|
||||
super(list);
|
||||
}
|
||||
|
||||
private MyPopupChooserBuilder(@NotNull JTree tree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addCenterComponentToContentPane(JPanel contentPane, JComponent component) {
|
||||
if (myAddDetailViewToEast) {
|
||||
mySplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, component, (JComponent)myDetailView);
|
||||
|
||||
final DimensionService dimensionService = DimensionService.getInstance();
|
||||
Dimension size = dimensionService.getSize(getSplitterDimensionKey());
|
||||
if (size != null) {
|
||||
mySplitPane.setDividerLocation((int)size.getWidth());
|
||||
}
|
||||
|
||||
mySplitPane.setResizeWeight(0.5);
|
||||
mySplitPane.setOneTouchExpandable(true);
|
||||
mySplitPane.setContinuousLayout(true);
|
||||
|
||||
contentPane.add(mySplitPane, BorderLayout.CENTER);
|
||||
}
|
||||
else {
|
||||
super.addCenterComponentToContentPane(contentPane, component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getSplitterDimensionKey() {
|
||||
return myDimensionServiceKey + ".splitter";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -736,11 +736,11 @@ public class AbstractTreeUi {
|
||||
expand(getRootNode(), true);
|
||||
}
|
||||
ActionCallback callback;
|
||||
if (!willUpdate) {
|
||||
callback = updateNodeChildren(getRootNode(), pass, null, false, false, false, true, true);
|
||||
if (willUpdate) {
|
||||
callback = new ActionCallback.Done();
|
||||
}
|
||||
else {
|
||||
callback = new ActionCallback.Done();
|
||||
callback = updateNodeChildren(getRootNode(), pass, null, false, false, false, true, true);
|
||||
}
|
||||
callback.doWhenDone(new Runnable() {
|
||||
@Override
|
||||
@@ -912,7 +912,7 @@ public class AbstractTreeUi {
|
||||
@Override
|
||||
public void run(final Boolean changes) {
|
||||
if (changes) {
|
||||
invokeLaterIfNeeded(false, new Runnable() {
|
||||
invokeLaterIfNeeded(true, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Object element = nodeDescriptor.getElement();
|
||||
@@ -2177,11 +2177,6 @@ public class AbstractTreeUi {
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleMaybeReady() {
|
||||
myMaybeReady.cancelAllRequests();
|
||||
myMaybeReady.addRequest(myMaybeReadyRunnable, Registry.intValue("ide.tree.waitForReadySchedule"));
|
||||
}
|
||||
|
||||
private void flushPendingNodeActions() {
|
||||
final DefaultMutableTreeNode[] nodes = myPendingNodeActions.toArray(new DefaultMutableTreeNode[myPendingNodeActions.size()]);
|
||||
myPendingNodeActions.clear();
|
||||
@@ -4020,10 +4015,6 @@ public class AbstractTreeUi {
|
||||
|
||||
myRevalidatedObjects.add(element);
|
||||
AsyncResult<Object> revalidated = getBuilder().revalidateElement(element);
|
||||
if (revalidated == null) {
|
||||
runDone(onDone);
|
||||
return;
|
||||
}
|
||||
|
||||
revalidated.doWhenDone(new AsyncResult.Handler<Object>() {
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.intellij.openapi.ui.popup;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.DimensionService;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
@@ -263,18 +264,18 @@ public class PopupChooserBuilder {
|
||||
((JComponent)myScrollPane.getViewport().getView()).setBorder(BorderFactory.createEmptyBorder(viewportPadding.top, viewportPadding.left, viewportPadding.bottom, viewportPadding.right));
|
||||
|
||||
if (myChooserComponent instanceof ListWithFilter) {
|
||||
contentPane.add(myChooserComponent, BorderLayout.CENTER);
|
||||
addCenterComponentToContentPane(contentPane, myChooserComponent);
|
||||
}
|
||||
else {
|
||||
contentPane.add(myScrollPane, BorderLayout.CENTER);
|
||||
addCenterComponentToContentPane(contentPane, myScrollPane);
|
||||
}
|
||||
|
||||
if (mySouthComponent != null) {
|
||||
contentPane.add(mySouthComponent, BorderLayout.SOUTH);
|
||||
addSouthComponentToContentPane(contentPane, mySouthComponent);
|
||||
}
|
||||
|
||||
if (myEastComponent != null) {
|
||||
contentPane.add(myEastComponent, BorderLayout.EAST);
|
||||
addEastComponentToContentPane(contentPane, myEastComponent);
|
||||
}
|
||||
|
||||
ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(contentPane, myChooserComponent);
|
||||
@@ -314,6 +315,19 @@ public class PopupChooserBuilder {
|
||||
return myPopup;
|
||||
}
|
||||
|
||||
protected void addEastComponentToContentPane(JPanel contentPane, JComponent component) {
|
||||
contentPane.add(component, BorderLayout.EAST);
|
||||
}
|
||||
|
||||
protected void addSouthComponentToContentPane(JPanel contentPane, JComponent component) {
|
||||
contentPane.add(component, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
protected void addCenterComponentToContentPane(JPanel contentPane, JComponent component) {
|
||||
contentPane.add(component, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
|
||||
public PopupChooserBuilder setMinSize(final Dimension dimension) {
|
||||
myMinSize = dimension;
|
||||
return this;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.util.net;
|
||||
|
||||
import com.btr.proxy.search.ProxySearch;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
@@ -28,6 +29,7 @@ import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.IOException;
|
||||
@@ -104,7 +106,7 @@ public class HttpConfigurable implements PersistentStateComponent<HttpConfigurab
|
||||
}
|
||||
};
|
||||
try {
|
||||
WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(runnable);
|
||||
WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(runnable, ModalityState.any());
|
||||
}
|
||||
catch (Exception e) {
|
||||
// ignore
|
||||
@@ -161,6 +163,33 @@ public class HttpConfigurable implements PersistentStateComponent<HttpConfigurab
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens HTTP connection to a given location using configured http proxy settings.
|
||||
* @param location url to connect to
|
||||
* @return instance of {@link HttpURLConnection}
|
||||
* @throws IOException in case of any I/O troubles or if created connection isn't instance of HttpURLConnection.
|
||||
*/
|
||||
@NotNull
|
||||
public HttpURLConnection openHttpConnection(@NotNull String location) throws IOException {
|
||||
setAuthenticator();
|
||||
URL url = new URL(location);
|
||||
final URLConnection urlConnection;
|
||||
if (USE_HTTP_PROXY) {
|
||||
InetSocketAddress proxyAddress = new InetSocketAddress(InetAddress.getByName(PROXY_HOST), PROXY_PORT);
|
||||
Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyAddress);
|
||||
urlConnection = url.openConnection(proxy);
|
||||
}
|
||||
else {
|
||||
urlConnection = url.openConnection();
|
||||
}
|
||||
if (urlConnection instanceof HttpURLConnection) {
|
||||
return (HttpURLConnection) urlConnection;
|
||||
}
|
||||
else {
|
||||
throw new IOException("Expected " + HttpURLConnection.class + ", but got " + url.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
public void setAuthenticator() {
|
||||
if (USE_HTTP_PROXY) {
|
||||
System.setProperty("proxySet", "true");
|
||||
|
||||
@@ -31,6 +31,9 @@ import java.awt.*;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public final class IdeaLaf extends MetalLookAndFeel {
|
||||
|
||||
public static final ColorUIResource TOOLTIP_BACKGROUND_COLOR = new ColorUIResource(255, 255, 231);
|
||||
|
||||
public void initComponentDefaults(UIDefaults defaults) {
|
||||
super.initComponentDefaults(defaults);
|
||||
LafManagerImpl.initInputMapDefaults(defaults);
|
||||
@@ -69,7 +72,7 @@ public final class IdeaLaf extends MetalLookAndFeel {
|
||||
//defaults.put("ScrollPaneUI", BegScrollPaneUI.class.getName());
|
||||
|
||||
defaults.put("TabbedPane.tabInsets", new Insets(0, 4, 0, 4));
|
||||
defaults.put("ToolTip.background", new ColorUIResource(255, 255, 231));
|
||||
defaults.put("ToolTip.background", TOOLTIP_BACKGROUND_COLOR);
|
||||
defaults.put("ToolTip.border", new ColoredSideBorder(Color.gray, Color.gray, Color.black, Color.black, 1));
|
||||
defaults.put("Tree.ancestorInputMap", null);
|
||||
defaults.put("FileView.directoryIcon", AllIcons.Nodes.Folder);
|
||||
|
||||
@@ -29,8 +29,10 @@ Focus.color=ff0000
|
||||
TextField.background=737373
|
||||
TextFieldUI=com.intellij.ide.ui.laf.darcula.ui.DarculaTextFieldUI
|
||||
TextField.border=com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder
|
||||
PasswordField.background=737373
|
||||
PasswordFieldUI=com.intellij.ide.ui.laf.darcula.ui.DarculaPasswordFieldUI
|
||||
PasswordField.border=com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder
|
||||
|
||||
PasswordField.background=aaaaaa
|
||||
|
||||
CheckBoxUI=com.intellij.ide.ui.laf.darcula.ui.DarculaCheckBoxUI
|
||||
ComboBoxUI=com.intellij.ide.ui.laf.darcula.ui.DarculaComboBoxUI
|
||||
|
||||
+3
-57
@@ -25,11 +25,8 @@ import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicArrowButton;
|
||||
import javax.swing.plaf.basic.BasicComboBoxEditor;
|
||||
import javax.swing.plaf.basic.BasicComboBoxUI;
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.geom.Path2D;
|
||||
|
||||
/**
|
||||
@@ -48,58 +45,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
|
||||
return new DarculaComboBoxUI(((JComboBox)c));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ComboBoxEditor createEditor() {
|
||||
final ComboBoxEditor ed = new BasicComboBoxEditor.UIResource(){
|
||||
@Override
|
||||
protected JTextField createEditorComponent() {
|
||||
return super.createEditorComponent();
|
||||
}
|
||||
};
|
||||
if (ed != null) {
|
||||
ed.getEditorComponent().addFocusListener(new FocusListener() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
myComboBox.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
myComboBox.repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return ed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
hasFocus = comboBox.hasFocus();
|
||||
final GraphicsConfig config = new GraphicsConfig(g);
|
||||
if ( !comboBox.isEditable() ) {
|
||||
Rectangle r = rectangleForCurrentValue();
|
||||
paintCurrentValueBackground(g,r,hasFocus);
|
||||
paintCurrentValue(g,r,hasFocus);
|
||||
g.setColor(ColorUtil.fromHex("939393").darker());
|
||||
final int xxx = c.getWidth() - c.getBorder().getBorderInsets(c).right - arrowButton.getWidth();
|
||||
g.drawLine(xxx, hasFocus ? 2 : 1, xxx, c.getHeight() - (hasFocus ? 3 : 0));
|
||||
} else {
|
||||
g.setColor(editor.getBackground());
|
||||
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
g.fillRoundRect(1, 1, c.getWidth() - 2, c.getHeight() - 2, 5, 5);
|
||||
g.setColor(ColorUtil.fromHex("939393"));
|
||||
final int xxx = editor.getWidth() + c.getBorder().getBorderInsets(c).left;
|
||||
g.drawLine(xxx, hasFocus ? 3 : 1, xxx, c.getHeight() - (hasFocus ? 2 : 0));
|
||||
|
||||
editor.repaint();
|
||||
}
|
||||
config.restore();
|
||||
}
|
||||
|
||||
protected JButton createArrowButton() {
|
||||
protected JButton createArrowButton() {
|
||||
final Color bg = myComboBox.getBackground();
|
||||
final Color fg = myComboBox.getForeground();
|
||||
JButton button = new BasicArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) {
|
||||
@@ -126,8 +72,8 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
|
||||
path.lineTo(xU+1, yU + 2);
|
||||
path.closePath();
|
||||
g.fill(path);
|
||||
g.setColor(ColorUtil.fromHex("939393").darker());
|
||||
g.drawLine(0, -1, 0 , h);
|
||||
g.setColor(ColorUtil.fromHex("939393"));
|
||||
g.drawLine(0, 0, 0 , h);
|
||||
//paintTriangle(g, w / 2, h / 2, 5, SOUTH, myComboBox.isEnabled());
|
||||
//g.setColor(ColorUtil.fromHex("939393"));
|
||||
//g.drawLine(0,0, 0,h);
|
||||
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicPasswordFieldUI;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DarculaPasswordFieldUI extends BasicPasswordFieldUI {
|
||||
|
||||
@SuppressWarnings({"MethodOverridesStaticMethodOfSuperclass", "UnusedDeclaration"})
|
||||
public static ComponentUI createUI(final JComponent c) {
|
||||
c.addFocusListener(new FocusAdapter() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
c.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
c.repaint();
|
||||
}
|
||||
});
|
||||
|
||||
return new DarculaPasswordFieldUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintBackground(Graphics g) {
|
||||
final JTextComponent c = getComponent();
|
||||
final Container parent = c.getParent();
|
||||
if (parent != null) {
|
||||
g.setColor(parent.getBackground());
|
||||
g.fillRect(0, 0, c.getWidth(), c.getHeight());
|
||||
}
|
||||
final Border border = c.getBorder();
|
||||
if (border instanceof DarculaTextBorder) {
|
||||
g.setColor(c.getBackground());
|
||||
final int width = c.getWidth();
|
||||
final int height = c.getHeight();
|
||||
final JBInsets insets = ((DarculaTextBorder)border).getBorderInsets(c);
|
||||
if (c.hasFocus()) {
|
||||
final GraphicsConfig config = new GraphicsConfig(g);
|
||||
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
g.fillRoundRect(insets.left - 5, insets.top - 2, width - insets.width() + 10, height - insets.height() + 6, 5, 5);
|
||||
config.restore();
|
||||
}
|
||||
else {
|
||||
g.fillRect(insets.left - 5, insets.top - 2, width - insets.width() + 12, height - insets.height() + 6);
|
||||
}
|
||||
} else {
|
||||
super.paintBackground(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,16 +48,6 @@ public class DarculaTextFieldUI extends BasicTextFieldUI {
|
||||
return new DarculaTextFieldUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installDefaults() {
|
||||
super.installDefaults();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintSafely(Graphics g) {
|
||||
super.paintSafely(g);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintBackground(Graphics g) {
|
||||
final JTextComponent c = getComponent();
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.ui.impl.GlassPaneDialogWrapperPeer;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.wm.IdeGlassPane;
|
||||
import com.intellij.openapi.wm.IdeGlassPaneUtil;
|
||||
import com.intellij.ui.popup.AbstractPopup;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -254,7 +255,8 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
|
||||
if (window != null) {
|
||||
for (Component component : window.getComponents()) {
|
||||
if (component instanceof JComponent
|
||||
&& UIUtil.findComponentOfType((JComponent)component, JPopupMenu.class) != null) {
|
||||
&& ((UIUtil.findComponentOfType((JComponent)component, JPopupMenu.class) != null)
|
||||
|| (UIUtil.findComponentOfType((JComponent)component, AbstractPopup.MyContentPanel.class) != null))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.vcs.history;
|
||||
package com.intellij.util.ui;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
|
||||
@@ -164,6 +164,9 @@ compiler.process.use.external.javac.description=Run javac compiler in a separate
|
||||
|
||||
compiler.process.debug.port=-1
|
||||
|
||||
compiler.automake.trigger.delay=3000
|
||||
compiler.automake.trigger.delay.description=Delay in milliseconds before triggering auto-make in response to file system events
|
||||
|
||||
vcs.show.colored.annotations=true
|
||||
vcs.showConsole=true
|
||||
|
||||
|
||||
+1
-1
@@ -199,7 +199,7 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
|
||||
|
||||
protected void loadModules(final ModuleModelImpl moduleModel) {
|
||||
if (myModulePaths != null && myModulePaths.size() > 0) {
|
||||
final ProgressIndicator progressIndicator = myProject.isDefault() ? null : ProgressIndicatorProvider.getInstance().getProgressIndicator();
|
||||
final ProgressIndicator progressIndicator = myProject.isDefault() ? null : ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
if (progressIndicator != null) {
|
||||
progressIndicator.setText("Loading modules...");
|
||||
progressIndicator.setText2("");
|
||||
|
||||
+2
-1
@@ -32,6 +32,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -89,7 +90,7 @@ public class ProjectJdkImpl extends UserDataHolderBase implements JDOMExternaliz
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setVersionString(String versionString) {
|
||||
public final void setVersionString(@Nullable String versionString) {
|
||||
myVersionString = versionString == null || versionString.isEmpty() ? null : versionString;
|
||||
myVersionDefined = true;
|
||||
}
|
||||
|
||||
+1
-2
@@ -634,8 +634,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
}
|
||||
|
||||
protected void doInitialize(boolean reverseAllSets/* for testing order independence*/) {
|
||||
final ProgressIndicatorProvider progressIndicatorProvider = ProgressIndicatorProvider.getInstance();
|
||||
ProgressIndicator progress = progressIndicatorProvider == null ? null : progressIndicatorProvider.getProgressIndicator();
|
||||
ProgressIndicator progress = ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
if (progress == null) progress = new EmptyProgressIndicator();
|
||||
|
||||
progress.pushState();
|
||||
|
||||
@@ -57,7 +57,7 @@ public class LimitedPool<T> {
|
||||
}
|
||||
|
||||
private void ensureCapacity() {
|
||||
if (storage.length <= index + 1) {
|
||||
if (storage.length <= index) {
|
||||
int newCapacity = Math.min(capacity, storage.length * 3 / 2);
|
||||
Object[] newStorage = new Object[newCapacity];
|
||||
System.arraycopy(storage, 0, newStorage, 0, storage.length);
|
||||
|
||||
@@ -76,4 +76,13 @@ public class FileHolder {
|
||||
public void setIsDir(boolean isDir) {
|
||||
myIsDir = isDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FileHolder{" +
|
||||
"myIoFile=" + myIoFile +
|
||||
", myFile=" + myFile +
|
||||
", myIsDir=" + myIsDir +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.localVcs.UpToDateLineNumberProvider;
|
||||
import com.intellij.openapi.vcs.annotate.FileAnnotation;
|
||||
import com.intellij.openapi.vcs.annotate.LineNumberListener;
|
||||
import com.intellij.openapi.vcs.history.TextTransferrable;
|
||||
import com.intellij.util.ui.TextTransferrable;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
|
||||
/**
|
||||
|
||||
@@ -633,11 +633,12 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
handleUpdateException(e);
|
||||
}
|
||||
}
|
||||
} catch (ProcessCanceledException ignore) {
|
||||
} catch (Throwable t) {
|
||||
LOG.debug(t);
|
||||
Rethrow.reThrowRuntime(t);
|
||||
} finally {
|
||||
if (! myUpdater.isStopped()) {
|
||||
if (!myUpdater.isStopped()) {
|
||||
dataHolder.notifyDoneProcessingChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
|
||||
THashSet<FilePath> dirsByRoot = myDirtyDirectoriesRecursively.get(root);
|
||||
if (dirsByRoot != null) {
|
||||
for (FilePath dir : dirsByRoot) {
|
||||
final VirtualFile vFile = dir.getVirtualFile();
|
||||
final VirtualFile vFile = obtainVirtualFile(dir);
|
||||
if (vFile != null && vFile.isValid()) {
|
||||
myVcsManager.iterateVfUnderVcsRoot(vFile, processor);
|
||||
}
|
||||
@@ -431,13 +431,13 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
|
||||
final THashSet<FilePath> files = myDirtyFiles.get(root);
|
||||
if (files != null) {
|
||||
for (FilePath file : files) {
|
||||
if (file.getVirtualFile() != null) {
|
||||
processor.process(file.getVirtualFile());
|
||||
}
|
||||
final VirtualFile vFile = file.getVirtualFile();
|
||||
if (vFile != null && vFile.isValid() && vFile.isDirectory()) {
|
||||
for (VirtualFile child : vFile.getChildren()) {
|
||||
processor.process(child);
|
||||
VirtualFile vFile = obtainVirtualFile(file);
|
||||
if (vFile != null && vFile.isValid()) {
|
||||
processor.process(vFile);
|
||||
if (vFile.isDirectory()) {
|
||||
for (VirtualFile child : vFile.getChildren()) {
|
||||
processor.process(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -445,6 +445,12 @@ public class VcsDirtyScopeImpl extends VcsModifiableDirtyScope {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile obtainVirtualFile(FilePath file) {
|
||||
VirtualFile vFile = file.getVirtualFile();
|
||||
return vFile == null ? VfsUtil.findFileByIoFile(file.getIOFile(), false) : vFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return myDirtyDirectoriesRecursively.isEmpty() && myDirtyFiles.isEmpty();
|
||||
|
||||
+3
-5
@@ -22,10 +22,7 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.VcsListener;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.openapi.wm.*;
|
||||
@@ -98,7 +95,8 @@ public class IncomingChangesIndicator {
|
||||
private boolean needIndicator() {
|
||||
final AbstractVcs[] vcss = ProjectLevelVcsManager.getInstance(myProject).getAllActiveVcss();
|
||||
for (AbstractVcs vcs : vcss) {
|
||||
if (vcs.getCachingCommittedChangesProvider() != null) {
|
||||
CachingCommittedChangesProvider provider = vcs.getCachingCommittedChangesProvider();
|
||||
if (provider != null && provider.supportsIncomingChanges()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -25,6 +25,7 @@ import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vcs.CachingCommittedChangesProvider;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
@@ -150,6 +151,9 @@ public class OutdatedVersionNotifier implements ProjectComponent {
|
||||
}
|
||||
|
||||
private void initPanel(final CommittedChangeList list, final Change c, final FileEditor editor) {
|
||||
if (!isIncomingChangesSupported(list)) {
|
||||
return;
|
||||
}
|
||||
final OutdatedRevisionPanel component = new OutdatedRevisionPanel(list, c);
|
||||
editor.putUserData(PANEL_KEY, component);
|
||||
myFileEditorManager.addTopComponent(editor, component);
|
||||
@@ -205,4 +209,9 @@ public class OutdatedVersionNotifier implements ProjectComponent {
|
||||
updateLabelText(c);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isIncomingChangesSupported(@NotNull CommittedChangeList list) {
|
||||
CachingCommittedChangesProvider provider = list.getVcs().getCachingCommittedChangesProvider();
|
||||
return provider != null && provider.supportsIncomingChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +67,7 @@ import com.intellij.ui.dualView.DualViewColumnInfo;
|
||||
import com.intellij.ui.table.TableView;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.text.DateFormatUtil;
|
||||
import com.intellij.util.ui.ColumnInfo;
|
||||
import com.intellij.util.ui.StatusText;
|
||||
import com.intellij.util.ui.TableViewModel;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -44,14 +44,12 @@ class ImportsAreUsedVisitor extends JavaRecursiveElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReferenceElement(
|
||||
@NotNull PsiJavaCodeReferenceElement reference) {
|
||||
public void visitReferenceElement(@NotNull PsiJavaCodeReferenceElement reference) {
|
||||
followReferenceToImport(reference);
|
||||
super.visitReferenceElement(reference);
|
||||
}
|
||||
|
||||
private void followReferenceToImport(
|
||||
PsiJavaCodeReferenceElement reference) {
|
||||
private void followReferenceToImport(PsiJavaCodeReferenceElement reference) {
|
||||
if (reference.getQualifier() != null) {
|
||||
// it's already fully qualified, so the import statement wasn't
|
||||
// responsible
|
||||
@@ -89,8 +87,14 @@ class ImportsAreUsedVisitor extends JavaRecursiveElementVisitor {
|
||||
final String referenceName;
|
||||
if (element instanceof PsiMember) {
|
||||
final PsiMember member = (PsiMember)element;
|
||||
referenceClass = member.getContainingClass();
|
||||
referenceName = member.getName();
|
||||
if (member instanceof PsiClass && !member.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
referenceClass = null;
|
||||
referenceName = null;
|
||||
}
|
||||
else {
|
||||
referenceClass = member.getContainingClass();
|
||||
referenceName = member.getName();
|
||||
}
|
||||
}
|
||||
else {
|
||||
referenceClass = null;
|
||||
|
||||
@@ -4,4 +4,7 @@ public class Constants {
|
||||
|
||||
public static final int SIZE = 213;
|
||||
|
||||
private int field = 0; // I'm not an utility class.
|
||||
public static void instanceMatMethod() {}
|
||||
@SuppressWarnings("InnerClassMayBeStatic") public class InstanceInnerMaterial {}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import static java.lang.Math.*;
|
||||
import static java.lang.Integer.SIZE;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import static com.siyeh.igtest.imports.unused.Constants.*;
|
||||
import com.siyeh.igtest.imports.unused.Constants.*;
|
||||
|
||||
public class UnusedImport {
|
||||
|
||||
@@ -22,4 +24,9 @@ public class UnusedImport {
|
||||
list.add(i);
|
||||
Entry entry;
|
||||
}
|
||||
|
||||
public void context() {
|
||||
instanceMatMethod();
|
||||
InstanceInnerMaterial innerMaterial = new Constants().new InstanceInnerMaterial();
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,12 @@ class SimpleLogger extends LayoutLog implements ISdkLog, ILogger {
|
||||
myLog.debug(s);
|
||||
|
||||
if (myProject != null) {
|
||||
myMessages.add(FixableIssueMessage.createExceptionIssue(myProject, s, throwable));
|
||||
if (throwable != null) {
|
||||
myMessages.add(FixableIssueMessage.createExceptionIssue(myProject, s, throwable));
|
||||
}
|
||||
else {
|
||||
myMessages.add(new FixableIssueMessage(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +61,12 @@ class SimpleLogger extends LayoutLog implements ISdkLog, ILogger {
|
||||
myLog.debug(s);
|
||||
|
||||
if (myProject != null) {
|
||||
myMessages.add(FixableIssueMessage.createExceptionIssue(myProject, s, throwable));
|
||||
if (throwable != null) {
|
||||
myMessages.add(FixableIssueMessage.createExceptionIssue(myProject, s, throwable));
|
||||
}
|
||||
else {
|
||||
myMessages.add(new FixableIssueMessage(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +84,12 @@ class SimpleLogger extends LayoutLog implements ISdkLog, ILogger {
|
||||
myLog.debug(s);
|
||||
|
||||
if (myProject != null) {
|
||||
myMessages.add(FixableIssueMessage.createExceptionIssue(myProject, s, t));
|
||||
if (t != null) {
|
||||
myMessages.add(FixableIssueMessage.createExceptionIssue(myProject, s, t));
|
||||
}
|
||||
else {
|
||||
myMessages.add(new FixableIssueMessage(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -208,6 +208,8 @@ public class EclipseModuleManager implements PersistentStateComponent<Element>{
|
||||
}
|
||||
|
||||
public void loadState(Element state) {
|
||||
clear();
|
||||
|
||||
for (Object o : state.getChildren(LIBELEMENT)) {
|
||||
myEclipseUrls.add(((Element)o).getAttributeValue(VALUE_ATTR));
|
||||
}
|
||||
@@ -233,6 +235,13 @@ public class EclipseModuleManager implements PersistentStateComponent<Element>{
|
||||
}
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
myEclipseUrls.clear();
|
||||
myEclipseVariablePaths.clear();
|
||||
myUnknownCons.clear();
|
||||
mySrcPlace.clear();
|
||||
}
|
||||
|
||||
public void setExpectedModuleSourcePlace(int expectedModuleSourcePlace) {
|
||||
myExpectedModuleSourcePlace = expectedModuleSourcePlace;
|
||||
}
|
||||
|
||||
+9
-3
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.plugins.groovy.actions.generate.constructors;
|
||||
|
||||
import com.intellij.codeInsight.generation.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
@@ -39,6 +40,7 @@ import java.util.List;
|
||||
* Date: 21.05.2008
|
||||
*/
|
||||
public class GroovyGenerateConstructorHandler extends GenerateConstructorHandler {
|
||||
private static final Logger LOG = Logger.getInstance(GroovyGenerateConstructorHandler.class);
|
||||
|
||||
private static final String DEF_PSEUDO_ANNO = "_____intellij_idea_rulez_def_";
|
||||
|
||||
@@ -53,6 +55,8 @@ public class GroovyGenerateConstructorHandler extends GenerateConstructorHandler
|
||||
if (classMember instanceof PsiMethodMember) {
|
||||
final PsiMethod method = ((PsiMethodMember)classMember).getElement();
|
||||
final PsiMethod copy = (PsiMethod)method.copy();
|
||||
LOG.assertTrue(copy != null, method.getClass().getName());
|
||||
|
||||
if (copy instanceof GrMethod) {
|
||||
for (GrParameter parameter : ((GrMethod)copy).getParameterList().getParameters()) {
|
||||
if (parameter.getTypeElementGroovy() == null) {
|
||||
@@ -62,11 +66,13 @@ public class GroovyGenerateConstructorHandler extends GenerateConstructorHandler
|
||||
}
|
||||
|
||||
res.add(new PsiMethodMember(factory.createMethodFromText(GroovyToJavaGenerator.generateMethodStub(copy), method)));
|
||||
} else if (classMember instanceof PsiFieldMember) {
|
||||
final PsiField field = ((PsiFieldMember) classMember).getElement();
|
||||
}
|
||||
else if (classMember instanceof PsiFieldMember) {
|
||||
final PsiField field = ((PsiFieldMember)classMember).getElement();
|
||||
|
||||
String prefix = field instanceof GrField && ((GrField)field).getTypeElementGroovy() == null ? DEF_PSEUDO_ANNO : "";
|
||||
res.add(new PsiFieldMember(factory.createFieldFromText(field.getType().getCanonicalText() + " " + prefix + field.getName(), aClass)));
|
||||
res.add(
|
||||
new PsiFieldMember(factory.createFieldFromText(field.getType().getCanonicalText() + " " + prefix + field.getName(), aClass)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-6
@@ -220,9 +220,10 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
|
||||
|
||||
if (cannotBeDynamic || shouldHighlightAsUnresolved(ref)) {
|
||||
HighlightInfo info = createAnnotationForRef(ref, cannotBeDynamic, GroovyBundle.message("cannot.resolve", ref.getReferenceName()));
|
||||
LOG.assertTrue(info != null);
|
||||
|
||||
HighlightDisplayKey displayKey = HighlightDisplayKey.find(SHORT_NAME);
|
||||
if (isCall(ref)) {
|
||||
if (ref.getParent() instanceof GrMethodCall) {
|
||||
registerStaticImportFix(ref, info, displayKey);
|
||||
}
|
||||
else {
|
||||
@@ -377,7 +378,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
|
||||
return HighlightInfo.createHighlightInfo(highlightInfoType, refNameElement, message);
|
||||
}
|
||||
|
||||
private static void registerStaticImportFix(GrReferenceExpression referenceExpression, HighlightInfo info, final HighlightDisplayKey key) {
|
||||
private static void registerStaticImportFix(@NotNull GrReferenceExpression referenceExpression, @Nullable HighlightInfo info, @Nullable final HighlightDisplayKey key) {
|
||||
final String referenceName = referenceExpression.getReferenceName();
|
||||
if (StringUtil.isEmpty(referenceName)) return;
|
||||
if (referenceExpression.getQualifier() != null) return;
|
||||
@@ -436,7 +437,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerAddImportFixes(GrReferenceElement refElement, HighlightInfo info, final HighlightDisplayKey key) {
|
||||
private static void registerAddImportFixes(GrReferenceElement refElement, @Nullable HighlightInfo info, final HighlightDisplayKey key) {
|
||||
final String referenceName = refElement.getReferenceName();
|
||||
//noinspection ConstantConditions
|
||||
if (StringUtil.isEmpty(referenceName)) return;
|
||||
@@ -446,7 +447,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
|
||||
QuickFixAction.registerQuickFixAction(info, new GroovyAddImportAction(refElement), key);
|
||||
}
|
||||
|
||||
private static void registerCreateClassByTypeFix(GrReferenceElement refElement, HighlightInfo info, final HighlightDisplayKey key) {
|
||||
private static void registerCreateClassByTypeFix(GrReferenceElement refElement, @Nullable HighlightInfo info, final HighlightDisplayKey key) {
|
||||
GrPackageDefinition packageDefinition = PsiTreeUtil.getParentOfType(refElement, GrPackageDefinition.class);
|
||||
if (packageDefinition != null) return;
|
||||
|
||||
@@ -505,7 +506,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
|
||||
private final HighlightInfo myInfo;
|
||||
private HighlightDisplayKey myKey;
|
||||
|
||||
public QuickFixActionRegistrarAdapter(HighlightInfo info, HighlightDisplayKey displayKey) {
|
||||
public QuickFixActionRegistrarAdapter(@Nullable HighlightInfo info, HighlightDisplayKey displayKey) {
|
||||
myInfo = info;
|
||||
myKey = displayKey;
|
||||
}
|
||||
@@ -523,7 +524,9 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
|
||||
|
||||
@Override
|
||||
public void unregister(Condition<IntentionAction> condition) {
|
||||
QuickFixAction.unregisterQuickFixAction(myInfo, condition);
|
||||
if (myInfo != null) {
|
||||
QuickFixAction.unregisterQuickFixAction(myInfo, condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ public class GroovyCodeStyleSettings extends CustomCodeStyleSettings {
|
||||
public boolean SPACE_WITHIN_LIST_OR_MAP = false;
|
||||
public boolean ALIGN_NAMED_ARGS_IN_MAP = false;
|
||||
public boolean SPACE_BEFORE_CLOSURE_LBRACE = true;
|
||||
public boolean SPACE_WITHIN_GSTRING_INJECTION_BRACES = false;
|
||||
|
||||
//imports
|
||||
public boolean USE_FQ_CLASS_NAMES = false;
|
||||
|
||||
+2
@@ -118,6 +118,7 @@ public class GroovyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSe
|
||||
consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_IN_NAMED_ARGUMENT", "In named argument after ':'", CodeStyleSettingsCustomizable.SPACES_OTHER);
|
||||
consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_WITHIN_LIST_OR_MAP", "List and maps literals", CodeStyleSettingsCustomizable.SPACES_WITHIN);
|
||||
consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_BEFORE_CLOSURE_LBRACE", "Closure left brace in method calls", CodeStyleSettingsCustomizable.SPACES_BEFORE_LEFT_BRACE);
|
||||
consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_WITHIN_GSTRING_INJECTION_BRACES", "Space within GString injection braces", CodeStyleSettingsCustomizable.SPACES_WITHIN);
|
||||
return;
|
||||
}
|
||||
consumer.showAllStandardOptions();
|
||||
@@ -127,6 +128,7 @@ public class GroovyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSe
|
||||
public CommonCodeStyleSettings getDefaultCommonSettings() {
|
||||
CommonCodeStyleSettings defaultSettings = new CommonCodeStyleSettings(GroovyFileType.GROOVY_LANGUAGE);
|
||||
defaultSettings.initIndentOptions();
|
||||
defaultSettings.SPACE_WITHIN_BRACES = true;
|
||||
return defaultSettings;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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 org.jetbrains.plugins.groovy.formatter;
|
||||
|
||||
import com.intellij.formatting.Block;
|
||||
import com.intellij.formatting.Indent;
|
||||
import com.intellij.formatting.Wrap;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
public class ClosureBodyBlock extends GroovyBlock {
|
||||
private TextRange myTextRange;
|
||||
|
||||
public ClosureBodyBlock(@NotNull ASTNode node,
|
||||
@NotNull Indent indent,
|
||||
@Nullable Wrap wrap,
|
||||
CommonCodeStyleSettings settings,
|
||||
GroovyCodeStyleSettings groovySettings,
|
||||
@NotNull AlignmentProvider alignmentProvider) {
|
||||
super(node, indent, wrap, settings, groovySettings, alignmentProvider);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TextRange getTextRange() {
|
||||
init();
|
||||
return myTextRange;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (mySubBlocks == null) {
|
||||
GroovyBlockGenerator generator = new GroovyBlockGenerator(this);
|
||||
List<ASTNode> children = GroovyBlockGenerator.getClosureBodyVisibleChildren(myNode.getTreeParent());
|
||||
|
||||
mySubBlocks = generator.generateSubBlockForCodeBlocks(false, children);
|
||||
|
||||
//at least -> exists
|
||||
assert !mySubBlocks.isEmpty();
|
||||
TextRange firstRange = mySubBlocks.get(0).getTextRange();
|
||||
TextRange lastRange = mySubBlocks.get(mySubBlocks.size() - 1).getTextRange();
|
||||
myTextRange = new TextRange(firstRange.getStartOffset(), lastRange.getEndOffset());
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Block> getSubBlocks() {
|
||||
init();
|
||||
return mySubBlocks;
|
||||
}
|
||||
}
|
||||
@@ -155,13 +155,16 @@ public class GroovyBlock implements Block, GroovyElementTypes, ASTBlock {
|
||||
*/
|
||||
@Nullable
|
||||
public Spacing getSpacing(Block child1, @NotNull Block child2) {
|
||||
if ((child1 instanceof GroovyBlock) && (child2 instanceof GroovyBlock)) {
|
||||
if (child1 instanceof GroovyBlock && child2 instanceof GroovyBlock) {
|
||||
if (((GroovyBlock)child1).getNode() == ((GroovyBlock)child2).getNode()) {
|
||||
return Spacing.getReadOnlySpacing();
|
||||
}
|
||||
|
||||
Spacing spacing = new GroovySpacingProcessor(((GroovyBlock)child2).getNode(), mySettings, myGroovySettings).getSpacing();
|
||||
return spacing != null ? spacing : GroovySpacingProcessorBasic.getSpacing(((GroovyBlock)child1), ((GroovyBlock)child2), mySettings);
|
||||
if (spacing != null) {
|
||||
return spacing;
|
||||
}
|
||||
return GroovySpacingProcessorBasic.getSpacing(((GroovyBlock)child1), ((GroovyBlock)child2), mySettings, myGroovySettings);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -214,7 +217,7 @@ public class GroovyBlock implements Block, GroovyElementTypes, ASTBlock {
|
||||
return new ChildAttributes(Indent.getContinuationWithoutFirstIndent(), null);
|
||||
}
|
||||
if (psiParent instanceof GrParameterList) {
|
||||
return new ChildAttributes(this.getIndent(), this.getAlignment());
|
||||
return new ChildAttributes(getIndent(), getAlignment());
|
||||
}
|
||||
if (psiParent instanceof GrListOrMap) {
|
||||
return new ChildAttributes(Indent.getContinuationIndent(), null);
|
||||
|
||||
+91
-15
@@ -55,6 +55,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaratio
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentLabel;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression;
|
||||
@@ -101,6 +102,31 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
|
||||
myGroovySettings = myBlock.getGroovySettings();
|
||||
}
|
||||
|
||||
static List<ASTNode> getClosureBodyVisibleChildren(final ASTNode node) {
|
||||
List<ASTNode> children = visibleChildren(node);
|
||||
|
||||
if (!children.isEmpty()) {
|
||||
ASTNode first = children.get(0);
|
||||
if (first.getElementType() == GroovyTokenTypes.mLCURLY) children.remove(0);
|
||||
}
|
||||
|
||||
/* if (!children.isEmpty()) {
|
||||
ASTNode second = children.get(0);
|
||||
if (second.getElementType() == GroovyElementTypes.PARAMETERS_LIST) children.remove(0);
|
||||
}
|
||||
|
||||
if (!children.isEmpty()) {
|
||||
ASTNode second = children.get(0);
|
||||
if (second.getElementType() == GroovyTokenTypes.mCLOSABLE_BLOCK_OP) children.remove(0);
|
||||
}*/
|
||||
|
||||
if (!children.isEmpty()) {
|
||||
ASTNode last = children.get(children.size() - 1);
|
||||
if (last.getElementType() == GroovyTokenTypes.mRCURLY) children.remove(children.size() - 1);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
|
||||
public List<Block> generateSubBlocks() {
|
||||
|
||||
@@ -188,22 +214,54 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
|
||||
}
|
||||
|
||||
boolean classLevel = blockPsi instanceof GrTypeDefinitionBody;
|
||||
if (blockPsi instanceof GrCodeBlock || blockPsi instanceof GroovyFile || classLevel) {
|
||||
List<ASTNode> children = visibleChildren(myNode);
|
||||
calculateAlignments(children, classLevel);
|
||||
final ArrayList<Block> subBlocks = new ArrayList<Block>();
|
||||
if (blockPsi instanceof GrClosableBlock &&
|
||||
((GrClosableBlock)blockPsi).getArrow() != null &&
|
||||
((GrClosableBlock)blockPsi).getParameters().length > 0 &&
|
||||
!getClosureBodyVisibleChildren(myNode).isEmpty()) {
|
||||
GrClosableBlock closableBlock = (GrClosableBlock)blockPsi;
|
||||
|
||||
if (classLevel && myAlignment != null) {
|
||||
final AlignmentProvider.Aligner aligner = myAlignmentProvider.createAligner(true);
|
||||
for (ASTNode child : children) {
|
||||
aligner.append(child.getPsi());
|
||||
}
|
||||
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||
|
||||
PsiElement lbrace = closableBlock.getLBrace();
|
||||
if (lbrace != null) {
|
||||
ASTNode node = lbrace.getNode();
|
||||
Indent indent = GroovyIndentProcessor.getChildIndent(myBlock, node);
|
||||
blocks.add(new GroovyBlock(node, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
|
||||
}
|
||||
for (ASTNode childNode : children) {
|
||||
final Indent indent = GroovyIndentProcessor.getChildIndent(myBlock, childNode);
|
||||
subBlocks.add(new GroovyBlock(childNode, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
|
||||
|
||||
/* {
|
||||
Indent indent = GroovyIndentProcessor.getChildIndent(myBlock, parameterListNode);
|
||||
GroovyBlock block = new GroovyBlock(parameterListNode, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider);
|
||||
blocks.add(block);
|
||||
}
|
||||
return subBlocks;
|
||||
|
||||
{
|
||||
PsiElement arrow = closableBlock.getArrow();
|
||||
ASTNode node = arrow.getNode();
|
||||
Indent indent = GroovyIndentProcessor.getChildIndent(myBlock, node);
|
||||
GroovyBlock block = new GroovyBlock(node, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider);
|
||||
blocks.add(block);
|
||||
}*/
|
||||
|
||||
{
|
||||
Indent indent = Indent.getNormalIndent();
|
||||
ASTNode parameterListNode = closableBlock.getParameterList().getNode();
|
||||
ClosureBodyBlock bodyBlock = new ClosureBodyBlock(parameterListNode, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider);
|
||||
blocks.add(bodyBlock);
|
||||
}
|
||||
|
||||
PsiElement rbrace = closableBlock.getRBrace();
|
||||
if (rbrace != null) {
|
||||
ASTNode node = rbrace.getNode();
|
||||
Indent indent = GroovyIndentProcessor.getChildIndent(myBlock, node);
|
||||
blocks.add(new GroovyBlock(node, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
if (blockPsi instanceof GrCodeBlock || blockPsi instanceof GroovyFile || classLevel) {
|
||||
return generateSubBlockForCodeBlocks(classLevel, visibleChildren(myNode));
|
||||
}
|
||||
|
||||
// For other cases
|
||||
@@ -214,7 +272,25 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
|
||||
}
|
||||
return subBlocks;
|
||||
}
|
||||
|
||||
|
||||
public List<Block> generateSubBlockForCodeBlocks(boolean classLevel, final List<ASTNode> children) {
|
||||
|
||||
calculateAlignments(children, classLevel);
|
||||
final ArrayList<Block> subBlocks = new ArrayList<Block>();
|
||||
|
||||
if (classLevel && myAlignment != null) {
|
||||
final AlignmentProvider.Aligner aligner = myAlignmentProvider.createAligner(true);
|
||||
for (ASTNode child : children) {
|
||||
aligner.append(child.getPsi());
|
||||
}
|
||||
}
|
||||
for (ASTNode childNode : children) {
|
||||
final Indent indent = GroovyIndentProcessor.getChildIndent(myBlock, childNode);
|
||||
subBlocks.add(new GroovyBlock(childNode, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
|
||||
}
|
||||
return subBlocks;
|
||||
}
|
||||
|
||||
|
||||
private void calculateAlignments(List<ASTNode> children, boolean classLevel) {
|
||||
List<GrStatement> currentGroup = null;
|
||||
@@ -330,7 +406,7 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
|
||||
return psi instanceof GrBinaryExpression && (mBOR == ((GrBinaryExpression)psi).getOperationTokenType() || mLOR == ((GrBinaryExpression)psi).getOperationTokenType());
|
||||
}
|
||||
|
||||
private static List<ASTNode> visibleChildren(ASTNode node) {
|
||||
public static List<ASTNode> visibleChildren(ASTNode node) {
|
||||
ArrayList<ASTNode> list = new ArrayList<ASTNode>();
|
||||
for (ASTNode astNode : getGroovyChildren(node)) {
|
||||
if (canBeCorrectBlock(astNode)) {
|
||||
|
||||
+6
-1
@@ -25,6 +25,7 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.formatter.ClosureBodyBlock;
|
||||
import org.jetbrains.plugins.groovy.formatter.GroovyBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment;
|
||||
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocTag;
|
||||
@@ -85,9 +86,13 @@ public abstract class GroovyIndentProcessor implements GroovyElementTypes {
|
||||
}
|
||||
}
|
||||
|
||||
if (child.getElementType() == GroovyElementTypes.PARAMETERS_LIST && parent instanceof ClosureBodyBlock) {
|
||||
return Indent.getNoneIndent();
|
||||
}
|
||||
|
||||
// For common code block
|
||||
if (BLOCK_SET.contains(astNode.getElementType()) &&
|
||||
!BLOCK_STATEMENT.equals(astNode.getElementType())) {
|
||||
!BLOCK_STATEMENT.equals(astNode.getElementType()) || parent instanceof ClosureBodyBlock) {
|
||||
return indentForBlock(psiParent, child);
|
||||
}
|
||||
|
||||
|
||||
+17
-12
@@ -247,19 +247,20 @@ public class GroovySpacingProcessor extends GroovyElementVisitor {
|
||||
myResult = Spacing.createSpacing(0, 0, 0, true, 100, 0);
|
||||
}
|
||||
}
|
||||
else if (myType1 == mLCURLY && myType2 != PARAMETERS_LIST && myType2 != mCLOSABLE_BLOCK_OP || myType2 == mRCURLY) {
|
||||
myResult = Spacing
|
||||
.createDependentLFSpacing(mySettings.SPACE_WITHIN_BRACES ? 1 : 0, 1, closure.getTextRange(), mySettings.KEEP_LINE_BREAKS,
|
||||
mySettings.KEEP_BLANK_LINES_IN_CODE);
|
||||
else if (myType1 == mLCURLY && myType2 == mRCURLY) { //empty closure
|
||||
myResult = Spacing.createSpacing(0, 0, 0, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
|
||||
}
|
||||
else if (closure.getParameters().length == 0 && (myType1 == mLCURLY && myType2 != PARAMETERS_LIST && myType2 != mCLOSABLE_BLOCK_OP || myType2 == mRCURLY)) { //spaces between statements
|
||||
|
||||
boolean spacesWithinBraces = closure.getParent() instanceof GrStringInjection
|
||||
? myGroovySettings.SPACE_WITHIN_GSTRING_INJECTION_BRACES
|
||||
: mySettings.SPACE_WITHIN_BRACES;
|
||||
int minSpaces = spacesWithinBraces ? 1 : 0;
|
||||
myResult = Spacing.createDependentLFSpacing(minSpaces, 1, closure.getTextRange(), mySettings.KEEP_LINE_BREAKS,
|
||||
mySettings.KEEP_BLANK_LINES_IN_CODE);
|
||||
}
|
||||
else if (myType1 == mCLOSABLE_BLOCK_OP) {
|
||||
GrStatement[] statements = closure.getStatements();
|
||||
if (statements.length > 0) {
|
||||
TextRange range =
|
||||
new TextRange(statements[0].getTextRange().getStartOffset(), statements[statements.length - 1].getTextRange().getEndOffset());
|
||||
myResult =
|
||||
Spacing.createDependentLFSpacing(1, Integer.MAX_VALUE, range, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
|
||||
}
|
||||
myResult = GroovySpacingProcessorBasic.createDependentSpacingForClosure(mySettings, myGroovySettings, closure, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,6 +270,9 @@ public class GroovySpacingProcessor extends GroovyElementVisitor {
|
||||
myResult = Spacing.createSpacing(1, 1, 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
|
||||
}
|
||||
}
|
||||
else if (myType1 == mLCURLY && myType2 == mRCURLY) {
|
||||
myResult = Spacing.createSpacing(0, 0, 0, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
|
||||
}
|
||||
else if (myType1 == mLCURLY && !GrStringUtil.isMultilineStringElement(myChild2) ||
|
||||
myType2 == mRCURLY && !GrStringUtil.isMultilineStringElement(myChild1)) {
|
||||
final int spaceWithinBraces = mySettings.SPACE_WITHIN_BRACES ? 1 : 0;
|
||||
@@ -280,7 +284,8 @@ public class GroovySpacingProcessor extends GroovyElementVisitor {
|
||||
public void visitNewExpression(GrNewExpression newExpression) {
|
||||
if (myType1 == kNEW) {
|
||||
createSpaceInCode(true);
|
||||
} else if (myType2 == ARGUMENTS) {
|
||||
}
|
||||
else if (myType2 == ARGUMENTS) {
|
||||
createSpaceInCode(mySettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES);
|
||||
}
|
||||
}
|
||||
|
||||
+40
-5
@@ -18,17 +18,22 @@ package org.jetbrains.plugins.groovy.formatter.processors;
|
||||
|
||||
import com.intellij.formatting.Spacing;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiErrorElement;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;
|
||||
import org.jetbrains.plugins.groovy.formatter.ClosureBodyBlock;
|
||||
import org.jetbrains.plugins.groovy.formatter.GroovyBlock;
|
||||
import org.jetbrains.plugins.groovy.formatter.MethodCallWithoutQualifierBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrConditionalExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrUnaryExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringInjection;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
|
||||
@@ -57,7 +62,10 @@ public abstract class GroovySpacingProcessorBasic {
|
||||
private static final Spacing IMPORT_OTHER_SPACING = Spacing.createSpacing(0, 0, 2, true, 100);
|
||||
private static final Spacing LAZY_SPACING = Spacing.createSpacing(0, 239, 0, true, 100);
|
||||
|
||||
public static Spacing getSpacing(GroovyBlock child1, GroovyBlock child2, CommonCodeStyleSettings settings) {
|
||||
public static Spacing getSpacing(GroovyBlock child1,
|
||||
GroovyBlock child2,
|
||||
CommonCodeStyleSettings settings,
|
||||
GroovyCodeStyleSettings groovySettings) {
|
||||
|
||||
ASTNode leftNode = child1.getNode();
|
||||
ASTNode rightNode = child2.getNode();
|
||||
@@ -69,12 +77,20 @@ public abstract class GroovySpacingProcessorBasic {
|
||||
|
||||
//Braces Placement
|
||||
// For multi-line strings
|
||||
if (!mirrorsAst(child1) || !mirrorsAst(child2)) {
|
||||
if (!(mirrorsAst(child1) && mirrorsAst(child2))) {
|
||||
return NO_SPACING;
|
||||
}
|
||||
|
||||
if (leftType == mGDOC_COMMENT_START && rightType == mGDOC_COMMENT_DATA
|
||||
|| leftType == mGDOC_COMMENT_DATA && rightType == mGDOC_COMMENT_END) {
|
||||
if (child2 instanceof ClosureBodyBlock) {
|
||||
return settings.SPACE_WITHIN_BRACES ? COMMON_SPACING : NO_SPACING_WITH_NEWLINE;
|
||||
}
|
||||
|
||||
if (child1 instanceof ClosureBodyBlock) {
|
||||
return createDependentSpacingForClosure(settings, groovySettings, (GrClosableBlock)left.getParent(), false);
|
||||
}
|
||||
|
||||
if (leftType == mGDOC_COMMENT_START && rightType == mGDOC_COMMENT_DATA ||
|
||||
leftType == mGDOC_COMMENT_DATA && rightType == mGDOC_COMMENT_END) {
|
||||
return LAZY_SPACING;
|
||||
}
|
||||
|
||||
@@ -240,7 +256,26 @@ public abstract class GroovySpacingProcessorBasic {
|
||||
return COMMON_SPACING;
|
||||
}
|
||||
|
||||
static Spacing createDependentSpacingForClosure(CommonCodeStyleSettings settings,
|
||||
GroovyCodeStyleSettings groovySettings, GrClosableBlock closure,
|
||||
final boolean forArrow) {
|
||||
boolean spaceWithinBraces = closure.getParent() instanceof GrStringInjection
|
||||
? groovySettings.SPACE_WITHIN_GSTRING_INJECTION_BRACES
|
||||
: settings.SPACE_WITHIN_BRACES;
|
||||
GrStatement[] statements = closure.getStatements();
|
||||
if (statements.length > 0) {
|
||||
int start = statements[0].getTextRange().getStartOffset();
|
||||
int end = statements[statements.length - 1].getTextRange().getEndOffset();
|
||||
TextRange range = new TextRange(start, end);
|
||||
|
||||
int minSpaces = spaceWithinBraces || forArrow ? 1 : 0;
|
||||
int maxSpaces = spaceWithinBraces || forArrow ? 1 : 0;
|
||||
return Spacing.createDependentLFSpacing(minSpaces, maxSpaces, range, settings.KEEP_LINE_BREAKS, settings.KEEP_BLANK_LINES_IN_CODE);
|
||||
}
|
||||
return spaceWithinBraces || forArrow ? COMMON_SPACING : NO_SPACING_WITH_NEWLINE;
|
||||
}
|
||||
|
||||
private static boolean mirrorsAst(GroovyBlock block) {
|
||||
return block.getNode().getTextRange().equals(block.getTextRange()) || block instanceof MethodCallWithoutQualifierBlock;
|
||||
return block.getNode().getTextRange().equals(block.getTextRange()) || block instanceof MethodCallWithoutQualifierBlock || block instanceof ClosureBodyBlock;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-7
@@ -138,8 +138,13 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
|
||||
}
|
||||
|
||||
public GrReferenceExpression createReferenceExpressionFromText(String idText, PsiElement context) {
|
||||
PsiFile file = createGroovyFile(idText, false, context);
|
||||
return (GrReferenceExpression) ((GroovyFileBase) file).getTopStatements()[0];
|
||||
GroovyFile file = createGroovyFile(idText, false, context);
|
||||
GrTopStatement[] statements = file.getTopStatements();
|
||||
|
||||
if (statements.length != 1) throw new IncorrectOperationException("refText: " + idText);
|
||||
if (!(statements[0] instanceof GrReferenceExpression)) throw new IncorrectOperationException("refText: " + idText);
|
||||
|
||||
return (GrReferenceExpression)statements[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -608,13 +613,15 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
|
||||
|
||||
@Override
|
||||
public GrStatement createStatementFromText(String text, @Nullable PsiElement context) {
|
||||
try {
|
||||
PsiFile file = createGroovyFile(text, false, context);
|
||||
return (GrStatement)((GroovyFileBase)file).getTopStatements()[0];
|
||||
GroovyFile file = createGroovyFile(text, false, context);
|
||||
GrTopStatement[] statements = file.getTopStatements();
|
||||
if (statements.length != 1) {
|
||||
throw new IncorrectOperationException("count = " + statements.length + ", " + text);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
throw new IncorrectOperationException(text);
|
||||
if (!(statements[0] instanceof GrStatement)) {
|
||||
throw new IncorrectOperationException("type = " + statements[0].getClass().getName() + ", " + text);
|
||||
}
|
||||
return (GrStatement)statements[0];
|
||||
}
|
||||
|
||||
public GrBlockStatement createBlockStatement(@NonNls GrStatement... statements) {
|
||||
|
||||
+4
-1
@@ -93,7 +93,10 @@ public class GrConstructorInvocationImpl extends GrCallImpl implements GrConstru
|
||||
}
|
||||
|
||||
public GroovyResolveResult[] multiResolveClass() {
|
||||
return new GroovyResolveResult[]{new GroovyResolveResultImpl(getDelegatedClass(), this, null, PsiSubstitutor.EMPTY, true, true)};
|
||||
PsiClass aClass = getDelegatedClass();
|
||||
if (aClass == null) return GroovyResolveResult.EMPTY_ARRAY;
|
||||
|
||||
return new GroovyResolveResult[]{new GroovyResolveResultImpl(aClass, this, null, PsiSubstitutor.EMPTY, true, true)};
|
||||
}
|
||||
|
||||
public PsiMethod resolveMethod() {
|
||||
|
||||
+14
-1
@@ -18,8 +18,10 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.light.LightElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
|
||||
|
||||
@@ -48,7 +50,7 @@ public class GrSyntheticTypeElement extends LightElement implements PsiTypeEleme
|
||||
|
||||
@Override
|
||||
public PsiAnnotationOwner getOwner(PsiAnnotation annotation) {
|
||||
return null;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,6 +86,17 @@ public class GrSyntheticTypeElement extends LightElement implements PsiTypeEleme
|
||||
return "Synthetic PsiTypeElement";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement replace(@NotNull PsiElement newElement) throws IncorrectOperationException {
|
||||
if (newElement instanceof PsiTypeElement) {
|
||||
GrTypeElement groovyTypeElement = GroovyPsiElementFactory.getInstance(getProject()).createTypeElement(newElement.getText(), newElement);
|
||||
return myElement.replace(groovyTypeElement);
|
||||
}
|
||||
else {
|
||||
return super.replace(newElement);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextRange getTextRange() {
|
||||
return myElement.getTextRange();
|
||||
|
||||
+3
-2
@@ -118,8 +118,9 @@ public class ParameterToMapEntryTest extends GroovyFormatterTestCase {
|
||||
PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting();
|
||||
final String result = file.getText();
|
||||
//System.out.println(result);
|
||||
String expected = getExpectedResult(filePath);
|
||||
Assert.assertEquals(expected, result);
|
||||
myFixture.checkResultByFile(filePath.replace(".groovy", ".test"), true);
|
||||
// String expected = getExpectedResult(filePath);
|
||||
// Assert.assertEquals(expected, result);
|
||||
}
|
||||
|
||||
private String getExpectedResult(final String filePath) {
|
||||
|
||||
+1
@@ -61,6 +61,7 @@ public abstract class ExtractClosureTest extends LightGroovyTestCase {
|
||||
}
|
||||
|
||||
handler.invoke myFixture.project, myFixture.editor, myFixture.file, null
|
||||
doPostponedFormatting(myFixture.project)
|
||||
myFixture.checkResult after
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ if (suitable) {
|
||||
}
|
||||
-----
|
||||
if (suitable) {
|
||||
expectations.each {pattern, action ->
|
||||
expectations.each { pattern, action ->
|
||||
if (cloud.match(pattern, action)) {
|
||||
<caret>
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
try {foo()} catch (E e) {} finally {bar()}
|
||||
-----
|
||||
try
|
||||
{foo()} catch (E e)
|
||||
{ foo() } catch (E e)
|
||||
{}
|
||||
finally
|
||||
{bar()}
|
||||
{ bar() }
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
<option>BRACE_STYLE=END_OF_LINE</option>
|
||||
<option>FINALLY_ON_NEW_LINE=false</option>
|
||||
<option>CATCH_ON_NEW_LINE=true</option>
|
||||
try {foo()}
|
||||
try {foo()}
|
||||
catch (E e) {} finally {bar()}
|
||||
-----
|
||||
try {foo()}
|
||||
catch (E e) {} finally {bar()}
|
||||
try { foo() }
|
||||
catch (E e) {} finally { bar() }
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
def a={a,b->c}
|
||||
-----
|
||||
def a = {a, b -> c}
|
||||
def a = { a, b -> c }
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
foo{a-> a+1}
|
||||
-----
|
||||
foo {a -> a + 1}
|
||||
foo { a -> a + 1 }
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
foo (1,2) {a->3}
|
||||
-----
|
||||
foo(1, 2) {a -> 3}
|
||||
foo(1, 2) { a -> 3 }
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@
|
||||
-----
|
||||
foo(2) {
|
||||
foo(2) {
|
||||
foo(2) {print f}
|
||||
foo(2) { print f }
|
||||
} }
|
||||
+1
-1
@@ -5,5 +5,5 @@
|
||||
-----
|
||||
foo(2) {
|
||||
foo(2) {
|
||||
foo(2) {print f}
|
||||
foo(2) { print f }
|
||||
} }
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user