From a6b209e27bd50c1a691359f71cc15454e9d58569 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Tue, 24 Jun 2014 15:40:29 +0400 Subject: [PATCH 01/30] cosmetics: separator for venv on windows --- python/src/com/jetbrains/python/sdk/PySdkListCellRenderer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/sdk/PySdkListCellRenderer.java b/python/src/com/jetbrains/python/sdk/PySdkListCellRenderer.java index 9bd980a3dfac..1a42621dde3d 100644 --- a/python/src/com/jetbrains/python/sdk/PySdkListCellRenderer.java +++ b/python/src/com/jetbrains/python/sdk/PySdkListCellRenderer.java @@ -113,7 +113,7 @@ public class PySdkListCellRenderer extends ListCellRendererWrapper { } } else if (new File(name).exists()) { - name = ".../" + new File(name).getParentFile().getParentFile().getName(); + name = "..." + File.separator + new File(name).getParentFile().getParentFile().getName(); } return name; } From 13e423f2540da643f147a0a10ade91477e6b2417 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Wed, 25 Jun 2014 11:10:50 +0400 Subject: [PATCH 02/30] notnull --- .../src/com/intellij/codeInsight/lookup/impl/LookupImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java index e776b30b7f98..2e2bc60f29ee 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java @@ -78,7 +78,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable private final Editor myEditor; private final JBList myList = new JBList(new CollectionListModel()) { @Override - protected void processKeyEvent(final KeyEvent e) { + protected void processKeyEvent(@NotNull final KeyEvent e) { final char keyChar = e.getKeyChar(); if (keyChar == KeyEvent.VK_ENTER || keyChar == KeyEvent.VK_TAB) { IdeFocusManager.getInstance(myProject).requestFocus(myEditor.getContentComponent(), true).doWhenDone(new Runnable() { @@ -771,7 +771,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable private LookupElement oldItem = null; @Override - public void valueChanged(ListSelectionEvent e){ + public void valueChanged(@NotNull ListSelectionEvent e){ final LookupElement item = getCurrentItem(); if (oldItem != item && !myList.isEmpty()) { // do not update on temporary model wipe fireCurrentItemChanged(item); From e38a9410cd9bb6ab0250ae06db7a431a13abf47a Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Tue, 24 Jun 2014 15:38:00 +0400 Subject: [PATCH 03/30] Groovy: remove asserts which fail on Grails elements --- .../groovy/refactoring/rename/RenameGrFieldProcessor.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameGrFieldProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameGrFieldProcessor.java index db385b4f6bb9..9e90ac2326a0 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameGrFieldProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameGrFieldProcessor.java @@ -171,7 +171,6 @@ public class RenameGrFieldProcessor extends RenameJavaVariableProcessor { return GrTraitUtil.getTraitFieldPrefix(prototype.getContainingClass()) + newPrototypeName; } - LOG.error(element); return null; } @@ -202,7 +201,6 @@ public class RenameGrFieldProcessor extends RenameJavaVariableProcessor { return getNewElement(prototype); } - LOG.error(element); return null; } } From c66ad13aa74e9b7ab3eb6d8f916172d617116eb9 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 25 Jun 2014 09:33:50 +0200 Subject: [PATCH 04/30] adapt ResolveInLibrariesTest assertions to the new stubbing policy in library sources --- .../psi/resolve/ResolveInLibrariesTest.groovy | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy index 5e6adfdb4f55..ce04dd0ba20c 100644 --- a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveInLibrariesTest.groovy @@ -20,12 +20,12 @@ import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiClass -import com.intellij.psi.PsiFile -import com.intellij.psi.PsiManager import com.intellij.psi.PsiMethod +import com.intellij.psi.impl.source.PsiFileImpl import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.search.searches.ClassInheritorsSearch import com.intellij.psi.search.searches.OverridingMethodsSearch +import com.intellij.psi.stubs.StubTreeLoader import com.intellij.testFramework.PsiTestUtil import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase /** @@ -150,14 +150,12 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase { Collection pkgDirs = pkg.directories.collect { it.virtualFile } Collection pkgChildren = pkgDirs.collect { it.children as List }.flatten() - PsiFile javaSrc = psiManager.findFile(pkgChildren.find { it.name == 'LibraryClass.java' }) - assert !javaSrc.contentsLoaded - assert !javaSrc.stub + VirtualFile javaSrc = pkgChildren.find { it.name == 'LibraryClass.java' } + checkFileIsNotLoadedAndHasNoIndexedStub(javaSrc) assert pkg.containsClassNamed('LibraryClass') - assert !javaSrc.contentsLoaded - assert !javaSrc.stub - assert !javaSrc.node.parsed + checkFileIsNotLoadedAndHasNoIndexedStub(javaSrc) + assert !((PsiFileImpl)psiManager.findFile(javaSrc)).treeElement } @Override @@ -174,7 +172,7 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase { def localFile = myFixture.copyFileToProject(testDataPathForTest + File.separator + "Foo.java", 'Foo.java') assert localFile != null - checkFileIsNotLoadedAndHasNoStub(localFile) + checkFileIsNotLoadedAndHasNoIndexedStub(localFile) assert facade.findClasses('Foo', scope).size() == 0 PsiTestUtil.addLibrary(myModule, 'cas', lib.path, [] as String[], ["/classesAndSources.jar!/"] as String[]) @@ -187,14 +185,16 @@ class ResolveInLibrariesTest extends JavaCodeInsightFixtureTestCase { assert facade.findClasses('LibraryClass', scope).size() == 0 - checkFileIsNotLoadedAndHasNoStub(vfile) + checkFileIsNotLoadedAndHasNoIndexedStub(vfile) } - private void checkFileIsNotLoadedAndHasNoStub(VirtualFile vfile) { - def file = PsiManager.getInstance(project).findFile(vfile); + private void checkFileIsNotLoadedAndHasNoIndexedStub(VirtualFile vfile) { + PsiFileImpl file = psiManager.findFile(vfile); assert file != null assert !file.contentsLoaded - assert !file.stub + assert !StubTreeLoader.instance.readFromVFile(project, vfile) + assert !StubTreeLoader.instance.canHaveStub(vfile) + assert file.stub // from text } } From 5594ed43377cb8ac5b1f1c8e102eb0d2a60364f6 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Wed, 25 Jun 2014 11:44:27 +0400 Subject: [PATCH 05/30] EA-56055 - bug in DeleteLineAction --- .../editor/actions/DeleteLineAction.java | 4 +-- .../editor/actions/EditorActionTest.java | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteLineAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteLineAction.java index 4b5201e2c9ea..2143a176bd46 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteLineAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteLineAction.java @@ -41,7 +41,7 @@ public class DeleteLineAction extends TextComponentEditorAction { } @Override - public void executeWriteAction(Editor editor, DataContext dataContext) { + public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) { CommandProcessor.getInstance().setCurrentCommandGroupId(EditorActionUtil.DELETE_COMMAND_GROUP); CopyPasteManager.getInstance().stopKillRings(); SelectionModel selectionModel = editor.getSelectionModel(); @@ -76,7 +76,7 @@ public class DeleteLineAction extends TextComponentEditorAction { selectionModel.selectLineAtCaret(); boolean removeLastSymbol = selectionModel.getSelectionEnd() == document.getTextLength() && document.getLineCount() > 1; EditorModificationUtil.deleteSelectedText(editor); - if (removeLastSymbol) { + if (removeLastSymbol && document.getTextLength() > 0) { document.deleteString(document.getTextLength() - 1, document.getTextLength()); position = new VisualPosition(position.line - 1, position.column); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorActionTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorActionTest.java index 63e040def381..deb63c13abf8 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorActionTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/actions/EditorActionTest.java @@ -20,6 +20,8 @@ import com.intellij.openapi.editor.impl.AbstractEditorTest; import com.intellij.testFramework.EditorTestUtil; import com.intellij.testFramework.TestFileType; +import java.io.IOException; + public class EditorActionTest extends AbstractEditorTest { public void testDownWithSelectionWhenCaretsAreAllowedInsideTabs() throws Exception { init("text", @@ -69,4 +71,35 @@ public class EditorActionTest extends AbstractEditorTest { executeAction("EditorTab"); checkResultByText("some text"); } + + public void testLineDeleteWithSelectionEndAtLineStart() throws IOException { + String text = + "line 1\n" + + "line 2\n" + + "line 3"; + init(text, TestFileType.TEXT); + deleteLine(); + checkResultByText( + "line 1\n" + + "line 3" + ); + } + + public void testDeleteLastLine() throws IOException { + String text = + "1\n" + + "2\n" + + "3"; + init(text, TestFileType.TEXT); + + deleteLine(); + deleteLine(); + checkResultByText("1"); + } + + public void testDeleteLastNonEmptyLine() throws IOException { + init("1\n", TestFileType.TEXT); + deleteLine(); + checkResultByText(""); + } } \ No newline at end of file From 3a82ee665be3538d9425dd6ac9f4570fbc8ef181 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Wed, 25 Jun 2014 12:14:45 +0400 Subject: [PATCH 06/30] IDEA-126533 SQL: Code Style: "Word Case / Keyword = Do not change" is ignored by completion: multi word case --- .../src/com/intellij/codeInsight/lookup/impl/LookupImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java index 2e2bc60f29ee..ae9ba979e771 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java @@ -590,7 +590,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable final String prefix = itemPattern(item); final int length = prefix.length(); - if (length == 0 || !StringUtil.startsWithIgnoreCase(lookupString, prefix)) return lookupString; + if (length == 0 || !itemMatcher(item).prefixMatches(prefix)) return lookupString; boolean isAllLower = true; boolean isAllUpper = true; boolean sameCase = true; From 3b014cf231c00272e86384bf8a5d57ac58e28236 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Wed, 25 Jun 2014 12:28:49 +0400 Subject: [PATCH 07/30] EA-40788 - NPE: EditorImpl.paintComposedTextDecoration --- .../src/com/intellij/openapi/editor/impl/EditorImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 83bb738ca263..109fe6b75d27 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -2075,7 +2075,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi } private void paintComposedTextDecoration(@NotNull Graphics2D g) { - if (myInputMethodRequestsHandler != null && myInputMethodRequestsHandler.composedText != null) { + if (myInputMethodRequestsHandler != null + && myInputMethodRequestsHandler.composedText != null + && myInputMethodRequestsHandler.composedTextRange != null) { VisualPosition visStart = offsetToVisualPosition(Math.min(myInputMethodRequestsHandler.composedTextRange.getStartOffset(), myDocument.getTextLength())); int y = visibleLineToY(visStart.line) + getAscent() + 1; From 9bbe66b82e4c94aac99e80d60e592818275d2a8d Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Wed, 25 Jun 2014 13:00:14 +0400 Subject: [PATCH 08/30] show message if frames requested for not suspended thread --- .../com/intellij/debugger/engine/JavaExecutionStack.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaExecutionStack.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaExecutionStack.java index e52236dca5a2..2eb2ca8e78a8 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaExecutionStack.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaExecutionStack.java @@ -116,8 +116,8 @@ public class JavaExecutionStack extends XExecutionStack { @Override protected void action() throws Exception { boolean showLibraryStackframes = DebuggerSettings.getInstance().SHOW_LIBRARY_STACKFRAMES; - List frames = new ArrayList(); if (!myThreadProxy.isCollected() && myDebugProcess.getSuspendManager().isSuspended(myThreadProxy)) { + List frames = new ArrayList(); int status = myThreadProxy.status(); if (!(status == ThreadReference.THREAD_STATUS_UNKNOWN) && !(status == ThreadReference.THREAD_STATUS_NOT_STARTED) && @@ -146,8 +146,11 @@ public class JavaExecutionStack extends XExecutionStack { return; } } + container.addStackFrames(frames, true); + } + else { + container.errorOccurred(DebuggerBundle.message("frame.panel.frames.not.available")); } - container.addStackFrames(frames, true); } }); } From 34898d56b81a2c4396c51e78900172720ff8c4cb Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Tue, 24 Jun 2014 17:54:58 +0400 Subject: [PATCH 09/30] diff: fix element building in case of range fully inside single parent element --- .../FragmentedEditorHighlighter.java | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java b/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java index 8d26ee44031d..a76ffabdf022 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java @@ -55,15 +55,20 @@ public class FragmentedEditorHighlighter implements EditorHighlighter { } private void translate(HighlighterIterator iterator, List ranges) { - if (iterator.atEnd()) return; int offset = 0; - for (TextRange range : ranges) { - while (range.getStartOffset() > iterator.getStart()) { + int index = 0; + + while (!iterator.atEnd() && index < ranges.size()) { + TextRange range = ranges.get(index); + + if (range.getStartOffset() >= iterator.getEnd()) { iterator.advance(); - if (iterator.atEnd()) return; + continue; } - while (range.getEndOffset() >= iterator.getEnd()) { - int relativeStart = iterator.getStart() - range.getStartOffset(); + + if (range.getEndOffset() >= iterator.getStart()) { + int relativeStart = Math.max(iterator.getStart() - range.getStartOffset(), 0); + int relativeEnd = Math.min(iterator.getEnd() - range.getStartOffset(), range.getLength()); boolean merged = false; if (myMergeByTextAttributes && !myPieces.isEmpty()) { Map.Entry entry = myPieces.lastEntry(); @@ -74,19 +79,26 @@ public class FragmentedEditorHighlighter implements EditorHighlighter { element.getElementType().equals(iterator.getTokenType())) { merged = true; myPieces.put(key, new Element(key, - offset + (iterator.getEnd() - range.getStartOffset()), iterator.getTokenType(), + offset + relativeEnd, + iterator.getTokenType(), iterator.getTextAttributes())); } } if (!merged) { myPieces.put(offset + relativeStart, new Element(offset + relativeStart, - offset + (iterator.getEnd() - range.getStartOffset()), iterator.getTokenType(), + offset + relativeEnd, + iterator.getTokenType(), iterator.getTextAttributes())); } - iterator.advance(); - if (iterator.atEnd()) return; } - offset += range.getLength() + 1 + myAdditionalOffset; // myAdditionalOffset because of extra line - for shoene separators + + if (range.getEndOffset() < iterator.getEnd()) { + offset += range.getLength() + 1 + myAdditionalOffset; // myAdditionalOffset because of extra line - for shoene separators + index++; + continue; + } + + iterator.advance(); } } From 81fa6d7dddc06a9945040c65eb2bdbdd2225662e Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Tue, 24 Jun 2014 21:28:31 +0400 Subject: [PATCH 10/30] IDEA-113317 diff: make RangeMarker greedy for 'compare with clipboard' action --- .../src/com/intellij/openapi/diff/FragmentContent.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/platform-api/src/com/intellij/openapi/diff/FragmentContent.java b/platform/platform-api/src/com/intellij/openapi/diff/FragmentContent.java index 9a176e37aaf4..26537316b4e9 100644 --- a/platform/platform-api/src/com/intellij/openapi/diff/FragmentContent.java +++ b/platform/platform-api/src/com/intellij/openapi/diff/FragmentContent.java @@ -48,6 +48,8 @@ public class FragmentContent extends DiffContent { public FragmentContent(@NotNull DiffContent original, @NotNull TextRange range, Project project, FileType fileType) { RangeMarker rangeMarker = original.getDocument().createRangeMarker(range.getStartOffset(), range.getEndOffset(), true); + rangeMarker.setGreedyToLeft(true); + rangeMarker.setGreedyToRight(true); mySynchonizer = new MyDocumentsSynchronizer(project, rangeMarker); myOriginal = original; myType = fileType; From ced1a6b33fa726bf3279f931a2a52a4c7098c97c Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 25 Jun 2014 12:51:32 +0400 Subject: [PATCH 11/30] IDEA-118700 IDEA-89365 diff: fix diff highlighting in commit dialog fix disappearing highlighting in case of few ranges inside single big highlighted block (ex: few small modifications in multiline comment) The color disappears in last range of block during different text operations (selecting text, changing caret position, "ticking" of caret) document.getComponent().repaint() brings back correct highlighting. --- .../openapi/editor/highlighter/FragmentedEditorHighlighter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java b/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java index a76ffabdf022..5d1b1ab79ea8 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java @@ -105,7 +105,7 @@ public class FragmentedEditorHighlighter implements EditorHighlighter { @NotNull @Override public HighlighterIterator createIterator(int startOffset) { - Map.Entry entry = myPieces.ceilingEntry(startOffset); + Map.Entry entry = myPieces.floorEntry(startOffset); return new ProxyIterator(myDocument, entry == null ? -1 : entry.getKey()); } From b537dc77576c96c3cee6ffe2f608d5d4e93061ac Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 25 Jun 2014 13:04:59 +0400 Subject: [PATCH 12/30] diff: we don't need a map here --- .../FragmentedEditorHighlighter.java | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java b/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java index 5d1b1ab79ea8..eed6946c86ff 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/highlighter/FragmentedEditorHighlighter.java @@ -23,9 +23,10 @@ import com.intellij.openapi.util.TextRange; import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; -import java.util.Map; -import java.util.TreeMap; /** * Created by IntelliJ IDEA. @@ -34,7 +35,7 @@ import java.util.TreeMap; * Time: 12:52 PM */ public class FragmentedEditorHighlighter implements EditorHighlighter { - private final TreeMap myPieces; + private final List myPieces; private final Document myDocument; private final int myAdditionalOffset; private final boolean myMergeByTextAttributes; @@ -49,7 +50,7 @@ public class FragmentedEditorHighlighter implements EditorHighlighter { boolean mergeByTextAttributes) { myMergeByTextAttributes = mergeByTextAttributes; myDocument = sourceIterator.getDocument(); - myPieces = new TreeMap(); + myPieces = new ArrayList(); myAdditionalOffset = additionalOffset; translate(sourceIterator, ranges); } @@ -71,24 +72,22 @@ public class FragmentedEditorHighlighter implements EditorHighlighter { int relativeEnd = Math.min(iterator.getEnd() - range.getStartOffset(), range.getLength()); boolean merged = false; if (myMergeByTextAttributes && !myPieces.isEmpty()) { - Map.Entry entry = myPieces.lastEntry(); - final Integer key = entry.getKey(); - final Element element = entry.getValue(); + Element element = myPieces.get(myPieces.size() - 1); if (element.getEnd() >= offset + relativeStart && element.getAttributes().equals(iterator.getTextAttributes()) && element.getElementType().equals(iterator.getTokenType())) { merged = true; - myPieces.put(key, new Element(key, - offset + relativeEnd, - iterator.getTokenType(), - iterator.getTextAttributes())); + myPieces.add(new Element(element.getStart(), + offset + relativeEnd, + iterator.getTokenType(), + iterator.getTextAttributes())); } } if (!merged) { - myPieces.put(offset + relativeStart, new Element(offset + relativeStart, - offset + relativeEnd, - iterator.getTokenType(), - iterator.getTextAttributes())); + myPieces.add(new Element(offset + relativeStart, + offset + relativeEnd, + iterator.getTokenType(), + iterator.getTextAttributes())); } } @@ -105,8 +104,16 @@ public class FragmentedEditorHighlighter implements EditorHighlighter { @NotNull @Override public HighlighterIterator createIterator(int startOffset) { - Map.Entry entry = myPieces.floorEntry(startOffset); - return new ProxyIterator(myDocument, entry == null ? -1 : entry.getKey()); + int offset = Collections.binarySearch(myPieces, new Element(startOffset, 0, null, null), new Comparator() { + @Override + public int compare(Element o1, Element o2) { + return o1.getStart() - o2.getStart(); + } + }); + // offset: (-insertion point - 1), where insertionPoint is the index of the first element greater than the key + // and we need offset of the first element that is less or equal (floorElement) + if (offset < 0) offset = Math.max(-offset - 2, 0); + return new ProxyIterator(myDocument, offset); } @Override @@ -160,27 +167,21 @@ public class FragmentedEditorHighlighter implements EditorHighlighter { @Override public void advance() { - if (myIdx == myPieces.lastKey() || myIdx == -1) { - myIdx = -1; - return; + if (myIdx < myPieces.size()) { + myIdx++; } - Map.Entry entry = myPieces.tailMap(myIdx, false).firstEntry(); - myIdx = entry.getKey(); } @Override public void retreat() { - if (myIdx == myPieces.firstKey() || myIdx == -1) { - myIdx = -1; - return; + if (myIdx > -1) { + myIdx--; } - Map.Entry entry = myPieces.headMap(myIdx, false).lastEntry(); - myIdx = entry.getKey(); } @Override public boolean atEnd() { - return myIdx < 0; + return myIdx < 0 || myIdx >= myPieces.size(); } @Override From b4226ca0500238550d76493575e58495e493cf34 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Tue, 24 Jun 2014 14:44:40 +0400 Subject: [PATCH 13/30] Properly check that API token is used for authentication in Redmine --- .../intellij/tasks/redmine/RedmineRepository.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/redmine/RedmineRepository.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/redmine/RedmineRepository.java index 5dadcdfb0e8f..e0c4ba3170a7 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/redmine/RedmineRepository.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/redmine/RedmineRepository.java @@ -108,7 +108,11 @@ public class RedmineRepository extends NewBaseRepositoryImpl { // /users/current.json. Unfortunately this endpoint may be unavailable on some old servers (see IDEA-122845) // and in this case we have to come back to requesting issues in this case to test anything at all. HttpClient client = getHttpClient(); - HttpResponse response = client.execute(new HttpGet(getRestApiUrl("users", "current.json"))); + URIBuilder uriBuilder = new URIBuilder(getRestApiUrl("users", "current.json")); + if (isUseApiKeyAuthentication()) { + uriBuilder.addParameter("key", getAPIKey()); + } + HttpResponse response = client.execute(new HttpGet(uriBuilder.build())); //TaskUtil.prettyFormatResponseToLog(LOG, response); int code = response.getStatusLine().getStatusCode(); if (code == HttpStatus.SC_NOT_FOUND) { @@ -189,7 +193,7 @@ public class RedmineRepository extends NewBaseRepositoryImpl { } private boolean isUseApiKeyAuthentication() { - return !StringUtil.isEmptyOrSpaces(myAPIKey) && !isUseHttpAuthentication(); + return !isUseHttpAuthentication() && StringUtil.isNotEmpty(myAPIKey); } @Override @@ -203,11 +207,11 @@ public class RedmineRepository extends NewBaseRepositoryImpl { @Override public boolean isConfigured() { - if (!super.isConfigured() || StringUtil.isEmpty(myUsername)) return false; + if (!super.isConfigured()) return false; if (isUseHttpAuthentication()) { - return StringUtil.isNotEmpty(myPassword); + return StringUtil.isNotEmpty(myPassword) && StringUtil.isNotEmpty(myUsername); } - return !StringUtil.isEmptyOrSpaces(myAPIKey); + return StringUtil.isNotEmpty(myAPIKey); } @Nullable From 2c9d49403473cedca909cb0f2c8ee9a9328f1efc Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Tue, 24 Jun 2014 14:45:41 +0400 Subject: [PATCH 14/30] Hide API token field if basic authentication is used and vice-versa in Redmine settings --- .../tasks/redmine/RedmineRepositoryEditor.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/redmine/RedmineRepositoryEditor.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/redmine/RedmineRepositoryEditor.java index 46ee77a9ac7d..43f34d525c07 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/redmine/RedmineRepositoryEditor.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/redmine/RedmineRepositoryEditor.java @@ -35,6 +35,8 @@ public class RedmineRepositoryEditor extends BaseRepositoryEditor Date: Tue, 24 Jun 2014 16:27:27 +0400 Subject: [PATCH 15/30] Remove project from combo when test connection is failed --- .../src/com/intellij/tasks/redmine/RedmineRepositoryEditor.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/redmine/RedmineRepositoryEditor.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/redmine/RedmineRepositoryEditor.java index 43f34d525c07..110f9328ef9a 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/redmine/RedmineRepositoryEditor.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/redmine/RedmineRepositoryEditor.java @@ -49,6 +49,8 @@ public class RedmineRepositoryEditor extends BaseRepositoryEditor Date: Tue, 24 Jun 2014 18:11:22 +0400 Subject: [PATCH 16/30] Exclude all local and cached tasks from those returned by server in TaskItemProvider --- .../intellij/tasks/actions/TaskItemProvider.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/TaskItemProvider.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/TaskItemProvider.java index afa94414c35c..2511fdef536b 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/TaskItemProvider.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/TaskItemProvider.java @@ -20,8 +20,6 @@ import java.util.List; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicReference; -import static com.intellij.tasks.actions.TaskSearchSupport.getRepositoriesTasks; - /** * @author Mikhail Golubev */ @@ -88,7 +86,15 @@ class TaskItemProvider implements ChooseByNameItemProvider, Disposable { try { List tasks = future.get(); myFutureReference.compareAndSet(future, null); - tasks.removeAll(cachedAndLocalTasks); + + // Exclude *all* cached and local issues, not only those returned by TaskSearchSupport.getLocalAndCachedTasks(). + // Previously used approach might lead to the following strange behavior. Local task excluded by getLocalAndCachedTasks() + // as "locally closed" (i.e. having no associated change list) was indeed *included* in popup because it + // was contained in server response (as not remotely closed). Moreover on next request with pagination when the + // same issues was not returned again by server it was *excluded* from popup (thus subsequent update reduced total + // number of items shown). + tasks.removeAll(TaskManager.getManager(myProject).getLocalTasks()); + tasks.removeAll(TaskManager.getManager(myProject).getCachedIssues()); return processTasks(tasks, consumer, cancelled); } catch (InterruptedException interrupted) { @@ -138,7 +144,8 @@ class TaskItemProvider implements ChooseByNameItemProvider, Disposable { limit = GotoTaskAction.PAGE_SIZE; myCurrentOffset += GotoTaskAction.PAGE_SIZE; } - List tasks = getRepositoriesTasks(TaskManager.getManager(myProject), pattern, offset, limit, true, everywhere, cancelled); + List tasks = TaskSearchSupport.getRepositoriesTasks(TaskManager.getManager(myProject), + pattern, offset, limit, true, everywhere, cancelled); myOldEverywhere = everywhere; myOldPattern = pattern; return tasks; From 7662a5e629f0941cddf70f45e98c3685b2f35591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Wed, 25 Jun 2014 12:10:27 +0200 Subject: [PATCH 17/30] jUnit: do not search for anonymous inheritors --- .../com/intellij/execution/ConfigurationUtil.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/plugins/junit/src/com/intellij/execution/ConfigurationUtil.java b/plugins/junit/src/com/intellij/execution/ConfigurationUtil.java index 89590887cbbb..274c2797540d 100644 --- a/plugins/junit/src/com/intellij/execution/ConfigurationUtil.java +++ b/plugins/junit/src/com/intellij/execution/ConfigurationUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,17 +19,12 @@ package com.intellij.execution; import com.intellij.execution.junit.JUnitUtil; import com.intellij.execution.junit.TestClassFilter; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.project.DumbService; -import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.PsiElementProcessor; -import com.intellij.psi.search.PsiElementProcessorAdapter; -import com.intellij.psi.search.PsiShortNamesCache; +import com.intellij.psi.search.*; import com.intellij.psi.search.searches.AnnotatedMembersSearch; import com.intellij.psi.search.searches.ClassInheritorsSearch; import com.intellij.psi.util.PsiUtilCore; @@ -47,7 +42,7 @@ public class ConfigurationUtil { final Project project = manager.getProject(); GlobalSearchScope projectScopeWithoutLibraries = GlobalSearchScope.projectScope(project); final GlobalSearchScope scope = projectScopeWithoutLibraries.intersectWith(testClassFilter.getScope()); - ClassInheritorsSearch.search(testClassFilter.getBase(), scope, true).forEach(new PsiElementProcessorAdapter(new PsiElementProcessor() { + ClassInheritorsSearch.search(testClassFilter.getBase(), scope, true, true, false).forEach(new PsiElementProcessorAdapter(new PsiElementProcessor() { public boolean execute(@NotNull final PsiClass aClass) { if (testClassFilter.isAccepted(aClass)) found.add(aClass); return true; @@ -113,7 +108,7 @@ public class ConfigurationUtil { found.add(containingClass); isJUnit4.set(Boolean.TRUE); } - ClassInheritorsSearch.search(containingClass, scope, true) + ClassInheritorsSearch.search(containingClass, scope, true, true, false) .forEach(new PsiElementProcessorAdapter(new PsiElementProcessor() { public boolean execute(@NotNull final PsiClass aClass) { if (testClassFilter.isAccepted(aClass)) { From 643881aed8cbaed162c2ede90960b5be74b3a084 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 24 Jun 2014 21:00:28 +0200 Subject: [PATCH 18/30] include enum.values() in signature hierarchy (IDEA-125077) --- .../psi/impl/PsiSuperMethodImplUtil.java | 15 ++++++++--- .../lambda/newMethodRef/EnumValuesMethod.java | 25 +++++++++++++++++++ .../lambda/NewMethodRefHighlightingTest.java | 4 +++ 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/EnumValuesMethod.java diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java index ac3e7a6fd455..f1d847cb24c2 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSuperMethodImplUtil.java @@ -22,12 +22,11 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.psi.*; import com.intellij.psi.impl.source.HierarchicalMethodSignatureImpl; +import com.intellij.psi.impl.source.PsiClassImpl; import com.intellij.psi.search.searches.DeepestSuperMethodsSearch; import com.intellij.psi.search.searches.SuperMethodsSearch; import com.intellij.psi.util.*; -import com.intellij.util.NotNullFunction; -import com.intellij.util.Processor; -import com.intellij.util.SmartList; +import com.intellij.util.*; import gnu.trove.THashMap; import gnu.trove.THashSet; import gnu.trove.TObjectHashingStrategy; @@ -143,7 +142,15 @@ public class PsiSuperMethodImplUtil { } }); - for (PsiMethod method : aClass.getMethods()) { + PsiMethod[] methods = aClass.getMethods(); + if (aClass instanceof PsiClassImpl) { + final PsiMethod valuesMethod = ((PsiClassImpl)aClass).getValuesMethod(); + if (valuesMethod != null) { + methods = ArrayUtil.append(methods, valuesMethod); + } + } + + for (PsiMethod method : methods) { if (!method.isValid()) { throw new PsiInvalidElementAccessException(method, "class.valid=" + aClass.isValid() + "; name=" + method.getName()); } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/EnumValuesMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/EnumValuesMethod.java new file mode 100644 index 000000000000..14ad192c8823 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/EnumValuesMethod.java @@ -0,0 +1,25 @@ +import java.util.function.Supplier; + +class EnumValues { + + { + Supplier> supplier = () -> new C<>(ABC::values); + } + + private static interface I { + T get(); + } + + private static class C implements I { + C(Supplier supplier) {} + + @Override + public E get() { + return null; + } + } + + private static enum ABC { + A, B, C + } +} \ No newline at end of file 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 0c61b63bfc8d..3cfdaa4071cc 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 @@ -265,6 +265,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testEnumValuesMethod() throws Exception { + doTest(); + } + private void doTest() { doTest(false); } From 824377547fa6e5d053d5c0738d8d47cff4baf2c4 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 25 Jun 2014 12:00:01 +0200 Subject: [PATCH 19/30] editor notifications should only be updated for open files --- .../intellij/ui/EditorNotificationsImpl.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java b/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java index 24660c6674ab..800d8bd1dc63 100644 --- a/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java @@ -90,6 +90,8 @@ public class EditorNotificationsImpl extends EditorNotifications { myCurrentUpdates.put(file, indicator); final ReadTask task = createTask(indicator, file); + if (task == null) return; + if (ApplicationManager.getApplication().isUnitTestMode()) { task.computeInReadAction(indicator); } @@ -106,11 +108,25 @@ public class EditorNotificationsImpl extends EditorNotifications { }); } + @Nullable private ReadTask createTask(final ProgressIndicator indicator, final VirtualFile file) { + final FileEditor[] editors = FileEditorManager.getInstance(myProject).getAllEditors(file); + if (editors.length == 0) return null; + return new ReadTask() { private boolean isOutdated() { - return myProject.isDisposed() || !file.isValid() || indicator != myCurrentUpdates.get(file); + if (myProject.isDisposed() || !file.isValid() || indicator != myCurrentUpdates.get(file)) { + return true; + } + + for (FileEditor editor : editors) { + if (!editor.isValid()) { + return true; + } + } + + return false; } @Override @@ -118,7 +134,7 @@ public class EditorNotificationsImpl extends EditorNotifications { if (isOutdated()) return; final List updates = ContainerUtil.newArrayList(); - for (final FileEditor editor : FileEditorManager.getInstance(myProject).getAllEditors(file)) { + for (final FileEditor editor : editors) { for (final Provider provider : Extensions.getExtensions(EXTENSION_POINT_NAME, myProject)) { final JComponent component = provider.createNotificationPanel(file, editor); updates.add(new Runnable() { From 770a94ebfd8fde64f5e8c94fad1bc319585ed86e Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 25 Jun 2014 14:45:47 +0400 Subject: [PATCH 20/30] cosmetics: border in new project in default LaF --- .../newProject/actions/AbstractProjectSettingsStep.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java b/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java index d2c1782abc89..d9f3cf24f0e5 100644 --- a/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java +++ b/python/ide/src/com/jetbrains/python/newProject/actions/AbstractProjectSettingsStep.java @@ -44,6 +44,7 @@ import icons.PythonIcons; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import javax.swing.border.Border; import javax.swing.event.DocumentEvent; import java.awt.*; import java.awt.event.ActionEvent; @@ -353,10 +354,12 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane } private static class Button extends ActionButtonWithText { + private final Border myBorder; public Button(AnAction action, Presentation presentation) { super(action, presentation, "NewProject", new Dimension(70, 50)); - setBorder(UIUtil.getButtonBorder()); + myBorder = UIUtil.isUnderDarcula() ? UIUtil.getButtonBorder() : BorderFactory.createLineBorder(UIUtil.getBorderColor()); + setBorder(myBorder); } @Override @@ -385,7 +388,7 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane setBorder(null); } else if (e.getID() == MouseEvent.MOUSE_EXITED) { - setBorder(UIUtil.getButtonBorder()); + setBorder(myBorder); } } } From d29445a45cc2aead3b83a1ee7559556d0e561c29 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 24 Jun 2014 18:53:40 +0400 Subject: [PATCH 21/30] notnull --- .../impl/AttachSourcesNotificationProvider.java | 11 ++++++----- .../daemon/impl/SetupSDKNotificationProvider.java | 5 +++-- .../ide/GeneratedFileEditingNotificationProvider.java | 6 ++++-- .../src/com/intellij/ui/EditorNotifications.java | 8 +++++--- .../intellij/ide/FileChangedNotificationProvider.java | 1 + .../PluginAdvertiserEditorNotificationProvider.java | 5 +++-- .../ChangelistConflictNotificationProvider.java | 8 ++++++-- ...seDistributionWithSourcesNotificationProvider.java | 5 +++-- .../ConfigureGroovyLibraryNotificationProvider.java | 6 ++++-- 9 files changed, 35 insertions(+), 20 deletions(-) diff --git a/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/AttachSourcesNotificationProvider.java b/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/AttachSourcesNotificationProvider.java index 5f6f18def730..8a4c380a669a 100644 --- a/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/AttachSourcesNotificationProvider.java +++ b/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/AttachSourcesNotificationProvider.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. @@ -43,7 +43,7 @@ import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; @@ -79,13 +79,14 @@ public class AttachSourcesNotificationProvider extends EditorNotifications.Provi }); } + @NotNull @Override public Key getKey() { return KEY; } @Override - public EditorNotificationPanel createNotificationPanel(final VirtualFile file, FileEditor fileEditor) { + public EditorNotificationPanel createNotificationPanel(@NotNull final VirtualFile file, @NotNull FileEditor fileEditor) { if (file.getFileType() != JavaClassFileType.INSTANCE) return null; final List libraries = findOrderEntriesContainingFile(file); if (libraries == null) return null; @@ -240,7 +241,7 @@ public class AttachSourcesNotificationProvider extends EditorNotifications.Provi if (modelsToCommit.isEmpty()) return new ActionCallback.Rejected(); new WriteAction() { @Override - protected void run(final Result result) { + protected void run(@NotNull final Result result) { for (Library.ModifiableModel model : modelsToCommit) { model.commit(); } @@ -253,7 +254,7 @@ public class AttachSourcesNotificationProvider extends EditorNotifications.Provi @Nullable private VirtualFile findRoot(Library library) { for (VirtualFile classesRoot : library.getFiles(OrderRootType.CLASSES)) { - if (VfsUtil.isAncestor(classesRoot, myClassFile, true)) { + if (VfsUtilCore.isAncestor(classesRoot, myClassFile, true)) { return classesRoot; } } diff --git a/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/SetupSDKNotificationProvider.java b/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/SetupSDKNotificationProvider.java index 178c85584ae2..668f2cc97577 100644 --- a/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/SetupSDKNotificationProvider.java +++ b/java/idea-ui/src/com/intellij/codeInsight/daemon/impl/SetupSDKNotificationProvider.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. @@ -53,13 +53,14 @@ public class SetupSDKNotificationProvider extends EditorNotifications.Provider getKey() { return KEY; } @Override - public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) { + public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) { if (file.getFileType() == JavaClassFileType.INSTANCE) return null; final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file); diff --git a/platform/lang-impl/src/com/intellij/ide/GeneratedFileEditingNotificationProvider.java b/platform/lang-impl/src/com/intellij/ide/GeneratedFileEditingNotificationProvider.java index 5a6606be1c77..5b9e9a663b3f 100644 --- a/platform/lang-impl/src/com/intellij/ide/GeneratedFileEditingNotificationProvider.java +++ b/platform/lang-impl/src/com/intellij/ide/GeneratedFileEditingNotificationProvider.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. @@ -20,6 +20,7 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.EditorNotificationPanel; import com.intellij.ui.EditorNotifications; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -33,6 +34,7 @@ public class GeneratedFileEditingNotificationProvider extends EditorNotification myChangeTracker = changeTracker; } + @NotNull @Override public Key getKey() { return KEY; @@ -40,7 +42,7 @@ public class GeneratedFileEditingNotificationProvider extends EditorNotification @Nullable @Override - public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) { + public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) { if (!myChangeTracker.isEditedGeneratedFile(file)) return null; EditorNotificationPanel panel = new EditorNotificationPanel(); diff --git a/platform/platform-api/src/com/intellij/ui/EditorNotifications.java b/platform/platform-api/src/com/intellij/ui/EditorNotifications.java index 4db32d94dd30..6805266e57ad 100644 --- a/platform/platform-api/src/com/intellij/ui/EditorNotifications.java +++ b/platform/platform-api/src/com/intellij/ui/EditorNotifications.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. @@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -31,10 +32,11 @@ import javax.swing.*; public abstract class EditorNotifications extends AbstractProjectComponent { public abstract static class Provider { + @NotNull public abstract Key getKey(); @Nullable - public abstract T createNotificationPanel(VirtualFile file, FileEditor fileEditor); + public abstract T createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor); } public static EditorNotifications getInstance(Project project) { @@ -45,7 +47,7 @@ public abstract class EditorNotifications extends AbstractProjectComponent { super(project); } - public abstract void updateNotifications(final VirtualFile file); + public abstract void updateNotifications(@NotNull VirtualFile file); public abstract void updateAllNotifications(); diff --git a/platform/platform-impl/src/com/intellij/ide/FileChangedNotificationProvider.java b/platform/platform-impl/src/com/intellij/ide/FileChangedNotificationProvider.java index cce510c0233d..fa975283d921 100644 --- a/platform/platform-impl/src/com/intellij/ide/FileChangedNotificationProvider.java +++ b/platform/platform-impl/src/com/intellij/ide/FileChangedNotificationProvider.java @@ -79,6 +79,7 @@ public class FileChangedNotificationProvider extends EditorNotifications.Provide }); } + @NotNull @Override public Key getKey() { return KEY; diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginAdvertiserEditorNotificationProvider.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginAdvertiserEditorNotificationProvider.java index 18c5f76b670a..394dec20f4ef 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginAdvertiserEditorNotificationProvider.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/pluginsAdvertisement/PluginAdvertiserEditorNotificationProvider.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. @@ -52,6 +52,7 @@ public class PluginAdvertiserEditorNotificationProvider extends EditorNotificati myNotifications = notifications; } + @NotNull @Override public Key getKey() { return KEY; @@ -59,7 +60,7 @@ public class PluginAdvertiserEditorNotificationProvider extends EditorNotificati @Nullable @Override - public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) { + public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) { if (file.getFileType() != PlainTextFileType.INSTANCE) return null; final String extension = file.getExtension(); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictNotificationProvider.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictNotificationProvider.java index 99c8d796c38b..60750b1cdbad 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictNotificationProvider.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/conflicts/ChangelistConflictNotificationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.vcs.changes.ChangeListManagerImpl; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.EditorNotifications; +import org.jetbrains.annotations.NotNull; /** * @author Dmitry Avdeev @@ -34,11 +35,14 @@ public class ChangelistConflictNotificationProvider extends EditorNotifications. myConflictTracker = changeListManager.getConflictTracker(); } + @Override + @NotNull public Key getKey() { return KEY; } - public ChangelistConflictNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) { + @Override + public ChangelistConflictNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) { return myConflictTracker.hasConflict(file) ? ChangelistConflictNotificationPanel.create(myConflictTracker, file) : null; } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java index 7ac99066d74f..7b06640f6234 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.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. @@ -85,13 +85,14 @@ public class UseDistributionWithSourcesNotificationProvider extends EditorNotifi }); } + @NotNull @Override public Key getKey() { return KEY; } @Override - public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) { + public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) { try { if (GradleConstants.DEFAULT_SCRIPT_NAME.equals(file.getName()) || GradleConstants.SETTINGS_FILE_NAME.equals(file.getName())) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ConfigureGroovyLibraryNotificationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ConfigureGroovyLibraryNotificationProvider.java index 911451e55e2d..1b2f82fe186b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ConfigureGroovyLibraryNotificationProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/ConfigureGroovyLibraryNotificationProvider.java @@ -21,6 +21,7 @@ import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; @@ -67,13 +68,14 @@ public class ConfigureGroovyLibraryNotificationProvider extends EditorNotificati } } + @NotNull @Override public Key getKey() { return KEY; } @Override - public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) { + public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) { try { if (!supportedFileTypes.contains(file.getFileType())) return null; // do not show the panel for Gradle build scripts @@ -81,7 +83,7 @@ public class ConfigureGroovyLibraryNotificationProvider extends EditorNotificati if (StringUtil.endsWith(file.getName(), ".gradle")) return null; if (CompilerManager.getInstance(myProject).isExcludedFromCompilation(file)) return null; - final Module module = ModuleUtil.findModuleForFile(file, myProject); + final Module module = ModuleUtilCore.findModuleForFile(file, myProject); if (module == null) return null; if (isMavenModule(module)) return null; From af4c3a3d2d5218591e37d01fa573f2904d5450fb Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 25 Jun 2014 14:54:40 +0400 Subject: [PATCH 22/30] removed usages of AtomicLongFieldUpdater because it's broken under JDK7 (doesn't like private fields) --- .../openapi/editor/impl/IntervalTreeImpl.java | 18 +++++++++--------- .../util/concurrency/AtomicFieldUpdater.java | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/platform/core-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java index b8ecfc3dc017..68e8d2500314 100644 --- a/platform/core-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/editor/impl/IntervalTreeImpl.java @@ -23,6 +23,7 @@ import com.intellij.util.IncorrectOperationException; import com.intellij.util.Processor; import com.intellij.util.SmartList; import com.intellij.util.WalkingState; +import com.intellij.util.concurrency.AtomicFieldUpdater; import gnu.trove.TLongHashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -32,7 +33,6 @@ import java.lang.ref.WeakReference; import java.util.ConcurrentModificationException; import java.util.List; import java.util.NoSuchElementException; -import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -295,14 +295,14 @@ public abstract class IntervalTreeImpl extends RedBla } /** - * packing/unpacking cachedDeltaUpToRoot field parts - * Bits layout: - * XXXXXXXXNMMMMMMMM where - * XXXXXXXX - 31bit int containing cached delta up to root - * N - 1bit flag. if set then all deltas up to root are null - * MMMMMMMM - 32bit int containing this node modification count + * packing/unpacking cachedDeltaUpToRoot field parts + * Bits layout: + * XXXXXXXXNMMMMMMMM where + * XXXXXXXX - 31bit int containing cached delta up to root + * N - 1bit flag. if set then all deltas up to root are null + * MMMMMMMM - 32bit int containing this node modification count */ - private static final AtomicLongFieldUpdater cachedDeltaUpdater = AtomicLongFieldUpdater.newUpdater(IntervalNode.class, "cachedDeltaUpToRoot"); + private static final AtomicFieldUpdater cachedDeltaUpdater = AtomicFieldUpdater.forLongFieldIn(IntervalNode.class); private void setCachedValues(int deltaUpToRoot, boolean allDeltaUpToRootAreNull, int modCount) { cachedDeltaUpToRoot = packValues(deltaUpToRoot, allDeltaUpToRootAreNull, modCount); @@ -316,7 +316,7 @@ public abstract class IntervalTreeImpl extends RedBla if (myIntervalTree.modCount != treeModCount) return false; long newValue = packValues(deltaUpToRoot, allDeltasUpAreNull, treeModCount); long oldValue = cachedDeltaUpToRoot; - return cachedDeltaUpdater.compareAndSet(this, oldValue, newValue); + return cachedDeltaUpdater.compareAndSetLong(this, oldValue, newValue); } private static boolean allDeltasUpAreNull(long packedOffsets) { diff --git a/platform/util/src/com/intellij/util/concurrency/AtomicFieldUpdater.java b/platform/util/src/com/intellij/util/concurrency/AtomicFieldUpdater.java index a57e601cf2d9..9da8aca1b231 100644 --- a/platform/util/src/com/intellij/util/concurrency/AtomicFieldUpdater.java +++ b/platform/util/src/com/intellij/util/concurrency/AtomicFieldUpdater.java @@ -27,8 +27,6 @@ import sun.misc.Unsafe; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import java.util.concurrent.atomic.AtomicLongFieldUpdater; /** * Utility class similar to {@link java.util.concurrent.atomic.AtomicReferenceFieldUpdater} except: @@ -69,15 +67,13 @@ public class AtomicFieldUpdater { } @NotNull - public static AtomicLongFieldUpdater forLongFieldIn(@NotNull Class ownerClass) { - Field field = getTheOnlyVolatileFieldOfClass(ownerClass, long.class); - return AtomicLongFieldUpdater.newUpdater(ownerClass, field.getName()); + public static AtomicFieldUpdater forLongFieldIn(@NotNull Class ownerClass) { + return new AtomicFieldUpdater(ownerClass, long.class); } @NotNull - public static AtomicIntegerFieldUpdater forIntFieldIn(@NotNull Class ownerClass) { - Field field = getTheOnlyVolatileFieldOfClass(ownerClass, int.class); - return AtomicIntegerFieldUpdater.newUpdater(ownerClass, field.getName()); + public static AtomicFieldUpdater forIntFieldIn(@NotNull Class ownerClass) { + return new AtomicFieldUpdater(ownerClass, int.class); } private AtomicFieldUpdater(@NotNull Class ownerClass, @NotNull Class fieldType) { @@ -120,6 +116,10 @@ public class AtomicFieldUpdater { return unsafe.compareAndSwapLong(owner, offset, expected, newValue); } + public boolean compareAndSetInt(@NotNull T owner, int expected, int newValue) { + return unsafe.compareAndSwapInt(owner, offset, expected, newValue); + } + public void set(@NotNull T owner, V newValue) { unsafe.putObjectVolatile(owner, offset, newValue); } From 9f294e7c7fbdc4b9f0eb85ce0f7da841aa921761 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 25 Jun 2014 13:44:23 +0200 Subject: [PATCH 23/30] notnull --- .../backend/src/org/jetbrains/debugger/ScriptManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptManager.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptManager.java index 76157af7b808..39d5def0934f 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptManager.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/ScriptManager.java @@ -25,6 +25,7 @@ public interface ScriptManager { * * @param newSource new text of script */ + @NotNull AsyncResult setSourceOnRemote(@NotNull Script script, @NotNull String newSource, boolean preview); void forEachScript(@NotNull Processor