From e90c93b546b76138dd6ec4cb5dbd31b230944576 Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 16 Jul 2010 16:44:23 +0400 Subject: [PATCH 01/79] method extracted --- .../src/com/intellij/ui/HyperlinkLabel.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/platform/platform-api/src/com/intellij/ui/HyperlinkLabel.java b/platform/platform-api/src/com/intellij/ui/HyperlinkLabel.java index 93c9dc5e301d..3dec125ac557 100644 --- a/platform/platform-api/src/com/intellij/ui/HyperlinkLabel.java +++ b/platform/platform-api/src/com/intellij/ui/HyperlinkLabel.java @@ -16,9 +16,11 @@ package com.intellij.ui; +import com.intellij.ide.BrowserUtil; import com.intellij.openapi.editor.markup.EffectType; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.util.ui.UIUtil; +import org.jetbrains.annotations.NotNull; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; @@ -108,6 +110,15 @@ public class HyperlinkLabel extends HighlightableComponent { adjustSize(); } + public void setHyperlinkTarget(@NotNull final String url) { + addHyperlinkListener(new HyperlinkListener() { + @Override + public void hyperlinkUpdate(HyperlinkEvent e) { + BrowserUtil.launchBrowser(url); + } + }); + } + public void addHyperlinkListener(HyperlinkListener listener) { myListeners.add(listener); } From c54cafe97543a42f3bf88a7bd7dc9bd4eb7819d8 Mon Sep 17 00:00:00 2001 From: nik Date: Mon, 19 Jul 2010 11:26:37 +0400 Subject: [PATCH 02/79] tests fixed --- .../AddSupportForFrameworksPanel.java | 32 +++++++++++-------- .../FrameworkSupportProviderTestCase.java | 5 ++- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java index 729972d24cdf..64018fe883de 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java @@ -285,7 +285,7 @@ public class AddSupportForFrameworksPanel implements Disposable { String underlyingFrameworkId = provider.getUnderlyingFrameworkId(); FrameworkSupportNode parentNode = null; if (underlyingFrameworkId != null) { - FrameworkSupportProvider parentProvider = findProvider(underlyingFrameworkId); + FrameworkSupportProvider parentProvider = findProvider(underlyingFrameworkId, myProviders); if (parentProvider == null) { LOG.info("Cannot find id = " + underlyingFrameworkId); return null; @@ -300,8 +300,8 @@ public class AddSupportForFrameworksPanel implements Disposable { } @Nullable - private FrameworkSupportProvider findProvider(@NotNull String id) { - for (FrameworkSupportProvider provider : myProviders) { + private static FrameworkSupportProvider findProvider(@NotNull String id, final List providers) { + for (FrameworkSupportProvider provider : providers) { if (id.equals(provider.getId())) { return provider; } @@ -362,13 +362,7 @@ public class AddSupportForFrameworksPanel implements Disposable { } private void sortFrameworks(final List nodes) { - DFSTBuilder builder = new DFSTBuilder(GraphGenerator.create(CachingSemiGraph.create(new ProvidersGraph(myProviders)))); - if (!builder.isAcyclic()) { - Pair pair = builder.getCircularDependency(); - LOG.error("Circular dependency between providers '" + pair.getFirst().getId() + "' and '" + pair.getSecond().getId() + "' was found."); - } - - final Comparator comparator = builder.comparator(); + final Comparator comparator = getFrameworkSupportProvidersComparator(myProviders); Collections.sort(nodes, new Comparator() { public int compare(final FrameworkSupportNode o1, final FrameworkSupportNode o2) { return comparator.compare(o1.getProvider(), o2.getProvider()); @@ -376,7 +370,19 @@ public class AddSupportForFrameworksPanel implements Disposable { }); } - private class ProvidersGraph implements GraphGenerator.SemiGraph { + public static Comparator getFrameworkSupportProvidersComparator(final List providers) { + DFSTBuilder + builder = new DFSTBuilder(GraphGenerator.create(CachingSemiGraph.create( + new ProvidersGraph(providers)))); + if (!builder.isAcyclic()) { + Pair pair = builder.getCircularDependency(); + LOG.error("Circular dependency between providers '" + pair.getFirst().getId() + "' and '" + pair.getSecond().getId() + "' was found."); + } + + return builder.comparator(); + } + + private static class ProvidersGraph implements GraphGenerator.SemiGraph { private final List myFrameworkSupportProviders; public ProvidersGraph(final List frameworkSupportProviders) { @@ -392,13 +398,13 @@ public class AddSupportForFrameworksPanel implements Disposable { List dependencies = new ArrayList(); String underlyingId = provider.getUnderlyingFrameworkId(); if (underlyingId != null) { - FrameworkSupportProvider underlyingProvider = findProvider(underlyingId); + FrameworkSupportProvider underlyingProvider = findProvider(underlyingId, myFrameworkSupportProviders); if (underlyingProvider != null) { dependencies.add(underlyingProvider); } } for (String id : ids) { - FrameworkSupportProvider dependency = findProvider(id); + FrameworkSupportProvider dependency = findProvider(id, myFrameworkSupportProviders); if (dependency != null) { dependencies.add(dependency); } diff --git a/java/java-tests/testSrc/com/intellij/ide/util/frameworkSupport/FrameworkSupportProviderTestCase.java b/java/java-tests/testSrc/com/intellij/ide/util/frameworkSupport/FrameworkSupportProviderTestCase.java index eb63696cd21a..9b843125a545 100644 --- a/java/java-tests/testSrc/com/intellij/ide/util/frameworkSupport/FrameworkSupportProviderTestCase.java +++ b/java/java-tests/testSrc/com/intellij/ide/util/frameworkSupport/FrameworkSupportProviderTestCase.java @@ -4,6 +4,7 @@ import com.intellij.facet.Facet; import com.intellij.facet.FacetManager; import com.intellij.facet.FacetTypeId; import com.intellij.facet.ui.FacetBasedFrameworkSupportProvider; +import com.intellij.ide.util.newProjectWizard.AddSupportForFrameworksPanel; import com.intellij.ide.util.newProjectWizard.FrameworkSupportNode; import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportCommunicator; import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelImpl; @@ -31,7 +32,9 @@ public abstract class FrameworkSupportProviderTestCase extends IdeaTestCase { super.setUp(); myFrameworkSupportModel = new FrameworkSupportModelImpl(getProject(), null); myNodes = new HashMap(); - for (FrameworkSupportProvider provider : FrameworkSupportProvider.EXTENSION_POINT.getExtensions()) { + final FrameworkSupportProvider[] providers = FrameworkSupportProvider.EXTENSION_POINT.getExtensions().clone(); + Arrays.sort(providers, AddSupportForFrameworksPanel.getFrameworkSupportProvidersComparator(new ArrayList(Arrays.asList(providers)))); + for (FrameworkSupportProvider provider : providers) { final FrameworkSupportNode node = new FrameworkSupportNode(provider, null, myFrameworkSupportModel, null, getTestRootDisposable()); myNodes.put(provider, node); myFrameworkSupportModel.registerComponent(provider, node); From 4a1dcd9f98984b23532cdaf2e08ab1e19b200dd8 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Fri, 16 Jul 2010 14:08:51 +0400 Subject: [PATCH 03/79] immutable CompositeDocumentationProvider --- .../intellij/lang/LanguageDocumentation.java | 9 +------ .../CompositeDocumentationProvider.java | 27 ++++++++++--------- .../documentation/DocumentationManager.java | 15 +++-------- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/platform/lang-api/src/com/intellij/lang/LanguageDocumentation.java b/platform/lang-api/src/com/intellij/lang/LanguageDocumentation.java index 6b3c81872974..443078992067 100644 --- a/platform/lang-api/src/com/intellij/lang/LanguageDocumentation.java +++ b/platform/lang-api/src/com/intellij/lang/LanguageDocumentation.java @@ -22,8 +22,6 @@ package com.intellij.lang; import com.intellij.lang.documentation.CompositeDocumentationProvider; import com.intellij.lang.documentation.DocumentationProvider; -import java.util.List; - public class LanguageDocumentation extends LanguageExtension { public static final LanguageDocumentation INSTANCE = new LanguageDocumentation(); @@ -32,11 +30,6 @@ public class LanguageDocumentation extends LanguageExtension providers = allForLanguage(l); - if (providers.size() < 2) { - return super.forLanguage(l); - } - - return new CompositeDocumentationProvider(providers); + return CompositeDocumentationProvider.wrapProviders(allForLanguage(l)); } } \ No newline at end of file diff --git a/platform/lang-api/src/com/intellij/lang/documentation/CompositeDocumentationProvider.java b/platform/lang-api/src/com/intellij/lang/documentation/CompositeDocumentationProvider.java index 98aa3ac92463..0cdf910f30da 100644 --- a/platform/lang-api/src/com/intellij/lang/documentation/CompositeDocumentationProvider.java +++ b/platform/lang-api/src/com/intellij/lang/documentation/CompositeDocumentationProvider.java @@ -28,24 +28,25 @@ public class CompositeDocumentationProvider implements DocumentationProvider, Ex private final List myProviders; - public CompositeDocumentationProvider (DocumentationProvider ... documentationProviders) { - this(Arrays.asList(documentationProviders)); + public static DocumentationProvider wrapProviders(Collection providers) { + ArrayList list = new ArrayList(); + for (DocumentationProvider provider : providers) { + if (provider instanceof CompositeDocumentationProvider) { + list.addAll(((CompositeDocumentationProvider)provider).getProviders()); + } + else if (provider != null) { + list.add(provider); + } + } + return list.size() == 1 ? list.get(0) : new CompositeDocumentationProvider(Collections.unmodifiableList(list)); } - public CompositeDocumentationProvider(Collection providers) { - myProviders = new ArrayList(providers); - } - - public void inject (DocumentationProvider provider) { - myProviders.add ( provider ); - } - - public void remove (DocumentationProvider provider) { - myProviders.remove ( provider ); + private CompositeDocumentationProvider(List providers) { + myProviders = providers; } public List getProviders() { - return Collections.unmodifiableList(myProviders); + return myProviders; } public String getQuickNavigateInfo(PsiElement element) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java index 9f1ddcece42c..0f6dcfa19449 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java @@ -64,7 +64,6 @@ import com.intellij.ui.popup.NotLookupOrSearchCondition; import com.intellij.ui.popup.PopupUpdateProcessor; import com.intellij.util.Alarm; import com.intellij.util.Processor; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.update.Activatable; import com.intellij.util.ui.update.UiNotifyConnector; import org.jetbrains.annotations.NonNls; @@ -777,22 +776,16 @@ public class DocumentationManager { DocumentationProvider elementProvider = element == null || elementLanguage.is(containingFileLanguage) ? null : LanguageDocumentation.INSTANCE.forLanguage(elementLanguage); - addProviderToResult(result, elementProvider); - addProviderToResult(result, originalProvider); + result.add(elementProvider); + result.add(originalProvider); if (containingFile != null) { final Language baseLanguage = containingFile.getViewProvider().getBaseLanguage(); if (!baseLanguage.is(containingFileLanguage)) { - addProviderToResult(result, LanguageDocumentation.INSTANCE.forLanguage(baseLanguage)); + result.add(LanguageDocumentation.INSTANCE.forLanguage(baseLanguage)); } } - // return extensible documentation provider even if the list is empty - return new CompositeDocumentationProvider(result); - } - - private static void addProviderToResult(final Set result, final DocumentationProvider t) { - if (t instanceof CompositeDocumentationProvider) result.addAll(((CompositeDocumentationProvider)t).getProviders()); - else ContainerUtil.addIfNotNull(t, result); + return CompositeDocumentationProvider.wrapProviders(result); } @Nullable From 80bda5f858f4a4efb903823d9626142986193846 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Fri, 16 Jul 2010 15:28:04 +0400 Subject: [PATCH 04/79] IDEA-46629: Quick javadoc for .tag-files not working --- .../src/com/intellij/psi/jsp/JspDirectiveKind.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/jsp-base-openapi/src/com/intellij/psi/jsp/JspDirectiveKind.java b/java/jsp-base-openapi/src/com/intellij/psi/jsp/JspDirectiveKind.java index 537d367c7bdb..9a6a53966be9 100644 --- a/java/jsp-base-openapi/src/com/intellij/psi/jsp/JspDirectiveKind.java +++ b/java/jsp-base-openapi/src/com/intellij/psi/jsp/JspDirectiveKind.java @@ -19,6 +19,7 @@ package com.intellij.psi.jsp; * @author ven */ public enum JspDirectiveKind { + /** Mapped to both page and tag directives */ PAGE, INCLUDE, TAGLIB, From 6e179be9d72861924a47fb749352ebc680d138df Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Mon, 19 Jul 2010 12:21:50 +0400 Subject: [PATCH 05/79] bundle zen-coding live templates --- xml/impl/resources/liveTemplates/zen_html.xml | 1153 +++++++++++++++++ xml/impl/resources/liveTemplates/zen_xsl.xml | 118 ++ .../XmlDefaultLiveTemplatesProvider.java | 2 +- .../zencoding/XmlZenCodingTemplate.java | 2 +- .../zencoding/nodes/GenerationNode.java | 4 +- 5 files changed, 1275 insertions(+), 4 deletions(-) create mode 100644 xml/impl/resources/liveTemplates/zen_html.xml create mode 100644 xml/impl/resources/liveTemplates/zen_xsl.xml diff --git a/xml/impl/resources/liveTemplates/zen_html.xml b/xml/impl/resources/liveTemplates/zen_html.xml new file mode 100644 index 000000000000..97584af43ad1 --- /dev/null +++ b/xml/impl/resources/liveTemplates/zen_html.xml @@ -0,0 +1,1153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml/impl/resources/liveTemplates/zen_xsl.xml b/xml/impl/resources/liveTemplates/zen_xsl.xml new file mode 100644 index 000000000000..de97235db242 --- /dev/null +++ b/xml/impl/resources/liveTemplates/zen_xsl.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/xml/impl/src/com/intellij/codeInsight/template/XmlDefaultLiveTemplatesProvider.java b/xml/impl/src/com/intellij/codeInsight/template/XmlDefaultLiveTemplatesProvider.java index ddd130748c77..7991581bfb17 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/XmlDefaultLiveTemplatesProvider.java +++ b/xml/impl/src/com/intellij/codeInsight/template/XmlDefaultLiveTemplatesProvider.java @@ -22,6 +22,6 @@ import com.intellij.codeInsight.template.impl.DefaultLiveTemplatesProvider; */ public class XmlDefaultLiveTemplatesProvider implements DefaultLiveTemplatesProvider { public String[] getDefaultLiveTemplateFiles() { - return new String[] { "/liveTemplates/html_xml" }; + return new String[] { "/liveTemplates/html_xml", "/liveTemplates/zen_html", "/liveTemplates/zen_xsl" }; } } diff --git a/xml/impl/src/com/intellij/codeInsight/template/zencoding/XmlZenCodingTemplate.java b/xml/impl/src/com/intellij/codeInsight/template/zencoding/XmlZenCodingTemplate.java index 0acceb6df469..c33e58464d2d 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/zencoding/XmlZenCodingTemplate.java +++ b/xml/impl/src/com/intellij/codeInsight/template/zencoding/XmlZenCodingTemplate.java @@ -262,7 +262,7 @@ public class XmlZenCodingTemplate extends ZenCodingTemplate { private static TemplateImpl generateTagTemplate(String tagName, CustomTemplateCallback callback) { StringBuilder builder = new StringBuilder("<"); builder.append(tagName).append('>'); - if (isTrueXml(callback) || !HtmlUtil.isSingleHtmlTag(tagName)) { + if (!HtmlUtil.isSingleHtmlTag(tagName)) { builder.append("$END$'); } return new TemplateImpl("", builder.toString(), ""); diff --git a/xml/impl/src/com/intellij/codeInsight/template/zencoding/nodes/GenerationNode.java b/xml/impl/src/com/intellij/codeInsight/template/zencoding/nodes/GenerationNode.java index 88dcb7b1622a..84430d374af5 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/zencoding/nodes/GenerationNode.java +++ b/xml/impl/src/com/intellij/codeInsight/template/zencoding/nodes/GenerationNode.java @@ -206,7 +206,7 @@ public class GenerationNode { return template; } - private static TemplateImpl invokeXmlTemplate(XmlTemplateToken token, + private static TemplateImpl invokeXmlTemplate(final XmlTemplateToken token, CustomTemplateCallback callback, final int numberInIteration, @Nullable ZenCodingGenerator generator, @@ -227,6 +227,7 @@ public class GenerationNode { public void run() { XmlTag tag1 = hasChildren ? expandEmptyTagIfNeccessary(tag) : tag; setAttributeValues(tag1, attr2value, numberInIteration); + token.setFile((XmlFile)tag1.getContainingFile()); } }); } @@ -272,7 +273,6 @@ public class GenerationNode { if (flag) { builder.append(">'); final XmlTag tag1 = XmlElementFactory.getInstance(tag.getProject()).createTagFromText(builder.toString(), XMLLanguage.INSTANCE); - tag.replace(tag1); return tag1; } return tag; From 5d6cd6a5058421446fb4e6338b36e68d193ba81a Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Fri, 16 Jul 2010 00:14:13 +0400 Subject: [PATCH 06/79] Fix: IDEA-56186 (Show the suggestion list in Run Grails target pop-up window without waiting for Ctrl+Space) --- .../ui/TextFieldWithAutoCompletion.java | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ui/TextFieldWithAutoCompletion.java b/platform/lang-impl/src/com/intellij/ui/TextFieldWithAutoCompletion.java index f4ce4668a557..df4c6a5403c2 100644 --- a/platform/lang-impl/src/com/intellij/ui/TextFieldWithAutoCompletion.java +++ b/platform/lang-impl/src/com/intellij/ui/TextFieldWithAutoCompletion.java @@ -97,25 +97,30 @@ public class TextFieldWithAutoCompletion extends EditorTextField { } public void actionPerformed(final AnActionEvent e) { - final Editor editor = getEditor(); - assert editor != null; - - editor.getSelectionModel().removeSelection(); - final String lookupPrefix = getCurrentLookupPrefix(getCurrentTextPrefix()); - final LookupImpl lookup = - (LookupImpl)LookupManager.getInstance(getProject()).createLookup(editor, - calcLookupItems(lookupPrefix), - lookupPrefix != null ? lookupPrefix : "", - LookupArranger.DEFAULT); - final String advertisementText = getAdvertisementText(); - if (!StringUtil.isEmpty(advertisementText)) { - lookup.setAdvertisementText(advertisementText); - lookup.refreshUi(); - } - lookup.show(); + showLookup(); } } + public void showLookup() { + if (LookupManager.getInstance(getProject()).getActiveLookup() != null) return; + final Editor editor = getEditor(); + assert editor != null; + + editor.getSelectionModel().removeSelection(); + final String lookupPrefix = getCurrentLookupPrefix(getCurrentTextPrefix()); + final LookupImpl lookup = + (LookupImpl)LookupManager.getInstance(getProject()).createLookup(editor, + calcLookupItems(lookupPrefix), + lookupPrefix != null ? lookupPrefix : "", + LookupArranger.DEFAULT); + final String advertisementText = getAdvertisementText(); + if (!StringUtil.isEmpty(advertisementText)) { + lookup.setAdvertisementText(advertisementText); + lookup.refreshUi(); + } + lookup.show(); + } + public void setAdvertisementText(@Nullable String text) { myAdText = text; } From edef28b37bdd761b549d5874a45d25eb30e5b4c6 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Sun, 18 Jul 2010 20:45:47 +0400 Subject: [PATCH 07/79] project icons fixed once again --- .../intellij/ide/actions/OpenProjectFileChooserDescriptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ide/actions/OpenProjectFileChooserDescriptor.java b/platform/platform-impl/src/com/intellij/ide/actions/OpenProjectFileChooserDescriptor.java index 60cdc3f185c3..68fbd4500600 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/OpenProjectFileChooserDescriptor.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/OpenProjectFileChooserDescriptor.java @@ -60,7 +60,7 @@ public class OpenProjectFileChooserDescriptor extends FileChooserDescriptor { public static Icon getImporterIcon(final VirtualFile virtualFile, final boolean open) { final ProjectOpenProcessor provider = ProjectOpenProcessor.getImportProvider(virtualFile); if(provider!=null) { - return virtualFile.isDirectory() ? ourProjectIcon : provider.getIcon(); + return virtualFile.isDirectory() && provider.lookForProjectsInDirectory() ? ourProjectIcon : provider.getIcon(); } return null; } From 11e54329c790f81fd71053fe5bd069fba81079f7 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Mon, 19 Jul 2010 13:17:37 +0400 Subject: [PATCH 08/79] write exceptions to log instead of printing to console --- .../references/PrefixReferenceProvider.java | 5 ++- .../relaxNG/validation/MessageViewHelper.java | 31 ++++++++++--------- .../plugins/relaxNG/validation/RngParser.java | 12 ++++--- .../validation/XmlInstanceValidator.java | 8 +++-- .../plugins/relaxNG/HighlightingTestBase.java | 2 +- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/references/PrefixReferenceProvider.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/references/PrefixReferenceProvider.java index ee5354b8515f..6252728de819 100644 --- a/plugins/relaxng/src/org/intellij/plugins/relaxNG/references/PrefixReferenceProvider.java +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/references/PrefixReferenceProvider.java @@ -22,6 +22,7 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.analysis.CreateNSDeclarationIntentionFix; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; import com.intellij.lang.xml.XMLLanguage; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; @@ -44,6 +45,8 @@ import org.jetbrains.annotations.Nullable; * Date: 24.07.2007 */ public class PrefixReferenceProvider extends PsiReferenceProviderBase { + private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.references.PrefixReferenceProvider"); + @NotNull public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { final XmlAttributeValue value = (XmlAttributeValue)element; @@ -102,7 +105,7 @@ public class PrefixReferenceProvider extends PsiReferenceProviderBase { QuickFixAction.registerQuickFixAction(info, new CreateNSDeclarationIntentionFix(tag, reference.getCanonicalText())); } catch (Throwable e) { - e.printStackTrace(); + LOG.error(e); } } diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java index a0af4a70dd45..a2baae294ffc 100644 --- a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java @@ -17,7 +17,9 @@ package org.intellij.plugins.relaxNG.validation; import com.intellij.ide.errorTreeView.NewErrorTreeViewPanel; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Key; @@ -33,7 +35,6 @@ import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; -import javax.swing.*; import java.net.MalformedURLException; import java.net.URL; import java.util.Set; @@ -44,6 +45,8 @@ import java.util.Set; * Date: 19.11.2007 */ public class MessageViewHelper { + private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.validation.MessageViewHelper"); + private final Project myProject; private final Set myErrors = new THashSet(); @@ -91,23 +94,23 @@ public class MessageViewHelper { try { file = VfsUtil.findFileByURL(new URL(systemId)); } catch (MalformedURLException e) { - System.err.println("systemId = " + systemId); - e.printStackTrace(); + LOG.warn("systemId = " + systemId); + LOG.error(e); } } final VirtualFile file1 = file; - SwingUtilities.invokeLater( - new Runnable() { - public void run() { - myErrorsView.addMessage( - warning ? MessageCategory.WARNING : MessageCategory.ERROR, - new String[]{ ex.getLocalizedMessage() }, - file1, - ex.getLineNumber() - 1, - ex.getColumnNumber() - 1, null); - } - } + ApplicationManager.getApplication().invokeLater( + new Runnable() { + public void run() { + myErrorsView.addMessage( + warning ? MessageCategory.WARNING : MessageCategory.ERROR, + new String[]{ex.getLocalizedMessage()}, + file1, + ex.getLineNumber() - 1, + ex.getColumnNumber() - 1, null); + } + } ); } diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java index 2e41399879ca..232938704cd1 100644 --- a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java @@ -16,6 +16,7 @@ package org.intellij.plugins.relaxNG.validation; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.SystemInfo; @@ -62,12 +63,15 @@ import java.io.StringReader; * Date: 19.07.2007 */ public class RngParser { + private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.validation.RngParser"); + static final Key> SCHEMA_KEY = Key.create("SCHEMA"); static final Key> PATTERN_KEY = Key.create("PATTERN"); public static final DefaultHandler DEFAULT_HANDLER = new DefaultHandler() { public void error(SAXParseException e) throws SAXException { - System.out.println("e.getMessage() = " + e.getMessage() + " [" + e.getSystemId() + "]"); + LOG.info("e.getMessage() = " + e.getMessage() + " [" + e.getSystemId() + "]"); + LOG.info(e); } }; @@ -90,9 +94,9 @@ public class RngParser { return (DPattern)p.parse(checking ? new CheckingSchemaBuilder(sb, eh) : sb); } catch (BuildException e) { - e.printStackTrace(); + LOG.info(e); } catch (IllegalSchemaException e) { - System.out.println("invalid schema: " + file.getVirtualFile().getPresentableUrl()); + LOG.info("invalid schema: " + file.getVirtualFile().getPresentableUrl()); } return null; } @@ -166,7 +170,7 @@ public class RngParser { return Result.createSingleDependency(schema, descriptorFile); } } catch (Exception e) { - e.printStackTrace(); + LOG.info(e); return Result.createSingleDependency(null, descriptorFile); } } diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/XmlInstanceValidator.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/XmlInstanceValidator.java index 2956996170f3..02a835452697 100644 --- a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/XmlInstanceValidator.java +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/XmlInstanceValidator.java @@ -17,6 +17,7 @@ package org.intellij.plugins.relaxNG.validation; import com.intellij.codeInsight.daemon.Validator; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.psi.PsiDocumentManager; @@ -40,6 +41,7 @@ import org.xml.sax.SAXParseException; * Date: 30.07.2007 */ public class XmlInstanceValidator { + private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.validation.MessageViewHelper"); public static void doValidation(@NotNull final XmlDocument doc, final Validator.ValidationHost host, final XmlFile descriptorFile) { try { @@ -61,9 +63,11 @@ public class XmlInstanceValidator { doc.accept(new Psi2SaxAdapter(handler)); } catch (ProcessCanceledException e) { - throw e; + LOG.error(e); + } catch (RuntimeException e) { + LOG.error(e); } catch (Exception e) { - e.printStackTrace(); + LOG.info(e); } } diff --git a/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java b/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java index a25cff996b95..08dc74d42a96 100644 --- a/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java +++ b/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java @@ -85,7 +85,7 @@ public abstract class HighlightingTestBase extends TestCase implements IdeaCodeI } }); } catch (IOException e) { - e.printStackTrace(); + throw new RuntimeException(e); } } From dccb1f8f664ac81e104e9b5e358c16cbf6090bb0 Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Mon, 19 Jul 2010 13:19:02 +0400 Subject: [PATCH 09/79] idea config cleanup --- java/compiler/impl/compiler-impl.iml | 2 -- .../intellij/roots/libraries/LibraryTest.java | 2 +- .../roots/impl/libraries/LibraryImpl.java | 2 +- plugins/cvs/cvs-core/cvs-core.iml | 1 - plugins/git4idea/git4idea.iml | 1 - plugins/groovy/jetgroovy.iml | 2 -- plugins/maven/facade-api/maven-facade-api.iml | 2 -- .../maven/facade-impl/maven-facade-impl.iml | 28 ------------------- plugins/relaxng/relaxng.iml | 7 ----- plugins/svn4idea/svn4idea-tests.iml | 3 -- plugins/svn4idea/svn4idea.iml | 5 ---- 11 files changed, 2 insertions(+), 53 deletions(-) diff --git a/java/compiler/impl/compiler-impl.iml b/java/compiler/impl/compiler-impl.iml index 4f7473c9ff2a..381f3496886b 100644 --- a/java/compiler/impl/compiler-impl.iml +++ b/java/compiler/impl/compiler-impl.iml @@ -23,8 +23,6 @@ - - diff --git a/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java b/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java index a9578c24654e..b1bbd7a29e74 100644 --- a/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java +++ b/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java @@ -47,7 +47,7 @@ public class LibraryTest extends IdeaTestCase { final Element element = new Element("root"); library.writeExternal(element); - assertEquals("", + assertEquals("", new XMLOutputter().outputString(element)); ApplicationManager.getApplication().runWriteAction(new Runnable() { diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java index 091ccf348d86..762e7b6bd738 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java @@ -277,7 +277,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { if (roots.size() == 0 && rootType.skipWriteIfEmpty()) continue; //compatibility iml/ipr final Element rootTypeElement = new Element(rootType.name()); roots.writeExternal(rootTypeElement, ROOT_PATH_ELEMENT); - element.addContent(rootTypeElement); + if (rootTypeElement.getAttributes().size() > 0 || rootTypeElement.getContent().size() > 0) element.addContent(rootTypeElement); } List urls = new ArrayList(myJarDirectories.keySet()); Collections.sort(urls, new Comparator() { diff --git a/plugins/cvs/cvs-core/cvs-core.iml b/plugins/cvs/cvs-core/cvs-core.iml index 53189febbd11..f170b4099106 100644 --- a/plugins/cvs/cvs-core/cvs-core.iml +++ b/plugins/cvs/cvs-core/cvs-core.iml @@ -15,7 +15,6 @@ - diff --git a/plugins/git4idea/git4idea.iml b/plugins/git4idea/git4idea.iml index aa21265058b8..5fa1b17970c1 100644 --- a/plugins/git4idea/git4idea.iml +++ b/plugins/git4idea/git4idea.iml @@ -16,7 +16,6 @@ - diff --git a/plugins/groovy/jetgroovy.iml b/plugins/groovy/jetgroovy.iml index 3b210de157c4..3ead47ab4a1e 100644 --- a/plugins/groovy/jetgroovy.iml +++ b/plugins/groovy/jetgroovy.iml @@ -26,8 +26,6 @@ - - diff --git a/plugins/maven/facade-api/maven-facade-api.iml b/plugins/maven/facade-api/maven-facade-api.iml index 8ba63b8dc7db..56173f227d95 100644 --- a/plugins/maven/facade-api/maven-facade-api.iml +++ b/plugins/maven/facade-api/maven-facade-api.iml @@ -14,8 +14,6 @@ - - diff --git a/plugins/maven/facade-impl/maven-facade-impl.iml b/plugins/maven/facade-impl/maven-facade-impl.iml index 9240cd8ba91c..ae61f67a346f 100644 --- a/plugins/maven/facade-impl/maven-facade-impl.iml +++ b/plugins/maven/facade-impl/maven-facade-impl.iml @@ -16,8 +16,6 @@ - - @@ -25,8 +23,6 @@ - - @@ -34,8 +30,6 @@ - - @@ -43,8 +37,6 @@ - - @@ -52,8 +44,6 @@ - - @@ -61,8 +51,6 @@ - - @@ -70,8 +58,6 @@ - - @@ -79,8 +65,6 @@ - - @@ -88,8 +72,6 @@ - - @@ -97,8 +79,6 @@ - - @@ -106,8 +86,6 @@ - - @@ -115,8 +93,6 @@ - - @@ -124,8 +100,6 @@ - - @@ -133,8 +107,6 @@ - - diff --git a/plugins/relaxng/relaxng.iml b/plugins/relaxng/relaxng.iml index d7d35d40c904..6ff34b95fc39 100644 --- a/plugins/relaxng/relaxng.iml +++ b/plugins/relaxng/relaxng.iml @@ -18,7 +18,6 @@ - @@ -29,8 +28,6 @@ - - @@ -38,8 +35,6 @@ - - @@ -47,8 +42,6 @@ - - diff --git a/plugins/svn4idea/svn4idea-tests.iml b/plugins/svn4idea/svn4idea-tests.iml index 798757278775..5039b6b4a9f5 100644 --- a/plugins/svn4idea/svn4idea-tests.iml +++ b/plugins/svn4idea/svn4idea-tests.iml @@ -16,7 +16,6 @@ - @@ -30,8 +29,6 @@ - - diff --git a/plugins/svn4idea/svn4idea.iml b/plugins/svn4idea/svn4idea.iml index fd765b400568..e00b72d68d9c 100644 --- a/plugins/svn4idea/svn4idea.iml +++ b/plugins/svn4idea/svn4idea.iml @@ -22,7 +22,6 @@ - @@ -33,8 +32,6 @@ - - @@ -43,8 +40,6 @@ - - From db740a2bb8d209809a1cbeb443cceb26b82ac53d Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Mon, 19 Jul 2010 13:54:18 +0400 Subject: [PATCH 10/79] assertion message --- .../intellij/codeInsight/template/impl/TemplateState.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java index 720fb1d6a01d..10aaab15bc90 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java @@ -70,6 +70,7 @@ public class TemplateState implements Disposable { private Editor myEditor; private TemplateImpl myTemplate; + private TemplateImpl myPrevTemplate; private TemplateSegments mySegments = null; private Map myPredefinedVariableValues; @@ -219,6 +220,7 @@ public class TemplateState implements Disposable { mySegments = null; } myTemplateRange = null; + myPrevTemplate = myTemplate; myTemplate = null; releaseEditor(); myTabStopHighlighters.clear(); @@ -271,6 +273,7 @@ public class TemplateState implements Disposable { myTemplateIndented = false; myCurrentVariableNumber = -1; mySegments = new TemplateSegments(myEditor); + myPrevTemplate = myTemplate; myTemplate = template; //myArgument = argument; myPredefinedVariableValues = predefinedVarValues; @@ -378,7 +381,7 @@ public class TemplateState implements Disposable { private void afterChangedUpdate() { if (isFinished()) return; - LOG.assertTrue(myTemplate != null); + LOG.assertTrue(myTemplate != null, myPrevTemplate != null ? myPrevTemplate.getKey() : "prev template is null"); if (myDocumentChanged) { if (myDocumentChangesTerminateTemplate || mySegments.isInvalid()) { final int oldIndex = myCurrentVariableNumber; From 4eebed92f87ff5319fd0a5e4d5c8feb30fcc98b6 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 19 Jul 2010 14:08:40 +0400 Subject: [PATCH 11/79] don't show file path twice in platform goto file dialog --- .../util/PlatformModuleRendererFactory.java | 58 ++++++++++--------- .../util/gotoByName/GotoFileCellRenderer.java | 12 ++++ 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/PlatformModuleRendererFactory.java b/platform/lang-impl/src/com/intellij/ide/util/PlatformModuleRendererFactory.java index 06c1483059e0..c66fe2146a6a 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/PlatformModuleRendererFactory.java +++ b/platform/lang-impl/src/com/intellij/ide/util/PlatformModuleRendererFactory.java @@ -28,38 +28,40 @@ import java.awt.*; */ public class PlatformModuleRendererFactory extends ModuleRendererFactory { public DefaultListCellRenderer getModuleRenderer() { - return new DefaultListCellRenderer() { - public Component getListCellRendererComponent(final JList list, - final Object value, - final int index, - final boolean isSelected, - final boolean cellHasFocus) { - final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - String text = ""; - if (value instanceof NavigationItem) { - final ItemPresentation presentation = ((NavigationItem)value).getPresentation(); - if (presentation != null) { - String containerText = presentation.getLocationString(); - if (containerText != null && containerText.length() > 0) { - text = " " + containerText; - } - } - } - - - setText(text); - setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); - setHorizontalTextPosition(SwingConstants.LEFT); - setBackground(isSelected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground()); - setForeground(isSelected ? UIUtil.getListSelectionForeground() : UIUtil.getInactiveTextColor()); - return component; - } - }; + return new PlatformModuleRenderer(); } @Override public boolean rendersLocationString() { return true; } + + public static class PlatformModuleRenderer extends DefaultListCellRenderer { + public Component getListCellRendererComponent(final JList list, + final Object value, + final int index, + final boolean isSelected, + final boolean cellHasFocus) { + final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + String text = ""; + if (value instanceof NavigationItem) { + final ItemPresentation presentation = ((NavigationItem)value).getPresentation(); + if (presentation != null) { + String containerText = presentation.getLocationString(); + if (containerText != null && containerText.length() > 0) { + text = " " + containerText; + } + } + } + + + setText(text); + setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); + setHorizontalTextPosition(SwingConstants.LEFT); + setBackground(isSelected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground()); + setForeground(isSelected ? UIUtil.getListSelectionForeground() : UIUtil.getInactiveTextColor()); + return component; + } + } } diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java index 5a9a5ca63995..f8f1e5de4b4b 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java @@ -16,6 +16,7 @@ package com.intellij.ide.util.gotoByName; +import com.intellij.ide.util.PlatformModuleRendererFactory; import com.intellij.ide.util.PsiElementListCellRenderer; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; @@ -26,6 +27,7 @@ import com.intellij.psi.PsiFile; import com.intellij.util.ui.FilePathSplittingPolicy; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.awt.*; import java.io.File; @@ -72,6 +74,16 @@ public class GotoFileCellRenderer extends PsiElementListCellRenderer{ return url; } + @Override + protected DefaultListCellRenderer getRightCellRenderer() { + final DefaultListCellRenderer rightRenderer = super.getRightCellRenderer(); + if (rightRenderer instanceof PlatformModuleRendererFactory.PlatformModuleRenderer) { + // that renderer will display file path, but we're showing it ourselves - no need to show twice + return null; + } + return rightRenderer; + } + protected int getIconFlags() { return 0; } From 53692d65e884c382dd3638f1f7a4a5fc51bc7ce0 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Mon, 19 Jul 2010 14:20:47 +0400 Subject: [PATCH 12/79] upper space for tabs added --- .../intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java index 16811705de04..87ca0bd74f94 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java @@ -70,6 +70,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import javax.swing.border.EmptyBorder; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -132,6 +133,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec synchronized (myInitLock) { if (myPanels == null) { myPanels = new JPanel(new BorderLayout()); + myPanels.setBorder(new EmptyBorder(1, 0, 0, 0)); mySplitters = new EditorsSplitters(this); myPanels.add(mySplitters, BorderLayout.CENTER); } From 2153bfcb7817b0c41855a72681ca6e285057722a Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Mon, 19 Jul 2010 14:38:10 +0400 Subject: [PATCH 13/79] fix double slide project view on project open --- .../src/com/intellij/platform/PlatformProjectViewOpener.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewOpener.java b/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewOpener.java index a605677e93a7..16a574ef9f67 100644 --- a/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewOpener.java +++ b/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewOpener.java @@ -25,6 +25,7 @@ import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.openapi.wm.ToolWindowId; +import com.intellij.openapi.wm.ToolWindowType; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -43,7 +44,7 @@ public class PlatformProjectViewOpener implements DirectoryProjectConfigurator { public void run() { if (project.isDisposed()) return; final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.PROJECT_VIEW); - if (toolWindow != null) { + if (toolWindow != null && toolWindow.getType() != ToolWindowType.SLIDING) { toolWindow.activate(null); } } From 0aecb5f4b48bc67afaaa1569ad8badf9045d340f Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Mon, 19 Jul 2010 15:03:27 +0400 Subject: [PATCH 14/79] IDEA-56168: duplicate id reference inspection marks good code as error --- .../intellij/xml/util/XmlRefCountHolder.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java b/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java index 2d4f79eff89d..58c1ead70368 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java +++ b/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java @@ -17,6 +17,7 @@ package com.intellij.xml.util; import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor; import com.intellij.lang.Language; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.UserDataCache; @@ -30,6 +31,7 @@ import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.*; +import com.intellij.util.containers.ContainerUtil; import com.intellij.xml.XmlAttributeDescriptor; import com.intellij.xml.XmlElementDescriptor; import org.jetbrains.annotations.NotNull; @@ -97,14 +99,17 @@ public class XmlRefCountHolder { if (list == null) { list = new ArrayList>(); myId2AttributeListMap.put(id, list); - } else if (!soft) { + } + else if (!soft) { // mark as duplicate - if (list.size() == 1) { - if (!list.get(0).second.booleanValue()) { - myPossiblyDuplicateIds.add(list.get(0).first); - myPossiblyDuplicateIds.add(attributeValue); + Pair notSoft = ContainerUtil.find(list, new Condition>() { + @Override + public boolean value(Pair xmlAttributeValueBooleanPair) { + return !xmlAttributeValueBooleanPair.second; } - } else { + }); + if (notSoft != null) { + myPossiblyDuplicateIds.add(notSoft.first); myPossiblyDuplicateIds.add(attributeValue); } } From 3ed1cab4f5075390ae4822bd639af174989de087 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Mon, 19 Jul 2010 15:23:25 +0400 Subject: [PATCH 15/79] navbar upper border fixed --- .../ide/navigationToolbar/NavBarPanel.java | 21 +++++++++++++++---- .../NavBarRootPaneExtension.java | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java index 7414c7558ee9..b0dc4e89699c 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java @@ -23,6 +23,7 @@ import com.intellij.ide.IdeView; import com.intellij.ide.projectView.ProjectView; import com.intellij.ide.projectView.impl.AbstractProjectViewPane; import com.intellij.ide.projectView.impl.ProjectRootsUtil; +import com.intellij.ide.ui.UISettings; import com.intellij.ide.ui.customization.CustomActionsSchema; import com.intellij.ide.util.DeleteHandler; import com.intellij.ide.util.DirectoryChooserUtil; @@ -190,7 +191,7 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup } }); - installBorder(-1); + installBorder(-1, false); myCopyPasteDelegator = new CopyPasteDelegator(myProject, NavBarPanel.this) { @NotNull @@ -758,14 +759,26 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup myModelUpdateAlarm.cancelAllRequests(); } - public void installBorder(final int rightOffset) { + public void installBorder(final int rightOffset, final boolean isDocked) { setBorder(new Border() { public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) { g.setColor(c.getBackground() != null ? c.getBackground().darker() : Color.darkGray); + + boolean drawTopBorder = true; + if (isDocked) { + if (!UISettings.getInstance().SHOW_MAIN_TOOLBAR) { + drawTopBorder = false; + } + } + if (rightOffset == -1) { - g.drawLine(0, 0, width - 1, 0); + if (drawTopBorder) { + g.drawLine(0, 0, width - 1, 0); + } } else { - g.drawLine(0, 0, width - rightOffset + 3, 0); + if (drawTopBorder) { + g.drawLine(0, 0, width - rightOffset + 3, 0); + } } g.drawLine(0, height - 1 , width, height - 1); diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java index 9d4b1ddbce10..f9ca00a2875a 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java @@ -70,7 +70,7 @@ public class NavBarRootPaneExtension extends IdeRootPaneNorthExtension { myPanel.add(closeLabel, BorderLayout.EAST); myPanel.putClientProperty("NavBarPanel", myNavigationBar); - myNavigationBar.installBorder(0); + myNavigationBar.installBorder(0, true); myPanel.setBorder(myNavigationBar.getBorder()); myNavigationBar.setBorder(null); } From 74db3f0a17c629a0755e38586f24eb66b028aafb Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Mon, 19 Jul 2010 15:54:26 +0400 Subject: [PATCH 16/79] choose be name renderer background fix --- .../com/intellij/ide/util/NavigationItemListCellRenderer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/NavigationItemListCellRenderer.java b/platform/lang-impl/src/com/intellij/ide/util/NavigationItemListCellRenderer.java index cdbf6f125a2a..1c48d7361168 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/NavigationItemListCellRenderer.java +++ b/platform/lang-impl/src/com/intellij/ide/util/NavigationItemListCellRenderer.java @@ -67,13 +67,14 @@ public class NavigationItemListCellRenderer extends OpaquePanel implements ListC final Color listBg = leftCellRendererComponent.getBackground(); add(leftCellRendererComponent, BorderLayout.WEST); - setBackground(isSelected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground()); + setBackground(isSelected ? UIUtil.getListSelectionBackground() : listBg); if (hasRightRenderer){ final DefaultListCellRenderer moduleRenderer = factory.getModuleRenderer(); final Component rightCellRendererComponent = moduleRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + ((JComponent)rightCellRendererComponent).setOpaque(false); rightCellRendererComponent.setBackground(listBg); add(rightCellRendererComponent, BorderLayout.EAST); final JPanel spacer = new NonOpaquePanel(); From 050c064f0196ffca454a942943fb37d88ed2e94d Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Fri, 16 Jul 2010 17:35:17 +0400 Subject: [PATCH 17/79] CIDR-debugger: escaping program parameters --- .../execution/runners/ExecutionUtil.java | 17 ++++++++++++----- .../com/intellij/xdebugger/XDebugSession.java | 2 ++ .../xdebugger/impl/XDebugSessionImpl.java | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java b/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java index 428ee23b2e46..1ace770954c4 100644 --- a/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java +++ b/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java @@ -28,6 +28,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.wm.ToolWindowId; import com.intellij.openapi.wm.ToolWindowManager; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import javax.swing.event.HyperlinkEvent; @@ -47,16 +48,16 @@ public class ExecutionUtil { } public static void handleExecutionError(@NotNull final Project project, - @NotNull String toolWindowId, + @NotNull final String toolWindowId, @NotNull String taskName, @NotNull ExecutionException e) { if (e instanceof RunCanceledByUserException) return; + LOG.debug(e); + String error = e.getMessage(); HyperlinkListener listener = null; - LOG.debug(error); - if (error.contains("87") && e instanceof ProcessNotCreatedException) { final String commandLineString = ((ProcessNotCreatedException)e).getCommandLine().getCommandLineString(); if (commandLineString.length() > 1024 * 32) { @@ -72,12 +73,18 @@ public class ExecutionUtil { }; } } - String message = ExecutionBundle.message("error.running.configuration.with.error.error.message", taskName, error); + final String message = ExecutionBundle.message("error.running.configuration.with.error.error.message", taskName, error); if (ApplicationManager.getApplication().isUnitTestMode()) { LOG.error(message); } - ToolWindowManager.getInstance(project).notifyByBalloon(toolWindowId, MessageType.ERROR, message, null, listener); + final HyperlinkListener finalListener = listener; + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + ToolWindowManager.getInstance(project).notifyByBalloon(toolWindowId, MessageType.ERROR, message, null, finalListener); + } + }); } } diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java index 4a24013a7074..f924a5fb70a4 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java @@ -16,6 +16,7 @@ package com.intellij.xdebugger; +import com.intellij.execution.ExecutionException; import com.intellij.execution.ui.RunContentDescriptor; import com.intellij.execution.configurations.RunProfile; import com.intellij.openapi.project.Project; @@ -113,6 +114,7 @@ public interface XDebugSession extends AbstractDebuggerSession { void addSessionListener(@NotNull XDebugSessionListener listener); void removeSessionListener(@NotNull XDebugSessionListener listener); + void reportError(String message); @NotNull String getSessionName(); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java index 2384d409f96d..b2ebacdc00b9 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java @@ -20,6 +20,7 @@ import com.intellij.execution.filters.HyperlinkInfo; import com.intellij.execution.filters.OpenFileHyperlinkInfo; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.runners.ExecutionEnvironment; +import com.intellij.execution.runners.ExecutionUtil; import com.intellij.execution.runners.ProgramRunner; import com.intellij.execution.ui.ConsoleView; import com.intellij.execution.ui.ConsoleViewContentType; @@ -28,8 +29,11 @@ import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.application.Result; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.wm.ToolWindowId; +import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.util.EventDispatcher; import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.*; @@ -536,6 +540,16 @@ public class XDebugSessionImpl implements XDebugSession { } } + @Override + public void reportError(final String message) { + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.DEBUG, MessageType.ERROR, message, null, null); + } + }); + } + private class MyBreakpointListener implements XBreakpointListener> { public void breakpointAdded(@NotNull final XBreakpoint breakpoint) { if (!myBreakpointsDisabled) { From 09ea5721735e377ea4ed5e0346c9f2ab7b98fb3e Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 19 Jul 2010 14:28:39 +0400 Subject: [PATCH 18/79] CIDR-debugger: spaces in file paths --- .../src/com/intellij/util/concurrency/QueueProcessor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java b/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java index 39c936efa3da..d34b068305f9 100644 --- a/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java +++ b/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java @@ -85,7 +85,7 @@ public class QueueProcessor { myProcessor.consume(next); } catch (Exception e) { - LOG.error(e); + LOG.warn(e); } synchronized (myQueue) { From 183d248e7d857f3670cfe01a2b88278b7d8fb0d0 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 19 Jul 2010 16:42:17 +0400 Subject: [PATCH 19/79] CIDR-debugger: spaces in file paths --- .../src/com/intellij/openapi/vfs/VfsUtil.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java index 313073589174..8ed063a63bbf 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java @@ -646,6 +646,17 @@ public class VfsUtil { return result; } + public static VirtualFile createDirectoryIfMissing(VirtualFile parent, String relativePath) throws IOException { + for (String each : StringUtil.split(relativePath, "/")) { + VirtualFile child = parent.findChild(each); + if (child == null) { + child = parent.createChildDirectory(LocalFileSystem.getInstance(), each); + } + parent = child; + } + return parent; + } + @Nullable public static VirtualFile createDirectoryIfMissing(@NotNull String dir) throws IOException { return doCreateDirectoriesIfMissing(FileUtil.toSystemIndependentName(dir)); From 232cc277268f16c0091c42ed4e18f5830bafbf8d Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 16 Jul 2010 19:25:20 +0400 Subject: [PATCH 20/79] type inference: super bounds promotion corrected (IDEA-55718) --- .../source/resolve/PsiResolveHelperImpl.java | 3 +++ .../InferenceWithSuperBounds.java | 16 ++++++++++++++++ .../daemon/GenericsHighlightingTest.java | 1 + 3 files changed, 20 insertions(+) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithSuperBounds.java diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java index 67abae3ba884..a674ea013098 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java @@ -185,6 +185,9 @@ public class PsiResolveHelperImpl implements PsiResolveHelper { if (wildcardToCapture != null) { if (lowerBound != PsiType.NULL) { if (!wildcardToCapture.isAssignableFrom(lowerBound)) return getFailedInferenceConstraint(typeParameter); + if (wildcardToCapture.isSuper()) { + return new Pair(wildcardToCapture, ConstraintType.SUPERTYPE); + } lowerBound = GenericsUtil.getLeastUpperBound(lowerBound, wildcardToCapture, typeParameter.getManager()); } else { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithSuperBounds.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithSuperBounds.java new file mode 100644 index 000000000000..d68f90786e9b --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithSuperBounds.java @@ -0,0 +1,16 @@ +public class ExampleProblem { + void asserting(T t, Simple l){ + } + + Simple comp(K k){ + return null; + } + + public void main(String[] args) { + asserting(0, comp(0)); + } +} + +class Simple{ + +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index d6b425be2701..a68ee6bf6d3f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -49,6 +49,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testExplicitMethodParameters() throws Exception { doTest(false); } public void testExplicitMethodParameters1() throws Exception { doTest(false); } public void testInferenceWithBounds() throws Exception {doTest(false);} + public void testInferenceWithSuperBounds() throws Exception {doTest(false);} public void testVariance() throws Exception {doTest(false);} public void testForeachTypes() throws Exception {doTest(false);} public void testRawOverridingMethods() throws Exception {doTest(false);} From b126136e73c2702c69847fdd943ec3f7e2b96f83 Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 16 Jul 2010 21:10:36 +0400 Subject: [PATCH 21/79] pull up conflicts: method2abstract used private method moved to superclass (IDEA-56133) --- .../memberPullUp/PullUpConflictsUtil.java | 29 +++++++++++++++++-- .../after/Test.java | 5 ++++ .../after/TestSubclass.java | 7 +++++ .../before/Test.java | 7 +++++ .../refactoring/ExtractSuperClassTest.java | 7 +++++ 5 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/Test.java create mode 100644 java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/TestSubclass.java create mode 100644 java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/before/Test.java diff --git a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpConflictsUtil.java b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpConflictsUtil.java index 59df4a4a9f39..d63f2e25d988 100644 --- a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpConflictsUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpConflictsUtil.java @@ -63,9 +63,9 @@ public class PullUpConflictsUtil { } public static MultiMap checkConflicts(final MemberInfo[] infos, - PsiClass subclass, + final PsiClass subclass, @Nullable PsiClass superClass, - PsiPackage targetPackage, + final PsiPackage targetPackage, PsiDirectory targetDirectory, final InterfaceContainmentVerifier interfaceContainmentVerifier, boolean movedMembers2Super) { @@ -143,6 +143,31 @@ public class PullUpConflictsUtil { } RefactoringConflictsUtil.analyzeModuleConflicts(subclass.getProject(), checkModuleConflictsList, new UsageInfo[0], targetRepresentativeElement, conflicts); + for (final PsiMethod abstractMethod : abstractMethods) { + abstractMethod.accept(new ClassMemberReferencesVisitor(subclass) { + @Override + protected void visitClassMemberReferenceElement(PsiMember classMember, PsiJavaCodeReferenceElement classMemberReference) { + if (classMember != null && willBeMoved(classMember, movedMembers)) { + boolean isAccessible = false; + if (classMember.hasModifierProperty(PsiModifier.PRIVATE)) { + isAccessible = true; + } + else if (classMember.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) && + !Comparing.strEqual(targetPackage.getQualifiedName(), StringUtil.getPackageName(subclass.getQualifiedName()))) { + isAccessible = true; + } + if (isAccessible) { + String message = RefactoringUIUtil.getDescription(abstractMethod, false) + + " uses " + + RefactoringUIUtil.getDescription(classMember, true) + + " which won't be accessible from the subclass."; + message = CommonRefactoringUtil.capitalize(message); + conflicts.putValue(classMember, message); + } + } + } + }); + } return conflicts; } diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/Test.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/Test.java new file mode 100644 index 000000000000..c19d63941b3b --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/Test.java @@ -0,0 +1,5 @@ +public abstract class Test { + abstract void x(); + + private void xx(){} +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/TestSubclass.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/TestSubclass.java new file mode 100644 index 000000000000..54bd69ab2a95 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/TestSubclass.java @@ -0,0 +1,7 @@ +public class TestSubclass extends Test { + @java.lang.Override + void x() { + xx(); + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/before/Test.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/before/Test.java new file mode 100644 index 000000000000..0196b2c91f82 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/before/Test.java @@ -0,0 +1,7 @@ +public class Test { + void x() { + xx(); + } + + private void xx(){} +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java index b49809edf0af..c780618504d5 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java @@ -47,6 +47,13 @@ public class ExtractSuperClassTest extends CodeInsightTestCase { new RefactoringTestUtil.MemberDescriptor("x", PsiMethod.class)); } + public void testConflictMoveAbstractWithPrivateMethod() throws Exception { + doTest("Test", "TestSubclass", + new String[] {"Method x() uses method Test.xx() which won't be accessible from the subclass."}, + new RefactoringTestUtil.MemberDescriptor("x", PsiMethod.class, true), + new RefactoringTestUtil.MemberDescriptor("xx", PsiMethod.class)); + } + public void testConflictUsingPackageLocalMethod() throws Exception { doTest("a.Test", "TestSubclass", new String[] {"method Sup.foo() won't be accessible"}, From 69ff6e7b27ebe78e047b3d053de4cf6731bc7a00 Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 16 Jul 2010 21:36:48 +0400 Subject: [PATCH 22/79] pull up conflicts: forbid to make package local method abstract (IDEA-56130) --- .../refactoring/memberPullUp/PullUpConflictsUtil.java | 10 +++++++++- .../after/a/Test.java | 5 +++++ .../conflictAbstractPackageLocalMethod/after/b/E.java | 2 ++ .../after/b/TestSubclass.java | 8 ++++++++ .../before/a/Test.java | 5 +++++ .../conflictAbstractPackageLocalMethod/before/b/E.java | 2 ++ .../intellij/refactoring/ExtractSuperClassTest.java | 7 +++++++ 7 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/a/Test.java create mode 100644 java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/E.java create mode 100644 java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/TestSubclass.java create mode 100644 java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/a/Test.java create mode 100644 java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/b/E.java diff --git a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpConflictsUtil.java b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpConflictsUtil.java index d63f2e25d988..fd26092d74cb 100644 --- a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpConflictsUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpConflictsUtil.java @@ -144,6 +144,8 @@ public class PullUpConflictsUtil { RefactoringConflictsUtil.analyzeModuleConflicts(subclass.getProject(), checkModuleConflictsList, new UsageInfo[0], targetRepresentativeElement, conflicts); for (final PsiMethod abstractMethod : abstractMethods) { + final boolean toDifferentPackage = + !Comparing.strEqual(targetPackage.getQualifiedName(), StringUtil.getPackageName(subclass.getQualifiedName())); abstractMethod.accept(new ClassMemberReferencesVisitor(subclass) { @Override protected void visitClassMemberReferenceElement(PsiMember classMember, PsiJavaCodeReferenceElement classMemberReference) { @@ -153,7 +155,7 @@ public class PullUpConflictsUtil { isAccessible = true; } else if (classMember.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) && - !Comparing.strEqual(targetPackage.getQualifiedName(), StringUtil.getPackageName(subclass.getQualifiedName()))) { + toDifferentPackage) { isAccessible = true; } if (isAccessible) { @@ -167,6 +169,12 @@ public class PullUpConflictsUtil { } } }); + if (abstractMethod.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) && toDifferentPackage) { + String message = "Can't make " + RefactoringUIUtil.getDescription(abstractMethod, false) + + " abstract as it won't be accessible from the subclass."; + message = CommonRefactoringUtil.capitalize(message); + conflicts.putValue(abstractMethod, message); + } } return conflicts; } diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/a/Test.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/a/Test.java new file mode 100644 index 000000000000..1de09028ad92 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/a/Test.java @@ -0,0 +1,5 @@ +package a; + +public abstract class Test { + abstract void x(); +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/E.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/E.java new file mode 100644 index 000000000000..e6e4b670d00a --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/E.java @@ -0,0 +1,2 @@ +package b; +class E{} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/TestSubclass.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/TestSubclass.java new file mode 100644 index 000000000000..ac7700e1dfa2 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/TestSubclass.java @@ -0,0 +1,8 @@ +package b; + +import a.Test; + +public class TestSubclass extends Test { + @java.lang.Override void x() { + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/a/Test.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/a/Test.java new file mode 100644 index 000000000000..5fe720246445 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/a/Test.java @@ -0,0 +1,5 @@ +package a; +public class Test { + void x() { + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/b/E.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/b/E.java new file mode 100644 index 000000000000..e6e4b670d00a --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/b/E.java @@ -0,0 +1,2 @@ +package b; +class E{} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java index c780618504d5..e55123aa576a 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java @@ -54,6 +54,13 @@ public class ExtractSuperClassTest extends CodeInsightTestCase { new RefactoringTestUtil.MemberDescriptor("xx", PsiMethod.class)); } + public void testConflictAbstractPackageLocalMethod() throws Exception { + doTest("a.Test", "TestSubclass", + new String[] {"Can't make method x() abstract as it won't be accessible from the subclass."}, + "b", + new RefactoringTestUtil.MemberDescriptor("x", PsiMethod.class, true)); + } + public void testConflictUsingPackageLocalMethod() throws Exception { doTest("a.Test", "TestSubclass", new String[] {"method Sup.foo() won't be accessible"}, From 7cb159fe3d7f8dd69b94bf60d1ba0698ae3ad164 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Mon, 19 Jul 2010 17:17:29 +0400 Subject: [PATCH 23/79] fix xhtml item icon --- xml/impl/src/com/intellij/ide/actions/CreateHtmlFileAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/impl/src/com/intellij/ide/actions/CreateHtmlFileAction.java b/xml/impl/src/com/intellij/ide/actions/CreateHtmlFileAction.java index 8b0d6f269e90..9727f397e814 100644 --- a/xml/impl/src/com/intellij/ide/actions/CreateHtmlFileAction.java +++ b/xml/impl/src/com/intellij/ide/actions/CreateHtmlFileAction.java @@ -56,7 +56,7 @@ public class CreateHtmlFileAction extends CreateFromTemplateAction { .setTitle(XmlBundle.message("new.html.file.action")) .addKind("HTML file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML_TEMPLATE_NAME) .addKind("HTML5 file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML5_TEMPLATE_NAME) - .addKind("XHTML file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_XHTML_TEMPLATE_NAME); + .addKind("XHTML file", StdFileTypes.XHTML.getIcon(), FileTemplateManager.INTERNAL_XHTML_TEMPLATE_NAME); } @Override From d6be49a5ef504fc233c62047b43e5661453efdf2 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Mon, 19 Jul 2010 17:30:08 +0400 Subject: [PATCH 24/79] file editor manager border small fix --- .../impl/FileEditorManagerImpl.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java index 87ca0bd74f94..3a8d88acdbfd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java @@ -70,6 +70,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import java.awt.*; import java.beans.PropertyChangeEvent; @@ -133,7 +134,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec synchronized (myInitLock) { if (myPanels == null) { myPanels = new JPanel(new BorderLayout()); - myPanels.setBorder(new EmptyBorder(1, 0, 0, 0)); + myPanels.setBorder(new MyBorder()); mySplitters = new EditorsSplitters(this); myPanels.add(mySplitters, BorderLayout.CENTER); } @@ -141,6 +142,23 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec } } + private class MyBorder implements Border { + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + } + + @Override + public Insets getBorderInsets(Component c) { + boolean filesOpen = mySplitters != null && mySplitters.getOpenFiles().length > 0; + return new Insets(filesOpen ? 1 : 0, 0, 0, 0); + } + + @Override + public boolean isBorderOpaque() { + return false; + } + } + public JComponent getPreferredFocusedComponent() { assertReadAccess(); final EditorWindow window = getSplitters().getCurrentWindow(); From adb5e9ac9539989e08b297f4f7aefb9d8b8476e1 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Mon, 19 Jul 2010 19:56:19 +0400 Subject: [PATCH 25/79] xml actions inside xml plugin --- .../platform-resources/src/META-INF}/XmlActions.xml | 0 platform/platform-resources/src/META-INF/XmlPlugin.xml | 1 + resources/src/idea/IdeaActions.xml | 3 --- 3 files changed, 1 insertion(+), 3 deletions(-) rename {resources/src/idea => platform/platform-resources/src/META-INF}/XmlActions.xml (100%) diff --git a/resources/src/idea/XmlActions.xml b/platform/platform-resources/src/META-INF/XmlActions.xml similarity index 100% rename from resources/src/idea/XmlActions.xml rename to platform/platform-resources/src/META-INF/XmlActions.xml diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml index 084e08c7287d..a1e957da36be 100644 --- a/platform/platform-resources/src/META-INF/XmlPlugin.xml +++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml @@ -1,5 +1,6 @@ + diff --git a/resources/src/idea/IdeaActions.xml b/resources/src/idea/IdeaActions.xml index 7213ffbd919f..57745c3c45dc 100644 --- a/resources/src/idea/IdeaActions.xml +++ b/resources/src/idea/IdeaActions.xml @@ -678,7 +678,4 @@ - - - From 2181834e1456e3874074fe07317e9262945b46a6 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 19 Jul 2010 19:16:07 +0400 Subject: [PATCH 26/79] CIDR-debugger: do not block ui on debugger start --- .../src/com/intellij/util/concurrency/FutureResult.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/util/src/com/intellij/util/concurrency/FutureResult.java b/platform/util/src/com/intellij/util/concurrency/FutureResult.java index b6172f59b96f..356ec5845238 100644 --- a/platform/util/src/com/intellij/util/concurrency/FutureResult.java +++ b/platform/util/src/com/intellij/util/concurrency/FutureResult.java @@ -19,12 +19,12 @@ public class FutureResult implements Future { } public boolean isDone() { - return mySema.availablePermits() > 0; + return myValue != null; } public void set(T result) { assert myValue == null; - + myValue = Ref.create(Pair.create((Object)result, true)); mySema.release(); } @@ -37,8 +37,8 @@ public class FutureResult implements Future { } public T get() throws InterruptedException, ExecutionException { + mySema.acquire(); try { - mySema.acquire(); return doGet(); } finally { @@ -47,8 +47,8 @@ public class FutureResult implements Future { } public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + if (!mySema.tryAcquire(timeout, unit)) throw new TimeoutException(); try { - if (!mySema.tryAcquire(timeout, unit)) throw new TimeoutException(); return doGet(); } finally { From d52127250adc12b3e4e720c63eae1fc164652ecc Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Mon, 19 Jul 2010 21:53:27 +0400 Subject: [PATCH 27/79] fix test --- .../com/intellij/roots/ModuleRootsExternalizationTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/roots/ModuleRootsExternalizationTest.java b/java/java-tests/testSrc/com/intellij/roots/ModuleRootsExternalizationTest.java index b52b91b3b495..a8b32cbc3614 100644 --- a/java/java-tests/testSrc/com/intellij/roots/ModuleRootsExternalizationTest.java +++ b/java/java-tests/testSrc/com/intellij/roots/ModuleRootsExternalizationTest.java @@ -159,13 +159,11 @@ public class ModuleRootsExternalizationTest extends ModuleTestCase { "" + "" + "" + - "" + "" + "" + "" + "" + "" + - "" + "" + "" + "", module); From 522561d40c94db95bb3055e2cfeed672c921edc6 Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 19 Jul 2010 18:56:10 +0400 Subject: [PATCH 28/79] generate javadoc: use file to store command line parameters --- .../javadoc/JavadocConfiguration.java | 48 +++++++++++++++---- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java index d203f7aa8d85..ec37e90cb4e1 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java +++ b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java @@ -29,8 +29,10 @@ import com.intellij.execution.process.ProcessEvent; import com.intellij.execution.process.ProcessTerminatedListener; import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.ide.BrowserUtil; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JavaSdk; import com.intellij.openapi.projectRoots.JavaSdkType; @@ -38,6 +40,7 @@ import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.ex.PathUtilEx; import com.intellij.openapi.roots.*; import com.intellij.openapi.util.*; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.util.PathUtil; @@ -49,8 +52,12 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collection; +import java.util.regex.Pattern; /** * @author Eugene Zhuravlev @@ -75,6 +82,7 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl private final Project myProject; private AnalysisScope myGenerationScope; + private static final Logger LOGGER = Logger.getInstance("#" + JavadocConfiguration.class.getName()); public void setGenerationScope(AnalysisScope generationScope) { myGenerationScope = generationScope; @@ -236,22 +244,42 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl parameters.add(classPathString); } - parameters.add("-sourcepath"); - parameters.add(OrderEnumerator.orderEntries(myProject).withoutSdk().withoutLibraries().getSourcePathsList().getPathsString()); - if (OUTPUT_DIRECTORY != null) { parameters.add("-d"); parameters.add(OUTPUT_DIRECTORY.replace('/', File.separatorChar)); } - final Collection packages = new HashSet(); - final Collection sources = new HashSet(); - myGenerationOptions.accept(new MyContentIterator(myProject, packages, sources)); - if (packages.size() + sources.size() == 0) { - throw new CantRunException(JavadocBundle.message("javadoc.generate.no.classes.in.selected.packages.error")); + try { + File sourcepathTempFile = File.createTempFile("javadoc", "args.txt"); + sourcepathTempFile.deleteOnExit(); + parameters.add("@" + sourcepathTempFile.getCanonicalPath()); + final PrintWriter writer = new PrintWriter(new FileWriter(sourcepathTempFile)); + try { + writer.println("-sourcepath"); + writer.println(OrderEnumerator.orderEntries(myProject).withoutSdk().withoutLibraries().getSourcePathsList().getPathsString()); + final Collection packages = new HashSet(); + final Collection sources = new HashSet(); + final Runnable findRunnable = new Runnable() { + public void run() { + myGenerationOptions.accept(new MyContentIterator(myProject, packages, sources)); + } + }; + if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(findRunnable, "Search for sources to generate javadoc in...", false, myProject)) { + return; + } + if (packages.size() + sources.size() == 0) { + throw new CantRunException(JavadocBundle.message("javadoc.generate.no.classes.in.selected.packages.error")); + } + writer.println(StringUtil.join(packages, " ")); + writer.println(StringUtil.join(sources, " ")); + } + finally { + writer.close(); + } + } + catch (IOException e) { + LOGGER.error(e); } - parameters.addAll(new ArrayList(packages)); - parameters.addAll(new ArrayList(sources)); } protected OSProcessHandler startProcess() throws ExecutionException { From 032068c1bd7df178fc50abb5f3420d92314e75c8 Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 19 Jul 2010 19:24:53 +0400 Subject: [PATCH 29/79] throwable never thrown: exclude usages as method arguments --- .../ThrowableInstanceNeverThrownInspection.java | 2 ++ .../ThrowableInstanceNeverThrown.java | 13 +++++++++++++ .../throwable_instance_never_thrown/expected.xml | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java index 043ea018f324..7d825378e8a5 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java @@ -83,6 +83,7 @@ public class ThrowableInstanceNeverThrownInspection extends BaseInspection { } else if (parent instanceof PsiReturnStatement) { return; } + if (PsiTreeUtil.getParentOfType(parent, PsiCallExpression.class) != null) return; final PsiElement typedParent = PsiTreeUtil.getParentOfType(expression, PsiAssignmentExpression.class, @@ -129,6 +130,7 @@ public class ThrowableInstanceNeverThrownInspection extends BaseInspection { } else if (usageParent instanceof PsiReturnStatement) { return; } + if (PsiTreeUtil.getParentOfType(usageParent, PsiCallExpression.class) != null) return; } } registerError(expression, expression); diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/ThrowableInstanceNeverThrown.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/ThrowableInstanceNeverThrown.java index b6445f7bf1da..f87fa95e2cae 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/ThrowableInstanceNeverThrown.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/ThrowableInstanceNeverThrown.java @@ -1,5 +1,8 @@ package com.siyeh.igtest.bugs.throwable_instance_never_thrown; +import java.io.IOException; +import java.util.*; + public class ThrowableInstanceNeverThrown { void foo() throws Exception { @@ -30,4 +33,14 @@ public class ThrowableInstanceNeverThrown { void leftBehind() throws Throwable { final RuntimeException e = new RuntimeException("throw me"); } + + void exceptionIsCollected() { + List exs = new ArrayList(); + exs.add(new IOException()); + IOException io2 = new IOException(); + exs.add(io2); + methodCall(io2); + } + + void methodCall(IOException e){} } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/expected.xml index 0c197b2f6208..9dfb5295b08f 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/expected.xml +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/expected.xml @@ -3,14 +3,14 @@ ThrowableInstanceNeverThrown.java - 14 + 17 Throwable instance not thrown Runtime exception instance <code>new RuntimeException()</code> is not thrown ThrowableInstanceNeverThrown.java - 31 + 34 Throwable instance not thrown Runtime exception instance <code>new RuntimeException("throw me")</code> is not thrown From ad3c6eea8ad8968aa1a35d7688aa8aadab2626df Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 19 Jul 2010 19:49:37 +0400 Subject: [PATCH 30/79] extract method: update signature on toggle varargs (IDEA-56595) --- .../refactoring/extractMethod/ExtractMethodDialog.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java index 9901f3a6dbd2..2122580a4488 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java @@ -229,6 +229,11 @@ public class ExtractMethodDialog extends AbstractExtractDialog { if (canBeVarargs) { myCbMakeVarargs = new NonFocusableCheckBox(RefactoringBundle.message("declare.varargs.checkbox")); updateVarargsEnabled(); + myCbMakeVarargs.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + updateSignature(); + } + }); myCbMakeVarargs.setSelected(false); panel.add(myCbMakeVarargs); } From 8d13f7d3ead7be394622491b8f0524d0172d359e Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 19 Jul 2010 20:20:31 +0400 Subject: [PATCH 31/79] rename: extract class -> extract delegate --- .../src/com/intellij/refactoring/RefactorJBundle.properties | 2 +- .../refactoring/extractclass/ExtractClassHandler.java | 4 ---- .../src/messages/ActionsBundle.properties | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/RefactorJBundle.properties b/java/java-impl/src/com/intellij/refactoring/RefactorJBundle.properties index 178a50c038f1..f01ed4fc2c82 100644 --- a/java/java-impl/src/com/intellij/refactoring/RefactorJBundle.properties +++ b/java/java-impl/src/com/intellij/refactoring/RefactorJBundle.properties @@ -190,7 +190,7 @@ the.refactoring.is.not.supported.on.non.static.inner.classes=The refactoring is the.selected.class.has.no.members.to.extract=The selected class has no members to extract. references.to.extract=References to extract extracting.from.class=Extracting from class: -extracted.class.command.name=Extracted class {0} +extracted.class.command.name=Extracted delegate {0} method.to.extract.parameters.from.label=Method to extract parameters from: name.for.new.parameter.label=Name for new parameter: method.selected.has.no.parameters=Method selected has no parameters. diff --git a/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractClassHandler.java b/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractClassHandler.java index 574899db05d0..a0df14bbc042 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractClassHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractClassHandler.java @@ -31,10 +31,6 @@ import org.jetbrains.annotations.NotNull; public class ExtractClassHandler implements RefactoringActionHandler { - protected static String getRefactoringName() { - return RefactorJBundle.message("extract.class"); - } - protected static String getHelpID() { return HelpID.ExtractClass; } diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 9000f6fe48b2..527d5e8b0da8 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -496,8 +496,8 @@ action.InvertBoolean.text=Invert _Boolean... action.InvertBoolean.description=Makes the method return or variable contain the opposite value and corrects the references action.IntroduceParameterObject.text=Introduce Parameter Ob_ject... action.IntroduceParameterObject.description=Replaces method parameters list with object -action.ExtractClass.text=E_xtract Class... -action.ExtractClass.description=Extract Class +action.ExtractClass.text=E_xtract Delegate... +action.ExtractClass.description=Extract Delegate action.IntroduceVariable.text=Introduce _Variable... action.IntroduceVariable.description=Put a result of the selected expression into a variable action.IntroduceField.text=Introduce _Field... From 9ebf19b75e8015a759ccfaa95dcec1e68888df94 Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 19 Jul 2010 20:24:10 +0400 Subject: [PATCH 32/79] invert boolean: leave expressions with unused return value untouched (IDEA-56568 ) --- .../invertBoolean/InvertBooleanProcessor.java | 4 +++- .../refactoring/invertBoolean/unusedReturnValue.java | 9 +++++++++ .../invertBoolean/unusedReturnValue_after.java | 9 +++++++++ .../com/intellij/refactoring/InvertBooleanTest.java | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue.java create mode 100644 java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue_after.java diff --git a/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java b/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java index d2252ddb0632..e9c123c3d693 100644 --- a/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java @@ -233,7 +233,9 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor { ((PsiPrefixExpression)expression.getParent()).getOperationSign().getTokenType() == JavaTokenType.EXCL) { expression = (PsiExpression)expression.getParent(); } - expression.replace(CodeInsightServicesUtil.invertCondition(expression)); + if (!(expression.getParent() instanceof PsiExpressionStatement)) { + expression.replace(CodeInsightServicesUtil.invertCondition(expression)); + } } catch (IncorrectOperationException e) { LOG.error(e); diff --git a/java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue.java b/java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue.java new file mode 100644 index 000000000000..162ec480abe0 --- /dev/null +++ b/java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue.java @@ -0,0 +1,9 @@ +class C { + boolean foo() { + return false; + } + + void bar() { + foo(); + } +} diff --git a/java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue_after.java b/java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue_after.java new file mode 100644 index 000000000000..4741aeb6c41c --- /dev/null +++ b/java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue_after.java @@ -0,0 +1,9 @@ +class C { + boolean fooInverted() { + return true; + } + + void bar() { + fooInverted(); + } +} diff --git a/java/java-tests/testSrc/com/intellij/refactoring/InvertBooleanTest.java b/java/java-tests/testSrc/com/intellij/refactoring/InvertBooleanTest.java index 8a35526861a7..90591310658e 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/InvertBooleanTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/InvertBooleanTest.java @@ -25,6 +25,7 @@ public class InvertBooleanTest extends LightCodeInsightTestCase { public void testParameter() throws Exception { doTest(); } //inverting boolean parameter public void testParameter1() throws Exception { doTest(); } //inverting boolean parameter more advanced stuff + public void testUnusedReturnValue() throws Exception { doTest(); } private void doTest() throws Exception { configureByFile(TEST_ROOT + getTestName(true) + ".java"); From fe5e7386b0db920e0c610073ab409071ec3f456b Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 19 Jul 2010 20:37:59 +0400 Subject: [PATCH 33/79] write access --- .../refactoring/OptimizeImportsRefactoringHelper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/refactoring/OptimizeImportsRefactoringHelper.java b/java/java-impl/src/com/intellij/refactoring/OptimizeImportsRefactoringHelper.java index b615d96b6693..08719452aab8 100644 --- a/java/java-impl/src/com/intellij/refactoring/OptimizeImportsRefactoringHelper.java +++ b/java/java-impl/src/com/intellij/refactoring/OptimizeImportsRefactoringHelper.java @@ -48,7 +48,11 @@ public class OptimizeImportsRefactoringHelper implements RefactoringHelper javaFiles) { - PsiDocumentManager.getInstance(project).commitAllDocuments(); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + PsiDocumentManager.getInstance(project).commitAllDocuments(); + } + }); final Set> redundants = new HashSet>(); final Runnable findRedundantImports = new Runnable() { public void run() { From 809e663eb77679f91d69a79b3c7002439b456ee9 Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 19 Jul 2010 22:45:04 +0400 Subject: [PATCH 34/79] roots cleanup --- plugins/eclipse/testData/iml/allProps/expected/expected.iml | 4 ---- plugins/eclipse/testData/iml/emptySrc/expected/expected.iml | 1 - .../testData/iml/resolvedVariables/expected/expected.iml | 2 -- 3 files changed, 7 deletions(-) diff --git a/plugins/eclipse/testData/iml/allProps/expected/expected.iml b/plugins/eclipse/testData/iml/allProps/expected/expected.iml index e859b2f34993..03ebc91eb508 100644 --- a/plugins/eclipse/testData/iml/allProps/expected/expected.iml +++ b/plugins/eclipse/testData/iml/allProps/expected/expected.iml @@ -94,8 +94,6 @@ - - @@ -103,8 +101,6 @@ - - diff --git a/plugins/eclipse/testData/iml/emptySrc/expected/expected.iml b/plugins/eclipse/testData/iml/emptySrc/expected/expected.iml index 739c0f9ea674..6043d6eda204 100644 --- a/plugins/eclipse/testData/iml/emptySrc/expected/expected.iml +++ b/plugins/eclipse/testData/iml/emptySrc/expected/expected.iml @@ -12,7 +12,6 @@ - diff --git a/plugins/eclipse/testData/iml/resolvedVariables/expected/expected.iml b/plugins/eclipse/testData/iml/resolvedVariables/expected/expected.iml index 0eced5ed6f50..24c383002455 100644 --- a/plugins/eclipse/testData/iml/resolvedVariables/expected/expected.iml +++ b/plugins/eclipse/testData/iml/resolvedVariables/expected/expected.iml @@ -12,7 +12,6 @@ - @@ -23,7 +22,6 @@ - From c25abbf98eb9023874022dfe10c84d72b512fbb5 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 19 Jul 2010 20:32:22 +0400 Subject: [PATCH 35/79] PSI builder test cleaned --- .../intellij/lang/LightPsiBuilderTest.java | 66 +++++++++++-------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java index 243aca81a128..58e3c93c3504 100644 --- a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java +++ b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java @@ -20,34 +20,34 @@ import com.intellij.lexer.LexerBase; import com.intellij.psi.impl.DebugUtil; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; -import org.jetbrains.annotations.NotNull; import org.junit.Test; import static org.junit.Assert.assertEquals; public class LightPsiBuilderTest { + private static final IElementType ROOT = new IElementType("ROOT", Language.ANY); + private static final IElementType LETTER = new IElementType("LETTER", Language.ANY); + private static final IElementType DIGIT = new IElementType("DIGIT", Language.ANY); + private static final IElementType OTHER = new IElementType("OTHER", Language.ANY); + private static final IElementType COLLAPSED = new IElementType("COLLAPSED", Language.ANY); @Test public void testPlain() { doTest( "a<= myBufferEnd) { + return null; + } + else if (Character.isDigit(myBuffer.charAt(myIndex))) { + return DIGIT; + } + else if (Character.isLetter(myBuffer.charAt(myIndex))) { + return LETTER; + } + else { + return OTHER; + } } public int getTokenStart() { From 07653a410ff61a8d007579dd241df143d7113dea Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 19 Jul 2010 20:36:17 +0400 Subject: [PATCH 36/79] PSI builder test cleaned --- .../intellij/lang/LightPsiBuilderTest.java | 58 +++++++++---------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java index 58e3c93c3504..23833e66e031 100644 --- a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java +++ b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java @@ -34,41 +34,39 @@ public class LightPsiBuilderTest { @Test public void testPlain() { - doTest( - "a< Date: Mon, 19 Jul 2010 20:58:40 +0400 Subject: [PATCH 37/79] PSI builder test extended --- .../intellij/lang/LightPsiBuilderTest.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java index 23833e66e031..a9eacb5b0cd7 100644 --- a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java +++ b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java @@ -70,6 +70,47 @@ public class LightPsiBuilderTest { ); } + @Test + public void testDoneAndError() { + doTest("a2b", + new Parser() { + public void parse(PsiBuilder builder) { + IElementType tokenType; + while ((tokenType = builder.getTokenType()) != null) { + final PsiBuilder.Marker marker = builder.mark(); + builder.advanceLexer(); + if (tokenType == DIGIT) marker.error("no digits allowed"); else marker.done(tokenType); + } + } + }, + "Element(ROOT)\n" + + " Element(LETTER)\n" + + " PsiElement(LETTER)('a')\n" + + " PsiErrorElement:no digits allowed\n" + + " PsiElement(DIGIT)('2')\n" + + " Element(LETTER)\n" + + " PsiElement(LETTER)('b')\n"); + } + + @Test + public void testPrecedeAndDoneBefore() throws Exception { + doTest("ab", + new Parser() { + public void parse(PsiBuilder builder) { + builder.advanceLexer(); + final PsiBuilder.Marker marker = builder.mark(); + builder.advanceLexer(); + marker.done(OTHER); + marker.precede().doneBefore(COLLAPSED, marker); + } + }, + "Element(ROOT)\n" + + " PsiElement(LETTER)('a')\n" + + " Element(COLLAPSED)\n" + + " \n" + + " Element(OTHER)\n" + + " PsiElement(LETTER)('b')\n"); + } private interface Parser { void parse(PsiBuilder builder); From 6d9d1b2944d57f8cde66378158af4115711d5d09 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 19 Jul 2010 21:59:01 +0400 Subject: [PATCH 38/79] PSI builder: errorBefore() --- .../src/com/intellij/lang/PsiBuilder.java | 8 ++++++ .../intellij/lang/impl/PsiBuilderImpl.java | 26 +++++++++++++++++++ .../intellij/lang/LightPsiBuilderTest.java | 24 +++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/platform/lang-api/src/com/intellij/lang/PsiBuilder.java b/platform/lang-api/src/com/intellij/lang/PsiBuilder.java index e730513dad5d..b276dcc9e71e 100644 --- a/platform/lang-api/src/com/intellij/lang/PsiBuilder.java +++ b/platform/lang-api/src/com/intellij/lang/PsiBuilder.java @@ -139,6 +139,14 @@ public interface PsiBuilder extends UserDataHolder { * @param message for error element. */ void error(String message); + + /** + * Like {@linkplain #error(String)}, but the marker is completed before specified one. + * + * @param message for error element. + * @param before marker to complete this one before. + */ + void errorBefore(String message, Marker before); } /** diff --git a/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java b/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java index 64bcae71ece0..fd614033652e 100644 --- a/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java +++ b/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java @@ -298,6 +298,11 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { myBuilder.error(this, message); } + public void errorBefore(final String message, final Marker before) { + myType = TokenType.ERROR_ELEMENT; + myBuilder.errorBefore(this, message, before); + } + public IElementType getTokenType() { return myType; } @@ -601,6 +606,27 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { myProduction.add(doneMarker); } + @SuppressWarnings({"SuspiciousMethodCalls"}) + public void errorBefore(Marker marker, String message, Marker before) { +// TODO: there could be not done markers after 'marker' and that's normal + if (((StartMarker)marker).myDoneMarker != null) { + LOG.error("Marker already done."); + } + + int idx = myProduction.lastIndexOf(marker); + if (idx < 0) { + LOG.error("Marker has never been added."); + } + + int beforeIndex = myProduction.lastIndexOf(before); + + DoneWithErrorMarker doneMarker = new DoneWithErrorMarker((StartMarker)marker, myCurrentLexeme, message); + doneMarker.myLexemeIndex = ((StartMarker)before).myLexemeIndex; + + ((StartMarker)marker).myDoneMarker = doneMarker; + myProduction.add(beforeIndex, doneMarker); + } + public void done(final Marker marker) { doValidityChecks(marker); diff --git a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java index a9eacb5b0cd7..3d42598cbe28 100644 --- a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java +++ b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java @@ -112,6 +112,30 @@ public class LightPsiBuilderTest { " PsiElement(LETTER)('b')\n"); } + @Test + public void testErrorBefore() throws Exception { + doTest("a1", + new Parser() { + public void parse(PsiBuilder builder) { + final PsiBuilder.Marker letter = builder.mark(); + builder.advanceLexer(); + letter.done(LETTER); + final PsiBuilder.Marker digit = builder.mark(); + builder.advanceLexer(); + digit.done(DIGIT); + digit.precede().errorBefore("something lost", digit); + } + }, + "Element(ROOT)\n" + + " Element(LETTER)\n" + + " PsiElement(LETTER)('a')\n" + + " PsiErrorElement:something lost\n" + + " \n" + + " Element(DIGIT)\n" + + " PsiElement(DIGIT)('1')\n"); + } + + private interface Parser { void parse(PsiBuilder builder); } From 4e67576dba08d5ab8383646c738c463bfe67a4d7 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 19 Jul 2010 22:15:50 +0400 Subject: [PATCH 39/79] PSI builder: javadoc, test extended --- .../src/com/intellij/lang/PsiBuilder.java | 12 +++++++++--- .../com/intellij/lang/LightPsiBuilderTest.java | 15 ++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/platform/lang-api/src/com/intellij/lang/PsiBuilder.java b/platform/lang-api/src/com/intellij/lang/PsiBuilder.java index b276dcc9e71e..c9c10570ad5d 100644 --- a/platform/lang-api/src/com/intellij/lang/PsiBuilder.java +++ b/platform/lang-api/src/com/intellij/lang/PsiBuilder.java @@ -111,21 +111,27 @@ public interface PsiBuilder extends UserDataHolder { void done(IElementType type); /** - * Like done(), but collapses all tokens between start and end markers into single leaf node of given type. + * Like {@linkplain #done(IElementType)}, but collapses all tokens between start and end markers + * into single leaf node of given type. * * @param type the type of the node in the AST tree. */ void collapse(IElementType type); /** - * TODO doc + * Like {@linkplain #done(IElementType)}, but the marker is completed (end marker inserted) + * before specified one. All markers added between start of this marker and the marker specified as end one + * must be either dropped or completed. + * * @param type the type of the node in the AST tree. * @param before marker to complete this one before. */ void doneBefore(IElementType type, Marker before); /** - * TODO doc + * Like {@linkplain #doneBefore(IElementType, Marker)}, but in addition an error element with given text + * is inserted right before this marker's end. + * * @param type the type of the node in the AST tree. * @param before marker to complete this one before. * @param errorMessage for error element. diff --git a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java index 3d42598cbe28..83ee93a92f03 100644 --- a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java +++ b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java @@ -97,17 +97,22 @@ public class LightPsiBuilderTest { doTest("ab", new Parser() { public void parse(PsiBuilder builder) { + final PsiBuilder.Marker marker1 = builder.mark(); builder.advanceLexer(); - final PsiBuilder.Marker marker = builder.mark(); + final PsiBuilder.Marker marker2 = builder.mark(); builder.advanceLexer(); - marker.done(OTHER); - marker.precede().doneBefore(COLLAPSED, marker); + marker2.done(OTHER); + marker2.precede().doneBefore(COLLAPSED, marker2); + marker1.doneBefore(COLLAPSED, marker2, "with error"); } }, "Element(ROOT)\n" + - " PsiElement(LETTER)('a')\n" + " Element(COLLAPSED)\n" + - " \n" + + " PsiElement(LETTER)('a')\n" + + " Element(COLLAPSED)\n" + + " \n" + + " PsiErrorElement:with error\n" + + " \n" + " Element(OTHER)\n" + " PsiElement(LETTER)('b')\n"); } From bf977e4eb6f13cfb7eb6a8073cf3be2bc2d5c5dc Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Mon, 19 Jul 2010 23:05:54 +0400 Subject: [PATCH 40/79] IDEA-48647 rename property: rename as a whole --- .../refactoring/rename/inplace/VariableInplaceRenamer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java index 09c9ebdc6f5d..6b375936fafe 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java @@ -227,7 +227,9 @@ public class VariableInplaceRenamer { } //add highlights - addHighlights(rangesToHighlight, topLevelEditor, myHighlighters, highlightManager); + if (myHighlighters != null) { // can be null if finish is called during testing + addHighlights(rangesToHighlight, topLevelEditor, myHighlighters, highlightManager); + } } }); } From 54783be81530887141492c4f9ee8ea8c4d55eea4 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 19 Jul 2010 23:41:38 +0400 Subject: [PATCH 41/79] fix XML action registration order --- platform/platform-resources/src/META-INF/XmlActions.xml | 1 - resources/src/idea/IdeaActions.xml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-resources/src/META-INF/XmlActions.xml b/platform/platform-resources/src/META-INF/XmlActions.xml index 56dc5c8e9b04..243c6ea3713c 100644 --- a/platform/platform-resources/src/META-INF/XmlActions.xml +++ b/platform/platform-resources/src/META-INF/XmlActions.xml @@ -25,7 +25,6 @@ - + From 26ef9d94996ad8ad7c00beb1ba988f2f4899fb91 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Mon, 19 Jul 2010 23:44:52 +0400 Subject: [PATCH 42/79] forcibly flush appenders cache if too too many bytes are stored in memory --- .../intellij/util/io/PersistentHashMap.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/platform/util/src/com/intellij/util/io/PersistentHashMap.java b/platform/util/src/com/intellij/util/io/PersistentHashMap.java index b5f0aa509f79..8cf3e40ed56c 100644 --- a/platform/util/src/com/intellij/util/io/PersistentHashMap.java +++ b/platform/util/src/com/intellij/util/io/PersistentHashMap.java @@ -32,7 +32,7 @@ import java.util.Collection; */ public class PersistentHashMap extends PersistentEnumerator{ private static final Logger LOG = Logger.getInstance("#com.intellij.util.io.PersistentHashMap"); - + private static final int APPEND_CACHE_DATA_THRESHOLD = 20 * 1024 * 1024; // 20 MB private PersistentHashMapValueStorage myValueStorage; private final DataExternalizer myValueExternalizer; private static final long NULL_ADDR = 0; @@ -50,6 +50,10 @@ public class PersistentHashMap extends PersistentEnumerator{ super(new ByteArrayOutputStream()); } + public int getBufferSize() { + return ((ByteArrayOutputStream)out).size(); + } + public void writeTo(OutputStream stream) throws IOException { ((ByteArrayOutputStream)out).writeTo(stream); } @@ -63,6 +67,8 @@ public class PersistentHashMap extends PersistentEnumerator{ } } + private int myBytesInMemoryCount = 0; + private final LimitedPool myStreamPool = new LimitedPool(10, new LimitedPool.ObjectFactory() { public AppendStream create() { return new AppendStream(); @@ -92,6 +98,8 @@ public class PersistentHashMap extends PersistentEnumerator{ updateValueId(id, headerRecord); myStreamPool.recycle(value); + + myBytesInMemoryCount -= bytes.length; } catch (IOException e) { throw new RuntimeException(e); @@ -187,7 +195,18 @@ public class PersistentHashMap extends PersistentEnumerator{ public synchronized void appendData(Key key, ValueDataAppender appender) throws IOException { synchronized (ourLock) { markDirty(true); - appender.append(myAppendCache.get(key)); + + final AppendStream stream = myAppendCache.get(key); + final int sizeBefore = stream.getBufferSize(); + appender.append(stream); + myBytesInMemoryCount += (stream.getBufferSize() - sizeBefore); + + if (myBytesInMemoryCount > APPEND_CACHE_DATA_THRESHOLD) { + LOG.warn( + "PersistentHashMap: OVER " + APPEND_CACHE_DATA_THRESHOLD + " BYTES IN APPEND STREAM CACHE, FORCING CACHE FLUSH (not optimal serialization format?) File: " + getDataFile(myFile).getPath() + ); + myAppendCache.clear(); + } } } From be9442d2b54698357e608b5db8082370d24b7f0e Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 19 Jul 2010 23:49:24 +0400 Subject: [PATCH 43/79] get rid of 'validate XML' in commander popup menu altogether --- resources/src/idea/IdeaActions.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/src/idea/IdeaActions.xml b/resources/src/idea/IdeaActions.xml index 2ac280e6248d..57745c3c45dc 100644 --- a/resources/src/idea/IdeaActions.xml +++ b/resources/src/idea/IdeaActions.xml @@ -519,7 +519,6 @@ - From 277009d3a69052844c5827dd911d3379a42f4bb4 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Tue, 19 Jan 2010 16:31:29 +0300 Subject: [PATCH 44/79] method is @Nullable according it's usages --- .../src/com/intellij/execution/RunConfigurationExtension.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java b/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java index 3a833f51f11c..b4f6f769e207 100644 --- a/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java +++ b/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java @@ -48,6 +48,7 @@ public abstract class RunConfigurationExtension { public static final ExtensionPointName EP_NAME = new ExtensionPointName("com.intellij.runConfigurationExtension"); public static final Key RUN_EXTENSIONS = Key.create("run.extension.elemnts"); public abstract void handleStartProcess(final ModuleBasedConfiguration configuration, final OSProcessHandler handler); + @Nullable public abstract SettingsEditor createEditor(T configuration); public abstract String getEditorTitle(); public abstract String getName(); From dc6c422a55138f290c21fb3223f45bedede16055 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Wed, 3 Feb 2010 17:37:56 +0300 Subject: [PATCH 45/79] basic rcov patterns UI implementation --- .../intellij/ui/OptionalChooserComponent.java | 34 ++++++++++++------- .../settings/SpellCheckerSettingsPane.java | 14 ++++---- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/OptionalChooserComponent.java b/platform/platform-api/src/com/intellij/ui/OptionalChooserComponent.java index 3a5e81d6557b..f0a43d9f290f 100644 --- a/platform/platform-api/src/com/intellij/ui/OptionalChooserComponent.java +++ b/platform/platform-api/src/com/intellij/ui/OptionalChooserComponent.java @@ -26,16 +26,16 @@ import java.util.List; * @author oleg * This component represents a list of checkboxes. */ - public abstract class OptionalChooserComponent implements CheckBoxListListener { +public abstract class OptionalChooserComponent implements CheckBoxListListener { private JPanel myContentPane; private CheckBoxList myList; private DefaultListModel myListModel; - private final List> myInitialList; - private ArrayList> myWorkingList; + private List> myInitialList; + private ArrayList> myWorkingList; - public OptionalChooserComponent(@NotNull final List> list) { - myInitialList = list; - myWorkingList = new ArrayList>(myInitialList); + public OptionalChooserComponent(@NotNull final List> list) { + setInitialList(list); + myWorkingList = new ArrayList>(myInitialList); // fill list reset(); @@ -46,7 +46,7 @@ import java.util.List; } public void checkBoxSelectionChanged(int index, boolean value) { - final Pair pair = myWorkingList.remove(index); + final Pair pair = myWorkingList.remove(index); myWorkingList.add(index, Pair.create(pair.first, value)); } @@ -56,17 +56,25 @@ import java.util.List; } public void reset() { - myWorkingList = new ArrayList>(myInitialList); - update(); + myWorkingList = new ArrayList>(myInitialList); + refresh(); } - public abstract JCheckBox createCheckBox(final String path, final boolean checked); + protected abstract JCheckBox createCheckBox(final T value, final boolean checked); + + public int getSelectedIndex() { + return myList.getSelectedIndex(); + } public boolean isModified() { return !myWorkingList.equals(myInitialList); } - public ArrayList> getValue() { + public void setInitialList(@NotNull final List> list) { + myInitialList = list; + } + + public ArrayList> getCurrentModel() { return myWorkingList; } @@ -75,9 +83,9 @@ import java.util.List; myInitialList.addAll(myWorkingList); } - public void update() { + public void refresh() { myListModel.clear(); - for (Pair pair : myWorkingList) { + for (Pair pair : myWorkingList) { myListModel.addElement(createCheckBox(pair.first, pair.second)); } } diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java b/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java index e6dbd57757a3..4a15eea85615 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java @@ -50,8 +50,8 @@ public class SpellCheckerSettingsPane implements Disposable { private JPanel panelForDictionaryChooser; private JPanel panelForAcceptedWords; private JPanel panelForFolderChooser; - private final OptionalChooserComponent optionalChooserComponent; - private final PathsChooserComponent pathsChooserComponent; + private OptionalChooserComponent optionalChooserComponent; + private PathsChooserComponent pathsChooserComponent; private final List> allDictionaries = new ArrayList>(); private final List dictionariesFolders = new ArrayList(); private final WordsPanel wordsPanel; @@ -96,20 +96,20 @@ public class SpellCheckerSettingsPane implements Disposable { } paths.add(path); - final ArrayList> currentDictionaries = optionalChooserComponent.getValue(); + final ArrayList> currentDictionaries = optionalChooserComponent.getCurrentModel(); SPFileUtil.processFilesRecursively(path, new Consumer() { public void consume(final String s) { currentDictionaries.add(Pair.create(s, true)); } }); - optionalChooserComponent.update(); + optionalChooserComponent.refresh(); return true; } public boolean removePath(List paths, String path) { if (paths.remove(path)) { final ArrayList> result = new ArrayList>(); - final ArrayList> currentDictionaries = optionalChooserComponent.getValue(); + final ArrayList> currentDictionaries = optionalChooserComponent.getCurrentModel(); for (Pair pair : currentDictionaries) { if (!pair.first.startsWith(FileUtil.toSystemDependentName(path))) { result.add(pair); @@ -117,7 +117,7 @@ public class SpellCheckerSettingsPane implements Disposable { } currentDictionaries.clear(); currentDictionaries.addAll(result); - optionalChooserComponent.update(); + optionalChooserComponent.refresh(); return true; } return false; @@ -127,7 +127,7 @@ public class SpellCheckerSettingsPane implements Disposable { panelForFolderChooser.add(pathsChooserComponent.getContentPane(), BorderLayout.CENTER); - optionalChooserComponent = new OptionalChooserComponent(allDictionaries) { + optionalChooserComponent = new OptionalChooserComponent(allDictionaries) { @Override public JCheckBox createCheckBox(String path, boolean checked) { if (isUserDictionary(path)) { From 615d95eabbf2da1f50d829a1ddae138fc5909937 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Wed, 7 Jul 2010 13:47:05 +0400 Subject: [PATCH 46/79] 1. Ability to group params in General command line 2. RCov cmdline patcher was updated according new grouping API in general cmd line + rcov debuging was allowed --- .../configurations/GeneralCommandLine.java | 5 +- .../configurations/ParametersList.java | 62 +++++++- .../execution/configurations/ParamsGroup.java | 89 ++++++++++++ .../openapi/execution/ParametersListTest.java | 132 +++++++++++++++++- 4 files changed, 279 insertions(+), 9 deletions(-) create mode 100644 platform/platform-api/src/com/intellij/execution/configurations/ParamsGroup.java diff --git a/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java b/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java index 4bccb70d3d8a..2f956a7c7a59 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java @@ -27,10 +27,7 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; public class GeneralCommandLine { private Map myEnvParams; diff --git a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java index 08b873b12410..c83a76455c33 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java @@ -33,6 +33,7 @@ public class ParametersList implements Cloneable{ private static final Logger LOG = Logger.getInstance("#com.intellij.execution.configurations.ParametersList"); private List myParameters = new ArrayList(); private Map myMacroMap = null; + private List myGroups = new ArrayList(); public boolean hasParameter(@NonNls final String param) { return myParameters.contains(param); @@ -63,11 +64,15 @@ public class ParametersList implements Cloneable{ buffer.append(separator); buffer.append(GeneralCommandLine.quote(param)); } + for (ParamsGroup paramsGroup : myGroups) { + // params group parameters string already contains a separator + buffer.append(paramsGroup.getParametersList().getParametersString()); + } return buffer.toString(); } public String[] getArray() { - return ArrayUtil.toStringArray(myParameters); + return ArrayUtil.toStringArray(getList()); } public void addParametersString(final String parameters) { @@ -83,6 +88,42 @@ public class ParametersList implements Cloneable{ myParameters.add(expandMacros(parameter)); } + public ParamsGroup addParamsGroup(@NotNull final String groupId) { + return addParamsGroup(new ParamsGroup(groupId)); + } + + public ParamsGroup addParamsGroup(@NotNull final ParamsGroup group) { + myGroups.add(group); + return group; + } + + public ParamsGroup addParamsGroupAt(final int index, + @NotNull final String groupId) { + final ParamsGroup group = new ParamsGroup(groupId); + myGroups.add(index, group); + return group; + } + + public int getParamsGroupsCount() { + return myGroups.size(); + } + + public List getParameters() { + return Collections.unmodifiableList(myParameters); + } + + public List getParamsGroups() { + return Collections.unmodifiableList(myGroups); + } + + public ParamsGroup getParamsGroupAt(final int index) { + return myGroups.get(index); + } + + public ParamsGroup removeParamsGroup(final int index) { + return myGroups.remove(index); + } + public void addAt(final int index, @NotNull final String parameter) { myParameters.add(index, expandMacros(parameter)); } @@ -119,7 +160,20 @@ public class ParametersList implements Cloneable{ } public List getList() { - return Collections.unmodifiableList(myParameters); + if (myGroups.isEmpty()) { + return Collections.unmodifiableList(myParameters); + } + + final List params = new ArrayList(); + + // params + params.addAll(myParameters); + + // recursively add groups + for (ParamsGroup group : myGroups) { + params.addAll(group.getParameters()); + } + return Collections.unmodifiableList(params); } public void prepend(@NonNls final String parameter) { @@ -143,6 +197,10 @@ public class ParametersList implements Cloneable{ try { final ParametersList clone = (ParametersList)super.clone(); clone.myParameters = new ArrayList(myParameters); + clone.myGroups = new ArrayList(myGroups.size() + 1); + for (ParamsGroup group : myGroups) { + clone.myGroups.add(group.clone()); + } return clone; } catch (CloneNotSupportedException e) { diff --git a/platform/platform-api/src/com/intellij/execution/configurations/ParamsGroup.java b/platform/platform-api/src/com/intellij/execution/configurations/ParamsGroup.java new file mode 100644 index 000000000000..7e207440ad0e --- /dev/null +++ b/platform/platform-api/src/com/intellij/execution/configurations/ParamsGroup.java @@ -0,0 +1,89 @@ +/* + * Copyright 2000-2010 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.execution.configurations; + +import com.intellij.openapi.diagnostic.Logger; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * @author Roman.Chernyatchik + * + * Group of linked params. Sometime it's much more convenient to split cmdline in logical groups. + * In this case it will be easier to patch such grouped argements using custom extentions + * + * E.g.: we want to add Coverage support to all existing Ruby run configurations(ruby applications, + * different kinds of ruby tests, rails configuration, etc). Coverage support require to reorder args + * in cmdline, add rcov runner script, etc. Without groups it would be harder to parse abstract list of arguments + */ +public class ParamsGroup implements Cloneable{ + private static final Logger LOG = Logger.getInstance(ParamsGroup.class.getName()); + + private String myGroupId; + private ParametersList myGroupParams = new ParametersList(); + + public ParamsGroup(@NotNull final String groupId) { + myGroupId = groupId; + } + + public String getId() { + return myGroupId; + } + + public void addParameter(@NotNull @NonNls final String parameter) { + myGroupParams.add(parameter); + } + + public void addParameters(final String... parameters) { + for (String parameter : parameters) { + addParameter(parameter); + } + } + + public void addParameters(final List parameters) { + for (final String parameter : parameters) { + addParameter(parameter); + } + } + + public List getParameters() { + return myGroupParams.getList(); + } + + public ParametersList getParametersList() { + return myGroupParams; + } + + public ParamsGroup clone() { + try { + final ParamsGroup clone = (ParamsGroup)super.clone(); + clone.myGroupId = myGroupId; + clone.myGroupParams = myGroupParams.clone(); + return clone; + } + catch (CloneNotSupportedException e) { + LOG.error(e); + return null; + } + } + + @Override + public String toString() { + return myGroupId; + } +} diff --git a/platform/platform-impl/testSrc/com/intellij/openapi/execution/ParametersListTest.java b/platform/platform-impl/testSrc/com/intellij/openapi/execution/ParametersListTest.java index d792a353759e..bb45302c876b 100644 --- a/platform/platform-impl/testSrc/com/intellij/openapi/execution/ParametersListTest.java +++ b/platform/platform-impl/testSrc/com/intellij/openapi/execution/ParametersListTest.java @@ -16,14 +16,17 @@ package com.intellij.openapi.execution; import com.intellij.execution.configurations.ParametersList; -import com.intellij.util.Assertion; +import com.intellij.execution.configurations.ParamsGroup; +import com.intellij.testFramework.UsefulTestCase; import com.intellij.util.ArrayUtil; -import junit.framework.TestCase; +import com.intellij.util.Assertion; + +import java.util.Collections; /** * @author dyoma */ -public class ParametersListTest extends TestCase { +public class ParametersListTest extends UsefulTestCase { private final Assertion CHECK = new Assertion(); public void testAddParametersString() { @@ -41,4 +44,127 @@ public class ParametersListTest extends TestCase { String[] strings = ArrayUtil.toStringArray(params.getList()); CHECK.compareAll(expected, strings); } + + public void testParamsGroup_Empty() { + ParametersList params = new ParametersList(); + + assertEquals(0, params.getParamsGroupsCount()); + assertTrue(params.getParamsGroups().isEmpty()); + } + + public void testParamsGroup_Add() { + ParametersList params = new ParametersList(); + + final ParamsGroup group1 = params.addParamsGroup("id1"); + assertEquals("id1", group1.getId()); + assertEquals(1, params.getParamsGroupsCount()); + assertSameElements(Collections.singletonList(group1), params.getParamsGroups()); + + final ParamsGroup group2 = params.addParamsGroup("id2"); + assertEquals("id2", group2.getId()); + assertEquals(2, params.getParamsGroupsCount()); + assertOrderedEquals(params.getParamsGroups(), group1, group2); + } + + public void testParamsGroup_AddAt() { + ParametersList params = new ParametersList(); + + final ParamsGroup group1 = params.addParamsGroup("id1"); + final ParamsGroup group2 = params.addParamsGroup("id2"); + + final ParamsGroup group12 = params.addParamsGroupAt(1, "id12"); + final ParamsGroup group01 = params.addParamsGroupAt(0, "id01"); + + assertOrderedEquals(params.getParamsGroups(), group01, group1, group12, group2); + } + + public void testParamsGroup_Remove() { + ParametersList params = new ParametersList(); + + final ParamsGroup group1 = params.addParamsGroup("id1"); + final ParamsGroup group2 = params.addParamsGroup("id2"); + final ParamsGroup group3 = params.addParamsGroup("id3"); + final ParamsGroup group4 = params.addParamsGroup("id4"); + + params.removeParamsGroup(0); + assertOrderedEquals(params.getParamsGroups(), group2, group3, group4); + + params.removeParamsGroup(1); + assertOrderedEquals(params.getParamsGroups(), group2, group4); + } + + public void testParamsGroup_GroupParams() { + ParametersList params = new ParametersList(); + params.add("param1"); + + final ParamsGroup group1 = params.addParamsGroup("id1"); + group1.addParameter("group1_param1"); + + params.add("param2"); + group1.addParameter("group1_param2"); + + + final ParamsGroup group2 = params.addParamsGroup("id2"); + group2.addParameter("group2_param1"); + + params.add("param3"); + + assertOrderedEquals(params.getParameters(), "param1", "param2", "param3"); + assertOrderedEquals(params.getList(), "param1", "param2", "param3", "group1_param1", "group1_param2", "group2_param1"); + assertOrderedEquals(params.getArray(), "param1", "param2", "param3", "group1_param1", "group1_param2", "group2_param1"); + assertEquals("param1 param2 param3 group1_param1 group1_param2 group2_param1", params.getParametersString().trim()); + + final ParametersList group1_params = group1.getParametersList(); + assertOrderedEquals(group1_params.getParameters(), "group1_param1", "group1_param2"); + assertOrderedEquals(group1_params.getList(), "group1_param1", "group1_param2"); + assertOrderedEquals(group1_params.getArray(), "group1_param1", "group1_param2"); + assertEquals("group1_param1 group1_param2", group1_params.getParametersString().trim()); + + final ParametersList group2_params = group2.getParametersList(); + assertOrderedEquals(group2_params.getParameters(), "group2_param1"); + assertOrderedEquals(group2_params.getList(), "group2_param1"); + assertOrderedEquals(group2_params.getArray(), "group2_param1"); + assertEquals("group2_param1", group2_params.getParametersString().trim()); + } + + public void testParamsGroup_SubGroups() { + ParametersList params = new ParametersList(); + + final ParamsGroup group1 = params.addParamsGroup("id1"); + group1.addParameter("group1_param1"); + group1.addParameter("group1_param2"); + + final ParamsGroup group2 = params.addParamsGroup("id2"); + group2.addParameter("group2_param1"); + + final ParamsGroup group1_1 = group1.getParametersList().addParamsGroup("id1_1"); + group1_1.addParameter("group1_1_param1"); + + final ParamsGroup group1_2 = group1.getParametersList().addParamsGroup("id1_2"); + group1_2.addParameter("group1_2_param1"); + + assertOrderedEquals(params.getList(), "group1_param1", "group1_param2", "group1_1_param1", "group1_2_param1", "group2_param1"); + assertOrderedEquals(params.getList(), "group1_param1", "group1_param2", "group1_1_param1", "group1_2_param1", "group2_param1"); + assertEquals("group1_param1 group1_param2 group1_1_param1 group1_2_param1 group2_param1", params.getParametersString().trim()); + } + + public void testParamsGroup_Clone() { + ParametersList params = new ParametersList(); + + final ParamsGroup group1 = params.addParamsGroup("id1"); + group1.addParameter("group1_param1"); + final ParamsGroup group2 = params.addParamsGroup("id2"); + group2.addParameter("group2_param1"); + final ParamsGroup group3 = params.addParamsGroup("id3"); + group3.addParameter("group3_param1"); + + final ParametersList params_clone = params.clone(); + + // let's change original params group + params.removeParamsGroup(0); + group2.addParameter("group2_param2"); + + assertEquals("group2_param1 group2_param2 group3_param1", params.getParametersString().trim()); + assertEquals("group1_param1 group2_param1 group3_param1", params_clone.getParametersString().trim()); + } } From 89be5e38e36220e5829a5b8be9e5072ef2df00d5 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Thu, 8 Jul 2010 20:08:27 +0400 Subject: [PATCH 47/79] Split file content into lines corrected --- .../src/com/intellij/openapi/util/text/StringUtil.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index 538ec7bc0d67..a62221988df3 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -887,6 +887,11 @@ public class StringUtil { @NotNull public static List split(@NotNull String s, @NotNull String separator) { + return split(s, separator, true); + } + + @NotNull public static List split(@NotNull String s, @NotNull String separator, + boolean excludeSeparator) { if (separator.length() == 0) { return Collections.singletonList(s); } @@ -895,11 +900,12 @@ public class StringUtil { while (true) { int index = s.indexOf(separator, pos); if (index == -1) break; - String token = s.substring(pos, index); + final int nextPos = index + separator.length(); + String token = s.substring(pos, excludeSeparator ? index : nextPos); if (token.length() != 0) { result.add(token); } - pos = index + separator.length(); + pos = nextPos; } if (pos < s.length()) { result.add(s.substring(pos, s.length())); From aa9e68a76fb330a9b145b83e29f7e8ca8b8cfc21 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Thu, 8 Jul 2010 21:23:46 +0400 Subject: [PATCH 48/79] Generate coverage report dialog may be customized --- .../codeInspection/export/ExportToHTMLDialog.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/export/ExportToHTMLDialog.java b/platform/lang-impl/src/com/intellij/codeInspection/export/ExportToHTMLDialog.java index 75710be70ddf..78653db5d643 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/export/ExportToHTMLDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/export/ExportToHTMLDialog.java @@ -25,12 +25,11 @@ import com.intellij.ui.OptionGroup; import javax.swing.*; -// TODO copy-paste result of com.intellij.codeEditor.printing.ExportToHTMLDialog public class ExportToHTMLDialog extends DialogWrapper{ - private JCheckBox myCbOpenInBrowser; private final Project myProject; - private TextFieldWithBrowseButton myTargetDirectoryField; - private final boolean myCanBeOpenInBrowser; + protected JCheckBox myCbOpenInBrowser; + protected TextFieldWithBrowseButton myTargetDirectoryField; + protected final boolean myCanBeOpenInBrowser; public ExportToHTMLDialog(Project project, final boolean canBeOpenInBrowser) { super(project, true); @@ -54,11 +53,15 @@ public class ExportToHTMLDialog extends DialogWrapper{ if (!myCanBeOpenInBrowser) return null; OptionGroup optionGroup = new OptionGroup(InspectionsBundle.message("inspection.export.options.panel.title")); + addOptions(optionGroup); + + return optionGroup.createPanel(); + } + + protected void addOptions(OptionGroup optionGroup) { myCbOpenInBrowser = new JCheckBox(); myCbOpenInBrowser.setText(InspectionsBundle.message("inspection.export.open.option")); optionGroup.add(myCbOpenInBrowser); - - return optionGroup.createPanel(); } public void reset() { From 09233489aeef5b95dd9d0e5a16cdc9e24dd49755 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Fri, 9 Jul 2010 22:23:02 +0400 Subject: [PATCH 49/79] Custom listeners support --- .../src/com/intellij/execution/ExecutionMode.java | 13 +++++++++++++ .../src/com/intellij/execution/ExecutionModes.java | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/execution/ExecutionMode.java b/platform/lang-impl/src/com/intellij/execution/ExecutionMode.java index 81e8677fcac8..656101855044 100644 --- a/platform/lang-impl/src/com/intellij/execution/ExecutionMode.java +++ b/platform/lang-impl/src/com/intellij/execution/ExecutionMode.java @@ -15,10 +15,14 @@ */ package com.intellij.execution; +import com.intellij.execution.process.ProcessListener; import com.intellij.util.Function; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.util.ArrayList; +import java.util.List; /** * @author Roman.Chernyatchik @@ -32,6 +36,7 @@ public abstract class ExecutionMode { private final JComponent myProgressParentComponent; private Function myShouldCancelFun; private final Object CANCEL_FUN_LOCK = new Object(); + private List myListeners = new ArrayList(1); public ExecutionMode(final boolean cancelable, @Nullable final String title, @@ -94,4 +99,12 @@ public abstract class ExecutionMode { } } + public void addProcessListener(@NotNull final ProcessListener listener) { + myListeners.add(listener); + } + + @NotNull + public List getProcessListeners() { + return myListeners; + } } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/execution/ExecutionModes.java b/platform/lang-impl/src/com/intellij/execution/ExecutionModes.java index a03ac3ec6ef5..b0a81e064c17 100644 --- a/platform/lang-impl/src/com/intellij/execution/ExecutionModes.java +++ b/platform/lang-impl/src/com/intellij/execution/ExecutionModes.java @@ -20,7 +20,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; /** - * @author oleg + * @author Roman.Chernyatchik, oleg */ public class ExecutionModes { /** From c33672159a3d11dfc19f9f296a09ebd66e7b1c45 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Mon, 19 Jul 2010 17:05:03 +0400 Subject: [PATCH 50/79] vcs line markers colors were updated --- .../platform-resources/src/DefaultColorSchemesManager.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/platform-resources/src/DefaultColorSchemesManager.xml b/platform/platform-resources/src/DefaultColorSchemesManager.xml index df7b3a0e20cf..5292aff7a78a 100644 --- a/platform/platform-resources/src/DefaultColorSchemesManager.xml +++ b/platform/platform-resources/src/DefaultColorSchemesManager.xml @@ -284,7 +284,7 @@ @@ -293,7 +293,7 @@ @@ -302,7 +302,7 @@ From 6864533e515d102ba2a8f9697bda676fc7624222 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Tue, 20 Jul 2010 00:45:00 +0400 Subject: [PATCH 51/79] vcs line markers colors : a bit lighter --- .../platform-resources/src/DefaultColorSchemesManager.xml | 4 ++-- .../src/com/intellij/openapi/vcs/ex/LineStatusTracker.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/platform-resources/src/DefaultColorSchemesManager.xml b/platform/platform-resources/src/DefaultColorSchemesManager.xml index 5292aff7a78a..c9c317cbce69 100644 --- a/platform/platform-resources/src/DefaultColorSchemesManager.xml +++ b/platform/platform-resources/src/DefaultColorSchemesManager.xml @@ -284,7 +284,7 @@ @@ -293,7 +293,7 @@ diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java index 658bd0752582..adcd39b5dac4 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java @@ -210,7 +210,8 @@ public class LineStatusTracker { private static void paintGutterFragment(Editor editor, Graphics g, Rectangle r, TextAttributesKey diffAttributeKey) { EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx(); - g.setColor(editor.getColorsScheme().getAttributes(diffAttributeKey).getErrorStripeColor()); + final Color stripeColor = editor.getColorsScheme().getAttributes(diffAttributeKey).getErrorStripeColor(); + g.setColor(stripeColor); int endX = gutter.getWhitespaceSeparatorOffset(); int x = r.x + r.width - 2; int width = endX - x; From 18de1de97bf006d11c061987bd122591bf7bc5d9 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Tue, 20 Jul 2010 00:47:53 +0400 Subject: [PATCH 52/79] show hidden files in MacOpenDialog (enable/disable using Registry) --- .../src/com/intellij/ui/mac/MacFileChooserDialogImpl.java | 6 ++++++ platform/platform-resources-en/src/misc/registry.properties | 1 + 2 files changed, 7 insertions(+) diff --git a/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java b/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java index a41c7b301680..cd29df862013 100644 --- a/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java @@ -18,6 +18,7 @@ package com.intellij.ui.mac; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.MacFileChooserDialog; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.mac.foundation.Foundation; @@ -99,6 +100,11 @@ public class MacFileChooserDialogImpl implements MacFileChooserDialog { if (Foundation.isClassRespondsToSelector(Foundation.getClass("NSOpenPanel"), Foundation.createSelector("_setIncludeNewFolderButton:"))) { invoke(chooser, "_setIncludeNewFolderButton:", true); } + if (Registry.is("ide.mac.filechooser.showhidden.files")) { + if (Foundation.isClassRespondsToSelector(Foundation.getClass("NSOpenPanel"), Foundation.createSelector("setShowsHiddenFiles:"))) { + invoke(chooser, "setShowsHiddenFiles:", true); + } + } invoke(chooser, "setDelegate:", self); diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index 1d5704c563e6..7671ea69a6c3 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -62,6 +62,7 @@ ide.splitter.mouseZone=6 ide.tabbedPane.bufferedPaint=true ide.use.native.mac.filechooser=false +ide.mac.filechooser.showhidden.files=false debugger.valueTooltipAutoShow=true debugger.valueTooltipAutoShow.description=Auto show tooltip on mouse over From 75748f0292970817099fbdf21c9fcf5a0d8ac5b6 Mon Sep 17 00:00:00 2001 From: Gregory Shrago Date: Fri, 16 Jul 2010 21:15:53 +0400 Subject: [PATCH 53/79] NPE fix --- .../plugins/groovy/lang/resolve/CollectClassMembersUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/CollectClassMembersUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/CollectClassMembersUtil.java index df3823da00ff..9d5a4fc4204d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/CollectClassMembersUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/CollectClassMembersUtil.java @@ -124,7 +124,8 @@ public class CollectClassMembersUtil { private static boolean hasExplicitVisibilityModifiers(PsiField field) { if (field instanceof GrField) { - return ((GrModifierList)field.getModifierList()).hasExplicitVisibilityModifiers(); + final GrModifierList list = (GrModifierList)field.getModifierList(); + return list == null || list.hasExplicitVisibilityModifiers(); } else { return true; From bc87bcc2aab03536c373b2e8cb7fc06b16b78679 Mon Sep 17 00:00:00 2001 From: Gregory Shrago Date: Tue, 20 Jul 2010 03:36:21 +0400 Subject: [PATCH 54/79] descriptions & category --- plugins/IntelliLang/src/META-INF/plugin.xml | 8 ++++---- .../EditInjectionSettingsAction/after.java.template | 1 + .../EditInjectionSettingsAction/before.java.template | 1 + .../EditInjectionSettingsAction/description.html | 5 +++++ .../InjectLanguageAction/after.java.template | 8 +------- .../InjectLanguageAction/before.java.template | 4 +--- .../InjectLanguageAction/description.html | 5 +++++ .../QuickEditAction/after.java.template | 1 + .../QuickEditAction/before.java.template | 1 + .../QuickEditAction/description.html | 5 +++++ .../UnInjectLanguageAction/after.java.template | 1 + .../UnInjectLanguageAction/before.java.template | 1 + .../UnInjectLanguageAction/description.html | 5 +++++ .../intelliLang/inject/EditInjectionSettingsAction.java | 2 +- .../plugins/intelliLang/inject/InjectLanguageAction.java | 2 +- .../intelliLang/inject/UnInjectLanguageAction.java | 2 +- .../intelliLang/inject/quickedit/QuickEditAction.java | 2 +- 17 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/after.java.template create mode 100644 plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/before.java.template create mode 100644 plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/description.html create mode 100644 plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/after.java.template create mode 100644 plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/before.java.template create mode 100644 plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/description.html create mode 100644 plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/after.java.template create mode 100644 plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/before.java.template create mode 100644 plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/description.html diff --git a/plugins/IntelliLang/src/META-INF/plugin.xml b/plugins/IntelliLang/src/META-INF/plugin.xml index a03cb883b532..086bf2d42211 100644 --- a/plugins/IntelliLang/src/META-INF/plugin.xml +++ b/plugins/IntelliLang/src/META-INF/plugin.xml @@ -20,20 +20,20 @@ org.intellij.plugins.intelliLang.inject.InjectLanguageAction - Language Injections + Language Injection org.intellij.plugins.intelliLang.inject.UnInjectLanguageAction - + Language Injection org.intellij.plugins.intelliLang.inject.EditInjectionSettingsAction - + Language Injection org.intellij.plugins.intelliLang.inject.quickedit.QuickEditAction - + Language Injection diff --git a/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/after.java.template b/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/after.java.template new file mode 100644 index 000000000000..391250caa0ad --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/after.java.template @@ -0,0 +1 @@ +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/before.java.template b/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/before.java.template new file mode 100644 index 000000000000..391250caa0ad --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/before.java.template @@ -0,0 +1 @@ +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/description.html b/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/description.html new file mode 100644 index 000000000000..20ae1483ef3c --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/description.html @@ -0,0 +1,5 @@ + + +Opens language injection settings if available. + + \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/after.java.template b/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/after.java.template index caf04b69bf78..391250caa0ad 100644 --- a/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/after.java.template +++ b/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/after.java.template @@ -1,7 +1 @@ -class XmlConstants { - String ROOT_TAG = ""; - - void foo(){ - "".replaceAll("[^a-b]", ""); - } -} +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/before.java.template b/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/before.java.template index 2744467fdd71..391250caa0ad 100644 --- a/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/before.java.template +++ b/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/before.java.template @@ -1,3 +1 @@ -class XmlConstants { - String ROOT_TAG = ""; -} +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/description.html b/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/description.html index e69de29bb2d1..44a47d111940 100644 --- a/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/description.html +++ b/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/description.html @@ -0,0 +1,5 @@ + + +Injects language into text-holding program element (string literal, XML attribute and tag body, etc.). + + \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/after.java.template b/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/after.java.template new file mode 100644 index 000000000000..391250caa0ad --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/after.java.template @@ -0,0 +1 @@ +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/before.java.template b/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/before.java.template new file mode 100644 index 000000000000..391250caa0ad --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/before.java.template @@ -0,0 +1 @@ +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/description.html b/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/description.html new file mode 100644 index 000000000000..0fd0a0873b88 --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/description.html @@ -0,0 +1,5 @@ + + +Edit injected fragment in a designated editor without outer language escaping and concatenations. + + \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/after.java.template b/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/after.java.template new file mode 100644 index 000000000000..391250caa0ad --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/after.java.template @@ -0,0 +1 @@ +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/before.java.template b/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/before.java.template new file mode 100644 index 000000000000..391250caa0ad --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/before.java.template @@ -0,0 +1 @@ +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/description.html b/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/description.html new file mode 100644 index 000000000000..b1f57e463b65 --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/description.html @@ -0,0 +1,5 @@ + + +Removes language injection if it is configurable. + + \ No newline at end of file diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/EditInjectionSettingsAction.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/EditInjectionSettingsAction.java index f2d400ad9bae..2c8426d2c4b2 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/EditInjectionSettingsAction.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/EditInjectionSettingsAction.java @@ -53,7 +53,7 @@ public class EditInjectionSettingsAction implements IntentionAction { @NotNull public String getFamilyName() { - return InjectLanguageAction.INJECT_LANGUAGE_FAMILY; + return "Edit Injection Settings"; } public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java index 63f609448bc8..36b012b60073 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java @@ -51,7 +51,7 @@ import java.util.Collections; import java.util.List; public class InjectLanguageAction implements IntentionAction { - @NonNls protected static final String INJECT_LANGUAGE_FAMILY = "Inject Language"; + @NonNls private static final String INJECT_LANGUAGE_FAMILY = "Inject Language"; @NotNull public String getText() { diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/UnInjectLanguageAction.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/UnInjectLanguageAction.java index 4847d2c0fe73..80555e8de3c6 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/UnInjectLanguageAction.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/UnInjectLanguageAction.java @@ -50,7 +50,7 @@ public class UnInjectLanguageAction implements IntentionAction { @NotNull public String getFamilyName() { - return InjectLanguageAction.INJECT_LANGUAGE_FAMILY; + return getText(); } public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/quickedit/QuickEditAction.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/quickedit/QuickEditAction.java index c94135fc6765..d5043ac80a32 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/quickedit/QuickEditAction.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/quickedit/QuickEditAction.java @@ -89,7 +89,7 @@ public class QuickEditAction implements IntentionAction { @NotNull public String getFamilyName() { - return "Quick Edit"; + return "Edit Injected Fragment"; } public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { From f2e6eb7073c6e7c81e28fdd17da6cd27132c7c0e Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 20 Jul 2010 10:44:49 +0400 Subject: [PATCH 55/79] IDEA-56603: Add frameword support page: quick search is not working --- .../util/newProjectWizard/FrameworksTree.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java index 14865f42312a..8a831a5077be 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java @@ -17,6 +17,8 @@ package com.intellij.ide.util.newProjectWizard; import com.intellij.ui.CheckboxTree; import com.intellij.ui.CheckedTreeNode; +import com.intellij.ui.TreeSpeedSearch; +import com.intellij.util.containers.Convertor; import com.intellij.util.ui.tree.TreeUtil; import javax.swing.*; @@ -63,6 +65,20 @@ public class FrameworksTree extends CheckboxTree { super.processMouseEvent(e); } + @Override + protected void installSpeedSearch() { + new TreeSpeedSearch(this, new Convertor() { + @Override + public String convert(TreePath path) { + final Object node = path.getLastPathComponent(); + if (node instanceof FrameworkSupportNode) { + return ((FrameworkSupportNode)node).getTitle(); + } + return ""; + } + }); + } + public boolean isProcessingMouseEventOnCheckbox() { return myProcessingMouseEventOnCheckbox; } From e68247e763d2d476783c914423ece324d00f861c Mon Sep 17 00:00:00 2001 From: "Kirill.Safonov" Date: Mon, 19 Jul 2010 21:18:19 +0400 Subject: [PATCH 56/79] CreateTemplateInPackageAction moved to lang-impl --- .../com/intellij/ide/actions/CreateTemplateInPackageAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {java/java-impl => platform/lang-impl}/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java (99%) diff --git a/java/java-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java b/platform/lang-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java similarity index 99% rename from java/java-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java rename to platform/lang-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java index aa9db99da131..2c5b8702158d 100644 --- a/java/java-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2010 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. From b17a134339b5cc9ddbcef7949c30caca77a1e569 Mon Sep 17 00:00:00 2001 From: "Kirill.Safonov" Date: Mon, 19 Jul 2010 23:16:29 +0400 Subject: [PATCH 57/79] CreateTemplateInPackageAction moved to lang-impl; Java-specific code extracted --- .../ide/actions/CreateClassAction.java | 2 +- .../JavaCreateTemplateInPackageAction.java | 40 +++++++++++++++++++ .../CreateTemplateInPackageAction.java | 10 ++--- .../groovy/actions/NewGroovyClassAction.java | 4 +- .../groovy/actions/NewScriptAction.java | 4 +- 5 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 java/java-impl/src/com/intellij/ide/actions/JavaCreateTemplateInPackageAction.java diff --git a/java/java-impl/src/com/intellij/ide/actions/CreateClassAction.java b/java/java-impl/src/com/intellij/ide/actions/CreateClassAction.java index b2a8c3692d6f..32d08259fbcf 100644 --- a/java/java-impl/src/com/intellij/ide/actions/CreateClassAction.java +++ b/java/java-impl/src/com/intellij/ide/actions/CreateClassAction.java @@ -34,7 +34,7 @@ import org.jetbrains.annotations.NotNull; * * @since 5.1 */ -public class CreateClassAction extends CreateTemplateInPackageAction { +public class CreateClassAction extends JavaCreateTemplateInPackageAction { public CreateClassAction() { super(IdeBundle.message("action.create.new.class"), IdeBundle.message("action.create.new.class"), Icons.CLASS_ICON, true); } diff --git a/java/java-impl/src/com/intellij/ide/actions/JavaCreateTemplateInPackageAction.java b/java/java-impl/src/com/intellij/ide/actions/JavaCreateTemplateInPackageAction.java new file mode 100644 index 000000000000..9171a14b36e6 --- /dev/null +++ b/java/java-impl/src/com/intellij/ide/actions/JavaCreateTemplateInPackageAction.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2010 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.actions; + +import com.intellij.psi.JavaDirectoryService; +import com.intellij.psi.PsiDirectory; +import com.intellij.psi.PsiElement; +import com.intellij.util.IncorrectOperationException; + +import javax.swing.*; + +public abstract class JavaCreateTemplateInPackageAction extends CreateTemplateInPackageAction { + + protected JavaCreateTemplateInPackageAction(String text, String description, Icon icon, boolean inSourceOnly) { + super(text, description, icon, inSourceOnly); + } + + @Override + protected boolean checkPackageExists(PsiDirectory directory) { + return JavaDirectoryService.getInstance().getPackage(directory) != null; + } + + protected void doCheckCreate(PsiDirectory dir, String className, String templateName) throws IncorrectOperationException { + JavaDirectoryService.getInstance().checkCreateClass(dir, className); + } + +} diff --git a/platform/lang-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java b/platform/lang-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java index 2c5b8702158d..477de5f94a47 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java @@ -23,7 +23,6 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ProjectRootManager; -import com.intellij.psi.JavaDirectoryService; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiElement; import com.intellij.util.IncorrectOperationException; @@ -71,7 +70,7 @@ public abstract class CreateTemplateInPackageAction extend ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); for (PsiDirectory dir : view.getDirectories()) { - if (projectFileIndex.isInSourceContent(dir.getVirtualFile()) && JavaDirectoryService.getInstance().getPackage(dir) != null) { + if (projectFileIndex.isInSourceContent(dir.getVirtualFile()) && checkPackageExists(dir)) { return true; } } @@ -79,6 +78,8 @@ public abstract class CreateTemplateInPackageAction extend return false; } + protected abstract boolean checkPackageExists(PsiDirectory directory); + @Nullable private T checkOrCreate(String newName, PsiDirectory directory, String templateName, boolean check) throws IncorrectOperationException { PsiDirectory dir = directory; @@ -113,10 +114,9 @@ public abstract class CreateTemplateInPackageAction extend return doCreate(dir, className, templateName); } - protected void doCheckCreate(PsiDirectory dir, String className, String templateName) throws IncorrectOperationException { - JavaDirectoryService.getInstance().checkCreateClass(dir, className); - } + protected abstract void doCheckCreate(PsiDirectory dir, String className, String templateName) throws IncorrectOperationException; + @Nullable protected abstract T doCreate(final PsiDirectory dir, final String className, String templateName) throws IncorrectOperationException; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewGroovyClassAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewGroovyClassAction.java index b9a747629595..d4f37ff3cdcb 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewGroovyClassAction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewGroovyClassAction.java @@ -17,7 +17,7 @@ package org.jetbrains.plugins.groovy.actions; import com.intellij.ide.actions.CreateFileFromTemplateDialog; -import com.intellij.ide.actions.CreateTemplateInPackageAction; +import com.intellij.ide.actions.JavaCreateTemplateInPackageAction; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataKeys; import com.intellij.openapi.project.DumbAware; @@ -32,7 +32,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; import org.jetbrains.plugins.groovy.util.LibrariesUtil; -public class NewGroovyClassAction extends CreateTemplateInPackageAction implements DumbAware { +public class NewGroovyClassAction extends JavaCreateTemplateInPackageAction implements DumbAware { public NewGroovyClassAction() { super(GroovyBundle.message("newclass.menu.action.text"), GroovyBundle.message("newclass.menu.action.description"), GroovyIcons.CLASS, true); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewScriptAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewScriptAction.java index 3d5a251ba14c..c63c8a664c12 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewScriptAction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewScriptAction.java @@ -17,7 +17,7 @@ package org.jetbrains.plugins.groovy.actions; import com.intellij.ide.actions.CreateFileFromTemplateDialog; -import com.intellij.ide.actions.CreateTemplateInPackageAction; +import com.intellij.ide.actions.JavaCreateTemplateInPackageAction; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataKeys; import com.intellij.openapi.project.DumbAware; @@ -33,7 +33,7 @@ import org.jetbrains.plugins.groovy.GroovyIcons; import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; import org.jetbrains.plugins.groovy.util.LibrariesUtil; -public class NewScriptAction extends CreateTemplateInPackageAction implements DumbAware { +public class NewScriptAction extends JavaCreateTemplateInPackageAction implements DumbAware { private static final String GROOVY_DSL_SCRIPT_TMPL = "GroovyDslScript.gdsl"; public NewScriptAction() { From 6815d02c65bd232548f7023160091c0281851e5e Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 10:52:16 +0400 Subject: [PATCH 58/79] IDEA-56174 Highlight class references in Groovy --- .../groovy/annotator/GroovyAnnotator.java | 24 ++++++++++++++----- .../highlighter/DefaultHighlighter.java | 5 ++++ .../highlighter/GroovyColorsAndFontsPage.java | 15 ++++++------ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index e9429f30b52e..ef9bbbb5c317 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -283,6 +283,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { if (body != null) checkDuplicateMethod(body.getGroovyMethods(), myHolder); checkImplementedMethodsOfClass(myHolder, typeDefinition); checkConstructors(myHolder, typeDefinition); + highligtClassReference(myHolder, typeDefinition.getNameIdentifierGroovy()); } private static void checkConstructors(AnnotationHolder holder, GrTypeDefinition typeDefinition) { @@ -1296,6 +1297,9 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { if (member instanceof PsiMethod) { annotation.setTextAttributes(!isStatic ? DefaultHighlighter.METHOD_CALL : DefaultHighlighter.STATIC_METHOD_ACCESS); } + if (member instanceof PsiClass) { + highligtClassReference(holder, refExpr); + } } @@ -1536,16 +1540,24 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { private static void highlightAnnotation(AnnotationHolder holder, PsiElement refElement, GroovyResolveResult result) { PsiElement element = result.getElement(); PsiElement parent = refElement.getParent(); - if (element instanceof PsiClass && ((PsiClass)element).isAnnotationType() && !(parent instanceof GrImportStatement)) { - Annotation annotation = holder.createInfoAnnotation(parent, null); - annotation.setTextAttributes(DefaultHighlighter.ANNOTATION); - GroovyPsiElement context = result.getCurrentFileResolveContext(); - if (context instanceof GrImportStatement) { - annotation = holder.createInfoAnnotation(((GrImportStatement)context).getImportReference(), null); + if (element instanceof PsiClass) { + if (((PsiClass)element).isAnnotationType() && !(parent instanceof GrImportStatement)) { + Annotation annotation = holder.createInfoAnnotation(parent, null); annotation.setTextAttributes(DefaultHighlighter.ANNOTATION); + GroovyPsiElement context = result.getCurrentFileResolveContext(); + if (context instanceof GrImportStatement) { + annotation = holder.createInfoAnnotation(((GrImportStatement)context).getImportReference(), null); + annotation.setTextAttributes(DefaultHighlighter.ANNOTATION); + } + } else { + highligtClassReference(holder, refElement); } } + } + private static void highligtClassReference(AnnotationHolder holder, PsiElement classReference) { + final Annotation annotation = holder.createInfoAnnotation(classReference, null); + annotation.setTextAttributes(DefaultHighlighter.CLASS_REFERENCE); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/DefaultHighlighter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/DefaultHighlighter.java index a924b235f92a..a3b5dd8321e9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/DefaultHighlighter.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/DefaultHighlighter.java @@ -70,6 +70,8 @@ public class DefaultHighlighter { static final String METHOD_CALL_ID = "Method call"; @NonNls static final String STATIC_METHOD_ACCESS_ID = "Static method access"; + @NonNls + static final String CLASS_REFERENCE_ID = "Class"; @NonNls @@ -103,6 +105,9 @@ public class DefaultHighlighter { public static TextAttributesKey DOC_COMMENT_TAG = TextAttributesKey.createTextAttributesKey(DOC_COMMENT_TAG_ID, SyntaxHighlighterColors.DOC_COMMENT_TAG.getDefaultAttributes()); + public static TextAttributesKey CLASS_REFERENCE = + TextAttributesKey.createTextAttributesKey(CLASS_REFERENCE_ID, HighlighterColors.TEXT.getDefaultAttributes().clone()); + public static final TextAttributes KEYWORD_ATTRIBUTES = SyntaxHighlighterColors.KEYWORD.getDefaultAttributes().clone(); static{ diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovyColorsAndFontsPage.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovyColorsAndFontsPage.java index d19624f62087..e9bab50b59a5 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovyColorsAndFontsPage.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovyColorsAndFontsPage.java @@ -67,7 +67,7 @@ public class GroovyColorsAndFontsPage implements ColorSettingsPage { new AttributesDescriptor(DefaultHighlighter.ANNOTATION_ID, DefaultHighlighter.ANNOTATION), new AttributesDescriptor(DefaultHighlighter.STATIC_FIELD_ID, DefaultHighlighter.STATIC_FIELD), new AttributesDescriptor(DefaultHighlighter.STATIC_FIELD_ID, DefaultHighlighter.INSTANCE_FIELD), - new AttributesDescriptor(DefaultHighlighter.STATIC_METHOD_ACCESS_ID, DefaultHighlighter.STATIC_METHOD_ACCESS), + new AttributesDescriptor(DefaultHighlighter.CLASS_REFERENCE_ID, DefaultHighlighter.CLASS_REFERENCE), }; @NotNull @@ -83,23 +83,23 @@ public class GroovyColorsAndFontsPage implements ColorSettingsPage { @NonNls @NotNull public String getDemoText() { - return "import javax.swing.JPanel\n" + + return "import javax.swing.JPanel\n" + " ### \n" + "/**\n" + " * This is Groovydoc comment\n" + - " * @see java.lang.String#equals\n" + + " * @see java.lang.String#equals\n" + " */\n" + "@SpecialBean \n" + - "class Demo {\n" + + "class Demo {\n" + " def property\n" + "//This is a line comment\n" + "/* This is a block comment */\n" + " static def foo(int i) { return [i, i, property] }\n" + - " static def panel = new JPanel()\n" + + " static def panel = new JPanel()\n" + "}\n" + "\n" + - "Demo.panel.size = " + - "Demo.foo(\"123${456}789\".toInteger()) \n" + + "Demo.panel.size = " + + "Demo.foo(\"123${456}789\".toInteger()) \n" + "'JetBrains'.matches(/Jw+Bw+/) \n" + "def x=1 + unresolved" ; @@ -115,6 +115,7 @@ public class GroovyColorsAndFontsPage implements ColorSettingsPage { map.put("gdoc", DefaultHighlighter.DOC_COMMENT_CONTENT); map.put("doctag", DefaultHighlighter.DOC_COMMENT_TAG); map.put("unresolved", DefaultHighlighter.UNRESOLVED_ACCESS); + map.put("classref", DefaultHighlighter.CLASS_REFERENCE); return map; } From 0d689b8f58406736b15e2acf4ecc24731c5ef592 Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 12:26:03 +0400 Subject: [PATCH 59/79] IDEA-56126 Groovy: "Convert parameter to map entry" intention applied to closure doesn't change its arguments in explicit call --- .../ConvertParameterToMapEntryIntention.java | 83 ++++++++++--------- .../ParameterToMapEntryTest.java | 22 +++-- .../testdata/paramToMap/callMethod/A.groovy | 3 + .../testdata/paramToMap/callMethod/A.test | 3 + 4 files changed, 65 insertions(+), 46 deletions(-) create mode 100644 plugins/groovy/testdata/paramToMap/callMethod/A.groovy create mode 100644 plugins/groovy/testdata/paramToMap/callMethod/A.test diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java index 3ce5f8148c7d..494bdb90eb55 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java @@ -185,42 +185,53 @@ public class ConvertParameterToMapEntryIntention extends Intention { //final List calls = getCallOccurrences(occurrences); try { for (PsiElement occurrence : occurrences) { - if (occurrence instanceof GrReferenceExpression && occurrence.getParent() instanceof GrCall) { - final GrReferenceExpression refExpr = (GrReferenceExpression)occurrence; - final GrClosureSignature signature = generateSignature(owner, refExpr); - if (signature == null) continue; - final GrCall call = (GrCall)refExpr.getParent(); - final GrArgumentList argumentList = call.getArgumentList(); - final GrClosableBlock[] closureArguments = - call instanceof GrCallExpression ? ((GrCallExpression)call).getClosureArguments() : GrClosableBlock.EMPTY_ARRAY; - - final GrClosureSignatureUtil.ArgInfo[] argInfos = - GrClosureSignatureUtil.mapParametersToArguments(signature, argumentList, closureArguments, owner.getResolveScope()); - if (argInfos == null) continue; - final GrClosureSignatureUtil.ArgInfo argInfo = argInfos[index]; - - final GrNamedArgument namedArg; - if (argInfo.isMultiArg) { - if (argInfo.args.size() == 0) continue; - String arg = "[" + StringUtil.join(ContainerUtil.map(argInfo.args, new Function() { - public String fun(PsiElement element) { - return element.getText(); - } - }), ", ") + "]"; - for (PsiElement psiElement : argInfo.args) { - psiElement.delete(); + GrReferenceExpression refExpr = null; + if (occurrence instanceof GrReferenceExpression) { + final PsiElement parent = occurrence.getParent(); + if (parent instanceof GrCall) { + refExpr = (GrReferenceExpression)occurrence; + } + else if (parent instanceof GrReferenceExpression) { + final PsiElement resolved = ((GrReferenceExpression)parent).resolve(); + if (resolved instanceof PsiMethod && "call".equals(((PsiMethod)resolved).getName())) { + refExpr = (GrReferenceExpression)parent; } - namedArg = factory.createNamedArgument(paramName, factory.createExpressionFromText(arg)); } - else { - if (argInfo.args.size() == 0) continue; - final PsiElement argument = argInfo.args.iterator().next(); - assert argument instanceof GrExpression; - namedArg = factory.createNamedArgument(paramName, (GrExpression)argument); - argument.delete(); - } - ((GrCall)refExpr.getParent()).addNamedArgument(namedArg); } + if (refExpr == null) continue; + final GrClosureSignature signature = generateSignature(owner, refExpr); + if (signature == null) continue; + final GrCall call = (GrCall)refExpr.getParent(); + final GrArgumentList argumentList = call.getArgumentList(); + final GrClosableBlock[] closureArguments = + call instanceof GrCallExpression ? ((GrCallExpression)call).getClosureArguments() : GrClosableBlock.EMPTY_ARRAY; + + final GrClosureSignatureUtil.ArgInfo[] argInfos = + GrClosureSignatureUtil.mapParametersToArguments(signature, argumentList, closureArguments, owner.getResolveScope()); + if (argInfos == null) continue; + final GrClosureSignatureUtil.ArgInfo argInfo = argInfos[index]; + + final GrNamedArgument namedArg; + if (argInfo.isMultiArg) { + if (argInfo.args.size() == 0) continue; + String arg = "[" + StringUtil.join(ContainerUtil.map(argInfo.args, new Function() { + public String fun(PsiElement element) { + return element.getText(); + } + }), ", ") + "]"; + for (PsiElement psiElement : argInfo.args) { + psiElement.delete(); + } + namedArg = factory.createNamedArgument(paramName, factory.createExpressionFromText(arg)); + } + else { + if (argInfo.args.size() == 0) continue; + final PsiElement argument = argInfo.args.iterator().next(); + assert argument instanceof GrExpression; + namedArg = factory.createNamedArgument(paramName, (GrExpression)argument); + argument.delete(); + } + ((GrCall)refExpr.getParent()).addNamedArgument(namedArg); } } catch (IncorrectOperationException e) { @@ -369,10 +380,8 @@ public class ConvertParameterToMapEntryIntention extends Intention { final PsiElement namedElem = getReferencedElement(owner); if (namedElem == null) return true; final Ref result = new Ref(true); - final Task task = new Task.Modal(project, GroovyIntentionsBundle.message("find.method.ro.closure.usages.0", - owner instanceof GrClosableBlock - ? CLOSURE_CAPTION - : METHOD_CAPTION), true) { + final Task task = new Task.Modal(project, GroovyIntentionsBundle + .message("find.method.ro.closure.usages.0", owner instanceof GrClosableBlock ? CLOSURE_CAPTION : METHOD_CAPTION), true) { public void run(@NotNull final ProgressIndicator indicator) { final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(getProject()); final Query query = ReferencesSearch.search(namedElem, projectScope); diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ParameterToMapEntryTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ParameterToMapEntryTest.java index f8692a9da4c8..8fa073f22a6f 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ParameterToMapEntryTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ParameterToMapEntryTest.java @@ -56,39 +56,43 @@ public class ParameterToMapEntryTest extends GroovyFormatterTestCase { } */ - public void testParam1() throws Throwable { + public void testParam1() { doTestImpl("A.groovy"); } - public void testFormatter() throws Throwable { + public void testFormatter() { doTestImpl("A.groovy"); } - public void testClosureAtEnd() throws Throwable { + public void testClosureAtEnd() { doTestImpl("A.groovy"); } - public void testClosure1() throws Throwable { + public void testClosure1() { doTestImpl("A.groovy"); } - public void testNewMap() throws Throwable { + public void testNewMap() { doTestImpl("A.groovy"); } - public void testTestError() throws Throwable { + public void testTestError() { doTestImpl("A.groovy"); } - public void testSecondClosure() throws Throwable { + public void testSecondClosure() { doTestImpl("A.groovy"); } - public void testVarArgs() throws Throwable { + public void testVarArgs() { doTestImpl("A.groovy"); } - private void doTestImpl(String filePath) throws Throwable { + public void testCallMethod() { + doTestImpl("A.groovy"); + } + + private void doTestImpl(String filePath) { myFixture.configureByFile(filePath); int offset = myFixture.getEditor().getCaretModel().getOffset(); final PsiFile file = myFixture.getFile(); diff --git a/plugins/groovy/testdata/paramToMap/callMethod/A.groovy b/plugins/groovy/testdata/paramToMap/callMethod/A.groovy new file mode 100644 index 000000000000..23d1c8b94211 --- /dev/null +++ b/plugins/groovy/testdata/paramToMap/callMethod/A.groovy @@ -0,0 +1,3 @@ +def clos = { int i -> println(i) } +clos(1) +clos.call(1) \ No newline at end of file diff --git a/plugins/groovy/testdata/paramToMap/callMethod/A.test b/plugins/groovy/testdata/paramToMap/callMethod/A.test new file mode 100644 index 000000000000..0b7f54921e34 --- /dev/null +++ b/plugins/groovy/testdata/paramToMap/callMethod/A.test @@ -0,0 +1,3 @@ +def clos = { Map attrs -> println(attrs.i) } +clos(i: 1) +clos.call(i: 1) From b3cac21b5e013e6ef8f9e5a0f4c219c2e6a6b36b Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 12:57:24 +0400 Subject: [PATCH 60/79] IDEA-56528 Renaming Groovy class should preserve file extension --- .../groovy/lang/psi/impl/PsiImplUtil.java | 31 ++----------------- .../typedef/GrTypeDefinitionImpl.java | 12 +++++-- .../refactoring/rename/RenameTest.groovy | 6 ++++ 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java index c2f07fe0df08..23a3fd0794f6 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java @@ -227,38 +227,11 @@ public class PsiImplUtil { } public static void setName(String name, PsiElement nameElement) { - ASTNode node = nameElement.getNode(); - ASTNode newNameNode = GroovyPsiElementFactory.getInstance(nameElement.getProject()).createReferenceNameFromText(name).getNode(); - assert newNameNode != null && node != null; - node.getTreeParent().replaceChild(node, newNameNode); + final PsiElement newNameElement = GroovyPsiElementFactory.getInstance(nameElement.getProject()).createReferenceNameFromText(name); + nameElement.replace(newNameElement); } public static boolean isExtendsSignature(MethodSignature superSignatureCandidate, MethodSignature subSignature) { - /*final String name1 = superSignatureCandidate.getName(); - final String name2 = subSignature.getName(); - if (!name1.equals(name2)) return false; - - final PsiType[] superTypes = superSignatureCandidate.getParameterTypes(); - final PsiType[] subTypes = subSignature.getParameterTypes(); - if (subTypes.length != superTypes.length) return false; - for (int i = 0; i < subTypes.length - 1; i++) { - PsiType superType = TypeConversionUtil.erasure(superTypes[i]); - PsiType subType = subTypes[i]; - if (!superType.isAssignableFrom(subType)) return false; - } - - if (superTypes.length > 0) { - final PsiType lastSuperType = TypeConversionUtil.erasure(superTypes[superTypes.length - 1]); - final PsiType lastSubType = subTypes[superTypes.length - 1]; - if (lastSuperType instanceof PsiArrayType && !(lastSubType instanceof PsiArrayType)) { - final PsiType componentType = ((PsiArrayType) lastSuperType).getComponentType(); - if (!lastSubType.isConvertibleFrom(componentType)) return false; - } else { - if (!lastSuperType.isAssignableFrom(lastSubType)) return false; - } - } - - return true;*/ return MethodSignatureUtil.isSubsignature(superSignatureCandidate, subSignature); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java index 68d1dc80d232..b21d9252909f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java @@ -138,6 +138,7 @@ public abstract class GrTypeDefinitionImpl extends GroovyBaseElementImpl Date: Mon, 19 Jul 2010 22:55:15 +0400 Subject: [PATCH 61/79] EA-21019 --- .../com/intellij/codeInspection/ui/InspectionResultsView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java index 5980a99f166a..6d80319c7077 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -572,7 +572,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren if (myTree == null) return null; TreePath[] paths = myTree.getSelectionPaths(); - if (paths == null) return null; + if (paths == null || paths.length == 0) return null; if (paths.length > 1) { if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) { From 842d07671dbceaf1e1380dae61d0847372551765 Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 19 Jul 2010 23:07:22 +0400 Subject: [PATCH 62/79] @NotNulls --- .../com/intellij/ide/util/newProjectWizard/StepSequence.java | 3 ++- .../src/com/intellij/ide/wizard/AbstractWizard.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/StepSequence.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/StepSequence.java index 26ab9a35bf03..87dd1330a927 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/StepSequence.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/StepSequence.java @@ -23,6 +23,7 @@ package com.intellij.ide.util.newProjectWizard; import com.intellij.ide.util.projectWizard.ModuleWizardStep; import com.intellij.openapi.module.ModuleType; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; @@ -41,7 +42,7 @@ public class StepSequence { myParentSequence = stepSequence; } - public void addCommonStep(ModuleWizardStep step){ + public void addCommonStep(@NotNull ModuleWizardStep step){ myCommonSteps.add(step); } diff --git a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java index 0c6efad5db99..e9c6eab32b81 100644 --- a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java +++ b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java @@ -25,6 +25,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.ui.CommandButtonGroup; import com.intellij.ui.components.panels.OpaquePanel; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -221,7 +222,7 @@ public abstract class AbstractWizard extends DialogWrapper { return mySteps.get(myCurrentStep); } - public void addStep(final T step) { + public void addStep(@NotNull final T step) { mySteps.add(step); if (step instanceof StepAdapter) { From 2bacc5e0ed30cbb7c70e524b53db8d46379f26c4 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 20 Jul 2010 10:24:51 +0400 Subject: [PATCH 63/79] NPE (EA-20586) --- .../introduceField/IntroduceFieldHandler.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java index 967b5054fd2d..69f89f7678b0 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java @@ -65,9 +65,13 @@ public class IntroduceFieldHandler extends BaseExpressionToFieldHandler { protected Settings showRefactoringDialog(Project project, Editor editor, PsiClass parentClass, PsiExpression expr, PsiType type, PsiExpression[] occurences, PsiElement anchorElement, PsiElement anchorElementIfAll) { - final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expr, PsiMethod.class); - PsiElement element = expr.getUserData(ElementToWorkOn.PARENT); - if (element == null) element = expr; + final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expr != null ? expr : anchorElement, PsiMethod.class); + PsiElement element = null; + if (expr != null) { + element = expr.getUserData(ElementToWorkOn.PARENT); + if (element == null) element = expr; + } + if (element == null) element = anchorElement; final PsiModifierListOwner staticParentElement = PsiUtil.getEnclosingStaticElement(element, parentClass); boolean declareStatic = staticParentElement != null; From c93c6966bff6a67dfea148e20eccc3872f2d0fb3 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 20 Jul 2010 10:33:27 +0400 Subject: [PATCH 64/79] NPE --- platform/usageView/src/com/intellij/usages/TextChunk.java | 2 +- .../src/com/intellij/usages/UsageInfo2UsageAdapter.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/usageView/src/com/intellij/usages/TextChunk.java b/platform/usageView/src/com/intellij/usages/TextChunk.java index 3888ddae0f8b..bc2cabcef047 100644 --- a/platform/usageView/src/com/intellij/usages/TextChunk.java +++ b/platform/usageView/src/com/intellij/usages/TextChunk.java @@ -23,7 +23,7 @@ public class TextChunk { private final AttributesFlyweight myAttributes; private final String myText; - public TextChunk(TextAttributes attributesKey, @NotNull String text) { + public TextChunk(@NotNull TextAttributes attributesKey, @NotNull String text) { myAttributes = attributesKey.getFlyweight(); myText = text; } diff --git a/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java b/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java index 7d10f844cf4b..d7bc0a6acb7a 100644 --- a/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java +++ b/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java @@ -24,6 +24,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.RangeMarker; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileEditor.*; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; @@ -91,7 +92,7 @@ public class UsageInfo2UsageAdapter implements UsageInModule, UsageInLibrary, Us initChunks(); } else { // element over light virtual file myTextChunks = new TextChunk[] { - new TextChunk(null, element.getText()) + new TextChunk(new TextAttributes(), element.getText()) }; myOffset = element.getTextOffset(); } From 2c41963ef11c2ea3ed4a82c67a06f7c2f42193d4 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 20 Jul 2010 12:31:47 +0400 Subject: [PATCH 65/79] NPE (EA-19846) --- .../moveMembers/MoveMembersProcessor.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java index 6ddce912fa95..bc6d43828c3b 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java @@ -156,19 +156,21 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor { protected void performRefactoring(final UsageInfo[] usages) { try { // correct references to moved members from the outside - LanguageExtension extension=new LanguageExtension("com.intellij.refactoring.moveMemberHandler"); PsiClass targetClass = JavaPsiFacade.getInstance(myProject) .findClass(myOptions.getTargetClassName(), GlobalSearchScope.projectScope(myProject)); if (targetClass == null) return; final Map anchors = new HashMap(); for (PsiMember member : myMembersToMove) { - anchors.put(member, extension.forLanguage(member.getLanguage()).getAnchor(member, targetClass)); + final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(member.getLanguage()); + if (handler != null) { + anchors.put(member, handler.getAnchor(member, targetClass)); + } } ArrayList otherUsages = new ArrayList(); for (UsageInfo usageInfo : usages) { MoveMembersUsageInfo usage = (MoveMembersUsageInfo)usageInfo; if (!usage.reference.isValid()) continue; - final MoveMemberHandler handler = extension.forLanguage(usageInfo.getElement().getLanguage()); + final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(usageInfo.getElement().getLanguage()); if (handler!=null) { if (handler.changeExternalUsage(myOptions, usage)) continue; } @@ -189,13 +191,15 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor { } } final RefactoringElementListener elementListener = getTransaction().getElementListener(member); - final MoveMemberHandler handler = extension.forLanguage(member.getLanguage()); - PsiMember newMember=handler.doMove(myOptions, member, anchors.get(member), targetClass); - elementListener.elementMoved(newMember); + final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(member.getLanguage()); + if (handler != null) { + PsiMember newMember=handler.doMove(myOptions, member, anchors.get(member), targetClass); + elementListener.elementMoved(newMember); - fixModifierList(newMember, usages); - for (PsiReference reference : refsToBeRebind) { - reference.bindToElement(newMember); + fixModifierList(newMember, usages); + for (PsiReference reference : refsToBeRebind) { + reference.bindToElement(newMember); + } } } From dbb3eaf4b352a2f45437cf3af2ec96274fdc2f15 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 20 Jul 2010 13:00:04 +0400 Subject: [PATCH 66/79] PSI builder: more consistent validity checks --- .../intellij/lang/impl/PsiBuilderImpl.java | 80 +++++++++---------- .../intellij/lang/LightPsiBuilderTest.java | 64 +++++++++++++++ 2 files changed, 101 insertions(+), 43 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java b/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java index fd614033652e..7a55ed3f5969 100644 --- a/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java +++ b/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java @@ -569,15 +569,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { @SuppressWarnings({"SuspiciousMethodCalls"}) public void doneBefore(Marker marker, Marker before) { -// TODO: there could be not done markers after 'marker' and that's normal - if (((StartMarker)marker).myDoneMarker != null) { - LOG.error("Marker already done."); - } - - int idx = myProduction.lastIndexOf(marker); - if (idx < 0) { - LOG.error("Marker never been added."); - } + doValidityChecks(marker, before); int beforeIndex = myProduction.lastIndexOf(before); @@ -599,7 +591,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { } public void error(Marker marker, String message) { - doValidityChecks(marker); + doValidityChecks(marker, null); DoneWithErrorMarker doneMarker = new DoneWithErrorMarker((StartMarker)marker, myCurrentLexeme, message); ((StartMarker)marker).myDoneMarker = doneMarker; @@ -608,27 +600,18 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { @SuppressWarnings({"SuspiciousMethodCalls"}) public void errorBefore(Marker marker, String message, Marker before) { -// TODO: there could be not done markers after 'marker' and that's normal - if (((StartMarker)marker).myDoneMarker != null) { - LOG.error("Marker already done."); - } - - int idx = myProduction.lastIndexOf(marker); - if (idx < 0) { - LOG.error("Marker has never been added."); - } + doValidityChecks(marker, before); int beforeIndex = myProduction.lastIndexOf(before); DoneWithErrorMarker doneMarker = new DoneWithErrorMarker((StartMarker)marker, myCurrentLexeme, message); doneMarker.myLexemeIndex = ((StartMarker)before).myLexemeIndex; - ((StartMarker)marker).myDoneMarker = doneMarker; myProduction.add(beforeIndex, doneMarker); } public void done(final Marker marker) { - doValidityChecks(marker); + doValidityChecks(marker, null); DoneMarker doneMarker = DONE_MARKERS.alloc(); doneMarker.myStart = (StartMarker)marker; @@ -644,30 +627,41 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { } @SuppressWarnings({"UseOfSystemOutOrSystemErr", "SuspiciousMethodCalls"}) - private void doValidityChecks(final Marker marker) { - if (myDebugMode) { - final DoneMarker doneMarker = ((StartMarker)marker).myDoneMarker; - if (doneMarker != null) { - LOG.error("Marker already done."); - } - int idx = myProduction.lastIndexOf(marker); - if (idx < 0) { - LOG.error("Marker never been added."); - } + private void doValidityChecks(final Marker marker, @Nullable final Marker before) { + if (!myDebugMode) return; - for (int i = myProduction.size() - 1; i > idx; i--) { - Object item = myProduction.get(i); - if (item instanceof StartMarker) { - StartMarker otherMarker = (StartMarker)item; - if (otherMarker.myDoneMarker == null) { - final Throwable debugAllocOther = otherMarker.myDebugAllocationPosition; - final Throwable debugAllocThis = ((StartMarker)marker).myDebugAllocationPosition; - if (debugAllocOther != null) { - debugAllocThis.printStackTrace(System.err); - debugAllocOther.printStackTrace(System.err); - } - LOG.error("Another not done marker added after this one. Must be done before this."); + final DoneMarker doneMarker = ((StartMarker)marker).myDoneMarker; + if (doneMarker != null) { + LOG.error("Marker already done."); + } + int idx = myProduction.lastIndexOf(marker); + if (idx < 0) { + LOG.error("Marker has never been added."); + } + + int endIdx = myProduction.size(); + if (before != null) { + endIdx = myProduction.lastIndexOf(before); + if (endIdx < 0) { + LOG.error("'Before' marker has never been added."); + } + if (idx > endIdx) { + LOG.error("'Before' marker precedes this one."); + } + } + + for (int i = endIdx - 1; i > idx; i--) { + Object item = myProduction.get(i); + if (item instanceof StartMarker) { + StartMarker otherMarker = (StartMarker)item; + if (otherMarker.myDoneMarker == null) { + final Throwable debugAllocOther = otherMarker.myDebugAllocationPosition; + final Throwable debugAllocThis = ((StartMarker)marker).myDebugAllocationPosition; + if (debugAllocOther != null) { + debugAllocThis.printStackTrace(System.err); + debugAllocOther.printStackTrace(System.err); } + LOG.error("Another not done marker added after this one. Must be done before this."); } } } diff --git a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java index 83ee93a92f03..111228759fff 100644 --- a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java +++ b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java @@ -20,9 +20,13 @@ import com.intellij.lexer.LexerBase; import com.intellij.psi.impl.DebugUtil; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; +import com.sun.tools.internal.xjc.util.NullStream; import org.junit.Test; +import java.io.PrintStream; + import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; public class LightPsiBuilderTest { @@ -140,6 +144,45 @@ public class LightPsiBuilderTest { " PsiElement(DIGIT)('1')\n"); } + @Test + public void testValidityChecksOnDone() throws Exception { + doFailTest("a", + new Parser() { + public void parse(PsiBuilder builder) { + final PsiBuilder.Marker first = builder.mark(); + builder.advanceLexer(); + builder.mark(); + first.done(LETTER); + } + }); + } + + @Test + public void testValidityChecksOnDoneBefore1() throws Exception { + doFailTest("a", + new Parser() { + public void parse(PsiBuilder builder) { + final PsiBuilder.Marker first = builder.mark(); + builder.advanceLexer(); + final PsiBuilder.Marker second = builder.mark(); + second.precede(); + first.doneBefore(LETTER, second); + } + }); + } + + @Test + public void testValidityChecksOnDoneBefore2() throws Exception { + doFailTest("a", + new Parser() { + public void parse(PsiBuilder builder) { + final PsiBuilder.Marker first = builder.mark(); + builder.advanceLexer(); + final PsiBuilder.Marker second = builder.mark(); + second.doneBefore(LETTER, first); + } + }); + } private interface Parser { void parse(PsiBuilder builder); @@ -154,6 +197,27 @@ public class LightPsiBuilderTest { assertEquals(expected, DebugUtil.nodeTreeToString(root, true)); } + private static void doFailTest(final String text, final Parser parser) { + final PrintStream std = System.err; + //noinspection IOResourceOpenedButNotSafelyClosed + System.setErr(new PrintStream(new NullStream())); + try { + try { + final PsiBuilder builder = new PsiBuilderImpl(new MyTestLexer(), TokenSet.EMPTY, TokenSet.EMPTY, text); + builder.setDebugMode(true); + parser.parse(builder); + fail("should fail"); + } + catch (AssertionError e) { + //System.out.println("caught: " + e); + if ("should fail".equals(e.getMessage())) throw e; + } + } + finally { + System.setErr(std); + } + } + private static class MyTestLexer extends LexerBase { private CharSequence myBuffer = ""; private int myIndex = 0; From aca6ea27a8ee4fc7389f775fd0a9210799b69aa1 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Mon, 19 Jul 2010 16:33:01 +0400 Subject: [PATCH 67/79] IDEA-56168: duplicate id reference inspection marks good code as error --- .../src/com/intellij/xml/util/XmlRefCountHolder.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java b/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java index 58c1ead70368..ef8dc3839ce9 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java +++ b/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java @@ -17,7 +17,6 @@ package com.intellij.xml.util; import com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitor; import com.intellij.lang.Language; -import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.UserDataCache; @@ -31,6 +30,7 @@ import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.*; +import com.intellij.util.NullableFunction; import com.intellij.util.containers.ContainerUtil; import com.intellij.xml.XmlAttributeDescriptor; import com.intellij.xml.XmlElementDescriptor; @@ -102,14 +102,14 @@ public class XmlRefCountHolder { } else if (!soft) { // mark as duplicate - Pair notSoft = ContainerUtil.find(list, new Condition>() { + List notSoft = ContainerUtil.mapNotNull(list, new NullableFunction, XmlAttributeValue>() { @Override - public boolean value(Pair xmlAttributeValueBooleanPair) { - return !xmlAttributeValueBooleanPair.second; + public XmlAttributeValue fun(Pair pair) { + return pair.second ? null : pair.first; } }); - if (notSoft != null) { - myPossiblyDuplicateIds.add(notSoft.first); + if (!notSoft.isEmpty()) { + myPossiblyDuplicateIds.addAll(notSoft); myPossiblyDuplicateIds.add(attributeValue); } } From ff490194ebc96443b1a36a19f1e4e45a8c6af46d Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Mon, 19 Jul 2010 19:19:43 +0400 Subject: [PATCH 68/79] exclude zipped files --- .../psi/impl/include/FileIncludeIndex.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java b/platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java index fea3861e633b..997c4578e2f4 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java @@ -17,6 +17,7 @@ package com.intellij.psi.impl.include; import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.containers.FactoryMap; @@ -68,14 +69,14 @@ public class FileIncludeIndex extends FileBasedIndexExtension, FileContent> getIndexer() { - return new DataIndexer, FileContent>() { + public DataIndexer, FileContent> getIndexer() { + return new DataIndexer, FileContent>() { @NotNull - public Map> map(FileContent inputData) { + public Map> map(FileContent inputData) { - Map> map = new FactoryMap>() { + Map> map = new FactoryMap>() { @Override - protected List create(FileIncludeIndex.Key key) { + protected List create(Key key) { return new ArrayList(); } }; @@ -144,6 +145,9 @@ public class FileIncludeIndex extends FileBasedIndexExtension Date: Mon, 19 Jul 2010 20:04:26 +0400 Subject: [PATCH 69/79] hide actions not relevant for current language --- .../actions/BaseRefactoringAction.java | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/refactoring/actions/BaseRefactoringAction.java b/platform/lang-impl/src/com/intellij/refactoring/actions/BaseRefactoringAction.java index f738a908d8af..fe2e9504d750 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/actions/BaseRefactoringAction.java +++ b/platform/lang-impl/src/com/intellij/refactoring/actions/BaseRefactoringAction.java @@ -83,12 +83,8 @@ public abstract class BaseRefactoringAction extends AnAction { presentation.setEnabled(true); DataContext dataContext = e.getDataContext(); Project project = e.getData(PlatformDataKeys.PROJECT); - if (project == null) { - disableAction(e); - return; - } - if (isHidden()) { - e.getPresentation().setVisible(false); + if (project == null || isHidden()) { + hideAction(e); return; } @@ -103,7 +99,7 @@ public abstract class BaseRefactoringAction extends AnAction { if (editor == null) { if (isAvailableInEditorOnly()) { - disableAction(e); + hideAction(e); return; } final PsiElement[] elements = getPsiElementArray(dataContext); @@ -116,21 +112,30 @@ public abstract class BaseRefactoringAction extends AnAction { PsiElement element = e.getData(LangDataKeys.PSI_ELEMENT); if (element == null || !isAvailableForLanguage(element.getLanguage())) { if (file == null) { - disableAction(e); + hideAction(e); return; } element = getElementAtCaret(editor, file); } - final boolean isEnabled = element != null && - !(element instanceof SyntheticElement) && - isAvailableForLanguage(PsiUtilBase.getLanguageInEditor(editor, project)) && - isAvailableOnElementInEditor(element, editor); - if (!isEnabled) { - disableAction(e); + boolean isVisible = element != null && + !(element instanceof SyntheticElement) && + isAvailableForLanguage(PsiUtilBase.getLanguageInEditor(editor, project)); + if (isVisible) { + boolean isEnabled = isAvailableOnElementInEditor(element, editor); + if (!isEnabled) { + disableAction(e); + } + } + else { + hideAction(e); } } } + private static void hideAction(AnActionEvent e) { + e.getPresentation().setVisible(false); + } + protected boolean isHidden() { return false; } @@ -162,7 +167,7 @@ public abstract class BaseRefactoringAction extends AnAction { private static void disableAction(final AnActionEvent e) { e.getPresentation().setEnabled(false); if (ActionPlaces.isPopupPlace(e.getPlace())) { - e.getPresentation().setVisible(false); + hideAction(e); } } From f1a2ef058338d5df21686fa386e7985278213baf Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 20 Jul 2010 14:36:08 +0400 Subject: [PATCH 70/79] Inline Included File reanimated --- .../intellij/lang/refactoring/InlineActionHandler.java | 4 ++++ .../lang-api/src/com/intellij/psi/util/PsiUtilBase.java | 8 ++++++++ .../com/intellij/refactoring/actions/InlineAction.java | 8 ++++---- .../src/messages/RefactoringBundle.properties | 7 +++---- xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java | 1 - 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java b/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java index 950d9660c986..bc9ddaf7a954 100644 --- a/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java +++ b/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java @@ -38,6 +38,10 @@ public abstract class InlineActionHandler { return canInlineElement(element); } + public boolean isEnabledOnElement(PsiElement element, Editor editor) { + return isEnabledOnElement(element); + } + public abstract boolean isEnabledForLanguage(Language l); public abstract boolean canInlineElement(PsiElement element); diff --git a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java index 34509ab6cb43..02577d3b0d7b 100644 --- a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java +++ b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java @@ -431,6 +431,14 @@ public class PsiUtilBase { return narrowLanguage(lang, file.getLanguage()); } + @Nullable + public static PsiElement getElementAtCaret(Editor editor) { + Project project = editor.getProject(); + if (project == null) return null; + PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); + return file == null ? null : file.findElementAt(editor.getCaretModel().getOffset()); + } + public static Language getDialect(@NotNull PsiElement element) { return narrowLanguage(element.getLanguage(), element.getContainingFile().getLanguage()); } diff --git a/platform/lang-impl/src/com/intellij/refactoring/actions/InlineAction.java b/platform/lang-impl/src/com/intellij/refactoring/actions/InlineAction.java index 2f60105e59ee..dd167029e2c1 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/actions/InlineAction.java +++ b/platform/lang-impl/src/com/intellij/refactoring/actions/InlineAction.java @@ -45,16 +45,16 @@ public class InlineAction extends BasePlatformRefactoringAction { @Override protected boolean isAvailableOnElementInEditor(PsiElement element, Editor editor) { - return hasInlineActionHandler(element, PsiUtilBase.getLanguageInEditor(editor, element.getProject())); + return hasInlineActionHandler(element, PsiUtilBase.getLanguageInEditor(editor, element.getProject()), editor); } public boolean isEnabledOnElements(PsiElement[] elements) { - return elements.length == 1 && hasInlineActionHandler(elements [0], null); + return elements.length == 1 && hasInlineActionHandler(elements [0], null, null); } - private static boolean hasInlineActionHandler(PsiElement element, @Nullable Language editorLanguage) { + private static boolean hasInlineActionHandler(PsiElement element, @Nullable Language editorLanguage, Editor editor) { for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { - if (handler.isEnabledOnElement(element)) { + if (handler.isEnabledOnElement(element, editor)) { return true; } } diff --git a/platform/platform-resources-en/src/messages/RefactoringBundle.properties b/platform/platform-resources-en/src/messages/RefactoringBundle.properties index 69c2d469036d..031d2b333c23 100644 --- a/platform/platform-resources-en/src/messages/RefactoringBundle.properties +++ b/platform/platform-resources-en/src/messages/RefactoringBundle.properties @@ -452,11 +452,10 @@ instances.upcasted.to.object=Instances upcasted to Object instances.upcasted.to.java.lang.object.found=Instances upcasted to java.lang.Object found replace.inheritance.with.delegation.command=Replacing inheritance with delegation in {0} replace.inheritance.with.delegation.elements.header=Replace inheritance with delegation +# Inline included file inline.included.file.title=Inline included file -the.caret.should.be.positioned.on.the.include.directive.to.inline=The caret should be positioned on the include directive to inline -cannot.determine.the.structure.of.included.file=Cannot determine the structure of included file. -included.file.uses.another.syntax=Included file uses another syntax. -cannot.resolve.included.file=Cannot resolve included file +the.caret.should.be.positioned.on.the.included.file.to.inline=The caret should be positioned on the included file reference to inline + inline.the.contents.include.prompt=Inline the contents of ''{0}''? remove.include.prompt=Included file is no longer used. Remove it? delete.include.command=Delete {0} diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java b/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java index 60c822b92d3a..5e0129ab5df5 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java +++ b/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java @@ -20,7 +20,6 @@ import org.jetbrains.annotations.Nullable; public interface XmlTagChild extends XmlElement{ XmlTagChild[] EMPTY_ARRAY = new XmlTagChild[0]; - @Nullable XmlTag getParentTag(); @Nullable From 5d575db14294b9af17c58c8a985e9a95d7fa97a4 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 20 Jul 2010 13:36:34 +0400 Subject: [PATCH 71/79] preserve suggestions order --- .../src/com/intellij/refactoring/rename/RenameDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java index e323b8732287..bfa5458b7066 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java @@ -134,7 +134,7 @@ public class RenameDialog extends RefactoringDialog { } public String[] getSuggestedNames() { - Set result = new HashSet(); + LinkedHashSet result = new LinkedHashSet(); final NameSuggestionProvider[] providers = Extensions.getExtensions(NameSuggestionProvider.EP_NAME); for(NameSuggestionProvider provider: providers) { SuggestedNameInfo info = provider.getSuggestedNames(myPsiElement, myNameSuggestionContext, result); From 23f0bfee45e5181effea97effcfe2ec8939db08a Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Tue, 20 Jul 2010 15:09:46 +0400 Subject: [PATCH 72/79] deferred painting, fix for uml --- .../src/com/intellij/ui/DeferredIconImpl.java | 81 +++++++++++++++---- .../src/com/intellij/ui/PaintingParent.java | 39 +++++++++ 2 files changed, 105 insertions(+), 15 deletions(-) create mode 100644 platform/platform-api/src/com/intellij/ui/PaintingParent.java diff --git a/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java b/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java index 7dbc4a248c92..11c207c33154 100644 --- a/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java +++ b/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java @@ -23,6 +23,7 @@ import com.intellij.concurrency.Job; import com.intellij.concurrency.JobUtil; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.IndexNotReadyException; +import com.intellij.openapi.util.Ref; import com.intellij.util.Alarm; import com.intellij.util.Function; import com.intellij.util.ui.EmptyIcon; @@ -66,29 +67,37 @@ public class DeferredIconImpl implements DeferredIcon { if (!myIsScheduled) { myIsScheduled = true; - final Component target; + final Ref target = new Ref(null); + final Ref paintingParent = new Ref(null); + final Ref paintingParentRec = new Ref(null); final Container list = SwingUtilities.getAncestorOfClass(JList.class, c); if (list != null) { - target = list; + target.set(list); } else { final Container tree = SwingUtilities.getAncestorOfClass(JTree.class, c); if (tree != null) { - target = tree; + target.set(tree); } else { final Container table = SwingUtilities.getAncestorOfClass(JTable.class, c); if (table != null) { - target = table; + target.set(table); } else { - target = c; + target.set(c); } } } - myLastTarget = new WeakReference(target); + Container pp = SwingUtilities.getAncestorOfClass(PaintingParent.class, c); + paintingParent.set(pp); + if (paintingParent.get() != null) { + paintingParentRec.set(((PaintingParent)pp).getChildRec(c)); + } + + myLastTarget = new WeakReference(target.get()); JobUtil.submitToJobThread(new Runnable() { public void run() { @@ -100,10 +109,23 @@ public class DeferredIconImpl implements DeferredIcon { //noinspection SSBasedInspection SwingUtilities.invokeLater(new Runnable() { public void run() { + Component actualTarget = target.get(); + if (SwingUtilities.getWindowAncestor(actualTarget) == null) { + actualTarget = paintingParent.get(); + if (actualTarget == null || SwingUtilities.getWindowAncestor(actualTarget) == null) { + actualTarget = null; + myLastTarget = null; + } + } + + if (actualTarget == null) return; + + myLastTarget = new WeakReference(actualTarget); + if (shouldRevalidate) { // revalidate will not work: jtree caches size of nodes - if (target instanceof JTree) { - final TreeUI ui = ((JTree)target).getUI(); + if (actualTarget instanceof JTree) { + final TreeUI ui = ((JTree)actualTarget).getUI(); if (ui instanceof BasicTreeUI) { // this call is "fake" and only need to reset tree layout cache ((BasicTreeUI)ui).setLeftChildIndent(((Integer)UIManager.get("Tree.leftChildIndent")).intValue()); @@ -111,11 +133,16 @@ public class DeferredIconImpl implements DeferredIcon { } } - if (c == target) { + if (c == actualTarget) { c.repaint(x, y, getIconWidth(), getIconHeight()); } else { - ourRepaintScheduler.pushDirtyComponent(target); + Rectangle rec = null; + if (paintingParentRec.get() != null) { + rec = paintingParentRec.get(); + } + + ourRepaintScheduler.pushDirtyComponent(actualTarget, rec); } } }); @@ -191,20 +218,44 @@ public class DeferredIconImpl implements DeferredIcon { private static class RepaintScheduler { private final Alarm myAlarm = new Alarm(); - private final Set myQueue = new LinkedHashSet(); + private final Set myQueue = new LinkedHashSet(); - public void pushDirtyComponent(Component c) { + public void pushDirtyComponent(final Component c, final Rectangle rec) { myAlarm.cancelAllRequests(); myAlarm.addRequest(new Runnable() { public void run() { - for (Component component : myQueue) { - component.repaint(); + for (RepaintRequest each : myQueue) { + Rectangle r = each.getRectangle(); + if (r != null) { + each.getComponent().repaint(r.x, r.y, r.width, r.height); + } else { + each.getComponent().repaint(); + } } myQueue.clear(); } }, 50); - myQueue.add(c); + myQueue.add(new RepaintRequest(c, rec)); } } + + private static class RepaintRequest { + private Component myComponent; + private Rectangle myRectangle; + + private RepaintRequest(Component component, Rectangle rectangle) { + myComponent = component; + myRectangle = rectangle; + } + + public Component getComponent() { + return myComponent; + } + + public Rectangle getRectangle() { + return myRectangle; + } + } + } diff --git a/platform/platform-api/src/com/intellij/ui/PaintingParent.java b/platform/platform-api/src/com/intellij/ui/PaintingParent.java new file mode 100644 index 000000000000..a49f1235e11f --- /dev/null +++ b/platform/platform-api/src/com/intellij/ui/PaintingParent.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2010 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.ui; + +import org.jetbrains.annotations.Nullable; + +import java.awt.*; + +/** + * Used for deferred re-painting (i.e. for deferred icons). As a paint() method is invoked through the normal AWT painting cycle, deferred painting + * of children may be queued. It means that actual data used for painting is pushed for calculation and, as it gets ready, there is need for repaint. + * The target component for further repaint() is either the component that was originally exposed to painting or, if it's no longer showing (in case of a flyweight + * renderer) -- the first component up in the hierarchy that implements PaintingParent. + * + */ +public interface PaintingParent { + + /** + * Returns rectangle of a child component for further repainting + * @param c + * @return a rectange, if null -- the whole component will be repainted + */ + @Nullable + Rectangle getChildRec(Component c); + +} From 8329536c4999347b654adb9dcb36bdb226b37572 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 20 Jul 2010 15:54:28 +0400 Subject: [PATCH 73/79] case-insensitive comparator (IDEA-56602) --- .../intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java index a23ab8fb9e91..2a54b574ba1b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java @@ -440,7 +440,7 @@ public class WelcomeScreen { final boolean e2 = ((IdeaPluginDescriptorImpl)o2).isEnabled(); if (e1 && !e2) return -1; if (!e1 && e2) return 1; - return o1.getName().compareTo(o2.getName()); + return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase()); } }; Collections.sort(installedPlugins, pluginsComparator); From 04095647a5ab2d7c857893be1a11e354dadd080f Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 16:04:36 +0400 Subject: [PATCH 74/79] IDEA-47083 Quickfix to convert Java-style array creation to Groovy-style --- plugins/groovy/src/META-INF/plugin.xml | 5 ++ .../GroovyIntentionsBundle.properties | 5 +- ...onvertJavaStyleArrayCreationIntention.java | 65 +++++++++++++++++++ .../ConvertJavaStyleArrayCreationTest.java | 32 +++++++++ .../Conversion.groovy | 1 + .../Conversion_after.groovy | 1 + 6 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertJavaStyleArrayCreationIntention.java create mode 100644 plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertJavaStyleArrayCreationTest.java create mode 100644 plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion.groovy create mode 100644 plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion_after.groovy diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index 0418c136e6bf..1eedae80b8bd 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -375,6 +375,11 @@ --> + + org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle + intention.category.groovy/intention.category.conversions + org.jetbrains.plugins.groovy.intentions.conversions.ConvertJavaStyleArrayCreationIntention + org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle intention.category.groovy/intention.category.conversions diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties index 113f31b0d971..beb7dffac824 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties @@ -82,4 +82,7 @@ do.not.create.first.new=Use &existing first parameter as map for named arguments convert.cannot.itself=Refactoring is not available for map parameter itself perform.refactoring=Performing refactoring map.param.name=Map parameter &name: -convert.param.to.map.entry=Convert parameter to map entry \ No newline at end of file +convert.param.to.map.entry=Convert parameter to map entry + +convert.java.style.array.creation.intention.name=Convert java-style array creation +convert.java.style.array.creation.intention.family.name=Convert Java-Style Array Creation to Groovy Syntax \ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertJavaStyleArrayCreationIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertJavaStyleArrayCreationIntention.java new file mode 100644 index 000000000000..a2c6052d879e --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertJavaStyleArrayCreationIntention.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2010 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.intentions.conversions; + +import com.intellij.psi.PsiElement; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.groovy.intentions.base.Intention; +import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate; +import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression; + +/** + * @author Maxim.Medvedev + */ +public class ConvertJavaStyleArrayCreationIntention extends Intention { + @Override + protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException { + final GrClosableBlock block = ((GrMethodCallExpression)element).getClosureArguments()[0]; + final String text = block.getText(); + int start = block.getLBrace().getStartOffsetInParent() + 1; + int finish = block.getRBrace().getStartOffsetInParent(); + String newText = "[" + text.substring(start, finish) + "]"; + final GrExpression newExpr = GroovyPsiElementFactory.getInstance(element.getProject()).createExpressionFromText(newText); + ((GrMethodCallExpression)element).replaceWithStatement(newExpr); + } + + @NotNull + @Override + protected PsiElementPredicate getElementPredicate() { + return new PsiElementPredicate() { + @Override + public boolean satisfiedBy(PsiElement element) { + if (!(element instanceof GrMethodCallExpression)) return false; + final GrExpression expression = ((GrMethodCallExpression)element).getInvokedExpression(); + if (!(expression instanceof GrNewExpression)) return false; + if (((GrNewExpression)expression).getArrayCount() == 0) return false; + + if (((GrMethodCallExpression)element).getArgumentList().getText().trim().length() > 0) return false; + + final GrClosableBlock[] closureArguments = ((GrMethodCallExpression)element).getClosureArguments(); + if (closureArguments.length != 1) return false; + final GrClosableBlock block = closureArguments[0]; + if (block.getLBrace() == null || block.getRBrace() == null) return false; + return true; + } + }; + } +} diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertJavaStyleArrayCreationTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertJavaStyleArrayCreationTest.java new file mode 100644 index 000000000000..0353936fa62a --- /dev/null +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertJavaStyleArrayCreationTest.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2010 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.intentions; + +import org.jetbrains.plugins.groovy.util.TestUtils; + +/** + * @author Maxim.Medvedev + */ +public class ConvertJavaStyleArrayCreationTest extends GrIntentionTestCase{ + @Override + protected String getBasePath() { + return TestUtils.getTestDataPath() + "intentions/convertJavaStyleArrayCreation/"; + } + + public void testConversion() { + doTest(GroovyIntentionsBundle.message("convert.java.style.array.creation.intention.name"), true); + } +} diff --git a/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion.groovy b/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion.groovy new file mode 100644 index 000000000000..11781d79e883 --- /dev/null +++ b/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion.groovy @@ -0,0 +1 @@ +def foo = new Object[] {1, 2, 3} \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion_after.groovy b/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion_after.groovy new file mode 100644 index 000000000000..2be10eba8fd1 --- /dev/null +++ b/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion_after.groovy @@ -0,0 +1 @@ +def foo = [1, 2, 3] \ No newline at end of file From ca690f8efc43341b6c052cf571b13517db8fa8de Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 16:13:33 +0400 Subject: [PATCH 75/79] IDEA-47083 intention description --- .../after.groovy.template | 1 + .../before.groovy.template | 1 + .../description.html | 7 +++++++ 3 files changed, 9 insertions(+) create mode 100644 plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template create mode 100644 plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template create mode 100644 plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html diff --git a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template new file mode 100644 index 000000000000..221308e2c833 --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template @@ -0,0 +1 @@ +def objects = [foo, bar] \ No newline at end of file diff --git a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template new file mode 100644 index 000000000000..9944d004075f --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template @@ -0,0 +1 @@ +def objects = new Object[] {foo, bar} diff --git a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html new file mode 100644 index 000000000000..a57eb1cb3c81 --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html @@ -0,0 +1,7 @@ + + + +This intention converts java-style array creation to groovy syntax. + + + From ba50b765d85c7f90be7b3c8c0818f6526b442b75 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Tue, 20 Jul 2010 17:34:35 +0400 Subject: [PATCH 76/79] navbar popup fix --- .../src/com/intellij/ide/navigationToolbar/NavBarPanel.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java index b0dc4e89699c..139614aae1c7 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java @@ -555,6 +555,10 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup } }); + if (!isValid()) { + validate(); + } + myNodePopup.showUnderneathOf(item); } } From 1649c442f2e2c00ca68fd7e67db3491e62791d86 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Tue, 20 Jul 2010 17:39:09 +0400 Subject: [PATCH 77/79] optimized project files for CE project --- .idea/libraries/Ant.xml | 1 - .idea/libraries/CGLIB.xml | 1 - .idea/libraries/DTDParser.xml | 2 -- .idea/libraries/EasyMock.xml | 2 -- .idea/libraries/Eclipse.xml | 1 - .idea/libraries/Gant.xml | 1 - .idea/libraries/Groovy.xml | 1 - .idea/libraries/JDOM.xml | 1 - .idea/libraries/JMock1.xml | 2 -- .idea/libraries/JUnit3.xml | 2 -- .idea/libraries/JUnit4.xml | 1 - .idea/libraries/JavaHelp.xml | 1 - .idea/libraries/Jaxen.xml | 2 -- .idea/libraries/Log4J.xml | 1 - .idea/libraries/Mac.xml | 1 - .idea/libraries/Mocks.xml | 2 -- .idea/libraries/NanoXML.xml | 1 - .idea/libraries/OroMatcher.xml | 2 -- .idea/libraries/TestNG.xml | 2 -- .idea/libraries/Trove4j.xml | 1 - .idea/libraries/Velocity.xml | 1 - .idea/libraries/XStream.xml | 2 -- .idea/libraries/Xerces.xml | 1 - .idea/libraries/XmlBeans.xml | 2 -- .idea/libraries/XmlRPC.xml | 1 - .idea/libraries/asm.xml | 1 - .idea/libraries/commons_codec.xml | 2 -- .idea/libraries/commons_collections.xml | 1 - .idea/libraries/commons_lang.xml | 2 -- .idea/libraries/commons_net.xml | 1 - .idea/libraries/jcip.xml | 2 -- .idea/libraries/jgoodies_forms.xml | 1 - .idea/libraries/jna.xml | 2 -- .idea/libraries/microba.xml | 2 -- .idea/libraries/picocontainer.xml | 1 - .idea/libraries/tcServiceMessages.xml | 1 - 36 files changed, 51 deletions(-) diff --git a/.idea/libraries/Ant.xml b/.idea/libraries/Ant.xml index dfdd147fd7bc..4d69c6899db3 100644 --- a/.idea/libraries/Ant.xml +++ b/.idea/libraries/Ant.xml @@ -28,7 +28,6 @@ - diff --git a/.idea/libraries/CGLIB.xml b/.idea/libraries/CGLIB.xml index 061f6f213744..b7e692fa647e 100644 --- a/.idea/libraries/CGLIB.xml +++ b/.idea/libraries/CGLIB.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/DTDParser.xml b/.idea/libraries/DTDParser.xml index dcc82b44e627..c40d012406c8 100644 --- a/.idea/libraries/DTDParser.xml +++ b/.idea/libraries/DTDParser.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/EasyMock.xml b/.idea/libraries/EasyMock.xml index 05648438f07a..cc51a3eea9a6 100644 --- a/.idea/libraries/EasyMock.xml +++ b/.idea/libraries/EasyMock.xml @@ -4,7 +4,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/Eclipse.xml b/.idea/libraries/Eclipse.xml index 09b7e2c73bd4..7fa7c6724800 100644 --- a/.idea/libraries/Eclipse.xml +++ b/.idea/libraries/Eclipse.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Gant.xml b/.idea/libraries/Gant.xml index ec46297abec3..ccd8bf04bef7 100644 --- a/.idea/libraries/Gant.xml +++ b/.idea/libraries/Gant.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Groovy.xml b/.idea/libraries/Groovy.xml index 82c7bd9c0740..39ef164c7fa7 100644 --- a/.idea/libraries/Groovy.xml +++ b/.idea/libraries/Groovy.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/JDOM.xml b/.idea/libraries/JDOM.xml index 17d2e7336796..bce78cc5489e 100644 --- a/.idea/libraries/JDOM.xml +++ b/.idea/libraries/JDOM.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/JMock1.xml b/.idea/libraries/JMock1.xml index ca4dac06d5e2..28bec95a2700 100644 --- a/.idea/libraries/JMock1.xml +++ b/.idea/libraries/JMock1.xml @@ -4,7 +4,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/JUnit3.xml b/.idea/libraries/JUnit3.xml index c8e5da0d1ec9..c1b662d9bfb0 100644 --- a/.idea/libraries/JUnit3.xml +++ b/.idea/libraries/JUnit3.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/JUnit4.xml b/.idea/libraries/JUnit4.xml index 6e7ba44fb1d0..3293fe32308b 100644 --- a/.idea/libraries/JUnit4.xml +++ b/.idea/libraries/JUnit4.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/JavaHelp.xml b/.idea/libraries/JavaHelp.xml index 458f03548750..a581fbd1d42b 100644 --- a/.idea/libraries/JavaHelp.xml +++ b/.idea/libraries/JavaHelp.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Jaxen.xml b/.idea/libraries/Jaxen.xml index dd17c6df93a6..8c9fa7adb99c 100644 --- a/.idea/libraries/Jaxen.xml +++ b/.idea/libraries/Jaxen.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/Log4J.xml b/.idea/libraries/Log4J.xml index 6e3948c15fc9..3179b1470772 100644 --- a/.idea/libraries/Log4J.xml +++ b/.idea/libraries/Log4J.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Mac.xml b/.idea/libraries/Mac.xml index 256d4c9e54a9..a12291d435e5 100644 --- a/.idea/libraries/Mac.xml +++ b/.idea/libraries/Mac.xml @@ -4,7 +4,6 @@ - diff --git a/.idea/libraries/Mocks.xml b/.idea/libraries/Mocks.xml index 5a52b9d16391..e4bf218554bf 100644 --- a/.idea/libraries/Mocks.xml +++ b/.idea/libraries/Mocks.xml @@ -12,7 +12,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/NanoXML.xml b/.idea/libraries/NanoXML.xml index b189c1aeccf4..0bb733ed7323 100644 --- a/.idea/libraries/NanoXML.xml +++ b/.idea/libraries/NanoXML.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/OroMatcher.xml b/.idea/libraries/OroMatcher.xml index 11cae893cfea..91713b2ea1e2 100644 --- a/.idea/libraries/OroMatcher.xml +++ b/.idea/libraries/OroMatcher.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/TestNG.xml b/.idea/libraries/TestNG.xml index 5ab2412b1a6e..a5778213fdef 100644 --- a/.idea/libraries/TestNG.xml +++ b/.idea/libraries/TestNG.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/Trove4j.xml b/.idea/libraries/Trove4j.xml index ffb447bb506b..3f41197d62e8 100644 --- a/.idea/libraries/Trove4j.xml +++ b/.idea/libraries/Trove4j.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Velocity.xml b/.idea/libraries/Velocity.xml index 6af932840678..3d7e67090faf 100644 --- a/.idea/libraries/Velocity.xml +++ b/.idea/libraries/Velocity.xml @@ -4,7 +4,6 @@ - diff --git a/.idea/libraries/XStream.xml b/.idea/libraries/XStream.xml index 1ae2bba6df3e..d910ea261e1e 100644 --- a/.idea/libraries/XStream.xml +++ b/.idea/libraries/XStream.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/Xerces.xml b/.idea/libraries/Xerces.xml index 70f9b6a585a0..c5dbcdcf4e97 100644 --- a/.idea/libraries/Xerces.xml +++ b/.idea/libraries/Xerces.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/XmlBeans.xml b/.idea/libraries/XmlBeans.xml index 9ba2a85a0698..77058a249a98 100644 --- a/.idea/libraries/XmlBeans.xml +++ b/.idea/libraries/XmlBeans.xml @@ -5,7 +5,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/XmlRPC.xml b/.idea/libraries/XmlRPC.xml index 4dc45f5b4c27..ac9c9a5dbc94 100644 --- a/.idea/libraries/XmlRPC.xml +++ b/.idea/libraries/XmlRPC.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/asm.xml b/.idea/libraries/asm.xml index 449c600c9d8d..183a1bb65b08 100644 --- a/.idea/libraries/asm.xml +++ b/.idea/libraries/asm.xml @@ -4,7 +4,6 @@ - diff --git a/.idea/libraries/commons_codec.xml b/.idea/libraries/commons_codec.xml index 3921ae1a3395..edbee5956ef0 100644 --- a/.idea/libraries/commons_codec.xml +++ b/.idea/libraries/commons_codec.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/commons_collections.xml b/.idea/libraries/commons_collections.xml index 489c3f067ebf..346eec1cf896 100644 --- a/.idea/libraries/commons_collections.xml +++ b/.idea/libraries/commons_collections.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/commons_lang.xml b/.idea/libraries/commons_lang.xml index ba16df792f70..735f56f94f1e 100644 --- a/.idea/libraries/commons_lang.xml +++ b/.idea/libraries/commons_lang.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/commons_net.xml b/.idea/libraries/commons_net.xml index 73d5abb5afc1..a67717822b3e 100644 --- a/.idea/libraries/commons_net.xml +++ b/.idea/libraries/commons_net.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/jcip.xml b/.idea/libraries/jcip.xml index 5109f151a699..1a6bfae9c4c1 100644 --- a/.idea/libraries/jcip.xml +++ b/.idea/libraries/jcip.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/jgoodies_forms.xml b/.idea/libraries/jgoodies_forms.xml index 0acd33f16bd7..6d2c19a1d4c8 100644 --- a/.idea/libraries/jgoodies_forms.xml +++ b/.idea/libraries/jgoodies_forms.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/jna.xml b/.idea/libraries/jna.xml index 8c0751775e1e..9fbb37eb48fc 100644 --- a/.idea/libraries/jna.xml +++ b/.idea/libraries/jna.xml @@ -4,7 +4,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/microba.xml b/.idea/libraries/microba.xml index 893e0dcc7f2a..771a1df5a98f 100644 --- a/.idea/libraries/microba.xml +++ b/.idea/libraries/microba.xml @@ -4,7 +4,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/picocontainer.xml b/.idea/libraries/picocontainer.xml index 0850ebb24085..e07ed90f94b5 100644 --- a/.idea/libraries/picocontainer.xml +++ b/.idea/libraries/picocontainer.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/tcServiceMessages.xml b/.idea/libraries/tcServiceMessages.xml index e3cc93f1d751..2117ae66d481 100644 --- a/.idea/libraries/tcServiceMessages.xml +++ b/.idea/libraries/tcServiceMessages.xml @@ -3,7 +3,6 @@ - From 1be17ebb83cf160910ae336bf82171da15a92717 Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 17:47:42 +0400 Subject: [PATCH 78/79] IDEA-47083 fix upperCase --- .../after.groovy.template | 1 - .../before.groovy.template | 1 - .../description.html | 7 ------- 3 files changed, 9 deletions(-) delete mode 100644 plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template delete mode 100644 plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template delete mode 100644 plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html diff --git a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template deleted file mode 100644 index 221308e2c833..000000000000 --- a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/after.groovy.template +++ /dev/null @@ -1 +0,0 @@ -def objects = [foo, bar] \ No newline at end of file diff --git a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template deleted file mode 100644 index 9944d004075f..000000000000 --- a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/before.groovy.template +++ /dev/null @@ -1 +0,0 @@ -def objects = new Object[] {foo, bar} diff --git a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html b/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html deleted file mode 100644 index a57eb1cb3c81..000000000000 --- a/plugins/groovy/resources/intentionDescriptions/convertJavaStyleArrayCreationIntention/description.html +++ /dev/null @@ -1,7 +0,0 @@ - - - -This intention converts java-style array creation to groovy syntax. - - - From bf30b4b438a84d658285fbd5bb65c5cd82a6bf35 Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Tue, 20 Jul 2010 17:51:03 +0400 Subject: [PATCH 79/79] IDEA-47083 fixUppercase step2 --- .../com/intellij/ui/classFilter/ClassFilterEditor.java | 8 ++++++-- .../after.groovy.template | 1 + .../before.groovy.template | 1 + .../description.html | 7 +++++++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/after.groovy.template create mode 100644 plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/before.groovy.template create mode 100644 plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/description.html diff --git a/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java b/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java index d2ebffc8bfbd..b475e65c66c4 100644 --- a/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java +++ b/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java @@ -29,9 +29,9 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.TableUtil; import com.intellij.ui.UIBundle; +import com.intellij.ui.table.JBTable; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.ItemRemovable; -import com.intellij.util.ui.Table; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -66,7 +66,7 @@ public class ClassFilterEditor extends JPanel { myAddClassButton = new JButton(getAddButtonText()); myAddPatternButton = new JButton(getAddPatternButtonText()); myRemoveButton = new JButton(UIBundle.message("button.remove")); - myTable = new Table(); + myTable = new JBTable(); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable); add(scrollPane, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 3, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 4, 4, 6), 0, 0)); @@ -347,4 +347,8 @@ public class ClassFilterEditor extends JPanel { TableUtil.removeSelectedItems(myTable); } } + + public void setAddPatternButtonVisible(boolean visible) { + myAddPatternButton.setVisible(visible); + } } diff --git a/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/after.groovy.template b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/after.groovy.template new file mode 100644 index 000000000000..221308e2c833 --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/after.groovy.template @@ -0,0 +1 @@ +def objects = [foo, bar] \ No newline at end of file diff --git a/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/before.groovy.template b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/before.groovy.template new file mode 100644 index 000000000000..9944d004075f --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/before.groovy.template @@ -0,0 +1 @@ +def objects = new Object[] {foo, bar} diff --git a/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/description.html b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/description.html new file mode 100644 index 000000000000..a57eb1cb3c81 --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/description.html @@ -0,0 +1,7 @@ + + + +This intention converts java-style array creation to groovy syntax. + + +