From 48921aff8d617ddba07c827b7ddce94445a082ff Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 24 Feb 2014 12:19:17 +0100 Subject: [PATCH 01/39] console gutter component should use setAdditionalColumnsCount now (we use editor area) rename outdated historyAnnotation --- .../console/ConsoleGutterComponent.java | 16 +++--- .../console/LanguageConsoleBuilder.java | 49 +++++++++++++------ .../console/LanguageConsoleImpl.java | 12 +++-- 3 files changed, 52 insertions(+), 25 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/console/ConsoleGutterComponent.java b/platform/lang-impl/src/com/intellij/execution/console/ConsoleGutterComponent.java index 7dfdfc198a71..ecb6cfc2a586 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/ConsoleGutterComponent.java +++ b/platform/lang-impl/src/com/intellij/execution/console/ConsoleGutterComponent.java @@ -60,9 +60,9 @@ class ConsoleGutterComponent extends JComponent implements MouseMotionListener { }); } - public void updateSize() { + public void updateSize(int start, int end) { int oldAnnotationsWidth = maxAnnotationWidth; - computeMaxAnnotationWidth(); + computeMaxAnnotationWidth(start, end); if (oldAnnotationsWidth != maxAnnotationWidth || myLastPreferredHeight != editor.getPreferredHeight()) { fireResized(); } @@ -73,7 +73,7 @@ class ConsoleGutterComponent extends JComponent implements MouseMotionListener { processComponentEvent(new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED)); } - private void computeMaxAnnotationWidth() { + private void computeMaxAnnotationWidth(int start, int end) { gutterContentProvider.beforeUiComponentUpdate(editor); if (!gutterContentProvider.hasText()) { @@ -82,10 +82,10 @@ class ConsoleGutterComponent extends JComponent implements MouseMotionListener { } FontMetrics fontMetrics = editor.getFontMetrics(Font.PLAIN); - int lineCount = editor.getDocument().getLineCount(); + int lineCount = Math.min(end, editor.getDocument().getLineCount()); int gutterSize = 0; - for (int i = 0; i < lineCount; i++) { - String text = gutterContentProvider.getText(i, editor); + for (int line = start; line < lineCount; line++) { + String text = gutterContentProvider.getText(line, editor); if (text != null) { gutterSize = Math.max(gutterSize, fontMetrics.stringWidth(text)); } @@ -94,7 +94,9 @@ class ConsoleGutterComponent extends JComponent implements MouseMotionListener { if (gutterSize != 0) { gutterSize += lineEndInset; } - maxAnnotationWidth = gutterSize; + maxAnnotationWidth = Math.max(gutterSize, maxAnnotationWidth); + + editor.getSettings().setAdditionalColumnsCount(1 + (maxAnnotationWidth / EditorUtil.getSpaceWidth(Font.PLAIN, editor))); } @Override diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java index fb5593bcd4bb..ac16686432c7 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java @@ -125,7 +125,7 @@ public final class LanguageConsoleBuilder { return new Pair(action, historyController); } - public LanguageConsoleBuilder historyAnnotation(@Nullable GutterContentProvider value) { + public LanguageConsoleBuilder gutterContentProvider(@Nullable GutterContentProvider value) { gutterContentProvider = value; return this; } @@ -196,6 +196,11 @@ public final class LanguageConsoleBuilder { this.psiFileFactory = psiFileFactory; } + @Override + boolean isHistoryViewerForceAdditionalColumnsUsage() { + return gutterContentProvider == null; + } + @NotNull @Override protected PsiFile createFile(@NotNull LightVirtualFile virtualFile, @NotNull Document document, @NotNull Project project) { @@ -288,7 +293,7 @@ public final class LanguageConsoleBuilder { private final ConsoleIconGutterComponent lineStartGutter; private final ConsoleGutterComponent lineEndGutter; - private Runnable gutterSizeUpdater; + private Task gutterSizeUpdater; private RangeHighlighterEx lineSeparatorPainter; public GutterUpdateScheduler(@NotNull ConsoleIconGutterComponent lineStartGutter, @NotNull ConsoleGutterComponent lineEndGutter) { @@ -333,7 +338,7 @@ public final class LanguageConsoleBuilder { int startDocLine = document.getLineNumber(event.getOffset()); int endDocLine = document.getLineNumber(event.getOffset() + event.getNewLength()); if (event.getOldLength() > event.getNewLength() || startDocLine != endDocLine || StringUtil.indexOf(event.getOldFragment(), '\n') != -1) { - updateGutterSize(); + updateGutterSize(0, Integer.MAX_VALUE); } } else if (event.getOldLength() > 0) { @@ -342,6 +347,8 @@ public final class LanguageConsoleBuilder { } private void documentCleared() { + gutterSizeUpdater = null; + assert gutterContentProvider != null; gutterContentProvider.documentCleared(getHistoryViewer()); } @@ -358,26 +365,38 @@ public final class LanguageConsoleBuilder { else { addLineSeparatorPainterIfNeed(); } - updateGutterSize(); + updateGutterSize(0, Integer.MAX_VALUE); } - private void updateGutterSize() { + private void updateGutterSize(int start, int end) { if (gutterSizeUpdater != null) { + gutterSizeUpdater.start = Math.min(start, gutterSizeUpdater.start); + gutterSizeUpdater.end = Math.max(end, gutterSizeUpdater.end); return; } - gutterSizeUpdater = new Runnable() { - @Override - public void run() { - if (!getHistoryViewer().isDisposed()) { - lineStartGutter.updateSize(); - lineEndGutter.updateSize(); - } - gutterSizeUpdater = null; - } - }; + gutterSizeUpdater = new Task(start, end); SwingUtilities.invokeLater(gutterSizeUpdater); } + + private final class Task implements Runnable { + private int start; + private int end; + + public Task(int start, int end) { + this.start = start; + this.end = end; + } + + @Override + public void run() { + if (!getHistoryViewer().isDisposed()) { + lineStartGutter.updateSize(); + lineEndGutter.updateSize(start, end); + } + gutterSizeUpdater = null; + } + } } private final class LineSeparatorPainter extends RangeMarkerImpl implements RangeHighlighterEx, Getter { diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java index 3ec577da2259..da38faf0f8f5 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java @@ -682,6 +682,10 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider { return ObjectUtils.assertNotNull(PsiManager.getInstance(project).findFile(virtualFile)); } + boolean isHistoryViewerForceAdditionalColumnsUsage() { + return true; + } + private class MyLayout extends AbstractLayoutManager { @Override public Dimension preferredLayoutSize(final Container parent) { @@ -713,9 +717,11 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider { // deal with width final int width = Math.max(editorSize.width, historySize.width); newEditorSize.width = width + editor.getScrollPane().getHorizontalScrollBar().getHeight(); - history.getSoftWrapModel().forceAdditionalColumnsUsage(); - editor.getSettings().setAdditionalColumnsCount(2 + (width - editorSize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, editor)); - history.getSettings().setAdditionalColumnsCount(2 + (width - historySize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, history)); + if (isHistoryViewerForceAdditionalColumnsUsage()) { + history.getSoftWrapModel().forceAdditionalColumnsUsage(); + editor.getSettings().setAdditionalColumnsCount(2 + (width - editorSize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, editor)); + history.getSettings().setAdditionalColumnsCount(2 + (width - historySize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, history)); + } // deal with height if (historySize.width == 0) { From f32b77f5f82c4bda22531c1a7169fe1aaf8b181c Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 24 Feb 2014 14:48:52 +0100 Subject: [PATCH 02/39] use install icon and fg/bg on update button --- .../intellij/ide/plugins/PluginHeaderPanel.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java index 0c27f99e7c58..8fc55d06a397 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java @@ -115,7 +115,13 @@ public class PluginHeaderPanel { myVersion.setText("Version: " + (version == null ? "N/A" : version)); myUpdated.setVisible(false); if (!plugin.isBundled()) { - myActionId = ((IdeaPluginDescriptorImpl)plugin).isDeleted() ? ACTION_ID.RESTART : ACTION_ID.UNINSTALL; + if (((IdeaPluginDescriptorImpl)plugin).isDeleted()) { + myActionId = ACTION_ID.RESTART; + } else if (InstalledPluginsTableModel.hasNewerVersion(plugin.getPluginId())) { + myActionId = ACTION_ID.UPDATE; + } else { + myActionId = ACTION_ID.UNINSTALL; + } } if (myActionId == ACTION_ID.RESTART && myManager != null && !myManager.isRequireShutdown()) { myActionId = null; @@ -167,7 +173,7 @@ public class PluginHeaderPanel { private Color getButtonForeground() { switch (myActionId) { - case UPDATE: return new JBColor(Gray._0, Gray._20); + case UPDATE: return new JBColor(Gray._0, Gray._210); case INSTALL: return new JBColor(Gray._255, Gray._210); case UNINSTALL: return new JBColor(Gray._0, Gray._140); case RESTART: @@ -179,7 +185,7 @@ public class PluginHeaderPanel { private Paint getBackgroundPaint() { switch (myActionId) { - case UPDATE: return new JBColor(new Color(209, 190, 114), new Color(132, 116, 66)); + case UPDATE: return new JBColor(new Color(209, 190, 114), new Color(49, 98, 49)); case INSTALL: return new JBColor(new Color(0x4DA864), new Color(49, 98, 49)); case UNINSTALL: return UIUtil.isUnderDarcula() ? new GradientPaint(0, 0, UIManager.getColor("Button.darcula.color1"), @@ -216,7 +222,7 @@ public class PluginHeaderPanel { @Override public Icon getIcon() { switch (myActionId) { - case UPDATE: return AllIcons.Actions.Refresh; + case UPDATE: return AllIcons.General.DownloadPlugin; case INSTALL: return AllIcons.General.DownloadPlugin; case UNINSTALL: return AllIcons.Actions.Delete; case RESTART: return AllIcons.Actions.Restart; From 0c614ba6789cbf9ddbe9db501735403bb08b3093 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 24 Feb 2014 14:49:16 +0100 Subject: [PATCH 03/39] IDEA-121031 Plugin Manager: "Update plugin" button does nothing --- .../src/com/intellij/ide/plugins/PluginHeaderPanel.java | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java index 8fc55d06a397..e6664c0845e6 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java @@ -236,7 +236,6 @@ public class PluginHeaderPanel { public void actionPerformed(ActionEvent e) { switch (myActionId) { case UPDATE: - break; case INSTALL: new ActionInstallPlugin(myManager.getAvailable(), myManager.getInstalled()).install(new Runnable() { @Override From e17305af54101a1789dfd8c64affc4bf7bbecbeb Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 24 Feb 2014 18:12:56 +0400 Subject: [PATCH 04/39] diff: optimise reindexer do not recreate BitSet if there was nothing discarded --- .../src/com/intellij/util/diff/Reindexer.java | 81 ++++++++++--------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/platform/util/src/com/intellij/util/diff/Reindexer.java b/platform/util/src/com/intellij/util/diff/Reindexer.java index e30849e5853b..13d7f7910c77 100644 --- a/platform/util/src/com/intellij/util/diff/Reindexer.java +++ b/platform/util/src/com/intellij/util/diff/Reindexer.java @@ -41,8 +41,9 @@ class Reindexer { for (int j = 0; j < 2; j++) { int originalLength = myOriginalLengths[j]; myOldIndecies[j] = new int[originalLength]; - for (int i = 0; i < originalLength; i++) + for (int i = 0; i < originalLength; i++) { myOldIndecies[j][i] = i; + } } } @@ -75,50 +76,58 @@ class Reindexer { } public void reindex(BitSet[] discardedChanges, LCSBuilder builder) { - BitSet changes1 = new BitSet(myOriginalLengths[0]); - BitSet changes2 = new BitSet(myOriginalLengths[1]); + BitSet changes1; + BitSet changes2; + + if (myDiscardedLengths[0] == myOriginalLengths[0] && myDiscardedLengths[0] == myOriginalLengths[0]) { + changes1 = discardedChanges[0]; + changes2 = discardedChanges[1]; + } + else { + changes1 = new BitSet(myOriginalLengths[0]); + changes2 = new BitSet(myOriginalLengths[1]); + int x = 0; + int y = 0; + while (x < myDiscardedLengths[0] || y < myDiscardedLengths[1]) { + if ((x < myDiscardedLengths[0] && y < myDiscardedLengths[1]) && !discardedChanges[0].get(x) && !discardedChanges[1].get(y)) { + x = increment(myOldIndecies[0], x, changes1, myOriginalLengths[0]); + y = increment(myOldIndecies[1], y, changes2, myOriginalLengths[1]); + continue; + } + if (discardedChanges[0].get(x)) { + changes1.set(getOriginal(myOldIndecies[0], x)); + x = increment(myOldIndecies[0], x, changes1, myOriginalLengths[0]); + continue; + } + if (discardedChanges[1].get(y)) { + changes2.set(getOriginal(myOldIndecies[1], y)); + y = increment(myOldIndecies[1], y, changes2, myOriginalLengths[1]); + continue; + } + } + if (myDiscardedLengths[0] == 0) { + changes1.set(0, myOriginalLengths[0]); + } + else { + changes1.set(0, myOldIndecies[0][0]); + } + if (myDiscardedLengths[1] == 0) { + changes2.set(0, myOriginalLengths[1]); + } + else { + changes2.set(0, myOldIndecies[1][0]); + } + } int x = 0; int y = 0; - while (x < myDiscardedLengths[0] || y < myDiscardedLengths[1]) { - if ((x < myDiscardedLengths[0] && y < myDiscardedLengths[1]) && !discardedChanges[0].get(x) && !discardedChanges[1].get(y)) { - x = increment(myOldIndecies[0], x, changes1, myOriginalLengths[0]); - y = increment(myOldIndecies[1], y, changes2, myOriginalLengths[1]); - continue; - } - if (discardedChanges[0].get(x)) { - changes1.set(getOriginal(myOldIndecies[0], x)); - x = increment(myOldIndecies[0], x, changes1, myOriginalLengths[0]); - continue; - } - if (discardedChanges[1].get(y)) { - changes2.set(getOriginal(myOldIndecies[1], y)); - y = increment(myOldIndecies[1], y, changes2, myOriginalLengths[1]); - continue; - } - } - if (myDiscardedLengths[0] == 0) { - changes1.set(0, myOriginalLengths[0]); - } - else { - changes1.set(0, myOldIndecies[0][0]); - } - if (myDiscardedLengths[1] == 0) { - changes2.set(0, myOriginalLengths[1]); - } - else { - changes2.set(0, myOldIndecies[1][0]); - } - - x = 0; - y = 0; while (x < myOriginalLengths[0] && y < myOriginalLengths[1]) { int startX = x; while (x < myOriginalLengths[0] && y < myOriginalLengths[1] && !changes1.get(x) && !changes2.get(y)) { x++; y++; } - if (x> startX) builder.addEqual(x - startX); + if (x > startX) builder.addEqual(x - startX); int dx = 0; int dy = 0; while (x < myOriginalLengths[0] && changes1.get(x)) { From a23a0a630fe955ddcd6804189fef609870aee94f Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 24 Feb 2014 18:12:57 +0400 Subject: [PATCH 05/39] diff: do not forget about start offset --- .../util/src/com/intellij/util/diff/PatienceIntLCS.java | 2 +- .../testSrc/com/intellij/util/diff/PatienceIntLCSTest.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/util/src/com/intellij/util/diff/PatienceIntLCS.java b/platform/util/src/com/intellij/util/diff/PatienceIntLCS.java index 8f04dfa10257..5acb8272c8fb 100644 --- a/platform/util/src/com/intellij/util/diff/PatienceIntLCS.java +++ b/platform/util/src/com/intellij/util/diff/PatienceIntLCS.java @@ -55,7 +55,7 @@ public class PatienceIntLCS { return; } - int startOffset = matchForward(0, 0); + int startOffset = matchForward(myStart1, myStart2); int start1 = myStart1 + startOffset; int start2 = myStart2 + startOffset; diff --git a/platform/util/testSrc/com/intellij/util/diff/PatienceIntLCSTest.java b/platform/util/testSrc/com/intellij/util/diff/PatienceIntLCSTest.java index eb9c1dc2905e..e82a990e45d3 100644 --- a/platform/util/testSrc/com/intellij/util/diff/PatienceIntLCSTest.java +++ b/platform/util/testSrc/com/intellij/util/diff/PatienceIntLCSTest.java @@ -70,6 +70,13 @@ public class PatienceIntLCSTest extends TestCase { new int[]{0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}); } + public void testBug1() throws FilesTooBigForDiffException { + BitSet[] change = buildChange(new int[]{2, 3, 4, 6, 7, 8, 9, 11, 12, 4, 6, 11, 15}, + new int[]{2, 3, 6, 7, 8, 9, 6, 11, 12, 4, 11, 15, 6}); + checkChange(change, new int[]{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, + new int[]{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0}); + } + public void testInnerChunks1() throws FilesTooBigForDiffException { BitSet[] change = buildChange(new int[]{0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0}, new int[]{1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1}); checkChange(change, new int[]{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}, new int[]{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}); From c598b17c41877dc477dc0e4fbd17e072f85e0a08 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 24 Feb 2014 15:26:22 +0400 Subject: [PATCH 06/39] @TestOnly --- platform/util/src/com/intellij/util/diff/Reindexer.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/util/src/com/intellij/util/diff/Reindexer.java b/platform/util/src/com/intellij/util/diff/Reindexer.java index 13d7f7910c77..55247ac521c6 100644 --- a/platform/util/src/com/intellij/util/diff/Reindexer.java +++ b/platform/util/src/com/intellij/util/diff/Reindexer.java @@ -16,6 +16,7 @@ package com.intellij.util.diff; import gnu.trove.TIntArrayList; +import org.jetbrains.annotations.TestOnly; import java.util.Arrays; import java.util.BitSet; @@ -33,6 +34,7 @@ class Reindexer { return new int[][]{discarded1, discard(discarded1, ints2, 1)}; } + @TestOnly void idInit(int length1, int length2) { myOriginalLengths[0] = length1; myOriginalLengths[1] = length2; @@ -47,7 +49,8 @@ class Reindexer { } } - public int restoreIndex(int index, int array) { + @TestOnly + int restoreIndex(int index, int array) { return myOldIndecies[array][index]; } From 3d789e34499ea5d296abadd4627c423fd17e4a02 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Mon, 24 Feb 2014 19:26:11 +0400 Subject: [PATCH 07/39] temporary fix for completion issue (IDEA-80056, EA-54248) --- .../completion/NormalCompletionTest.groovy | 12 ++++++ .../editor/actionSystem/TypedAction.java | 42 +++++++++++-------- 2 files changed, 36 insertions(+), 18 deletions(-) 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 00a635d96386..9472cedeca3c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -1384,6 +1384,18 @@ class Foo {{ doMultiCaretTest() } + public void testFinishWithEqualsWhenMultipleCaretsAreEnabled() { + EditorTestUtil.enableMultipleCarets() + try { + configureByFile("SpacesAroundEq.java"); + type('='); + checkResultByFile("SpacesAroundEq_after.java"); + } + finally { + EditorTestUtil.disableMultipleCarets() + } + } + public void "test complete lowercase class name"() { myFixture.addClass("package foo; public class myClass {}") myFixture.configureByText "a.java", """ diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/TypedAction.java b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/TypedAction.java index c52ec738af4e..28bc0f0510ed 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/TypedAction.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/TypedAction.java @@ -51,7 +51,7 @@ public class TypedAction { private static class Handler implements TypedActionHandler { @Override - public void execute(@NotNull Editor editor, char charTyped, @NotNull DataContext dataContext) { + public void execute(@NotNull final Editor editor, char charTyped, @NotNull DataContext dataContext) { if (editor.isViewer()) return; Document doc = editor.getDocument(); @@ -64,7 +64,18 @@ public class TypedAction { try { final String str = String.valueOf(charTyped); CommandProcessor.getInstance().setCurrentCommandName(EditorBundle.message("typing.in.editor.command.name")); - EditorModificationUtil.typeInStringAtCaretHonorBlockSelection(editor, str, true); + + if (editor.getCaretModel().getAllCarets().size() == 1) { // temporary fix for completion - going forward we shouldn't use this check + EditorModificationUtil.typeInStringAtCaretHonorBlockSelection(editor, str, true); + } + else { + editor.getCaretModel().runForEachCaret(new CaretAction() { + @Override + public void perform(Caret caret) { + EditorModificationUtil.typeInStringAtCaretHonorBlockSelection(editor, str, true); + } + }); + } } catch (ReadOnlyFragmentModificationException e) { EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(doc).handle(e); @@ -127,22 +138,17 @@ public class TypedAction { ApplicationManager.getApplication().runWriteAction(new DocumentRunnable(myEditor.getDocument(), myEditor.getProject()) { @Override public void run() { - myEditor.getCaretModel().runForEachCaret(new CaretAction() { - @Override - public void perform(Caret caret) { - Document doc = myEditor.getDocument(); - doc.startGuardedBlockChecking(); - try { - getHandler().execute(myEditor, myCharTyped, myDataContext); - } - catch (ReadOnlyFragmentModificationException e) { - EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(doc).handle(e); - } - finally { - doc.stopGuardedBlockChecking(); - } - } - }); + Document doc = myEditor.getDocument(); + doc.startGuardedBlockChecking(); + try { + getHandler().execute(myEditor, myCharTyped, myDataContext); + } + catch (ReadOnlyFragmentModificationException e) { + EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(doc).handle(e); + } + finally { + doc.stopGuardedBlockChecking(); + } } }); } From 4edfd8ed17d13a9194213223372db235b1c80c82 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 24 Feb 2014 19:20:35 +0400 Subject: [PATCH 08/39] remove possible deadlock on network operation in EDT --- .../com/intellij/util/net/ssl/CertificatesManager.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/platform-api/src/com/intellij/util/net/ssl/CertificatesManager.java b/platform/platform-api/src/com/intellij/util/net/ssl/CertificatesManager.java index bc1f52629de6..ff02df7e49fe 100644 --- a/platform/platform-api/src/com/intellij/util/net/ssl/CertificatesManager.java +++ b/platform/platform-api/src/com/intellij/util/net/ssl/CertificatesManager.java @@ -197,7 +197,7 @@ public class CertificatesManager implements ApplicationComponent, PersistentStat Application app = ApplicationManager.getApplication(); final CountDownLatch proceeded = new CountDownLatch(1); final AtomicBoolean accepted = new AtomicBoolean(); - app.invokeLater(new Runnable() { + Runnable showDialog = new Runnable() { @Override public void run() { try { @@ -211,7 +211,13 @@ public class CertificatesManager implements ApplicationComponent, PersistentStat proceeded.countDown(); } } - }, ModalityState.any()); + }; + if (app.isDispatchThread()) { + showDialog.run(); + } + else { + app.invokeLater(showDialog, ModalityState.any()); + } try { proceeded.await(); } From 5a6339bd067cf87a5e62a50d466700c3cc178226 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 24 Feb 2014 19:21:36 +0400 Subject: [PATCH 09/39] github: assert -> warning This is bad, but will be fixed later --- .../src/org/jetbrains/plugins/github/api/GithubApiUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java b/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java index 2036b3546030..ec7d3ae2b51d 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java +++ b/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java @@ -94,7 +94,9 @@ public class GithubApiUtil { @Nullable String requestBody, @NotNull Collection
headers, @NotNull HttpVerb verb) throws IOException { - LOG.assertTrue(!EventQueue.isDispatchThread() || ApplicationManager.getApplication().isUnitTestMode(), "Network operation in EDT"); + if (EventQueue.isDispatchThread() && !ApplicationManager.getApplication().isUnitTestMode()) { + LOG.warn("Network operation in EDT"); + } HttpMethod method = null; try { From e167ddf4a50efb7369b1fa42e8e9554eb9a83c45 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 24 Feb 2014 19:39:16 +0400 Subject: [PATCH 10/39] github: fix tests --- plugins/github/github.iml | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/github/github.iml b/plugins/github/github.iml index 4a9a26bd3323..38d066453ccf 100644 --- a/plugins/github/github.iml +++ b/plugins/github/github.iml @@ -24,6 +24,7 @@ + From 1cc06ea2ee1b3086944572e613983851b5906053 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 24 Feb 2014 16:38:26 +0100 Subject: [PATCH 11/39] text will be assigned automatically --- .../src/com/intellij/ide/actions/SplitAction.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SplitAction.java b/platform/platform-impl/src/com/intellij/ide/actions/SplitAction.java index 1e4c10d6feba..5e8de1b19bf1 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/SplitAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/SplitAction.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. @@ -15,15 +15,15 @@ */ package com.intellij.ide.actions; -import com.intellij.ide.IdeBundle; -import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; import com.intellij.openapi.fileEditor.impl.EditorWindow; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; -import javax.swing.*; - /** * @author Vladimir Kondratyev */ @@ -45,9 +45,6 @@ public abstract class SplitAction extends AnAction implements DumbAware { public void update(final AnActionEvent event) { final Project project = CommonDataKeys.PROJECT.getData(event.getDataContext()); final Presentation presentation = event.getPresentation(); - presentation.setText (myOrientation == SwingConstants.VERTICAL - ? IdeBundle.message("action.split.vertically") - : IdeBundle.message("action.split.horizontally")); if (project == null) { presentation.setEnabled(false); return; From 0120c91c6d1d9d499e627d4268d874e7ed4cd779 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 24 Feb 2014 16:48:30 +0100 Subject: [PATCH 12/39] Generify to support move to right and move to down actions --- .../com/intellij/ide/actions/SplitAction.java | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SplitAction.java b/platform/platform-impl/src/com/intellij/ide/actions/SplitAction.java index 5e8de1b19bf1..aa2ce0014ba9 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/SplitAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/SplitAction.java @@ -18,38 +18,45 @@ package com.intellij.ide.actions; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; import com.intellij.openapi.fileEditor.impl.EditorWindow; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; /** * @author Vladimir Kondratyev + * @author Konstantin Bulenkov */ public abstract class SplitAction extends AnAction implements DumbAware { private final int myOrientation; + private final boolean myCloseSource; - protected SplitAction(final int orientation){ + protected SplitAction(final int orientation) { + this(orientation, false); + } + + protected SplitAction(final int orientation, boolean closeSource) { myOrientation = orientation; + myCloseSource = closeSource; } public void actionPerformed(final AnActionEvent event) { - final Project project = CommonDataKeys.PROJECT.getData(event.getDataContext()); + final Project project = event.getData(CommonDataKeys.PROJECT); final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project); - final EditorWindow window = EditorWindow.DATA_KEY.getData(event.getDataContext()); + final EditorWindow window = event.getData(EditorWindow.DATA_KEY); + final VirtualFile file = event.getData(CommonDataKeys.VIRTUAL_FILE); fileEditorManager.createSplitter(myOrientation, window); + + if (myCloseSource && window != null && file != null) { + window.closeFile(file, false, false); + } } public void update(final AnActionEvent event) { - final Project project = CommonDataKeys.PROJECT.getData(event.getDataContext()); - final Presentation presentation = event.getPresentation(); - if (project == null) { - presentation.setEnabled(false); - return; - } - final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project); - presentation.setEnabled(fileEditorManager.hasOpenedFile ()); + final Project project = event.getData(CommonDataKeys.PROJECT); + final boolean enabled = project != null && FileEditorManagerEx.getInstanceEx(project).hasOpenedFile(); + event.getPresentation().setEnabled(enabled); } } From 479f584cfaaabba8128abb2097c8c689b67b98bc Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 24 Feb 2014 16:49:11 +0100 Subject: [PATCH 13/39] move to right and move to down actions --- .../ide/actions/MoveTabDownAction.java | 27 +++++++++++++++++++ .../ide/actions/MoveTabRightAction.java | 27 +++++++++++++++++++ .../src/messages/ActionsBundle.properties | 4 +++ .../src/idea/PlatformActions.xml | 4 +++ 4 files changed, 62 insertions(+) create mode 100644 platform/platform-impl/src/com/intellij/ide/actions/MoveTabDownAction.java create mode 100644 platform/platform-impl/src/com/intellij/ide/actions/MoveTabRightAction.java diff --git a/platform/platform-impl/src/com/intellij/ide/actions/MoveTabDownAction.java b/platform/platform-impl/src/com/intellij/ide/actions/MoveTabDownAction.java new file mode 100644 index 000000000000..77aa887ef551 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ide/actions/MoveTabDownAction.java @@ -0,0 +1,27 @@ +/* + * 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.intellij.ide.actions; + +import javax.swing.*; + +/** + * @author Konstantin Bulenkov + */ +public class MoveTabDownAction extends SplitAction { + protected MoveTabDownAction() { + super(SwingConstants.HORIZONTAL, true); + } +} diff --git a/platform/platform-impl/src/com/intellij/ide/actions/MoveTabRightAction.java b/platform/platform-impl/src/com/intellij/ide/actions/MoveTabRightAction.java new file mode 100644 index 000000000000..82f7572a0367 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ide/actions/MoveTabRightAction.java @@ -0,0 +1,27 @@ +/* + * 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.intellij.ide.actions; + +import javax.swing.*; + +/** + * @author Konstantin Bulenkov + */ +public class MoveTabRightAction extends SplitAction { + protected MoveTabRightAction() { + super(SwingConstants.VERTICAL, true); + } +} diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index fa38ddeae330..8d51e6b5dbd2 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -834,6 +834,10 @@ action.SplitVertically.text=Split _Vertically action.SplitVertically.description=Split editor area into 2 tab groups and move the current tab to the right group action.SplitHorizontally.text=Split _Horizontally action.SplitHorizontally.description=Split editor area into 2 tab groups and move the current tab to the bottom group +action.MoveTabRight.text=Move Right +action.MoveTabRight.description=Split editor area into 2 tab groups and move the current tab to the right group and close the left editor +action.MoveTabDown.text=Move Down +action.MoveTabDown.description=Split editor area into 2 tab groups and move the current tab to the bottom group and close the top editor action.ChangeSplitOrientation.text=Change Splitter O_rientation action.ChangeSplitOrientation.description=Changes orientation of splitter action.Unsplit.text=Un_split diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 9902476aab7f..e0e136024f2a 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -376,6 +376,8 @@ + + @@ -478,6 +480,8 @@ + + From cd5c3c95f72093bbf8bf5a0fa0109ec797fd88da Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 24 Feb 2014 16:58:32 +0100 Subject: [PATCH 14/39] check there are at least 2 tabs are open for move operations --- .../src/com/intellij/ide/actions/SplitAction.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SplitAction.java b/platform/platform-impl/src/com/intellij/ide/actions/SplitAction.java index aa2ce0014ba9..fb55f3649484 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/SplitAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/SplitAction.java @@ -56,7 +56,11 @@ public abstract class SplitAction extends AnAction implements DumbAware { public void update(final AnActionEvent event) { final Project project = event.getData(CommonDataKeys.PROJECT); - final boolean enabled = project != null && FileEditorManagerEx.getInstanceEx(project).hasOpenedFile(); + final EditorWindow window = event.getData(EditorWindow.DATA_KEY); + final int minimum = myCloseSource ? 2 : 1; + final boolean enabled = project != null + && window != null + && window.getTabCount() >= minimum; event.getPresentation().setEnabled(enabled); } } From a216ae3456b7d806201c6af41bb8d8894c023225 Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Mon, 24 Feb 2014 19:18:26 +0400 Subject: [PATCH 15/39] DBE: manage data sources action --- .../com/intellij/openapi/keymap/KeymapUtil.java | 17 +++++------------ .../com/intellij/openapi/wm/ToolWindowId.java | 1 + .../fileEditor/impl/EditorEmptyTextPainter.java | 3 ++- .../src/messages/UIBundle.properties | 1 + 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/keymap/KeymapUtil.java b/platform/platform-api/src/com/intellij/openapi/keymap/KeymapUtil.java index 6c2dc85a09fe..7be0993de405 100644 --- a/platform/platform-api/src/com/intellij/openapi/keymap/KeymapUtil.java +++ b/platform/platform-api/src/com/intellij/openapi/keymap/KeymapUtil.java @@ -24,6 +24,7 @@ import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.registry.RegistryValue; import com.intellij.openapi.util.registry.RegistryValueListener; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.containers.ContainerUtil; import org.intellij.lang.annotations.JdkConstants; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -187,23 +188,15 @@ public class KeymapUtil { @NotNull public static String getFirstKeyboardShortcutText(@NotNull String actionId) { Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionId); - for (Shortcut shortcut : shortcuts) { - if (shortcut instanceof KeyboardShortcut) { - return getShortcutText(shortcut); - } - } - return ""; + KeyboardShortcut shortcut = ContainerUtil.findInstance(shortcuts, KeyboardShortcut.class); + return shortcut == null? "" : getShortcutText(shortcut); } @NotNull public static String getFirstKeyboardShortcutText(@NotNull AnAction action) { Shortcut[] shortcuts = action.getShortcutSet().getShortcuts(); - for (Shortcut shortcut : shortcuts) { - if (shortcut instanceof KeyboardShortcut) { - return getShortcutText(shortcut); - } - } - return ""; + KeyboardShortcut shortcut = ContainerUtil.findInstance(shortcuts, KeyboardShortcut.class); + return shortcut == null ? "" : getShortcutText(shortcut); } public static String getShortcutsText(Shortcut[] shortcuts) { diff --git a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowId.java b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowId.java index b572f15f0f44..edcf3b87ae2a 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowId.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowId.java @@ -37,4 +37,5 @@ public interface ToolWindowId { String DUPLICATES = UIBundle.message("tool.window.name.module.duplicates"); String DOCUMENTATION = UIBundle.message("tool.window.name.documentation"); String TASKS = UIBundle.message("tool.window.name.tasks"); + String DATABASE_VIEW = UIBundle.message("tool.window.name.database"); } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorEmptyTextPainter.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorEmptyTextPainter.java index b2a5e740999c..5ef017382026 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorEmptyTextPainter.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorEmptyTextPainter.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.fileEditor.impl; +import com.intellij.ide.actions.ActivateToolWindowAction; import com.intellij.ide.actions.ShowFilePathAction; import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.actionSystem.Shortcut; @@ -87,7 +88,7 @@ public class EditorEmptyTextPainter { protected void appendToolWindow(UIUtil.TextPainter painter, String action, String toolWindowId, EditorsSplitters splitters) { if (!isToolwindowVisible(splitters, toolWindowId)) { - String activateActionId = "Activate" + toolWindowId + "ToolWindow"; + String activateActionId = ActivateToolWindowAction.getActionIdForToolWindow(toolWindowId); appendAction(painter, action, getActionShortcutText(activateActionId)); } } diff --git a/platform/platform-resources-en/src/messages/UIBundle.properties b/platform/platform-resources-en/src/messages/UIBundle.properties index 6999a22e254e..61d5d135cc2a 100644 --- a/platform/platform-resources-en/src/messages/UIBundle.properties +++ b/platform/platform-resources-en/src/messages/UIBundle.properties @@ -54,6 +54,7 @@ tool.window.name.dependency.viewer=Dependency Viewer tool.window.name.version.control=Version Control tool.window.name.module.dependencies=Module Dependencies tool.window.name.tasks=Time Tracking +tool.window.name.database=Database tool.window.move.to.action.group.name=Move to tool.window.move.to.top.action.name=Top tool.window.move.to.left.action.name=Left From a8c7d79ddfa51c6a72cad433ac29bc167fb7755d Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 24 Feb 2014 17:46:11 +0100 Subject: [PATCH 16/39] compact view for installed plugins --- .../ide/plugins/AvailablePluginColumnInfo.java | 2 +- .../ide/plugins/InstalledPluginsTableModel.java | 2 +- .../intellij/ide/plugins/PluginsTableRenderer.form | 4 ++-- .../intellij/ide/plugins/PluginsTableRenderer.java | 12 ++++++++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/AvailablePluginColumnInfo.java b/platform/platform-impl/src/com/intellij/ide/plugins/AvailablePluginColumnInfo.java index c9427cf50379..84ec678f304c 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/AvailablePluginColumnInfo.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/AvailablePluginColumnInfo.java @@ -28,6 +28,6 @@ class AvailablePluginColumnInfo extends PluginManagerColumnInfo { @Override public TableCellRenderer getRenderer(final IdeaPluginDescriptor pluginDescriptor) { - return new PluginsTableRenderer(pluginDescriptor); + return new PluginsTableRenderer(pluginDescriptor, true); } } diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsTableModel.java b/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsTableModel.java index 73256852b19c..7fd2f88b716d 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsTableModel.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/InstalledPluginsTableModel.java @@ -642,7 +642,7 @@ public class InstalledPluginsTableModel extends PluginTableModel { @Override public TableCellRenderer getRenderer(final IdeaPluginDescriptor pluginDescriptor) { - return new PluginsTableRenderer(pluginDescriptor); + return new PluginsTableRenderer(pluginDescriptor, false); } @Override diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginsTableRenderer.form b/platform/platform-impl/src/com/intellij/ide/plugins/PluginsTableRenderer.form index 597fc45c26a3..c68e09d8e7c6 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginsTableRenderer.form +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginsTableRenderer.form @@ -29,14 +29,14 @@ - + - + diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginsTableRenderer.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginsTableRenderer.java index 65a45e644d0b..04daa90f4ea8 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginsTableRenderer.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginsTableRenderer.java @@ -43,10 +43,13 @@ public class PluginsTableRenderer extends DefaultTableCellRenderer { private JLabel myCategory; private JPanel myRightPanel; + private JPanel myBottomPanel; + private JPanel myInfoPanel; private final IdeaPluginDescriptor myPluginDescriptor; - public PluginsTableRenderer(IdeaPluginDescriptor pluginDescriptor) { + public PluginsTableRenderer(IdeaPluginDescriptor pluginDescriptor, boolean showFullInfo) { myPluginDescriptor = pluginDescriptor; + boolean myShowFullInfo = showFullInfo; final Font smallFont; if (SystemInfo.isMac) { @@ -61,9 +64,14 @@ public class PluginsTableRenderer extends DefaultTableCellRenderer { myStatus.setText(""); myCategory.setText(""); myLastUpdated.setFont(smallFont); - if (! (pluginDescriptor instanceof PluginNode)) { + if (!myShowFullInfo || !(pluginDescriptor instanceof PluginNode)) { myPanel.remove(myRightPanel); } + + if (!myShowFullInfo) { + myInfoPanel.remove(myBottomPanel); + } + myPanel.setBorder(UIUtil.isRetina() ? new EmptyBorder(4,3,4,3) : new EmptyBorder(2,3,2,3)); } From 4be43bab7d5aff4a1379d9efe3c55ff9809e45bb Mon Sep 17 00:00:00 2001 From: Konstantin Ulitin Date: Mon, 24 Feb 2014 21:07:01 +0400 Subject: [PATCH 17/39] WEB-10887 TypeScript: unexpected error occured when Import clause with immediate export --- .../core-api/src/com/intellij/psi/util/QualifiedName.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/core-api/src/com/intellij/psi/util/QualifiedName.java b/platform/core-api/src/com/intellij/psi/util/QualifiedName.java index cd96e5438424..7ff4f7c4fd2a 100644 --- a/platform/core-api/src/com/intellij/psi/util/QualifiedName.java +++ b/platform/core-api/src/com/intellij/psi/util/QualifiedName.java @@ -201,4 +201,8 @@ public class QualifiedName { public int hashCode() { return myComponents.hashCode(); } + + public QualifiedName subQualifiedName(int fromIndex, int toIndex) { + return fromComponents(myComponents.subList(fromIndex, toIndex)); + } } From 5ef006cce753cfa65df1fe0164bfbb7c4ba12444 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 24 Feb 2014 15:49:15 +0100 Subject: [PATCH 18/39] =?UTF-8?q?WEB-9926=20don't=20auto=20expand=20librar?= =?UTF-8?q?y=20scope,=20we=20must=20use=20case-sensitive=20natural=20compa?= =?UTF-8?q?re=20=E2=80=94=20constants=20must=20be=20first?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/src/com/intellij/openapi/util/text/StringUtil.java | 4 ++-- .../intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java | 2 +- 2 files changed, 3 insertions(+), 3 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 f54897eb4282..552763fcfb85 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -2286,7 +2286,7 @@ public class StringUtil extends StringUtilRt { return naturalCompare(string1, string2, false); } - private static int naturalCompare(@Nullable String string1, @Nullable String string2, boolean caseSensitive) { + public static int naturalCompare(@Nullable String string1, @Nullable String string2, boolean caseSensitive) { //noinspection StringEquality if (string1 == string2) { return 0; @@ -2635,7 +2635,7 @@ public class StringUtil extends StringUtilRt { * i.e. when java.util.regex.Pattern match goes out of control. */ public abstract static class BombedCharSequence implements CharSequence { - private CharSequence delegate; + private final CharSequence delegate; private int i = 0; public BombedCharSequence(@NotNull CharSequence sequence) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java index 8b679f120739..2f48f369ee29 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java @@ -44,7 +44,7 @@ public class XValueNodeImpl extends XValueContainerNode implements XValu @Override public int compare(XValueNodeImpl o1, XValueNodeImpl o2) { //noinspection ConstantConditions - return StringUtil.naturalCompare(o1.getName(), o2.getName()); + return StringUtil.naturalCompare(o1.getName(), o2.getName(), true); } }; From 84aa4e814222b8f618f4dd74590173c73ba56be7 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 24 Feb 2014 16:02:20 +0100 Subject: [PATCH 19/39] =?UTF-8?q?we=20must=20use=20case-sensitive=20natura?= =?UTF-8?q?l=20compare=20=E2=80=94=20constants=20must=20be=20first,=20but?= =?UTF-8?q?=20our=20naturalCompare=20is=20"buggy",=20so,=20we=20perform=20?= =?UTF-8?q?manual=20sort=20before=20call=20platform=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/src/com/intellij/openapi/util/text/StringUtil.java | 2 +- .../intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java | 2 +- 2 files changed, 2 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 552763fcfb85..5a1c6af28b9b 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -2286,7 +2286,7 @@ public class StringUtil extends StringUtilRt { return naturalCompare(string1, string2, false); } - public static int naturalCompare(@Nullable String string1, @Nullable String string2, boolean caseSensitive) { + private static int naturalCompare(@Nullable String string1, @Nullable String string2, boolean caseSensitive) { //noinspection StringEquality if (string1 == string2) { return 0; diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java index 2f48f369ee29..8b679f120739 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java @@ -44,7 +44,7 @@ public class XValueNodeImpl extends XValueContainerNode implements XValu @Override public int compare(XValueNodeImpl o1, XValueNodeImpl o2) { //noinspection ConstantConditions - return StringUtil.naturalCompare(o1.getName(), o2.getName(), true); + return StringUtil.naturalCompare(o1.getName(), o2.getName()); } }; From 17b78eb122f6473e4415b33a2f10dbbcdc671a6c Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 24 Feb 2014 18:14:56 +0100 Subject: [PATCH 20/39] show "native" description for node objects --- .../frame/presentation/XKeywordValuePresentation.java | 2 +- .../xdebugger/frame/presentation/XValuePresentation.java | 3 +++ .../impl/ui/tree/nodes/XValuePresentationUtil.java | 5 +++++ .../impl/ui/tree/nodes/XValueTextRendererImpl.java | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XKeywordValuePresentation.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XKeywordValuePresentation.java index c6d79ff881d2..c84cadd5b254 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XKeywordValuePresentation.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XKeywordValuePresentation.java @@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull; public class XKeywordValuePresentation extends XValuePresentation { private final String myValue; - public XKeywordValuePresentation(String value) { + public XKeywordValuePresentation(@NotNull String value) { myValue = value; } diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XValuePresentation.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XValuePresentation.java index 0fbc9c713f15..69f3f95c7e41 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XValuePresentation.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XValuePresentation.java @@ -15,6 +15,7 @@ */ package com.intellij.xdebugger.frame.presentation; +import com.intellij.ui.SimpleTextAttributes; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -71,6 +72,8 @@ public abstract class XValuePresentation { */ void renderKeywordValue(@NotNull String value); + void renderValue(@NotNull String value, @Nullable SimpleTextAttributes attributes); + /** * Appends {@code value} surrounded by quotes to the node text colored as a string * @param value value to be shown diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValuePresentationUtil.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValuePresentationUtil.java index aaad5a9827c2..3232d028cd3c 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValuePresentationUtil.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValuePresentationUtil.java @@ -124,6 +124,11 @@ public class XValuePresentationUtil { myBuilder.append(symbol); } + @Override + public void renderValue(@NotNull String value, @Nullable SimpleTextAttributes attributes) { + renderValue(value); + } + public String getText() { return myBuilder.toString(); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java index 975d8e49cc68..d8aa9f46b05c 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java @@ -21,6 +21,7 @@ import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.ui.ColoredTextContainer; import com.intellij.ui.SimpleTextAttributes; +import com.intellij.util.ObjectUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,6 +40,11 @@ class XValueTextRendererImpl extends XValueTextRendererBase { XValuePresentationUtil.renderValue(value, myText, SimpleTextAttributes.REGULAR_ATTRIBUTES, -1, null); } + @Override + public void renderValue(@NotNull String value, @Nullable SimpleTextAttributes attributes) { + myText.append(value, ObjectUtils.notNull(attributes, SimpleTextAttributes.REGULAR_ATTRIBUTES)); + } + @Override protected void renderRawValue(@NotNull String value, @NotNull TextAttributesKey key) { TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key); From e29d48f43c8f86cd551aca7f08986f061ca617a9 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Mon, 24 Feb 2014 18:40:26 +0100 Subject: [PATCH 21/39] EA-53239 - UOE: VirtualFileImpl.getChildren --- .../com/intellij/openapi/vfs/impl/http/VirtualFileImpl.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/http/VirtualFileImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/http/VirtualFileImpl.java index 3c354bc30fe2..110d71003867 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/http/VirtualFileImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/http/VirtualFileImpl.java @@ -141,10 +141,7 @@ class VirtualFileImpl extends HttpVirtualFile { @Override public VirtualFile[] getChildren() { - if (myFileInfo == null) { - return EMPTY_ARRAY; - } - throw new UnsupportedOperationException(); + return EMPTY_ARRAY; } @Override From 01b095b77bb4e9ec391499ddc98133da3e82c190 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Mon, 24 Feb 2014 18:49:13 +0100 Subject: [PATCH 22/39] check myDisposed in read action too --- .../src/com/intellij/find/impl/livePreview/SearchResults.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/find/impl/livePreview/SearchResults.java b/platform/lang-impl/src/com/intellij/find/impl/livePreview/SearchResults.java index 754c3c6204ed..384c92ee0427 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/livePreview/SearchResults.java +++ b/platform/lang-impl/src/com/intellij/find/impl/livePreview/SearchResults.java @@ -220,7 +220,7 @@ public class SearchResults implements DocumentListener { @Override public void run() { Project project = getProject(); - if (project != null && project.isDisposed()) return; + if (myDisposed || project != null && project.isDisposed()) return; int[] starts = new int[0]; int[] ends = new int[0]; try { From 828cb5a1a2503f99ec10e0b2a1a4dffe219c0e33 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 24 Feb 2014 13:41:58 +0100 Subject: [PATCH 23/39] new inference: erase return type if unchecked conversion was performed --- .../graphInference/InferenceSession.java | 17 ++++++++++++----- .../tree/java/PsiMethodCallExpressionImpl.java | 7 +++++++ .../constraints/UncheckedBoundsWithErasure.java | 4 ++-- 3 files changed, 21 insertions(+), 7 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 59089f5c16eb..ea0c8081d25e 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 @@ -49,6 +49,8 @@ public class InferenceSession { private static final Logger LOG = Logger.getInstance("#" + InferenceSession.class.getName()); public static final Key LOWER_BOUND = Key.create("LowBound"); + private static final Key ERASED = Key.create("UNCHECKED_CONVERSION"); + private final Map myInferenceVariables = new LinkedHashMap(); private final List myConstraints = new ArrayList(); @@ -286,6 +288,9 @@ public class InferenceSession { final PsiSubstitutor substitutor = resolveBounds(myInferenceVariables.values(), mySiteSubstitutor); if (substitutor != null) { + if (myContext != null) { + myContext.putUserData(ERASED, myErased); + } mySiteSubstitutor = substitutor; for (PsiTypeParameter parameter : substitutor.getSubstitutionMap().keySet()) { final InferenceVariable variable = getInferenceVariable(parameter); @@ -396,9 +401,6 @@ public class InferenceSession { myConstraints.add(new TypeCompatibilityConstraint(targetType, PsiUtil.captureToplevelWildcards(substitutor.substitute(inferenceVariable.getParameter()), myContext))); } else { - if (targetType instanceof PsiClassType && ((PsiClassType)targetType).isRaw()) { - setErased(); - } if (FunctionalInterfaceParameterizationUtil.isWildcardParameterized(returnType)) { final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(returnType); final PsiClass psiClass = resolveResult.getElement(); @@ -419,7 +421,7 @@ public class InferenceSession { myConstraints.add(new TypeCompatibilityConstraint(targetType, substitutedCapture)); } } else { - myConstraints.add(new TypeCompatibilityConstraint(myErased ? TypeConversionUtil.erasure(targetType) : targetType, returnType)); + myConstraints.add(new TypeCompatibilityConstraint(targetType, myErased ? TypeConversionUtil.erasure(returnType) : returnType)); } } } @@ -470,7 +472,7 @@ public class InferenceSession { } private static boolean hasWildcardParameterization(InferenceVariable inferenceVariable, PsiClassType targetType) { - if (FunctionalInterfaceParameterizationUtil.isWildcardParameterized(targetType)) { + if (!FunctionalInterfaceParameterizationUtil.isWildcardParameterized(targetType)) { final List bounds = inferenceVariable.getBounds(InferenceBound.LOWER); final Processor> differentParameterizationProcessor = new Processor>() { @Override @@ -1198,4 +1200,9 @@ public class InferenceSession { } } } + + public static boolean wasUncheckedConversionPerformed(PsiElement call) { + final Boolean erased = call.getUserData(ERASED); + return erased != null && erased.booleanValue(); + } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java index 36013c3625a3..dc204b4ae315 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java @@ -24,6 +24,7 @@ import com.intellij.psi.*; import com.intellij.psi.impl.DebugUtil; import com.intellij.psi.impl.PsiImplUtil; import com.intellij.psi.impl.source.resolve.JavaResolveCache; +import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession; import com.intellij.psi.impl.source.tree.ChildRole; import com.intellij.psi.impl.source.tree.ElementType; import com.intellij.psi.impl.source.tree.JavaElementType; @@ -208,6 +209,12 @@ public class PsiMethodCallExpressionImpl extends ExpressionPsiElement implements PsiSubstitutor substitutor) { PsiType substitutedReturnType = substitutor.substitute(ret); if (substitutedReturnType == null) return TypeConversionUtil.erasure(ret); + if (InferenceSession.wasUncheckedConversionPerformed(call)) { + // 18.5.2 + // if unchecked conversion was necessary, then this substitution provides the parameter types of the invocation type, + // while the return type and thrown types are given by the erasure of m's type (without applying θ'). + return TypeConversionUtil.erasure(substitutedReturnType); + } if (PsiUtil.isRawSubstitutor(method, substitutor)) { final PsiType returnTypeErasure = TypeConversionUtil.erasure(ret); if (Comparing.equal(TypeConversionUtil.erasure(substitutedReturnType), returnTypeErasure)) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/UncheckedBoundsWithErasure.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/UncheckedBoundsWithErasure.java index a106da75fa7e..49753a7bcdac 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/UncheckedBoundsWithErasure.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/constraints/UncheckedBoundsWithErasure.java @@ -7,8 +7,8 @@ public class Sample { B bar(G gb) {return null;} void f(G1 g1) { - G l11 = bar(g1); - String l1 = bar(g1); + G l11 = bar(g1); + String l1 = bar(g1); Object o = bar(g1); } } From 232f8bd465af6bbba795713b000954da3c3f0229 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 24 Feb 2014 13:45:23 +0100 Subject: [PATCH 24/39] new inference: strict subtyping: skip raw types --- .../constraints/StrictSubtypingConstraint.java | 4 ++++ .../lambda/newMethodRef/RawTargetType.java | 15 +++++++++++++++ .../lambda/NewMethodRefHighlightingTest.java | 4 ++++ 3 files changed, 23 insertions(+) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawTargetType.java diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/StrictSubtypingConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/StrictSubtypingConstraint.java index 7324818c4351..db193ddda9eb 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/StrictSubtypingConstraint.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/StrictSubtypingConstraint.java @@ -19,6 +19,7 @@ import com.intellij.psi.*; import com.intellij.psi.impl.source.resolve.graphInference.InferenceBound; import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession; import com.intellij.psi.impl.source.resolve.graphInference.InferenceVariable; +import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.TypeConversionUtil; import java.util.List; @@ -94,6 +95,9 @@ public class StrictSubtypingConstraint implements ConstraintFormula { if (!(myS instanceof PsiClassType)) return false; PsiClassType.ClassResolveResult SResult = ((PsiClassType)myS).resolveGenerics(); PsiClass SClass = SResult.getElement(); + if (((PsiClassType)myT).isRaw()) { + return SClass != null && InheritanceUtil.isInheritorOrSelf(SClass, CClass, true); + } final PsiSubstitutor tSubstitutor = TResult.getSubstitutor(); final PsiSubstitutor sSubstitutor = SClass != null ? TypeConversionUtil.getClassSubstitutor(CClass, SClass, SResult.getSubstitutor()) : null; if (sSubstitutor != null) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawTargetType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawTargetType.java new file mode 100644 index 000000000000..880d654e1659 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/RawTargetType.java @@ -0,0 +1,15 @@ +import java.util.Map; +import java.util.TreeMap; +import java.util.function.Supplier; + +class Test { + interface I {} + + { + I i = foo(TreeMap::new); + } + + > I foo(Supplier mapFactory) { + return null; + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java index 8386a4c327b9..e944269c098b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java @@ -169,6 +169,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testRawTargetType() throws Exception { + doTest(); + } + private void doTest() { doTest(false); } From f1b256f416dd425f70536a8aa700238d7171d248 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 24 Feb 2014 13:58:41 +0100 Subject: [PATCH 25/39] forbid lambda in conditional inside cast context --- java/java-psi-api/src/com/intellij/psi/LambdaUtil.java | 2 +- .../daemonCodeAnalyzer/lambda/highlighting/LambdaContext.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java b/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java index 32a81a764127..10eb7f714fbb 100644 --- a/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java @@ -115,7 +115,7 @@ public class LambdaUtil { context instanceof PsiExpressionList || context instanceof PsiParenthesizedExpression || context instanceof PsiArrayInitializerExpression || - context instanceof PsiConditionalExpression; + context instanceof PsiConditionalExpression && PsiTreeUtil.getParentOfType(context, PsiTypeCastExpression.class) == null; } public static boolean isLambdaFullyInferred(PsiLambdaExpression expression, PsiType functionalInterfaceType) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/LambdaContext.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/LambdaContext.java index 4fd368c7b029..a5efd12bd7a0 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/LambdaContext.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/LambdaContext.java @@ -23,5 +23,6 @@ interface II { class Test1 { void bar(boolean b){ II ik = b ? (s)-> true : (s)->false; + II ik1 = (II)(b ? (s)-> true : (s)->false); } } \ No newline at end of file From e0ce9deea384c3985f70ae27dae3dac0710a62c7 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 24 Feb 2014 15:23:10 +0100 Subject: [PATCH 26/39] testdata --- .../lambda/graphInference/NestedCalls1.java | 14 ++++++++++++++ .../lambda/GraphInferenceHighlightingTest.java | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls1.java diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls1.java new file mode 100644 index 000000000000..4a942952c7d5 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/NestedCalls1.java @@ -0,0 +1,14 @@ +class Main { + + { + foo(bar(String.class)); + } + + T bar(Class cf) { + return null; + } + + K foo(K vo) { + return null; + } +} 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 7dc6ba831d57..f99ae3ce430a 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 @@ -152,6 +152,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase doTest(); } + public void testNestedCalls1() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(false); } From 8f7ff5bdb81bbd1507103bd1b087f409ccaff8a7 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 24 Feb 2014 17:54:15 +0100 Subject: [PATCH 27/39] wrap with command --- .../changeSignature/JavaChangeSignatureDialog.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java index 2548fbf312ce..f86b78d1d17e 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java @@ -19,7 +19,7 @@ import com.intellij.codeInsight.completion.CompletionResultSet; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CustomShortcutSet; -import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorFontType; @@ -556,7 +556,7 @@ public class JavaChangeSignatureDialog extends ChangeSignatureDialogBase() { + item.parameter.defaultValue = WriteCommandAction.runWriteCommandAction(myProject, new Computable() { @Override public String compute() { return JavaCodeStyleManager.getInstance(myProject).qualifyClassReferences(item.defaultValueCodeFragment).getText(); From 351b9b1ebe5cf2dba6f0b2e70d1da90d4ce242f3 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 24 Feb 2014 18:40:32 +0100 Subject: [PATCH 28/39] tests left on 1.7 for now --- .../com/intellij/refactoring/ExtractMethodObjectTest.java | 6 ++++++ .../intellij/refactoring/FindMethodDuplicatesBaseTest.java | 6 ++++++ .../com/intellij/refactoring/inline/InlineMethodTest.java | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java index 33cd43ed55d3..745828a48fb1 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java @@ -7,6 +7,7 @@ package com.intellij.refactoring; import com.intellij.JavaTestUtil; import com.intellij.codeInsight.TargetElementUtilBase; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectHandler; @@ -120,4 +121,9 @@ public class ExtractMethodObjectTest extends LightRefactoringTestCase { public void testWithPrivateMethodWhichCantBeMoved() throws Exception { doTest(); } + + @Override + protected LanguageLevel getLanguageLevel() { + return LanguageLevel.JDK_1_7; + } } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/FindMethodDuplicatesBaseTest.java b/java/java-tests/testSrc/com/intellij/refactoring/FindMethodDuplicatesBaseTest.java index dea08d1dedad..988cc4ef45a4 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/FindMethodDuplicatesBaseTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/FindMethodDuplicatesBaseTest.java @@ -7,6 +7,7 @@ package com.intellij.refactoring; import com.intellij.JavaTestUtil; import com.intellij.analysis.AnalysisScope; import com.intellij.codeInsight.TargetElementUtilBase; +import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMember; import com.intellij.refactoring.util.duplicates.MethodDuplicatesHandler; @@ -51,4 +52,9 @@ public abstract class FindMethodDuplicatesBaseTest extends LightCodeInsightTestC } protected abstract String getTestFilePath(); + + @Override + protected LanguageLevel getLanguageLevel() { + return LanguageLevel.JDK_1_7; + } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java index b0dd70c5f859..ec5ab9e53e96 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/inline/InlineMethodTest.java @@ -17,6 +17,7 @@ package com.intellij.refactoring.inline; import com.intellij.JavaTestUtil; import com.intellij.codeInsight.TargetElementUtilBase; +import com.intellij.openapi.projectRoots.Sdk; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; @@ -26,6 +27,7 @@ import com.intellij.refactoring.BaseRefactoringProcessor; import com.intellij.refactoring.LightRefactoringTestCase; import com.intellij.refactoring.MockInlineMethodOptions; import com.intellij.refactoring.util.InlineUtil; +import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -299,4 +301,9 @@ public class InlineMethodTest extends LightRefactoringTestCase { new InlineMethodProcessor(getProject(), method, refExpr, myEditor, options.isInlineThisOnly(), nonCode, nonCode); processor.run(); } + + @Override + protected Sdk getProjectJDK() { + return IdeaTestUtil.getMockJdk18(); + } } From d7d0eecd06ba42c88b6a65bc55c0f6a6918b21da Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 24 Feb 2014 18:47:11 +0100 Subject: [PATCH 29/39] extract method with new inference --- .../extractMethodObject/ExtractMethodObjectProcessor.java | 8 ++------ .../com/intellij/refactoring/ExtractMethodObjectTest.java | 7 ++++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java index 8d449cf94e74..e423210e8177 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java @@ -36,7 +36,6 @@ import com.intellij.psi.codeStyle.JavaCodeStyleManager; import com.intellij.psi.codeStyle.VariableKind; import com.intellij.psi.controlFlow.ControlFlowUtil; import com.intellij.psi.impl.source.PsiImmediateClassType; -import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.util.PropertyUtil; @@ -469,12 +468,9 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor { final PsiTypeParameter[] methodTypeParameters = getMethod().getTypeParameters(); if (methodTypeParameters.length > 0) { List typeSignature = new ArrayList(); - final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(getMethod().getProject()).getResolveHelper(); + final PsiSubstitutor substitutor = methodCallExpression.resolveMethodGenerics().getSubstitutor(); for (final PsiTypeParameter typeParameter : methodTypeParameters) { - final PsiType type = resolveHelper.inferTypeForMethodTypeParameter(typeParameter, getMethod().getParameterList().getParameters(), - methodCallExpression.getArgumentList().getExpressions(), - PsiSubstitutor.EMPTY, methodCallExpression, - DefaultParameterTypeInferencePolicy.INSTANCE); + final PsiType type = substitutor.substitute(typeParameter); if (type == null || PsiType.NULL.equals(type)) { return ""; } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java index 745828a48fb1..1efcf2631c8f 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObjectTest.java @@ -7,11 +7,12 @@ package com.intellij.refactoring; import com.intellij.JavaTestUtil; import com.intellij.codeInsight.TargetElementUtilBase; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.pom.java.LanguageLevel; +import com.intellij.openapi.projectRoots.Sdk; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectHandler; import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectProcessor; +import com.intellij.testFramework.IdeaTestUtil; import org.jetbrains.annotations.NotNull; public class ExtractMethodObjectTest extends LightRefactoringTestCase { @@ -123,7 +124,7 @@ public class ExtractMethodObjectTest extends LightRefactoringTestCase { } @Override - protected LanguageLevel getLanguageLevel() { - return LanguageLevel.JDK_1_7; + protected Sdk getProjectJDK() { + return IdeaTestUtil.getMockJdk18(); } } From 7a70428d04ffed8ff631768b1c38df92d40e9996 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 24 Feb 2014 18:56:06 +0100 Subject: [PATCH 30/39] lambda: accept ellipsis parameter when array expected (IDEA-117124) --- .../tree/java/PsiLambdaExpressionImpl.java | 16 ++++++++++------ .../lambda/newLambda/IDEA117124.java | 8 ++++++++ .../daemon/lambda/NewLambdaHighlightingTest.java | 4 ++++ 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA117124.java diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java index 673215872abf..d6f9f1bc50f7 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java @@ -176,8 +176,8 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi PsiParameter parameter = lambdaParameters[lambdaParamIdx]; final PsiTypeElement typeElement = parameter.getTypeElement(); if (typeElement != null) { - final PsiType lambdaFormalType = typeElement.getType(); - final PsiType methodParameterType = parameterTypes[lambdaParamIdx]; + final PsiType lambdaFormalType = toArray(typeElement.getType()); + final PsiType methodParameterType = toArray(parameterTypes[lambdaParamIdx]); if (!lambdaFormalType.equals(methodParameterType)) { return false; } @@ -186,10 +186,7 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi if (checkReturnType) { final String uniqueVarName = JavaCodeStyleManager.getInstance(getProject()).suggestUniqueVariableName("l", this, true); - String canonicalText = leftType.getCanonicalText(); - if (leftType instanceof PsiEllipsisType) { - canonicalText = ((PsiEllipsisType)leftType).toArrayType().getCanonicalText(); - } + final String canonicalText = toArray(leftType).getCanonicalText(); final PsiStatement assignmentFromText = JavaPsiFacade.getElementFactory(getProject()) .createStatementFromText(canonicalText + " " + uniqueVarName + " = " + getText(), this); final PsiLocalVariable localVariable = (PsiLocalVariable)((PsiDeclarationStatement)assignmentFromText).getDeclaredElements()[0]; @@ -201,4 +198,11 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi } return true; } + + private static PsiType toArray(PsiType paramType) { + if (paramType instanceof PsiEllipsisType) { + return ((PsiEllipsisType)paramType).toArrayType(); + } + return paramType; + } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA117124.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA117124.java new file mode 100644 index 000000000000..c8b29ed35ceb --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA117124.java @@ -0,0 +1,8 @@ +interface Var { + void var(int[] ps); +} +class Abc { + void foo() { + Var var = (int... ps) -> {}; + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java index a57993717ef8..7df809217da6 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java @@ -130,6 +130,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testIDEA117124() throws Exception { + doTest(); + } + private void doTest() { doTest(false); } From f64f1ef111bc08b3bf1151ec81763800b4a98c73 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 24 Feb 2014 19:25:40 +0100 Subject: [PATCH 31/39] do not suggest broken plugins --- .../src/com/intellij/ide/plugins/PluginManagerCore.java | 2 +- .../impl/pluginsAdvertisement/PluginsAdvertiser.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java b/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java index 10759ebf812f..e58213c6d0ba 100644 --- a/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java +++ b/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java @@ -117,7 +117,7 @@ public class PluginManagerCore { return ourDisabledPlugins; } - private static boolean isBrokenPlugin(IdeaPluginDescriptor descriptor) { + public static boolean isBrokenPlugin(IdeaPluginDescriptor descriptor) { return getBrokenPluginVersions().get(descriptor.getPluginId().getIdString()).contains(descriptor.getVersion()); } diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginsAdvertiser.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginsAdvertiser.java index 034fd0e849c8..aa7b6b3874e7 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginsAdvertiser.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginsAdvertiser.java @@ -28,12 +28,11 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.PluginId; import com.intellij.openapi.fileTypes.FileTypeFactory; import com.intellij.openapi.options.ShowSettingsUtil; -import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupActivity; -import com.intellij.openapi.updateSettings.impl.*; +import com.intellij.openapi.updateSettings.impl.PluginDownloader; +import com.intellij.openapi.updateSettings.impl.UpdateSettings; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.io.FileUtil; @@ -134,6 +133,8 @@ public class PluginsAdvertiser implements StartupActivity { if (loadedPlugin != null && fromServerPluginDescription != null && StringUtil.compareVersionNumbers(loadedPlugin.getVersion(), fromServerPluginDescription.getVersion()) >= 0) continue; + if (fromServerPluginDescription != null && PluginManagerCore.isBrokenPlugin(fromServerPluginDescription)) continue; + final JsonElement ext = jsonObject.get("implementationName"); final String extension = StringUtil.unquoteString(ext.toString()); Set pluginIds = result.get(extension); From aa61e881dedc2a886d9f823e15f5a3e47c5e43c8 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 24 Feb 2014 19:27:29 +0100 Subject: [PATCH 32/39] EA-54181 - NPE: NullableStuffInspectionBase.checkNullableStuffForMethod --- .../codeInspection/nullable/NullableStuffInspectionBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java index 0edaee491523..38f8d46fe10c 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java @@ -395,7 +395,7 @@ public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionToo parameters[i].getNameIdentifier(); //be sure that corresponding tree element available PsiAnnotation annotation = AnnotationUtil.findAnnotation(parameters[i], nullableManager.getNotNulls()); PsiElement psiElement = annotation; - if (!annotation.isPhysical()) { + if (annotation == null || !annotation.isPhysical()) { psiElement = parameters[i].getNameIdentifier(); if (psiElement == null) continue; } From b4eba393401023039fde4158a382c93c4e9d6cc8 Mon Sep 17 00:00:00 2001 From: Evgeny Pasynkov Date: Mon, 24 Feb 2014 15:27:55 +0100 Subject: [PATCH 33/39] move xml descriptors to the module available from Upsource --- .../src/com/intellij/xml/util/documentation/html5table.xml | 0 .../src/com/intellij/xml/util/documentation/htmltable.xml | 0 .../src/com/intellij/xml/util/documentation/mathmltable.xml | 0 .../src/com/intellij/xml/util/documentation/svgtable.xml | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename xml/{impl => xml-psi-impl}/src/com/intellij/xml/util/documentation/html5table.xml (100%) rename xml/{impl => xml-psi-impl}/src/com/intellij/xml/util/documentation/htmltable.xml (100%) rename xml/{impl => xml-psi-impl}/src/com/intellij/xml/util/documentation/mathmltable.xml (100%) rename xml/{impl => xml-psi-impl}/src/com/intellij/xml/util/documentation/svgtable.xml (100%) diff --git a/xml/impl/src/com/intellij/xml/util/documentation/html5table.xml b/xml/xml-psi-impl/src/com/intellij/xml/util/documentation/html5table.xml similarity index 100% rename from xml/impl/src/com/intellij/xml/util/documentation/html5table.xml rename to xml/xml-psi-impl/src/com/intellij/xml/util/documentation/html5table.xml diff --git a/xml/impl/src/com/intellij/xml/util/documentation/htmltable.xml b/xml/xml-psi-impl/src/com/intellij/xml/util/documentation/htmltable.xml similarity index 100% rename from xml/impl/src/com/intellij/xml/util/documentation/htmltable.xml rename to xml/xml-psi-impl/src/com/intellij/xml/util/documentation/htmltable.xml diff --git a/xml/impl/src/com/intellij/xml/util/documentation/mathmltable.xml b/xml/xml-psi-impl/src/com/intellij/xml/util/documentation/mathmltable.xml similarity index 100% rename from xml/impl/src/com/intellij/xml/util/documentation/mathmltable.xml rename to xml/xml-psi-impl/src/com/intellij/xml/util/documentation/mathmltable.xml diff --git a/xml/impl/src/com/intellij/xml/util/documentation/svgtable.xml b/xml/xml-psi-impl/src/com/intellij/xml/util/documentation/svgtable.xml similarity index 100% rename from xml/impl/src/com/intellij/xml/util/documentation/svgtable.xml rename to xml/xml-psi-impl/src/com/intellij/xml/util/documentation/svgtable.xml From 2df995fd74aa9be9ac5d49936c230a511f00f217 Mon Sep 17 00:00:00 2001 From: Evgeny Pasynkov Date: Mon, 24 Feb 2014 16:39:51 +0100 Subject: [PATCH 34/39] More extensibility for CoreProjectEnvironment --- .../src/com/intellij/core/CoreProjectEnvironment.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/core-impl/src/com/intellij/core/CoreProjectEnvironment.java b/platform/core-impl/src/com/intellij/core/CoreProjectEnvironment.java index e28de382d8df..d7fcde008e77 100644 --- a/platform/core-impl/src/com/intellij/core/CoreProjectEnvironment.java +++ b/platform/core-impl/src/com/intellij/core/CoreProjectEnvironment.java @@ -41,6 +41,8 @@ import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.util.PsiModificationTracker; import com.intellij.util.CachedValuesManagerImpl; import com.intellij.util.messages.impl.MessageBusImpl; +import org.jetbrains.annotations.NotNull; +import org.picocontainer.PicoContainer; public class CoreProjectEnvironment { private final Disposable myParentDisposable; @@ -54,7 +56,7 @@ public class CoreProjectEnvironment { public CoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) { myParentDisposable = parentDisposable; myEnvironment = applicationEnvironment; - myProject = new MockProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable); + myProject = createProject(myEnvironment.getApplication().getPicoContainer(), myParentDisposable); preregisterServices(); @@ -84,6 +86,10 @@ public class CoreProjectEnvironment { myProject.registerService(DumbService.class, new MockDumbService(myProject)); } + protected MockProject createProject(PicoContainer parent, @NotNull Disposable parentDisposable) { + return new MockProject(parent, parentDisposable); + } + protected ProjectScopeBuilder createProjectScopeBuilder() { return new CoreProjectScopeBuilder(myProject, myFileIndexFacade); } From 7a9bf2ac519056cc0f2bd004218a5d79609c05c0 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 24 Feb 2014 20:33:39 +0100 Subject: [PATCH 35/39] reject 1.7 varargs hack as 1.8 reject the code again even with target 1.7 --- .../JavaMethodsConflictResolver.java | 15 ++------------- .../pck/AmbiguousMethodCall.java | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java index aecf22009155..54e43a59c5ec 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java @@ -367,7 +367,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ boolean toFilter = false; for (CandidateInfo conflict : conflicts) { ProgressManager.checkCanceled(); - @MethodCandidateInfo.ApplicabilityLevelConstant final int level = preferVarargs((MethodCandidateInfo)conflict); + @MethodCandidateInfo.ApplicabilityLevelConstant final int level = ((MethodCandidateInfo)conflict).getPertinentApplicabilityLevel(); if (maxApplicabilityLevel > 0 && maxApplicabilityLevel != level) { toFilter = true; } @@ -380,7 +380,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ for (Iterator iterator = conflicts.iterator(); iterator.hasNext();) { ProgressManager.checkCanceled(); CandidateInfo info = iterator.next(); - final int level = preferVarargs((MethodCandidateInfo)info); + final int level = ((MethodCandidateInfo)info).getPertinentApplicabilityLevel(); if (level < maxApplicabilityLevel) { iterator.remove(); } @@ -390,17 +390,6 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{ return maxApplicabilityLevel; } - private static int preferVarargs(MethodCandidateInfo info) { - final int level = info.getPertinentApplicabilityLevel(); - if (level == MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY) { - final PsiMethod psiMethod = info.getElement(); - if (psiMethod != null && psiMethod.isVarArgs() && JavaVersionService.getInstance().isAtLeast(psiMethod, JavaSdkVersion.JDK_1_7)) { - return level + 1; - } - } - return level; - } - private static int getCheckAccessLevel(MethodCandidateInfo method){ boolean visible = method.isAccessible(); return visible ? 1 : 0; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67573/pck/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67573/pck/AmbiguousMethodCall.java index b63b6aa93132..918518e705c9 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67573/pck/AmbiguousMethodCall.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ambiguousIDEA67573/pck/AmbiguousMethodCall.java @@ -12,6 +12,6 @@ class C { void bar(T x) { - x.foo(null); + x.foo(null); } } From b716f4763b02bf229d4f63367d3995f9629e260d Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 24 Feb 2014 20:42:19 +0100 Subject: [PATCH 36/39] more consistent highlight "type#selector" --- .../xdebugger/frame/presentation/XValuePresentation.java | 4 ++-- .../impl/ui/tree/nodes/XValuePresentationUtil.java | 5 ----- .../impl/ui/tree/nodes/XValueTextRendererBase.java | 6 ++++++ .../impl/ui/tree/nodes/XValueTextRendererImpl.java | 6 ------ 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XValuePresentation.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XValuePresentation.java index 69f3f95c7e41..a3865bca2540 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XValuePresentation.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/presentation/XValuePresentation.java @@ -15,7 +15,7 @@ */ package com.intellij.xdebugger.frame.presentation; -import com.intellij.ui.SimpleTextAttributes; +import com.intellij.openapi.editor.colors.TextAttributesKey; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -72,7 +72,7 @@ public abstract class XValuePresentation { */ void renderKeywordValue(@NotNull String value); - void renderValue(@NotNull String value, @Nullable SimpleTextAttributes attributes); + void renderValue(@NotNull String value, @Nullable TextAttributesKey key); /** * Appends {@code value} surrounded by quotes to the node text colored as a string diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValuePresentationUtil.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValuePresentationUtil.java index 3232d028cd3c..aaad5a9827c2 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValuePresentationUtil.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValuePresentationUtil.java @@ -124,11 +124,6 @@ public class XValuePresentationUtil { myBuilder.append(symbol); } - @Override - public void renderValue(@NotNull String value, @Nullable SimpleTextAttributes attributes) { - renderValue(value); - } - public String getText() { return myBuilder.toString(); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererBase.java index 9fb0aa2d394d..693ab4835988 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererBase.java @@ -19,6 +19,7 @@ import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.xdebugger.frame.presentation.XValuePresentation; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author nik @@ -39,5 +40,10 @@ public abstract class XValueTextRendererBase implements XValuePresentation.XValu renderRawValue(value, DefaultLanguageHighlighterColors.KEYWORD); } + @Override + public final void renderValue(@NotNull String value, @Nullable TextAttributesKey key) { + renderRawValue(value, key); + } + protected abstract void renderRawValue(@NotNull String value, @NotNull TextAttributesKey key); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java index d8aa9f46b05c..975d8e49cc68 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java @@ -21,7 +21,6 @@ import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.ui.ColoredTextContainer; import com.intellij.ui.SimpleTextAttributes; -import com.intellij.util.ObjectUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -40,11 +39,6 @@ class XValueTextRendererImpl extends XValueTextRendererBase { XValuePresentationUtil.renderValue(value, myText, SimpleTextAttributes.REGULAR_ATTRIBUTES, -1, null); } - @Override - public void renderValue(@NotNull String value, @Nullable SimpleTextAttributes attributes) { - myText.append(value, ObjectUtils.notNull(attributes, SimpleTextAttributes.REGULAR_ATTRIBUTES)); - } - @Override protected void renderRawValue(@NotNull String value, @NotNull TextAttributesKey key) { TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key); From 44dde647bbd13612ff04cab765a9218e330117ef Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 24 Feb 2014 21:01:00 +0100 Subject: [PATCH 37/39] anonym -> lambda: do not suggest when forward references are detected (IDEA-120699) --- .../codeInspection/AnonymousCanBeLambdaInspection.java | 10 ++++++---- .../afterForwardStaticFieldReference.java | 7 +++++++ .../anonymous2lambda/beforeForwardFieldReference.java | 10 ++++++++++ .../beforeForwardStaticFieldReference.java | 10 ++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterForwardStaticFieldReference.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardFieldReference.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardStaticFieldReference.java diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java index a5558660cbe1..b2a537249b28 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java @@ -130,10 +130,12 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection final PsiField field = PsiTreeUtil.getParentOfType(expression, PsiField.class); if (field != null) { final PsiElement resolved = expression.resolve(); - if (resolved instanceof PsiField && - !((PsiField)resolved).hasInitializer() && - ((PsiField)resolved).getContainingClass() == field.getContainingClass()) { - bodyContainsForbiddenRefs[0] = true; + if (resolved instanceof PsiField && ((PsiField)resolved).getContainingClass() == field.getContainingClass()) { + final PsiExpression initializer = ((PsiField)resolved).getInitializer(); + if (initializer == null || + initializer.getTextOffset() > aClass.getTextOffset() && !((PsiField)resolved).hasModifierProperty(PsiModifier.STATIC)) { + bodyContainsForbiddenRefs[0] = true; + } } } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterForwardStaticFieldReference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterForwardStaticFieldReference.java new file mode 100644 index 000000000000..16ed145c7916 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterForwardStaticFieldReference.java @@ -0,0 +1,7 @@ +// "Replace with lambda" "true" +class HelloLambda { + private final Runnable r = () -> { + System.out.println(x); + }; + private static int x = 0; +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardFieldReference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardFieldReference.java new file mode 100644 index 000000000000..2469fe1b7a42 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardFieldReference.java @@ -0,0 +1,10 @@ +// "Replace with lambda" "false" +class HelloLambda { + private final Runnable r = new Runnable() { + @Override + public void run() { + System.out.println(x); + } + }; + private int x = 0; +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardStaticFieldReference.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardStaticFieldReference.java new file mode 100644 index 000000000000..1afad4b29c62 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeForwardStaticFieldReference.java @@ -0,0 +1,10 @@ +// "Replace with lambda" "true" +class HelloLambda { + private final Runnable r = new Runnable() { + @Override + public void run() { + System.out.println(x); + } + }; + private static int x = 0; +} \ No newline at end of file From 24fbf809a1140125dcc387d6c6ef657b011ae507 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 24 Feb 2014 21:46:25 +0100 Subject: [PATCH 38/39] anonym -> lambda: check initializer inside constructor for final fields (IDEA-120698) --- .../AnonymousCanBeLambdaInspection.java | 178 ++++++++++++------ ...dInitializedBeforeAnonymInConstructor.java | 15 ++ ...ldInitializedAfterAnonymInConstructor.java | 18 ++ ...dInitializedBeforeAnonymInConstructor.java | 18 ++ 4 files changed, 167 insertions(+), 62 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterFinalFieldInitializedBeforeAnonymInConstructor.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedAfterAnonymInConstructor.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedBeforeAnonymInConstructor.java diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java index b2a537249b28..ea1c64b97f10 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java @@ -17,6 +17,7 @@ package com.intellij.codeInspection; import com.intellij.codeInsight.ChangeContextUtil; import com.intellij.codeInsight.daemon.GroupNames; +import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil; import com.intellij.codeInsight.intention.HighPriorityAction; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -25,14 +26,18 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; +import com.intellij.psi.controlFlow.AnalysisCanceledException; +import com.intellij.psi.controlFlow.ControlFlow; +import com.intellij.psi.controlFlow.ControlFlowUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.util.Function; -import com.intellij.util.containers.HashSet; +import com.intellij.util.containers.ContainerUtilRt; import com.intellij.util.containers.hash.LinkedHashMap; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -82,68 +87,11 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection if (methods.length == 1 && aClass.getFields().length == 0) { final PsiCodeBlock body = methods[0].getBody(); if (body != null) { - final boolean [] bodyContainsForbiddenRefs = new boolean[1]; - final Set locals = new HashSet(); - body.accept(new JavaRecursiveElementWalkingVisitor() { - @Override - public void visitMethodCallExpression(PsiMethodCallExpression methodCallExpression) { - if (bodyContainsForbiddenRefs[0]) return; - super.visitMethodCallExpression(methodCallExpression); - final PsiMethod psiMethod = methodCallExpression.resolveMethod(); - if (psiMethod == methods[0] || - psiMethod != null && - !methodCallExpression.getMethodExpression().isQualified() && - "getClass".equals(psiMethod.getName()) && - psiMethod.getParameterList().getParametersCount() == 0) { - bodyContainsForbiddenRefs[0] = true; - } - } - - @Override - public void visitThisExpression(PsiThisExpression expression) { - if (bodyContainsForbiddenRefs[0]) return; - if (expression.getQualifier() == null) { - bodyContainsForbiddenRefs[0] = true; - } - } - - @Override - public void visitSuperExpression(PsiSuperExpression expression) { - if (bodyContainsForbiddenRefs[0]) return; - if (expression.getQualifier() == null) { - bodyContainsForbiddenRefs[0] = true; - } - } - - @Override - public void visitLocalVariable(PsiLocalVariable variable) { - if (bodyContainsForbiddenRefs[0]) return; - super.visitLocalVariable(variable); - locals.add(variable); - } - - @Override - public void visitReferenceExpression(PsiReferenceExpression expression) { - if (bodyContainsForbiddenRefs[0]) return; - super.visitReferenceExpression(expression); - if (!(expression.getParent() instanceof PsiMethodCallExpression)) { - final PsiField field = PsiTreeUtil.getParentOfType(expression, PsiField.class); - if (field != null) { - final PsiElement resolved = expression.resolve(); - if (resolved instanceof PsiField && ((PsiField)resolved).getContainingClass() == field.getContainingClass()) { - final PsiExpression initializer = ((PsiField)resolved).getInitializer(); - if (initializer == null || - initializer.getTextOffset() > aClass.getTextOffset() && !((PsiField)resolved).hasModifierProperty(PsiModifier.STATIC)) { - bodyContainsForbiddenRefs[0] = true; - } - } - } - } - } - }); - if (!bodyContainsForbiddenRefs[0]) { + final ForbiddenRefsChecker checker = new ForbiddenRefsChecker(methods[0], aClass); + body.accept(checker); + if (!checker.hasForbiddenRefs()) { PsiResolveHelper helper = PsiResolveHelper.SERVICE.getInstance(body.getProject()); - for (PsiLocalVariable local : locals) { + for (PsiLocalVariable local : checker.getLocals()) { final String localName = local.getName(); if (localName != null && helper.resolveReferencedVariable(localName, aClass) != null) return; } @@ -329,4 +277,110 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection return parameterType + parameterName; } } + + private static class ForbiddenRefsChecker extends JavaRecursiveElementWalkingVisitor { + private boolean myBodyContainsForbiddenRefs; + private final Set myLocals = ContainerUtilRt.newHashSet(5); + + private final PsiMethod myMethod; + private final PsiAnonymousClass myAnonymClass; + + public ForbiddenRefsChecker(PsiMethod method, + PsiAnonymousClass aClass) { + myMethod = method; + myAnonymClass = aClass; + } + + @Override + public void visitMethodCallExpression(PsiMethodCallExpression methodCallExpression) { + if (myBodyContainsForbiddenRefs) return; + + super.visitMethodCallExpression(methodCallExpression); + final PsiMethod psiMethod = methodCallExpression.resolveMethod(); + if (psiMethod == myMethod || + psiMethod != null && + !methodCallExpression.getMethodExpression().isQualified() && + "getClass".equals(psiMethod.getName()) && + psiMethod.getParameterList().getParametersCount() == 0) { + myBodyContainsForbiddenRefs = true; + } + } + + @Override + public void visitThisExpression(PsiThisExpression expression) { + if (myBodyContainsForbiddenRefs) return; + + if (expression.getQualifier() == null) { + myBodyContainsForbiddenRefs = true; + } + } + + @Override + public void visitSuperExpression(PsiSuperExpression expression) { + if (myBodyContainsForbiddenRefs) return; + + if (expression.getQualifier() == null) { + myBodyContainsForbiddenRefs = true; + } + } + + @Override + public void visitLocalVariable(PsiLocalVariable variable) { + if (myBodyContainsForbiddenRefs) return; + + super.visitLocalVariable(variable); + myLocals.add(variable); + } + + @Override + public void visitReferenceExpression(PsiReferenceExpression expression) { + if (myBodyContainsForbiddenRefs) return; + + super.visitReferenceExpression(expression); + if (!(expression.getParent() instanceof PsiMethodCallExpression)) { + final PsiField field = PsiTreeUtil.getParentOfType(expression, PsiField.class); + if (field != null) { + final PsiElement resolved = expression.resolve(); + if (resolved instanceof PsiField && ((PsiField)resolved).getContainingClass() == field.getContainingClass()) { + final PsiExpression initializer = ((PsiField)resolved).getInitializer(); + if (initializer == null || + initializer.getTextOffset() > myAnonymClass.getTextOffset() && !((PsiField)resolved).hasModifierProperty(PsiModifier.STATIC)) { + myBodyContainsForbiddenRefs = true; + } + } + } else { + final PsiMethod method = PsiTreeUtil.getParentOfType(myAnonymClass, PsiMethod.class); + if (method != null && method.isConstructor()) { + final PsiElement resolved = expression.resolve(); + if (resolved instanceof PsiField && + ((PsiField)resolved).hasModifierProperty(PsiModifier.FINAL) && + ((PsiField)resolved).getContainingClass() == method.getContainingClass()) { + try { + final PsiCodeBlock constructorBody = method.getBody(); + if (constructorBody != null) { + final ControlFlow flow = HighlightControlFlowUtil.getControlFlowNoConstantEvaluate(constructorBody); + final int startOffset = flow.getStartOffset(myAnonymClass); + final Collection writtenVariables = ControlFlowUtil.getWrittenVariables(flow, 0, startOffset, false); + if (!writtenVariables.contains(resolved)) { + myBodyContainsForbiddenRefs = true; + } + } + } + catch (AnalysisCanceledException e) { + myBodyContainsForbiddenRefs = true; + } + } + } + } + } + } + + public boolean hasForbiddenRefs() { + return myBodyContainsForbiddenRefs; + } + + public Set getLocals() { + return myLocals; + } + } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterFinalFieldInitializedBeforeAnonymInConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterFinalFieldInitializedBeforeAnonymInConstructor.java new file mode 100644 index 000000000000..e481f9b597c2 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/afterFinalFieldInitializedBeforeAnonymInConstructor.java @@ -0,0 +1,15 @@ +// "Replace with lambda" "true" +class HelloLambda { + final int x; + + HelloLambda() { + x = 1; + Runnable r = () -> { + System.out.println(x); + + }; + + } + + +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedAfterAnonymInConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedAfterAnonymInConstructor.java new file mode 100644 index 000000000000..8660181f50a6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedAfterAnonymInConstructor.java @@ -0,0 +1,18 @@ +// "Replace with lambda" "false" +class HelloLambda { + final int x; + + HelloLambda() { + Runnable r = new Runnable() { + @Override + public void run() { + System.out.println(x); + + } + }; + x = 1; + + } + + +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedBeforeAnonymInConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedBeforeAnonymInConstructor.java new file mode 100644 index 000000000000..be7fc0df1207 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/anonymous2lambda/beforeFinalFieldInitializedBeforeAnonymInConstructor.java @@ -0,0 +1,18 @@ +// "Replace with lambda" "true" +class HelloLambda { + final int x; + + HelloLambda() { + x = 1; + Runnable r = new Runnable() { + @Override + public void run() { + System.out.println(x); + + } + }; + + } + + +} From 43fdfb2b9bdad0583eebe1f17a6c89878ddf526b Mon Sep 17 00:00:00 2001 From: Alexey Gopachenko Date: Mon, 24 Feb 2014 12:17:57 +0100 Subject: [PATCH 39/39] Spellchecker : IDEA-120568 add gzip (cherry picked from commit 9204f00) --- 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 9358208806df..ca831c33beab 100644 --- a/spellchecker/src/com/intellij/spellchecker/jetbrains.dic +++ b/spellchecker/src/com/intellij/spellchecker/jetbrains.dic @@ -164,6 +164,7 @@ getters giud globals google +gzip gruntfile hardcoded hardlink