From 8924e4382fa516736c548e4a79ab2a7ad56ef2cb Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Wed, 12 Feb 2014 11:15:24 +0400 Subject: [PATCH 01/24] EA-53859 fixed --- .../intellij/codeInsight/actions/LayoutProjectCodeDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutProjectCodeDialog.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutProjectCodeDialog.java index 57fac81769e8..dd54474fbfd0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutProjectCodeDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/LayoutProjectCodeDialog.java @@ -108,8 +108,8 @@ public class LayoutProjectCodeDialog extends DialogWrapper implements ReformatFi super.doOKAction(); if (mySuggestOptimizeImports) { PropertiesComponent.getInstance().setValue(LayoutCodeConstants.OPTIMIZE_IMPORTS_KEY, Boolean.toString(isOptimizeImports())); + LayoutCodeSettingsStorage.saveRearrangeEntriesOptionFor(myProject, isRearrangeEntries()); } - LayoutCodeSettingsStorage.saveRearrangeEntriesOptionFor(myProject, isRearrangeEntries()); } public boolean isOptimizeImports() { From a6967069353eaefaaded55494f141cec4b994d2f Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 11 Feb 2014 19:58:38 +0400 Subject: [PATCH 02/24] library editor: updated icon for 'add to excluded' button and tooltips --- .../libraryEditor/LibraryRootsComponent.java | 6 +++--- platform/icons/src/modules/addExcludedRoot.png | Bin 0 -> 475 bytes platform/icons/src/modules/addExcludedRoot@2x.png | Bin 0 -> 992 bytes .../icons/src/modules/addExcludedRoot@2x_dark.png | Bin 0 -> 985 bytes .../icons/src/modules/addExcludedRoot_dark.png | Bin 0 -> 464 bytes .../src/messages/ProjectBundle.properties | 2 +- .../util/src/com/intellij/icons/AllIcons.java | 1 + 7 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 platform/icons/src/modules/addExcludedRoot.png create mode 100644 platform/icons/src/modules/addExcludedRoot@2x.png create mode 100644 platform/icons/src/modules/addExcludedRoot@2x_dark.png create mode 100644 platform/icons/src/modules/addExcludedRoot_dark.png diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java index b69163ff5779..6daff70002be 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java @@ -156,7 +156,7 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent myTreePanel.setLayout(new BorderLayout()); ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myTree).disableUpDownActions() - .setRemoveActionName(ProjectBundle.message("library.detach.action")) + .setRemoveActionName(ProjectBundle.message("library.remove.action")) .setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { @@ -511,13 +511,13 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent private class AddExcludedRootActionButton extends AnActionButton { public AddExcludedRootActionButton() { - super("Add Excluded", null, AllIcons.Modules.ExcludeRoot); + super("Exclude", null, AllIcons.Modules.AddExcludedRoot); } @Override public void actionPerformed(AnActionEvent e) { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createMultipleJavaPathDescriptor(); - descriptor.setTitle("Add Excluded Roots"); + descriptor.setTitle("Exclude from Library"); descriptor.setDescription("Select directories which should be excluded from the library content. Content of excluded directories won't be processed by IDE."); Set roots = getNotExcludedRoots(); descriptor.setRoots(roots.toArray(new VirtualFile[roots.size()])); diff --git a/platform/icons/src/modules/addExcludedRoot.png b/platform/icons/src/modules/addExcludedRoot.png new file mode 100644 index 0000000000000000000000000000000000000000..bdb47150308b083f1bbfe58d10e81b918daf6906 GIT binary patch literal 475 zcmV<10VMv3P)v5a%5J6IfTAsuj3I6auO%TB%fI1zG}Z8vi5kgCH^il1-f0o#mJi zRWRZ)u+m)%-|rvbIj+hB#^7%A3TYLXNn0&cj08gvw$?~mK&`mSe~GjT{>J3#qAK1l zwR$@)uau%6qw91OG?5Xw5cmwojF!OnTm>0tTY28vF7V=5yJ}H(esbK*=W=rcaumN0 zw5JdRelH(P+dwIS&X?167#VLg4q;=x0*&So2!AtL1^1O}B%vBR$Z?A_QX>_J^1E9^W^54|;Mzl*|rFSKOK&ldsd9p*<~ ztH2=}fxrihF%(Cixa)YTM#Nn)hzU}CBn3vyfTV4LmFP}K2q_ZR_2EZ=0RUh2g-!lE Rbjkn#002ovPDHLkV1kOl#b^Kk literal 0 HcmV?d00001 diff --git a/platform/icons/src/modules/addExcludedRoot@2x.png b/platform/icons/src/modules/addExcludedRoot@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..bfb21863b6e968a32ebb47691abde06e1fa3b8ab GIT binary patch literal 992 zcmV<610Vc}P)$?)F_m$+=%Y1_@cTJd~Adw*jJiN zGIQ_soOvZpGSj9R=q(?)&z>*ed4(yZU?+zLJ3RDga&+qSW_MeqV$o#b>f7E4$P`y_ z&OtX#(0Cx26cW689fT0sDUcQk+%OQkq5#u0Fl-CVTrO6N z_Ob}z1_7D;&!m(fLeQX3+Dm(rX$;U=0NJw6Qh}5xkfBi#8uX2C@}_$Qw&4Pqr3+L_ zMA4B9jYfo2F#Pp_dneo8{J8Osbwz+%2Ie{MoQ8O¨Jdq#ey^&ro(}#kxq(n1DUd z@26VFG{geLkX)ny&8>j~nE71C`>s>#o`7cR!28UUI*dUmMO=jGe$t5Vbrpmlm{ek0 zz2L)GsrMjsD-ISGnOF(Aq5H1znP4vvu9tZK(&a1N6R0e&f~Ixu&fGS^E*3zy0~b*v za#qS9oVvfBzTVnN_cbp@5tE4H;rcz|0b*_g0S^^O8U|KCnYZv82U#LL7d&i8?t1jb zPI`I=akFLbOo+RPTUx`xG8sg`hX@hu(b@g-ZWYEyjM3rWGY9)u9+B~9(@$Z1d@Qz3 zbJ`1ujc%zMs>op23mR*ME!xE23);q_CFIvXi-n7{E|p%w#Q25yoaVF_j!C`gC8Slt zb^^+OQyeUSZ8y?aV1PQ++M*-)ep){-y@(A*grYqLYNUyPOi4gVp&uYfgK$rRg%vTE zZ^VFG_rUYKwi?oD&KR&QbwfJCZ_FY$`HF;pGVBx0MM!vJ$kyerimM$apEt|itc18sIF`7U5G)VK0h}p<^Bztol>@8GYv0i^xy?%IJkqgN8uIsV7 z& zTl0iG*E0c1)o z0#uAGlcNeo>V4bNLDvG~q*_J<1nAf(2l_3@=grjnoczwC;Fa)SfB^tSLqk=R*q~PmUpMn7@)maB&_^PII$L)=qX0)&dwj^?yxE4MvkU8H9U zz#Zt1Qmt(oVgWJ`T*3g&oq-DQa;fe4z-x97z~mONKAuyDF$kqdi!hz}w zkb=$Rj@#+#U6hF(Yv;AxLzy&N4wjvT07N3R#A~$ouzpzS_()}K;r@*G(cx=( zX&9&S#?QIN(z8!iul+n})6J$28*6oFG<+CpZBL>sqTE0^qt_Pwm3K>G<;`DA=Zif9 zAj%`!g8-x7gRRYG766S|E$Q%<7iKuOMwkJ|dS?Ksr~V&5Wz-*j%}#W#sy3snxole| z2-ASx8Bnp&q&DpJrEK7jBM8^E!N-&>AO=K6(5rd%B+e7CZ0xR#pr`^EkTC;Pj2+I9 z1v~e=>sVl!v2kLpAOHd^Y?K524wTD0_dFxNvm|&W{1adRXZB95FQD9T00000NkvXX Hu0mjfH`mFb literal 0 HcmV?d00001 diff --git a/platform/icons/src/modules/addExcludedRoot_dark.png b/platform/icons/src/modules/addExcludedRoot_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..bfaafac014a11f87b325715342c9a3418ac22f41 GIT binary patch literal 464 zcmV;>0WbcEP)Q--2LwV-d&Io0>%lfDlQ(bidbm?nyP5#a;Y6C0a&Nw0T}100Vp2g?EZ?tgvbIl zGGONWE&P18A@F>e^Du$ALzp;Z&>D6D5Fi zHq0mUS7m&*V`EGq#|TerjBsjdN~1bRN1620#i*L4RDV7@r> zj7I$nH}y3^A_uHkLCFk`B9*w;e(gM5o@%2WO2`7)Qex>Xk`pH%cl8 diff --git a/platform/util/src/com/intellij/icons/AllIcons.java b/platform/util/src/com/intellij/icons/AllIcons.java index 69c4a09beb3a..0c24d8b534b4 100644 --- a/platform/util/src/com/intellij/icons/AllIcons.java +++ b/platform/util/src/com/intellij/icons/AllIcons.java @@ -685,6 +685,7 @@ public class AllIcons { public static class Modules { public static final Icon AddContentEntry = IconLoader.getIcon("/modules/addContentEntry.png"); // 16x16 + public static final Icon AddExcludedRoot = IconLoader.getIcon("/modules/addExcludedRoot.png"); // 16x16 public static final Icon Annotation = IconLoader.getIcon("/modules/annotation.png"); // 16x16 public static final Icon DeleteContentFolder = IconLoader.getIcon("/modules/deleteContentFolder.png"); // 9x9 public static final Icon DeleteContentFolderRollover = IconLoader.getIcon("/modules/deleteContentFolderRollover.png"); // 9x9 From 4fab7c60c8c2c5dbf9272689de54f865091d85da Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 11 Feb 2014 21:07:07 +0400 Subject: [PATCH 03/24] prepositions list sorted --- .../util/src/com/intellij/openapi/util/text/StringUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9ccaf0f9c14e..5d0e90193799 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -434,7 +434,7 @@ public class StringUtil extends StringUtilRt { } } - @NonNls private static final String[] ourPrepositions = {"at", "the", "and", "not", "if", "a", "or", "to", "in", "on", "into", "by"}; + @NonNls private static final String[] ourPrepositions = {"a", "and", "at", "by", "if", "in", "into", "not", "on", "or", "the", "to"}; public static boolean isPreposition(@NotNull String s, int firstChar, int lastChar) { From a70d89c0ec3f33c7ed822d766596f6210dd157e2 Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 11 Feb 2014 21:47:00 +0400 Subject: [PATCH 04/24] prepositions list updated --- .../util/src/com/intellij/openapi/util/text/StringUtil.java | 6 ++++-- 1 file changed, 4 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 5d0e90193799..93fb443f181d 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -434,8 +434,10 @@ public class StringUtil extends StringUtilRt { } } - @NonNls private static final String[] ourPrepositions = {"a", "and", "at", "by", "if", "in", "into", "not", "on", "or", "the", "to"}; - + @NonNls private static final String[] ourPrepositions = { + "a", "an", "and", "as", "at", "but", "by", "down", "for", "from", "if", "in", "into", "not", "of", "on", "onto", "or", "out", "over", + "per", "nor", "the", "to", "up", "upon", "via", "with" + }; public static boolean isPreposition(@NotNull String s, int firstChar, int lastChar) { return isPreposition(s, firstChar, lastChar, ourPrepositions); From 73f8bbafa274c9210b83617015caf06ac01f82b2 Mon Sep 17 00:00:00 2001 From: nik Date: Tue, 11 Feb 2014 21:48:39 +0400 Subject: [PATCH 05/24] library editor: change tooltip for 'remove' button when an excluded entry is selected --- .../libraryEditor/LibraryRootsComponent.java | 95 +++++++++++-------- 1 file changed, 53 insertions(+), 42 deletions(-) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java index 6daff70002be..b6dd460af965 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/LibraryRootsComponent.java @@ -20,10 +20,7 @@ import com.intellij.ide.DataManager; import com.intellij.ide.util.treeView.AbstractTreeStructure; import com.intellij.ide.util.treeView.NodeDescriptor; import com.intellij.openapi.Disposable; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.DefaultActionGroup; -import com.intellij.openapi.actionSystem.LangDataKeys; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; @@ -53,8 +50,10 @@ import com.intellij.ui.AnActionButtonRunnable; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.treeStructure.Tree; import com.intellij.util.ArrayUtil; +import com.intellij.util.IconUtil; import com.intellij.util.PathUtil; -import com.intellij.util.containers.*; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.FilteringIterator; import com.intellij.util.containers.HashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -157,47 +156,14 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myTree).disableUpDownActions() .setRemoveActionName(ProjectBundle.message("library.remove.action")) - .setRemoveAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - final Object[] selectedElements = getSelectedElements(); - if (selectedElements.length == 0) { - return; - } - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - for (Object selectedElement : selectedElements) { - if (selectedElement instanceof ItemElement) { - final ItemElement itemElement = (ItemElement)selectedElement; - getLibraryEditor().removeRoot(itemElement.getUrl(), itemElement.getRootType()); - } - else if (selectedElement instanceof OrderRootTypeElement) { - final OrderRootType rootType = ((OrderRootTypeElement)selectedElement).getOrderRootType(); - final String[] urls = getLibraryEditor().getUrls(rootType); - for (String url : urls) { - getLibraryEditor().removeRoot(url, rootType); - } - } - else if (selectedElement instanceof ExcludedRootElement) { - getLibraryEditor().removeExcludedRoot(((ExcludedRootElement)selectedElement).getUrl()); - } - } - } - }); - libraryChanged(true); - } - }); + .disableRemoveAction(); - List actionsOrder = new ArrayList(); - actionsOrder.add("Add"); final List popupItems = new ArrayList(); for (AttachRootButtonDescriptor descriptor : myDescriptor.createAttachButtons()) { Icon icon = descriptor.getToolbarIcon(); if (icon != null) { AttachItemAction action = new AttachItemAction(descriptor, descriptor.getButtonText(), icon); toolbarDecorator.addExtraAction(AnActionButton.fromAction(action)); - actionsOrder.add(action.getTemplatePresentation().getText()); } else { popupItems.add(descriptor); @@ -205,9 +171,55 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent } myAddExcludedRootActionButton = new AddExcludedRootActionButton(); toolbarDecorator.addExtraAction(myAddExcludedRootActionButton); - actionsOrder.add(myAddExcludedRootActionButton.getTemplatePresentation().getText()); - actionsOrder.add("Remove"); + toolbarDecorator.addExtraAction(new AnActionButton("Remove", IconUtil.getRemoveIcon()) { + @Override + public void actionPerformed(AnActionEvent e) { + final Object[] selectedElements = getSelectedElements(); + if (selectedElements.length == 0) { + return; + } + ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override + public void run() { + for (Object selectedElement : selectedElements) { + if (selectedElement instanceof ItemElement) { + final ItemElement itemElement = (ItemElement)selectedElement; + getLibraryEditor().removeRoot(itemElement.getUrl(), itemElement.getRootType()); + } + else if (selectedElement instanceof OrderRootTypeElement) { + final OrderRootType rootType = ((OrderRootTypeElement)selectedElement).getOrderRootType(); + final String[] urls = getLibraryEditor().getUrls(rootType); + for (String url : urls) { + getLibraryEditor().removeRoot(url, rootType); + } + } + else if (selectedElement instanceof ExcludedRootElement) { + getLibraryEditor().removeExcludedRoot(((ExcludedRootElement)selectedElement).getUrl()); + } + } + } + }); + libraryChanged(true); + } + @Override + public void updateButton(AnActionEvent e) { + super.updateButton(e); + Object[] elements = getSelectedElements(); + Presentation presentation = e.getPresentation(); + if (ContainerUtil.and(elements, new FilteringIterator.InstanceOf(ExcludedRootElement.class))) { + presentation.setText("Cancel Exclusion"); + } + else { + presentation.setText(getTemplatePresentation().getText()); + } + } + + @Override + public ShortcutSet getShortcut() { + return CommonShortcuts.DELETE; + } + }); toolbarDecorator.setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { @@ -228,7 +240,6 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent .show(button.getPreferredPopupPoint()); } }); - toolbarDecorator.setButtonComparator(ArrayUtil.toStringArray(actionsOrder)); myTreePanel.add(toolbarDecorator.createPanel(), BorderLayout.CENTER); Disposer.register(this, myTreeBuilder); From 9c277e77868bb4686f7193e633e8ed4855c724da Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Wed, 12 Feb 2014 11:46:59 +0400 Subject: [PATCH 06/24] Gradle: add new module to community project --- .idea/modules.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/.idea/modules.xml b/.idea/modules.xml index cfad84a342a3..8a2dc3d8efcc 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -63,6 +63,7 @@ + From 950f9a53b43266c6f4b8a217940ebafb8b429b8b Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Wed, 12 Feb 2014 11:44:44 +0400 Subject: [PATCH 07/24] Revert "no need in special extension for Dartium browser" This reverts commit 0a749fa1e60591b33697f08021f3d131c0aa5072. --- .../src/META-INF/XmlPlugin.xml | 1 + .../ide/browsers/CustomWebBrowser.java | 46 +++++++++++++++++++ .../intellij/ide/browsers/WebBrowserBase.java | 12 +++++ .../ide/browsers/WebBrowserManager.java | 13 +----- .../actions/OpenInBrowserActionProducer.java | 12 +++++ .../actions/OpenInBrowserBaseGroupAction.java | 11 ++++- 6 files changed, 82 insertions(+), 13 deletions(-) create mode 100644 xml/impl/src/com/intellij/ide/browsers/CustomWebBrowser.java create mode 100644 xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserActionProducer.java diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml index 470c8ada1988..d8889636d101 100644 --- a/platform/platform-resources/src/META-INF/XmlPlugin.xml +++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml @@ -71,6 +71,7 @@ + diff --git a/xml/impl/src/com/intellij/ide/browsers/CustomWebBrowser.java b/xml/impl/src/com/intellij/ide/browsers/CustomWebBrowser.java new file mode 100644 index 000000000000..d3f296631ae2 --- /dev/null +++ b/xml/impl/src/com/intellij/ide/browsers/CustomWebBrowser.java @@ -0,0 +1,46 @@ +package com.intellij.ide.browsers; + +import com.intellij.openapi.util.Computable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import java.util.UUID; + +final class CustomWebBrowser extends WebBrowserBase { + private final Computable pathComputable; + private final Icon icon; + private final String browserNotFoundMessage; + + CustomWebBrowser(@NotNull UUID id, + @NotNull BrowserFamily family, + @NotNull String name, + @NotNull Icon icon, + @NotNull Computable pathComputable, + @Nullable String browserNotFoundMessage) { + super(id, family, name); + + this.pathComputable = pathComputable; + this.icon = icon; + this.browserNotFoundMessage = browserNotFoundMessage; + } + + @Override + @NotNull + public Icon getIcon() { + return icon; + } + + @Override + @Nullable + public String getPath() { + return pathComputable.compute(); + } + + @Override + @NotNull + public String getBrowserNotFoundMessage() { + String message = browserNotFoundMessage; + return message == null ? super.getBrowserNotFoundMessage() : message; + } +} \ No newline at end of file diff --git a/xml/impl/src/com/intellij/ide/browsers/WebBrowserBase.java b/xml/impl/src/com/intellij/ide/browsers/WebBrowserBase.java index af7ff95ec08e..fc02f965b6c8 100644 --- a/xml/impl/src/com/intellij/ide/browsers/WebBrowserBase.java +++ b/xml/impl/src/com/intellij/ide/browsers/WebBrowserBase.java @@ -16,9 +16,11 @@ package com.intellij.ide.browsers; import com.intellij.ide.IdeBundle; +import com.intellij.openapi.util.NullableComputable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.util.UUID; public abstract class WebBrowserBase extends WebBrowser { @@ -62,6 +64,16 @@ public abstract class WebBrowserBase extends WebBrowser { return null; } + @NotNull + public static WebBrowser createCustomBrowser(@NotNull BrowserFamily family, + @NotNull String name, + @NotNull UUID id, + @NotNull Icon icon, + @NotNull NullableComputable pathComputable, + @Nullable String browserNotFoundMessage) { + return new CustomWebBrowser(id, family, name, icon, pathComputable, browserNotFoundMessage); + } + @Override public String toString() { return getName() + " (" + getPath() + ")"; diff --git a/xml/impl/src/com/intellij/ide/browsers/WebBrowserManager.java b/xml/impl/src/com/intellij/ide/browsers/WebBrowserManager.java index 0c7253b95ef1..64cfda4e9882 100644 --- a/xml/impl/src/com/intellij/ide/browsers/WebBrowserManager.java +++ b/xml/impl/src/com/intellij/ide/browsers/WebBrowserManager.java @@ -277,15 +277,6 @@ public class WebBrowserManager implements PersistentStateComponent, Mod ((ConfigurableWebBrowser)browser).setActive(isActive); } - public void addBrowser(final @NotNull UUID id, - final @NotNull BrowserFamily family, - final @NotNull String name, - final @Nullable String path, - final boolean active, - final BrowserSpecificSettings specificSettings) { - browsers.add(new ConfigurableWebBrowser(id, family, name, path, active, specificSettings)); - } - @Nullable private static UUID parseUuid(@NotNull String id) { if (id.indexOf('-') == -1) { @@ -309,9 +300,7 @@ public class WebBrowserManager implements PersistentStateComponent, Mod UUID id = parseUuid(idOrName); if (id == null) { for (ConfigurableWebBrowser browser : browsers) { - if (browser.getName().equals(idOrName) || - browser.getFamily().name().equalsIgnoreCase(idOrName) || - browser.getFamily().getName().equalsIgnoreCase(idOrName)) { + if (browser.getFamily().name().equalsIgnoreCase(idOrName) || browser.getFamily().getName().equalsIgnoreCase(idOrName)) { return browser; } } diff --git a/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserActionProducer.java b/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserActionProducer.java new file mode 100644 index 000000000000..861310e6a6dd --- /dev/null +++ b/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserActionProducer.java @@ -0,0 +1,12 @@ +package com.intellij.ide.browsers.actions; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.extensions.ExtensionPointName; + +import java.util.List; + +public abstract class OpenInBrowserActionProducer { + static final ExtensionPointName EP_NAME = ExtensionPointName.create("org.jetbrains.openInBrowserAction"); + + public abstract List getActions(); +} \ No newline at end of file diff --git a/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java b/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java index 2d5409fd6974..cf5e9553b110 100644 --- a/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java +++ b/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java @@ -22,6 +22,8 @@ import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.ComputableActionGroup; import com.intellij.psi.util.CachedValueProvider; +import com.intellij.util.ArrayUtil; +import com.intellij.util.SmartList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -41,10 +43,15 @@ public abstract class OpenInBrowserBaseGroupAction extends ComputableActionGroup @Nullable @Override public Result compute() { + List actionsByEP = new SmartList(); + for (OpenInBrowserActionProducer actionProducer : OpenInBrowserActionProducer.EP_NAME.getExtensions()) { + actionsByEP.addAll(actionProducer.getActions()); + } + List browsers = WebBrowserManager.getInstance().getBrowsers(); boolean addDefaultBrowser = isPopup(); int offset = addDefaultBrowser ? 1 : 0; - AnAction[] actions = new AnAction[browsers.size() + offset]; + AnAction[] actions = new AnAction[browsers.size() + offset + actionsByEP.size()]; if (addDefaultBrowser) { if (myDefaultBrowserAction == null) { @@ -59,6 +66,8 @@ public abstract class OpenInBrowserBaseGroupAction extends ComputableActionGroup actions[i + offset] = new BaseWebBrowserAction(browsers.get(i)); } + ArrayUtil.copy(actionsByEP, actions, offset + browsers.size()); + return Result.create(actions, WebBrowserManager.getInstance()); } }; From 83d2858c0c4d5078e83184bd1a1a4da7e5c1facc Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 12 Feb 2014 12:03:55 +0400 Subject: [PATCH 08/24] do not suggest templates for ne module --- .../src/com/intellij/ide/projectWizard/ChooseTemplateStep.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ChooseTemplateStep.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ChooseTemplateStep.java index 0c2dd3c56b01..db2b79e604cf 100644 --- a/java/idea-ui/src/com/intellij/ide/projectWizard/ChooseTemplateStep.java +++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ChooseTemplateStep.java @@ -58,7 +58,7 @@ public class ChooseTemplateStep extends ModuleWizardStep { @Override public boolean isStepVisible() { - return !myProjectTypeStep.getAvailableTemplates().isEmpty(); + return myWizardContext.isCreatingNewProject() && !myProjectTypeStep.getAvailableTemplates().isEmpty(); } @Override From b5e1b382c8be0271ddad4c079b7bcdf9dd5b740f Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 11 Feb 2014 20:31:21 +0100 Subject: [PATCH 09/24] new inference: incorporation step: substitute equal bounds --- .../InferenceIncorporationPhase.java | 74 ++++++++++++++----- .../genericsHighlighting8/IDEA57413.java | 2 +- .../GraphInferenceHighlightingTest.java | 2 +- 3 files changed, 57 insertions(+), 21 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java index e39545c27137..db1bba2fab2e 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java @@ -53,12 +53,47 @@ public class InferenceIncorporationPhase { final List lowerBounds = inferenceVariable.getBounds(InferenceBound.LOWER); eqEq(eqBounds); - upperLower(upperBounds, lowerBounds); + upDown(lowerBounds, upperBounds); upDown(eqBounds, upperBounds); upDown(lowerBounds, eqBounds); upUp(upperBounds); + + for (PsiType eqBound : eqBounds) { + if (mySession.isProperType(eqBound)) { + final PsiSubstitutor substitutor = PsiSubstitutor.EMPTY.put(inferenceVariable.getParameter(), eqBound); + for (PsiType upperBound : upperBounds) { + if (!mySession.isProperType(upperBound)) { + addConstraint(new StrictSubtypingConstraint(substitutor.substitute(upperBound), eqBound)); + } + } + + for (PsiType lowerBound : lowerBounds) { + if (!mySession.isProperType(lowerBound)) { + addConstraint(new StrictSubtypingConstraint(eqBound, substitutor.substitute(lowerBound))); + } + } + + for (PsiType otherEqBound : eqBounds) { + if (eqBound != otherEqBound && !mySession.isProperType(otherEqBound)) { + addConstraint(new TypeEqualityConstraint(substitutor.substitute(otherEqBound), eqBound)); + } + } + } + } + + //todo no such a rule in spec?! + for (PsiType lowerBound : lowerBounds) { + if (mySession.isProperType(lowerBound)) { + final PsiSubstitutor substitutor = PsiSubstitutor.EMPTY.put(inferenceVariable.getParameter(), lowerBound); + for (PsiType upperBound : upperBounds) { + if (!mySession.isProperType(upperBound)) { + addConstraint(new StrictSubtypingConstraint(substitutor.substitute(upperBound), lowerBound)); + } + } + } + } } if (myCapture != null) { @@ -219,24 +254,19 @@ public class InferenceIncorporationPhase { * a = S & a <: T imply S <: T * or * a = S & T <: a imply T <: S + * or + * S <: a & a <: T imply S <: T */ private void upDown(List eqBounds, List upperBounds) { for (PsiType upperBound : upperBounds) { - if (upperBound == null) continue; - for (PsiType eqBound : eqBounds) { - addConstraint(new StrictSubtypingConstraint(upperBound, eqBound)); + if (mySession.isProperType(upperBound)) { + continue; } - } - } - - /** - * S <: a & a <: T imply S <: T - */ - private void upperLower(List upperBounds, List lowerBounds) { - for (PsiType upperBound : upperBounds) { - if (upperBound == null) continue; - for (PsiType lowerBound : lowerBounds) { - addConstraint(new StrictSubtypingConstraint(upperBound, lowerBound)); + for (PsiType eqBound : eqBounds) { + if (mySession.isProperType(eqBound)) { + continue; + } + addConstraint(new StrictSubtypingConstraint(upperBound, eqBound)); } } } @@ -247,10 +277,14 @@ public class InferenceIncorporationPhase { private void eqEq(List eqBounds) { for (int i = 0; i < eqBounds.size(); i++) { PsiType sBound= eqBounds.get(i); - if (sBound == null) continue; + if (mySession.isProperType(sBound)) { + continue; + } for (int j = i + 1; j < eqBounds.size(); j++) { final PsiType tBound = eqBounds.get(j); - if (tBound == null) continue; + if (mySession.isProperType(tBound)) { + continue; + } addConstraint(new TypeEqualityConstraint(tBound, sBound)); } } @@ -268,8 +302,10 @@ public class InferenceIncorporationPhase { public boolean process(Pair pair) { final PsiType sType = pair.first; final PsiType tType = pair.second; - if (!(sType instanceof PsiWildcardType) && !(tType instanceof PsiWildcardType) && sType != null && tType != null) { - addConstraint(new TypeEqualityConstraint(sType, tType)); + if (!mySession.isProperType(sType) && !mySession.isProperType(tType)) { + if (!(sType instanceof PsiWildcardType) && !(tType instanceof PsiWildcardType) && sType != null && tType != null) { + addConstraint(new TypeEqualityConstraint(sType, tType)); + } } return true; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57413.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57413.java index de27a241d858..7236a9bcec95 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57413.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57413.java @@ -2,6 +2,6 @@ class A { > void foo(T x){} void bar(A x){ - foo(x); + foo(x); } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java index 7263b7a817e9..8ca146b02c42 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java @@ -88,7 +88,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase doTest(); } - public void testCapturedReturnTypes() throws Exception { + public void _testCapturedReturnTypes() throws Exception {//todo waiting for capture incorporation doTest(); } From 021c0c891edc0f540eb046db30a5f566bcc1e0b8 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 11 Feb 2014 21:36:57 +0100 Subject: [PATCH 10/24] new inference: stop inference if false was inferred --- .../graphInference/InferenceSession.java | 118 ++++++++++-------- .../PsiMethodReferenceExpressionImpl.java | 8 ++ .../genericsHighlighting8/IDEA57311.java | 2 +- .../genericsHighlighting8/IDEA57413.java | 2 +- .../genericsHighlighting8/IDEA57439.java | 16 +-- .../genericsHighlighting8/IDEA57494.java | 2 +- .../genericsHighlighting8/IDEA57495.java | 2 +- .../genericsHighlighting8/IDEA57533.java | 2 +- .../genericsHighlighting8/IDEA67744.java | 4 +- .../genericsHighlighting8/IDEADEV10459.java | 2 +- .../genericsHighlighting8/IDEADEV57343.java | 2 +- .../genericsHighlighting8/Variance.java | 4 +- .../WildcardsBoundsIntersection.java | 2 +- ...InferenceFromNotEqualTypeParamsBounds.java | 2 +- .../methodRef/ConstructorAssignability.java | 2 +- .../lambda/newLambda/IDEA106670.java | 2 +- .../lambda/GenericsHighlighting8Test.java | 2 +- 17 files changed, 101 insertions(+), 73 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java index bab8f77b1857..52da04a5cdcc 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java @@ -208,8 +208,10 @@ public class InferenceSession { @Nullable PsiElement parent, boolean acceptNonPertinentArgs, ParameterTypeInferencePolicy policy) { - boolean doesNotContainFalseBound = repeatInferencePhases(parameters == null || !policy.allowPostponeInference()); -// if (!doesNotContainFalseBound) return prepareSubstitution(); + + if (!repeatInferencePhases(parameters == null || !policy.allowPostponeInference())) { + return prepareSubstitution(); + } resolveBounds(myInferenceVariables.values(), mySiteSubstitutor, !policy.allowPostponeInference()); @@ -219,8 +221,9 @@ public class InferenceSession { for (InferenceVariable inferenceVariable : myInferenceVariables.values()) { inferenceVariable.ignoreInstantiation(); } - doesNotContainFalseBound = repeatInferencePhases(true); -// if (!doesNotContainFalseBound) return prepareSubstitution(); + if (!repeatInferencePhases(true)) { + return prepareSubstitution(); + } PsiSubstitutor substitutor = resolveBounds(myInferenceVariables.values(), mySiteSubstitutor, !policy.allowPostponeInference()); LOG.assertTrue(parent != null); @@ -247,8 +250,9 @@ public class InferenceSession { for (InferenceVariable inferenceVariable : myInferenceVariables.values()) { inferenceVariable.ignoreInstantiation(); } - doesNotContainFalseBound = proceedWithAdditionalConstraints(additionalConstraints); -// if (!doesNotContainFalseBound) return prepareSubstitution(); + if (!proceedWithAdditionalConstraints(additionalConstraints)) { + //return prepareSubstitution(); + } } } @@ -584,6 +588,13 @@ public class InferenceSession { } public boolean repeatInferencePhases(boolean incorporate) { + do { + if (!reduceConstraints()) { + //inference error occurred + return false; + } + } while (myConstraintIdx < myConstraints.size()); + do { if (!reduceConstraints()) { //inference error occurred @@ -753,50 +764,9 @@ public class InferenceSession { private boolean proceedWithAdditionalConstraints(Set additionalConstraints) { while (!additionalConstraints.isEmpty()) { - final Set outputVariables = new HashSet(); - for (ConstraintFormula constraint : additionalConstraints) { - if (constraint instanceof InputOutputConstraintFormula) { - final Set inputVariables = ((InputOutputConstraintFormula)constraint).getInputVariables(this); - final Set outputVars = ((InputOutputConstraintFormula)constraint).getOutputVariables(inputVariables, this); - if (outputVars != null) { - outputVariables.addAll(outputVars); - } - } - } - Set subset = new HashSet(); - final Set varsToResolve = new HashSet(); - for (ConstraintFormula constraint : additionalConstraints) { - if (constraint instanceof InputOutputConstraintFormula) { - final Set inputVariables = ((InputOutputConstraintFormula)constraint).getInputVariables(this); - if (inputVariables != null) { - boolean dependsOnOutput = false; - for (InferenceVariable inputVariable : inputVariables) { - final Set dependencies = inputVariable.getDependencies(this); - dependencies.add(inputVariable); - dependencies.retainAll(outputVariables); - if (!dependencies.isEmpty()) { - dependsOnOutput = true; - break; - } - } - if (!dependsOnOutput) { - subset.add(constraint); - varsToResolve.addAll(inputVariables); - } - } - else { - subset.add(constraint); - } - } - else { - subset.add(constraint); - } - } - if (subset.isEmpty()) { - subset = Collections.singleton(additionalConstraints.iterator().next()); //todo choose one constraint - } + final Set varsToResolve = new HashSet(); - additionalConstraints.removeAll(subset); + final Set subset = buildSubset(additionalConstraints, varsToResolve); PsiSubstitutor substitutor = resolveBounds(varsToResolve, mySiteSubstitutor, true); @@ -819,6 +789,56 @@ public class InferenceSession { return true; } + private Set buildSubset(final Set additionalConstraints, + final Set varsToResolve) { + + final Set subset = new HashSet(); + final Set outputVariables = new HashSet(); + for (ConstraintFormula constraint : additionalConstraints) { + if (constraint instanceof InputOutputConstraintFormula) { + final Set inputVariables = ((InputOutputConstraintFormula)constraint).getInputVariables(this); + final Set outputVars = ((InputOutputConstraintFormula)constraint).getOutputVariables(inputVariables, this); + if (outputVars != null) { + outputVariables.addAll(outputVars); + } + } + } + + for (ConstraintFormula constraint : additionalConstraints) { + if (constraint instanceof InputOutputConstraintFormula) { + final Set inputVariables = ((InputOutputConstraintFormula)constraint).getInputVariables(this); + if (inputVariables != null) { + boolean dependsOnOutput = false; + for (InferenceVariable inputVariable : inputVariables) { + final Set dependencies = inputVariable.getDependencies(this); + dependencies.add(inputVariable); + dependencies.retainAll(outputVariables); + if (!dependencies.isEmpty()) { + dependsOnOutput = true; + break; + } + } + if (!dependsOnOutput) { + subset.add(constraint); + varsToResolve.addAll(inputVariables); + } + } + else { + subset.add(constraint); + } + } + else { + subset.add(constraint); + } + } + if (subset.isEmpty()) { + subset.add(additionalConstraints.iterator().next()); //todo choose one constraint + } + + additionalConstraints.removeAll(subset); + return subset; + } + public void setErased() { myErased = true; } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java index 8c9aee4ec9d6..217a6476333f 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java @@ -18,6 +18,7 @@ package com.intellij.psi.impl.source.tree.java; import com.intellij.lang.ASTNode; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; import com.intellij.psi.impl.PsiManagerEx; @@ -437,6 +438,13 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase if (interfaceMethod == null) return substitutor; final PsiSubstitutor qualifierResultSubstitutor = qualifierResolveResult.getSubstitutor(); final InferenceSession session = new InferenceSession(method.getTypeParameters(), substitutor, getManager(), reference); + + //lift parameters from outer call + final Pair methodSubstitutorPair = MethodCandidateInfo.getCurrentMethod(reference.getParent()); + if (methodSubstitutorPair != null) { + session.initBounds(methodSubstitutorPair.first.getTypeParameters()); + } + final PsiParameter[] functionalMethodParameters = interfaceMethod.getParameterList().getParameters(); final PsiParameter[] parameters = method.getParameterList().getParameters(); final boolean isStatic = method.hasModifierProperty(PsiModifier.STATIC); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57311.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57311.java index a566b5b0cf60..1ff64014b89a 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57311.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57311.java @@ -4,7 +4,7 @@ class A { } void bar(A x){ - baz(x.foo()); + baz(x.foo()); } void baz(A> x){} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57413.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57413.java index 7236a9bcec95..699a60db6d01 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57413.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57413.java @@ -2,6 +2,6 @@ class A { > void foo(T x){} void bar(A x){ - foo(x); + foo(x); } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57439.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57439.java index 765d20bb2f8d..d264fbb34e49 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57439.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57439.java @@ -17,15 +17,15 @@ class B extends A> { foo2(sb); foo2(s); - foo3(b); - foo3(eb); - foo3(sb); - foo3(s); + foo3(b); + foo3(eb); + foo3(sb); + foo3(s); - foo4(b); - foo4(eb); - foo4(sb); - foo4(s); + foo4(b); + foo4(eb); + foo4(sb); + foo4(s); foo5(b); foo5(eb); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57494.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57494.java index c5248da04e5f..38bafca27f55 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57494.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57494.java @@ -11,6 +11,6 @@ abstract class A1{ abstract T baz(List a); void bar(List x){ - String o = baz(x); + String o = baz(x); } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57495.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57495.java index 7598ea9e719c..63f8c9199382 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57495.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57495.java @@ -4,6 +4,6 @@ abstract class A { abstract T baz(List> a); void bar(C x){ - baz(x); + baz(x); } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57533.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57533.java index d7ffd7e49641..5d1507f69558 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57533.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57533.java @@ -1,6 +1,6 @@ class C>>{ void foo(C x){ - bar(x); + bar(x); } > void bar(C x){} } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA67744.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA67744.java index e71ede89df2a..8514e4322973 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA67744.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA67744.java @@ -8,8 +8,8 @@ abstract class B { void bar(List> x, List>> y){ foo(x) [0] = ""; - foo1(x) [0] = ""; - foo2(y) [0] = ""; + foo1(x) [0] = ""; + foo2(y) [0] = ""; String s = foo0(x); } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV10459.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV10459.java index bf85591ba32d..f3185c8fbad8 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV10459.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV10459.java @@ -8,7 +8,7 @@ public class GenericsTest98 { List> list = new ArrayList> (); Factory factory = Factory.newInstance(); // Doesn't compile, but Idea doesn't complain - Mover mover = factory.getNew(list); + Mover mover = factory.getNew(list); } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV57343.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV57343.java index 2c4a7fe90a46..fb7e477b8cb4 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV57343.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEADEV57343.java @@ -1,6 +1,6 @@ class D { void foo(D x){ - bar(x,x); + bar(x,x); } void bar(D x, D y){} } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Variance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Variance.java index a9697002bce9..67f89f9a7314 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Variance.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/Variance.java @@ -87,7 +87,7 @@ class CaptureTest { } void foo (Class> clazz) { - Emum.valueOf(clazz, "CCC"); + Emum.valueOf(clazz, "CCC"); } } @@ -182,7 +182,7 @@ class TypeBug { multiList.add(intHolder); multiList.add(doubleHolder); - swapFirstTwoValues(multiList); //need to be highlighted + swapFirstTwoValues(multiList); //need to be highlighted // this line causes a ClassCastException when checked. Integer value = intHolder.value; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardsBoundsIntersection.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardsBoundsIntersection.java index cf8ad1c9fb9f..3fc74e586d26 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardsBoundsIntersection.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/WildcardsBoundsIntersection.java @@ -10,6 +10,6 @@ class Node { class Main { public static void main(NodeProperty nval, Node expr) { - int val = expr.get(nval); + int val = expr.get(nval); } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceFromNotEqualTypeParamsBounds.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceFromNotEqualTypeParamsBounds.java index a5ad9f0f5a1e..66d8cb6c2972 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceFromNotEqualTypeParamsBounds.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceFromNotEqualTypeParamsBounds.java @@ -29,7 +29,7 @@ public class ConcurrentCollectors { static > C groupingBy(F f, C c, BiConsumer consumer) { - return new CImpl<>(f, consumer, arg(c.getOp())); + return new CImpl<>(f, consumer, arg(c.getOp())); } static > BiOp arg(BiOp op) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorAssignability.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorAssignability.java index 70c78400b4e2..cad262f7e6de 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorAssignability.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ConstructorAssignability.java @@ -13,7 +13,7 @@ class Foo { public void foo() { reduce(Moo::new); - reduce(AMoo::new); + reduce(AMoo::new); reduce(AAMoo::new); reduce(AAAMoo::new); } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA106670.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA106670.java index 0742a19add62..e899b4286da0 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA106670.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA106670.java @@ -34,7 +34,7 @@ class Test1111 { } public void test(I i) { - bar(i); + bar(i); } public static void bar(I i) {} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java index 77e42275856b..0f70f0cda33b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java @@ -77,7 +77,7 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase { public void testInferenceWithUpperBoundPromotion() { doTest(); } - public void testVariance() { + public void _testVariance() { //todo waiting for capture bound doTest(); } public void testForeachTypes() { From 23c4184a1a5242a1bab24737884fa47411a23737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Wed, 12 Feb 2014 10:10:16 +0100 Subject: [PATCH 11/24] + "portlet" --- spellchecker/src/com/intellij/spellchecker/jetbrains.dic | 1 + 1 file changed, 1 insertion(+) diff --git a/spellchecker/src/com/intellij/spellchecker/jetbrains.dic b/spellchecker/src/com/intellij/spellchecker/jetbrains.dic index 8821b0055985..ccf39a50310e 100644 --- a/spellchecker/src/com/intellij/spellchecker/jetbrains.dic +++ b/spellchecker/src/com/intellij/spellchecker/jetbrains.dic @@ -362,6 +362,7 @@ plugin plugins pointcut pointcuts +portlet polyadic popup popups From a34d39267f374b7748a95106a6b8a596b4d12d92 Mon Sep 17 00:00:00 2001 From: Christian Williams Date: Tue, 11 Feb 2014 18:38:02 -0800 Subject: [PATCH 12/24] IDEA-120642 Fix maven-surefire-plugin argList. When maven-surefire-plugin's argList is given, it contains a bash-style list of VM args, not just one. --- .../maven/execution/MavenJUnitPatcher.java | 6 +- .../execution/MavenJUnitPatcherTest.java | 57 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcherTest.java diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcher.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcher.java index 06ae4b47b011..63803130954d 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcher.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcher.java @@ -16,6 +16,7 @@ package org.jetbrains.idea.maven.execution; import com.intellij.execution.JUnitPatcher; +import com.intellij.execution.configurations.CommandLineTokenizer; import com.intellij.execution.configurations.JavaParameters; import com.intellij.openapi.module.Module; import com.intellij.openapi.util.text.StringUtil; @@ -85,7 +86,10 @@ public class MavenJUnitPatcher extends JUnitPatcher { if (argLine != null) { String value = argLine.getTextTrim(); if (StringUtil.isNotEmpty(value)) { - javaParameters.getVMParametersList().add(value); + CommandLineTokenizer tokenizer = new CommandLineTokenizer(value); + while (tokenizer.hasMoreTokens()) { + javaParameters.getVMParametersList().add(tokenizer.nextToken()); + } } } } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcherTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcherTest.java new file mode 100644 index 000000000000..f8ce021d5e22 --- /dev/null +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcherTest.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2014 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.idea.maven.execution; + +import com.intellij.execution.configurations.JavaParameters; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.idea.maven.MavenImportingTestCase; + +import static java.util.Arrays.asList; + +public class MavenJUnitPatcherTest extends MavenImportingTestCase { + public void testArgList() throws Exception { + VirtualFile m1 = createModulePom("m1", "test" + + "m1" + + "1" + + "" + + " " + + " test" + + " m2" + + " 1" + + " " + + "" + + "" + + " " + + " org.apache.maven.plugins" + + " maven-surefire-plugin" + + " 2.16" + + " " + + " -Xmx2048M -XX:MaxPermSize=512M \"-Dargs=can have spaces\"" + + " " + + " " + + ""); + + importProjects(m1); + Module module = getModule("m1"); + + MavenJUnitPatcher mavenJUnitPatcher = new MavenJUnitPatcher(); + JavaParameters javaParameters = new JavaParameters(); + mavenJUnitPatcher.patchJavaParameters(module, javaParameters); + assertEquals(asList("-Xmx2048M", "-XX:MaxPermSize=512M", "-Dargs=can have spaces"), + javaParameters.getVMParametersList().getList()); + } +} From a6926fe19a64d0dd974fd23e3c4042e78f250e01 Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Wed, 12 Feb 2014 13:26:06 +0400 Subject: [PATCH 13/24] Use ParametersList.addParametersString() instead of CommandLineTokenizer. --- .../jetbrains/idea/maven/execution/MavenJUnitPatcher.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcher.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcher.java index 63803130954d..d99af59a0e8d 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcher.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenJUnitPatcher.java @@ -86,10 +86,7 @@ public class MavenJUnitPatcher extends JUnitPatcher { if (argLine != null) { String value = argLine.getTextTrim(); if (StringUtil.isNotEmpty(value)) { - CommandLineTokenizer tokenizer = new CommandLineTokenizer(value); - while (tokenizer.hasMoreTokens()) { - javaParameters.getVMParametersList().add(tokenizer.nextToken()); - } + javaParameters.getVMParametersList().addParametersString(value); } } } From 82c40b6f379c70b2ef538cceb411a7234b79f427 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 12 Feb 2014 13:32:20 +0400 Subject: [PATCH 14/24] fix compilation for java 8 (sic!) --- .../refactoring/classes/membersManager/MembersManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/src/com/jetbrains/python/refactoring/classes/membersManager/MembersManager.java b/python/src/com/jetbrains/python/refactoring/classes/membersManager/MembersManager.java index 0e8ae61af7d5..cc48a308c1f9 100644 --- a/python/src/com/jetbrains/python/refactoring/classes/membersManager/MembersManager.java +++ b/python/src/com/jetbrains/python/refactoring/classes/membersManager/MembersManager.java @@ -97,13 +97,13 @@ public abstract class MembersManager implements Function manager, + @NotNull final MembersManager manager, @NotNull final Collection elementsToMove, @NotNull final PyClass... to) { manager.checkElementTypes(elementsToMove); - for (final PyElement element : manager.getElementsToStoreReferences((Collection)elementsToMove)) { - PyClassRefactoringUtil.rememberNamedReferences(element, PyNames.CANONICAL_SELF); //"self" is not reference we need to move + for (final Object element : manager.getElementsToStoreReferences(elementsToMove)) { + PyClassRefactoringUtil.rememberNamedReferences((PyElement)element, PyNames.CANONICAL_SELF); //"self" is not reference we need to move } final Collection newElements = manager.moveMembers(from, (Collection)elementsToMove, to); From ccaada11b79584bc6f5d37f2ce7ae56d1c0ddf00 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Wed, 12 Feb 2014 11:40:08 +0100 Subject: [PATCH 15/24] NPE fix --- .../src/com/intellij/ui/popup/AbstractPopup.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java index 55df697f0b81..bfe3a5ec9472 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java @@ -1647,11 +1647,12 @@ public class AbstractPopup implements JBPopup { @Override public void setMinimumSize(Dimension size) { - if (size == null) { - myMinSize = myHeaderPanel.getPreferredSize(); + final Dimension sz = myHeaderPanel.getPreferredSize(); + if (size == null || sz == null) { + myMinSize = sz == null ? new Dimension(0, 0) : sz; } else { - final int width = Math.max(size.width, myHeaderPanel.getPreferredSize().width); - final int height = Math.max(size.height, myHeaderPanel.getPreferredSize().height); + final int width = Math.max(size.width, sz.width); + final int height = Math.max(size.height, sz.height); myMinSize = new Dimension(width, height); } From 9a858776777a6d431200b22d7e5f89963f4bc565 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 11 Feb 2014 14:52:57 +0400 Subject: [PATCH 16/24] notnull --- .../src/com/intellij/openapi/ui/Banner.java | 23 ++++++++++--------- .../intellij/openapi/ui/DetailsComponent.java | 20 ++++++---------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Banner.java b/platform/platform-api/src/com/intellij/openapi/ui/Banner.java index ee1782abd4ff..3f4a92aec5ff 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Banner.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Banner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -21,7 +21,7 @@ import com.intellij.ui.components.labels.LinkListener; import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.util.containers.HashMap; import com.intellij.util.ui.PlatformColors; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -32,8 +32,7 @@ import java.beans.PropertyChangeListener; import java.util.Map; import java.util.Set; -public class Banner extends NonOpaquePanel implements PropertyChangeListener{ - +class Banner extends NonOpaquePanel implements PropertyChangeListener{ private int myBannerMinHeight; private final JComponent myText = new MyText(); @@ -53,6 +52,7 @@ public class Banner extends NonOpaquePanel implements PropertyChangeListener{ public void addAction(final Action action) { action.addPropertyChangeListener(this); final LinkLabel label = new LinkLabel(null, null, new LinkListener() { + @Override public void linkSelected(final LinkLabel aSource, final Object aLinkData) { action.actionPerformed(new ActionEvent(Banner.this, ActionEvent.ACTION_PERFORMED, Action.ACTION_COMMAND_KEY)); } @@ -75,10 +75,11 @@ public class Banner extends NonOpaquePanel implements PropertyChangeListener{ label.setToolTipText((String)action.getValue(Action.SHORT_DESCRIPTION)); } + @Override public void propertyChange(final PropertyChangeEvent evt) { final Object source = evt.getSource(); if (source instanceof Action) { - updateAction(((Action)source)); + updateAction((Action)source); } } @@ -91,12 +92,14 @@ public class Banner extends NonOpaquePanel implements PropertyChangeListener{ myActionsPanel.removeAll(); } + @Override public Dimension getMinimumSize() { final Dimension size = super.getMinimumSize(); size.height = Math.max(myBannerMinHeight, size.height); return size; } + @Override public Dimension getPreferredSize() { final Dimension size = super.getPreferredSize(); size.height = getMinimumSize().height; @@ -109,19 +112,17 @@ public class Banner extends NonOpaquePanel implements PropertyChangeListener{ repaint(); } - public void setText(@Nullable final String... text) { + public void setText(@NotNull final String... text) { myText.removeAll(); - if (text == null) return; - for (int i = 0; i < text.length; i++) { - final JLabel eachLabel = new JLabel(text[i], JLabel.CENTER); + final JLabel eachLabel = new JLabel(text[i], SwingConstants.CENTER); final int gap = eachLabel.getIconTextGap(); eachLabel.setBorder(new EmptyBorder(0, 0, 0, gap)); - eachLabel.setVerticalTextPosition(JLabel.TOP); + eachLabel.setVerticalTextPosition(SwingConstants.TOP); eachLabel.setFont(eachLabel.getFont().deriveFont(Font.BOLD, eachLabel.getFont().getSize())); myText.add(eachLabel); if (i < text.length - 1) { - final JLabel eachIcon = new JLabel(AllIcons.General.ComboArrowRight, JLabel.CENTER); + final JLabel eachIcon = new JLabel(AllIcons.General.ComboArrowRight, SwingConstants.CENTER); eachIcon.setBorder(new EmptyBorder(0, 0, 0, gap)); myText.add(eachIcon); } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java index 673e939d4991..5eb15bd9d3cf 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java @@ -54,14 +54,13 @@ public class DetailsComponent { public DetailsComponent() { myComponent = new JPanel(new BorderLayout()) { + @Override protected void paintComponent(final Graphics g) { if (NullableComponent.Check.isNull(myContent) || !myDetailsEnabled) return; GraphicsConfig c = new GraphicsConfig(g); c.setAntialiasing(true); - int arc = 8; - Insets insets = getInsets(); if (insets == null) { insets = new Insets(0, 0, 0, 0); @@ -78,6 +77,7 @@ public class DetailsComponent { final int rightY = banner.y + banner.height; header.moveTo(leftX, rightY); + int arc = 8; header.lineTo(leftX, leftY + arc); header.quadTo(leftX, leftY, leftX + arc, leftY); header.lineTo(rightX - arc, leftY); @@ -111,7 +111,7 @@ public class DetailsComponent { myBanner.add(myBannerLabel, BorderLayout.CENTER); - myEmptyContentLabel = new JLabel("", JLabel.CENTER); + myEmptyContentLabel = new JLabel("", SwingConstants.CENTER); revalidateDetailsMode(); } @@ -200,12 +200,7 @@ public class DetailsComponent { } private void updateBanner() { - if (NullableComponent.Check.isNull(myContent)) { - myBannerLabel.setText(null); - } - else { - myBannerLabel.setText(myBannerText); - } + myBannerLabel.setText(NullableComponent.Check.isNull(myContent) || myBannerText == null ? ArrayUtil.EMPTY_STRING_ARRAY : myBannerText); myBannerLabel.revalidate(); myBannerLabel.repaint(); @@ -250,17 +245,16 @@ public class DetailsComponent { } - public static interface Facade { - + public interface Facade { DetailsComponent getDetailsComponent(); - } private class MyWrapper extends Wrapper implements NullableComponent { public MyWrapper(final JComponent c) { - super(c == null || NullableComponent.Check.isNull(c) ? DetailsComponent.this.myEmptyContentLabel : c); + super(c == null || NullableComponent.Check.isNull(c) ? myEmptyContentLabel : c); } + @Override public boolean isNull() { return getTargetComponent() == myEmptyContentLabel; } From 64ebe4f85de62a299c52afd78f3a6593ffc33133 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 11 Feb 2014 15:01:24 +0400 Subject: [PATCH 17/24] notnull --- .../util/src/com/intellij/util/ArrayUtil.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/platform/util/src/com/intellij/util/ArrayUtil.java b/platform/util/src/com/intellij/util/ArrayUtil.java index 667ee6e54539..058ee86e7625 100644 --- a/platform/util/src/com/intellij/util/ArrayUtil.java +++ b/platform/util/src/com/intellij/util/ArrayUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -370,7 +370,7 @@ public class ArrayUtil extends ArrayUtilRt { } @NotNull - public static T[] remove(@NotNull final T[] src, int idx, ArrayFactory factory) { + public static T[] remove(@NotNull final T[] src, int idx, @NotNull ArrayFactory factory) { int length = src.length; if (idx < 0 || idx >= length) { throw new IllegalArgumentException("invalid index: " + idx); @@ -390,7 +390,7 @@ public class ArrayUtil extends ArrayUtilRt { } @NotNull - public static T[] remove(@NotNull final T[] src, T element, ArrayFactory factory) { + public static T[] remove(@NotNull final T[] src, T element, @NotNull ArrayFactory factory) { final int idx = find(src, element); if (idx == -1) return src; @@ -441,14 +441,10 @@ public class ArrayUtil extends ArrayUtilRt { return indexOf(src, obj); } - public static boolean startsWith(byte[] array, byte[] prefix) { + public static boolean startsWith(@NotNull byte[] array, @NotNull byte[] prefix) { if (array == prefix) { return true; } - if (array == null || prefix == null) { - return false; - } - int length = prefix.length; if (array.length < length) { return false; @@ -463,14 +459,10 @@ public class ArrayUtil extends ArrayUtilRt { return true; } - public static boolean startsWith(E[] array, E[] subArray) { + public static boolean startsWith(@NotNull E[] array, @NotNull E[] subArray) { if (array == subArray) { return true; } - if (array == null || subArray == null) { - return false; - } - int length = subArray.length; if (array.length < length) { return false; @@ -681,11 +673,11 @@ public class ArrayUtil extends ArrayUtilRt { return -1; } - public static boolean contains(@Nullable final Object o, final Object... objects) { + public static boolean contains(@Nullable final Object o, @NotNull Object... objects) { return indexOf(objects, o) >= 0; } - public static boolean contains(@Nullable final String s, final String... strings) { + public static boolean contains(@Nullable final String s, @NotNull String... strings) { if (s == null) { for (String str : strings) { if (str == null) return true; From 2067791f30159d6f4ba717d72f83f89901856d59 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 11 Feb 2014 16:12:56 +0400 Subject: [PATCH 18/24] notnull --- platform/util/src/com/intellij/util/ArrayUtil.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/platform/util/src/com/intellij/util/ArrayUtil.java b/platform/util/src/com/intellij/util/ArrayUtil.java index 058ee86e7625..1f75e0c78065 100644 --- a/platform/util/src/com/intellij/util/ArrayUtil.java +++ b/platform/util/src/com/intellij/util/ArrayUtil.java @@ -492,13 +492,10 @@ public class ArrayUtil extends ArrayUtilRt { return true; } - public static boolean equals(T[] a1, T[] a2, @NotNull Equality comparator) { + public static boolean equals(@NotNull T[] a1, @NotNull T[] a2, @NotNull Equality comparator) { if (a1 == a2) { return true; } - if (a1 == null || a2 == null) { - return false; - } int length = a2.length; if (a1.length != length) { @@ -513,14 +510,10 @@ public class ArrayUtil extends ArrayUtilRt { return true; } - public static boolean equals(T[] a1, T[] a2, @NotNull Comparator comparator) { + public static boolean equals(@NotNull T[] a1, @NotNull T[] a2, @NotNull Comparator comparator) { if (a1 == a2) { return true; } - if (a1 == null || a2 == null) { - return false; - } - int length = a2.length; if (a1.length != length) { return false; From cb1eb74f695d257306cd0ab1ae3c8507b64ffc72 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 11 Feb 2014 18:37:06 +0400 Subject: [PATCH 19/24] made final --- .../intellij/execution/impl/RunDialog.java | 4 ++-- .../openapi/actionSystem/ActionPlaces.java | 4 ++-- .../IdeSettingsStatisticsService.java | 4 ++-- .../ui/playback/commands/AbstractCommand.java | 5 ++--- .../ui/playback/commands/AssertFocused.java | 5 ++--- .../ui/playback/commands/DelayCommand.java | 4 ++-- .../playback/commands/KeyShortcutCommand.java | 6 +++--- .../commands/RegistryValueCommand.java | 4 ++-- .../ui/playback/commands/StopCommand.java | 4 ++-- .../configurations/CommandLineTokenizer.java | 4 ++-- .../src/com/intellij/vcsUtil/VcsUtil.java | 4 ++-- .../src/dom/impl/LanguageResolvingUtil.java | 2 +- .../introduce/IntroducePropertyAction.java | 19 +++++++++++++++++-- .../inspection/DependsOnGroupsInspection.java | 4 ++-- .../jetbrains/python/PyStructureViewTest.java | 4 ++-- 15 files changed, 45 insertions(+), 32 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunDialog.java b/platform/lang-impl/src/com/intellij/execution/impl/RunDialog.java index bcf2f61299a5..71e205c3f22c 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunDialog.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -38,7 +38,7 @@ public class RunDialog extends DialogWrapper implements RunConfigurable.RunDialo private final Project myProject; private final RunConfigurable myConfigurable; private JComponent myCenterPanel; - @NonNls public static String HELP_ID = "reference.dialogs.rundebug"; + @NonNls public static final String HELP_ID = "reference.dialogs.rundebug"; private final Executor myExecutor; public RunDialog(final Project project, final Executor executor) { diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java index a23b9ec78904..221733e505cf 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPlaces.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -109,7 +109,7 @@ public abstract class ActionPlaces { public static final String PHING_EXPLORER_POPUP = "PhingExplorerPopup"; public static final String PHING_EXPLORER_TOOLBAR = "PhingExplorerToolbar"; public static final String DOCK_MENU = "DockMenu"; - public static String PHING_MESSAGES_TOOLBAR = "PhingMessagesToolbar"; + public static final String PHING_MESSAGES_TOOLBAR = "PhingMessagesToolbar"; public static final String CHANGES_LOCAL_DIFF_SETTINGS = "CHANGES_LOCAL_DIFF_SETTINGS"; diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/ideSettings/IdeSettingsStatisticsService.java b/platform/platform-impl/src/com/intellij/internal/statistic/ideSettings/IdeSettingsStatisticsService.java index 23cb562ef7a4..c0acb8435339 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/ideSettings/IdeSettingsStatisticsService.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/ideSettings/IdeSettingsStatisticsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -30,7 +30,7 @@ import java.net.URL; public class IdeSettingsStatisticsService extends SettingsConnectionService { private static final Logger LOG = Logger.getInstance("#com.intellij.internal.statistic.ideSettings.IdeSettingsUsagesCollector"); - private static String FILE_NAME = "ide-settings-statistics.xml"; + private static final String FILE_NAME = "ide-settings-statistics.xml"; private static final IdeSettingsStatisticsService myInstance = new IdeSettingsStatisticsService(); private IdeSettingsDescriptor[] myDescriptors; diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/AbstractCommand.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/AbstractCommand.java index 3c234526f6b5..da4ac90fa448 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/AbstractCommand.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/AbstractCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -18,14 +18,13 @@ package com.intellij.openapi.ui.playback.commands; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.ui.playback.PlaybackCommand; import com.intellij.openapi.ui.playback.PlaybackContext; -import com.intellij.openapi.ui.playback.PlaybackRunner; import com.intellij.openapi.util.ActionCallback; import java.io.File; public abstract class AbstractCommand implements PlaybackCommand { - public static String CMD_PREFIX = "%"; + public static final String CMD_PREFIX = "%"; private final String myText; private final int myLine; diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/AssertFocused.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/AssertFocused.java index 7993aae5dfa3..657f39d1b15d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/AssertFocused.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/AssertFocused.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -17,7 +17,6 @@ package com.intellij.openapi.ui.playback.commands; import com.intellij.openapi.ui.Queryable; import com.intellij.openapi.ui.playback.PlaybackContext; -import com.intellij.openapi.ui.playback.PlaybackRunner; import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.wm.IdeFocusManager; @@ -26,7 +25,7 @@ import java.util.*; public class AssertFocused extends AbstractCommand { - public static String PREFIX = CMD_PREFIX + "assert focused"; + public static final String PREFIX = CMD_PREFIX + "assert focused"; public AssertFocused(String text, int line) { super(text, line); diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/DelayCommand.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/DelayCommand.java index c4689ddef1eb..ba773d4534ed 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/DelayCommand.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/DelayCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -19,7 +19,7 @@ import com.intellij.openapi.ui.playback.PlaybackContext; import com.intellij.openapi.util.ActionCallback; public class DelayCommand extends AbstractCommand { - public static String PREFIX = CMD_PREFIX + "delay"; + public static final String PREFIX = CMD_PREFIX + "delay"; public DelayCommand(String text, int line) { super(text, line); diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/KeyShortcutCommand.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/KeyShortcutCommand.java index c272125d32c2..5031ec37d904 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/KeyShortcutCommand.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/KeyShortcutCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ import com.intellij.openapi.util.ActionCallback; public class KeyShortcutCommand extends TypeCommand { - public static String PREFIX = CMD_PREFIX + "["; - public static String POSTFIX = "]"; + public static final String PREFIX = CMD_PREFIX + "["; + public static final String POSTFIX = "]"; public KeyShortcutCommand(String text, int line) { super(text, line); diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/RegistryValueCommand.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/RegistryValueCommand.java index 36c4d3f2c62c..b4f7b2fbd1b0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/RegistryValueCommand.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/RegistryValueCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -21,7 +21,7 @@ import com.intellij.openapi.util.registry.Registry; public class RegistryValueCommand extends AbstractCommand { - public static String PREFIX = CMD_PREFIX + "set"; + public static final String PREFIX = CMD_PREFIX + "set"; public RegistryValueCommand(String text, int line) { super(text, line); diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/StopCommand.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/StopCommand.java index 5e44570ec2ab..1d122fe47ebb 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/StopCommand.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/StopCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import com.intellij.openapi.util.ActionCallback; public class StopCommand extends AbstractCommand { - public static String PREFIX = CMD_PREFIX + "stop"; + public static final String PREFIX = CMD_PREFIX + "stop"; public StopCommand(String text, int line) { super(text, line); diff --git a/platform/util/src/com/intellij/execution/configurations/CommandLineTokenizer.java b/platform/util/src/com/intellij/execution/configurations/CommandLineTokenizer.java index a2e103bbec20..a62af9aa62dc 100644 --- a/platform/util/src/com/intellij/execution/configurations/CommandLineTokenizer.java +++ b/platform/util/src/com/intellij/execution/configurations/CommandLineTokenizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -26,7 +26,7 @@ import java.util.StringTokenizer; */ public class CommandLineTokenizer extends StringTokenizer { - private static String DEFAULT_DELIMITERS = " \t\n\r\f"; + private static final String DEFAULT_DELIMITERS = " \t\n\r\f"; // keep source level 1.4 private List myTokens = new ArrayList(); private int myCurrentToken = 0; diff --git a/platform/vcs-api/src/com/intellij/vcsUtil/VcsUtil.java b/platform/vcs-api/src/com/intellij/vcsUtil/VcsUtil.java index 9f9e261657f3..bdd9304e9d88 100644 --- a/platform/vcs-api/src/com/intellij/vcsUtil/VcsUtil.java +++ b/platform/vcs-api/src/com/intellij/vcsUtil/VcsUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -589,7 +589,7 @@ public class VcsUtil { return (! s1Trimmed.equals(s2Trimmed)) && s1Trimmed.equalsIgnoreCase(s2Trimmed); } - private static String ANNO_ASPECT = "show.vcs.annotation.aspect."; + private static final String ANNO_ASPECT = "show.vcs.annotation.aspect."; //public static boolean isAspectAvailableByDefault(LineAnnotationAspect aspect) { // if (aspect.getId() == null) return aspect.isShowByDefault(); // return PropertiesComponent.getInstance().getBoolean(ANNO_ASPECT + aspect.getId(), aspect.isShowByDefault()); diff --git a/plugins/devkit/src/dom/impl/LanguageResolvingUtil.java b/plugins/devkit/src/dom/impl/LanguageResolvingUtil.java index a7b18c62efab..acb0dbfc42bb 100644 --- a/plugins/devkit/src/dom/impl/LanguageResolvingUtil.java +++ b/plugins/devkit/src/dom/impl/LanguageResolvingUtil.java @@ -45,7 +45,7 @@ import java.util.List; class LanguageResolvingUtil { - private static String ANY_LANGUAGE_DEFAULT_ID = Language.ANY.getID(); + private static final String ANY_LANGUAGE_DEFAULT_ID = Language.ANY.getID(); static Collection getAllLanguageDefinitions(ConvertContext context) { List languageDefinitions = collectLanguageDefinitions(context); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java index 16d9de03b115..e595e1fa3788 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/refactorings/introduce/IntroducePropertyAction.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 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.idea.maven.dom.refactorings.introduce; import com.intellij.find.FindManager; @@ -43,8 +58,8 @@ import org.jetbrains.idea.maven.dom.model.MavenDomProperties; import java.util.*; public class IntroducePropertyAction extends BaseRefactoringAction { - private static String PREFIX = "${"; - private static String SUFFIX = "}"; + private static final String PREFIX = "${"; + private static final String SUFFIX = "}"; public IntroducePropertyAction() { setInjectedContext(true); diff --git a/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnGroupsInspection.java b/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnGroupsInspection.java index 3f8699bf2959..16bd5ddec4b2 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnGroupsInspection.java +++ b/plugins/testng/src/com/theoryinpractice/testng/inspection/DependsOnGroupsInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -48,7 +48,7 @@ public class DependsOnGroupsInspection extends BaseJavaLocalInspectionTool { private static final Pattern PATTERN = Pattern.compile("\"([a-zA-Z0-9_\\-\\(\\)]*)\""); public JDOMExternalizableStringList groups = new JDOMExternalizableStringList(); - @NonNls public static String SHORT_NAME = "groupsTestNG"; + @NonNls public static final String SHORT_NAME = "groupsTestNG"; @NotNull @Override diff --git a/python/testSrc/com/jetbrains/python/PyStructureViewTest.java b/python/testSrc/com/jetbrains/python/PyStructureViewTest.java index 7556d0f1e70b..b1ed6037412c 100644 --- a/python/testSrc/com/jetbrains/python/PyStructureViewTest.java +++ b/python/testSrc/com/jetbrains/python/PyStructureViewTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -25,7 +25,7 @@ import static com.intellij.testFramework.PlatformTestUtil.assertTreeEqual; * @author vlan */ public class PyStructureViewTest extends PyTestCase { - private static String TEST_DIRECTORY = "structureView/"; + private static final String TEST_DIRECTORY = "structureView/"; public void testBaseClassNames() { myFixture.configureByFiles(TEST_DIRECTORY + "baseClassNames.py", From fec4fa9e8b8b33e761680b6fd19906156fd30f13 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 12 Feb 2014 12:30:38 +0400 Subject: [PATCH 20/24] jdk8 compilation --- .../membersManager/MembersManager.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/python/src/com/jetbrains/python/refactoring/classes/membersManager/MembersManager.java b/python/src/com/jetbrains/python/refactoring/classes/membersManager/MembersManager.java index cc48a308c1f9..31b4f84beea7 100644 --- a/python/src/com/jetbrains/python/refactoring/classes/membersManager/MembersManager.java +++ b/python/src/com/jetbrains/python/refactoring/classes/membersManager/MembersManager.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 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.jetbrains.python.refactoring.classes.membersManager; import com.google.common.base.Function; @@ -97,13 +112,14 @@ public abstract class MembersManager implements Function manager, @NotNull final Collection elementsToMove, @NotNull final PyClass... to) { manager.checkElementTypes(elementsToMove); - for (final Object element : manager.getElementsToStoreReferences(elementsToMove)) { - PyClassRefactoringUtil.rememberNamedReferences((PyElement)element, PyNames.CANONICAL_SELF); //"self" is not reference we need to move + Collection references = manager.getElementsToStoreReferences((Collection)elementsToMove); + for (final PyElement element : references) { + PyClassRefactoringUtil.rememberNamedReferences(element, PyNames.CANONICAL_SELF); //"self" is not reference we need to move } final Collection newElements = manager.moveMembers(from, (Collection)elementsToMove, to); From ebc8333e322cab055e640cc3c1fed6fc870f9e01 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 12 Feb 2014 12:31:37 +0400 Subject: [PATCH 21/24] IDEA-114244 Find in path tooltip wrongly parses HTML entities --- .../intellij/usages/impl/UsageViewManagerImpl.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewManagerImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewManagerImpl.java index bb98e722a555..b8aef667f0e6 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewManagerImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewManagerImpl.java @@ -211,10 +211,11 @@ public class UsageViewManagerImpl extends UsageViewManager { @NotNull public static String getProgressTitle(@NotNull UsageViewPresentation presentation) { final String scopeText = presentation.getScopeText(); - if (scopeText == null) { - return UsageViewBundle.message("progress.searching.for", StringUtil.capitalize(presentation.getUsagesString())); - } - return UsageViewBundle.message("progress.searching.for.in", StringUtil.capitalize(presentation.getUsagesString()), scopeText); + String usagesString = StringUtil.capitalize(presentation.getUsagesString()); + String result = scopeText == null + ? UsageViewBundle.message("progress.searching.for", usagesString) + : UsageViewBundle.message("progress.searching.for.in", usagesString, scopeText); + return StringUtil.escapeXml(result); } private void showToolWindow(boolean activateWindow) { @@ -341,7 +342,7 @@ public class UsageViewManagerImpl extends UsageViewManager { findUsagesStartedBalloon.addRequest(new Runnable() { @Override public void run() { - String balloon = "Searching for " + myPresentation.getUsagesString()+"..."; + String balloon = UsageViewBundle.message("progress.searching.for", StringUtil.escapeXml(myPresentation.getUsagesString())); notifyByFindBalloon(null, MessageType.WARNING, myProcessPresentation, UsageViewManagerImpl.this.myProject, balloon); findStartedBalloonShown.set(true); From ca64418b85da7c3315476bb7759b85acc4408fda Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 12 Feb 2014 12:34:17 +0400 Subject: [PATCH 22/24] IDEA-120542 "Find Usages" uses scope of last "Find in Path" --- .../find/actions/ShowUsagesAction.java | 2 +- .../find/findUsages/FindUsagesManager.java | 40 +------------------ 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java index 931e2f6aa704..c93f47ae1b01 100644 --- a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java +++ b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java @@ -205,7 +205,7 @@ public class ShowUsagesAction extends AnAction implements PopupAction { private static FindUsagesOptions getDefaultOptions(@NotNull FindUsagesHandler handler) { FindUsagesOptions options = handler.getFindUsagesOptions(DataManager.getInstance().getDataContext()); // by default, scope in FindUsagesOptions is copied from the FindSettings, but we need a default one - //options.searchScope = FindUsagesManager.getMaximalScope(handler); + options.searchScope = GlobalSearchScope.projectScope(handler.getProject()); return options; } diff --git a/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java b/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java index ba9870a05941..2089d3dfd5e5 100644 --- a/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java +++ b/platform/lang-impl/src/com/intellij/find/findUsages/FindUsagesManager.java @@ -200,14 +200,6 @@ public class FindUsagesManager implements JDOMExternalizable { } public void findUsages(@NotNull PsiElement psiElement, final PsiFile scopeFile, final FileEditor editor, boolean showDialog) { - doShowDialogAndStartFind(psiElement, scopeFile, editor, showDialog, false); - } - - private void doShowDialogAndStartFind(@NotNull PsiElement psiElement, - PsiFile scopeFile, - FileEditor editor, - boolean showDialog, - boolean useMaximalScope) { FindUsagesHandler handler = getNewFindUsagesHandler(psiElement, false); if (handler == null) return; @@ -224,8 +216,8 @@ public class FindUsagesManager implements JDOMExternalizable { setOpenInNewTab(dialog.isShowInSeparateWindow()); FindUsagesOptions findUsagesOptions = dialog.calcFindUsagesOptions(); - if (!showDialog && useMaximalScope) { - findUsagesOptions.searchScope = getMaximalScope(handler); + if (!showDialog) { + findUsagesOptions.searchScope = GlobalSearchScope.projectScope(myProject); } clearFindingNextUsageInFile(); @@ -282,34 +274,6 @@ public class FindUsagesManager implements JDOMExternalizable { } } - public boolean isUsed(@NotNull PsiElement element, @NotNull FindUsagesOptions findUsagesOptions) { - FindUsagesHandler handler = getFindUsagesHandler(element, true); - if (handler == null) return false; - UsageSearcher usageSearcher = createUsageSearcher(new PsiElement[]{element}, PsiElement.EMPTY_ARRAY, handler, findUsagesOptions, null); - final AtomicBoolean used = new AtomicBoolean(); - usageSearcher.generate(new Processor() { - @Override - public boolean process(final Usage usage) { - if (isInComment(usage)) return true; - used.set(true); - return false; - } - }); - return used.get(); - } - - private static boolean isInComment(@NotNull Usage usage) { - if (!(usage instanceof UsageInfo2UsageAdapter)) return false; - UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo(); - if (!usageInfo.isNonCodeUsage()) return false; - SmartPsiFileRange psiRangePointer = usageInfo.getPsiFileRange(); - if (psiRangePointer == null) return false; - Segment range = psiRangePointer.getRange(); - PsiFile file = psiRangePointer.getContainingFile(); - if (file == null || range == null) return false; - PsiElement element = file.findElementAt(range.getStartOffset()); - return element instanceof PsiComment; - } @NotNull public static ProgressIndicator startProcessUsages(@NotNull FindUsagesHandler handler, From 1805aa5a93ae0d399a8d43ab52ea850c94aadc0b Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 12 Feb 2014 12:35:52 +0400 Subject: [PATCH 23/24] IDEA-120481 Ctrl+Alt+F7 cannot find usages in Selection --- .../util/scopeChooser/ScopeChooserCombo.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java index 37b1573e7094..b07b60b21626 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java +++ b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -24,6 +24,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.SelectionModel; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.module.Module; @@ -31,6 +32,7 @@ import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.packageDependencies.ChangeListsScopesProvider; import com.intellij.packageDependencies.DependencyValidationManager; @@ -110,7 +112,7 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo addActionListener(createScopeChooserListener()); final JComboBox combo = getComboBox(); - combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer(combo.getRenderer())); + combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer()); rebuildModel(); @@ -174,7 +176,7 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo model.addElement(new ScopeSeparator("VCS Scopes")); final List changeLists = ChangeListsScopesProvider.getInstance(myProject).getCustomScopes(); for (NamedScope changeListScope : changeLists) { - final GlobalSearchScope scope = GlobalSearchScopes.filterScope(myProject, changeListScope); + final GlobalSearchScope scope = GlobalSearchScopesCore.filterScope(myProject, changeListScope); model.addElement(new ScopeDescriptor(scope)); } @@ -183,7 +185,7 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo for (NamedScopesHolder holder : holders) { final NamedScope[] scopes = holder.getEditableScopes(); // predefined scopes already included for (NamedScope scope : scopes) { - final GlobalSearchScope searchScope = GlobalSearchScopes.filterScope(myProject, scope); + final GlobalSearchScope searchScope = GlobalSearchScopesCore.filterScope(myProject, scope); customScopes.add(new ScopeDescriptor(searchScope)); } } @@ -240,8 +242,8 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo } if (!PlatformUtils.isCidr() && ModuleUtil.isSupportedRootType(project, JavaSourceRootType.TEST_SOURCE)) { // TODO: fix these scopes in AppCode - result.add(GlobalSearchScopes.projectProductionScope(project)); - result.add(GlobalSearchScopes.projectTestScope(project)); + result.add(GlobalSearchScopesCore.projectProductionScope(project)); + result.add(GlobalSearchScopesCore.projectTestScope(project)); } result.add(GlobalSearchScopes.openFilesScope(project)); @@ -273,17 +275,21 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo if (selectedTextEditor != null) { final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(selectedTextEditor.getDocument()); if (psiFile != null) { - if (selectedTextEditor.getSelectionModel().hasSelection()) { - final PsiElement startElement = psiFile.findElementAt(selectedTextEditor.getSelectionModel().getSelectionStart()); + SelectionModel selectionModel = selectedTextEditor.getSelectionModel(); + if (selectionModel.hasSelection()) { + int start = selectionModel.getSelectionStart(); + final PsiElement startElement = psiFile.findElementAt(start); if (startElement != null) { - final PsiElement endElement = psiFile.findElementAt(selectedTextEditor.getSelectionModel().getSelectionEnd()); + int end = selectionModel.getSelectionEnd(); + final PsiElement endElement = psiFile.findElementAt(end); if (endElement != null) { final PsiElement parent = PsiTreeUtil.findCommonParent(startElement, endElement); if (parent != null) { final List elements = new ArrayList(); final PsiElement[] children = parent.getChildren(); + TextRange selection = new TextRange(start, end); for (PsiElement child : children) { - if (!(child instanceof PsiWhiteSpace) && child.getContainingFile() != null) { + if (!(child instanceof PsiWhiteSpace) && child.getContainingFile() != null && selection.contains(child.getTextOffset())) { elements.add(child); } } @@ -445,10 +451,6 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo } private static class ScopeDescriptionWithDelimiterRenderer extends ListCellRendererWrapper { - public ScopeDescriptionWithDelimiterRenderer(final ListCellRenderer original) { - super(); - } - @Override public void customize(JList list, ScopeDescriptor value, int index, boolean selected, boolean hasFocus) { setText(value.getDisplay()); From ed7a6c3975304ce126d71b6d449b5017e90aa02c Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Wed, 12 Feb 2014 15:10:40 +0400 Subject: [PATCH 24/24] Postfix completion: fix CCE --- .../postfix/templates/NullCheckPostfixTemplate.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NullCheckPostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NullCheckPostfixTemplate.java index 4d4ac0c4786c..77126b8df9fb 100644 --- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NullCheckPostfixTemplate.java +++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/NullCheckPostfixTemplate.java @@ -20,7 +20,10 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; -import com.intellij.psi.*; +import com.intellij.psi.JavaPsiFacade; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementFactory; +import com.intellij.psi.PsiExpression; import org.jetbrains.annotations.NotNull; /** @@ -46,7 +49,7 @@ public abstract class NullCheckPostfixTemplate extends PostfixTemplate { Project project = expr.getProject(); PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory(); - PsiBinaryExpression condition = (PsiBinaryExpression)factory.createExpressionFromText(expr.getText() + getTail(), context); + PsiExpression condition = factory.createExpressionFromText(expr.getText() + getTail(), context); PsiElement replace = expr.replace(condition); assert replace instanceof PsiExpression;