From 98ebdab195f6eb3ccf29375bc0e5422bfc2dc5a1 Mon Sep 17 00:00:00 2001 From: Vojtech Krasa Date: Fri, 7 Dec 2012 13:35:46 +0100 Subject: [PATCH 01/18] IDEA-94184 hardcoded value ChooseByNameBase#REBUILD_DELAY moved to registry.properties --- .../ide/util/gotoByName/ChooseByNameBase.java | 11 ++++++----- .../src/misc/registry.properties | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java index 5573cd5970ff..e9cd42026340 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java @@ -130,7 +130,7 @@ public abstract class ChooseByNameBase { @NonNls private static final String NOT_FOUND_CARD = "nfound"; @NonNls private static final String CHECK_BOX_CARD = "chkbox"; @NonNls private static final String SEARCHING_CARD = "searching"; - private static final int REBUILD_DELAY = 300; + private final int myRebuildDelay; private final Alarm myHideAlarm = new Alarm(); private boolean myShowListAfterCompletionKeyStroke = false; @@ -185,6 +185,7 @@ public abstract class ChooseByNameBase { myProvider = provider; myInitialIndex = initialIndex; mySearchInAnyPlace = Registry.is("ide.goto.middle.matching") && model.useMiddleMatching(); + myRebuildDelay = Registry.intValue("ide.goto.rebuild.delay"); } public void setShowListAfterCompletionKeyStroke(boolean showListAfterCompletionKeyStroke) { @@ -584,7 +585,7 @@ public abstract class ChooseByNameBase { case KeyEvent.VK_ENTER: if (myList.getSelectedValue() == EXTRA_ELEM) { myMaximumListSizeLimit += myListSizeIncreasing; - rebuildList(myList.getSelectedIndex(), REBUILD_DELAY, null, ModalityState.current()); + rebuildList(myList.getSelectedIndex(), myRebuildDelay, null, ModalityState.current()); e.consume(); } break; @@ -627,7 +628,7 @@ public abstract class ChooseByNameBase { if (selectedCellBounds != null && selectedCellBounds.contains(e.getPoint())) { // Otherwise it was reselected in the selection listener if (myList.getSelectedValue() == EXTRA_ELEM) { myMaximumListSizeLimit += myListSizeIncreasing; - rebuildList(selectedIndex, REBUILD_DELAY, null, ModalityState.current()); + rebuildList(selectedIndex, myRebuildDelay, null, ModalityState.current()); } else { doClose(true); @@ -706,11 +707,11 @@ public abstract class ChooseByNameBase { } /** - * Default rebuild list. It uses {@link #REBUILD_DELAY} and current modality state. + * Default rebuild list. It uses {@link #myRebuildDelay} and current modality state. */ public void rebuildList(boolean initial) { // TODO this method is public, because the chooser does not listed for the model. - rebuildList(initial ? myInitialIndex : 0, REBUILD_DELAY, null, ModalityState.current()); + rebuildList(initial ? myInitialIndex : 0, myRebuildDelay, null, ModalityState.current()); } private void updateDocPosition() { diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index 035f579cb6f2..1dab41c34b6c 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -202,6 +202,7 @@ ide.completion.middle.matching.description=Suggest items in completion that cont ide.goto.middle.matching=true # suppress inspection "UnusedProperty" ide.goto.middle.matching.description=Suggest items in goto actions that contain the entered string somewhere in the middle. +ide.goto.rebuild.delay=300 ide.enable.toolwindow.stack=false From b2cbb2a51df0825321a0659580b97bf941150d4f Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Fri, 7 Dec 2012 16:48:36 +0400 Subject: [PATCH 02/18] old rearranger plugin is removed --- .idea/modules.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index 6443efd723a0..829555b11baa 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -105,7 +105,6 @@ - From 39b016fb57f157ae53b442949e24b8a5376e08bd Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Wed, 5 Dec 2012 19:24:29 +0400 Subject: [PATCH 03/18] indents fixed --- .../application/options/CodeStyleGenerationConfigurable.form | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.form b/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.form index 9fff54900ceb..f3656e9f1a7a 100644 --- a/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.form +++ b/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.form @@ -267,7 +267,7 @@ - + @@ -275,7 +275,7 @@ - + From edd146d045fb17665463da95a6482f4d17294933 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Wed, 5 Dec 2012 19:26:01 +0400 Subject: [PATCH 04/18] color for issues in goto task popup under darcula fixed --- .../src/com/intellij/tasks/actions/TaskCellRenderer.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/TaskCellRenderer.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/TaskCellRenderer.java index 4619fea620e8..65a4d454e864 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/TaskCellRenderer.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/TaskCellRenderer.java @@ -25,7 +25,6 @@ import java.awt.*; * @author Evgeny Zakrevsky */ public class TaskCellRenderer extends DefaultListCellRenderer implements MatcherHolder { - private static final Color ISSUE_BG_COLOR = new Color(240, 240, 255); private Matcher myMatcher; private final Project myProject; @@ -47,7 +46,7 @@ public class TaskCellRenderer extends DefaultListCellRenderer implements Matcher final boolean isLocalTask = taskManager.findTask(task.getId()) != null; final boolean isClosed = task.isClosed() || (task instanceof LocalTask && taskManager.isLocallyClosed((LocalTask)task)); - final Color bg = sel ? UIUtil.getListSelectionBackground() : isLocalTask ? UIUtil.getListBackground() : ISSUE_BG_COLOR; + final Color bg = sel ? UIUtil.getListSelectionBackground() : isLocalTask ? UIUtil.getListBackground() : UIUtil.getDecoratedRowColor(); panel.setBackground(bg); SimpleTextAttributes attr = getAttributes(sel, isClosed); From 42466bd342b2ee21921ddc33b8e251e0afa0f47a Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Wed, 5 Dec 2012 19:51:50 +0400 Subject: [PATCH 05/18] Assembla connector. Correct isConfigured method. Avoid unnecessary connections. --- .../intellij/tasks/generic/assembla/AssemblaRepository.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/assembla/AssemblaRepository.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/assembla/AssemblaRepository.java index 2d47980a21e4..ec0e4b1a676b 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/assembla/AssemblaRepository.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/assembla/AssemblaRepository.java @@ -74,4 +74,9 @@ public class AssemblaRepository extends GenericRepository { public String getPresentableName() { return StringUtil.isEmpty(getUsername()) ? "" : getUsername() + "'s tickets"; } + + @Override + public boolean isConfigured() { + return super.isConfigured() && StringUtil.isNotEmpty(getUsername()) && StringUtil.isNotEmpty(getPassword()); + } } From 09cb77b6ad4fe861e7d97b8af9fc78fa7aad6f21 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Wed, 5 Dec 2012 19:52:47 +0400 Subject: [PATCH 06/18] Task Configurable. Borders under Darcula. --- .../intellij/tasks/config/TaskConfigurable.form | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskConfigurable.form b/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskConfigurable.form index 595bc4f4a2d0..9a070abb8670 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskConfigurable.form +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/config/TaskConfigurable.form @@ -8,7 +8,7 @@ - + @@ -23,7 +23,7 @@ - + @@ -71,10 +71,11 @@ + - + @@ -125,11 +126,11 @@ - + - + @@ -145,11 +146,11 @@ - + - + From 5379914989011ebba0cbce5b20e5d266196cf954 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Wed, 5 Dec 2012 21:23:53 +0400 Subject: [PATCH 07/18] Run Configurations dialog doesn't jumping on expanding/collapsing of Before launch panel. --- .../execution/impl/ConfigurationSettingsEditorWrapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java index e19198949998..2f3115e0e3af 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java @@ -59,7 +59,7 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor Date: Wed, 5 Dec 2012 22:13:20 +0400 Subject: [PATCH 08/18] EditorTextField border --- .../platform-impl/src/com/intellij/ui/EditorTextField.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ui/EditorTextField.java b/platform/platform-impl/src/com/intellij/ui/EditorTextField.java index 836a91a01710..9a859f7a5ff7 100644 --- a/platform/platform-impl/src/com/intellij/ui/EditorTextField.java +++ b/platform/platform-impl/src/com/intellij/ui/EditorTextField.java @@ -572,7 +572,10 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener, } }); } - else if (UIUtil.isUnderAlloyLookAndFeel()) { + else if (UIUtil.isUnderAlloyLookAndFeel() || UIUtil.isUnderJGoodiesLookAndFeel()) { + editor.setBorder(BorderFactory.createCompoundBorder(UIUtil.getTextFieldBorder(), BorderFactory.createEmptyBorder(1, 1, 1, 1))); + } + else { editor.setBorder(BorderFactory.createCompoundBorder(UIUtil.getTextFieldBorder(), BorderFactory.createEmptyBorder(2, 2, 2, 2))); } } From 4b20d82908cfaace2322bc4618936867873e0e9f Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Thu, 6 Dec 2012 16:05:48 +0400 Subject: [PATCH 09/18] Tooltip font color under Darcula. --- .../util/src/com/intellij/util/ui/UIUtil.java | 163 +++++++++++------- 1 file changed, 103 insertions(+), 60 deletions(-) diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 4981b09c0314..d8ae6ae7d0bb 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -22,10 +22,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.*; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.ui.ColorUtil; -import com.intellij.ui.Gray; -import com.intellij.ui.PanelWithAnchor; -import com.intellij.ui.SideBorder; +import com.intellij.ui.*; import com.intellij.util.*; import com.intellij.util.containers.ContainerUtil; import org.intellij.lang.annotations.Language; @@ -96,9 +93,12 @@ public class UIUtil { if (isUnderAquaLookAndFeel()) { c.putClientProperty("JComponent.sizeVariant", componentStyle == ComponentStyle.REGULAR ? "regular" : componentStyle == ComponentStyle.SMALL ? "small" : "mini"); - } else { + } + else { c.setFont(getFont( - componentStyle == ComponentStyle.REGULAR ? FontSize.NORMAL : componentStyle == ComponentStyle.SMALL ? FontSize.SMALL : FontSize.MINI, c.getFont())); + componentStyle == ComponentStyle.REGULAR + ? FontSize.NORMAL + : componentStyle == ComponentStyle.SMALL ? FontSize.SMALL : FontSize.MINI, c.getFont())); } Container p = c.getParent(); if (p != null) { @@ -108,12 +108,13 @@ public class UIUtil { public static Cursor getTextCursor(final Color backgroundColor) { return SystemInfo.isMac && ColorUtil.isDark(backgroundColor) ? - MacUIUtil.getInvertedTextCursor(): Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR); + MacUIUtil.getInvertedTextCursor() : Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR); } /** * Draws two horizontal lines, the first at {@code topY}, the second at {@code bottomY}. * The purpose of this method (and the ground of the name) is to draw two lines framing a horizontal filled rectangle. + * * @param g Graphics context to draw with. * @param startX x-start point. * @param endX x-end point. @@ -128,12 +129,15 @@ public class UIUtil { private static final GrayFilter DEFAULT_GRAY_FILTER = new GrayFilter(true, 65); private static final GrayFilter DARCULA_GRAY_FILTER = new GrayFilter(true, 30); + public static GrayFilter getGrayFilter() { return isUnderDarcula() ? DARCULA_GRAY_FILTER : DEFAULT_GRAY_FILTER; } public enum FontSize {NORMAL, SMALL, MINI} + public enum ComponentStyle {REGULAR, SMALL, MINI} + public enum FontColor {NORMAL, BRIGHTER} public static final char MNEMONIC = BundleBase.MNEMONIC; @@ -204,7 +208,8 @@ public class UIUtil { private static final Ref ourRetina = Ref.create(SystemInfo.isMac ? null : false); - private UIUtil() { } + private UIUtil() { + } public static boolean isRetina() { synchronized (ourRetina) { @@ -281,13 +286,15 @@ public class UIUtil { public static void drawLinePickedOut(Graphics graphics, int x, int y, int x1, int y1) { if (x == x1) { int minY = Math.min(y, y1); - int maxY = Math.max(y, y1); - graphics.drawLine(x, minY+1, x1, maxY-1); - } else if (y == y1) { + int maxY = Math.max(y, y1); + graphics.drawLine(x, minY + 1, x1, maxY - 1); + } + else if (y == y1) { int minX = Math.min(x, x1); int maxX = Math.max(x, x1); - graphics.drawLine(minX+1, y, maxX-1, y1); - } else { + graphics.drawLine(minX + 1, y, maxX - 1, y1); + } + else { drawLine(graphics, x, y, x1, y1); } } @@ -327,7 +334,6 @@ public class UIUtil { for (int i = 0; i < subComponentCount; i++) { setEnabled(container.getComponent(i), enabled, recursively); } - } } } @@ -431,7 +437,8 @@ public class UIUtil { public static Color getLabelFontColor(FontColor fontColor) { Color defColor = getLabelForeground(); if (fontColor == FontColor.BRIGHTER) { - return new Color(Math.min(defColor.getRed() + 50, 255), Math.min(defColor.getGreen() + 50, 255), Math.min(defColor.getBlue() + 50, 255)); + return new JBColor(new Color(Math.min(defColor.getRed() + 50, 255), Math.min(defColor.getGreen() + 50, 255), Math.min( + defColor.getBlue() + 50, 255)), defColor.darker()); } return defColor; } @@ -592,8 +599,13 @@ public class UIUtil { LookAndFeel.installBorder(contentPane, "PopupMenu.border"); } - /** @deprecated Motif is gone (to remove in IDEA 13) */ - @SuppressWarnings("UnusedDeclaration") public static boolean isMotifLookAndFeel() { return false; } + /** + * @deprecated Motif is gone (to remove in IDEA 13) + */ + @SuppressWarnings("UnusedDeclaration") + public static boolean isMotifLookAndFeel() { + return false; + } public static Color getTreeSelectionBorderColor() { return UIManager.getColor("Tree.selectionBorderColor"); @@ -816,11 +828,11 @@ public class UIUtil { } public static Color getTableFocusCellForeground() { - return UIManager.getColor("Table.focusCellForeground"); + return UIManager.getColor("Table.focusCellForeground"); } /** - * @deprecated use com.intellij.util.ui.UIUtil#getPanelBackground() instead + * @deprecated use com.intellij.util.ui.UIUtil#getPanelBackground() instead */ public static Color getPanelBackgound() { return getPanelBackground(); @@ -918,8 +930,13 @@ public class UIUtil { return UIManager.getColor("OptionPane.background"); } - /** @deprecated Quaqua is gone (to remove in IDEA 13) */ - @SuppressWarnings("UnusedDeclaration") public static boolean isUnderQuaquaLookAndFeel() { return false; } + /** + * @deprecated Quaqua is gone (to remove in IDEA 13) + */ + @SuppressWarnings("UnusedDeclaration") + public static boolean isUnderQuaquaLookAndFeel() { + return false; + } @SuppressWarnings({"HardCodedStringLiteral"}) public static boolean isUnderAlloyLookAndFeel() { @@ -941,8 +958,13 @@ public class UIUtil { return UIManager.getLookAndFeel().getName().equals("Windows Classic"); } - /** @deprecated Metal is gone (to remove in IDEA 13) */ - @SuppressWarnings("UnusedDeclaration") public static boolean isUnderMetalLookAndFeel() { return false; } + /** + * @deprecated Metal is gone (to remove in IDEA 13) + */ + @SuppressWarnings("UnusedDeclaration") + public static boolean isUnderMetalLookAndFeel() { + return false; + } @SuppressWarnings({"HardCodedStringLiteral"}) public static boolean isUnderNimbusLookAndFeel() { @@ -964,8 +986,13 @@ public class UIUtil { return SystemInfo.isMac && (isUnderAquaLookAndFeel() || isUnderDarcula()); } - /** @deprecated Motif is gone (to remove in IDEA 13) */ - @SuppressWarnings("UnusedDeclaration") public static boolean isUnderMotif() { return false; } + /** + * @deprecated Motif is gone (to remove in IDEA 13) + */ + @SuppressWarnings("UnusedDeclaration") + public static boolean isUnderMotif() { + return false; + } @SuppressWarnings({"HardCodedStringLiteral"}) public static boolean isUnderDarcula() { @@ -1056,8 +1083,12 @@ public class UIUtil { return !isUnderNativeMacLookAndFeel(); } - /** @deprecated Quaqua is gone (to remove in IDEA 13) */ - @SuppressWarnings("UnusedDeclaration") public static void removeQuaquaVisualMarginsIn(Component component) { } + /** + * @deprecated Quaqua is gone (to remove in IDEA 13) + */ + @SuppressWarnings("UnusedDeclaration") + public static void removeQuaquaVisualMarginsIn(Component component) { + } public static boolean isControlKeyDown(MouseEvent mouseEvent) { return SystemInfo.isMac ? mouseEvent.isMetaDown() : mouseEvent.isControlDown(); @@ -1182,9 +1213,9 @@ public class UIUtil { } public static void drawSearchMatch(final Graphics2D g, - final int startX, - final int endX, - final int height) { + final int startX, + final int endX, + final int height) { Color c1 = new Color(255, 234, 162); Color c2 = new Color(255, 208, 66); drawSearchMatch(g, startX, endX, height, c1, c2); @@ -1214,8 +1245,8 @@ public class UIUtil { } public static void drawRectPickedOut(Graphics2D g, int x, int y, int w, int h) { - g.drawLine(x+1, y, x+w-1, y); - g.drawLine(x+w, y+1, x+w, y+h-1); + g.drawLine(x + 1, y, x + w - 1, y); + g.drawLine(x + w, y + 1, x + w, y + h - 1); g.drawLine(x + w - 1, y + h, x + 1, y + h); g.drawLine(x, y + 1, x, y + h - 1); } @@ -1290,27 +1321,27 @@ public class UIUtil { g.drawLine(x, drawTopLine ? 1 : 0, width, drawTopLine ? 1 : 0); if (active) { - g.setColor(new Color(100, 150, 230, toolWindow? 50 : 30)); + g.setColor(new Color(100, 150, 230, toolWindow ? 50 : 30)); g.fillRect(x, 0, width, height); } } public static void drawDoubleSpaceDottedLine(final Graphics2D g, - final int start, - final int end, - final int xOrY, - final Color fgColor, - boolean horizontal) { + final int start, + final int end, + final int xOrY, + final Color fgColor, + boolean horizontal) { g.setColor(fgColor); - for (int dot = start; dot < end; dot+=3) { + for (int dot = start; dot < end; dot += 3) { if (horizontal) { g.drawLine(dot, xOrY, dot, xOrY); - } else { + } + else { g.drawLine(xOrY, dot, xOrY, dot); } } - } private static void drawAppleDottedLine(final Graphics2D g, @@ -1423,7 +1454,7 @@ public class UIUtil { if (isRetina()) { return RetinaImage.create(width, height, type); } - //noinspection UndesirableClassUsage + //noinspection UndesirableClassUsage return new BufferedImage(width, height, type); } @@ -1431,7 +1462,10 @@ public class UIUtil { paintWithRetina(size, g, true, paintRoutine); } - public static void paintWithRetina(@NotNull Dimension size, @NotNull Graphics g, boolean useRetinaCondition, Consumer paintRoutine) { + public static void paintWithRetina(@NotNull Dimension size, + @NotNull Graphics g, + boolean useRetinaCondition, + Consumer paintRoutine) { if (!useRetinaCondition || !isRetina() || Registry.is("ide.mac.retina.disableDrawingFix", false)) { paintRoutine.consume((Graphics2D)g); } @@ -1462,7 +1496,7 @@ public class UIUtil { * The whole idea is that XRender-based pipeline doesn't support * {@link AlphaComposite#SRC} and we should use {@link AlphaComposite#SRC_OVER} instead. * - * @param g target graphics container + * @param g target graphics container */ public static void setupComposite(@NotNull Graphics2D g) { g.setComposite(X_RENDER_ACTIVE.getValue() ? AlphaComposite.SrcOver : AlphaComposite.Src); @@ -1611,7 +1645,7 @@ public class UIUtil { @NonNls @Language("HTML") String body = "body, div, td, p {" + fontFamilyAndSize + " " + (fgColor != null ? "color:" + ColorUtil.toHex(fgColor) : "") + "}"; if (resource != null) { - body += "ul {list-style-image: " + resource.toExternalForm() +"}"; + body += "ul {list-style-image: " + resource.toExternalForm() + "}"; } @NonNls String link = linkColor != null ? "a {" + fontFamilyAndSize + " color:" + ColorUtil.toHex(linkColor) + "}" : ""; return ""; @@ -1894,13 +1928,15 @@ public class UIUtil { String each = html.substring(currentPos, currentPos + 1); if ("<".equals(each)) { braces++; - } else if (">".equals(each)) { + } + else if (">".equals(each)) { braces--; } if (" ".equals(each) && braces == 0) { result.append(" "); - } else { + } + else { result.append(each); } currentPos++; @@ -1955,12 +1991,13 @@ public class UIUtil { /** * Avoid blinking while changing background. - * @param component component. - * @param background new background. + * + * @param component component. + * @param background new background. */ public static void changeBackGround(final Component component, final Color background) { final Color oldBackGround = component.getBackground(); - if (background == null || !background.equals(oldBackGround)){ + if (background == null || !background.equals(oldBackGround)) { component.setBackground(background); } } @@ -1974,7 +2011,8 @@ public class UIUtil { ourSystemFontData = Pair.create(font.getName(), font.getSize()); } } - catch (Exception ignored) { } + catch (Exception ignored) { + } } @Nullable @@ -2024,7 +2062,7 @@ public class UIUtil { else if (component != null) { final String str = component.toString(); // skip default Component.toString and handle SimpleColoredComponent case - text = str == null || str.startsWith(component.getClass().getName()+"[")? null : str; + text = str == null || str.startsWith(component.getClass().getName() + "[") ? null : str; } else { text = null; @@ -2046,7 +2084,7 @@ public class UIUtil { try { final Field popup = BasicComboBoxUI.class.getDeclaredField("popup"); popup.setAccessible(true); - return (ComboPopup) popup.get(ui); + return (ComboPopup)popup.get(ui); } catch (NoSuchFieldException e) { return null; @@ -2107,11 +2145,12 @@ public class UIUtil { @SuppressWarnings("deprecation") public static void setComboBoxEditorBounds(int x, int y, int width, int height, JComponent editor) { - if(SystemInfo.isMac && isUnderAquaLookAndFeel()) { + if (SystemInfo.isMac && isUnderAquaLookAndFeel()) { // fix for too wide combobox editor, see AquaComboBoxUI.layoutContainer: // it adds +4 pixels to editor width. WTF?! editor.reshape(x, y, width - 4, height - 1); - } else { + } + else { editor.reshape(x, y, width, height); } } @@ -2354,7 +2393,8 @@ public class UIUtil { if (myDrawShadow) { c = g.getColor(); g.setColor(myShadowColor); - g.drawLine(x - maxBulletWidth[0] - 10, yOffset[0] + fm.getDescent() + 1, x + maxWidth[0] + 10, yOffset[0] + fm.getDescent() + 1); + g.drawLine(x - maxBulletWidth[0] - 10, yOffset[0] + fm.getDescent() + 1, x + maxWidth[0] + 10, + yOffset[0] + fm.getDescent() + 1); g.setColor(c); } } @@ -2387,7 +2427,8 @@ public class UIUtil { Component eachParent = c; while (eachParent != null) { if (eachParent instanceof JComponent) { - @SuppressWarnings({"unchecked"}) WeakReference pane = (WeakReference)((JComponent)eachParent).getClientProperty(ROOT_PANE); + @SuppressWarnings({"unchecked"}) WeakReference pane = + (WeakReference)((JComponent)eachParent).getClientProperty(ROOT_PANE); if (pane != null) return pane.get(); } eachParent = eachParent.getParent(); @@ -2407,7 +2448,7 @@ public class UIUtil { } public static Timer createNamedTimer(@NonNls @NotNull final String name, int delay, @NotNull ActionListener listener) { - return new Timer(delay, listener){ + return new Timer(delay, listener) { @Override public String toString() { return name; @@ -2424,7 +2465,7 @@ public class UIUtil { } @Nullable - public static JComponent mergeComponentsWithAnchor(PanelWithAnchor...panels) { + public static JComponent mergeComponentsWithAnchor(PanelWithAnchor... panels) { return mergeComponentsWithAnchor(Arrays.asList(panels)); } @@ -2514,7 +2555,8 @@ public class UIUtil { pixelGrabber.grabPixels(); return new Color(pixels[0]); } - catch (InterruptedException ignored) { } + catch (InterruptedException ignored) { + } } return null; @@ -2533,6 +2575,7 @@ public class UIUtil { private static final Color DECORATED_ROW_BG_COLOR = new Color(242, 245, 249); private static final Color DECORATED_ROW_BG_COLOR_DARK = Gray._75; + public static Color getDecoratedRowColor() { return isUnderDarcula() ? DECORATED_ROW_BG_COLOR_DARK : DECORATED_ROW_BG_COLOR; } From 5c99cfad75cd9ac1486e611db73d5a4761fe3929 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Thu, 6 Dec 2012 17:58:37 +0400 Subject: [PATCH 10/18] Tooltip --- .../compiler/options/CompilerOptionsPanel.form | 13 ++++++------- .../compiler/options/CompilerUIConfigurable.java | 3 ++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form b/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form index 70297f6c5e46..a236930b8592 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form +++ b/java/compiler/impl/src/com/intellij/compiler/options/CompilerOptionsPanel.form @@ -13,8 +13,8 @@ - - + + @@ -31,23 +31,22 @@ - + - - + - - + + diff --git a/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java b/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java index 889b45e23b10..8620d7396e97 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java +++ b/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java @@ -28,6 +28,7 @@ import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.ui.components.JBLabel; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -47,7 +48,7 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura private JTextField myResourcePatternsField; private JCheckBox myCbClearOutputDirectory; private JCheckBox myCbAssertNotNull; - private JLabel myPatternLegendLabel; + private JBLabel myPatternLegendLabel; private JCheckBox myCbAutoShowFirstError; private JCheckBox myCbUseExternalBuild; private JCheckBox myCbEnableAutomake; From 7e988f00c6edd83b257d1293264685fd2a95c53e Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Thu, 6 Dec 2012 18:12:04 +0400 Subject: [PATCH 11/18] JSplitPane -> Splitter --- .../committed/CommittedChangesBrowser.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesBrowser.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesBrowser.java index c68f39de4839..0e66b22634f4 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesBrowser.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesBrowser.java @@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.CommonShortcuts; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.vcs.ChangeListColumn; import com.intellij.openapi.vcs.VcsBundle; import com.intellij.openapi.vcs.VcsException; @@ -159,17 +160,13 @@ public class CommittedChangesBrowser extends JPanel { myLeftPanel.add(forwardButton, new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2,2,2,2), 0, 0)); } - JSplitPane leftSplitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT); - leftSplitter.setTopComponent(myLeftPanel); - leftSplitter.setBottomComponent(commitPanel); - leftSplitter.setDividerLocation(0.8); - leftSplitter.setResizeWeight(0.8); + Splitter leftSplitter = new Splitter(true, 0.8f); + leftSplitter.setFirstComponent(myLeftPanel); + leftSplitter.setSecondComponent(commitPanel); - JSplitPane splitter = new JSplitPane(); - splitter.setLeftComponent(leftSplitter); - splitter.setRightComponent(myChangesView); - splitter.setDividerLocation(0.5); - splitter.setResizeWeight(0.5); + Splitter splitter = new Splitter(false, 0.5f); + splitter.setFirstComponent(leftSplitter); + splitter.setSecondComponent(myChangesView); add(splitter, BorderLayout.CENTER); From c8f66eb0ccb650565396e9fc7a4a69576443aa36 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Fri, 7 Dec 2012 11:44:34 +0400 Subject: [PATCH 12/18] icon of hideable panel under darcula changed --- .../src/com/intellij/ui/HideableDecorator.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/HideableDecorator.java b/platform/platform-impl/src/com/intellij/ui/HideableDecorator.java index 6e3ef43c25bf..e34f03ce6d93 100644 --- a/platform/platform-impl/src/com/intellij/ui/HideableDecorator.java +++ b/platform/platform-impl/src/com/intellij/ui/HideableDecorator.java @@ -101,8 +101,8 @@ public class HideableDecorator { protected void on() { myOn = true; - myTitledSeparator.getLabel().setIcon(AllIcons.General.ComboArrowDown); - myTitledSeparator.getLabel().setDisabledIcon(IconLoader.getTransparentIcon(AllIcons.General.ComboArrowDown, 0.5f)); + myTitledSeparator.getLabel().setIcon(AllIcons.General.SplitDown); + myTitledSeparator.getLabel().setDisabledIcon(IconLoader.getTransparentIcon(AllIcons.General.SplitDown, 0.5f)); myTitledSeparator.getLabel().setIconTextGap(5); if (myContent != null) { myContent.setVisible(true); @@ -114,10 +114,8 @@ public class HideableDecorator { protected void off() { myOn = false; - myTitledSeparator.getLabel().setIcon(AllIcons.General.ComboArrowRight); - myTitledSeparator.getLabel().setDisabledIcon(IconLoader.getTransparentIcon(AllIcons.General.ComboArrowRight, 0.5f)); - myTitledSeparator.getLabel() - .setIconTextGap(5 + AllIcons.General.ComboArrowDown.getIconWidth() - AllIcons.General.ComboArrowRight.getIconWidth()); + myTitledSeparator.getLabel().setIcon(AllIcons.General.SplitRight); + myTitledSeparator.getLabel().setDisabledIcon(IconLoader.getTransparentIcon(AllIcons.General.SplitRight, 0.5f)); if (myContent != null) { myContent.setVisible(false); myPreviousContentSize = myContent.getSize(); From 49117c4e472cad444633d425f1b335826803e618 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Fri, 7 Dec 2012 17:08:06 +0400 Subject: [PATCH 13/18] FixedSizeButton size --- .../intellij/execution/ui/ConfigurationArgumentsHelpArea.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/execution/impl/src/com/intellij/execution/ui/ConfigurationArgumentsHelpArea.java b/java/execution/impl/src/com/intellij/execution/ui/ConfigurationArgumentsHelpArea.java index ef2bebd366bb..c2c5e408904e 100644 --- a/java/execution/impl/src/com/intellij/execution/ui/ConfigurationArgumentsHelpArea.java +++ b/java/execution/impl/src/com/intellij/execution/ui/ConfigurationArgumentsHelpArea.java @@ -59,7 +59,7 @@ public class ConfigurationArgumentsHelpArea extends JPanel { CopyPasteManager.getInstance().setContents(contents); } }); - myToolbarPanel.add(copyButton, BorderLayout.CENTER); + myToolbarPanel.add(copyButton, BorderLayout.NORTH); myToolbarPanel.setVisible(false); } From abb302d3209f586be118fb67684acb69efb94c5a Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 6 Dec 2012 18:44:28 +0100 Subject: [PATCH 14/18] prevent SIOOBE --- .../codeInsight/lookup/impl/CompletionPreview.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionPreview.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionPreview.java index 6d0cc30c1a49..889e10756dec 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionPreview.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionPreview.java @@ -130,7 +130,12 @@ public class CompletionPreview { } } - new CompletionPreview(lookup, text, lookup.itemPattern(item)); + String prefix = lookup.itemPattern(item); + if (prefix.length() > text.length()) { + return; + } + + new CompletionPreview(lookup, text, prefix); } public void uninstallPreview() { From 1373e37d8c87ace5d583750e2559b20de75c50ad Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 7 Dec 2012 14:48:17 +0100 Subject: [PATCH 15/18] let shorter items go after the preferred ones (for the preselection to be the first one in the lookup) --- .../completion/JavaCompletionSorting.java | 5 +-- .../NormalCompletionOrderingTest.groovy | 20 ++++----- .../completion/NormalCompletionTest.groovy | 2 +- .../SmartTypeCompletionOrderingTest.groovy | 2 +- .../impl/CompletionServiceImpl.java | 7 +-- .../impl/LiftShorterItemsClassifier.java | 44 ++++++++----------- 6 files changed, 32 insertions(+), 48 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java index 61a3b1329d47..437de0c7ea9b 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java @@ -86,9 +86,6 @@ public class JavaCompletionSorting { return new LiftShorterItemsClassifier(next, new LiftShorterItemsClassifier.LiftingCondition() { @Override public boolean shouldLift(LookupElement shorterElement, LookupElement longerElement) { - if (super.shouldLift(shorterElement, longerElement)) { - return true; - } Object object = shorterElement.getObject(); if (object instanceof PsiClass) { PsiClass psiClass = (PsiClass)object; @@ -107,7 +104,7 @@ public class JavaCompletionSorting { } return false; } - }); + }, true); } }); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy index 3d94e2115506..f9c4ea38f01c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionOrderingTest.groovy @@ -162,10 +162,10 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase { FileDocumentManager.instance.saveAllDocuments() invokeCompletion("SameStatsForDifferentQualifiersJLabel.java"); - assertPreferredItems(1, "getComponent", "getComponents"); + assertPreferredItems(0, "getComponents", "getComponent"); invokeCompletion("SameStatsForDifferentQualifiersJComponent.java"); - assertPreferredItems(1, "getComponent", "getComponents"); + assertPreferredItems(0, "getComponents", "getComponent"); } public void testSameStatsForDifferentQualifiers2() throws Throwable { @@ -175,10 +175,10 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase { FileDocumentManager.instance.saveAllDocuments() invokeCompletion("SameStatsForDifferentQualifiersJComponent.java"); - assertPreferredItems(1, "getComponent", "getComponents"); + assertPreferredItems(0, "getComponents", "getComponent"); invokeCompletion("SameStatsForDifferentQualifiersJLabel.java"); - assertPreferredItems(1, "getComponent", "getComponents"); + assertPreferredItems(0, "getComponents", "getComponent"); } public void testDispreferFinalize() throws Throwable { @@ -223,7 +223,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase { } public void testSkipLifted() { - checkPreferredItems(1, "hashCode", "hashCodeMine") + checkPreferredItems(0, "hashCodeMine", "hashCode") } public void testDispreferInnerClasses() { @@ -248,7 +248,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase { } public void testPreferFinallyToFinal() { - checkPreferredItems(1, "final", "finally"); + checkPreferredItems(0, "finally", "final"); } public void testPreferReturn() { @@ -473,8 +473,8 @@ import java.lang.annotation.Target; for (i in 0..10) { incUseCount(lookup, 1) } - assertPreferredItems 1, 'add', 'addAll' - incUseCount(lookup, 0) + assertPreferredItems 0, 'addAll', 'add' + incUseCount(lookup, 1) assertPreferredItems 0, 'add', 'addAll' } @@ -502,8 +502,8 @@ import java.lang.annotation.Target; invokeCompletion(getTestName(false) + ".java") myFixture.completeBasic() myFixture.type('cont') - assertPreferredItems 1, 'contains', 'containsAll' - myFixture.lookup.currentItem = myFixture.lookupElements[0] + assertPreferredItems 0, 'containsAll', 'contains' + myFixture.lookup.currentItem = myFixture.lookupElements[1] myFixture.type('\nc)) {\nif (set.') myFixture.completeBasic() myFixture.type('cont') diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy index 182d22ae1b40..4bac5c3bfa32 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -804,7 +804,7 @@ public class ListUtils { public void testFinalInForLoop2() throws Throwable { configure() - assertStringItems 'final', 'finalize' + myFixture.assertPreferredCompletionItems 0, 'finalize', 'final' } public void testOnlyClassesInExtends() throws Throwable { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy index 9b06de147347..7d4977d6b261 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionOrderingTest.groovy @@ -21,7 +21,7 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase { } public void testJComponentAdd() throws Throwable { - checkPreferredItems(0, "name", "getName", "b", "foo", "fooBean239", "this"); + checkPreferredItems(0, "name", "getName", "b", "fooBean239", "foo", "this"); } public void testJComponentAddNew() throws Throwable { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java index 7806c2fbf413..a2a72a56fbd9 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/CompletionServiceImpl.java @@ -256,17 +256,12 @@ public class CompletionServiceImpl extends CompletionService{ } }); } - } - if (parameters.getCompletionType() == CompletionType.SMART) { - return sorter; - } - return sorter.withClassifier("priority", true, new ClassifierFactory("liftShorter") { @Override public Classifier createClassifier(final Classifier next) { - return new LiftShorterItemsClassifier(next, new LiftShorterItemsClassifier.LiftingCondition()); + return new LiftShorterItemsClassifier(next, new LiftShorterItemsClassifier.LiftingCondition(), false); } }); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/LiftShorterItemsClassifier.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/LiftShorterItemsClassifier.java index bc10ff06258a..f73ca1d941df 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/LiftShorterItemsClassifier.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/impl/LiftShorterItemsClassifier.java @@ -15,7 +15,6 @@ */ package com.intellij.codeInsight.completion.impl; -import com.intellij.codeInsight.completion.CompletionLookupArranger; import com.intellij.codeInsight.lookup.Classifier; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.openapi.util.Condition; @@ -47,16 +46,17 @@ public class LiftShorterItemsClassifier extends Classifier { return new ArrayList(1); } }; - private final Map> myToLiftForSorting = newIdentityHashMap(); - private final Map> myToLiftForPreselection = newIdentityHashMap(); + private final Map> myToLift = newIdentityHashMap(); private final IdentityHashMap, IdentityHashMap>> myPrepends = newIdentityHashMap(); private final Classifier myNext; private final LiftingCondition myCondition; + private final boolean myLiftBefore; private int myCount = 0; - public LiftShorterItemsClassifier(Classifier next, LiftingCondition condition) { + public LiftShorterItemsClassifier(Classifier next, LiftingCondition condition, boolean liftBefore) { myNext = next; myCondition = condition; + myLiftBefore = liftBefore; } @Override @@ -85,10 +85,10 @@ public class LiftShorterItemsClassifier extends Classifier { } private void updateLongerItem(LookupElement shorter, LookupElement longer) { - boolean forPreselection = myCondition.shouldLift(shorter, longer); - Map> map = forPreselection ? myToLiftForPreselection : myToLiftForSorting; - FList oldValue = ContainerUtil.getOrElse(map, longer, FList.emptyList()); - map.put(longer, prependOrReuse(oldValue, shorter)); + if (myCondition.shouldLift(shorter, longer)) { + FList oldValue = ContainerUtil.getOrElse(myToLift, longer, FList.emptyList()); + myToLift.put(longer, prependOrReuse(oldValue, shorter)); + } } private FList prependOrReuse(FList tail, LookupElement head) { @@ -104,27 +104,21 @@ public class LiftShorterItemsClassifier extends Classifier { } private void calculateToLift(LookupElement element) { - FList forPreselection = FList.emptyList(); - FList forSorting = FList.emptyList(); + FList toLift = FList.emptyList(); for (String string : element.getAllLookupStrings()) { for (int len = 1; len < string.length(); len++) { String prefix = string.substring(0, len); for (LookupElement shorterElement : myElements.get(prefix)) { if (myCondition.shouldLift(shorterElement, element)) { - forPreselection = prependOrReuse(forPreselection, shorterElement); - } else { - forSorting = prependOrReuse(forSorting, shorterElement); + toLift = prependOrReuse(toLift, shorterElement); } } } } - if (!forPreselection.isEmpty()) { - myToLiftForPreselection.put(element, forPreselection); - } - if (!forSorting.isEmpty()) { - myToLiftForSorting.put(element, forSorting); + if (!toLift.isEmpty()) { + myToLift.put(element, toLift); } } @@ -164,7 +158,7 @@ public class LiftShorterItemsClassifier extends Classifier { public static class LiftingCondition { public boolean shouldLift(LookupElement shorterElement, LookupElement longerElement) { - return false; + return true; } } @@ -189,7 +183,6 @@ public class LiftShorterItemsClassifier extends Classifier { final Set processed = newIdentityTroveSet(mySrcSet.size()); final Set> arraysProcessed = newIdentityTroveSet(); - final boolean forSorting = myContext.get(CompletionLookupArranger.PURE_RELEVANCE) != Boolean.TRUE; final Iterable next = myNext.classify(mySource, myContext); Iterator base = FilteringIterator.create(next.iterator(), new Condition() { @Override @@ -200,17 +193,16 @@ public class LiftShorterItemsClassifier extends Classifier { return new FlatteningIterator(base) { @Override protected Iterator createValueIterator(LookupElement element) { - List shorter = addShorterElements(null, myToLiftForPreselection.get(element)); - if (forSorting) { - shorter = addShorterElements(shorter, myToLiftForSorting.get(element)); - } + List shorter = addShorterElements(null, myToLift.get(element)); + List singleton = Collections.singletonList(element); if (shorter != null) { if (myLifted != null) { myLifted.addAll(shorter); } - return ContainerUtil.concat(myNext.classify(shorter, myContext), Collections.singletonList(element)).iterator(); + Iterable lifted = myNext.classify(shorter, myContext); + return (myLiftBefore ? ContainerUtil.concat(lifted, singleton) : ContainerUtil.concat(singleton, lifted)).iterator(); } - return Collections.singletonList(element).iterator(); + return singleton.iterator(); } @Nullable From ca038da5b3f91bb8ebaa7cd8c12d3e198f47eaab Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Fri, 7 Dec 2012 18:07:50 +0400 Subject: [PATCH 16/18] IDEA-89113 Spring Autowiring does not work with GWT module and the gwt-user library as dependency in 11.0 - 12 EAP [nik] --- .../impl/providers/PackageReferenceSet.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackageReferenceSet.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackageReferenceSet.java index b0cabca93e44..5e5407b916d1 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackageReferenceSet.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackageReferenceSet.java @@ -17,6 +17,7 @@ package com.intellij.psi.impl.source.resolve.reference.impl.providers; import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.TextRange; import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiElement; @@ -47,13 +48,14 @@ public class PackageReferenceSet extends ReferenceSetBase { return new PsiPackageReference(this, range, index); } - public Collection resolvePackageName(@Nullable PsiPackage context, String packageName) { + public Collection resolvePackageName(@Nullable PsiPackage context, final String packageName) { if (context != null) { - for (PsiPackage aPackage : context.getSubPackages()) { - if (Comparing.equal(aPackage.getName(), packageName)) { - return Collections.singleton(aPackage); + return ContainerUtil.filter(context.getSubPackages(), new Condition() { + @Override + public boolean value(PsiPackage aPackage) { + return Comparing.equal(aPackage.getName(), packageName); } - } + }); } return Collections.emptyList(); } From 45efdbccc38400fd6c4a6beff06b13ae96f256ea Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Fri, 7 Dec 2012 15:24:31 +0100 Subject: [PATCH 17/18] IDEA-96217 (Good code is yellow: 'Contents of StringBuilder never queried') --- ...hedStringBuilderQueryUpdateInspection.java | 20 ++++--------------- .../MismatchedStringBuilderQueryUpdate.java | 7 +++++++ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/MismatchedStringBuilderQueryUpdateInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/MismatchedStringBuilderQueryUpdateInspection.java index 5c0169254c8f..168e27628beb 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/MismatchedStringBuilderQueryUpdateInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/MismatchedStringBuilderQueryUpdateInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 Bas Leijdekkers + * Copyright 2011-2012 Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -92,7 +92,8 @@ public class MismatchedStringBuilderQueryUpdateInspection extends BaseInspection private static class MismatchedQueryAndUpdateOfStringBuilderVisitor extends BaseInspectionVisitor { @Override - public void visitField(PsiField field) { super.visitField(field); + public void visitField(PsiField field) { + super.visitField(field); if (!field.hasModifierProperty(PsiModifier.PRIVATE)) { return; } @@ -272,19 +273,6 @@ public class MismatchedStringBuilderQueryUpdateInspection extends BaseInspection queryNames.add("substring"); } - @NonNls - private static final Set returnThisNames = new HashSet(); - - static { - returnThisNames.add("append"); - returnThisNames.add("appendCodePoint"); - returnThisNames.add("delete"); - returnThisNames.add("delete"); - returnThisNames.add("deleteCharAt"); - returnThisNames.add("insert"); - returnThisNames.add("replace"); - } - private final PsiVariable variable; private boolean queried = false; @@ -340,7 +328,7 @@ public class MismatchedStringBuilderQueryUpdateInspection extends BaseInspection final String name = methodExpression.getReferenceName(); final PsiExpression qualifierExpression = methodExpression.getQualifierExpression(); if (!queryNames.contains(name)) { - if (returnThisNames.contains(name) && hasReferenceToVariable(variable, qualifierExpression) && isVariableValueUsed(expression)) { + if (returnSelfNames.contains(name) && hasReferenceToVariable(variable, qualifierExpression) && isVariableValueUsed(expression)) { queried = true; } return; diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_string_builder_query_update/MismatchedStringBuilderQueryUpdate.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_string_builder_query_update/MismatchedStringBuilderQueryUpdate.java index 56102609182c..ce84d8e173f9 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_string_builder_query_update/MismatchedStringBuilderQueryUpdate.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/mismatched_string_builder_query_update/MismatchedStringBuilderQueryUpdate.java @@ -10,4 +10,11 @@ public class MismatchedStringBuilderQueryUpdate { final StringBuilder c = new StringBuilder(); c.append(' '); } + + private static CharSequence getSomething() + { + StringBuilder sb = new StringBuilder(); + sb.append("abc"); + return sb.reverse(); + } } From c60116561d415397cb853f01e174ed2b4b82640e Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 7 Dec 2012 15:27:00 +0100 Subject: [PATCH 18/18] NPE --- .../hint/ImplementationViewComponent.java | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ImplementationViewComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ImplementationViewComponent.java index 5a4c7af584c9..1e2c9e2f60f2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ImplementationViewComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ImplementationViewComponent.java @@ -194,25 +194,6 @@ public class ImplementationViewComponent extends JPanel { gc.fill = GridBagConstraints.HORIZONTAL; gc.weightx = 1; myLabel = new JLabel(); - if (myElements.length > 1) { - updateRenderer(project); - myLabel.setVisible(false); - } - else { - myFileChooser = new ComboBox(); - myFileChooser.setVisible(false); - myCountLabel.setVisible(false); - - VirtualFile file = psiFile.getVirtualFile(); - if (file != null) { - myLabel.setIcon(getIconForFile(psiFile)); - myLabel.setForeground(FileStatusManager.getInstance(project).getStatus(file).getColor()); - myLabel.setText(file.getPresentableName()); - myLabel.setBorder(new CompoundBorder(IdeBorderFactory.createRoundedBorder(), IdeBorderFactory.createEmptyBorder(0, 0, 0, 5))); - } - toolbarPanel.add(myLabel, gc); - } - myFileChooser = new ComboBox(fileDescriptors.toArray(new FileDescriptor[fileDescriptors.size()]), 250); myFileChooser.addActionListener(new ActionListener() { @Override @@ -226,6 +207,24 @@ public class ImplementationViewComponent extends JPanel { }); toolbarPanel.add(myFileChooser, gc); + if (myElements.length > 1) { + updateRenderer(project); + myLabel.setVisible(false); + } + else { + myFileChooser.setVisible(false); + myCountLabel.setVisible(false); + + VirtualFile file = psiFile.getVirtualFile(); + if (file != null) { + myLabel.setIcon(getIconForFile(psiFile)); + myLabel.setForeground(FileStatusManager.getInstance(project).getStatus(file).getColor()); + myLabel.setText(file.getPresentableName()); + myLabel.setBorder(new CompoundBorder(IdeBorderFactory.createRoundedBorder(), IdeBorderFactory.createEmptyBorder(0, 0, 0, 5))); + } + toolbarPanel.add(myLabel, gc); + } + gc.fill = GridBagConstraints.NONE; gc.weightx = 0; toolbarPanel.add(myCountLabel, gc);