From 99dab771cd3db1c9e7fe3651c7b819c84600a73a Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Fri, 21 Feb 2014 16:47:46 +0400 Subject: [PATCH 01/75] IDEA-80056 Column selection mode improvement completion behaviour improvements: * insert generated text into all carets' positions * apply post-completion actions (like parenthesis insertion) to all carets --- .../normal/MultiCaretSingleItemInsertion.java | 4 +++ .../MultiCaretSingleItemInsertion_after.java | 4 +++ .../normal/MulticaretMethodWithParen.java | 4 +++ .../MulticaretMethodWithParen_after.java | 4 +++ .../completion/NormalCompletionTest.groovy | 36 ++++++++++++++++++- .../completion/CodeCompletionHandlerBase.java | 25 +++++++++---- .../codeInsight/lookup/impl/LookupImpl.java | 33 +++++++++-------- 7 files changed, 88 insertions(+), 22 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/completion/normal/MultiCaretSingleItemInsertion.java create mode 100644 java/java-tests/testData/codeInsight/completion/normal/MultiCaretSingleItemInsertion_after.java create mode 100644 java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen.java create mode 100644 java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen_after.java diff --git a/java/java-tests/testData/codeInsight/completion/normal/MultiCaretSingleItemInsertion.java b/java/java-tests/testData/codeInsight/completion/normal/MultiCaretSingleItemInsertion.java new file mode 100644 index 000000000000..6c7981f4fbc6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/MultiCaretSingleItemInsertion.java @@ -0,0 +1,4 @@ +class Foo {{ + ret; + ret; +}} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normal/MultiCaretSingleItemInsertion_after.java b/java/java-tests/testData/codeInsight/completion/normal/MultiCaretSingleItemInsertion_after.java new file mode 100644 index 000000000000..bed450b802e2 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/MultiCaretSingleItemInsertion_after.java @@ -0,0 +1,4 @@ +class Foo {{ + return; + return; +}} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen.java b/java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen.java new file mode 100644 index 000000000000..a4bddd9cb46b --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen.java @@ -0,0 +1,4 @@ +class Foo {{ + System.out.ap + System.out.ap +}} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen_after.java b/java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen_after.java new file mode 100644 index 000000000000..46acfade83b6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/MulticaretMethodWithParen_after.java @@ -0,0 +1,4 @@ +class Foo {{ + System.out.append() + System.out.append() +}} \ No newline at end of file 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 a511209092e9..fe527575da2b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiMethod import com.intellij.psi.codeStyle.CodeStyleSettingsManager import com.intellij.psi.codeStyle.CommonCodeStyleSettings +import com.intellij.testFramework.EditorTestUtil public class NormalCompletionTest extends LightFixtureCompletionTestCase { @Override @@ -874,6 +875,16 @@ public class ListUtils { doAntiTest() } + private void doMultiCaretTest() throws Exception { + EditorTestUtil.enableMultipleCarets() + try { + doTest() + } + finally { + EditorTestUtil.disableMultipleCarets() + } + } + private void doTest() throws Exception { configure() checkResult(); @@ -1365,6 +1376,29 @@ class Foo {{ }}''' } + public void testMulticaretSingleItemInsertion() { + doMultiCaretTest() + } + + public void testMulticaretMethodWithParen() { + doMultiCaretTest() + } + + public void testMulticaretTyping() { + EditorTestUtil.enableMultipleCarets() + try { + configure() + assert lookup + type('p') + assert lookup + type('\n') + checkResult() + } + 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/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java index 1aa29cc14ee3..aa32ce31a646 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.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. @@ -574,11 +574,11 @@ public class CodeCompletionHandlerBase { } - private static CompletionAssertions.WatchingInsertionContext insertItemHonorBlockSelection(CompletionProgressIndicator indicator, - LookupElement item, - char completionChar, - List items, - CompletionLookupArranger.StatisticsUpdate update) { + private static CompletionAssertions.WatchingInsertionContext insertItemHonorBlockSelection(final CompletionProgressIndicator indicator, + final LookupElement item, + final char completionChar, + final List items, + final CompletionLookupArranger.StatisticsUpdate update) { final Editor editor = indicator.getEditor(); final int caretOffset = editor.getCaretModel().getOffset(); @@ -586,6 +586,7 @@ public class CodeCompletionHandlerBase { if (idEndOffset < 0) { idEndOffset = CompletionInitializationContext.calcDefaultIdentifierEnd(editor, caretOffset); } + final int idEndOffsetDelta = idEndOffset - caretOffset; CompletionAssertions.WatchingInsertionContext context = null; if (editor.getSelectionModel().hasBlockSelection() && editor.getSelectionModel().getBlockSelectionEnds().length > 0) { @@ -622,7 +623,17 @@ public class CodeCompletionHandlerBase { } } else { - context = insertItem(indicator, item, completionChar, items, update, editor, caretOffset, idEndOffset); + final Ref contextRef = new Ref(); + editor.getCaretModel().runForEachCaret(new CaretAction() { + @Override + public void perform(Caret caret) { + CompletionAssertions.WatchingInsertionContext currentContext = insertItem(indicator, item, completionChar, items, update, editor, caret.getOffset(), caret.getOffset() + idEndOffsetDelta); + if (caret == editor.getCaretModel().getPrimaryCaret()) { + contextRef.set(currentContext); + } + } + }); + context = contextRef.get(); } return context; } 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 b92155067b27..26115d4b307e 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 @@ -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. @@ -678,9 +678,9 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable } private void insertLookupString(LookupElement item, final int prefix) { - Document document = myEditor.getDocument(); + final Document document = myEditor.getDocument(); - String lookupString = getCaseCorrectedLookupString(item); + final String lookupString = getCaseCorrectedLookupString(item); if (myEditor.getSelectionModel().hasBlockSelection()) { LogicalPosition blockStart = myEditor.getSelectionModel().getBlockStart(); @@ -710,20 +710,25 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable myEditor.getSelectionModel().setBlockSelection(start, end); myEditor.getCaretModel().moveToLogicalPosition(new LogicalPosition(caretLine, end.column)); } else { - EditorModificationUtil.deleteSelectedText(myEditor); - final int caretOffset = myEditor.getCaretModel().getOffset(); - int lookupStart = caretOffset - prefix; + myEditor.getCaretModel().runForEachCaret(new CaretAction() { + @Override + public void perform(Caret caret) { + EditorModificationUtil.deleteSelectedText(myEditor); + final int caretOffset = myEditor.getCaretModel().getOffset(); + int lookupStart = caretOffset - prefix; - int len = document.getTextLength(); - LOG.assertTrue(lookupStart >= 0 && lookupStart <= len, - "ls: " + lookupStart + " caret: " + caretOffset + " prefix:" + prefix + " doc: " + len); - LOG.assertTrue(caretOffset >= 0 && caretOffset <= len, "co: " + caretOffset + " doc: " + len); + int len = document.getTextLength(); + LOG.assertTrue(lookupStart >= 0 && lookupStart <= len, + "ls: " + lookupStart + " caret: " + caretOffset + " prefix:" + prefix + " doc: " + len); + LOG.assertTrue(caretOffset >= 0 && caretOffset <= len, "co: " + caretOffset + " doc: " + len); - document.replaceString(lookupStart, caretOffset, lookupString); + document.replaceString(lookupStart, caretOffset, lookupString); - int offset = lookupStart + lookupString.length(); - myEditor.getCaretModel().moveToOffset(offset); - myEditor.getSelectionModel().removeSelection(); + int offset = lookupStart + lookupString.length(); + myEditor.getCaretModel().moveToOffset(offset); + myEditor.getSelectionModel().removeSelection(); + } + }); } myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); From 0ea4a4bdef88a74fa27b6278145301f2d1a842c2 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Fri, 21 Feb 2014 16:49:47 +0400 Subject: [PATCH 02/75] IDEA-80056 Column selection mode improvement completion behaviour improvements: * insert generated text into all carets' positions * apply post-completion actions (like parenthesis insertion) to all carets --- .../completion/NormalCompletionTest.groovy | 15 --------------- 1 file changed, 15 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 fe527575da2b..00a635d96386 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -1384,21 +1384,6 @@ class Foo {{ doMultiCaretTest() } - public void testMulticaretTyping() { - EditorTestUtil.enableMultipleCarets() - try { - configure() - assert lookup - type('p') - assert lookup - type('\n') - checkResult() - } - finally { - EditorTestUtil.disableMultipleCarets() - } - } - public void "test complete lowercase class name"() { myFixture.addClass("package foo; public class myClass {}") myFixture.configureByText "a.java", """ From 6033db3055ab1e5735c0553e63921885e87de0bf Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 21 Feb 2014 12:19:25 +0100 Subject: [PATCH 03/75] eliminate WebBrowserBase --- .../ide/browsers/ConfigurableWebBrowser.java | 39 ++++++++++- .../intellij/ide/browsers/WebBrowserBase.java | 69 ------------------- 2 files changed, 37 insertions(+), 71 deletions(-) delete mode 100644 xml/impl/src/com/intellij/ide/browsers/WebBrowserBase.java diff --git a/xml/impl/src/com/intellij/ide/browsers/ConfigurableWebBrowser.java b/xml/impl/src/com/intellij/ide/browsers/ConfigurableWebBrowser.java index d15c59d28581..7cae777e4163 100644 --- a/xml/impl/src/com/intellij/ide/browsers/ConfigurableWebBrowser.java +++ b/xml/impl/src/com/intellij/ide/browsers/ConfigurableWebBrowser.java @@ -1,6 +1,7 @@ package com.intellij.ide.browsers; import com.intellij.icons.AllIcons; +import com.intellij.ide.IdeBundle; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.PathUtil; @@ -10,7 +11,10 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.UUID; -final class ConfigurableWebBrowser extends WebBrowserBase { +final class ConfigurableWebBrowser extends WebBrowser { + private final UUID id; + @NotNull private BrowserFamily family; + @NotNull private String name; private boolean active; private String path; @@ -31,7 +35,9 @@ final class ConfigurableWebBrowser extends WebBrowserBase { @Nullable String path, boolean active, @Nullable BrowserSpecificSettings specificSettings) { - super(id, family, name); + this.id = id; + this.family = family; + this.name = name; this.path = StringUtil.nullize(path); this.active = active; @@ -120,4 +126,33 @@ final class ConfigurableWebBrowser extends WebBrowserBase { public int hashCode() { return getId().hashCode(); } + + @Override + @NotNull + public String getName() { + return name; + } + + @Override + @NotNull + public final UUID getId() { + return id; + } + + @Override + @NotNull + public BrowserFamily getFamily() { + return family; + } + + @Override + @NotNull + public String getBrowserNotFoundMessage() { + return IdeBundle.message("error.0.browser.path.not.specified", getName()); + } + + @Override + public String toString() { + return getName() + " (" + getPath() + ")"; + } } \ No newline at end of file diff --git a/xml/impl/src/com/intellij/ide/browsers/WebBrowserBase.java b/xml/impl/src/com/intellij/ide/browsers/WebBrowserBase.java deleted file mode 100644 index af7ff95ec08e..000000000000 --- a/xml/impl/src/com/intellij/ide/browsers/WebBrowserBase.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.browsers; - -import com.intellij.ide.IdeBundle; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.UUID; - -public abstract class WebBrowserBase extends WebBrowser { - protected @NotNull BrowserFamily family; - protected @NotNull String name; - private final UUID id; - - protected WebBrowserBase(@NotNull UUID id, @NotNull BrowserFamily family, @NotNull String name) { - this.id = id; - this.family = family; - this.name = name; - } - - @Override - @NotNull - public String getName() { - return name; - } - - @Override - @NotNull - public final UUID getId() { - return id; - } - - @Override - @NotNull - public BrowserFamily getFamily() { - return family; - } - - @Override - @NotNull - public String getBrowserNotFoundMessage() { - return IdeBundle.message("error.0.browser.path.not.specified", getName()); - } - - @Override - @Nullable - public BrowserSpecificSettings getSpecificSettings() { - return null; - } - - @Override - public String toString() { - return getName() + " (" + getPath() + ")"; - } -} \ No newline at end of file From 78ef38e24eb35bb97679c3ec2ebbad676db1ef92 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 21 Feb 2014 12:53:17 +0100 Subject: [PATCH 04/75] cleanup --- .../breakpoints/XLineBreakpointManager.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.java index 138052e88714..98bb91ed5219 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.java @@ -38,7 +38,10 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.*; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileEvent; +import com.intellij.openapi.vfs.VirtualFileManager; +import com.intellij.openapi.vfs.VirtualFileUrlChangeAdapter; import com.intellij.psi.PsiDocumentManager; import com.intellij.util.containers.BidirectionalMap; import com.intellij.util.ui.update.MergingUpdateQueue; @@ -80,6 +83,7 @@ public class XLineBreakpointManager { final MyDependentBreakpointListener myDependentBreakpointListener = new MyDependentBreakpointListener(); myDependentBreakpointManager.addListener(myDependentBreakpointListener); Disposer.register(project, new Disposable() { + @Override public void dispose() { myDependentBreakpointManager.removeListener(myDependentBreakpointListener); } @@ -127,6 +131,7 @@ public class XLineBreakpointManager { if (myProject.isDefault()) return; Runnable runnable = new DumbAwareRunnable() { + @Override public void run() { for (XLineBreakpointImpl breakpoint : myBreakpoints.keySet()) { breakpoint.updateUI(); @@ -177,7 +182,8 @@ public class XLineBreakpointManager { private void removeBreakpoints(final List> toRemove) { new WriteAction() { - protected void run(final Result result) { + @Override + protected void run(@NotNull final Result result) { for (XBreakpoint breakpoint : toRemove) { XDebuggerManager.getInstance(myProject).getBreakpointManager().removeBreakpoint(breakpoint); } @@ -201,6 +207,7 @@ public class XLineBreakpointManager { public void queueBreakpointUpdate(@NotNull final XLineBreakpointImpl breakpoint) { myBreakpointsUpdateQueue.queue(new Update(breakpoint) { + @Override public void run() { breakpoint.updateUI(); } @@ -209,6 +216,7 @@ public class XLineBreakpointManager { public void queueAllBreakpointsUpdate() { myBreakpointsUpdateQueue.queue(new Update("all breakpoints") { + @Override public void run() { for (XLineBreakpointImpl breakpoint : myBreakpoints.keySet()) { breakpoint.updateUI(); @@ -218,11 +226,13 @@ public class XLineBreakpointManager { } private class MyDocumentListener extends DocumentAdapter { + @Override public void documentChanged(final DocumentEvent e) { final Document document = e.getDocument(); Collection breakpoints = myBreakpoints.getKeysByValue(document); if (breakpoints != null && !breakpoints.isEmpty()) { myBreakpointsUpdateQueue.queue(new Update(document) { + @Override public void run() { updateBreakpoints(document); } @@ -232,6 +242,7 @@ public class XLineBreakpointManager { } private class MyEditorMouseListener extends EditorMouseAdapter { + @Override public void mouseClicked(final EditorMouseEvent e) { final Editor editor = e.getEditor(); final MouseEvent mouseEvent = e.getMouseEvent(); @@ -245,12 +256,14 @@ public class XLineBreakpointManager { } PsiDocumentManager.getInstance(myProject).commitAndRunReadAction(new Runnable() { + @Override public void run() { final int line = editor.xyToLogicalPosition(mouseEvent.getPoint()).line; final Document document = editor.getDocument(); final VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (line >= 0 && line < document.getLineCount() && file != null) { ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override public void run() { if (!myProject.isDisposed() && myProject.isInitialized() && file.isValid()) { @@ -274,10 +287,12 @@ public class XLineBreakpointManager { } private class MyDependentBreakpointListener implements XDependentBreakpointListener { + @Override public void dependencySet(final XBreakpoint slave, final XBreakpoint master) { queueBreakpointUpdate(slave); } + @Override public void dependencyCleared(final XBreakpoint breakpoint) { queueBreakpointUpdate(breakpoint); } From f97c3ae24d1dca4c76ea8fbb3edccf345a783a74 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 21 Feb 2014 12:57:50 +0100 Subject: [PATCH 05/75] nullability --- platform/util-rt/src/com/intellij/openapi/util/Comparing.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/util-rt/src/com/intellij/openapi/util/Comparing.java b/platform/util-rt/src/com/intellij/openapi/util/Comparing.java index 7efc489dfc11..6813404f0539 100644 --- a/platform/util-rt/src/com/intellij/openapi/util/Comparing.java +++ b/platform/util-rt/src/com/intellij/openapi/util/Comparing.java @@ -90,7 +90,7 @@ public class Comparing { } } - public static boolean strEqual(String arg1, String arg2){ + public static boolean strEqual(@Nullable String arg1, @Nullable String arg2){ return strEqual(arg1, arg2, true); } From 09954a9e59a86863fb8c9fa05ae4b32163004434 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 21 Feb 2014 12:59:55 +0100 Subject: [PATCH 06/75] nodejs doesn't report actual locations after set breakpoint --- .../intellij/xdebugger/impl/XDebugSessionImpl.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java index bb07eea52682..ea407a2cfcd4 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java @@ -45,6 +45,7 @@ import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.ToolWindowId; import com.intellij.ui.AppUIUtil; @@ -601,14 +602,15 @@ public class XDebugSessionImpl implements XDebugSession { CustomizedBreakpointPresentation presentation; synchronized (myRegisteredBreakpoints) { presentation = myRegisteredBreakpoints.get(breakpoint); - if (presentation != null) { - presentation.setErrorMessage(errorMessage); - presentation.setIcon(icon); + if (presentation == null || + (Comparing.equal(presentation.getIcon(), icon) && Comparing.strEqual(presentation.getErrorMessage(), errorMessage))) { + return; } + + presentation.setErrorMessage(errorMessage); + presentation.setIcon(icon); } - if (presentation != null) { - myDebuggerManager.getBreakpointManager().getLineBreakpointManager().queueBreakpointUpdate((XLineBreakpointImpl)breakpoint); - } + myDebuggerManager.getBreakpointManager().getLineBreakpointManager().queueBreakpointUpdate((XLineBreakpointImpl)breakpoint); } @Override From 4715a4215e81023e53c267bf73bbb0afc780a26b Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 21 Feb 2014 14:07:25 +0100 Subject: [PATCH 07/75] add file validation on show execution point --- .../src/com/intellij/xdebugger/impl/XSourcePositionImpl.java | 2 +- .../intellij/xdebugger/impl/ui/ExecutionPointHighlighter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XSourcePositionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XSourcePositionImpl.java index 579798caec5d..e5e511bc1f13 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XSourcePositionImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XSourcePositionImpl.java @@ -85,7 +85,7 @@ public class XSourcePositionImpl implements XSourcePosition { offset = -1; } else { - Document document = FileDocumentManager.getInstance().getDocument(file); + Document document = file.isValid() ? FileDocumentManager.getInstance().getDocument(file) : null; if (document == null) { return null; } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/ExecutionPointHighlighter.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/ExecutionPointHighlighter.java index d34ebcd9ad43..47485e568a14 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/ExecutionPointHighlighter.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/ExecutionPointHighlighter.java @@ -102,7 +102,7 @@ public class ExecutionPointHighlighter { mySourcePosition = position; myOpenFileDescriptor = XSourcePositionImpl.createOpenFileDescriptor(myProject, mySourcePosition); - myEditor = FileEditorManager.getInstance(myProject).openTextEditor(myOpenFileDescriptor, false); + myEditor = myOpenFileDescriptor.getFile().isValid() ? FileEditorManager.getInstance(myProject).openTextEditor(myOpenFileDescriptor, false) : null; myUseSelection = useSelection; myGutterIconRenderer = renderer; if (myEditor != null) { From ca75131f064dfed685dffaade0f1e39e464f4df6 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 18 Feb 2014 14:11:35 +0400 Subject: [PATCH 08/75] NPE --- .../com/intellij/usages/impl/UsageViewTreeCellRenderer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewTreeCellRenderer.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewTreeCellRenderer.java index a4f6e9dd5779..d6edbbb655bc 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewTreeCellRenderer.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewTreeCellRenderer.java @@ -238,14 +238,14 @@ class UsageViewTreeCellRenderer extends ColoredTreeCellRenderer { public RowLocation isRowVisible(int row, @NotNull Rectangle visibleRect) { Dimension pref; if (cachedPreferredSize == null) { - pref = cachedPreferredSize = getPreferredSize(); + cachedPreferredSize = pref = getPreferredSize(); } else { pref = cachedPreferredSize; } pref.width = Math.max(visibleRect.width, pref.width); myRowBoundsCalled = true; - final JTree tree = getTree(); + JTree tree = getTree(); final Rectangle bounds = tree == null ? null : tree.getRowBounds(row); myRowBoundsCalled = false; int y = bounds == null ? 0 : bounds.y; From 4ef4bad82700f6281839db71d97d30a25558f36a Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 18 Feb 2014 18:56:52 +0400 Subject: [PATCH 09/75] moved to core --- .../src/com/intellij/ui/SimpleTextAttributes.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename platform/{platform-api => core-api}/src/com/intellij/ui/SimpleTextAttributes.java (99%) diff --git a/platform/platform-api/src/com/intellij/ui/SimpleTextAttributes.java b/platform/core-api/src/com/intellij/ui/SimpleTextAttributes.java similarity index 99% rename from platform/platform-api/src/com/intellij/ui/SimpleTextAttributes.java rename to platform/core-api/src/com/intellij/ui/SimpleTextAttributes.java index a77827b01aec..c2005c3e1a99 100644 --- a/platform/platform-api/src/com/intellij/ui/SimpleTextAttributes.java +++ b/platform/core-api/src/com/intellij/ui/SimpleTextAttributes.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 745381bcfb8a47e4512a12802f1e0dea4e442ef6 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 19 Feb 2014 14:27:11 +0400 Subject: [PATCH 10/75] NotNull --- .../impl/java/AnonymousClassesSorter.java | 3 +- .../JavaAnonymousClassesNodeProvider.java | 5 +- .../JavaInheritedMembersNodeProvider.java | 6 ++- .../structureView/impl/java/KindSorter.java | 3 +- .../impl/java/PropertiesGrouper.java | 4 +- .../impl/java/PropertyGroup.java | 4 +- .../impl/java/PsiFieldTreeElement.java | 3 +- .../impl/java/PsiMethodTreeElement.java | 3 +- .../impl/java/SuperTypeGroup.java | 5 +- .../impl/java/SuperTypesGrouper.java | 4 +- .../impl/java/VisibilitySorter.java | 4 +- .../openapi/editor/colors/ColorKey.java | 25 +++++----- .../TextEditorBasedStructureViewModel.java | 8 ++-- .../TreeBasedStructureViewBuilder.java | 7 ++- .../ide/actions/ViewStructureAction.java | 23 +++++---- .../ide/commander/ProjectListBuilder.java | 4 +- .../impl/nodes/PsiTreeAnchorizer.java | 9 ++-- .../structureView/StructureViewFactoryEx.java | 8 ++-- .../impl/StructureViewElementWrapper.java | 4 +- .../impl/StructureViewFactoryImpl.java | 23 +++++---- .../impl/StructureViewModelWrapper.java | 10 ++-- .../TemplateLanguageStructureViewBuilder.java | 4 +- .../impl/common/PsiTreeElementBase.java | 4 +- .../StructureViewComponent.java | 48 +++++++------------ .../newStructureView/TreeActionWrapper.java | 5 +- .../newStructureView/TreeModelWrapper.java | 42 ++++++++-------- .../intellij/ide/todo/nodes/ToDoRootNode.java | 3 +- .../ide/util/FileStructureDialog.java | 23 ++++----- .../ide/util/StructureViewCompositeModel.java | 6 ++- .../smartTree/CachingChildrenTreeNode.java | 27 +++++++---- .../util/treeView/smartTree/GroupWrapper.java | 14 ++++-- .../smartTree/TreeElementWrapper.java | 19 ++++++-- .../structureView/StructureViewBuilder.java | 4 +- .../structureView/StructureViewFactory.java | 15 +++--- .../ide/structureView/StructureViewModel.java | 16 +++---- .../StructureViewTreeElement.java | 4 +- .../ide/util/treeView/AbstractTreeNode.java | 17 ++----- .../ide/util/treeView/AbstractTreeUi.java | 20 ++++---- .../util/treeView/smartTree/NodeProvider.java | 7 ++- .../util/treeView/smartTree/SorterUtil.java | 17 ++++--- .../util/treeView/smartTree/TreeModel.java | 14 ++++-- .../openapi/ide/CopyPasteManager.java | 7 +-- .../openapi/vcs/FileStatusListener.java | 4 +- .../openapi/vcs/FileStatusManager.java | 14 +++--- .../com/intellij/ide/CopyPasteManagerEx.java | 7 +-- .../intellij/structureView/TestGrouper.java | 19 +++++++- .../intellij/structureView/TestTreeModel.java | 25 ++++++++-- .../intellij/openapi/util/MultiValuesMap.java | 18 ++++--- .../src/com/intellij/util/ReflectionUtil.java | 2 +- ...pertiesGroupingStructureViewComponent.java | 4 +- ...esourceBundleFileStructureViewElement.java | 5 +- ...rceBundlePropertyStructureViewElement.java | 14 +++++- .../ResourceBundleStructureViewModel.java | 10 ++-- .../structureView/GroupByWordPrefixes.java | 9 +++- .../PropertiesFileStructureViewElement.java | 3 +- .../PropertiesFileStructureViewModel.java | 3 +- .../structureView/PropertiesPrefixGroup.java | 4 +- ...PropertiesStructureViewBuilderFactory.java | 4 +- .../PropertiesStructureViewElement.java | 5 +- .../RestStructureViewElement.java | 5 +- .../structureView/RestStructureViewModel.java | 4 +- .../structureView/PyStructureViewElement.java | 5 +- .../structureView/PyStructureViewModel.java | 4 +- .../structure/DomStructureTreeElement.java | 4 +- .../structure/DomStructureViewBuilder.java | 6 +-- .../Html5SectionsNodeProvider.java | 5 +- .../HtmlStructureViewTreeModel.java | 3 +- 67 files changed, 404 insertions(+), 263 deletions(-) diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java index cefb5d9f280c..a6412f050460 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ public class AnonymousClassesSorter implements Sorter { } }; + @NotNull @Override public Comparator getComparator() { return myComparator; diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java index 65bc73d12b8a..557c0fe716c5 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,8 +45,9 @@ public class JavaAnonymousClassesNodeProvider implements FileStructureNodeProvid public static final String ID = "SHOW_ANONYMOUS"; public static final String JAVA_ANONYMOUS_PROPERTY_NAME = "java.anonymous.provider"; + @NotNull @Override - public Collection provideNodes(TreeElement node) { + public Collection provideNodes(@NotNull TreeElement node) { if (node instanceof PsiMethodTreeElement || node instanceof PsiFieldTreeElement || node instanceof ClassInitializerTreeElement) { final PsiElement el = ((PsiTreeElementBase)node).getElement(); for (AnonymousElementProvider provider : Extensions.getExtensions(AnonymousElementProvider.EP_NAME)) { diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java index e8a4cbbbf481..d17f9bb47842 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.intellij.ide.util.InheritedMembersNodeProvider; import com.intellij.ide.util.treeView.smartTree.TreeElement; import com.intellij.psi.*; import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; import java.util.*; @@ -27,8 +28,9 @@ import java.util.*; * @author Konstantin Bulenkov */ public class JavaInheritedMembersNodeProvider extends InheritedMembersNodeProvider { + @NotNull @Override - public Collection provideNodes(TreeElement node) { + public Collection provideNodes(@NotNull TreeElement node) { if (node instanceof JavaClassTreeElement) { final PsiClass aClass = ((JavaClassTreeElement)node).getValue(); Collection inherited = new LinkedHashSet(); diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.java index 18cc5972d29a..f1cdf3e6ccb4 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.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. @@ -65,6 +65,7 @@ public class KindSorter implements Sorter { } }; + @NotNull public Comparator getComparator() { return COMPARATOR; } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java index b948ac948f75..5333306d7d24 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.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. @@ -33,7 +33,7 @@ public class PropertiesGrouper implements Grouper{ @NonNls public static final String ID = "SHOW_PROPERTIES"; @NotNull - public Collection group(final AbstractTreeNode parent, Collection children) { + public Collection group(@NotNull final AbstractTreeNode parent, @NotNull Collection children) { if (parent.getValue() instanceof PropertyGroup) return Collections.emptyList(); Map result = new THashMap(); for (TreeElement o : children) { diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java index 90e0c9eecab8..d66464e2af23 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertyGroup.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. @@ -90,10 +90,12 @@ public class PropertyGroup implements Group, ColoredItemPresentation, AccessLeve return null; } + @NotNull public Collection getChildren() { return myChildren; } + @NotNull public ItemPresentation getPresentation() { return this; } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java index 931750522863..1661596af0cf 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ public class PsiFieldTreeElement extends JavaClassTreeElementBase impl return getElement(); } + @NotNull public String getAlphaSortKey() { final PsiField field = getElement(); if (field != null) { diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java index 2f186db66a39..c1afbee6ada4 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.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. @@ -127,6 +127,7 @@ public class PsiMethodTreeElement extends JavaClassTreeElementBase im return getElement(); } + @NotNull @Override public String getAlphaSortKey() { final PsiMethod method = getElement(); diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java index ee713b880078..c2e2d58bcc12 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.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. @@ -25,6 +25,7 @@ import com.intellij.psi.PsiModifierList; import com.intellij.psi.SmartPointerManager; import com.intellij.psi.SmartPsiElementPointer; import com.intellij.psi.util.PsiUtil; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -47,6 +48,7 @@ public class SuperTypeGroup implements Group, ItemPresentation, AccessLevelProvi mySuperClassPointer = SmartPointerManager.getInstance(superClass.getProject()).createSmartPsiElementPointer(superClass); } + @NotNull public Collection getChildren() { return myChildren; } @@ -56,6 +58,7 @@ public class SuperTypeGroup implements Group, ItemPresentation, AccessLevelProvi return (PsiClass)mySuperClassPointer.getElement(); } + @NotNull public ItemPresentation getPresentation() { return this; } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java index 0f5a7589f6d6..cfa6d009293a 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.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. @@ -38,7 +38,7 @@ public class SuperTypesGrouper implements Grouper{ @NonNls public static final String ID = "SHOW_INTERFACES"; @NotNull - public Collection group(final AbstractTreeNode parent, Collection children) { + public Collection group(@NotNull final AbstractTreeNode parent, @NotNull Collection children) { if (isParentGrouped(parent)) return Collections.emptyList(); Map groups = new THashMap(); diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java index e5ce3310187f..b9f149261c6e 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.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. @@ -30,6 +30,7 @@ public class VisibilitySorter implements Sorter{ public static final Sorter INSTANCE = new VisibilitySorter(); private static final ActionPresentation PRESENTATION = new ActionPresentation() { + @NotNull public String getText() { return IdeBundle.message("action.structureview.sort.by.visibility"); } @@ -44,6 +45,7 @@ public class VisibilitySorter implements Sorter{ }; @NonNls public static final String ID = "VISIBILITY_SORTER"; + @NotNull public Comparator getComparator() { return VisibilityComparator.IMSTANCE; } diff --git a/platform/core-api/src/com/intellij/openapi/editor/colors/ColorKey.java b/platform/core-api/src/com/intellij/openapi/editor/colors/ColorKey.java index d868b99c8585..2c5a9d93cbef 100644 --- a/platform/core-api/src/com/intellij/openapi/editor/colors/ColorKey.java +++ b/platform/core-api/src/com/intellij/openapi/editor/colors/ColorKey.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.intellij.openapi.editor.colors; import com.intellij.openapi.diagnostic.Logger; import com.intellij.ui.Gray; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import java.awt.*; import java.util.HashMap; @@ -31,7 +32,7 @@ public final class ColorKey implements Comparable { private Color myDefaultColor = NULL_COLOR; private static final Map ourRegistry = new HashMap(); - private ColorKey(String externalName) { + private ColorKey(@NotNull String externalName) { myExternalName = externalName; if (ourRegistry.containsKey(myExternalName)) { LOG.error("Key " + myExternalName + " already registered."); @@ -41,20 +42,23 @@ public final class ColorKey implements Comparable { } } - public static ColorKey find(String externalName) { + @NotNull + public static ColorKey find(@NotNull String externalName) { ColorKey key = ourRegistry.get(externalName); - return key != null ? key : new ColorKey(externalName); + return key == null ? new ColorKey(externalName) : key; } public String toString() { return myExternalName; } + @NotNull public String getExternalName() { return myExternalName; } - public int compareTo(ColorKey key) { + @Override + public int compareTo(@NotNull ColorKey key) { return myExternalName.compareTo(key.myExternalName); } @@ -72,15 +76,14 @@ public final class ColorKey implements Comparable { return myDefaultColor; } - public static ColorKey createColorKey(@NonNls String externalName) { + @NotNull + public static ColorKey createColorKey(@NonNls @NotNull String externalName) { return find(externalName); } - public static ColorKey createColorKey(@NonNls String externalName, Color defaultColor) { - ColorKey key = ourRegistry.get(externalName); - if (key == null) { - key = find(externalName); - } + @NotNull + public static ColorKey createColorKey(@NonNls @NotNull String externalName, Color defaultColor) { + ColorKey key = createColorKey(externalName); if (key.getDefaultColor() == null) { key.myDefaultColor = defaultColor; diff --git a/platform/lang-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java b/platform/lang-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java index 02d63de0e0de..17a8c21b2ec8 100644 --- a/platform/lang-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java +++ b/platform/lang-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java @@ -85,12 +85,12 @@ public abstract class TextEditorBasedStructureViewModel implements StructureView } @Override - public final void addEditorPositionListener(FileEditorPositionListener listener) { + public final void addEditorPositionListener(@NotNull FileEditorPositionListener listener) { myListeners.add(listener); } @Override - public final void removeEditorPositionListener(FileEditorPositionListener listener) { + public final void removeEditorPositionListener(@NotNull FileEditorPositionListener listener) { myListeners.remove(listener); } @@ -136,12 +136,12 @@ public abstract class TextEditorBasedStructureViewModel implements StructureView } @Override - public void addModelListener(ModelListener modelListener) { + public void addModelListener(@NotNull ModelListener modelListener) { } @Override - public void removeModelListener(ModelListener modelListener) { + public void removeModelListener(@NotNull ModelListener modelListener) { } diff --git a/platform/lang-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java b/platform/lang-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java index ec30047809be..987b28f7e3c4 100644 --- a/platform/lang-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java +++ b/platform/lang-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.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. @@ -33,8 +33,7 @@ import org.jetbrains.annotations.Nullable; * @see TextEditorBasedStructureViewModel * @see com.intellij.lang.LanguageStructureViewBuilder#getStructureViewBuilder(com.intellij.psi.PsiFile) */ -public abstract class - TreeBasedStructureViewBuilder implements StructureViewBuilder { +public abstract class TreeBasedStructureViewBuilder implements StructureViewBuilder { /** * @deprecated Use createStructureViewModel(Editor editor) */ @@ -60,7 +59,7 @@ public abstract class @Override @NotNull - public StructureView createStructureView(FileEditor fileEditor, Project project) { + public StructureView createStructureView(FileEditor fileEditor, @NotNull Project project) { final StructureViewModel model = createStructureViewModel(fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null); StructureView view = StructureViewFactory.getInstance(project).createStructureView(fileEditor, model, project, isRootNodeShown()); Disposer.register(view, new Disposable() { diff --git a/platform/lang-impl/src/com/intellij/ide/actions/ViewStructureAction.java b/platform/lang-impl/src/com/intellij/ide/actions/ViewStructureAction.java index 3d48cd908530..3acb49a1b4ba 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/ViewStructureAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/ViewStructureAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,16 +56,16 @@ public class ViewStructureAction extends AnAction { final VirtualFile virtualFile; final Editor editor = e.getData(CommonDataKeys.EDITOR); - if (editor != null) { + if (editor == null) { + virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE); + } + else { PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (psiFile == null) return; virtualFile = psiFile.getVirtualFile(); } - else { - virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE); - } String title = virtualFile == null? fileEditor.getName() : virtualFile.getName(); FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.file.structure"); @@ -79,6 +79,7 @@ public class ViewStructureAction extends AnAction { popup.show(); } else { + assert editor != null; DialogWrapper dialog = createDialog(editor, project, navigatable, fileEditor); if (dialog == null) return; @@ -88,7 +89,10 @@ public class ViewStructureAction extends AnAction { } @Nullable - private static DialogWrapper createDialog(@Nullable Editor editor, @NotNull Project project, @Nullable Navigatable navigatable, @NotNull FileEditor fileEditor) { + private static DialogWrapper createDialog(@NotNull Editor editor, + @NotNull Project project, + @Nullable Navigatable navigatable, + @NotNull FileEditor fileEditor) { final StructureViewBuilder structureViewBuilder = fileEditor.getStructureViewBuilder(); if (structureViewBuilder == null) return null; StructureView structureView = structureViewBuilder.createStructureView(fileEditor, project); @@ -112,9 +116,10 @@ public class ViewStructureAction extends AnAction { return PLACE.equals(model.getPlace()); } - private static FileStructureDialog createStructureViewBasedDialog(StructureViewModel structureViewModel, - Editor editor, - Project project, + @NotNull + private static FileStructureDialog createStructureViewBasedDialog(@NotNull StructureViewModel structureViewModel, + @NotNull Editor editor, + @NotNull Project project, Navigatable navigatable, @NotNull Disposable alternativeDisposable) { return new FileStructureDialog(structureViewModel, editor, project, navigatable, alternativeDisposable, true); diff --git a/platform/lang-impl/src/com/intellij/ide/commander/ProjectListBuilder.java b/platform/lang-impl/src/com/intellij/ide/commander/ProjectListBuilder.java index bc4064a3fb6d..0591a5014437 100644 --- a/platform/lang-impl/src/com/intellij/ide/commander/ProjectListBuilder.java +++ b/platform/lang-impl/src/com/intellij/ide/commander/ProjectListBuilder.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. @@ -216,7 +216,7 @@ public class ProjectListBuilder extends AbstractListBuilder { } @Override - public void fileStatusChanged(final VirtualFile vFile) { + public void fileStatusChanged(@NotNull final VirtualFile vFile) { final PsiManager manager = PsiManager.getInstance(myProject); if (vFile.isDirectory()) { diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiTreeAnchorizer.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiTreeAnchorizer.java index 809c41cb9bf0..ab954007b0d3 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiTreeAnchorizer.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiTreeAnchorizer.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. @@ -23,13 +23,13 @@ import com.intellij.openapi.util.Key; import com.intellij.psi.PsiElement; import com.intellij.psi.SmartPointerManager; import com.intellij.psi.SmartPsiElementPointer; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * @author peter */ public class PsiTreeAnchorizer extends TreeAnchorizer { - private static final Key PSI_ANCHORIZER_POINTER = Key.create("PSI_ANCHORIZER_POINTER"); @Override @@ -47,7 +47,8 @@ public class PsiTreeAnchorizer extends TreeAnchorizer { if (pointer == null || pointer.myPointer.getElement() != psiElement) { Project project = psiElement.getProject(); - pointer = new SmartPointerWrapper(SmartPointerManager.getInstance(project).createSmartPsiElementPointer(psiElement)); + SmartPsiElementPointer psiElementPointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(psiElement); + pointer = new SmartPointerWrapper(psiElementPointer); psiElement.putUserData(PSI_ANCHORIZER_POINTER, pointer); } return pointer; @@ -74,7 +75,7 @@ public class PsiTreeAnchorizer extends TreeAnchorizer { private static class SmartPointerWrapper { private final SmartPsiElementPointer myPointer; - private SmartPointerWrapper(SmartPsiElementPointer pointer) { + private SmartPointerWrapper(@NotNull SmartPsiElementPointer pointer) { myPointer = pointer; } diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/StructureViewFactoryEx.java b/platform/lang-impl/src/com/intellij/ide/structureView/StructureViewFactoryEx.java index dd371e72ed63..ceb4fa72ca14 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/StructureViewFactoryEx.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/StructureViewFactoryEx.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.intellij.ide.structureView; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collection; @@ -30,7 +31,8 @@ public abstract class StructureViewFactoryEx extends StructureViewFactory { @Nullable public abstract StructureViewWrapper getStructureViewWrapper(); - public abstract Collection getAllExtensions(Class type); + @NotNull + public abstract Collection getAllExtensions(@NotNull Class type); public abstract void setActiveAction(final String name, final boolean state); @@ -40,5 +42,5 @@ public abstract class StructureViewFactoryEx extends StructureViewFactory { return (StructureViewFactoryEx)getInstance(project); } - public abstract void runWhenInitialized(Runnable runnable); + public abstract void runWhenInitialized(@NotNull Runnable runnable); } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewElementWrapper.java b/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewElementWrapper.java index 55f09ca297d8..63f77962fced 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewElementWrapper.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewElementWrapper.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. @@ -51,6 +51,7 @@ public class StructureViewElementWrapper implements Struct return (V)myTreeElement.getValue(); } + @NotNull @Override public StructureViewTreeElement[] getChildren() { TreeElement[] baseChildren = myTreeElement.getChildren(); @@ -63,6 +64,7 @@ public class StructureViewElementWrapper implements Struct return result.toArray(new StructureViewTreeElement[result.size()]); } + @NotNull @Override public ItemPresentation getPresentation() { return myTreeElement.getPresentation(); diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewFactoryImpl.java b/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewFactoryImpl.java index d49da8097bfc..8955f0769922 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewFactoryImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewFactoryImpl.java @@ -106,8 +106,9 @@ public final class StructureViewFactoryImpl extends StructureViewFactoryEx imple } } + @NotNull @Override - public Collection getAllExtensions(Class type) { + public Collection getAllExtensions(@NotNull Class type) { Collection result = myImplExtensions.get(type); if (result == null) { MultiValuesMap, StructureViewExtension> map = myExtensions.getValue(); @@ -154,7 +155,7 @@ public final class StructureViewFactoryImpl extends StructureViewFactoryEx imple } @Override - public void runWhenInitialized(Runnable runnable) { + public void runWhenInitialized(@NotNull Runnable runnable) { if (myStructureViewWrapperImpl != null) { runnable.run(); } @@ -163,14 +164,20 @@ public final class StructureViewFactoryImpl extends StructureViewFactoryEx imple } } - @Override - public StructureView createStructureView(final FileEditor fileEditor, final StructureViewModel treeModel, final Project project) { - return new StructureViewComponent(fileEditor, treeModel, project); - } - + @NotNull @Override public StructureView createStructureView(final FileEditor fileEditor, - final StructureViewModel treeModel, final Project project, final boolean showRootNode) { + @NotNull final StructureViewModel treeModel, + @NotNull final Project project) { + return createStructureView(fileEditor, treeModel, project, true); + } + + @NotNull + @Override + public StructureView createStructureView(final FileEditor fileEditor, + @NotNull StructureViewModel treeModel, + @NotNull Project project, + final boolean showRootNode) { return new StructureViewComponent(fileEditor, treeModel, project, showRootNode); } } diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewModelWrapper.java b/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewModelWrapper.java index e7301cd5be8b..dbc91a77dec6 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewModelWrapper.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewModelWrapper.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. @@ -45,22 +45,22 @@ public class StructureViewModelWrapper implements StructureViewModel { } @Override - public void addEditorPositionListener(final FileEditorPositionListener listener) { + public void addEditorPositionListener(@NotNull final FileEditorPositionListener listener) { myStructureViewModel.addEditorPositionListener(listener); } @Override - public void removeEditorPositionListener(final FileEditorPositionListener listener) { + public void removeEditorPositionListener(@NotNull final FileEditorPositionListener listener) { myStructureViewModel.removeEditorPositionListener(listener); } @Override - public void addModelListener(final ModelListener modelListener) { + public void addModelListener(@NotNull final ModelListener modelListener) { myStructureViewModel.addModelListener(modelListener); } @Override - public void removeModelListener(final ModelListener modelListener) { + public void removeModelListener(@NotNull final ModelListener modelListener) { myStructureViewModel.removeModelListener(modelListener); } diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/impl/TemplateLanguageStructureViewBuilder.java b/platform/lang-impl/src/com/intellij/ide/structureView/impl/TemplateLanguageStructureViewBuilder.java index 6886470e1a87..83174587bf01 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/impl/TemplateLanguageStructureViewBuilder.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/impl/TemplateLanguageStructureViewBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -155,7 +155,7 @@ public abstract class TemplateLanguageStructureViewBuilder implements StructureV @Override @NotNull - public StructureView createStructureView(FileEditor fileEditor, Project project) { + public StructureView createStructureView(FileEditor fileEditor, @NotNull Project project) { myFileEditor = fileEditor; List viewDescriptors = new ArrayList(); final TemplateLanguageFileViewProvider provider = getViewProvider(); diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/impl/common/PsiTreeElementBase.java b/platform/lang-impl/src/com/intellij/ide/structureView/impl/common/PsiTreeElementBase.java index 513e31f6be73..9d851c00f31e 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/impl/common/PsiTreeElementBase.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/impl/common/PsiTreeElementBase.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. @@ -40,6 +40,7 @@ public abstract class PsiTreeElementBase implements Struc myValue = psiElement; } + @NotNull @Override public ItemPresentation getPresentation() { return this; @@ -94,6 +95,7 @@ public abstract class PsiTreeElementBase implements Struc return element != null ? element.toString() : ""; } + @NotNull @Override public final StructureViewTreeElement[] getChildren() { final T element = getElement(); diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java index ae8cedaf9129..3bdb4de361f3 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.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. @@ -92,13 +92,9 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre private final StructureViewModel myTreeModel; private static int ourSettingsModificationCount; - public StructureViewComponent(FileEditor editor, StructureViewModel structureViewModel, Project project) { - this(editor, structureViewModel, project, true); - } - public StructureViewComponent(final FileEditor editor, - final StructureViewModel structureViewModel, - final Project project, + @NotNull StructureViewModel structureViewModel, + @NotNull Project project, final boolean showRootNode) { super(true, true); @@ -861,13 +857,11 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre final Object o = unwrapValue(getValue()); long currentStamp; - if (( o instanceof PsiElement && + if (o instanceof PsiElement && ((PsiElement)o).getNode() instanceof CompositeElement && - childrenStamp != (currentStamp = ((CompositeElement)((PsiElement)o).getNode()).getModificationCount()) - ) || - ( o instanceof ModificationTracker && + childrenStamp != (currentStamp = ((CompositeElement)((PsiElement)o).getNode()).getModificationCount()) || + o instanceof ModificationTracker && childrenStamp != (currentStamp = ((ModificationTracker)o).getModificationCount()) - ) ) { resetChildren(); childrenStamp = currentStamp; @@ -882,26 +876,22 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre @Override public boolean isAlwaysShowPlus() { - if (getElementInfoProvider() != null) { - return getElementInfoProvider().isAlwaysShowsPlus((StructureViewTreeElement)getValue()); - } - return true; + StructureViewModel.ElementInfoProvider elementInfoProvider = getElementInfoProvider(); + return elementInfoProvider == null || elementInfoProvider.isAlwaysShowsPlus((StructureViewTreeElement)getValue()); } @Override public boolean isAlwaysLeaf() { - if (getElementInfoProvider() != null) { - return getElementInfoProvider().isAlwaysLeaf((StructureViewTreeElement)getValue()); - } - - return false; + StructureViewModel.ElementInfoProvider elementInfoProvider = getElementInfoProvider(); + return elementInfoProvider != null && elementInfoProvider.isAlwaysLeaf((StructureViewTreeElement)getValue()); } @Nullable private StructureViewModel.ElementInfoProvider getElementInfoProvider() { if (myTreeModel instanceof StructureViewModel.ElementInfoProvider) { - return ((StructureViewModel.ElementInfoProvider)myTreeModel); - } else if (myTreeModel instanceof TreeModelWrapper) { + return (StructureViewModel.ElementInfoProvider)myTreeModel; + } + if (myTreeModel instanceof TreeModelWrapper) { StructureViewModel model = ((TreeModelWrapper)myTreeModel).getModel(); if (model instanceof StructureViewModel.ElementInfoProvider) { return (StructureViewModel.ElementInfoProvider)model; @@ -912,12 +902,12 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre } @Override - protected TreeElementWrapper createChildNode(final TreeElement child) { + protected TreeElementWrapper createChildNode(@NotNull final TreeElement child) { return new StructureViewTreeElementWrapper(myProject, child, myTreeModel); } @Override - protected GroupWrapper createGroupWrapper(final Project project, Group group, final TreeModel treeModel) { + protected GroupWrapper createGroupWrapper(final Project project, @NotNull Group group, final TreeModel treeModel) { return new StructureViewGroup(project, group, treeModel); } @@ -940,9 +930,7 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre if (o instanceof StructureViewTreeElement) { return ((StructureViewTreeElement)o).getValue(); } - else { - return o; - } + return o; } public int hashCode() { @@ -957,13 +945,13 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre } @Override - protected TreeElementWrapper createChildNode(TreeElement child) { + protected TreeElementWrapper createChildNode(@NotNull TreeElement child) { return new StructureViewTreeElementWrapper(getProject(), child, myTreeModel); } @Override - protected GroupWrapper createGroupWrapper(Project project, Group group, TreeModel treeModel) { + protected GroupWrapper createGroupWrapper(Project project, @NotNull Group group, TreeModel treeModel) { return new StructureViewGroup(project, group, treeModel); } diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeActionWrapper.java b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeActionWrapper.java index 4f9c63ea0078..890f2dff4740 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeActionWrapper.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeActionWrapper.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. @@ -23,13 +23,14 @@ import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.actionSystem.impl.MenuItemPresentationFactory; import com.intellij.openapi.project.DumbAware; +import org.jetbrains.annotations.NotNull; public class TreeActionWrapper extends ToggleAction implements DumbAware { private final TreeAction myAction; private final TreeActionsOwner myStructureView; - public TreeActionWrapper(TreeAction action, TreeActionsOwner structureView) { + public TreeActionWrapper(@NotNull TreeAction action, @NotNull TreeActionsOwner structureView) { myAction = action; myStructureView = structureView; } diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeModelWrapper.java b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeModelWrapper.java index 12d35f8f4344..d3af6621739d 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeModelWrapper.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeModelWrapper.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. @@ -26,12 +26,13 @@ import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.List; public class TreeModelWrapper implements StructureViewModel, ProvidingTreeModel { private final StructureViewModel myModel; private final TreeActionsOwner myStructureView; - public TreeModelWrapper(StructureViewModel model, TreeActionsOwner structureView) { + public TreeModelWrapper(@NotNull StructureViewModel model, @NotNull TreeActionsOwner structureView) { myModel = model; myStructureView = structureView; } @@ -45,41 +46,43 @@ public class TreeModelWrapper implements StructureViewModel, ProvidingTreeModel @Override @NotNull public Grouper[] getGroupers() { - ArrayList filtered = filterActive(myModel.getGroupers()); + List filtered = filterActive(myModel.getGroupers()); return filtered.toArray(new Grouper[filtered.size()]); } - private ArrayList filterActive(TreeAction[] actions) { - ArrayList filtered = new ArrayList(); - for (TreeAction action : actions) { + @NotNull + private List filterActive(@NotNull T[] actions) { + List filtered = new ArrayList(); + for (T action : actions) { if (isFiltered(action)) filtered.add(action); } return filtered; } - private ArrayList filterProviders(Collection actions) { - ArrayList filtered = new ArrayList(); + @NotNull + private List filterProviders(@NotNull Collection actions) { + List filtered = new ArrayList(); for (NodeProvider action : actions) { if (isFiltered(action)) filtered.add(action); } return filtered; } - private boolean isFiltered(TreeAction action) { + private boolean isFiltered(@NotNull TreeAction action) { return action instanceof Sorter && !((Sorter)action).isVisible() || myStructureView.isActionActive(action.getName()); } @Override @NotNull public Sorter[] getSorters() { - ArrayList filtered = filterActive(myModel.getSorters()); + List filtered = filterActive(myModel.getSorters()); return filtered.toArray(new Sorter[filtered.size()]); } @Override @NotNull public Filter[] getFilters() { - ArrayList filtered = filterActive(myModel.getFilters()); + List filtered = filterActive(myModel.getFilters()); return filtered.toArray(new Filter[filtered.size()]); } @@ -97,27 +100,24 @@ public class TreeModelWrapper implements StructureViewModel, ProvidingTreeModel return Collections.emptyList(); } - public static boolean isActive(final TreeAction action, final TreeActionsOwner actionsOwner) { + public static boolean isActive(@NotNull TreeAction action, @NotNull TreeActionsOwner actionsOwner) { if (shouldRevert(action)) { return !actionsOwner.isActionActive(action.getName()); } - else { - if (action instanceof Sorter && !((Sorter)action).isVisible()) return true; - return actionsOwner.isActionActive(action.getName()); - } + return action instanceof Sorter && !((Sorter)action).isVisible() || actionsOwner.isActionActive(action.getName()); } - public static boolean shouldRevert(final TreeAction action) { + public static boolean shouldRevert(@NotNull TreeAction action) { return action instanceof Filter && ((Filter)action).isReverted(); } @Override - public void addEditorPositionListener(FileEditorPositionListener listener) { + public void addEditorPositionListener(@NotNull FileEditorPositionListener listener) { myModel.addEditorPositionListener(listener); } @Override - public void removeEditorPositionListener(FileEditorPositionListener listener) { + public void removeEditorPositionListener(@NotNull FileEditorPositionListener listener) { myModel.removeEditorPositionListener(listener); } @@ -132,12 +132,12 @@ public class TreeModelWrapper implements StructureViewModel, ProvidingTreeModel } @Override - public void addModelListener(ModelListener modelListener) { + public void addModelListener(@NotNull ModelListener modelListener) { myModel.addModelListener(modelListener); } @Override - public void removeModelListener(ModelListener modelListener) { + public void removeModelListener(@NotNull ModelListener modelListener) { myModel.removeModelListener(modelListener); } diff --git a/platform/lang-impl/src/com/intellij/ide/todo/nodes/ToDoRootNode.java b/platform/lang-impl/src/com/intellij/ide/todo/nodes/ToDoRootNode.java index 17c19314a5e7..2698f894cd7b 100644 --- a/platform/lang-impl/src/com/intellij/ide/todo/nodes/ToDoRootNode.java +++ b/platform/lang-impl/src/com/intellij/ide/todo/nodes/ToDoRootNode.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. @@ -21,7 +21,6 @@ import com.intellij.ide.todo.ToDoSummary; import com.intellij.ide.todo.TodoTreeBuilder; import com.intellij.ide.util.treeView.AbstractTreeNode; import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructureDialog.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructureDialog.java index 9e171704605c..4abeb0787727 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructureDialog.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructureDialog.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. @@ -46,7 +46,7 @@ import com.intellij.pom.Navigatable; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import com.intellij.psi.util.PsiUtilBase; +import com.intellij.psi.util.PsiUtilCore; import com.intellij.ui.*; import com.intellij.ui.docking.DockManager; import com.intellij.ui.speedSearch.SpeedSearchSupply; @@ -80,9 +80,9 @@ public class FileStructureDialog extends DialogWrapper { @NonNls private static final String ourPropertyKey = "FileStructure.narrowDown"; private boolean myShouldNarrowDown = false; - public FileStructureDialog(StructureViewModel structureViewModel, - @Nullable Editor editor, - Project project, + public FileStructureDialog(@NotNull StructureViewModel structureViewModel, + @NotNull Editor editor, + @NotNull Project project, Navigatable navigatable, @NotNull final Disposable auxDisposable, final boolean applySortAndFilter) { @@ -109,17 +109,17 @@ public class FileStructureDialog extends DialogWrapper { if (psiElement != null) { if (structureViewModel.shouldEnterElement(psiElement)) { - myCommanderPanel.getBuilder().enterElement(psiElement, PsiUtilBase.getVirtualFile(psiElement)); + myCommanderPanel.getBuilder().enterElement(psiElement, PsiUtilCore.getVirtualFile(psiElement)); } else { - myCommanderPanel.getBuilder().selectElement(psiElement, PsiUtilBase.getVirtualFile(psiElement)); + myCommanderPanel.getBuilder().selectElement(psiElement, PsiUtilCore.getVirtualFile(psiElement)); } } Disposer.register(myDisposable, auxDisposable); } - protected PsiFile getPsiFile(final Project project) { + protected PsiFile getPsiFile(@NotNull Project project) { return PsiDocumentManager.getInstance(project).getPsiFile(myEditor.getDocument()); } @@ -189,7 +189,8 @@ public class FileStructureDialog extends DialogWrapper { ProjectListBuilder projectListBuilder = new ProjectListBuilder(myProject, myCommanderPanel, myTreeStructure, null, showRoot) { @Override protected boolean shouldEnterSingleTopLevelElement(Object rootChild) { - return myBaseTreeModel.shouldEnterElement(((StructureViewTreeElement)((AbstractTreeNode)rootChild).getValue()).getValue()); + Object element = ((StructureViewTreeElement)((AbstractTreeNode)rootChild).getValue()).getValue(); + return myBaseTreeModel.shouldEnterElement(element); } @Override @@ -311,7 +312,7 @@ public class FileStructureDialog extends DialogWrapper { boolean oldNarrowDown = myShouldNarrowDown; myShouldNarrowDown = false; try { - builder.enterElement(currentParent, PsiUtilBase.getVirtualFile(currentParent)); + builder.enterElement(currentParent, PsiUtilCore.getVirtualFile(currentParent)); } finally { myShouldNarrowDown = oldNarrowDown; @@ -321,7 +322,7 @@ public class FileStructureDialog extends DialogWrapper { } if (SpeedSearchBase.hasActiveSpeedSearch(myCommanderPanel.getList())) { - final SpeedSearchSupply supply = SpeedSearchBase.getSupply(myCommanderPanel.getList()); + final SpeedSearchSupply supply = SpeedSearchSupply.getSupply(myCommanderPanel.getList()); if (supply != null && supply.isPopupActive()) supply.refreshSelection(); } } diff --git a/platform/lang-impl/src/com/intellij/ide/util/StructureViewCompositeModel.java b/platform/lang-impl/src/com/intellij/ide/util/StructureViewCompositeModel.java index ca4c13626095..ac656636323d 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/StructureViewCompositeModel.java +++ b/platform/lang-impl/src/com/intellij/ide/util/StructureViewCompositeModel.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. @@ -65,11 +65,13 @@ public class StructureViewCompositeModel extends StructureViewModelBase implemen return file.canNavigateToSource(); } + @NotNull @Override public ItemPresentation getPresentation() { return file.getPresentation(); } + @NotNull @Override public TreeElement[] getChildren() { ArrayList elements = new ArrayList(); @@ -127,6 +129,7 @@ public class StructureViewCompositeModel extends StructureViewModelBase implemen return file.canNavigateToSource(); } + @NotNull @Override public ItemPresentation getPresentation() { return new ItemPresentation() { @@ -150,6 +153,7 @@ public class StructureViewCompositeModel extends StructureViewModelBase implemen }; } + @NotNull @Override public TreeElement[] getChildren() { return view.structureView.getTreeModel().getRoot().getChildren(); diff --git a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/CachingChildrenTreeNode.java b/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/CachingChildrenTreeNode.java index a81d18f13792..f08fb99cf4bf 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/CachingChildrenTreeNode.java +++ b/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/CachingChildrenTreeNode.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.intellij.ide.util.treeView.smartTree; import com.intellij.ide.structureView.impl.StructureViewElementWrapper; import com.intellij.ide.util.treeView.AbstractTreeNode; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.pom.Navigatable; import gnu.trove.THashMap; @@ -26,6 +27,7 @@ import org.jetbrains.annotations.NotNull; import java.util.*; public abstract class CachingChildrenTreeNode extends AbstractTreeNode { + private static final Logger LOG = Logger.getInstance("#com.intellij.ide.util.treeView.smartTree.CachingChildrenTreeNode"); private List myChildren; private List myOldChildren = null; protected final TreeModel myTreeModel; @@ -95,12 +97,13 @@ public abstract class CachingChildrenTreeNode extends AbstractTreeNode children = getChildren(); for (Filter filter : filters) { for (Iterator eachNode = children.iterator(); eachNode.hasNext();) { TreeElementWrapper eachChild = (TreeElementWrapper)eachNode.next(); - if (!filter.isVisible(eachChild.getValue())) { + TreeElement value = eachChild.getValue(); + if (value == null || !filter.isVisible(value)) { eachNode.remove(); } } @@ -108,7 +111,7 @@ public abstract class CachingChildrenTreeNode extends AbstractTreeNode extends AbstractTreeNode> ungrouped, Grouper grouper) { + private void processUngrouped(@NotNull List> ungrouped, @NotNull Grouper grouper) { Map ungroupedObjects = collectValues(ungrouped); Collection groups = grouper.group(this, ungroupedObjects.keySet()); Map groupNodes = createGroupNodes(groups); for (Group group : groups) { + if (group == null) { + LOG.error(grouper + " returned null group: "+groups); + } GroupWrapper groupWrapper = groupNodes.get(group); Collection children = group.getChildren(); for (TreeElement node : children) { + if (node == null) { + LOG.error(group + " returned null child: " + children); + } CachingChildrenTreeNode child = createChildNode(node); groupWrapper.addSubElement(child); AbstractTreeNode abstractTreeNode = ungroupedObjects.get(node); @@ -165,7 +174,7 @@ public abstract class CachingChildrenTreeNode extends AbstractTreeNode extends AbstractTreeNode createGroupNodes(Collection groups) { + private Map createGroupNodes(@NotNull Collection groups) { Map result = new THashMap(); for (Group group : groups) { result.put(group, createGroupWrapper(getProject(), group, myTreeModel)); @@ -185,7 +194,7 @@ public abstract class CachingChildrenTreeNode extends AbstractTreeNode extends AbstractTreeNode { + private static final Logger LOG = Logger.getInstance("#com.intellij.ide.util.treeView.smartTree.GroupWrapper"); public GroupWrapper(Project project, Group value, TreeModel treeModel) { super(project, value, treeModel); clearChildren(); } @Override - public void copyFromNewInstance(final CachingChildrenTreeNode newInstance) { + public void copyFromNewInstance(@NotNull final CachingChildrenTreeNode newInstance) { clearChildren(); setChildren(newInstance.getChildren()); synchronizeChildren(); @@ -43,8 +45,12 @@ public class GroupWrapper extends CachingChildrenTreeNode { @Override public void initChildren() { clearChildren(); - Collection children = getValue().getChildren(); + Group group = getValue(); + Collection children = group.getChildren(); for (TreeElement child : children) { + if (child == null) { + LOG.error(group + " returned null child: " + children); + } TreeElementWrapper childNode = createChildNode(child); addSubElement(childNode); } diff --git a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/TreeElementWrapper.java b/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/TreeElementWrapper.java index a0dafb0ed58f..ac1660aea6a0 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/TreeElementWrapper.java +++ b/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/TreeElementWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,17 +18,21 @@ package com.intellij.ide.util.treeView.smartTree; import com.intellij.ide.projectView.PresentationData; import com.intellij.ide.structureView.StructureViewTreeElement; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; +import java.util.Arrays; import java.util.Collection; public class TreeElementWrapper extends CachingChildrenTreeNode { + private static final Logger LOG = Logger.getInstance("#com.intellij.ide.util.treeView.smartTree.TreeElementWrapper"); public TreeElementWrapper(Project project, TreeElement value, TreeModel treeModel) { super(project, value, treeModel); } @Override - public void copyFromNewInstance(final CachingChildrenTreeNode oldInstance) { + public void copyFromNewInstance(@NotNull final CachingChildrenTreeNode oldInstance) { } @Override @@ -41,16 +45,23 @@ public class TreeElementWrapper extends CachingChildrenTreeNode { @Override public void initChildren() { clearChildren(); - TreeElement[] children = getValue().getChildren(); + TreeElement value = getValue(); + TreeElement[] children = value.getChildren(); for (TreeElement child : children) { + if (child == null) { + LOG.error(value + " returned null child: " + Arrays.toString(children)); + } addSubElement(createChildNode(child)); } if (myTreeModel instanceof ProvidingTreeModel) { final Collection providers = ((ProvidingTreeModel)myTreeModel).getNodeProviders(); for (NodeProvider provider : providers) { if (((ProvidingTreeModel)myTreeModel).isEnabled(provider)) { - final Collection nodes = provider.provideNodes(getValue()); + final Collection nodes = provider.provideNodes(value); for (TreeElement node : nodes) { + if (node == null) { + LOG.error(provider + " returned null node: " + nodes); + } addSubElement(createChildNode(node)); } } diff --git a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewBuilder.java b/platform/platform-api/src/com/intellij/ide/structureView/StructureViewBuilder.java index 87ba9c5e7b4d..ceaab48de15b 100644 --- a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewBuilder.java +++ b/platform/platform-api/src/com/intellij/ide/structureView/StructureViewBuilder.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. @@ -49,5 +49,5 @@ public interface StructureViewBuilder { * @see TreeBasedStructureViewBuilder */ @NotNull - StructureView createStructureView(FileEditor fileEditor, Project project); + StructureView createStructureView(FileEditor fileEditor, @NotNull Project project); } diff --git a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewFactory.java b/platform/platform-api/src/com/intellij/ide/structureView/StructureViewFactory.java index e10f3c190a69..1d2bf73f10f7 100644 --- a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewFactory.java +++ b/platform/platform-api/src/com/intellij/ide/structureView/StructureViewFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.intellij.ide.structureView; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; /** * Factory interface for creating instances of the standard structure view component. @@ -31,9 +32,10 @@ public abstract class StructureViewFactory { * @param project the project containing the file for which the structure view is requested. * @return the structure view instance. */ + @NotNull public abstract StructureView createStructureView(FileEditor fileEditor, - StructureViewModel treeModel, - Project project); + @NotNull StructureViewModel treeModel, + @NotNull Project project); /** * Creates a structure view component instance for the specified editor. @@ -44,10 +46,11 @@ public abstract class StructureViewFactory { * @param showRootNode pass false if root node of the structure built should not actually be shown in result tree. * @return the structure view instance. */ + @NotNull public abstract StructureView createStructureView(FileEditor fileEditor, - StructureViewModel treeModel, - Project project, - boolean showRootNode); + @NotNull StructureViewModel treeModel, + @NotNull Project project, + boolean showRootNode); public static StructureViewFactory getInstance(Project project) { return ServiceManager.getService(project, StructureViewFactory.class); diff --git a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewModel.java b/platform/platform-api/src/com/intellij/ide/structureView/StructureViewModel.java index 61009d21c34c..551d70d055e1 100644 --- a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewModel.java +++ b/platform/platform-api/src/com/intellij/ide/structureView/StructureViewModel.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. @@ -41,7 +41,7 @@ public interface StructureViewModel extends TreeModel { * * @param listener the listener to add. */ - void addEditorPositionListener(FileEditorPositionListener listener); + void addEditorPositionListener(@NotNull FileEditorPositionListener listener); /** * Removes a listener which gets notified when the selection in the editor linked to the @@ -49,7 +49,7 @@ public interface StructureViewModel extends TreeModel { * * @param listener the listener to remove. */ - void removeEditorPositionListener(FileEditorPositionListener listener); + void removeEditorPositionListener(@NotNull FileEditorPositionListener listener); /** * Adds a listener which gets notified when the data represented by the structure view @@ -57,7 +57,7 @@ public interface StructureViewModel extends TreeModel { * * @param modelListener the listener to add. */ - void addModelListener(ModelListener modelListener); + void addModelListener(@NotNull ModelListener modelListener); /** * Removes a listener which gets notified when the data represented by the structure view @@ -65,13 +65,14 @@ public interface StructureViewModel extends TreeModel { * * @param modelListener the listener to remove. */ - void removeModelListener(ModelListener modelListener); + void removeModelListener(@NotNull ModelListener modelListener); /** * Returns the root element of the structure view tree. * * @return the structure view root. */ + @Override @NotNull StructureViewTreeElement getRoot(); @@ -83,15 +84,12 @@ public interface StructureViewModel extends TreeModel { boolean shouldEnterElement(Object element); interface ElementInfoProvider extends StructureViewModel { - boolean isAlwaysShowsPlus(StructureViewTreeElement element); - boolean isAlwaysLeaf(StructureViewTreeElement element); - } interface ExpandInfoProvider { - boolean isAutoExpand(StructureViewTreeElement element); + boolean isAutoExpand(@NotNull StructureViewTreeElement element); boolean isSmartExpand(); } } diff --git a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewTreeElement.java b/platform/platform-api/src/com/intellij/ide/structureView/StructureViewTreeElement.java index 81010a383d9f..1b666467585e 100644 --- a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewTreeElement.java +++ b/platform/platform-api/src/com/intellij/ide/structureView/StructureViewTreeElement.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. @@ -34,6 +34,4 @@ public interface StructureViewTreeElement extends TreeElement, Navigatable{ * @return the data object instance. */ Object getValue(); - - /*StructureViewTreeElement[] getChildren();*/ } diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.java b/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.java index d722c2c6444e..ada9c64047e6 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.java +++ b/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.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. @@ -69,7 +69,7 @@ public abstract class AbstractTreeNode extends PresentableNodeDescriptor extends PresentableNodeDescriptor extends PresentableNodeDescriptor extends TreeAction { - Collection provideNodes(TreeElement node); + @NotNull + Collection provideNodes(@NotNull TreeElement node); } diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/SorterUtil.java b/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/SorterUtil.java index 5434bc082bab..cabcc7a7ac0d 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/SorterUtil.java +++ b/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/SorterUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ */ package com.intellij.ide.util.treeView.smartTree; +import org.jetbrains.annotations.NotNull; + /** * @author Konstantin Bulenkov */ @@ -22,16 +24,19 @@ public class SorterUtil { private SorterUtil() { } + @NotNull public static String getStringPresentation(Object object) { String result = null; if (object instanceof SortableTreeElement) { - result = ((SortableTreeElement) object).getAlphaSortKey(); - } else if (object instanceof TreeElement){ - result = ((TreeElement)object).getPresentation().getPresentableText(); - } else if (object instanceof Group){ + result = ((SortableTreeElement)object).getAlphaSortKey(); + } + else if (object instanceof TreeElement) { + result = ((TreeElement)object).getPresentation().getPresentableText(); + } + else if (object instanceof Group) { result = ((Group)object).getPresentation().getPresentableText(); } - return result != null ? result : ""; + return result == null ? "" : result; } } diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/TreeModel.java b/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/TreeModel.java index 0375e32eae03..675c7041cd3e 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/TreeModel.java +++ b/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/TreeModel.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. @@ -29,7 +29,8 @@ public interface TreeModel { * * @return the tree root. */ - @NotNull TreeElement getRoot(); + @NotNull + TreeElement getRoot(); /** * Returns the list of actions for grouping items in the tree. @@ -37,7 +38,8 @@ public interface TreeModel { * @return the array of grouping actions. * @see Grouper#EMPTY_ARRAY */ - @NotNull Grouper[] getGroupers(); + @NotNull + Grouper[] getGroupers(); /** * Returns the array of actions for sorting items in the tree. @@ -45,7 +47,8 @@ public interface TreeModel { * @return the array of sorting actions. * @see Sorter#EMPTY_ARRAY */ - @NotNull Sorter[] getSorters(); + @NotNull + Sorter[] getSorters(); /** * Returns the array of actions for filtering items in the tree. @@ -53,5 +56,6 @@ public interface TreeModel { * @return the array of filtering actions. * @see Filter#EMPTY_ARRAY */ - @NotNull Filter[] getFilters(); + @NotNull + Filter[] getFilters(); } diff --git a/platform/platform-api/src/com/intellij/openapi/ide/CopyPasteManager.java b/platform/platform-api/src/com/intellij/openapi/ide/CopyPasteManager.java index c96ce0ae3f81..756631c6b3ff 100644 --- a/platform/platform-api/src/com/intellij/openapi/ide/CopyPasteManager.java +++ b/platform/platform-api/src/com/intellij/openapi/ide/CopyPasteManager.java @@ -33,11 +33,11 @@ public abstract class CopyPasteManager { return ServiceManager.getService(CopyPasteManager.class); } - public abstract void addContentChangedListener(ContentChangedListener listener); + public abstract void addContentChangedListener(@NotNull ContentChangedListener listener); - public abstract void addContentChangedListener(ContentChangedListener listener, Disposable parentDisposable); + public abstract void addContentChangedListener(@NotNull ContentChangedListener listener, @NotNull Disposable parentDisposable); - public abstract void removeContentChangedListener(ContentChangedListener listener); + public abstract void removeContentChangedListener(@NotNull ContentChangedListener listener); /** @deprecated use {@link #getContents(DataFlavor)} or {@link #areDataFlavorsAvailable(DataFlavor...)} (to remove in IDEA 14) */ @SuppressWarnings("unused") @@ -53,6 +53,7 @@ public abstract class CopyPasteManager { @Nullable public abstract T getContents(@NotNull DataFlavor flavor); + @NotNull public abstract Transferable[] getAllContents(); public abstract void setContents(@NotNull Transferable content); diff --git a/platform/platform-api/src/com/intellij/openapi/vcs/FileStatusListener.java b/platform/platform-api/src/com/intellij/openapi/vcs/FileStatusListener.java index a556fb4e104e..f53a2adc086a 100644 --- a/platform/platform-api/src/com/intellij/openapi/vcs/FileStatusListener.java +++ b/platform/platform-api/src/com/intellij/openapi/vcs/FileStatusListener.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. @@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull; public interface FileStatusListener { /** * Indicates that some file statuses were change. On this event client should recalculate all statuses - * it's depenedend on. + * it's dependent on. */ void fileStatusesChanged(); void fileStatusChanged(@NotNull VirtualFile virtualFile); diff --git a/platform/platform-api/src/com/intellij/openapi/vcs/FileStatusManager.java b/platform/platform-api/src/com/intellij/openapi/vcs/FileStatusManager.java index f2fad70bb48e..4c40f9120a46 100644 --- a/platform/platform-api/src/com/intellij/openapi/vcs/FileStatusManager.java +++ b/platform/platform-api/src/com/intellij/openapi/vcs/FileStatusManager.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. @@ -35,23 +35,23 @@ public abstract class FileStatusManager { public abstract void fileStatusesChanged(); public abstract void fileStatusChanged(VirtualFile file); - public abstract void addFileStatusListener(FileStatusListener listener); - public abstract void addFileStatusListener(FileStatusListener listener, Disposable parentDisposable); - public abstract void removeFileStatusListener(FileStatusListener listener); + public abstract void addFileStatusListener(@NotNull FileStatusListener listener); + public abstract void addFileStatusListener(@NotNull FileStatusListener listener, @NotNull Disposable parentDisposable); + public abstract void removeFileStatusListener(@NotNull FileStatusListener listener); /** * @deprecated Use getStatus(file).getText()} instead */ - public String getStatusText(VirtualFile file){ + public String getStatusText(@NotNull VirtualFile file){ return getStatus(file).getText(); } /** * @deprecated Use getStatus(file).getColor()} instead */ - public Color getStatusColor(VirtualFile file){ + public Color getStatusColor(@NotNull VirtualFile file){ return getStatus(file).getColor(); } - public abstract Color getNotChangedDirectoryColor(VirtualFile vf); + public abstract Color getNotChangedDirectoryColor(@NotNull VirtualFile vf); } diff --git a/platform/platform-impl/src/com/intellij/ide/CopyPasteManagerEx.java b/platform/platform-impl/src/com/intellij/ide/CopyPasteManagerEx.java index d4bd50adf117..dea9dd8457bf 100644 --- a/platform/platform-impl/src/com/intellij/ide/CopyPasteManagerEx.java +++ b/platform/platform-impl/src/com/intellij/ide/CopyPasteManagerEx.java @@ -58,17 +58,17 @@ public class CopyPasteManagerEx extends CopyPasteManager implements ClipboardOwn } @Override - public void addContentChangedListener(ContentChangedListener listener) { + public void addContentChangedListener(@NotNull ContentChangedListener listener) { myDispatcher.addListener(listener); } @Override - public void addContentChangedListener(final ContentChangedListener listener, Disposable parentDisposable) { + public void addContentChangedListener(@NotNull final ContentChangedListener listener, @NotNull Disposable parentDisposable) { myDispatcher.addListener(listener, parentDisposable); } @Override - public void removeContentChangedListener(ContentChangedListener listener) { + public void removeContentChangedListener(@NotNull ContentChangedListener listener) { myDispatcher.removeListener(listener); } @@ -256,6 +256,7 @@ public class CopyPasteManagerEx extends CopyPasteManager implements ClipboardOwn return null; } + @NotNull @Override public Transferable[] getAllContents() { String clipString = getContents(DataFlavor.stringFlavor); diff --git a/platform/platform-tests/testSrc/com/intellij/structureView/TestGrouper.java b/platform/platform-tests/testSrc/com/intellij/structureView/TestGrouper.java index f4474c547514..280bfb89eacc 100644 --- a/platform/platform-tests/testSrc/com/intellij/structureView/TestGrouper.java +++ b/platform/platform-tests/testSrc/com/intellij/structureView/TestGrouper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.structureView; import com.intellij.ide.util.treeView.AbstractTreeNode; @@ -42,6 +57,7 @@ public class TestGrouper implements Grouper { myChildren = new ArrayList(children); } + @NotNull @Override public Collection getChildren() { Collection result = new LinkedHashSet(); @@ -53,6 +69,7 @@ public class TestGrouper implements Grouper { return result; } + @NotNull @Override public ItemPresentation getPresentation() { return null; @@ -80,7 +97,7 @@ public class TestGrouper implements Grouper { @Override @NotNull - public Collection group(final AbstractTreeNode parent, Collection children) { + public Collection group(@NotNull final AbstractTreeNode parent, @NotNull Collection children) { List result = new ArrayList(); Collection parentGroupUsedStrings = parent.getValue() instanceof StringGroup ? ((StringGroup)parent.getValue()).myChildrenUsedStrings : diff --git a/platform/platform-tests/testSrc/com/intellij/structureView/TestTreeModel.java b/platform/platform-tests/testSrc/com/intellij/structureView/TestTreeModel.java index 7b0da6e39d40..56e628a37fd8 100644 --- a/platform/platform-tests/testSrc/com/intellij/structureView/TestTreeModel.java +++ b/platform/platform-tests/testSrc/com/intellij/structureView/TestTreeModel.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.structureView; import com.intellij.ide.projectView.PresentationData; @@ -67,12 +82,14 @@ public class TestTreeModel implements StructureViewModel{ myValue = value; } + @NotNull @Override public StructureViewTreeElement[] getChildren() { return myChildren.toArray(new StructureViewTreeElement[myChildren.size()]); } + @NotNull @Override public ItemPresentation getPresentation() { return new PresentationData(myValue, null, null, null); @@ -114,11 +131,11 @@ public class TestTreeModel implements StructureViewModel{ } @Override - public void addEditorPositionListener(FileEditorPositionListener listener) { + public void addEditorPositionListener(@NotNull FileEditorPositionListener listener) { } @Override - public void removeEditorPositionListener(FileEditorPositionListener listener) { + public void removeEditorPositionListener(@NotNull FileEditorPositionListener listener) { } @Override @@ -131,12 +148,12 @@ public class TestTreeModel implements StructureViewModel{ } @Override - public void addModelListener(ModelListener modelListener) { + public void addModelListener(@NotNull ModelListener modelListener) { } @Override - public void removeModelListener(ModelListener modelListener) { + public void removeModelListener(@NotNull ModelListener modelListener) { } } diff --git a/platform/util/src/com/intellij/openapi/util/MultiValuesMap.java b/platform/util/src/com/intellij/openapi/util/MultiValuesMap.java index 41feba6d1584..4db826f55837 100644 --- a/platform/util/src/com/intellij/openapi/util/MultiValuesMap.java +++ b/platform/util/src/com/intellij/openapi/util/MultiValuesMap.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.util; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; @@ -32,35 +33,38 @@ public class MultiValuesMap{ myBaseMap = ordered ? new LinkedHashMap>() : new HashMap>(); } - public void putAll(K key, Collection values) { + public void putAll(K key, @NotNull Collection values) { for (V value : values) { put(key, value); } } - public void putAll(K key, V... values) { + public void putAll(K key, @NotNull V... values) { for (V value : values) { put(key, value); } } public void put(K key, V value) { - if (!myBaseMap.containsKey(key)) { - myBaseMap.put(key, myOrdered ? new LinkedHashSet() : new HashSet()); + Collection collection = myBaseMap.get(key); + if (collection == null) { + collection = myOrdered ? new LinkedHashSet() : new HashSet(); + myBaseMap.put(key, collection); } - myBaseMap.get(key).add(value); + collection.add(value); } - @Nullable public Collection get(K key){ return myBaseMap.get(key); } + @NotNull public Set keySet() { return myBaseMap.keySet(); } + @NotNull public Collection values() { Set result = myOrdered ? new LinkedHashSet() : new HashSet(); for (final Collection values : myBaseMap.values()) { @@ -88,6 +92,7 @@ public class MultiValuesMap{ return myBaseMap.remove(key); } + @NotNull public Set>> entrySet() { return myBaseMap.entrySet(); } @@ -100,6 +105,7 @@ public class MultiValuesMap{ return myBaseMap.containsKey(key); } + @NotNull public Collection collectValues() { Collection result = new HashSet(); for (Collection v : myBaseMap.values()) { diff --git a/platform/util/src/com/intellij/util/ReflectionUtil.java b/platform/util/src/com/intellij/util/ReflectionUtil.java index 897c3c392770..df768fdfa56d 100644 --- a/platform/util/src/com/intellij/util/ReflectionUtil.java +++ b/platform/util/src/com/intellij/util/ReflectionUtil.java @@ -367,7 +367,7 @@ public class ReflectionUtil { } } - public static boolean isAssignable(@NotNull Class ancestor, Class descendant) { + public static boolean isAssignable(@NotNull Class ancestor, @NotNull Class descendant) { return ancestor == descendant || ancestor.isAssignableFrom(descendant); } } diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/PropertiesGroupingStructureViewComponent.java b/plugins/properties/src/com/intellij/lang/properties/editor/PropertiesGroupingStructureViewComponent.java index cc38c8d74500..7547e9772c0b 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/PropertiesGroupingStructureViewComponent.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/PropertiesGroupingStructureViewComponent.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. @@ -34,7 +34,7 @@ public class PropertiesGroupingStructureViewComponent extends StructureViewCompo protected PropertiesGroupingStructureViewComponent(Project project, FileEditor editor, PropertiesGroupingStructureViewModel structureViewModel) { - super(editor, structureViewModel, project); + super(editor, structureViewModel, project, true); showToolbar(); } diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleFileStructureViewElement.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleFileStructureViewElement.java index b180a42b53da..2a1f94af4c95 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleFileStructureViewElement.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleFileStructureViewElement.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. @@ -26,6 +26,7 @@ import com.intellij.lang.properties.ResourceBundle; import com.intellij.lang.properties.psi.PropertiesFile; import com.intellij.navigation.ItemPresentation; import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.util.ArrayList; @@ -46,6 +47,7 @@ public class ResourceBundleFileStructureViewElement implements StructureViewTree return myResourceBundle; } + @NotNull public StructureViewTreeElement[] getChildren() { List propertiesFiles = myResourceBundle.getPropertiesFiles(myProject); Map propertyNames = new LinkedHashMap(); @@ -66,6 +68,7 @@ public class ResourceBundleFileStructureViewElement implements StructureViewTree return result.toArray(new StructureViewTreeElement[result.size()]); } + @NotNull public ItemPresentation getPresentation() { return new ItemPresentation() { public String getPresentableText() { diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java index b1eb6126bca0..e521047cb9ba 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.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. @@ -30,6 +30,7 @@ import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.util.PlatformIcons; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.*; @@ -58,24 +59,32 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView myPresentableName = presentableName; } + @Override public String getValue() { return myPropertyName; } + @Override + @NotNull public StructureViewTreeElement[] getChildren() { return EMPTY_ARRAY; } + @Override + @NotNull public ItemPresentation getPresentation() { return new ColoredItemPresentation() { + @Override public String getPresentableText() { return myPresentableName == null ? myPropertyName : myPresentableName; } + @Override public String getLocationString() { return null; } + @Override public Icon getIcon(boolean open) { return PlatformIcons.PROPERTY_ICON; } @@ -92,14 +101,17 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView }; } + @Override public void navigate(boolean requestFocus) { //todo } + @Override public boolean canNavigate() { return false; } + @Override public boolean canNavigateToSource() { return false; } diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleStructureViewModel.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleStructureViewModel.java index 90a08c81aa4a..6d3d266e8ae3 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleStructureViewModel.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleStructureViewModel.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. @@ -75,19 +75,19 @@ public class ResourceBundleStructureViewModel implements PropertiesGroupingStruc return null; } - public void addEditorPositionListener(FileEditorPositionListener listener) { + public void addEditorPositionListener(@NotNull FileEditorPositionListener listener) { } - public void removeEditorPositionListener(FileEditorPositionListener listener) { + public void removeEditorPositionListener(@NotNull FileEditorPositionListener listener) { } - public void addModelListener(ModelListener modelListener) { + public void addModelListener(@NotNull ModelListener modelListener) { } - public void removeModelListener(ModelListener modelListener) { + public void removeModelListener(@NotNull ModelListener modelListener) { } diff --git a/plugins/properties/src/com/intellij/lang/properties/structureView/GroupByWordPrefixes.java b/plugins/properties/src/com/intellij/lang/properties/structureView/GroupByWordPrefixes.java index bd3393591167..b67f6bfbea3f 100644 --- a/plugins/properties/src/com/intellij/lang/properties/structureView/GroupByWordPrefixes.java +++ b/plugins/properties/src/com/intellij/lang/properties/structureView/GroupByWordPrefixes.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. @@ -49,8 +49,9 @@ public class GroupByWordPrefixes implements Grouper, Sorter { return mySeparator; } + @Override @NotNull - public Collection group(final AbstractTreeNode parent, Collection children) { + public Collection group(@NotNull final AbstractTreeNode parent, @NotNull Collection children) { List keys = new ArrayList(); String parentPrefix; @@ -78,6 +79,7 @@ public class GroupByWordPrefixes implements Grouper, Sorter { keys.add(new Key(words, element)); } Collections.sort(keys, new Comparator() { + @Override public int compare(final Key k1, final Key k2) { List o1 = k1.words; List o2 = k2.words; @@ -146,6 +148,7 @@ public class GroupByWordPrefixes implements Grouper, Sorter { return !Comparing.strEqual(words.get(parentPrefixLength), prevWords.get(parentPrefixLength)); } + @Override @NotNull public ActionPresentation getPresentation() { return new ActionPresentationData(PropertiesBundle.message("structure.view.group.by.prefixes.action.name"), @@ -153,11 +156,13 @@ public class GroupByWordPrefixes implements Grouper, Sorter { AllIcons.Actions.GroupByPrefix); } + @Override @NotNull public String getName() { return ID; } + @NotNull @Override public Comparator getComparator() { return Sorter.ALPHA_SORTER.getComparator(); diff --git a/plugins/properties/src/com/intellij/lang/properties/structureView/PropertiesFileStructureViewElement.java b/plugins/properties/src/com/intellij/lang/properties/structureView/PropertiesFileStructureViewElement.java index 44909dd3c43a..d0a203a7644f 100644 --- a/plugins/properties/src/com/intellij/lang/properties/structureView/PropertiesFileStructureViewElement.java +++ b/plugins/properties/src/com/intellij/lang/properties/structureView/PropertiesFileStructureViewElement.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. @@ -52,6 +52,7 @@ public class PropertiesFileStructureViewElement extends PsiTreeElementBase getChildren() { Collection result = new ArrayList(); List prefixWords = StringUtil.split(myPrefix, mySeparator); diff --git a/plugins/properties/src/com/intellij/lang/properties/structureView/PropertiesStructureViewBuilderFactory.java b/plugins/properties/src/com/intellij/lang/properties/structureView/PropertiesStructureViewBuilderFactory.java index fb14390904e6..477e80fed24b 100644 --- a/plugins/properties/src/com/intellij/lang/properties/structureView/PropertiesStructureViewBuilderFactory.java +++ b/plugins/properties/src/com/intellij/lang/properties/structureView/PropertiesStructureViewBuilderFactory.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. @@ -34,7 +34,7 @@ public class PropertiesStructureViewBuilderFactory implements PsiStructureViewFa public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) { return new StructureViewBuilder() { @NotNull - public StructureView createStructureView(FileEditor fileEditor, Project project) { + public StructureView createStructureView(FileEditor fileEditor, @NotNull Project project) { return new PropertiesFileStructureViewComponent(project, (PropertiesFileImpl)psiFile, fileEditor); } }; diff --git a/plugins/properties/src/com/intellij/lang/properties/structureView/PropertiesStructureViewElement.java b/plugins/properties/src/com/intellij/lang/properties/structureView/PropertiesStructureViewElement.java index 5ababdd5bf44..77946f442518 100644 --- a/plugins/properties/src/com/intellij/lang/properties/structureView/PropertiesStructureViewElement.java +++ b/plugins/properties/src/com/intellij/lang/properties/structureView/PropertiesStructureViewElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.intellij.lang.properties.structureView; import com.intellij.ide.structureView.StructureViewTreeElement; import com.intellij.lang.properties.psi.Property; import com.intellij.navigation.ItemPresentation; +import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -48,10 +49,12 @@ public class PropertiesStructureViewElement implements StructureViewTreeElement return myProperty.canNavigateToSource(); } + @NotNull public StructureViewTreeElement[] getChildren() { return EMPTY_ARRAY; } + @NotNull public ItemPresentation getPresentation() { return new ItemPresentation() { public String getPresentableText() { diff --git a/python/rest/src/com/jetbrains/rest/structureView/RestStructureViewElement.java b/python/rest/src/com/jetbrains/rest/structureView/RestStructureViewElement.java index 0ba21cc3a7c4..bb2244580dd6 100644 --- a/python/rest/src/com/jetbrains/rest/structureView/RestStructureViewElement.java +++ b/python/rest/src/com/jetbrains/rest/structureView/RestStructureViewElement.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. @@ -22,6 +22,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.jetbrains.rest.psi.RestElement; import com.jetbrains.rest.psi.RestTitle; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -56,6 +57,7 @@ public class RestStructureViewElement implements StructureViewTreeElement { return myElement.canNavigateToSource(); } + @NotNull public StructureViewTreeElement[] getChildren() { final Set childrenElements = new LinkedHashSet(); myElement.acceptChildren(new PsiElementVisitor() { @@ -77,6 +79,7 @@ public class RestStructureViewElement implements StructureViewTreeElement { return children; } + @NotNull public ItemPresentation getPresentation() { return new ItemPresentation() { public String getPresentableText() { diff --git a/python/rest/src/com/jetbrains/rest/structureView/RestStructureViewModel.java b/python/rest/src/com/jetbrains/rest/structureView/RestStructureViewModel.java index 0897b996e4f6..8d96f83aa23f 100644 --- a/python/rest/src/com/jetbrains/rest/structureView/RestStructureViewModel.java +++ b/python/rest/src/com/jetbrains/rest/structureView/RestStructureViewModel.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. @@ -48,7 +48,7 @@ public class RestStructureViewModel extends StructureViewModelBase implements St } @Override - public boolean isAutoExpand(StructureViewTreeElement element) { + public boolean isAutoExpand(@NotNull StructureViewTreeElement element) { return element.getValue() instanceof PsiFile; } diff --git a/python/src/com/jetbrains/python/structureView/PyStructureViewElement.java b/python/src/com/jetbrains/python/structureView/PyStructureViewElement.java index fd043ce5dcec..93c44f7f2a17 100644 --- a/python/src/com/jetbrains/python/structureView/PyStructureViewElement.java +++ b/python/src/com/jetbrains/python/structureView/PyStructureViewElement.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. @@ -27,6 +27,7 @@ import com.intellij.util.Function; import com.jetbrains.python.PyNames; import com.jetbrains.python.psi.*; import icons.PythonIcons; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -120,6 +121,7 @@ public class PyStructureViewElement implements StructureViewTreeElement { return name != null ? name.hashCode() : 0; } + @NotNull public StructureViewTreeElement[] getChildren() { final Collection children = new ArrayList(); for (PyElement e : getElementChildren(myElement)) { @@ -232,6 +234,7 @@ public class PyStructureViewElement implements StructureViewTreeElement { return false; } + @NotNull @Override public ItemPresentation getPresentation() { return new ColoredItemPresentation() { diff --git a/python/src/com/jetbrains/python/structureView/PyStructureViewModel.java b/python/src/com/jetbrains/python/structureView/PyStructureViewModel.java index 662179240530..3e8e4f177568 100644 --- a/python/src/com/jetbrains/python/structureView/PyStructureViewModel.java +++ b/python/src/com/jetbrains/python/structureView/PyStructureViewModel.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. @@ -66,7 +66,7 @@ public class PyStructureViewModel extends StructureViewModelBase implements Stru } @Override - public boolean isAutoExpand(StructureViewTreeElement element) { + public boolean isAutoExpand(@NotNull StructureViewTreeElement element) { return element.getValue() instanceof PsiFile; } diff --git a/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureTreeElement.java b/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureTreeElement.java index 4794cf59fb2a..548276faf5e9 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureTreeElement.java +++ b/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureTreeElement.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. @@ -52,10 +52,12 @@ public class DomStructureTreeElement implements StructureViewTreeElement, ItemPr return myElement.isValid() ? myElement.getXmlElement() : null; } + @NotNull public ItemPresentation getPresentation() { return this; } + @NotNull public TreeElement[] getChildren() { if (!myElement.isValid()) return EMPTY_ARRAY; final ArrayList result = new ArrayList(); diff --git a/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewBuilder.java b/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewBuilder.java index a8fb409e7c2a..0b86f4365492 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewBuilder.java +++ b/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewBuilder.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. @@ -59,8 +59,8 @@ public class DomStructureViewBuilder extends TreeBasedStructureViewBuilder { @Override @NotNull - public StructureView createStructureView(final FileEditor fileEditor, final Project project) { - return new StructureViewComponent(fileEditor, createStructureViewModel(fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null), project) { + public StructureView createStructureView(final FileEditor fileEditor, @NotNull final Project project) { + return new StructureViewComponent(fileEditor, createStructureViewModel(fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null), project, true) { @Override public AsyncResult expandPathToElement(final Object element) { if (element instanceof XmlElement) { diff --git a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java b/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java index dd3341df4133..822086c4e90d 100644 --- a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java +++ b/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.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. @@ -69,8 +69,9 @@ public class Html5SectionsNodeProvider implements FileStructureNodeProvider provideNodes(final TreeElement node) { + public Collection provideNodes(@NotNull final TreeElement node) { if (!(node instanceof HtmlFileTreeElement)) return Collections.emptyList(); final XmlFile xmlFile = ((HtmlFileTreeElement)node).getElement(); diff --git a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java b/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java index 8a9f6f7fe54b..9dff12f3f5b0 100644 --- a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java +++ b/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.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. @@ -37,6 +37,7 @@ class HtmlStructureViewTreeModel extends XmlStructureViewTreeModel implements Pl private String myStructureViewPlace; private static Sorter HTML_ALPHA_SORTER = new Sorter() { + @NotNull @Override public Comparator getComparator() { return new Comparator() { From bc83d3353ff99dbafa74cdf81a670b28a647c98f Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 19 Feb 2014 14:47:47 +0400 Subject: [PATCH 11/75] moved to core --- .../src/com/intellij/openapi/ide/CopyPasteManager.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename platform/{platform-api => core-api}/src/com/intellij/openapi/ide/CopyPasteManager.java (100%) diff --git a/platform/platform-api/src/com/intellij/openapi/ide/CopyPasteManager.java b/platform/core-api/src/com/intellij/openapi/ide/CopyPasteManager.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/ide/CopyPasteManager.java rename to platform/core-api/src/com/intellij/openapi/ide/CopyPasteManager.java From 9f266036b7bbc2f5486b818440698826140d1260 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 19 Feb 2014 15:35:51 +0400 Subject: [PATCH 12/75] moved to editor-ui --- .../com/intellij/openapi/fileEditor/NavigatableFileEditor.java | 2 +- .../src/com/intellij/openapi/fileEditor/TextEditor.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/fileEditor/NavigatableFileEditor.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/fileEditor/TextEditor.java (95%) diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/NavigatableFileEditor.java b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/NavigatableFileEditor.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/fileEditor/NavigatableFileEditor.java rename to platform/editor-ui-api/src/com/intellij/openapi/fileEditor/NavigatableFileEditor.java index c742e08b0824..3d9b84b6f44c 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/NavigatableFileEditor.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/NavigatableFileEditor.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. diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/TextEditor.java b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/TextEditor.java similarity index 95% rename from platform/platform-api/src/com/intellij/openapi/fileEditor/TextEditor.java rename to platform/editor-ui-api/src/com/intellij/openapi/fileEditor/TextEditor.java index 8c0578b8cf38..99d9b1444ff7 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/TextEditor.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/TextEditor.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. From 001957a7afe18287ea920abada48fc82d1827c3d Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 19 Feb 2014 17:54:34 +0400 Subject: [PATCH 13/75] moved to core --- .../{lang-api => core-api}/src/com/intellij/psi/tree/package.html | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename platform/{lang-api => core-api}/src/com/intellij/psi/tree/package.html (100%) diff --git a/platform/lang-api/src/com/intellij/psi/tree/package.html b/platform/core-api/src/com/intellij/psi/tree/package.html similarity index 100% rename from platform/lang-api/src/com/intellij/psi/tree/package.html rename to platform/core-api/src/com/intellij/psi/tree/package.html From 5f12f65a04b68a5477161ffa711c46d7435ab493 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 19 Feb 2014 18:18:04 +0400 Subject: [PATCH 14/75] moved to editor --- .../src/com/intellij/ui/PlaceHolder.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) rename platform/{platform-api => editor-ui-api}/src/com/intellij/ui/PlaceHolder.java (85%) diff --git a/platform/platform-api/src/com/intellij/ui/PlaceHolder.java b/platform/editor-ui-api/src/com/intellij/ui/PlaceHolder.java similarity index 85% rename from platform/platform-api/src/com/intellij/ui/PlaceHolder.java rename to platform/editor-ui-api/src/com/intellij/ui/PlaceHolder.java index 88f4d0a140fc..0c78ac10ccc6 100644 --- a/platform/platform-api/src/com/intellij/ui/PlaceHolder.java +++ b/platform/editor-ui-api/src/com/intellij/ui/PlaceHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +15,11 @@ */ package com.intellij.ui; +import org.jetbrains.annotations.NotNull; + /** * @author Konstantin Bulenkov */ public interface PlaceHolder extends PlaceProvider { - void setPlace(Place place); + void setPlace(@NotNull Place place); } From 3c9e26a0eba86b30a1db5a9b11635a541eed8784 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 19 Feb 2014 18:20:03 +0400 Subject: [PATCH 15/75] removed dependency on FileEditorManager --- .../com/intellij/psi/util/PsiEditorUtil.java | 33 +++++++++++++++++++ .../com/intellij/psi/util/PsiUtilBase.java | 17 +++++----- resources/src/META-INF/IdeaPlugin.xml | 2 ++ 3 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 platform/editor-ui-api/src/com/intellij/psi/util/PsiEditorUtil.java diff --git a/platform/editor-ui-api/src/com/intellij/psi/util/PsiEditorUtil.java b/platform/editor-ui-api/src/com/intellij/psi/util/PsiEditorUtil.java new file mode 100644 index 000000000000..0f0f0879f79c --- /dev/null +++ b/platform/editor-ui-api/src/com/intellij/psi/util/PsiEditorUtil.java @@ -0,0 +1,33 @@ +/* + * 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.psi.util; + +import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.editor.Editor; +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public interface PsiEditorUtil { + @Nullable + Editor findEditorByPsiElement(@NotNull PsiElement element); + + class Service { + public static PsiEditorUtil getInstance() { + return ServiceManager.getService(PsiEditorUtil.class); + } + } +} diff --git a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java index 1cb4441d20b2..b85fcd8796fa 100644 --- a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java +++ b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java @@ -32,10 +32,8 @@ import com.intellij.openapi.fileEditor.TextEditor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.AsyncResult; import com.intellij.openapi.util.TextRange; -import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VFileProperty; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.VirtualFileSystem; import com.intellij.psi.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -43,7 +41,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.*; -public class PsiUtilBase extends PsiUtilCore { +public class PsiUtilBase extends PsiUtilCore implements PsiEditorUtil { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.util.PsiUtilBase"); public static final Comparator LANGUAGE_COMPARATOR = new Comparator() { @Override @@ -207,6 +205,12 @@ public class PsiUtilBase extends PsiUtilCore { while (true); } + @Nullable + @Override + public Editor findEditorByPsiElement(@NotNull PsiElement element) { + return findEditor(element); + } + /** * Tries to find editor for the given element. *

@@ -232,8 +236,7 @@ public class PsiUtilBase extends PsiUtilCore { return null; } - VirtualFileSystem fileSystem = virtualFile.getFileSystem(); - if (fileSystem instanceof LocalFileSystem) { + if (virtualFile.isInLocalFileSystem()) { // Try to find editor for the real file. final FileEditor[] editors = FileEditorManager.getInstance(psiFile.getProject()).getEditors(virtualFile); for (FileEditor editor : editors) { @@ -270,8 +273,6 @@ public class PsiUtilBase extends PsiUtilCore { PsiFileSystemItem psiFileSystemItem = (PsiFileSystemItem)element; return psiFileSystemItem.isValid() ? psiFileSystemItem.getVirtualFile() : null; } - else { - return null; - } + return null; } } diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index e6d8f987a166..ed828dfb3200 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -350,6 +350,8 @@ + From a4b11059fbce7e7f1c83fa9d5556b196032c1814 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 19 Feb 2014 18:32:29 +0400 Subject: [PATCH 16/75] cleanup --- .../impl/AddAllMembersProcessor.java | 5 +++-- .../impl/StructureNodeRenderer.java | 6 ++++-- .../impl/java/ClassInitializerTreeElement.java | 7 ++++++- .../structureView/impl/java/FieldsFilter.java | 6 +++++- .../impl/java/InheritedMembersFilter.java | 8 +++++++- .../impl/java/JavaAnonymousClassTreeElement.java | 4 ++-- .../java/JavaAnonymousClassesNodeProvider.java | 16 +++++++++------- .../impl/java/JavaClassTreeElement.java | 5 ++++- .../impl/java/JavaClassTreeElementBase.java | 4 +++- .../impl/java/JavaFileTreeElement.java | 4 +++- .../impl/java/JavaFileTreeModel.java | 4 ++-- .../ide/structureView/impl/java/KindSorter.java | 5 +++++ .../impl/java/PropertiesGrouper.java | 3 +++ .../structureView/impl/java/PropertyGroup.java | 9 +++++++++ .../impl/java/PsiFieldTreeElement.java | 3 +++ .../impl/java/PublicElementsFilter.java | 6 +++++- .../structureView/impl/java/SuperTypeGroup.java | 7 +++++++ .../impl/java/SuperTypesGrouper.java | 3 +++ .../impl/java/VisibilityComparator.java | 7 ++----- .../impl/java/VisibilitySorter.java | 7 +++++++ .../ide/util/treeView/SourceComparator.java | 3 ++- .../lang/java/JavaAnonymousClassesProvider.java | 6 ++++-- .../navigation/AnonymousElementProvider.java | 6 ++++-- .../intellij/ide/actions/GotoClassAction.java | 9 +++++---- 24 files changed, 107 insertions(+), 36 deletions(-) diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java b/java/java-impl/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java index 952c929e2e0d..f692c8ff50da 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.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. @@ -34,7 +34,7 @@ public class AddAllMembersProcessor extends BaseScopeProcessor { private final PsiClass myPsiClass; private final Map myMethodsBySignature = new HashMap(); - public AddAllMembersProcessor(Collection allMembers, PsiClass psiClass) { + public AddAllMembersProcessor(@NotNull Collection allMembers, @NotNull PsiClass psiClass) { for (PsiElement psiElement : allMembers) { if (psiElement instanceof PsiMethod) mapMethodBySignature((PsiMethod)psiElement); } @@ -42,6 +42,7 @@ public class AddAllMembersProcessor extends BaseScopeProcessor { myPsiClass = psiClass; } + @Override public boolean execute(@NotNull PsiElement element, ResolveState state) { PsiMember member = (PsiMember)element; if (!isInteresting(element)) return true; diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/StructureNodeRenderer.java b/java/java-impl/src/com/intellij/ide/structureView/impl/StructureNodeRenderer.java index b264b488430e..0ed2b58372d2 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/StructureNodeRenderer.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/StructureNodeRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,13 +26,15 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMember; import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.SimpleTextAttributes; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeNode; public class StructureNodeRenderer extends ColoredTreeCellRenderer { - public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { + @Override + public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { forNodeDescriptorInTree(value, expanded).customize(this); } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java index ccf7c6a30dc2..52119084e8e2 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.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. @@ -31,6 +31,7 @@ public class ClassInitializerTreeElement extends PsiTreeElementBase getChildrenBase() { return Collections.emptyList(); } + @Override public int getAccessLevel() { return PsiUtil.ACCESS_LEVEL_PRIVATE; } + @Override public int getSubLevel() { return 0; } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/FieldsFilter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/FieldsFilter.java index da430a0798e8..acea371cbad2 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/FieldsFilter.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/FieldsFilter.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. @@ -27,20 +27,24 @@ import org.jetbrains.annotations.NotNull; public class FieldsFilter implements Filter{ @NonNls public static final String ID = "SHOW_FIELDS"; + @Override public boolean isVisible(TreeElement treeNode) { return !(treeNode instanceof PsiFieldTreeElement); } + @Override @NotNull public ActionPresentation getPresentation() { return new ActionPresentationData(IdeBundle.message("action.structureview.show.fields"), null, PlatformIcons.FIELD_ICON); } + @Override @NotNull public String getName() { return ID; } + @Override public boolean isReverted() { return true; } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java index b176cc00325d..9e7c70565754 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.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. @@ -29,6 +29,7 @@ import org.jetbrains.annotations.NotNull; public class InheritedMembersFilter implements FileStructureFilter { @NonNls public static final String ID = "SHOW_INHERITED"; + @Override public boolean isVisible(TreeElement treeNode) { if (treeNode instanceof JavaClassTreeElementBase) { return !((JavaClassTreeElementBase)treeNode).isInherited(); @@ -38,24 +39,29 @@ public class InheritedMembersFilter implements FileStructureFilter { } } + @Override @NotNull public ActionPresentation getPresentation() { return new ActionPresentationData(IdeBundle.message("action.structureview.show.inherited"), null, AllIcons.Hierarchy.Supertypes); } + @Override @NotNull public String getName() { return ID; } + @Override public boolean isReverted() { return true; } + @Override public String getCheckBoxText() { return IdeBundle.message("file.structure.toggle.show.inherited"); } + @Override public Shortcut[] getShortcut() { return KeymapManager.getInstance().getActiveKeymap().getShortcuts("FileStructurePopup"); } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassTreeElement.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassTreeElement.java index 6c3cd1a0dbfc..2905a6ffaa4d 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassTreeElement.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassTreeElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import java.util.Set; * @author Konstantin Bulenkov */ public class JavaAnonymousClassTreeElement extends JavaClassTreeElement { - public final static JavaAnonymousClassTreeElement[] EMPTY_ARRAY = {}; + public static final JavaAnonymousClassTreeElement[] EMPTY_ARRAY = {}; private String myName; private String myBaseName; diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java index 557c0fe716c5..63de94431218 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java @@ -50,14 +50,16 @@ public class JavaAnonymousClassesNodeProvider implements FileStructureNodeProvid public Collection provideNodes(@NotNull TreeElement node) { if (node instanceof PsiMethodTreeElement || node instanceof PsiFieldTreeElement || node instanceof ClassInitializerTreeElement) { final PsiElement el = ((PsiTreeElementBase)node).getElement(); - for (AnonymousElementProvider provider : Extensions.getExtensions(AnonymousElementProvider.EP_NAME)) { - final PsiElement[] elements = provider.getAnonymousElements(el); - if (elements != null && elements.length > 0) { - List result = new ArrayList(elements.length); - for (PsiElement element : elements) { - result.add(new JavaAnonymousClassTreeElement((PsiAnonymousClass)element, new HashSet())); + if (el != null) { + for (AnonymousElementProvider provider : Extensions.getExtensions(AnonymousElementProvider.EP_NAME)) { + final PsiElement[] elements = provider.getAnonymousElements(el); + if (elements.length > 0) { + List result = new ArrayList(elements.length); + for (PsiElement element : elements) { + result.add(new JavaAnonymousClassTreeElement((PsiAnonymousClass)element, new HashSet())); + } + return result; } - return result; } } } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElement.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElement.java index cbae41312814..354ccf38ad48 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElement.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElement.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. @@ -35,6 +35,7 @@ public class JavaClassTreeElement extends JavaClassTreeElementBase { myParents.add(cls); } + @Override @NotNull public Collection getChildrenBase() { return getClassChildren(); @@ -89,10 +90,12 @@ public class JavaClassTreeElement extends JavaClassTreeElementBase { return myParents; } + @Override public String getPresentableText() { return getElement().getName(); } + @Override public boolean isPublic() { return getElement().getParent() instanceof PsiFile || super.isPublic(); } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElementBase.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElementBase.java index 817e170cbee0..50cc8c4cd5e4 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElementBase.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElementBase.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. @@ -46,6 +46,7 @@ public abstract class JavaClassTreeElementBase extends return !(element instanceof PsiModifierListOwner) || ((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.PUBLIC); } + @Override public int getAccessLevel() { final PsiModifierList modifierList = ((PsiModifierListOwner)getElement()).getModifierList(); if (modifierList == null) { @@ -54,6 +55,7 @@ public abstract class JavaClassTreeElementBase extends return PsiUtil.getAccessLevel(modifierList); } + @Override public int getSubLevel() { return 0; } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeElement.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeElement.java index 56a993ca1c88..ca9ace511002 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeElement.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeElement.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. @@ -31,10 +31,12 @@ public class JavaFileTreeElement extends PsiTreeElementBase imple super(file); } + @Override public String getPresentableText() { return getElement().getName(); } + @Override @NotNull public Collection getChildrenBase() { PsiClass[] classes = getElement().getClasses(); diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java index 962bf5f2c436..609dc1570a46 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.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. @@ -130,7 +130,7 @@ public class JavaFileTreeModel extends TextEditorBasedStructureViewModel impleme } @Override - public void setPlace(String place) { + public void setPlace(@NotNull String place) { myPlace = place; } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.java index f1cdf3e6ccb4..37cc7454abe2 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.java @@ -32,6 +32,7 @@ public class KindSorter implements Sorter { boolean isPopup = false; private final Comparator COMPARATOR = new Comparator() { + @Override public int compare(final Object o1, final Object o2) { return getWeight(o1) - getWeight(o2); } @@ -65,20 +66,24 @@ public class KindSorter implements Sorter { } }; + @Override @NotNull public Comparator getComparator() { return COMPARATOR; } + @Override public boolean isVisible() { return false; } + @Override @NotNull public ActionPresentation getPresentation() { throw new IllegalStateException(); } + @Override @NotNull public String getName() { return ID; diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java index 5333306d7d24..e86b733efd61 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java @@ -32,6 +32,7 @@ import java.util.Map; public class PropertiesGrouper implements Grouper{ @NonNls public static final String ID = "SHOW_PROPERTIES"; + @Override @NotNull public Collection group(@NotNull final AbstractTreeNode parent, @NotNull Collection children) { if (parent.getValue() instanceof PropertyGroup) return Collections.emptyList(); @@ -60,11 +61,13 @@ public class PropertiesGrouper implements Grouper{ return result.values(); } + @Override @NotNull public ActionPresentation getPresentation() { return new ActionPresentationData(IdeBundle.message("action.structureview.show.properties"), null, PlatformIcons.PROPERTY_ICON); } + @Override @NotNull public String getName() { return ID; diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java index d66464e2af23..fca67160401e 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java @@ -90,16 +90,19 @@ public class PropertyGroup implements Group, ColoredItemPresentation, AccessLeve return null; } + @Override @NotNull public Collection getChildren() { return myChildren; } + @Override @NotNull public ItemPresentation getPresentation() { return this; } + @Override public Icon getIcon(boolean open) { if (isStatic()) { if (getGetter() != null && getSetter() != null) { @@ -130,10 +133,12 @@ public class PropertyGroup implements Group, ColoredItemPresentation, AccessLeve return myIsStatic; } + @Override public String getLocationString() { return null; } + @Override public String getPresentableText() { return myPropertyName + ": " + myPropertyType.getPresentableText(); } @@ -176,6 +181,7 @@ public class PropertyGroup implements Group, ColoredItemPresentation, AccessLeve return PropertyUtil.suggestGetterName(myPropertyName, myPropertyType); } + @Override public int getAccessLevel() { int result = PsiUtil.ACCESS_LEVEL_PRIVATE; if (getGetter() != null) { @@ -190,6 +196,7 @@ public class PropertyGroup implements Group, ColoredItemPresentation, AccessLeve return result; } + @Override public int getSubLevel() { return 0; } @@ -237,6 +244,7 @@ public class PropertyGroup implements Group, ColoredItemPresentation, AccessLeve return icon; } + @Override public TextAttributesKey getTextAttributesKey() { return isDeprecated() ? CodeInsightColors.DEPRECATED_ATTRIBUTES : null; } @@ -260,6 +268,7 @@ public class PropertyGroup implements Group, ColoredItemPresentation, AccessLeve return this; } + @Override public int getWeight() { return 60; } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java index 1661596af0cf..48b60e438ecc 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java @@ -31,11 +31,13 @@ public class PsiFieldTreeElement extends JavaClassTreeElementBase impl super(isInherited,field); } + @Override @NotNull public Collection getChildrenBase() { return Collections.emptyList(); } + @Override public String getPresentableText() { return StringUtil.replace(PsiFormatUtil.formatVariable( getElement(), @@ -48,6 +50,7 @@ public class PsiFieldTreeElement extends JavaClassTreeElementBase impl return getElement(); } + @Override @NotNull public String getAlphaSortKey() { final PsiField field = getElement(); diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java index 79ecfac42eb4..5fb718fa3d31 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.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. @@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull; public class PublicElementsFilter implements Filter{ @NonNls public static final String ID = "SHOW_NON_PUBLIC"; + @Override public boolean isVisible(TreeElement treeNode) { if (treeNode instanceof JavaClassTreeElementBase) { return ((JavaClassTreeElementBase)treeNode).isPublic(); @@ -36,16 +37,19 @@ public class PublicElementsFilter implements Filter{ } } + @Override @NotNull public ActionPresentation getPresentation() { return new ActionPresentationData(IdeBundle.message("action.structureview.show.non.public"), null, PlatformIcons.PRIVATE_ICON); } + @Override @NotNull public String getName() { return ID; } + @Override public boolean isReverted() { return true; } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java index c2e2d58bcc12..049ecf2145ce 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java @@ -48,6 +48,7 @@ public class SuperTypeGroup implements Group, ItemPresentation, AccessLevelProvi mySuperClassPointer = SmartPointerManager.getInstance(superClass.getProject()).createSmartPsiElementPointer(superClass); } + @Override @NotNull public Collection getChildren() { return myChildren; @@ -58,11 +59,13 @@ public class SuperTypeGroup implements Group, ItemPresentation, AccessLevelProvi return (PsiClass)mySuperClassPointer.getElement(); } + @Override @NotNull public ItemPresentation getPresentation() { return this; } + @Override public Icon getIcon(boolean open) { switch (myOverrides) { case IMPLEMENTS: @@ -76,10 +79,12 @@ public class SuperTypeGroup implements Group, ItemPresentation, AccessLevelProvi return null; // Can't be } + @Override public String getLocationString() { return null; } + @Override public String getPresentableText() { return toString(); } @@ -111,12 +116,14 @@ public class SuperTypeGroup implements Group, ItemPresentation, AccessLevelProvi return this; } + @Override public int getAccessLevel() { final PsiClass superClass = getSuperClass(); PsiModifierList modifierList = superClass == null ? null : superClass.getModifierList(); return modifierList == null ? PsiUtil.ACCESS_LEVEL_PUBLIC : PsiUtil.getAccessLevel(modifierList); } + @Override public int getSubLevel() { return 1; } diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java index cfa6d009293a..1e95ac69887e 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java @@ -37,6 +37,7 @@ public class SuperTypesGrouper implements Grouper{ public static final Key> SUPER_METHOD_KEY = Key.create("StructureTreeBuilder.SUPER_METHOD_KEY"); @NonNls public static final String ID = "SHOW_INTERFACES"; + @Override @NotNull public Collection group(@NotNull final AbstractTreeNode parent, @NotNull Collection children) { if (isParentGrouped(parent)) return Collections.emptyList(); @@ -112,12 +113,14 @@ public class SuperTypesGrouper implements Grouper{ } + @Override @NotNull public ActionPresentation getPresentation() { return new ActionPresentationData(IdeBundle.message("action.structureview.group.methods.by.defining.type"), null, AllIcons.General.ImplementingMethod); } + @Override @NotNull public String getName() { return ID; diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java index 8320959f32b7..73eafed137b8 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.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. @@ -15,8 +15,6 @@ */ package com.intellij.ide.structureView.impl.java; -import com.intellij.ide.util.treeView.AlphaComparator; -import com.intellij.ide.util.treeView.SourceComparator; import com.intellij.openapi.diagnostic.Logger; import org.jetbrains.annotations.NotNull; @@ -25,8 +23,6 @@ import java.util.Comparator; public class VisibilityComparator implements Comparator { private static final Logger LOG = Logger.getInstance("#com.intellij.ide.structureView.impl.java.VisibilityComparator"); private static final int GROUP_ACCESS_SUBLEVEL = 1; - public static Comparator THEN_SOURCE = new VisibilityComparator(SourceComparator.INSTANCE); - public static Comparator THEN_ALPHA = new VisibilityComparator(AlphaComparator.INSTANCE); public static Comparator IMSTANCE = new VisibilityComparator(null); private final Comparator myNextComparator; @@ -36,6 +32,7 @@ public class VisibilityComparator implements Comparator { myNextComparator = comparator; } + @Override public int compare(@NotNull Object descriptor1, @NotNull Object descriptor2) { int accessLevel1 = getAccessLevel(descriptor1); int accessLevel2 = getAccessLevel(descriptor2); diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java index b9f149261c6e..d509c77f56b2 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java @@ -30,35 +30,42 @@ public class VisibilitySorter implements Sorter{ public static final Sorter INSTANCE = new VisibilitySorter(); private static final ActionPresentation PRESENTATION = new ActionPresentation() { + @Override @NotNull public String getText() { return IdeBundle.message("action.structureview.sort.by.visibility"); } + @Override public String getDescription() { return null; } + @Override public Icon getIcon() { return AllIcons.ObjectBrowser.VisibilitySort; } }; @NonNls public static final String ID = "VISIBILITY_SORTER"; + @Override @NotNull public Comparator getComparator() { return VisibilityComparator.IMSTANCE; } + @Override public boolean isVisible() { return true; } + @Override @NotNull public ActionPresentation getPresentation() { return PRESENTATION; } + @Override @NotNull public String getName() { return ID; diff --git a/java/java-impl/src/com/intellij/ide/util/treeView/SourceComparator.java b/java/java-impl/src/com/intellij/ide/util/treeView/SourceComparator.java index 3b9e17b2fbb1..7456bdcb192f 100644 --- a/java/java-impl/src/com/intellij/ide/util/treeView/SourceComparator.java +++ b/java/java-impl/src/com/intellij/ide/util/treeView/SourceComparator.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. @@ -28,6 +28,7 @@ public class SourceComparator implements Comparator{ private SourceComparator() { } + @Override public int compare(NodeDescriptor nodeDescriptor1, NodeDescriptor nodeDescriptor2) { int weight1 = getWeight(nodeDescriptor1); int weight2 = getWeight(nodeDescriptor2); diff --git a/java/java-impl/src/com/intellij/lang/java/JavaAnonymousClassesProvider.java b/java/java-impl/src/com/intellij/lang/java/JavaAnonymousClassesProvider.java index 0d01c1b762e1..5e5fa498bdc4 100644 --- a/java/java-impl/src/com/intellij/lang/java/JavaAnonymousClassesProvider.java +++ b/java/java-impl/src/com/intellij/lang/java/JavaAnonymousClassesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.intellij.lang.java; import com.intellij.navigation.AnonymousElementProvider; import com.intellij.psi.*; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -25,8 +26,9 @@ import java.util.List; * @author Konstantin Bulenkov */ public class JavaAnonymousClassesProvider implements AnonymousElementProvider { + @NotNull @Override - public PsiElement[] getAnonymousElements(PsiElement parent) { + public PsiElement[] getAnonymousElements(@NotNull PsiElement parent) { if (suite(parent)) { if (parent instanceof PsiCompiledElement) { parent = parent.getNavigationElement(); diff --git a/platform/lang-api/src/com/intellij/navigation/AnonymousElementProvider.java b/platform/lang-api/src/com/intellij/navigation/AnonymousElementProvider.java index 2d56cd99c7f3..f7369ca57278 100644 --- a/platform/lang-api/src/com/intellij/navigation/AnonymousElementProvider.java +++ b/platform/lang-api/src/com/intellij/navigation/AnonymousElementProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.intellij.navigation; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; /** * @author Konstantin Bulenkov @@ -24,5 +25,6 @@ import com.intellij.psi.PsiElement; public interface AnonymousElementProvider { ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.anonymousElementProvider"); - PsiElement[] getAnonymousElements(PsiElement parent); + @NotNull + PsiElement[] getAnonymousElements(@NotNull PsiElement parent); } diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GotoClassAction.java b/platform/lang-impl/src/com/intellij/ide/actions/GotoClassAction.java index 7070b065c959..8b44a0ece134 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/GotoClassAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/GotoClassAction.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. @@ -185,7 +185,7 @@ public class GotoClassAction extends GotoActionBase implements DumbAware { return null; } - private static PsiElement getElement(PsiElement element, ChooseByNamePopup popup) { + private static PsiElement getElement(@NotNull PsiElement element, ChooseByNamePopup popup) { final String path = popup.getPathToAnonymous(); if (path != null) { final String[] classes = path.split("\\$"); @@ -214,10 +214,11 @@ public class GotoClassAction extends GotoActionBase implements DumbAware { return element; } - static PsiElement[] getAnonymousClasses(PsiElement element) { + @NotNull + private static PsiElement[] getAnonymousClasses(@NotNull PsiElement element) { for (AnonymousElementProvider provider : Extensions.getExtensions(AnonymousElementProvider.EP_NAME)) { final PsiElement[] elements = provider.getAnonymousElements(element); - if (elements != null && elements.length > 0) { + if (elements.length > 0) { return elements; } } From 72e86eb2563dfb486a3b304148a2c94336667f39 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 19 Feb 2014 18:37:00 +0400 Subject: [PATCH 17/75] notnull --- .../ide/structureView/impl/java/InheritedMembersFilter.java | 2 ++ .../structureView/impl/java/JavaAnonymousMembersFilter.java | 6 ++++-- .../src/com/intellij/ide/util/FileStructureFilter.java | 5 ++++- .../python/structureView/PyInheritedMembersFilter.java | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java index 9e7c70565754..6d06d0e5c47d 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java @@ -56,11 +56,13 @@ public class InheritedMembersFilter implements FileStructureFilter { return true; } + @NotNull @Override public String getCheckBoxText() { return IdeBundle.message("file.structure.toggle.show.inherited"); } + @NotNull @Override public Shortcut[] getShortcut() { return KeymapManager.getInstance().getActiveKeymap().getShortcuts("FileStructurePopup"); diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousMembersFilter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousMembersFilter.java index fc91ca57ea01..d6d92b6a2655 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousMembersFilter.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousMembersFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,14 +30,16 @@ public class JavaAnonymousMembersFilter implements FileStructureFilter { private static final String ID = "SHOW_ANONYMOUS"; + @NotNull @Override public String getCheckBoxText() { return "Show Anonymous Classes"; } + @NotNull @Override public Shortcut[] getShortcut() { - return new Shortcut[0]; + return Shortcut.EMPTY_ARRAY; } @Override diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructureFilter.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructureFilter.java index 9c2f7b230ecc..f8fa7a877f40 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructureFilter.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructureFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,12 +18,15 @@ package com.intellij.ide.util; import com.intellij.ide.util.treeView.smartTree.Filter; import com.intellij.openapi.actionSystem.Shortcut; +import org.jetbrains.annotations.NotNull; /** * @author yole */ public interface FileStructureFilter extends Filter { + @NotNull String getCheckBoxText(); + @NotNull Shortcut[] getShortcut(); } diff --git a/python/src/com/jetbrains/python/structureView/PyInheritedMembersFilter.java b/python/src/com/jetbrains/python/structureView/PyInheritedMembersFilter.java index b61edd6e361a..2b5483f58891 100644 --- a/python/src/com/jetbrains/python/structureView/PyInheritedMembersFilter.java +++ b/python/src/com/jetbrains/python/structureView/PyInheritedMembersFilter.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. @@ -64,11 +64,13 @@ public class PyInheritedMembersFilter implements FileStructureFilter { AllIcons.Hierarchy.Supertypes); } + @NotNull @Override public String getCheckBoxText() { return IdeBundle.message("file.structure.toggle.show.inherited"); } + @NotNull @Override public Shortcut[] getShortcut() { return KeymapManager.getInstance().getActiveKeymap().getShortcuts("FileStructurePopup"); From 64b597f8c826c020fa88a2357926dc92447a5603 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 19 Feb 2014 18:40:56 +0400 Subject: [PATCH 18/75] notnull --- .../impl/java/JavaAnonymousClassesNodeProvider.java | 2 ++ .../src/com/intellij/ide/util/FileStructureNodeProvider.java | 5 ++++- .../com/intellij/ide/util/InheritedMembersNodeProvider.java | 4 +++- .../lang/html/structureView/Html5SectionsNodeProvider.java | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java index 63de94431218..fbfcaee40493 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java +++ b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java @@ -66,11 +66,13 @@ public class JavaAnonymousClassesNodeProvider implements FileStructureNodeProvid return Collections.emptyList(); } + @NotNull @Override public String getCheckBoxText() { return "Show Anonymous Classes"; } + @NotNull @Override public Shortcut[] getShortcut() { return new Shortcut[]{KeyboardShortcut.fromString(SystemInfo.isMac ? "meta I" : "control I")}; diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructureNodeProvider.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructureNodeProvider.java index 524354442e1b..2bf37e2635c1 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructureNodeProvider.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructureNodeProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,12 +18,15 @@ package com.intellij.ide.util; import com.intellij.ide.util.treeView.smartTree.NodeProvider; import com.intellij.ide.util.treeView.smartTree.TreeElement; import com.intellij.openapi.actionSystem.Shortcut; +import org.jetbrains.annotations.NotNull; /** * @author Konstantin Bulenkov */ public interface FileStructureNodeProvider extends NodeProvider { + @NotNull String getCheckBoxText(); + @NotNull Shortcut[] getShortcut(); } diff --git a/platform/lang-impl/src/com/intellij/ide/util/InheritedMembersNodeProvider.java b/platform/lang-impl/src/com/intellij/ide/util/InheritedMembersNodeProvider.java index 1ffb48293675..3b7a1d6257b9 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/InheritedMembersNodeProvider.java +++ b/platform/lang-impl/src/com/intellij/ide/util/InheritedMembersNodeProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,11 +31,13 @@ import org.jetbrains.annotations.NotNull; public abstract class InheritedMembersNodeProvider implements FileStructureNodeProvider { @NonNls public static final String ID = "SHOW_INHERITED"; + @NotNull @Override public String getCheckBoxText() { return IdeBundle.message("file.structure.toggle.show.inherited"); } + @NotNull @Override public Shortcut[] getShortcut() { return KeymapManager.getInstance().getActiveKeymap().getShortcuts("FileStructurePopup"); diff --git a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java b/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java index 822086c4e90d..fb7e5a30caed 100644 --- a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java +++ b/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java @@ -53,11 +53,13 @@ public class Html5SectionsNodeProvider implements FileStructureNodeProvider Date: Thu, 20 Feb 2014 16:09:37 +0400 Subject: [PATCH 19/75] moved to editor-ui --- .../com/intellij/openapi/vcs/FileStatus.java | 6 +- .../openapi/vcs/FileStatusFactory.java | 68 +++++++++++++++++-- .../com/intellij/openapi/vcs/VcsBundle.java | 2 +- 3 files changed, 68 insertions(+), 8 deletions(-) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/vcs/FileStatus.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/vcs/FileStatusFactory.java (50%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/vcs/VcsBundle.java (97%) diff --git a/platform/platform-api/src/com/intellij/openapi/vcs/FileStatus.java b/platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatus.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/vcs/FileStatus.java rename to platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatus.java index 0dc2ca3b08c6..4b57f9cf327d 100644 --- a/platform/platform-api/src/com/intellij/openapi/vcs/FileStatus.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatus.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.intellij.openapi.vcs; import com.intellij.openapi.editor.colors.ColorKey; import com.intellij.ui.Gray; +import org.jetbrains.annotations.NotNull; import java.awt.*; @@ -24,7 +25,6 @@ public interface FileStatus { Color COLOR_NOT_CHANGED = null; // deliberately null, do not use hardcoded Color.BLACK Color COLOR_NOT_CHANGED_RECURSIVE = new Color(138, 164, 200); Color COLOR_NOT_CHANGED_IMMEDIATE = new Color(50, 100, 180); - Color t = new Color(47, 109, 255); Color COLOR_MERGE = new Color(117, 3, 220); Color COLOR_MODIFIED = new Color(0, 50, 160); @@ -63,7 +63,9 @@ public interface FileStatus { Color getColor(); + @NotNull ColorKey getColorKey(); + @NotNull String getId(); } diff --git a/platform/platform-api/src/com/intellij/openapi/vcs/FileStatusFactory.java b/platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatusFactory.java similarity index 50% rename from platform/platform-api/src/com/intellij/openapi/vcs/FileStatusFactory.java rename to platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatusFactory.java index 1227c9e7b6b1..cb5d4808b55d 100644 --- a/platform/platform-api/src/com/intellij/openapi/vcs/FileStatusFactory.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatusFactory.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. @@ -16,8 +16,9 @@ package com.intellij.openapi.vcs; import com.intellij.openapi.editor.colors.ColorKey; -import com.intellij.openapi.vcs.impl.FileStatusImpl; +import com.intellij.openapi.editor.colors.EditorColorsManager; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import java.awt.*; import java.util.ArrayList; @@ -30,13 +31,13 @@ public class FileStatusFactory { private FileStatusFactory() { } - public synchronized FileStatus createFileStatus(@NonNls String id, String description, Color color) { + public synchronized FileStatus createFileStatus(@NonNls @NotNull String id, @NotNull String description, Color color) { FileStatusImpl result = new FileStatusImpl(id, ColorKey.createColorKey("FILESTATUS_" + id, color), description); myStatuses.add(result); return result; } - public synchronized FileStatus createOnlyColorForFileStatus(@NonNls String id, final Color color) { + public synchronized FileStatus createOnlyColorForFileStatus(@NonNls @NotNull String id, final Color color) { FileStatus result = new FileStatusImpl.OnlyColorFileStatus(id, ColorKey.createColorKey("FILESTATUS_" + id, color), null); myStatuses.add(result); return result; @@ -50,4 +51,61 @@ public class FileStatusFactory { return ourInstance; } -} \ No newline at end of file + /** + * author: lesya + */ + private static class FileStatusImpl implements FileStatus { + private final String myStatus; + private final ColorKey myColorKey; + private final String myText; + + public FileStatusImpl(@NotNull String status, @NotNull ColorKey key, String text) { + myStatus = status; + myColorKey = key; + myText = text; + } + + public String toString() { + return myStatus; + } + + @Override + public String getText() { + return myText; + } + + @Override + public Color getColor() { + return EditorColorsManager.getInstance().getGlobalScheme().getColor(getColorKey()); + } + + @NotNull + @Override + public ColorKey getColorKey() { + return myColorKey; + } + + @NotNull + @Override + public String getId() { + return myStatus; + } + + private static class OnlyColorFileStatus extends FileStatusImpl { + public OnlyColorFileStatus(@NotNull String status, @NotNull ColorKey key, String text) { + super(status, key, text); + } + + @NotNull + @Override + public String getId() { + throw new UnsupportedOperationException(); + } + + @Override + public String getText() { + throw new UnsupportedOperationException(); + } + } + } +} diff --git a/platform/platform-api/src/com/intellij/openapi/vcs/VcsBundle.java b/platform/editor-ui-api/src/com/intellij/openapi/vcs/VcsBundle.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/vcs/VcsBundle.java rename to platform/editor-ui-api/src/com/intellij/openapi/vcs/VcsBundle.java index 20cf6cb389fd..531cb653ed63 100644 --- a/platform/platform-api/src/com/intellij/openapi/vcs/VcsBundle.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/vcs/VcsBundle.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. From a816b5d9aaf7b133a2312add0a1e00e4662cd957 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 20 Feb 2014 16:29:10 +0400 Subject: [PATCH 20/75] moved to editor-ui --- .../openapi/vcs/impl/FileStatusImpl.java | 73 ------------------- 1 file changed, 73 deletions(-) delete mode 100644 platform/platform-api/src/com/intellij/openapi/vcs/impl/FileStatusImpl.java diff --git a/platform/platform-api/src/com/intellij/openapi/vcs/impl/FileStatusImpl.java b/platform/platform-api/src/com/intellij/openapi/vcs/impl/FileStatusImpl.java deleted file mode 100644 index 6f1b9d1d5b59..000000000000 --- a/platform/platform-api/src/com/intellij/openapi/vcs/impl/FileStatusImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2000-2009 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.openapi.vcs.impl; - -import com.intellij.openapi.editor.colors.ColorKey; -import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.vcs.FileStatus; - -import java.awt.*; - -/** - * author: lesya - */ -public class FileStatusImpl implements FileStatus { - private final String myStatus; - private final ColorKey myColorKey; - private final String myText; - - public FileStatusImpl(String status, ColorKey key, String text) { - myStatus = status; - myColorKey = key; - myText = text; - } - - public String toString() { - return myStatus; - } - - public String getText() { - return myText; - } - - public Color getColor() { - return EditorColorsManager.getInstance().getGlobalScheme().getColor(getColorKey()); - } - - public ColorKey getColorKey() { - return myColorKey; - } - - public String getId() { - return myStatus; - } - - public static class OnlyColorFileStatus extends FileStatusImpl { - public OnlyColorFileStatus(String status, ColorKey key, String text) { - super(status, key, text); - } - - @Override - public String getId() { - throw new UnsupportedOperationException(); - } - - @Override - public String getText() { - throw new UnsupportedOperationException(); - } - } -} From 9a997d1b113d0108f7b350b6566f6e95800ba450 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 20 Feb 2014 16:32:12 +0400 Subject: [PATCH 21/75] moved to editor-ui --- .../src/com/intellij/openapi/fileEditor/FileEditor.java | 2 +- .../src/com/intellij/openapi/fileEditor/FileEditorLocation.java | 2 +- .../src/com/intellij/openapi/fileEditor/FileEditorState.java | 2 +- .../com/intellij/openapi/fileEditor/FileEditorStateLevel.java | 2 +- .../src/com/intellij/openapi/vcs/FileStatusListener.java | 0 .../src/com/intellij/openapi/vcs/FileStatusManager.java | 0 6 files changed, 4 insertions(+), 4 deletions(-) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/fileEditor/FileEditor.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/fileEditor/FileEditorLocation.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/fileEditor/FileEditorState.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/fileEditor/FileEditorStateLevel.java (94%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/vcs/FileStatusListener.java (100%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/vcs/FileStatusManager.java (100%) diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditor.java b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/FileEditor.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditor.java rename to platform/editor-ui-api/src/com/intellij/openapi/fileEditor/FileEditor.java index f22010baa31a..c251020aaf4f 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditor.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/FileEditor.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. diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorLocation.java b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/FileEditorLocation.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorLocation.java rename to platform/editor-ui-api/src/com/intellij/openapi/fileEditor/FileEditorLocation.java index 696c6b991127..e62f21841f78 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorLocation.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/FileEditorLocation.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. diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorState.java b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/FileEditorState.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorState.java rename to platform/editor-ui-api/src/com/intellij/openapi/fileEditor/FileEditorState.java index 277a679e2b92..f8557358ac00 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorState.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/FileEditorState.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. diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorStateLevel.java b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/FileEditorStateLevel.java similarity index 94% rename from platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorStateLevel.java rename to platform/editor-ui-api/src/com/intellij/openapi/fileEditor/FileEditorStateLevel.java index 4408f12db539..0cd2a91e0c49 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorStateLevel.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/FileEditorStateLevel.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. diff --git a/platform/platform-api/src/com/intellij/openapi/vcs/FileStatusListener.java b/platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatusListener.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vcs/FileStatusListener.java rename to platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatusListener.java diff --git a/platform/platform-api/src/com/intellij/openapi/vcs/FileStatusManager.java b/platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatusManager.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/vcs/FileStatusManager.java rename to platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatusManager.java From 8e385033b788ff8a5c925bdf77522aa86e7581af Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 20 Feb 2014 16:33:30 +0400 Subject: [PATCH 22/75] notnull --- .../structureView/StructureViewModelBase.java | 8 ++++--- .../ide/impl/StructureViewWrapperImpl.java | 24 +++++++++---------- .../vcs/impl/FileStatusManagerImpl.java | 12 ++++++---- .../structureView/SmartTreeStructureTest.java | 4 +++- .../HtmlStructureViewTreeModel.java | 2 +- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/platform/lang-api/src/com/intellij/ide/structureView/StructureViewModelBase.java b/platform/lang-api/src/com/intellij/ide/structureView/StructureViewModelBase.java index f38ef1503ddf..d30c5906f4bb 100644 --- a/platform/lang-api/src/com/intellij/ide/structureView/StructureViewModelBase.java +++ b/platform/lang-api/src/com/intellij/ide/structureView/StructureViewModelBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,12 +48,14 @@ public class StructureViewModelBase extends TextEditorBasedStructureViewModel { return myRoot; } - public StructureViewModelBase withSorters(Sorter... sorters) { + @NotNull + public StructureViewModelBase withSorters(@NotNull Sorter... sorters) { mySorters = sorters; return this; } - public StructureViewModelBase withSuitableClasses(Class... suitableClasses) { + @NotNull + public StructureViewModelBase withSuitableClasses(@NotNull Class... suitableClasses) { mySuitableClasses = suitableClasses; return this; } diff --git a/platform/lang-impl/src/com/intellij/ide/impl/StructureViewWrapperImpl.java b/platform/lang-impl/src/com/intellij/ide/impl/StructureViewWrapperImpl.java index ec026cacd275..048ca1d72427 100644 --- a/platform/lang-impl/src/com/intellij/ide/impl/StructureViewWrapperImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/impl/StructureViewWrapperImpl.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. @@ -56,6 +56,7 @@ import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -74,6 +75,7 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl private VirtualFile myFile; private StructureView myStructureView; + private FileEditor myFileEditor; private ModuleStructureComponent myModuleStructureComponent; private JPanel[] myPanels = new JPanel[0]; @@ -222,7 +224,7 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl @Override public void run() { if (myStructureView != null) { - if (!Comparing.equal(myStructureView.getFileEditor(), fileEditor)) { + if (!Comparing.equal(myFileEditor, fileEditor)) { myFile = file; rebuild(); } @@ -269,6 +271,7 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl myStructureView.storeState(); Disposer.dispose(myStructureView); myStructureView = null; + myFileEditor = null; } if (myModuleStructureComponent != null) { @@ -290,7 +293,7 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl } } - String[] names = new String[] {""}; + String[] names = {""}; JComponent focusedComponent = null; if (file != null && file.isValid()) { if (file.isDirectory()) { @@ -315,6 +318,7 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl final StructureViewBuilder structureViewBuilder = editor.getStructureViewBuilder(); if (structureViewBuilder != null) { myStructureView = structureViewBuilder.createStructureView(editor, myProject); + myFileEditor = editor; Disposer.register(this, myStructureView); updateHeaderActions(myStructureView); @@ -322,18 +326,17 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl ((StructureView.Scrollable)myStructureView).setReferenceSizeWhileInitializing(referenceSize); } - final StructureViewComposite.StructureViewDescriptor[] views; - if (myStructureView instanceof StructureViewComposite) { final StructureViewComposite composite = (StructureViewComposite)myStructureView; - views = composite.getStructureViews(); + final StructureViewComposite.StructureViewDescriptor[] views = composite.getStructureViews(); myPanels = new JPanel[views.length]; names = new String[views.length]; for (int i = 0; i < myPanels.length; i++) { myPanels[i] = createContentPanel(views[i].structureView.getComponent()); names[i] = views[i].title; } - } else { + } + else { createSinglePanel(myStructureView.getComponent()); } focusedComponent = hadFocus ? IdeFocusTraversalPolicy.getPreferredFocusedComponent(myStructureView.getComponent()) : null; @@ -393,15 +396,12 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl } @Nullable - private FileEditor createTempFileEditor(VirtualFile file) { + private FileEditor createTempFileEditor(@NotNull VirtualFile file) { if (file.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize()) return null; FileEditorProviderManager editorProviderManager = FileEditorProviderManager.getInstance(); final FileEditorProvider[] providers = editorProviderManager.getProviders(myProject, file); - for (FileEditorProvider provider : providers) { - return provider.createEditor(myProject, file); - } - return null; + return providers.length == 0 ? null : providers[0].createEditor(myProject, file); } diff --git a/platform/platform-impl/src/com/intellij/openapi/vcs/impl/FileStatusManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/vcs/impl/FileStatusManagerImpl.java index 29a1ab9c5d7c..c3d1ab0c66ec 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vcs/impl/FileStatusManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vcs/impl/FileStatusManagerImpl.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. @@ -80,11 +80,13 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC throw new AssertionError("Should not be called"); } + @NotNull @Override public ColorKey getColorKey() { throw new AssertionError("Should not be called"); } + @NotNull @Override public String getId() { throw new AssertionError("Should not be called"); @@ -175,7 +177,7 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC } @Override - public void addFileStatusListener(final FileStatusListener listener, Disposable parentDisposable) { + public void addFileStatusListener(@NotNull final FileStatusListener listener, @NotNull Disposable parentDisposable) { addFileStatusListener(listener); Disposer.register(parentDisposable, new Disposable() { @Override @@ -275,14 +277,14 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC } @Override - public void removeFileStatusListener(FileStatusListener listener) { + public void removeFileStatusListener(@NotNull FileStatusListener listener) { myListeners.remove(listener); } @Override - public Color getNotChangedDirectoryColor(VirtualFile vf) { + public Color getNotChangedDirectoryColor(@NotNull VirtualFile vf) { final Color notChangedColor = FileStatus.NOT_CHANGED.getColor(); - if (vf == null || !vf.isDirectory()) { + if (!vf.isDirectory()) { return notChangedColor; } final Boolean exactMatch = myWhetherExactlyParentToChanged.get(vf); diff --git a/platform/platform-tests/testSrc/com/intellij/structureView/SmartTreeStructureTest.java b/platform/platform-tests/testSrc/com/intellij/structureView/SmartTreeStructureTest.java index 2132deb33f1c..e62512ba0669 100644 --- a/platform/platform-tests/testSrc/com/intellij/structureView/SmartTreeStructureTest.java +++ b/platform/platform-tests/testSrc/com/intellij/structureView/SmartTreeStructureTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -123,6 +123,7 @@ public class SmartTreeStructureTest extends LightPlatformCodeInsightFixtureTestC public void testSorting() throws Exception { myModel.addSorter(new Sorter() { + @NotNull @Override public Comparator getComparator() { return new Comparator() { @@ -154,6 +155,7 @@ public class SmartTreeStructureTest extends LightPlatformCodeInsightFixtureTestC }); myModel.addSorter(new Sorter() { + @NotNull @Override public Comparator getComparator() { return new Comparator() { diff --git a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java b/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java index 9dff12f3f5b0..f4f080d43c26 100644 --- a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java +++ b/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java @@ -94,7 +94,7 @@ class HtmlStructureViewTreeModel extends XmlStructureViewTreeModel implements Pl } @Override - public void setPlace(final String place) { + public void setPlace(@NotNull final String place) { myStructureViewPlace = place; } From aa5bc164867d0fc52986fae250bab934c86b5259 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 20 Feb 2014 19:04:15 +0400 Subject: [PATCH 23/75] moved to core --- .../src/com/intellij/openapi/util/ActiveRunnable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename platform/{platform-api => core-api}/src/com/intellij/openapi/util/ActiveRunnable.java (96%) diff --git a/platform/platform-api/src/com/intellij/openapi/util/ActiveRunnable.java b/platform/core-api/src/com/intellij/openapi/util/ActiveRunnable.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/util/ActiveRunnable.java rename to platform/core-api/src/com/intellij/openapi/util/ActiveRunnable.java index f3b5e59d34e3..96e5630d1e5c 100644 --- a/platform/platform-api/src/com/intellij/openapi/util/ActiveRunnable.java +++ b/platform/core-api/src/com/intellij/openapi/util/ActiveRunnable.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. From b4d9fc6499761d08c048c288c155d8ecca9e5a7a Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 20 Feb 2014 19:08:04 +0400 Subject: [PATCH 24/75] notnull --- .../src/com/intellij/openapi/util/BusyObject.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/util/BusyObject.java b/platform/platform-api/src/com/intellij/openapi/util/BusyObject.java index 1343eac3745f..915bc15d7224 100644 --- a/platform/platform-api/src/com/intellij/openapi/util/BusyObject.java +++ b/platform/platform-api/src/com/intellij/openapi/util/BusyObject.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. @@ -26,6 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger; public interface BusyObject { + @NotNull ActionCallback getReady(@NotNull Object requestor); abstract class Impl implements BusyObject { @@ -66,9 +67,7 @@ public interface BusyObject { if (isReady()) { return new ActionCallback.Done(); } - else { - return addReadyCallback(requestor); - } + return addReadyCallback(requestor); } @NotNull @@ -84,6 +83,7 @@ public interface BusyObject { } } + @NotNull private ActionCallback[] getReadyCallbacks() { synchronized (myReadyCallbacks) { ActionCallback[] result = myReadyCallbacks.values().toArray(new ActionCallback[myReadyCallbacks.size()]); @@ -92,6 +92,7 @@ public interface BusyObject { } } + @NotNull private Pair> getReadyCallbacks(Object readyRequestor) { synchronized (myReadyCallbacks) { ActionCallback done = myReadyCallbacks.get(readyRequestor); From e5df149ed549eaeba80754af5432e4e742b0b062 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 20 Feb 2014 19:09:01 +0400 Subject: [PATCH 25/75] moved to core --- .../src/com/intellij/openapi/util/BusyObject.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename platform/{platform-api => core-api}/src/com/intellij/openapi/util/BusyObject.java (100%) diff --git a/platform/platform-api/src/com/intellij/openapi/util/BusyObject.java b/platform/core-api/src/com/intellij/openapi/util/BusyObject.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/util/BusyObject.java rename to platform/core-api/src/com/intellij/openapi/util/BusyObject.java From b53845bbc136ea8a0f269cb44b634b07a2c718f3 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 20 Feb 2014 19:09:44 +0400 Subject: [PATCH 26/75] notnull --- .../impl/AbstractProjectViewPane.java | 1 + .../ide/projectView/impl/ProjectViewImpl.java | 3 ++- .../intellij/ide/scopeView/ScopeViewPane.java | 4 ++-- .../fileEditor/impl/TestEditorManagerImpl.java | 3 ++- .../wm/impl/ToolWindowHeadlessManagerImpl.java | 4 +++- .../intellij/openapi/wm/impl/ToolWindowImpl.java | 3 ++- .../ui/content/impl/ContentManagerImpl.java | 3 ++- .../src/com/intellij/mock/Mock.java | 16 ++++++++++++++++ 8 files changed, 30 insertions(+), 7 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java index 34ccfc64504c..bb80f55237e5 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java @@ -672,6 +672,7 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl return dragAction == DnDConstants.ACTION_MOVE && MoveHandler.canMove(dataContext); } + @NotNull @Override public ActionCallback getReady(@NotNull Object requestor) { if (myTreeBuilder == null || myTreeBuilder.isDisposed()) return new ActionCallback.Rejected(); diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java index 55909752ab2f..c7a81cbd0cda 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.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. @@ -1858,6 +1858,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo return mySelectInTargets.values(); } + @NotNull @Override public ActionCallback getReady(@NotNull Object requestor) { AbstractProjectViewPane pane = myId2Pane.get(myCurrentViewSubId); diff --git a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java index 8fa7e9b054c0..ccacc10761b9 100644 --- a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java +++ b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,6 @@ import com.intellij.psi.PsiFileSystemItem; import com.intellij.psi.PsiManager; import com.intellij.psi.search.scope.NonProjectFilesScope; import com.intellij.psi.search.scope.packageSet.*; -import com.intellij.ui.PopupHandler; import com.intellij.util.Alarm; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NonNls; @@ -252,6 +251,7 @@ public class ScopeViewPane extends AbstractProjectViewPane { return myViewPanel != null ? myViewPanel.getData(dataId) : null; } + @NotNull @Override public ActionCallback getReady(@NotNull Object requestor) { final ActionCallback callback = myViewPanel.getActionCallback(); diff --git a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/TestEditorManagerImpl.java b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/TestEditorManagerImpl.java index beb9ee21bc93..79ac777a6fd8 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/TestEditorManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/TestEditorManagerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -485,6 +485,7 @@ public class TestEditorManagerImpl extends FileEditorManagerEx implements Applic return null; } + @NotNull @Override public ActionCallback getReady(@NotNull Object requestor) { return new ActionCallback.Done(); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.java index 952bb259a605..340ca8032263 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.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. @@ -85,6 +85,7 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx { return false; } + @NotNull @Override public ActionCallback getReady(@NotNull Object requestor) { return new ActionCallback.Done(); @@ -265,6 +266,7 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx { private final List myContents = new ArrayList(); private Content mySelected; + @NotNull @Override public ActionCallback getReady(@NotNull Object requestor) { return new ActionCallback.Done(); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java index cc9180e4c96e..ce09b94cc7fe 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.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. @@ -154,6 +154,7 @@ public final class ToolWindowImpl implements ToolWindowEx { return myToolWindowManager.isToolWindowActive(myId) || myDecorator != null && myDecorator.isFocused(); } + @NotNull @Override public ActionCallback getReady(@NotNull final Object requestor) { final ActionCallback result = new ActionCallback(); diff --git a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java index b38eaedd62e7..b6e739692ede 100644 --- a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.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. @@ -108,6 +108,7 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene return myComponent; } + @NotNull @Override public ActionCallback getReady(@NotNull Object requestor) { Content selected = getSelectedContent(); diff --git a/platform/testFramework/src/com/intellij/mock/Mock.java b/platform/testFramework/src/com/intellij/mock/Mock.java index 87e13adf2473..d511f2fd2d35 100644 --- a/platform/testFramework/src/com/intellij/mock/Mock.java +++ b/platform/testFramework/src/com/intellij/mock/Mock.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.mock; import com.intellij.codeHighlighting.BackgroundEditorHighlighter; @@ -135,6 +150,7 @@ public class Mock { return new ActionCallback.Done(); } + @NotNull @Override public ActionCallback getReady(@NotNull Object requestor) { return new ActionCallback.Done(); From e65df6584fd55be68cea7c6408e2c6f7e9e63078 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 20 Feb 2014 19:34:39 +0400 Subject: [PATCH 27/75] cleanup --- .../impl/java/InheritedMembersFilter.java | 70 ------------------- .../intellij/util/ui/update/Activatable.java | 4 +- 2 files changed, 3 insertions(+), 71 deletions(-) delete mode 100644 java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java deleted file mode 100644 index 6d06d0e5c47d..000000000000 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/InheritedMembersFilter.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.structureView.impl.java; - -import com.intellij.icons.AllIcons; -import com.intellij.ide.IdeBundle; -import com.intellij.ide.util.FileStructureFilter; -import com.intellij.ide.util.treeView.smartTree.ActionPresentation; -import com.intellij.ide.util.treeView.smartTree.ActionPresentationData; -import com.intellij.ide.util.treeView.smartTree.TreeElement; -import com.intellij.openapi.actionSystem.Shortcut; -import com.intellij.openapi.keymap.KeymapManager; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -public class InheritedMembersFilter implements FileStructureFilter { - @NonNls public static final String ID = "SHOW_INHERITED"; - - @Override - public boolean isVisible(TreeElement treeNode) { - if (treeNode instanceof JavaClassTreeElementBase) { - return !((JavaClassTreeElementBase)treeNode).isInherited(); - } - else { - return true; - } - } - - @Override - @NotNull - public ActionPresentation getPresentation() { - return new ActionPresentationData(IdeBundle.message("action.structureview.show.inherited"), null, AllIcons.Hierarchy.Supertypes); - } - - @Override - @NotNull - public String getName() { - return ID; - } - - @Override - public boolean isReverted() { - return true; - } - - @NotNull - @Override - public String getCheckBoxText() { - return IdeBundle.message("file.structure.toggle.show.inherited"); - } - - @NotNull - @Override - public Shortcut[] getShortcut() { - return KeymapManager.getInstance().getActiveKeymap().getShortcuts("FileStructurePopup"); - } -} diff --git a/platform/platform-api/src/com/intellij/util/ui/update/Activatable.java b/platform/platform-api/src/com/intellij/util/ui/update/Activatable.java index d0cfc9f0159e..d840f992b561 100644 --- a/platform/platform-api/src/com/intellij/util/ui/update/Activatable.java +++ b/platform/platform-api/src/com/intellij/util/ui/update/Activatable.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. @@ -25,9 +25,11 @@ public interface Activatable { void hideNotify(); class Adapter implements Activatable { + @Override public void hideNotify() { } + @Override public void showNotify() { } } From cad71fe1cd5ad82029068dd2bda22e0eb3336399 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 20 Feb 2014 19:54:14 +0400 Subject: [PATCH 28/75] notnull --- .../impl/ClassesTreeStructureProvider.java | 6 ++++-- .../projectView/ClassNameConvertor.java | 18 +++++++++++++++++- .../projectView/ProjectViewUpdatingTest.java | 5 +++-- .../intellij/projectView/SameNamesJoiner.java | 18 +++++++++++++++++- .../ide/projectView/TreeStructureProvider.java | 6 ++++-- .../PlatformProjectViewStructureProvider.java | 6 ++++-- .../projectView/ResourceBundleGrouper.java | 6 ++++-- .../FormMergerTreeStructureProvider.java | 5 +++-- .../xslt/impl/XsltTreeStructureProvider.java | 6 ++++-- .../projectView/PyTreeStructureProvider.java | 6 ++++-- 10 files changed, 64 insertions(+), 18 deletions(-) diff --git a/java/java-impl/src/com/intellij/ide/projectView/impl/ClassesTreeStructureProvider.java b/java/java-impl/src/com/intellij/ide/projectView/impl/ClassesTreeStructureProvider.java index 518fb06fea75..7e0515726610 100644 --- a/java/java-impl/src/com/intellij/ide/projectView/impl/ClassesTreeStructureProvider.java +++ b/java/java-impl/src/com/intellij/ide/projectView/impl/ClassesTreeStructureProvider.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. @@ -29,6 +29,7 @@ import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.Computable; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes; @@ -42,8 +43,9 @@ public class ClassesTreeStructureProvider implements SelectableTreeStructureProv myProject = project; } + @NotNull @Override - public Collection modify(AbstractTreeNode parent, Collection children, ViewSettings settings) { + public Collection modify(@NotNull AbstractTreeNode parent, @NotNull Collection children, ViewSettings settings) { ArrayList result = new ArrayList(); for (final AbstractTreeNode child : children) { Object o = child.getValue(); diff --git a/java/java-tests/testSrc/com/intellij/projectView/ClassNameConvertor.java b/java/java-tests/testSrc/com/intellij/projectView/ClassNameConvertor.java index 65956b21a89b..b879fab12188 100644 --- a/java/java-tests/testSrc/com/intellij/projectView/ClassNameConvertor.java +++ b/java/java-tests/testSrc/com/intellij/projectView/ClassNameConvertor.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.projectView; import com.intellij.ide.projectView.PresentationData; @@ -23,8 +38,9 @@ class ClassNameConvertor implements TreeStructureProvider { myProject = project; } + @NotNull @Override - public Collection modify(AbstractTreeNode parent, Collection children, ViewSettings settings) { + public Collection modify(@NotNull AbstractTreeNode parent, @NotNull Collection children, ViewSettings settings) { ArrayList result = new ArrayList(); for (final AbstractTreeNode aChildren : children) { diff --git a/java/java-tests/testSrc/com/intellij/projectView/ProjectViewUpdatingTest.java b/java/java-tests/testSrc/com/intellij/projectView/ProjectViewUpdatingTest.java index dc7ab08b524b..8f95c73a6a11 100644 --- a/java/java-tests/testSrc/com/intellij/projectView/ProjectViewUpdatingTest.java +++ b/java/java-tests/testSrc/com/intellij/projectView/ProjectViewUpdatingTest.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. @@ -427,8 +427,9 @@ public class ProjectViewUpdatingTest extends BaseProjectViewTestCase { private TreeStructureProvider createWrapProvider(final NodeWrapper rootWrapper) { return new TreeStructureProvider() { + @NotNull @Override - public Collection modify(AbstractTreeNode parent, Collection children, ViewSettings settings) { + public Collection modify(@NotNull AbstractTreeNode parent, @NotNull Collection children, ViewSettings settings) { if (parent instanceof NodeWrapper) { return children; diff --git a/java/java-tests/testSrc/com/intellij/projectView/SameNamesJoiner.java b/java/java-tests/testSrc/com/intellij/projectView/SameNamesJoiner.java index a9efd3480a30..7b976f28b24d 100644 --- a/java/java-tests/testSrc/com/intellij/projectView/SameNamesJoiner.java +++ b/java/java-tests/testSrc/com/intellij/projectView/SameNamesJoiner.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.projectView; import com.intellij.ide.projectView.PresentationData; @@ -17,8 +32,9 @@ import java.util.Collection; import java.util.Iterator; class SameNamesJoiner implements TreeStructureProvider { + @NotNull @Override - public Collection modify(AbstractTreeNode parent, Collection children, ViewSettings settings) { + public Collection modify(@NotNull AbstractTreeNode parent, @NotNull Collection children, ViewSettings settings) { if (parent instanceof JoinedNode) return children; ArrayList result = new ArrayList(); diff --git a/platform/lang-api/src/com/intellij/ide/projectView/TreeStructureProvider.java b/platform/lang-api/src/com/intellij/ide/projectView/TreeStructureProvider.java index 0ecf0f2c90ef..315a41ec6a81 100644 --- a/platform/lang-api/src/com/intellij/ide/projectView/TreeStructureProvider.java +++ b/platform/lang-api/src/com/intellij/ide/projectView/TreeStructureProvider.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. @@ -17,6 +17,7 @@ package com.intellij.ide.projectView; import com.intellij.ide.util.treeView.AbstractTreeNode; import com.intellij.openapi.extensions.ExtensionPointName; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collection; @@ -38,7 +39,8 @@ public interface TreeStructureProvider { * @return the modified collection of child nodes, or children if no modifications * are required. */ - Collection modify(AbstractTreeNode parent, Collection children, ViewSettings settings); + @NotNull + Collection modify(@NotNull AbstractTreeNode parent, @NotNull Collection children, ViewSettings settings); /** * Returns a user data object of the specified type for the specified selection in the diff --git a/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewStructureProvider.java b/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewStructureProvider.java index d0cccf1844f7..ab08ce6d9091 100644 --- a/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewStructureProvider.java +++ b/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewStructureProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDirectory; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Collection; @@ -41,8 +42,9 @@ public class PlatformProjectViewStructureProvider implements TreeStructureProvid myProject = project; } + @NotNull @Override - public Collection modify(final AbstractTreeNode parent, final Collection children, final ViewSettings settings) { + public Collection modify(@NotNull final AbstractTreeNode parent, @NotNull final Collection children, final ViewSettings settings) { if (parent instanceof PsiDirectoryNode) { final VirtualFile vFile = ((PsiDirectoryNode)parent).getVirtualFile(); if (vFile != null && Comparing.equal(ProjectFileIndex.SERVICE.getInstance(myProject).getContentRootForFile(vFile), vFile)) { diff --git a/plugins/properties/src/com/intellij/lang/properties/projectView/ResourceBundleGrouper.java b/plugins/properties/src/com/intellij/lang/properties/projectView/ResourceBundleGrouper.java index 3394011ab309..fca0b172c561 100644 --- a/plugins/properties/src/com/intellij/lang/properties/projectView/ResourceBundleGrouper.java +++ b/plugins/properties/src/com/intellij/lang/properties/projectView/ResourceBundleGrouper.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. @@ -29,6 +29,7 @@ import com.intellij.openapi.util.Computable; import com.intellij.psi.PsiFile; import com.intellij.util.SmartList; import gnu.trove.THashMap; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Collection; @@ -42,7 +43,8 @@ public class ResourceBundleGrouper implements TreeStructureProvider, DumbAware { myProject = project; } - public Collection modify(AbstractTreeNode parent, final Collection children, final ViewSettings settings) { + @NotNull + public Collection modify(@NotNull AbstractTreeNode parent, @NotNull final Collection children, final ViewSettings settings) { if (parent instanceof ResourceBundleNode) return children; return ApplicationManager.getApplication().runReadAction(new Computable>() { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/projectView/FormMergerTreeStructureProvider.java b/plugins/ui-designer/src/com/intellij/uiDesigner/projectView/FormMergerTreeStructureProvider.java index 5c6786eaaa76..aed97d66243d 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/projectView/FormMergerTreeStructureProvider.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/projectView/FormMergerTreeStructureProvider.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. @@ -43,7 +43,8 @@ public class FormMergerTreeStructureProvider implements TreeStructureProvider { myProject = project; } - public Collection modify(AbstractTreeNode parent, Collection children, ViewSettings settings) { + @NotNull + public Collection modify(@NotNull AbstractTreeNode parent, @NotNull Collection children, ViewSettings settings) { if (parent.getValue() instanceof Form) return children; // Optimization. Check if there are any forms at all. diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltTreeStructureProvider.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltTreeStructureProvider.java index 5bb3a31cff75..78dd117627a4 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltTreeStructureProvider.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/impl/XsltTreeStructureProvider.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. @@ -28,6 +28,7 @@ import icons.XpathIcons; import org.intellij.lang.xpath.xslt.XsltConfig; import org.intellij.lang.xpath.xslt.XsltSupport; import org.intellij.lang.xpath.xslt.associations.FileAssociationsManager; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -43,8 +44,9 @@ public class XsltTreeStructureProvider implements TreeStructureProvider { myProject = project; } + @NotNull @SuppressWarnings({"RawUseOfParameterizedType", "unchecked"}) - public Collection modify(AbstractTreeNode parent, Collection children, ViewSettings settings) { + public Collection modify(@NotNull AbstractTreeNode parent, @NotNull Collection children, ViewSettings settings) { Collection l = children; int i = 0; for (AbstractTreeNode o : children) { diff --git a/python/src/com/jetbrains/python/projectView/PyTreeStructureProvider.java b/python/src/com/jetbrains/python/projectView/PyTreeStructureProvider.java index ae923ed2d7e8..cb9e2577e1f8 100644 --- a/python/src/com/jetbrains/python/projectView/PyTreeStructureProvider.java +++ b/python/src/com/jetbrains/python/projectView/PyTreeStructureProvider.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. @@ -32,6 +32,7 @@ import com.jetbrains.python.psi.PyDocStringOwner; import com.jetbrains.python.psi.PyFile; import com.jetbrains.python.psi.PyFunction; import com.jetbrains.python.sdk.PythonSdkType; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Collection; @@ -41,8 +42,9 @@ import java.util.List; * @author yole */ public class PyTreeStructureProvider implements SelectableTreeStructureProvider, DumbAware { + @NotNull @Override - public Collection modify(AbstractTreeNode parent, Collection children, ViewSettings settings) { + public Collection modify(@NotNull AbstractTreeNode parent, @NotNull Collection children, ViewSettings settings) { if (parent instanceof NamedLibraryElementNode) { return hideSkeletons((NamedLibraryElementNode)parent, children); } From 75ca104cb9801424d058b051a1e5a541709cd44c Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 20 Feb 2014 19:57:01 +0400 Subject: [PATCH 29/75] notnull --- .../intellij/ide/projectView/impl/nodes/PackageElement.java | 3 ++- .../src/com/intellij/ide/projectView/ProjectViewNode.java | 5 +++-- .../src/com/intellij/ide/projectView/RootsProvider.java | 4 +++- .../ide/projectView/impl/nodes/AbstractModuleNode.java | 3 ++- .../intellij/ide/projectView/impl/nodes/ModuleGroupNode.java | 3 ++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/java/java-impl/src/com/intellij/ide/projectView/impl/nodes/PackageElement.java b/java/java-impl/src/com/intellij/ide/projectView/impl/nodes/PackageElement.java index 3e92bdafbbab..ee64a3186f0e 100644 --- a/java/java-impl/src/com/intellij/ide/projectView/impl/nodes/PackageElement.java +++ b/java/java-impl/src/com/intellij/ide/projectView/impl/nodes/PackageElement.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. @@ -58,6 +58,7 @@ public final class PackageElement implements Queryable, RootsProvider { return myElement; } + @NotNull @Override public Collection getRoots() { Set roots= new HashSet(); diff --git a/platform/lang-api/src/com/intellij/ide/projectView/ProjectViewNode.java b/platform/lang-api/src/com/intellij/ide/projectView/ProjectViewNode.java index 5b72e74bcb09..eabf799ba1bd 100644 --- a/platform/lang-api/src/com/intellij/ide/projectView/ProjectViewNode.java +++ b/platform/lang-api/src/com/intellij/ide/projectView/ProjectViewNode.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. @@ -108,7 +108,7 @@ public abstract class ProjectViewNode extends AbstractTreeNode im Object value, ViewSettings settings) throws InstantiationException { - Object[] parameters = new Object[]{project, value, settings}; + Object[] parameters = {project, value, settings}; for (Constructor constructor : (Constructor[])nodeClass.getConstructors()) { if (constructor.getParameterTypes().length != 3) continue; try { @@ -164,6 +164,7 @@ public abstract class ProjectViewNode extends AbstractTreeNode im return false; } + @NotNull @Override public Collection getRoots() { Value value = getValue(); diff --git a/platform/lang-api/src/com/intellij/ide/projectView/RootsProvider.java b/platform/lang-api/src/com/intellij/ide/projectView/RootsProvider.java index 6a7ca09059c4..2f341936fb3d 100644 --- a/platform/lang-api/src/com/intellij/ide/projectView/RootsProvider.java +++ b/platform/lang-api/src/com/intellij/ide/projectView/RootsProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.intellij.ide.projectView; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.containers.HashSet; +import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.Set; @@ -25,6 +26,7 @@ public interface RootsProvider { Set EMPTY_ROOTS = new HashSet(); + @NotNull Collection getRoots(); } diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractModuleNode.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractModuleNode.java index 3ef138d82542..58591a139949 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractModuleNode.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractModuleNode.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. @@ -62,6 +62,7 @@ public abstract class AbstractModuleNode extends ProjectViewNode impleme return "Module"; } + @NotNull @Override public Collection getRoots() { return Arrays.asList(ModuleRootManager.getInstance(getValue()).getContentRoots()); diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/ModuleGroupNode.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/ModuleGroupNode.java index 1c3dca9dbb3a..621dd67af1e2 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/ModuleGroupNode.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/ModuleGroupNode.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. @@ -70,6 +70,7 @@ public abstract class ModuleGroupNode extends ProjectViewNode imple return result; } + @NotNull @Override public Collection getRoots() { Collection children = getChildren(); From 7693bbc497fadbac92b45a152b08e50a4bccc94c Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 20 Feb 2014 20:51:45 +0400 Subject: [PATCH 30/75] cleanup --- .../impl/xml/XmlStructureViewTreeModel.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java b/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java index 19408e7eff1c..3067f38411a9 100644 --- a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java +++ b/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.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. @@ -30,8 +30,9 @@ import org.jetbrains.annotations.Nullable; public class XmlStructureViewTreeModel extends TextEditorBasedStructureViewModel { private final XmlFile myFile; - private static final Class[] myClasses = new Class[]{XmlTag.class, XmlFile.class, XmlEntityDecl.class, XmlElementDecl.class, XmlAttlistDecl.class, XmlConditionalSection.class}; - private static final Sorter[] mySorters = {Sorter.ALPHA_SORTER}; + private static final Class[] CLASSES = + {XmlTag.class, XmlFile.class, XmlEntityDecl.class, XmlElementDecl.class, XmlAttlistDecl.class, XmlConditionalSection.class}; + private static final Sorter[] SORTERS = {Sorter.ALPHA_SORTER}; public XmlStructureViewTreeModel(XmlFile file, @Nullable Editor editor) { super(editor, file); @@ -58,7 +59,7 @@ public class XmlStructureViewTreeModel extends TextEditorBasedStructureViewModel @Override @NotNull protected Class[] getSuitableClasses() { - return myClasses; + return CLASSES; } @Override @@ -76,6 +77,6 @@ public class XmlStructureViewTreeModel extends TextEditorBasedStructureViewModel @Override @NotNull public Sorter[] getSorters() { - return mySorters; + return SORTERS; } } \ No newline at end of file From 1e7bbca5e6b4ed6cc59f1d73eab4330c71dcebf2 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 21 Feb 2014 12:52:12 +0400 Subject: [PATCH 31/75] moved to xml-analysis --- .../analysis/InsertRequiredAttributeFix.java | 35 ++++++------------- .../XmlQuickFixFactoryImpl.java | 5 ++- xml/openapi/xml-openapi.iml | 1 + .../codeInspection/XmlQuickFixFactory.java | 5 ++- .../com/intellij/xml/XmlTagRuleProvider.java | 4 +-- .../intellij/xml/util/TagSetRuleProvider.java | 2 +- .../xml/util/XmlTagRuleProviderBase.java | 16 ++++----- 7 files changed, 27 insertions(+), 41 deletions(-) rename xml/{openapi => xml-analysis-api}/src/com/intellij/xml/XmlTagRuleProvider.java (91%) rename xml/{impl => xml-analysis-impl}/src/com/intellij/xml/util/TagSetRuleProvider.java (98%) rename xml/{impl => xml-analysis-impl}/src/com/intellij/xml/util/XmlTagRuleProviderBase.java (92%) diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/InsertRequiredAttributeFix.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/InsertRequiredAttributeFix.java index 06f71c74c5b3..1a4a5842443d 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/InsertRequiredAttributeFix.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/InsertRequiredAttributeFix.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. @@ -18,12 +18,10 @@ package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.codeInsight.FileModificationService; import com.intellij.codeInsight.daemon.XmlErrorMessages; import com.intellij.codeInsight.intention.HighPriorityAction; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.codeInsight.template.*; -import com.intellij.codeInspection.LocalQuickFix; -import com.intellij.codeInspection.ProblemDescriptor; +import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement; import com.intellij.lang.ASTNode; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; @@ -39,20 +37,20 @@ import com.intellij.xml.XmlElementDescriptor; import com.intellij.xml.XmlExtension; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * User: anna * Date: 18-Nov-2005 */ -public class InsertRequiredAttributeFix implements IntentionAction, LocalQuickFix, HighPriorityAction { - private final XmlTag myTag; +public class InsertRequiredAttributeFix extends LocalQuickFixAndIntentionActionOnPsiElement implements HighPriorityAction { private final String myAttrName; private final String[] myValues; @NonNls private static final String NAME_TEMPLATE_VARIABLE = "name"; public InsertRequiredAttributeFix(@NotNull XmlTag tag, @NotNull String attrName,@NotNull String... values) { - myTag = tag; + super(tag); myAttrName = attrName; myValues = values; } @@ -63,12 +61,6 @@ public class InsertRequiredAttributeFix implements IntentionAction, LocalQuickFi return XmlErrorMessages.message("insert.required.attribute.quickfix.text", myAttrName); } - @Override - @NotNull - public String getName() { - return getText(); - } - @Override @NotNull public String getFamilyName() { @@ -76,18 +68,13 @@ public class InsertRequiredAttributeFix implements IntentionAction, LocalQuickFi } @Override - public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { - invoke(project, null, myTag.getContainingFile()); - } - - @Override - public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - return myTag.isValid(); - } - - @Override - public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) { + public void invoke(@NotNull final Project project, + @NotNull PsiFile file, + @Nullable("is null when called from inspection") final Editor editor, + @NotNull PsiElement startElement, + @NotNull PsiElement endElement) { if (!FileModificationService.getInstance().prepareFileForWrite(file)) return; + XmlTag myTag = (XmlTag)startElement; ASTNode treeElement = SourceTreeToPsiMap.psiElementToTree(myTag); final XmlElementDescriptor descriptor = myTag.getDescriptor(); diff --git a/xml/impl/src/com/intellij/codeInspection/XmlQuickFixFactoryImpl.java b/xml/impl/src/com/intellij/codeInspection/XmlQuickFixFactoryImpl.java index 8065ebf5221f..c095bd1cf49f 100644 --- a/xml/impl/src/com/intellij/codeInspection/XmlQuickFixFactoryImpl.java +++ b/xml/impl/src/com/intellij/codeInspection/XmlQuickFixFactoryImpl.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. @@ -17,7 +17,6 @@ package com.intellij.codeInspection; import com.intellij.codeInsight.daemon.impl.analysis.CreateNSDeclarationIntentionFix; import com.intellij.codeInsight.daemon.impl.analysis.InsertRequiredAttributeFix; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.psi.PsiElement; import com.intellij.psi.xml.XmlTag; import com.intellij.psi.xml.XmlToken; @@ -27,7 +26,7 @@ import org.jetbrains.annotations.Nullable; public class XmlQuickFixFactoryImpl extends XmlQuickFixFactory { @NotNull @Override - public IntentionAction insertRequiredAttributeFix(@NotNull XmlTag tag, @NotNull String attrName, @NotNull String... values) { + public LocalQuickFixAndIntentionActionOnPsiElement insertRequiredAttributeFix(@NotNull XmlTag tag, @NotNull String attrName, @NotNull String... values) { return new InsertRequiredAttributeFix(tag, attrName, values); } diff --git a/xml/openapi/xml-openapi.iml b/xml/openapi/xml-openapi.iml index 934360bb80c9..d6d222394004 100644 --- a/xml/openapi/xml-openapi.iml +++ b/xml/openapi/xml-openapi.iml @@ -9,6 +9,7 @@ + diff --git a/xml/xml-analysis-api/src/com/intellij/codeInspection/XmlQuickFixFactory.java b/xml/xml-analysis-api/src/com/intellij/codeInspection/XmlQuickFixFactory.java index e99bbab3d48a..c0c5b1081785 100644 --- a/xml/xml-analysis-api/src/com/intellij/codeInspection/XmlQuickFixFactory.java +++ b/xml/xml-analysis-api/src/com/intellij/codeInspection/XmlQuickFixFactory.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,7 +15,6 @@ */ package com.intellij.codeInspection; -import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.openapi.components.ServiceManager; import com.intellij.psi.PsiElement; import com.intellij.psi.xml.XmlTag; @@ -29,7 +28,7 @@ public abstract class XmlQuickFixFactory { } @NotNull - public abstract IntentionAction insertRequiredAttributeFix(@NotNull XmlTag tag, @NotNull String attrName,@NotNull String... values); + public abstract LocalQuickFixAndIntentionActionOnPsiElement insertRequiredAttributeFix(@NotNull XmlTag tag, @NotNull String attrName,@NotNull String... values); @NotNull public abstract LocalQuickFix createNSDeclarationIntentionFix(@NotNull final PsiElement element, diff --git a/xml/openapi/src/com/intellij/xml/XmlTagRuleProvider.java b/xml/xml-analysis-api/src/com/intellij/xml/XmlTagRuleProvider.java similarity index 91% rename from xml/openapi/src/com/intellij/xml/XmlTagRuleProvider.java rename to xml/xml-analysis-api/src/com/intellij/xml/XmlTagRuleProvider.java index 69d3bbef1951..b81172014831 100644 --- a/xml/openapi/src/com/intellij/xml/XmlTagRuleProvider.java +++ b/xml/xml-analysis-api/src/com/intellij/xml/XmlTagRuleProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ public abstract class XmlTagRuleProvider { public static final Rule[] EMPTY_ARRAY = new Rule[0]; - public void annotate(@NotNull XmlTag tag, ProblemsHolder holder) { + public void annotate(@NotNull XmlTag tag, @NotNull ProblemsHolder holder) { } diff --git a/xml/impl/src/com/intellij/xml/util/TagSetRuleProvider.java b/xml/xml-analysis-impl/src/com/intellij/xml/util/TagSetRuleProvider.java similarity index 98% rename from xml/impl/src/com/intellij/xml/util/TagSetRuleProvider.java rename to xml/xml-analysis-impl/src/com/intellij/xml/util/TagSetRuleProvider.java index e4e20b9ac570..a3bef9d3ca2e 100644 --- a/xml/impl/src/com/intellij/xml/util/TagSetRuleProvider.java +++ b/xml/xml-analysis-impl/src/com/intellij/xml/util/TagSetRuleProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/xml/impl/src/com/intellij/xml/util/XmlTagRuleProviderBase.java b/xml/xml-analysis-impl/src/com/intellij/xml/util/XmlTagRuleProviderBase.java similarity index 92% rename from xml/impl/src/com/intellij/xml/util/XmlTagRuleProviderBase.java rename to xml/xml-analysis-impl/src/com/intellij/xml/util/XmlTagRuleProviderBase.java index 66aed47b71d3..6f93f029bbbe 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlTagRuleProviderBase.java +++ b/xml/xml-analysis-impl/src/com/intellij/xml/util/XmlTagRuleProviderBase.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,10 +15,10 @@ */ package com.intellij.xml.util; -import com.intellij.codeInsight.daemon.impl.analysis.InsertRequiredAttributeFix; import com.intellij.codeInspection.LocalQuickFix; import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.codeInspection.ProblemsHolder; +import com.intellij.codeInspection.XmlQuickFixFactory; import com.intellij.codeInspection.htmlInspections.RemoveAttributeIntentionAction; import com.intellij.lang.ASTNode; import com.intellij.openapi.util.Condition; @@ -117,7 +117,7 @@ public abstract class XmlTagRuleProviderBase extends XmlTagRuleProvider { // ---=== Classes ===--- public abstract static class Effect { - public abstract void annotate(@NotNull XmlTag tag, ProblemsHolder holder); + public abstract void annotate(@NotNull XmlTag tag, @NotNull ProblemsHolder holder); } public static class InvalidAttrEffect extends Effect { @@ -132,7 +132,7 @@ public abstract class XmlTagRuleProviderBase extends XmlTagRuleProvider { } @Override - public void annotate(@NotNull XmlTag tag, ProblemsHolder holder) { + public void annotate(@NotNull XmlTag tag, @NotNull ProblemsHolder holder) { XmlAttribute attribute = tag.getAttribute(myAttrName); if (attribute != null) { PsiElement attributeNameElement = getAttributeNameElement(attribute); @@ -155,7 +155,7 @@ public abstract class XmlTagRuleProviderBase extends XmlTagRuleProvider { } @Override - public void annotate(@NotNull XmlTag tag, ProblemsHolder holder) { + public void annotate(@NotNull XmlTag tag, @NotNull ProblemsHolder holder) { for (XmlAttribute xmlAttribute : tag.getAttributes()) { String attrName = xmlAttribute.getName(); if (!ArrayUtil.contains(attrName, myAttrNames)) { @@ -178,7 +178,7 @@ public abstract class XmlTagRuleProviderBase extends XmlTagRuleProvider { } @Override - public void annotate(@NotNull XmlTag tag, ProblemsHolder holder) { + public void annotate(@NotNull XmlTag tag, @NotNull ProblemsHolder holder) { if (myCondition.value(tag)) { for (Effect effect : myEffect) { effect.annotate(tag, holder); @@ -214,7 +214,7 @@ public abstract class XmlTagRuleProviderBase extends XmlTagRuleProvider { } @Override - public void annotate(@NotNull XmlTag tag, ProblemsHolder holder) { + public void annotate(@NotNull XmlTag tag, @NotNull ProblemsHolder holder) { for (String attributeName : myAttributeNames) { if (tag.getAttribute(attributeName) != null) { return; @@ -228,7 +228,7 @@ public abstract class XmlTagRuleProviderBase extends XmlTagRuleProvider { LocalQuickFix[] fixes = new LocalQuickFix[myAttributeNames.length]; for (int i = 0; i < myAttributeNames.length; i++) { - fixes[i] = new InsertRequiredAttributeFix(tag, myAttributeNames[i]); + fixes[i] = XmlQuickFixFactory.getInstance().insertRequiredAttributeFix(tag, myAttributeNames[i]); } holder.registerProblem(tagNameElement, "Tag should have one of following attributes: " + StringUtil.join(myAttributeNames, ", "), From 53b173effcf9f5fa9b97feb09023c7d2b058c884 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 21 Feb 2014 14:22:23 +0400 Subject: [PATCH 32/75] cleanup --- .../structure/DomStructureViewTreeModel.java | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewTreeModel.java b/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewTreeModel.java index bb5b01b008f4..d7fd6d50a4e5 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewTreeModel.java +++ b/xml/dom-impl/src/com/intellij/util/xml/structure/DomStructureViewTreeModel.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,10 +19,8 @@ package com.intellij.util.xml.structure; import com.intellij.ide.structureView.StructureViewTreeElement; import com.intellij.ide.structureView.impl.xml.XmlFileTreeElement; import com.intellij.ide.structureView.impl.xml.XmlStructureViewTreeModel; -import com.intellij.ide.util.treeView.smartTree.Sorter; import com.intellij.openapi.Disposable; import com.intellij.openapi.editor.Editor; -import com.intellij.psi.PsiFile; import com.intellij.psi.xml.XmlFile; import com.intellij.util.Function; import com.intellij.util.xml.*; @@ -33,20 +31,18 @@ import org.jetbrains.annotations.Nullable; * @author Gregory.Shrago */ public class DomStructureViewTreeModel extends XmlStructureViewTreeModel implements Disposable { - private final XmlFile myFile; private final DomElementNavigationProvider myNavigationProvider; private final Function myDescriptor; - public DomStructureViewTreeModel(final XmlFile file, final Function descriptor, @Nullable Editor editor) { + public DomStructureViewTreeModel(@NotNull XmlFile file, @NotNull Function descriptor, @Nullable Editor editor) { this(file, DomElementsNavigationManager.getManager(file.getProject()).getDomElementsNavigateProvider(DomElementsNavigationManager.DEFAULT_PROVIDER_NAME), descriptor, editor); } - public DomStructureViewTreeModel(final XmlFile file, + public DomStructureViewTreeModel(@NotNull XmlFile file, final DomElementNavigationProvider navigationProvider, - final Function descriptor, + @NotNull Function descriptor, @Nullable Editor editor) { super(file, editor); - myFile = file; myNavigationProvider = navigationProvider; myDescriptor = descriptor; } @@ -54,6 +50,7 @@ public class DomStructureViewTreeModel extends XmlStructureViewTreeModel impleme @Override @NotNull public StructureViewTreeElement getRoot() { + XmlFile myFile = getPsiFile(); final DomFileElement fileElement = DomManager.getDomManager(myFile.getProject()).getFileElement(myFile, DomElement.class); return fileElement == null? new XmlFileTreeElement(myFile) : @@ -63,15 +60,4 @@ public class DomStructureViewTreeModel extends XmlStructureViewTreeModel impleme protected DomElementNavigationProvider getNavigationProvider() { return myNavigationProvider; } - - @Override - @NotNull - public Sorter[] getSorters() { - return new Sorter[]{Sorter.ALPHA_SORTER}; - } - - @Override - protected PsiFile getPsiFile() { - return myFile; - } } From 68c3a4063e088eae136c17a805c8c1b343d63687 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 21 Feb 2014 14:25:58 +0400 Subject: [PATCH 33/75] nullable --- .../structureView/newStructureView/StructureViewComponent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java index 3bdb4de361f3..6ac9813606ce 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java @@ -232,7 +232,7 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre } - private static Object[] convertPathsToValues(TreePath[] selectionPaths) { + private static Object[] convertPathsToValues(@Nullable TreePath[] selectionPaths) { if (selectionPaths == null) return null; List result = new ArrayList(); for (TreePath selectionPath : selectionPaths) { From 9739a4d3c47d1a1f5eb3033d60b08cc6827af125 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 21 Feb 2014 17:09:44 +0400 Subject: [PATCH 34/75] javadoc --- .../src/com/intellij/codeInspection/LocalQuickFix.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFix.java b/platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFix.java index bd245cba4896..bf0a35c14983 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFix.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ package com.intellij.codeInspection; * Instead, use the {@link ProblemDescriptor#getPsiElement()} * in {@link QuickFix#applyFix(com.intellij.openapi.project.Project, CommonProblemDescriptor)} * to retrieve the PSI context the fix will work on. + * See also {@link LocalQuickFixOnPsiElement} which uses {@link com.intellij.psi.SmartPsiElementPointer} instead of storing PSI elements. * * @author max * @see LocalQuickFixBase From ac1554975d438985c92d1f239d46b00eb9f331a6 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 21 Feb 2014 17:39:42 +0400 Subject: [PATCH 35/75] structure view extracted --- .idea/modules.xml | 5 ++ build/scripts/layouts.gant | 3 +- build/scripts/utils.gant | 4 ++ java/java-impl/java-impl.iml | 1 + .../impl/java/JavaAnonymousMembersFilter.java | 66 ------------------- .../java-structure-view.iml | 14 ++++ .../JavaClsStructureViewBuilderProvider.java | 2 +- .../impl/AddAllMembersProcessor.java | 0 .../impl/java/AccessLevelProvider.java | 2 +- .../impl/java/AnonymousClassesSorter.java | 2 +- .../java/ClassInitializerTreeElement.java | 2 +- .../structureView/impl/java/FieldsFilter.java | 0 .../java/JavaAnonymousClassTreeElement.java | 0 .../JavaAnonymousClassesNodeProvider.java | 0 .../impl/java/JavaClassTreeElement.java | 0 .../impl/java/JavaClassTreeElementBase.java | 0 .../impl/java/JavaFileTreeElement.java | 2 +- .../impl/java/JavaFileTreeModel.java | 19 ++---- .../JavaInheritedMembersNodeProvider.java | 0 .../structureView/impl/java/KindSorter.java | 9 ++- .../impl/java/PropertiesGrouper.java | 0 .../impl/java/PropertyGroup.java | 0 .../impl/java/PsiFieldTreeElement.java | 0 .../impl/java/PsiMethodTreeElement.java | 0 .../impl/java/PublicElementsFilter.java | 0 .../impl/java/SuperTypeGroup.java | 0 .../impl/java/SuperTypesGrouper.java | 0 .../impl/java/VisibilityComparator.java | 0 .../impl/java/VisibilitySorter.java | 0 .../java/JavaStructureViewBuilderFactory.java | 2 +- .../JavaFileStructureTestCase.java | 6 +- platform/editor-ui-api/editor-ui-api.iml | 2 + .../ide/projectView/ProjectViewNode.java | 3 +- platform/lang-impl/lang-impl.iml | 1 + .../ide/actions/ViewStructureAction.java | 8 +-- .../ide/util/FileStructureDialog.java | 3 +- .../intellij/ide/util/FileStructurePopup.java | 23 ++++--- platform/platform-api/platform-api.iml | 1 + .../ide/projectView/PresentationData.java | 2 +- .../ide/projectView/RootsProvider.java | 0 .../ide/projectView/SettingsProvider.java | 20 ++++++ .../projectView/TreeStructureProvider.java | 0 .../ide/projectView/ViewSettings.java | 2 +- .../FileEditorPositionListener.java | 2 +- .../ide/structureView/ModelListener.java | 2 +- .../ide/structureView/StructureView.java | 2 +- .../structureView/StructureViewBuilder.java | 0 .../StructureViewBuilderProvider.java | 2 +- .../structureView/StructureViewFactory.java | 0 .../ide/structureView/StructureViewModel.java | 0 .../structureView/StructureViewModelBase.java | 4 +- .../StructureViewTreeElement.java | 0 .../TextEditorBasedStructureViewModel.java | 4 +- .../TreeBasedStructureViewBuilder.java | 2 +- .../intellij/ide/structureView/package.html | 0 .../ide/util/ActionShortcutProvider.java | 24 +++++++ .../ide/util/FileStructureFilter.java | 0 .../ide/util/FileStructureNodeProvider.java | 0 .../ide/util/treeView/AbstractTreeNode.java | 0 .../util/treeView/AbstractTreeStructure.java | 2 +- .../ide/util/treeView/AlphaComparator.java | 2 +- .../ide/util/treeView/IndexComparator.java | 2 +- .../ide/util/treeView/NodeDescriptor.java | 2 +- .../treeView/NodeDescriptorProvidingKey.java | 2 +- .../ide/util/treeView/NodeOptions.java | 2 +- .../treeView/PresentableNodeDescriptor.java | 4 +- .../ide/util/treeView/TreeAnchorizer.java | 2 +- .../ide/util/treeView/TreeUpdatePass.java | 2 +- .../ide/util/treeView/TreeVisitor.java | 2 +- .../ide/util/treeView/ValidateableNode.java | 2 +- .../ide/util/treeView/WeighedItem.java | 4 +- .../smartTree/ActionPresentation.java | 5 +- .../smartTree/ActionPresentationData.java | 7 +- .../ide/util/treeView/smartTree/Filter.java | 2 +- .../ide/util/treeView/smartTree/Group.java | 5 +- .../ide/util/treeView/smartTree/Grouper.java | 5 +- .../util/treeView/smartTree/NodeProvider.java | 0 .../smartTree/ProvidingTreeModel.java | 2 +- .../smartTree/SortableTreeElement.java | 5 +- .../ide/util/treeView/smartTree/Sorter.java | 2 +- .../util/treeView/smartTree/SorterUtil.java | 0 .../util/treeView/smartTree/TreeAction.java | 2 +- .../util/treeView/smartTree/TreeElement.java | 6 +- .../util/treeView/smartTree/TreeModel.java | 0 .../ide/util/treeView/smartTree/package.html | 0 .../lang/LanguageStructureViewBuilder.java | 2 +- .../lang/PsiStructureViewFactory.java | 2 +- .../navigation/AnonymousElementProvider.java | 0 .../intellij/openapi/util/PropertyOwner.java | 2 +- .../structure-view-api/structure-view-api.iml | 31 +++++++++ ...eFileTypeStructureViewBuilderProvider.java | 2 +- .../structureView/StructureViewExtension.java | 2 +- .../structureView/StructureViewFactoryEx.java | 2 +- .../structureView/StructureViewWrapper.java | 2 +- .../impl/StructureViewComposite.java | 2 +- .../impl/StructureViewElementWrapper.java | 0 .../impl/StructureViewModelWrapper.java | 0 .../impl/StructureViewState.java | 2 +- .../impl/common/PsiTreeElementBase.java | 0 .../util/InheritedMembersNodeProvider.java | 11 +++- .../treeView/AbstractTreeStructureBase.java | 4 +- .../smartTree/CachingChildrenTreeNode.java | 0 .../util/treeView/smartTree/GroupWrapper.java | 0 .../smartTree/SmartTreeStructure.java | 2 +- .../smartTree/TreeElementWrapper.java | 0 .../treeView/smartTree/TreeStructureUtil.java | 16 ++++- .../structure-view-impl.iml | 13 ++++ xml/impl/xml.iml | 1 + xml/openapi/xml-openapi.iml | 1 + .../structureView/HtmlFileStructureTest.java | 19 +++++- .../xml/XmlStructureViewBuilderProvider.java | 2 +- .../xml/XmlStructureViewElementProvider.java | 2 +- .../xml-structure-view-api.iml | 15 +++++ .../impl/xml/AbstractXmlTagTreeElement.java | 2 +- .../impl/xml/DtdFileTreeElement.java | 2 +- .../impl/xml/XmlFileTreeElement.java | 2 +- .../impl/xml/XmlStructureViewTreeModel.java | 12 ++-- .../impl/xml/XmlTagTreeElement.java | 2 +- .../dtd/DtdStructureViewBuilderFactory.java | 2 +- .../Html5SectionTreeElement.java | 2 +- .../Html5SectionsNodeProvider.java | 14 +++- .../structureView/Html5SectionsProcessor.java | 2 +- .../structureView/HtmlFileTreeElement.java | 6 +- .../HtmlStructureViewBuilderProvider.java | 2 +- .../HtmlStructureViewTreeModel.java | 7 +- .../structureView/HtmlTagTreeElement.java | 2 +- .../xml/XmlStructureViewBuilderFactory.java | 2 +- .../xml-structure-view-impl.iml | 16 +++++ 128 files changed, 330 insertions(+), 195 deletions(-) delete mode 100644 java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousMembersFilter.java create mode 100644 java/java-structure-view/java-structure-view.iml rename java/{java-impl => java-structure-view}/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java (98%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java (94%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java (96%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java (99%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/FieldsFilter.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassTreeElement.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/JavaAnonymousClassesNodeProvider.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElement.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/JavaClassTreeElementBase.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/JavaFileTreeElement.java (99%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java (85%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/KindSorter.java (90%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java (100%) rename java/{java-impl => java-structure-view}/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java (97%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/projectView/PresentationData.java (99%) rename platform/{lang-api => structure-view-api}/src/com/intellij/ide/projectView/RootsProvider.java (100%) create mode 100644 platform/structure-view-api/src/com/intellij/ide/projectView/SettingsProvider.java rename platform/{lang-api => structure-view-api}/src/com/intellij/ide/projectView/TreeStructureProvider.java (100%) rename platform/{lang-api => structure-view-api}/src/com/intellij/ide/projectView/ViewSettings.java (98%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/structureView/FileEditorPositionListener.java (96%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/structureView/ModelListener.java (96%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/structureView/StructureView.java (98%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/structureView/StructureViewBuilder.java (100%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/structureView/StructureViewBuilderProvider.java (97%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/structureView/StructureViewFactory.java (100%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/structureView/StructureViewModel.java (100%) rename platform/{lang-api => structure-view-api}/src/com/intellij/ide/structureView/StructureViewModelBase.java (98%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/structureView/StructureViewTreeElement.java (100%) rename platform/{lang-api => structure-view-api}/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java (97%) rename platform/{lang-api => structure-view-api}/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java (99%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/structureView/package.html (100%) create mode 100644 platform/structure-view-api/src/com/intellij/ide/util/ActionShortcutProvider.java rename platform/{lang-impl => structure-view-api}/src/com/intellij/ide/util/FileStructureFilter.java (100%) rename platform/{lang-impl => structure-view-api}/src/com/intellij/ide/util/FileStructureNodeProvider.java (100%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/AbstractTreeNode.java (100%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/AbstractTreeStructure.java (98%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/AlphaComparator.java (98%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/IndexComparator.java (96%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/NodeDescriptor.java (99%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/NodeDescriptorProvidingKey.java (94%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/NodeOptions.java (98%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java (98%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/TreeAnchorizer.java (97%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/TreeUpdatePass.java (98%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/TreeVisitor.java (94%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/ValidateableNode.java (94%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/WeighedItem.java (94%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/ActionPresentation.java (93%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/ActionPresentationData.java (90%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/Filter.java (97%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/Group.java (91%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/Grouper.java (88%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/NodeProvider.java (100%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/ProvidingTreeModel.java (95%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/SortableTreeElement.java (89%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/Sorter.java (98%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/SorterUtil.java (100%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/TreeAction.java (97%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/TreeElement.java (88%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/TreeModel.java (100%) rename platform/{platform-api => structure-view-api}/src/com/intellij/ide/util/treeView/smartTree/package.html (100%) rename platform/{lang-api => structure-view-api}/src/com/intellij/lang/LanguageStructureViewBuilder.java (97%) rename platform/{lang-api => structure-view-api}/src/com/intellij/lang/PsiStructureViewFactory.java (96%) rename platform/{lang-api => structure-view-api}/src/com/intellij/navigation/AnonymousElementProvider.java (100%) rename platform/{platform-api => structure-view-api}/src/com/intellij/openapi/util/PropertyOwner.java (94%) create mode 100644 platform/structure-view-api/structure-view-api.iml rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/highlighter/LanguageFileTypeStructureViewBuilderProvider.java (97%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/structureView/StructureViewExtension.java (96%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/structureView/StructureViewFactoryEx.java (99%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/structureView/StructureViewWrapper.java (95%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/structureView/impl/StructureViewComposite.java (98%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/structureView/impl/StructureViewElementWrapper.java (100%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/structureView/impl/StructureViewModelWrapper.java (100%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/structureView/impl/StructureViewState.java (96%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/structureView/impl/common/PsiTreeElementBase.java (100%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/util/InheritedMembersNodeProvider.java (84%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/util/treeView/AbstractTreeStructureBase.java (95%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/util/treeView/smartTree/CachingChildrenTreeNode.java (100%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/util/treeView/smartTree/GroupWrapper.java (100%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java (98%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/util/treeView/smartTree/TreeElementWrapper.java (100%) rename platform/{lang-impl => structure-view-impl}/src/com/intellij/ide/util/treeView/smartTree/TreeStructureUtil.java (71%) create mode 100644 platform/structure-view-impl/structure-view-impl.iml rename xml/{openapi => xml-structure-view-api}/src/com/intellij/ide/structureView/xml/XmlStructureViewBuilderProvider.java (96%) rename xml/{openapi => xml-structure-view-api}/src/com/intellij/ide/structureView/xml/XmlStructureViewElementProvider.java (96%) create mode 100644 xml/xml-structure-view-api/xml-structure-view-api.iml rename xml/{impl => xml-structure-view-impl}/src/com/intellij/ide/structureView/impl/xml/AbstractXmlTagTreeElement.java (98%) rename xml/{impl => xml-structure-view-impl}/src/com/intellij/ide/structureView/impl/xml/DtdFileTreeElement.java (99%) rename xml/{impl => xml-structure-view-impl}/src/com/intellij/ide/structureView/impl/xml/XmlFileTreeElement.java (98%) rename xml/{impl => xml-structure-view-impl}/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java (89%) rename xml/{impl => xml-structure-view-impl}/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java (98%) rename xml/{impl => xml-structure-view-impl}/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java (97%) rename xml/{impl => xml-structure-view-impl}/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java (98%) rename xml/{impl => xml-structure-view-impl}/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java (87%) rename xml/{impl => xml-structure-view-impl}/src/com/intellij/lang/html/structureView/Html5SectionsProcessor.java (99%) rename xml/{impl => xml-structure-view-impl}/src/com/intellij/lang/html/structureView/HtmlFileTreeElement.java (94%) rename xml/{impl => xml-structure-view-impl}/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java (97%) rename xml/{impl => xml-structure-view-impl}/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java (92%) rename xml/{impl => xml-structure-view-impl}/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java (99%) rename xml/{impl => xml-structure-view-impl}/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java (98%) create mode 100644 xml/xml-structure-view-impl/xml-structure-view-impl.iml diff --git a/.idea/modules.xml b/.idea/modules.xml index d0916bb1096d..d7c5d4aea264 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -193,6 +193,11 @@ + + + + + diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant index 02d32fc8abe5..8a9c8d069137 100644 --- a/build/scripts/layouts.gant +++ b/build/scripts/layouts.gant @@ -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. @@ -75,6 +75,7 @@ def layoutFull(String home, String targetDirectory, String patchedDescriptorDir "java-indexing-impl", "java-impl", "java-psi-impl", + "java-structure-view", "jsp-spi", "manifest", "platform-main", diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant index ad21749a63bb..7eb7c83f2333 100644 --- a/build/scripts/utils.gant +++ b/build/scripts/utils.gant @@ -255,6 +255,7 @@ binding.setVariable("platformApiModules", [ "lvcs-api", "projectModel-api", "platform-api", + "structure-view-api", "usageView", "vcs-api", "vcs-log-api", @@ -262,6 +263,7 @@ binding.setVariable("platformApiModules", [ "xml-analysis-api", "xml-openapi", "xml-psi-api", + "xml-structure-view-api", ]) @@ -278,6 +280,7 @@ binding.setVariable("platformImplementationModules", [ "lvcs-impl", "projectModel-impl", "platform-impl", + "structure-view-impl", "vcs-impl", "vcs-log-graph", "vcs-log-impl", @@ -290,6 +293,7 @@ binding.setVariable("platformImplementationModules", [ "xml", "xml-analysis-impl", "xml-psi-impl", + "xml-structure-view-impl", ]) binding.setVariable("layoutMacApp", { String path, String ch, Map args -> diff --git a/java/java-impl/java-impl.iml b/java/java-impl/java-impl.iml index 0e65b921e41f..688a8d303608 100644 --- a/java/java-impl/java-impl.iml +++ b/java/java-impl/java-impl.iml @@ -52,6 +52,7 @@ + diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousMembersFilter.java b/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousMembersFilter.java deleted file mode 100644 index d6d92b6a2655..000000000000 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaAnonymousMembersFilter.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.structureView.impl.java; - -import com.intellij.ide.util.FileStructureFilter; -import com.intellij.ide.util.treeView.smartTree.ActionPresentation; -import com.intellij.ide.util.treeView.smartTree.ActionPresentationData; -import com.intellij.ide.util.treeView.smartTree.TreeElement; -import com.intellij.openapi.actionSystem.Shortcut; -import com.intellij.util.PlatformIcons; -import org.jetbrains.annotations.NotNull; - -/** - * @author Konstantin Bulenkov - */ -public class JavaAnonymousMembersFilter implements FileStructureFilter { - - private static final String ID = "SHOW_ANONYMOUS"; - - @NotNull - @Override - public String getCheckBoxText() { - return "Show Anonymous Classes"; - } - - @NotNull - @Override - public Shortcut[] getShortcut() { - return Shortcut.EMPTY_ARRAY; - } - - @Override - public boolean isVisible(TreeElement treeNode) { - return !(treeNode instanceof JavaAnonymousClassTreeElement); - } - - @Override - public boolean isReverted() { - return true; - } - - @NotNull - @Override - public ActionPresentation getPresentation() { - return new ActionPresentationData(getCheckBoxText(), null, PlatformIcons.ANONYMOUS_CLASS_ICON); - } - - @NotNull - @Override - public String getName() { - return ID; - } -} diff --git a/java/java-structure-view/java-structure-view.iml b/java/java-structure-view/java-structure-view.iml new file mode 100644 index 000000000000..036dead74222 --- /dev/null +++ b/java/java-structure-view/java-structure-view.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/java/java-impl/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java b/java/java-structure-view/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java similarity index 98% rename from java/java-impl/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java rename to java/java-structure-view/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java index 7361877b7e69..0d7e2f08206f 100644 --- a/java/java-impl/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.java +++ b/java/java-structure-view/src/com/intellij/ide/highlighter/JavaClsStructureViewBuilderProvider.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. diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java similarity index 100% rename from java/java-impl/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java similarity index 94% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java index 1f153aadffbd..97b5d3e47c4e 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.java +++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/AccessLevelProvider.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. diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java similarity index 96% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java index a6412f050460..b18f9afe5716 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java +++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/AnonymousClassesSorter.java @@ -28,7 +28,7 @@ import java.util.Comparator; public class AnonymousClassesSorter implements Sorter { public static Sorter INSTANCE = new AnonymousClassesSorter(); - private Comparator myComparator = new Comparator() { + private final Comparator myComparator = new Comparator() { @Override public int compare(Object o1, Object o2) { String s1 = SorterUtil.getStringPresentation(o1); diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java similarity index 99% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java index 52119084e8e2..400578037217 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java +++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/ClassInitializerTreeElement.java @@ -68,4 +68,4 @@ public class ClassInitializerTreeElement extends PsiTreeElementBase imple return result; } -} \ No newline at end of file +} diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java similarity index 85% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java index 609dc1570a46..a18a4cc271bd 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java +++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaFileTreeModel.java @@ -15,14 +15,10 @@ */ package com.intellij.ide.structureView.impl.java; -import com.intellij.ide.actions.ViewStructureAction; import com.intellij.ide.structureView.StructureViewModel; import com.intellij.ide.structureView.StructureViewTreeElement; import com.intellij.ide.structureView.TextEditorBasedStructureViewModel; -import com.intellij.ide.util.treeView.smartTree.Filter; -import com.intellij.ide.util.treeView.smartTree.Grouper; -import com.intellij.ide.util.treeView.smartTree.NodeProvider; -import com.intellij.ide.util.treeView.smartTree.Sorter; +import com.intellij.ide.util.treeView.smartTree.*; import com.intellij.openapi.editor.Editor; import com.intellij.psi.*; import com.intellij.ui.PlaceHolder; @@ -35,19 +31,16 @@ import java.util.Collection; public class JavaFileTreeModel extends TextEditorBasedStructureViewModel implements StructureViewModel.ElementInfoProvider, PlaceHolder { private static final Collection NODE_PROVIDERS = Arrays.asList(new JavaInheritedMembersNodeProvider(), new JavaAnonymousClassesNodeProvider()); - private final PsiClassOwner myFile; private String myPlace; public JavaFileTreeModel(@NotNull PsiClassOwner file, @Nullable Editor editor) { super(editor, file); - myFile = file; } @Override @NotNull public Filter[] getFilters() { - return new Filter[]{new FieldsFilter(), - new PublicElementsFilter()}; + return new Filter[]{new FieldsFilter(), new PublicElementsFilter()}; } @NotNull @@ -65,7 +58,7 @@ public class JavaFileTreeModel extends TextEditorBasedStructureViewModel impleme @Override @NotNull public StructureViewTreeElement getRoot() { - return new JavaFileTreeElement(myFile); + return new JavaFileTreeElement(getPsiFile()); } @Override @@ -77,15 +70,15 @@ public class JavaFileTreeModel extends TextEditorBasedStructureViewModel impleme @NotNull public Sorter[] getSorters() { return new Sorter[] { - ViewStructureAction.isInStructureViewPopup(this) ? KindSorter.POPUP_INSTANCE : KindSorter.INSTANCE, + TreeStructureUtil.isInStructureViewPopup(this) ? KindSorter.POPUP_INSTANCE : KindSorter.INSTANCE, VisibilitySorter.INSTANCE, AnonymousClassesSorter.INSTANCE, Sorter.ALPHA_SORTER}; } @Override - protected PsiFile getPsiFile() { - return myFile; + protected PsiClassOwner getPsiFile() { + return (PsiClassOwner)super.getPsiFile(); } @Override diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java similarity index 100% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/JavaInheritedMembersNodeProvider.java diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/KindSorter.java similarity index 90% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/KindSorter.java index 37cc7454abe2..10d8c6057c7e 100644 --- a/java/java-impl/src/com/intellij/ide/structureView/impl/java/KindSorter.java +++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/KindSorter.java @@ -24,12 +24,15 @@ import org.jetbrains.annotations.NotNull; import java.util.Comparator; public class KindSorter implements Sorter { - public static final Sorter INSTANCE = new KindSorter(); - public static final Sorter POPUP_INSTANCE = new KindSorter(){{isPopup = true;}}; + public static final Sorter INSTANCE = new KindSorter(false); + public static final Sorter POPUP_INSTANCE = new KindSorter(true); + public KindSorter(boolean isPopup) { + this.isPopup = isPopup; + } @NonNls public static final String ID = "KIND"; - boolean isPopup = false; + private final boolean isPopup; private final Comparator COMPARATOR = new Comparator() { @Override diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java similarity index 100% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertiesGrouper.java diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java similarity index 100% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PropertyGroup.java diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java similarity index 100% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PsiFieldTreeElement.java diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java similarity index 100% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PsiMethodTreeElement.java diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java similarity index 100% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/PublicElementsFilter.java diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java similarity index 100% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/SuperTypeGroup.java diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java similarity index 100% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/SuperTypesGrouper.java diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java similarity index 100% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/VisibilityComparator.java diff --git a/java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java similarity index 100% rename from java/java-impl/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java rename to java/java-structure-view/src/com/intellij/ide/structureView/impl/java/VisibilitySorter.java diff --git a/java/java-impl/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java b/java/java-structure-view/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java similarity index 97% rename from java/java-impl/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java rename to java/java-structure-view/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java index e8d4eba8a8ed..857191fdf4ad 100644 --- a/java/java-impl/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.java +++ b/java/java-structure-view/src/com/intellij/lang/java/JavaStructureViewBuilderFactory.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. diff --git a/java/java-tests/testSrc/com/intellij/ide/fileStructure/JavaFileStructureTestCase.java b/java/java-tests/testSrc/com/intellij/ide/fileStructure/JavaFileStructureTestCase.java index 674d3160fb37..b031f0e96796 100644 --- a/java/java-tests/testSrc/com/intellij/ide/fileStructure/JavaFileStructureTestCase.java +++ b/java/java-tests/testSrc/com/intellij/ide/fileStructure/JavaFileStructureTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ package com.intellij.ide.fileStructure; import com.intellij.JavaTestUtil; import com.intellij.ide.structureView.impl.java.JavaAnonymousClassesNodeProvider; import com.intellij.ide.structureView.impl.java.JavaInheritedMembersNodeProvider; -import com.intellij.ide.util.FileStructurePopup; import com.intellij.ide.util.PropertiesComponent; +import com.intellij.ide.util.treeView.smartTree.TreeStructureUtil; import com.intellij.testFramework.FileStructureTestBase; import com.intellij.testFramework.IdeaTestCase; @@ -66,7 +66,7 @@ public abstract class JavaFileStructureTestCase extends FileStructureTestBase { } private static String getAnonymousPropertyName() { - return FileStructurePopup.getPropertyName(JavaAnonymousClassesNodeProvider.JAVA_ANONYMOUS_PROPERTY_NAME); + return TreeStructureUtil.getPropertyName(JavaAnonymousClassesNodeProvider.JAVA_ANONYMOUS_PROPERTY_NAME); } @Override diff --git a/platform/editor-ui-api/editor-ui-api.iml b/platform/editor-ui-api/editor-ui-api.iml index 3de8227812bb..d45353c10fc4 100644 --- a/platform/editor-ui-api/editor-ui-api.iml +++ b/platform/editor-ui-api/editor-ui-api.iml @@ -12,6 +12,8 @@ + + diff --git a/platform/lang-api/src/com/intellij/ide/projectView/ProjectViewNode.java b/platform/lang-api/src/com/intellij/ide/projectView/ProjectViewNode.java index eabf799ba1bd..64972b0c8308 100644 --- a/platform/lang-api/src/com/intellij/ide/projectView/ProjectViewNode.java +++ b/platform/lang-api/src/com/intellij/ide/projectView/ProjectViewNode.java @@ -44,7 +44,7 @@ import java.util.List; * @see TreeStructureProvider#modify(com.intellij.ide.util.treeView.AbstractTreeNode, java.util.Collection, com.intellij.ide.projectView.ViewSettings) */ -public abstract class ProjectViewNode extends AbstractTreeNode implements RootsProvider { +public abstract class ProjectViewNode extends AbstractTreeNode implements RootsProvider, SettingsProvider { protected static final Logger LOG = Logger.getInstance("#com.intellij.ide.projectView.ProjectViewNode"); @@ -82,6 +82,7 @@ public abstract class ProjectViewNode extends AbstractTreeNode im return null; } + @Override public final ViewSettings getSettings() { return mySettings; } diff --git a/platform/lang-impl/lang-impl.iml b/platform/lang-impl/lang-impl.iml index d1580e0bc141..7528850108a3 100644 --- a/platform/lang-impl/lang-impl.iml +++ b/platform/lang-impl/lang-impl.iml @@ -30,6 +30,7 @@ + diff --git a/platform/lang-impl/src/com/intellij/ide/actions/ViewStructureAction.java b/platform/lang-impl/src/com/intellij/ide/actions/ViewStructureAction.java index 3acb49a1b4ba..b2533d5fad35 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/ViewStructureAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/ViewStructureAction.java @@ -22,6 +22,7 @@ import com.intellij.ide.structureView.StructureViewBuilder; import com.intellij.ide.structureView.StructureViewModel; import com.intellij.ide.util.FileStructureDialog; import com.intellij.ide.util.FileStructurePopup; +import com.intellij.ide.util.treeView.smartTree.TreeStructureUtil; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -41,7 +42,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class ViewStructureAction extends AnAction { - private static final String PLACE = "StructureViewPopup"; public ViewStructureAction() { setEnabledInModalContext(true); @@ -107,15 +107,11 @@ public class ViewStructureAction extends AnAction { StructureViewModel model = structureView.getTreeModel(); if (model instanceof PlaceHolder) { //noinspection unchecked - ((PlaceHolder)model).setPlace(PLACE); + ((PlaceHolder)model).setPlace(TreeStructureUtil.PLACE); } return createStructureViewPopup(project, fileEditor, structureView); } - public static boolean isInStructureViewPopup(@NotNull PlaceHolder model) { - return PLACE.equals(model.getPlace()); - } - @NotNull private static FileStructureDialog createStructureViewBasedDialog(@NotNull StructureViewModel structureViewModel, @NotNull Editor editor, diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructureDialog.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructureDialog.java index 4abeb0787727..c3ebb42dd5ef 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructureDialog.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructureDialog.java @@ -284,8 +284,7 @@ public class FileStructureDialog extends DialogWrapper { if (text == null) return; - Shortcut[] shortcuts = action instanceof FileStructureFilter ? - ((FileStructureFilter)action).getShortcut() : ((FileStructureNodeProvider)action).getShortcut(); + Shortcut[] shortcuts = FileStructurePopup.extractShortcutFor(action); final JCheckBox chkFilter = new JCheckBox(); diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java index 176e1b7c7a22..f260c732adf5 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java @@ -43,6 +43,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.fileEditor.TextEditor; import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory; +import com.intellij.openapi.keymap.KeymapManager; import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.JBPopup; @@ -713,8 +714,7 @@ public class FileStructurePopup implements Disposable { if (text == null) return; - Shortcut[] shortcuts = action instanceof FileStructureFilter ? - ((FileStructureFilter)action).getShortcut() : ((FileStructureNodeProvider)action).getShortcut(); + Shortcut[] shortcuts = extractShortcutFor(action); final JCheckBox chkFilter = new JCheckBox(); @@ -783,10 +783,20 @@ public class FileStructurePopup implements Disposable { myCheckBoxes.put(action.getClass(), chkFilter); } + @NotNull + static Shortcut[] extractShortcutFor(@NotNull TreeAction action) { + if (action instanceof ActionShortcutProvider) { + String actionId = ((ActionShortcutProvider)action).getActionIdForShortcut(); + return KeymapManager.getInstance().getActiveKeymap().getShortcuts(actionId); + } + return action instanceof FileStructureFilter ? + ((FileStructureFilter)action).getShortcut() : ((FileStructureNodeProvider)action).getShortcut(); + } + private static boolean getDefaultValue(TreeAction action) { if (action instanceof PropertyOwner) { final String propertyName = ((PropertyOwner)action).getPropertyName(); - return PropertiesComponent.getInstance().getBoolean(getPropertyName(propertyName), false); + return PropertiesComponent.getInstance().getBoolean(TreeStructureUtil.getPropertyName(propertyName), false); } return false; @@ -795,15 +805,10 @@ public class FileStructurePopup implements Disposable { private static void saveState(TreeAction action, boolean state) { if (action instanceof PropertyOwner) { final String propertyName = ((PropertyOwner)action).getPropertyName(); - PropertiesComponent.getInstance().setValue(getPropertyName(propertyName), Boolean.toString(state)); + PropertiesComponent.getInstance().setValue(TreeStructureUtil.getPropertyName(propertyName), Boolean.toString(state)); } } - @NonNls - public static String getPropertyName(String propertyName) { - return propertyName + ".file.structure.state"; - } - public void setTitle(String title) { myTitle = title; } diff --git a/platform/platform-api/platform-api.iml b/platform/platform-api/platform-api.iml index df91a1972748..3a4898f7c5cd 100644 --- a/platform/platform-api/platform-api.iml +++ b/platform/platform-api/platform-api.iml @@ -35,6 +35,7 @@ + diff --git a/platform/platform-api/src/com/intellij/ide/projectView/PresentationData.java b/platform/structure-view-api/src/com/intellij/ide/projectView/PresentationData.java similarity index 99% rename from platform/platform-api/src/com/intellij/ide/projectView/PresentationData.java rename to platform/structure-view-api/src/com/intellij/ide/projectView/PresentationData.java index 18cd07311f41..435c5ef9279d 100644 --- a/platform/platform-api/src/com/intellij/ide/projectView/PresentationData.java +++ b/platform/structure-view-api/src/com/intellij/ide/projectView/PresentationData.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. diff --git a/platform/lang-api/src/com/intellij/ide/projectView/RootsProvider.java b/platform/structure-view-api/src/com/intellij/ide/projectView/RootsProvider.java similarity index 100% rename from platform/lang-api/src/com/intellij/ide/projectView/RootsProvider.java rename to platform/structure-view-api/src/com/intellij/ide/projectView/RootsProvider.java diff --git a/platform/structure-view-api/src/com/intellij/ide/projectView/SettingsProvider.java b/platform/structure-view-api/src/com/intellij/ide/projectView/SettingsProvider.java new file mode 100644 index 000000000000..e7163ba361c1 --- /dev/null +++ b/platform/structure-view-api/src/com/intellij/ide/projectView/SettingsProvider.java @@ -0,0 +1,20 @@ +/* + * 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.projectView; + +public interface SettingsProvider { + ViewSettings getSettings(); +} diff --git a/platform/lang-api/src/com/intellij/ide/projectView/TreeStructureProvider.java b/platform/structure-view-api/src/com/intellij/ide/projectView/TreeStructureProvider.java similarity index 100% rename from platform/lang-api/src/com/intellij/ide/projectView/TreeStructureProvider.java rename to platform/structure-view-api/src/com/intellij/ide/projectView/TreeStructureProvider.java diff --git a/platform/lang-api/src/com/intellij/ide/projectView/ViewSettings.java b/platform/structure-view-api/src/com/intellij/ide/projectView/ViewSettings.java similarity index 98% rename from platform/lang-api/src/com/intellij/ide/projectView/ViewSettings.java rename to platform/structure-view-api/src/com/intellij/ide/projectView/ViewSettings.java index bc11154a08ad..4229fcf47440 100644 --- a/platform/lang-api/src/com/intellij/ide/projectView/ViewSettings.java +++ b/platform/structure-view-api/src/com/intellij/ide/projectView/ViewSettings.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. diff --git a/platform/platform-api/src/com/intellij/ide/structureView/FileEditorPositionListener.java b/platform/structure-view-api/src/com/intellij/ide/structureView/FileEditorPositionListener.java similarity index 96% rename from platform/platform-api/src/com/intellij/ide/structureView/FileEditorPositionListener.java rename to platform/structure-view-api/src/com/intellij/ide/structureView/FileEditorPositionListener.java index 9dc167caac50..ad7a2ce32239 100644 --- a/platform/platform-api/src/com/intellij/ide/structureView/FileEditorPositionListener.java +++ b/platform/structure-view-api/src/com/intellij/ide/structureView/FileEditorPositionListener.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. diff --git a/platform/platform-api/src/com/intellij/ide/structureView/ModelListener.java b/platform/structure-view-api/src/com/intellij/ide/structureView/ModelListener.java similarity index 96% rename from platform/platform-api/src/com/intellij/ide/structureView/ModelListener.java rename to platform/structure-view-api/src/com/intellij/ide/structureView/ModelListener.java index e633d227dfc7..3ec8c284c6ca 100644 --- a/platform/platform-api/src/com/intellij/ide/structureView/ModelListener.java +++ b/platform/structure-view-api/src/com/intellij/ide/structureView/ModelListener.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. diff --git a/platform/platform-api/src/com/intellij/ide/structureView/StructureView.java b/platform/structure-view-api/src/com/intellij/ide/structureView/StructureView.java similarity index 98% rename from platform/platform-api/src/com/intellij/ide/structureView/StructureView.java rename to platform/structure-view-api/src/com/intellij/ide/structureView/StructureView.java index ee4817ae5a5f..604fa00b2841 100644 --- a/platform/platform-api/src/com/intellij/ide/structureView/StructureView.java +++ b/platform/structure-view-api/src/com/intellij/ide/structureView/StructureView.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. diff --git a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewBuilder.java b/platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewBuilder.java similarity index 100% rename from platform/platform-api/src/com/intellij/ide/structureView/StructureViewBuilder.java rename to platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewBuilder.java diff --git a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewBuilderProvider.java b/platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewBuilderProvider.java similarity index 97% rename from platform/platform-api/src/com/intellij/ide/structureView/StructureViewBuilderProvider.java rename to platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewBuilderProvider.java index 55495001457f..5d70e3d95c7d 100644 --- a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewBuilderProvider.java +++ b/platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewBuilderProvider.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. diff --git a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewFactory.java b/platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewFactory.java similarity index 100% rename from platform/platform-api/src/com/intellij/ide/structureView/StructureViewFactory.java rename to platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewFactory.java diff --git a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewModel.java b/platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewModel.java similarity index 100% rename from platform/platform-api/src/com/intellij/ide/structureView/StructureViewModel.java rename to platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewModel.java diff --git a/platform/lang-api/src/com/intellij/ide/structureView/StructureViewModelBase.java b/platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewModelBase.java similarity index 98% rename from platform/lang-api/src/com/intellij/ide/structureView/StructureViewModelBase.java rename to platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewModelBase.java index d30c5906f4bb..ac191b813ffd 100644 --- a/platform/lang-api/src/com/intellij/ide/structureView/StructureViewModelBase.java +++ b/platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewModelBase.java @@ -37,9 +37,7 @@ public class StructureViewModelBase extends TextEditorBasedStructureViewModel { } public StructureViewModelBase(@NotNull PsiFile psiFile, @NotNull StructureViewTreeElement root) { - super(psiFile); - - myRoot = root; + this(psiFile, null, root); } @Override diff --git a/platform/platform-api/src/com/intellij/ide/structureView/StructureViewTreeElement.java b/platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewTreeElement.java similarity index 100% rename from platform/platform-api/src/com/intellij/ide/structureView/StructureViewTreeElement.java rename to platform/structure-view-api/src/com/intellij/ide/structureView/StructureViewTreeElement.java diff --git a/platform/lang-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java b/platform/structure-view-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java similarity index 97% rename from platform/lang-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java rename to platform/structure-view-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java index 17a8c21b2ec8..5cef3a5801a6 100644 --- a/platform/lang-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java +++ b/platform/structure-view-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java @@ -24,7 +24,7 @@ import com.intellij.openapi.editor.event.CaretListener; import com.intellij.openapi.util.Disposer; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import com.intellij.psi.util.PsiUtilBase; +import com.intellij.psi.util.PsiEditorUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.ReflectionUtil; import com.intellij.util.containers.ContainerUtil; @@ -54,7 +54,7 @@ public abstract class TextEditorBasedStructureViewModel implements StructureView * @param psiFile the file for which the structure view model is requested. */ protected TextEditorBasedStructureViewModel(@NotNull PsiFile psiFile) { - this(PsiUtilBase.findEditor(psiFile), psiFile); + this(PsiEditorUtil.Service.getInstance().findEditorByPsiElement(psiFile), psiFile); } /** diff --git a/platform/lang-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java b/platform/structure-view-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java similarity index 99% rename from platform/lang-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java rename to platform/structure-view-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java index 987b28f7e3c4..c0152c7f64ad 100644 --- a/platform/lang-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java +++ b/platform/structure-view-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java @@ -78,4 +78,4 @@ public abstract class TreeBasedStructureViewBuilder implements StructureViewBuil public boolean isRootNodeShown() { return true; } -} \ No newline at end of file +} diff --git a/platform/platform-api/src/com/intellij/ide/structureView/package.html b/platform/structure-view-api/src/com/intellij/ide/structureView/package.html similarity index 100% rename from platform/platform-api/src/com/intellij/ide/structureView/package.html rename to platform/structure-view-api/src/com/intellij/ide/structureView/package.html diff --git a/platform/structure-view-api/src/com/intellij/ide/util/ActionShortcutProvider.java b/platform/structure-view-api/src/com/intellij/ide/util/ActionShortcutProvider.java new file mode 100644 index 000000000000..26c5c9388373 --- /dev/null +++ b/platform/structure-view-api/src/com/intellij/ide/util/ActionShortcutProvider.java @@ -0,0 +1,24 @@ +/* + * 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.util; + +import org.jetbrains.annotations.NotNull; + +// used in the implementation of FileStructureNodeProvider to avoid dependency on KeyMapManager in com.intellij.ide.util.FileStructureNodeProvider.getShortcut() +public interface ActionShortcutProvider { + @NotNull + String getActionIdForShortcut(); +} diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructureFilter.java b/platform/structure-view-api/src/com/intellij/ide/util/FileStructureFilter.java similarity index 100% rename from platform/lang-impl/src/com/intellij/ide/util/FileStructureFilter.java rename to platform/structure-view-api/src/com/intellij/ide/util/FileStructureFilter.java diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructureNodeProvider.java b/platform/structure-view-api/src/com/intellij/ide/util/FileStructureNodeProvider.java similarity index 100% rename from platform/lang-impl/src/com/intellij/ide/util/FileStructureNodeProvider.java rename to platform/structure-view-api/src/com/intellij/ide/util/FileStructureNodeProvider.java diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.java similarity index 100% rename from platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.java diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeStructure.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/AbstractTreeStructure.java similarity index 98% rename from platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeStructure.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/AbstractTreeStructure.java index 380c76e2351d..acd6548ff26d 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeStructure.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/AbstractTreeStructure.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. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/AlphaComparator.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/AlphaComparator.java similarity index 98% rename from platform/platform-api/src/com/intellij/ide/util/treeView/AlphaComparator.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/AlphaComparator.java index b5a71e4375d2..c97bfe5c9296 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/AlphaComparator.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/AlphaComparator.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. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/IndexComparator.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/IndexComparator.java similarity index 96% rename from platform/platform-api/src/com/intellij/ide/util/treeView/IndexComparator.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/IndexComparator.java index 07d38c9662a8..662b358aeea6 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/IndexComparator.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/IndexComparator.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. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java similarity index 99% rename from platform/platform-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java index dc5e236f6717..b49d89bea205 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/NodeDescriptorProvidingKey.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/NodeDescriptorProvidingKey.java similarity index 94% rename from platform/platform-api/src/com/intellij/ide/util/treeView/NodeDescriptorProvidingKey.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/NodeDescriptorProvidingKey.java index 2755f0292458..2bca0fc31b84 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/NodeDescriptorProvidingKey.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/NodeDescriptorProvidingKey.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. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/NodeOptions.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/NodeOptions.java similarity index 98% rename from platform/platform-api/src/com/intellij/ide/util/treeView/NodeOptions.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/NodeOptions.java index 376a25b554b1..324f1a58009c 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/NodeOptions.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/NodeOptions.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. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java similarity index 98% rename from platform/platform-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java index c6b832350fbe..1850778d706b 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -99,7 +99,7 @@ public abstract class PresentableNodeDescriptor extends NodeDescriptor { return new PresentationData(); } - protected void postprocess(PresentationData date) { + protected void postprocess(@NotNull PresentationData date) { } diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.java similarity index 97% rename from platform/platform-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.java index 058139e34ef7..1da325dcd5db 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.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. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/TreeUpdatePass.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/TreeUpdatePass.java similarity index 98% rename from platform/platform-api/src/com/intellij/ide/util/treeView/TreeUpdatePass.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/TreeUpdatePass.java index 4884ca1f804e..7b4e1f83b690 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/TreeUpdatePass.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/TreeUpdatePass.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. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/TreeVisitor.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/TreeVisitor.java similarity index 94% rename from platform/platform-api/src/com/intellij/ide/util/treeView/TreeVisitor.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/TreeVisitor.java index 2744537e60e4..211abb1b5c72 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/TreeVisitor.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/TreeVisitor.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. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/ValidateableNode.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/ValidateableNode.java similarity index 94% rename from platform/platform-api/src/com/intellij/ide/util/treeView/ValidateableNode.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/ValidateableNode.java index f08ba88976f5..f8f3c3d6fddf 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/ValidateableNode.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/ValidateableNode.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. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/WeighedItem.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/WeighedItem.java similarity index 94% rename from platform/platform-api/src/com/intellij/ide/util/treeView/WeighedItem.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/WeighedItem.java index ad2552cd62f2..edbe752d3208 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/WeighedItem.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/WeighedItem.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,4 +20,4 @@ package com.intellij.ide.util.treeView; */ public interface WeighedItem { int getWeight(); -} \ No newline at end of file +} diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentation.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentation.java similarity index 93% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentation.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentation.java index 0a95507ac9f1..8ba47d5b32e1 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentation.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentation.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. @@ -15,6 +15,8 @@ */ package com.intellij.ide.util.treeView.smartTree; +import org.jetbrains.annotations.NotNull; + import javax.swing.*; /** @@ -31,6 +33,7 @@ public interface ActionPresentation { * * @return the action name. */ + @NotNull String getText(); /** diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentationData.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentationData.java similarity index 90% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentationData.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentationData.java index d5194afe675d..1a85799128cc 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentationData.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentationData.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. @@ -15,6 +15,8 @@ */ package com.intellij.ide.util.treeView.smartTree; +import org.jetbrains.annotations.NotNull; + import javax.swing.*; /** @@ -35,13 +37,14 @@ public class ActionPresentationData implements ActionPresentation { * @param icon the icon for the action, displayed on the toolbar button. */ - public ActionPresentationData(String text, String description, Icon icon) { + public ActionPresentationData(@NotNull String text, String description, Icon icon) { myText = text; myDescription = description; myIcon = icon; } @Override + @NotNull public String getText() { return myText; } diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/Filter.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/Filter.java similarity index 97% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/Filter.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/Filter.java index f418858a8f1b..3cd07474612f 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/Filter.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/Filter.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. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/Group.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/Group.java similarity index 91% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/Group.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/Group.java index b1ba9a31d8e0..9623cf6a5c4e 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/Group.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/Group.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. @@ -16,6 +16,7 @@ package com.intellij.ide.util.treeView.smartTree; import com.intellij.navigation.ItemPresentation; +import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -30,6 +31,7 @@ public interface Group { * * @return the group presentation. */ + @NotNull ItemPresentation getPresentation(); /** @@ -37,5 +39,6 @@ public interface Group { * * @return the list of nodes. */ + @NotNull Collection getChildren(); } diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/Grouper.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/Grouper.java similarity index 88% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/Grouper.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/Grouper.java index 83381b65c2b0..9c36f0c5f867 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/Grouper.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/Grouper.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. @@ -37,5 +37,6 @@ public interface Grouper extends TreeAction { * @param children the children of the parent node. * @return the collection of groups */ - @NotNull Collection group(final AbstractTreeNode parent, Collection children); + @NotNull + Collection group(@NotNull AbstractTreeNode parent, @NotNull Collection children); } diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/NodeProvider.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/NodeProvider.java similarity index 100% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/NodeProvider.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/NodeProvider.java diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/ProvidingTreeModel.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/ProvidingTreeModel.java similarity index 95% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/ProvidingTreeModel.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/ProvidingTreeModel.java index 8e2263cf6bca..cd2f7a0df243 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/ProvidingTreeModel.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/ProvidingTreeModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/SortableTreeElement.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/SortableTreeElement.java similarity index 89% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/SortableTreeElement.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/SortableTreeElement.java index fda76a576379..6ec0f5484b57 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/SortableTreeElement.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/SortableTreeElement.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. @@ -16,10 +16,13 @@ package com.intellij.ide.util.treeView.smartTree; +import org.jetbrains.annotations.NotNull; + /** * Item in a smart tree which allows using a custom text (other than the presentable text) * as a key for alphabetic sorting. */ public interface SortableTreeElement { + @NotNull String getAlphaSortKey(); } diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/Sorter.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/Sorter.java similarity index 98% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/Sorter.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/Sorter.java index 1b0728de37de..cd0f2dbf6516 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/Sorter.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/Sorter.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. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/SorterUtil.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/SorterUtil.java similarity index 100% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/SorterUtil.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/SorterUtil.java diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/TreeAction.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/TreeAction.java similarity index 97% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/TreeAction.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/TreeAction.java index e35ec5df5dbb..82b907195b04 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/TreeAction.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/TreeAction.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. diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/TreeElement.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/TreeElement.java similarity index 88% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/TreeElement.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/TreeElement.java index b672bfa947ef..407c4437e57b 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/TreeElement.java +++ b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/TreeElement.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. @@ -16,6 +16,7 @@ package com.intellij.ide.util.treeView.smartTree; import com.intellij.navigation.ItemPresentation; +import org.jetbrains.annotations.NotNull; /** * An element in a generic tree control displayed in the IDEA user interface. @@ -24,11 +25,13 @@ import com.intellij.navigation.ItemPresentation; */ public interface TreeElement { + TreeElement[] EMPTY_ARRAY = new TreeElement[0]; /** * Returns the presentation of the tree element. * * @return the element presentation. */ + @NotNull ItemPresentation getPresentation(); /** @@ -36,5 +39,6 @@ public interface TreeElement { * * @return the list of children. */ + @NotNull TreeElement[] getChildren(); } diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/TreeModel.java b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/TreeModel.java similarity index 100% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/TreeModel.java rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/TreeModel.java diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/package.html b/platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/package.html similarity index 100% rename from platform/platform-api/src/com/intellij/ide/util/treeView/smartTree/package.html rename to platform/structure-view-api/src/com/intellij/ide/util/treeView/smartTree/package.html diff --git a/platform/lang-api/src/com/intellij/lang/LanguageStructureViewBuilder.java b/platform/structure-view-api/src/com/intellij/lang/LanguageStructureViewBuilder.java similarity index 97% rename from platform/lang-api/src/com/intellij/lang/LanguageStructureViewBuilder.java rename to platform/structure-view-api/src/com/intellij/lang/LanguageStructureViewBuilder.java index 924f53f6f6f5..df4d76cabf1b 100644 --- a/platform/lang-api/src/com/intellij/lang/LanguageStructureViewBuilder.java +++ b/platform/structure-view-api/src/com/intellij/lang/LanguageStructureViewBuilder.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. diff --git a/platform/lang-api/src/com/intellij/lang/PsiStructureViewFactory.java b/platform/structure-view-api/src/com/intellij/lang/PsiStructureViewFactory.java similarity index 96% rename from platform/lang-api/src/com/intellij/lang/PsiStructureViewFactory.java rename to platform/structure-view-api/src/com/intellij/lang/PsiStructureViewFactory.java index ca9ab8589ed6..afe96269e775 100644 --- a/platform/lang-api/src/com/intellij/lang/PsiStructureViewFactory.java +++ b/platform/structure-view-api/src/com/intellij/lang/PsiStructureViewFactory.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. diff --git a/platform/lang-api/src/com/intellij/navigation/AnonymousElementProvider.java b/platform/structure-view-api/src/com/intellij/navigation/AnonymousElementProvider.java similarity index 100% rename from platform/lang-api/src/com/intellij/navigation/AnonymousElementProvider.java rename to platform/structure-view-api/src/com/intellij/navigation/AnonymousElementProvider.java diff --git a/platform/platform-api/src/com/intellij/openapi/util/PropertyOwner.java b/platform/structure-view-api/src/com/intellij/openapi/util/PropertyOwner.java similarity index 94% rename from platform/platform-api/src/com/intellij/openapi/util/PropertyOwner.java rename to platform/structure-view-api/src/com/intellij/openapi/util/PropertyOwner.java index d8aa8b40840b..c344f15a4e23 100644 --- a/platform/platform-api/src/com/intellij/openapi/util/PropertyOwner.java +++ b/platform/structure-view-api/src/com/intellij/openapi/util/PropertyOwner.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/structure-view-api/structure-view-api.iml b/platform/structure-view-api/structure-view-api.iml new file mode 100644 index 000000000000..199e5f92fca9 --- /dev/null +++ b/platform/structure-view-api/structure-view-api.iml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/lang-impl/src/com/intellij/ide/highlighter/LanguageFileTypeStructureViewBuilderProvider.java b/platform/structure-view-impl/src/com/intellij/ide/highlighter/LanguageFileTypeStructureViewBuilderProvider.java similarity index 97% rename from platform/lang-impl/src/com/intellij/ide/highlighter/LanguageFileTypeStructureViewBuilderProvider.java rename to platform/structure-view-impl/src/com/intellij/ide/highlighter/LanguageFileTypeStructureViewBuilderProvider.java index 9601bfb5dc26..e07d30e77c6e 100644 --- a/platform/lang-impl/src/com/intellij/ide/highlighter/LanguageFileTypeStructureViewBuilderProvider.java +++ b/platform/structure-view-impl/src/com/intellij/ide/highlighter/LanguageFileTypeStructureViewBuilderProvider.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. diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/StructureViewExtension.java b/platform/structure-view-impl/src/com/intellij/ide/structureView/StructureViewExtension.java similarity index 96% rename from platform/lang-impl/src/com/intellij/ide/structureView/StructureViewExtension.java rename to platform/structure-view-impl/src/com/intellij/ide/structureView/StructureViewExtension.java index f92690bacb90..ee94c38030b8 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/StructureViewExtension.java +++ b/platform/structure-view-impl/src/com/intellij/ide/structureView/StructureViewExtension.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. diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/StructureViewFactoryEx.java b/platform/structure-view-impl/src/com/intellij/ide/structureView/StructureViewFactoryEx.java similarity index 99% rename from platform/lang-impl/src/com/intellij/ide/structureView/StructureViewFactoryEx.java rename to platform/structure-view-impl/src/com/intellij/ide/structureView/StructureViewFactoryEx.java index ceb4fa72ca14..d1cf194d0ddb 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/StructureViewFactoryEx.java +++ b/platform/structure-view-impl/src/com/intellij/ide/structureView/StructureViewFactoryEx.java @@ -43,4 +43,4 @@ public abstract class StructureViewFactoryEx extends StructureViewFactory { } public abstract void runWhenInitialized(@NotNull Runnable runnable); -} \ No newline at end of file +} diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/StructureViewWrapper.java b/platform/structure-view-impl/src/com/intellij/ide/structureView/StructureViewWrapper.java similarity index 95% rename from platform/lang-impl/src/com/intellij/ide/structureView/StructureViewWrapper.java rename to platform/structure-view-impl/src/com/intellij/ide/structureView/StructureViewWrapper.java index 17edcf03b9e1..df3f820f708c 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/StructureViewWrapper.java +++ b/platform/structure-view-impl/src/com/intellij/ide/structureView/StructureViewWrapper.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. diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewComposite.java b/platform/structure-view-impl/src/com/intellij/ide/structureView/impl/StructureViewComposite.java similarity index 98% rename from platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewComposite.java rename to platform/structure-view-impl/src/com/intellij/ide/structureView/impl/StructureViewComposite.java index 5d5f42974461..7251d0917ad4 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewComposite.java +++ b/platform/structure-view-impl/src/com/intellij/ide/structureView/impl/StructureViewComposite.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. diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewElementWrapper.java b/platform/structure-view-impl/src/com/intellij/ide/structureView/impl/StructureViewElementWrapper.java similarity index 100% rename from platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewElementWrapper.java rename to platform/structure-view-impl/src/com/intellij/ide/structureView/impl/StructureViewElementWrapper.java diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewModelWrapper.java b/platform/structure-view-impl/src/com/intellij/ide/structureView/impl/StructureViewModelWrapper.java similarity index 100% rename from platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewModelWrapper.java rename to platform/structure-view-impl/src/com/intellij/ide/structureView/impl/StructureViewModelWrapper.java diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewState.java b/platform/structure-view-impl/src/com/intellij/ide/structureView/impl/StructureViewState.java similarity index 96% rename from platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewState.java rename to platform/structure-view-impl/src/com/intellij/ide/structureView/impl/StructureViewState.java index 2e2f7252b81a..403487d4a8e1 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewState.java +++ b/platform/structure-view-impl/src/com/intellij/ide/structureView/impl/StructureViewState.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. diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/impl/common/PsiTreeElementBase.java b/platform/structure-view-impl/src/com/intellij/ide/structureView/impl/common/PsiTreeElementBase.java similarity index 100% rename from platform/lang-impl/src/com/intellij/ide/structureView/impl/common/PsiTreeElementBase.java rename to platform/structure-view-impl/src/com/intellij/ide/structureView/impl/common/PsiTreeElementBase.java diff --git a/platform/lang-impl/src/com/intellij/ide/util/InheritedMembersNodeProvider.java b/platform/structure-view-impl/src/com/intellij/ide/util/InheritedMembersNodeProvider.java similarity index 84% rename from platform/lang-impl/src/com/intellij/ide/util/InheritedMembersNodeProvider.java rename to platform/structure-view-impl/src/com/intellij/ide/util/InheritedMembersNodeProvider.java index 3b7a1d6257b9..c74d7e06887e 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/InheritedMembersNodeProvider.java +++ b/platform/structure-view-impl/src/com/intellij/ide/util/InheritedMembersNodeProvider.java @@ -21,14 +21,14 @@ import com.intellij.ide.util.treeView.smartTree.ActionPresentation; import com.intellij.ide.util.treeView.smartTree.ActionPresentationData; import com.intellij.ide.util.treeView.smartTree.TreeElement; import com.intellij.openapi.actionSystem.Shortcut; -import com.intellij.openapi.keymap.KeymapManager; +import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; /** * @author Konstantin Bulenkov */ -public abstract class InheritedMembersNodeProvider implements FileStructureNodeProvider { +public abstract class InheritedMembersNodeProvider implements FileStructureNodeProvider, ActionShortcutProvider { @NonNls public static final String ID = "SHOW_INHERITED"; @NotNull @@ -40,9 +40,14 @@ public abstract class InheritedMembersNodeProvider implem @NotNull @Override public Shortcut[] getShortcut() { - return KeymapManager.getInstance().getActiveKeymap().getShortcuts("FileStructurePopup"); + throw new IncorrectOperationException("see getActionIdForShortcut()"); } + @NotNull + @Override + public String getActionIdForShortcut() { + return "FileStructurePopup"; + } @Override @NotNull diff --git a/platform/lang-impl/src/com/intellij/ide/util/treeView/AbstractTreeStructureBase.java b/platform/structure-view-impl/src/com/intellij/ide/util/treeView/AbstractTreeStructureBase.java similarity index 95% rename from platform/lang-impl/src/com/intellij/ide/util/treeView/AbstractTreeStructureBase.java rename to platform/structure-view-impl/src/com/intellij/ide/util/treeView/AbstractTreeStructureBase.java index 6ba301ad9b67..0a516ae16501 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/treeView/AbstractTreeStructureBase.java +++ b/platform/structure-view-impl/src/com/intellij/ide/util/treeView/AbstractTreeStructureBase.java @@ -16,7 +16,7 @@ package com.intellij.ide.util.treeView; -import com.intellij.ide.projectView.ProjectViewNode; +import com.intellij.ide.projectView.SettingsProvider; import com.intellij.ide.projectView.TreeStructureProvider; import com.intellij.ide.projectView.ViewSettings; import com.intellij.openapi.diagnostic.Logger; @@ -47,7 +47,7 @@ public abstract class AbstractTreeStructureBase extends AbstractTreeStructure { Collection elements = treeNode.getChildren(); List providers = getProvidersDumbAware(); if (!providers.isEmpty()) { - ViewSettings settings = treeNode instanceof ProjectViewNode ? ((ProjectViewNode) treeNode).getSettings() : ViewSettings.DEFAULT; + ViewSettings settings = treeNode instanceof SettingsProvider ? ((SettingsProvider)treeNode).getSettings() : ViewSettings.DEFAULT; for (TreeStructureProvider provider : providers) { try { elements = provider.modify(treeNode, (Collection)elements, settings); diff --git a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/CachingChildrenTreeNode.java b/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/CachingChildrenTreeNode.java similarity index 100% rename from platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/CachingChildrenTreeNode.java rename to platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/CachingChildrenTreeNode.java diff --git a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/GroupWrapper.java b/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/GroupWrapper.java similarity index 100% rename from platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/GroupWrapper.java rename to platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/GroupWrapper.java diff --git a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java b/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java similarity index 98% rename from platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java rename to platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java index e2a10b4d421b..478c160b8c14 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java +++ b/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.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. diff --git a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/TreeElementWrapper.java b/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/TreeElementWrapper.java similarity index 100% rename from platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/TreeElementWrapper.java rename to platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/TreeElementWrapper.java diff --git a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/TreeStructureUtil.java b/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/TreeStructureUtil.java similarity index 71% rename from platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/TreeStructureUtil.java rename to platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/TreeStructureUtil.java index a08f3180b109..ce62a748559e 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/TreeStructureUtil.java +++ b/platform/structure-view-impl/src/com/intellij/ide/util/treeView/smartTree/TreeStructureUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,9 @@ package com.intellij.ide.util.treeView.smartTree; import com.intellij.ide.util.treeView.AbstractTreeStructure; +import com.intellij.ui.PlaceHolder; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import java.util.HashSet; @@ -24,6 +27,8 @@ import java.util.HashSet; * @author Maxim.Mossienko */ public class TreeStructureUtil { + public static final String PLACE = "StructureViewPopup"; + private TreeStructureUtil() {} public static Object[] getChildElementsFromTreeStructure(AbstractTreeStructure treeStructure, Object element) { @@ -37,4 +42,13 @@ public class TreeStructureUtil { return items; } + + public static boolean isInStructureViewPopup(@NotNull PlaceHolder model) { + return PLACE.equals(model.getPlace()); + } + + @NonNls + public static String getPropertyName(String propertyName) { + return propertyName + ".file.structure.state"; + } } diff --git a/platform/structure-view-impl/structure-view-impl.iml b/platform/structure-view-impl/structure-view-impl.iml new file mode 100644 index 000000000000..35a80b95dec3 --- /dev/null +++ b/platform/structure-view-impl/structure-view-impl.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/xml/impl/xml.iml b/xml/impl/xml.iml index 20135bdba460..2fda30d0d4af 100644 --- a/xml/impl/xml.iml +++ b/xml/impl/xml.iml @@ -20,6 +20,7 @@ + diff --git a/xml/openapi/xml-openapi.iml b/xml/openapi/xml-openapi.iml index d6d222394004..ca52bae6ea88 100644 --- a/xml/openapi/xml-openapi.iml +++ b/xml/openapi/xml-openapi.iml @@ -10,6 +10,7 @@ + diff --git a/xml/tests/src/com/intellij/xml/structureView/HtmlFileStructureTest.java b/xml/tests/src/com/intellij/xml/structureView/HtmlFileStructureTest.java index 77aab443bd03..d71aa3b25e87 100644 --- a/xml/tests/src/com/intellij/xml/structureView/HtmlFileStructureTest.java +++ b/xml/tests/src/com/intellij/xml/structureView/HtmlFileStructureTest.java @@ -1,7 +1,22 @@ +/* + * 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.xml.structureView; -import com.intellij.ide.util.FileStructurePopup; import com.intellij.ide.util.PropertiesComponent; +import com.intellij.ide.util.treeView.smartTree.TreeStructureUtil; import com.intellij.lang.html.structureView.Html5SectionsNodeProvider; import com.intellij.testFramework.FileStructureTestBase; @@ -22,7 +37,7 @@ public class HtmlFileStructureTest extends FileStructureTestBase { } private static String getHtml5OutlineModePropertyName() { - return FileStructurePopup.getPropertyName(Html5SectionsNodeProvider.HTML5_OUTLINE_PROVIDER_PROPERTY); + return TreeStructureUtil.getPropertyName(Html5SectionsNodeProvider.HTML5_OUTLINE_PROVIDER_PROPERTY); } @Override diff --git a/xml/openapi/src/com/intellij/ide/structureView/xml/XmlStructureViewBuilderProvider.java b/xml/xml-structure-view-api/src/com/intellij/ide/structureView/xml/XmlStructureViewBuilderProvider.java similarity index 96% rename from xml/openapi/src/com/intellij/ide/structureView/xml/XmlStructureViewBuilderProvider.java rename to xml/xml-structure-view-api/src/com/intellij/ide/structureView/xml/XmlStructureViewBuilderProvider.java index 8099e2de1107..6ca6a5953729 100644 --- a/xml/openapi/src/com/intellij/ide/structureView/xml/XmlStructureViewBuilderProvider.java +++ b/xml/xml-structure-view-api/src/com/intellij/ide/structureView/xml/XmlStructureViewBuilderProvider.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. diff --git a/xml/openapi/src/com/intellij/ide/structureView/xml/XmlStructureViewElementProvider.java b/xml/xml-structure-view-api/src/com/intellij/ide/structureView/xml/XmlStructureViewElementProvider.java similarity index 96% rename from xml/openapi/src/com/intellij/ide/structureView/xml/XmlStructureViewElementProvider.java rename to xml/xml-structure-view-api/src/com/intellij/ide/structureView/xml/XmlStructureViewElementProvider.java index 74b0aae2965d..4ff17cac86b4 100644 --- a/xml/openapi/src/com/intellij/ide/structureView/xml/XmlStructureViewElementProvider.java +++ b/xml/xml-structure-view-api/src/com/intellij/ide/structureView/xml/XmlStructureViewElementProvider.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. diff --git a/xml/xml-structure-view-api/xml-structure-view-api.iml b/xml/xml-structure-view-api/xml-structure-view-api.iml new file mode 100644 index 000000000000..15af705d61aa --- /dev/null +++ b/xml/xml-structure-view-api/xml-structure-view-api.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/xml/impl/src/com/intellij/ide/structureView/impl/xml/AbstractXmlTagTreeElement.java b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/AbstractXmlTagTreeElement.java similarity index 98% rename from xml/impl/src/com/intellij/ide/structureView/impl/xml/AbstractXmlTagTreeElement.java rename to xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/AbstractXmlTagTreeElement.java index fde490604718..2383784267ae 100644 --- a/xml/impl/src/com/intellij/ide/structureView/impl/xml/AbstractXmlTagTreeElement.java +++ b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/AbstractXmlTagTreeElement.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. diff --git a/xml/impl/src/com/intellij/ide/structureView/impl/xml/DtdFileTreeElement.java b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/DtdFileTreeElement.java similarity index 99% rename from xml/impl/src/com/intellij/ide/structureView/impl/xml/DtdFileTreeElement.java rename to xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/DtdFileTreeElement.java index c8f23585d100..8ca2b8933572 100644 --- a/xml/impl/src/com/intellij/ide/structureView/impl/xml/DtdFileTreeElement.java +++ b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/DtdFileTreeElement.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. diff --git a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlFileTreeElement.java b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/XmlFileTreeElement.java similarity index 98% rename from xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlFileTreeElement.java rename to xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/XmlFileTreeElement.java index e1cd6a213410..f13fe1ccba61 100644 --- a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlFileTreeElement.java +++ b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/XmlFileTreeElement.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. diff --git a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java similarity index 89% rename from xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java rename to xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java index 3067f38411a9..34790afb56d3 100644 --- a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java +++ b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/XmlStructureViewTreeModel.java @@ -23,25 +23,23 @@ import com.intellij.ide.util.treeView.smartTree.Sorter; import com.intellij.lang.dtd.DTDLanguage; import com.intellij.openapi.editor.Editor; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; import com.intellij.psi.xml.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class XmlStructureViewTreeModel extends TextEditorBasedStructureViewModel { - private final XmlFile myFile; private static final Class[] CLASSES = {XmlTag.class, XmlFile.class, XmlEntityDecl.class, XmlElementDecl.class, XmlAttlistDecl.class, XmlConditionalSection.class}; private static final Sorter[] SORTERS = {Sorter.ALPHA_SORTER}; - public XmlStructureViewTreeModel(XmlFile file, @Nullable Editor editor) { + public XmlStructureViewTreeModel(@NotNull XmlFile file, @Nullable Editor editor) { super(editor, file); - myFile = file; } @Override @NotNull public StructureViewTreeElement getRoot() { + XmlFile myFile = getPsiFile(); if (myFile.getLanguage() == DTDLanguage.INSTANCE) return new DtdFileTreeElement(myFile); return new XmlFileTreeElement(myFile); } @@ -52,8 +50,8 @@ public class XmlStructureViewTreeModel extends TextEditorBasedStructureViewModel } @Override - protected PsiFile getPsiFile() { - return myFile; + protected XmlFile getPsiFile() { + return (XmlFile)super.getPsiFile(); } @Override @@ -66,7 +64,7 @@ public class XmlStructureViewTreeModel extends TextEditorBasedStructureViewModel public Object getCurrentEditorElement() { final Object editorElement = super.getCurrentEditorElement(); if (editorElement instanceof XmlTag) { - for (StructureViewExtension extension : StructureViewFactoryEx.getInstanceEx(myFile.getProject()).getAllExtensions(XmlTag.class)) { + for (StructureViewExtension extension : StructureViewFactoryEx.getInstanceEx(getPsiFile().getProject()).getAllExtensions(XmlTag.class)) { final Object element = extension.getCurrentEditorElement(getEditor(), (PsiElement)editorElement); if (element != null) return element; } diff --git a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java similarity index 98% rename from xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java rename to xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java index ee75742ad237..eddd19cf5b4c 100644 --- a/xml/impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.java +++ b/xml/xml-structure-view-impl/src/com/intellij/ide/structureView/impl/xml/XmlTagTreeElement.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. diff --git a/xml/impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java b/xml/xml-structure-view-impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java similarity index 97% rename from xml/impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java rename to xml/xml-structure-view-impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java index fcccefe44f88..d6dc3c8cade3 100644 --- a/xml/impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.java +++ b/xml/xml-structure-view-impl/src/com/intellij/lang/dtd/DtdStructureViewBuilderFactory.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. diff --git a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java b/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java similarity index 98% rename from xml/impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java rename to xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java index f18222f69592..baee9a1534ec 100644 --- a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.java +++ b/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/Html5SectionTreeElement.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. diff --git a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java b/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java similarity index 87% rename from xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java rename to xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java index fb7e5a30caed..97409f894622 100644 --- a/xml/impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java +++ b/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/Html5SectionsNodeProvider.java @@ -16,18 +16,19 @@ package com.intellij.lang.html.structureView; import com.intellij.icons.AllIcons; +import com.intellij.ide.util.ActionShortcutProvider; import com.intellij.ide.util.FileStructureNodeProvider; import com.intellij.ide.util.treeView.smartTree.ActionPresentation; import com.intellij.ide.util.treeView.smartTree.ActionPresentationData; import com.intellij.ide.util.treeView.smartTree.TreeElement; import com.intellij.openapi.actionSystem.Shortcut; -import com.intellij.openapi.keymap.KeymapManager; import com.intellij.openapi.util.PropertyOwner; import com.intellij.psi.filters.XmlTagFilter; import com.intellij.psi.scope.processor.FilterElementProcessor; import com.intellij.psi.xml.XmlDocument; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; +import com.intellij.util.IncorrectOperationException; import com.intellij.xml.XmlBundle; import org.jetbrains.annotations.NotNull; @@ -36,7 +37,8 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -public class Html5SectionsNodeProvider implements FileStructureNodeProvider, PropertyOwner { +public class Html5SectionsNodeProvider implements FileStructureNodeProvider, PropertyOwner, + ActionShortcutProvider { public static final String ACTION_ID = "HTML5_OUTLINE_MODE"; public static final String HTML5_OUTLINE_PROVIDER_PROPERTY = "html5.sections.node.provider"; @@ -59,10 +61,16 @@ public class Html5SectionsNodeProvider implements FileStructureNodeProvider { if (xmlFile == null) return false; if (myInStructureViewPopup) { - final String propertyName = FileStructurePopup.getPropertyName(Html5SectionsNodeProvider.HTML5_OUTLINE_PROVIDER_PROPERTY); + final String propertyName = TreeStructureUtil.getPropertyName(Html5SectionsNodeProvider.HTML5_OUTLINE_PROVIDER_PROPERTY); if (PropertiesComponent.getInstance().getBoolean(propertyName, false)) { return true; } diff --git a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java b/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java similarity index 97% rename from xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java rename to xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java index 9a8741d308a8..91e17be3b451 100644 --- a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.java +++ b/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/HtmlStructureViewBuilderProvider.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. diff --git a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java b/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java similarity index 92% rename from xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java rename to xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java index f4f080d43c26..6efe68c75ceb 100644 --- a/xml/impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java +++ b/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/HtmlStructureViewTreeModel.java @@ -17,7 +17,6 @@ package com.intellij.lang.html.structureView; import com.intellij.icons.AllIcons; import com.intellij.ide.IdeBundle; -import com.intellij.ide.actions.ViewStructureAction; import com.intellij.ide.structureView.StructureViewTreeElement; import com.intellij.ide.structureView.impl.xml.XmlStructureViewTreeModel; import com.intellij.ide.util.treeView.smartTree.*; @@ -36,7 +35,7 @@ class HtmlStructureViewTreeModel extends XmlStructureViewTreeModel implements Pl private final Collection myNodeProviders; private String myStructureViewPlace; - private static Sorter HTML_ALPHA_SORTER = new Sorter() { + private static final Sorter HTML_ALPHA_SORTER = new Sorter() { @NotNull @Override public Comparator getComparator() { @@ -106,7 +105,7 @@ class HtmlStructureViewTreeModel extends XmlStructureViewTreeModel implements Pl @Override @NotNull public Sorter[] getSorters() { - if (ViewStructureAction.isInStructureViewPopup(this)) { + if (TreeStructureUtil.isInStructureViewPopup(this)) { return Sorter.EMPTY_ARRAY; // because in popup there's no option to disable sorter } @@ -122,6 +121,6 @@ class HtmlStructureViewTreeModel extends XmlStructureViewTreeModel implements Pl @Override @NotNull public StructureViewTreeElement getRoot() { - return new HtmlFileTreeElement(ViewStructureAction.isInStructureViewPopup(this), (XmlFile)getPsiFile()); + return new HtmlFileTreeElement(TreeStructureUtil.isInStructureViewPopup(this), (XmlFile)getPsiFile()); } } diff --git a/xml/impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java b/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java similarity index 99% rename from xml/impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java rename to xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java index f896146608db..ad060e2261e3 100644 --- a/xml/impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.java +++ b/xml/xml-structure-view-impl/src/com/intellij/lang/html/structureView/HtmlTagTreeElement.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. diff --git a/xml/impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java b/xml/xml-structure-view-impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java similarity index 98% rename from xml/impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java rename to xml/xml-structure-view-impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java index ba2721457763..97bb3ec1460c 100644 --- a/xml/impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.java +++ b/xml/xml-structure-view-impl/src/com/intellij/lang/xml/XmlStructureViewBuilderFactory.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. diff --git a/xml/xml-structure-view-impl/xml-structure-view-impl.iml b/xml/xml-structure-view-impl/xml-structure-view-impl.iml new file mode 100644 index 000000000000..538b123a1fc9 --- /dev/null +++ b/xml/xml-structure-view-impl/xml-structure-view-impl.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + From 825f767bde479d83c710ba98a5630de8cfb1ef2a Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Fri, 21 Feb 2014 17:53:34 +0400 Subject: [PATCH 36/75] NPE fix in FormatterTagHandler.getFormatterTag() --- .../src/com/intellij/formatting/FormatterTagHandler.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/formatting/FormatterTagHandler.java b/platform/lang-impl/src/com/intellij/formatting/FormatterTagHandler.java index af5164daad06..e475f8cf83d4 100644 --- a/platform/lang-impl/src/com/intellij/formatting/FormatterTagHandler.java +++ b/platform/lang-impl/src/com/intellij/formatting/FormatterTagHandler.java @@ -48,9 +48,11 @@ public class FormatterTagHandler { !StringUtil.isEmpty(mySettings.FORMATTER_OFF_TAG) && block instanceof ASTBlock) { ASTNode node = ((ASTBlock)block).getNode(); - PsiElement element = node.getPsi(); - if (element != null && element instanceof PsiComment) { - return getFormatterTag((PsiComment)element); + if (node != null) { + PsiElement element = node.getPsi(); + if (element != null && element instanceof PsiComment) { + return getFormatterTag((PsiComment)element); + } } } return FormatterTag.NONE; From a3548b0bf31dabd7baf1b30c1fe4c1edeb0afa1c Mon Sep 17 00:00:00 2001 From: Denis Fokin Date: Fri, 21 Feb 2014 17:59:58 +0400 Subject: [PATCH 37/75] Fix for focus traversal. --- .../intellij/ui/messages/SheetController.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java b/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java index 97b376534c2d..c2b6e7461ea3 100755 --- a/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java +++ b/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java @@ -160,23 +160,24 @@ public class SheetController { sheetPanel.add(headerLabel); - JEditorPane textArea = new JEditorPane(); + JEditorPane messageTextPane = new JEditorPane(); - textArea.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); - textArea.setFont(regularFont); - textArea.setEditable(false); + messageTextPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); + messageTextPane.setFont(regularFont); + messageTextPane.setEditable(false); - textArea.setContentType("text/html"); - textArea.setSize(250, Short.MAX_VALUE); - textArea.setText(message); - messageArea.setSize(250, textArea.getPreferredSize().height); - textArea.setSize(messageArea); + messageTextPane.setContentType("text/html"); + messageTextPane.setSize(250, Short.MAX_VALUE); + messageTextPane.setText(message); + messageArea.setSize(250, messageTextPane.getPreferredSize().height); + messageTextPane.setSize(messageArea); - textArea.setOpaque(false); + messageTextPane.setOpaque(false); + messageTextPane.setFocusable(false); - sheetPanel.add(textArea); + sheetPanel.add(messageTextPane); - textArea.repaint(); + messageTextPane.repaint(); SHEET_HEIGHT = 20 + headerLabel.getPreferredSize().height + 10 + messageArea.height + 10 + 70; @@ -187,9 +188,11 @@ public class SheetController { ico.setLocation(20, 20); sheetPanel.add(ico); headerLabel.setLocation(120, 20); - textArea.setLocation(120, 20 + headerLabel.getPreferredSize().height + 10); + messageTextPane.setLocation(120, 20 + headerLabel.getPreferredSize().height + 10); layoutWithAbsoluteLayout(buttons, sheetPanel); + sheetPanel.setFocusCycleRoot(true); + return sheetPanel; } @@ -267,8 +270,6 @@ public class SheetController { final BufferedImage image = UIUtil.createImage(SHEET_WIDTH, SHEET_HEIGHT, BufferedImage.TYPE_INT_ARGB); - - mySheetPanel.paint(image.createGraphics()); myOffScreenFrame.dispose(); return image; From cc56534dec9532242c1034cd9b763d9c59efe931 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 21 Feb 2014 14:31:46 +0100 Subject: [PATCH 38/75] IDEA-118094 smart completion in annotation: allow exclude --- .../ExcludeFromCompletionLookupActionProvider.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/ExcludeFromCompletionLookupActionProvider.java b/java/java-impl/src/com/intellij/codeInsight/completion/ExcludeFromCompletionLookupActionProvider.java index bc00fa223385..ec7c5c5ffde4 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/ExcludeFromCompletionLookupActionProvider.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/ExcludeFromCompletionLookupActionProvider.java @@ -32,7 +32,11 @@ import org.jetbrains.annotations.Nullable; public class ExcludeFromCompletionLookupActionProvider implements LookupActionProvider { @Override public void fillActions(LookupElement element, Lookup lookup, Consumer consumer) { - final Object o = element.getObject(); + Object o = element.getObject(); + if (o instanceof PsiClassObjectAccessExpression) { + o = PsiUtil.resolveClassInType(((PsiClassObjectAccessExpression)o).getOperand().getType()); + } + if (o instanceof PsiClass) { PsiClass clazz = (PsiClass)o; addExcludes(consumer, clazz, clazz.getQualifiedName()); From fdee76603c332bbcb65d10fa5b56fa444b9f9307 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 21 Feb 2014 14:44:06 +0100 Subject: [PATCH 39/75] IDEA-117332 Change signature refactoring should warn about @Contract conflict --- .../JavaChangeSignatureUsageProcessor.java | 16 ++++++++++++---- .../changeSignature/WarnAboutContract.java | 6 ++++++ .../refactoring/ChangeSignatureTest.java | 9 +++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 java/java-tests/testData/refactoring/changeSignature/WarnAboutContract.java diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java index e8bb45ce350d..83de0ed2f516 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java @@ -17,6 +17,7 @@ package com.intellij.refactoring.changeSignature; import com.intellij.codeInsight.ExceptionUtil; import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil; +import com.intellij.codeInspection.dataFlow.ControlFlowAnalyzer; import com.intellij.lang.StdLanguages; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; @@ -884,7 +885,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr private static class ConflictSearcher { private final JavaChangeInfo myChangeInfo; - private ConflictSearcher(JavaChangeInfo changeInfo) { + private ConflictSearcher(@NotNull JavaChangeInfo changeInfo) { this.myChangeInfo = changeInfo; } @@ -901,6 +902,8 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr LOG.error(e); } } + + checkContract(conflictDescriptions, myChangeInfo.getMethod()); for (UsageInfo usageInfo : usagesSet) { final PsiElement element = usageInfo.getElement(); @@ -914,6 +917,8 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr conflictDescriptions.putValue(baseMethod, "Implicit last parameter should not be deleted"); } } + + checkContract(conflictDescriptions, method); } else if (element instanceof PsiMethodReferenceExpression) { conflictDescriptions.putValue(element, "Changed method is used in method reference"); } @@ -922,6 +927,12 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr return conflictDescriptions; } + private static void checkContract(MultiMap conflictDescriptions, PsiMethod method) { + if (ControlFlowAnalyzer.findContractAnnotation(method) != null) { + conflictDescriptions.putValue(method, "@Contract annotation will have to be changed manually"); + } + } + private boolean needToChangeCalls() { return myChangeInfo.isNameChanged() || myChangeInfo.isParameterSetOrOrderChanged() || myChangeInfo.isExceptionSetOrOrderChanged(); } @@ -964,9 +975,6 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr private void addMethodConflicts(MultiMap conflicts) { String newMethodName = myChangeInfo.getNewName(); - if (!(myChangeInfo instanceof JavaChangeInfo)) { - return; - } try { PsiMethod prototype; final PsiMethod method = myChangeInfo.getMethod(); diff --git a/java/java-tests/testData/refactoring/changeSignature/WarnAboutContract.java b/java/java-tests/testData/refactoring/changeSignature/WarnAboutContract.java new file mode 100644 index 000000000000..f3f573e9bde2 --- /dev/null +++ b/java/java-tests/testData/refactoring/changeSignature/WarnAboutContract.java @@ -0,0 +1,6 @@ +class A { + @org.jetbrains.annotations.Contract("null,_->fail") + public int method(Object i, Object j) { + return 0; + } +} diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java index e769c7a88c85..51905419d22c 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ChangeSignatureTest.java @@ -42,6 +42,15 @@ public class ChangeSignatureTest extends LightRefactoringTestCase { doTest(null, new ParameterInfoImpl[]{new ParameterInfoImpl(1), new ParameterInfoImpl(0)}, false); } + public void testWarnAboutContract() throws Exception { + try { + doTest(null, new ParameterInfoImpl[]{new ParameterInfoImpl(1), new ParameterInfoImpl(0)}, false); + fail("Conflict expected"); + } + catch (BaseRefactoringProcessor.ConflictsInTestsException ignored) { + } + } + public void testGenericTypes() throws Exception { doTest(null, null, "T", new GenParams() { @Override From 26a4855fe0bfb4e641eded9e3f462d6fe3fbb28c Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 21 Feb 2014 15:58:43 +0100 Subject: [PATCH 40/75] hide psiFileFactory --- .../console/LanguageConsoleBuilder.java | 19 ++++++++++++- .../console/LanguageConsoleImpl.java | 27 ++++--------------- .../groovy/console/GroovyConsoleAction.java | 14 +++++----- 3 files changed, 30 insertions(+), 30 deletions(-) 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 70939f3a4f12..c38d6b52769c 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java @@ -26,6 +26,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; +import com.intellij.testFramework.LightVirtualFile; import com.intellij.ui.components.JBLayeredPane; import com.intellij.util.Consumer; import com.intellij.util.PairFunction; @@ -35,6 +36,9 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; +/** + * @experimental + */ public final class LanguageConsoleBuilder { @Nullable private LanguageConsoleView consoleView; @@ -153,15 +157,28 @@ public final class LanguageConsoleBuilder { private final static class GutteredLanguageConsole extends LanguageConsoleImpl { @Nullable private final GutterContentProvider gutterContentProvider; + private final PairFunction psiFileFactory; public GutteredLanguageConsole(@NotNull Project project, @NotNull Language language, @Nullable GutterContentProvider gutterContentProvider, @Nullable PairFunction psiFileFactory) { - super(project, language.getDisplayName() + " Console", language, psiFileFactory); + super(project, language.getDisplayName() + " Console", language); setShowSeparatorLine(false); this.gutterContentProvider = gutterContentProvider; + this.psiFileFactory = psiFileFactory; + } + + @NotNull + @Override + protected PsiFile createFile(@NotNull LightVirtualFile virtualFile, @NotNull Document document, @NotNull Project project) { + if (psiFileFactory == null) { + return super.createFile(virtualFile, document, project); + } + else { + return psiFileFactory.fun(virtualFile, project); + } } @Override 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 79373dc75ff8..3ec577da2259 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java @@ -58,7 +58,10 @@ import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.testFramework.LightVirtualFile; import com.intellij.ui.JBColor; import com.intellij.ui.SideBorder; -import com.intellij.util.*; +import com.intellij.util.DocumentUtil; +import com.intellij.util.FileContentUtil; +import com.intellij.util.ObjectUtils; +import com.intellij.util.SingleAlarm; import com.intellij.util.ui.AbstractLayoutManager; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -112,8 +115,6 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider { } }; - private final PairFunction myPsiFileFactory; - public LanguageConsoleImpl(@NotNull Project project, @NotNull String title, @NotNull Language language) { this(project, title, language, true); } @@ -122,19 +123,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider { this(project, title, new LightVirtualFile(title, language, ""), initComponents); } - public LanguageConsoleImpl(@NotNull Project project, @NotNull String title, @NotNull Language language, @Nullable PairFunction psiFileFactory) { - this(project, title, new LightVirtualFile(title, language, ""), false, psiFileFactory); - } - public LanguageConsoleImpl(@NotNull Project project, @NotNull String title, @NotNull LightVirtualFile lightFile, boolean initComponents) { - this(project, title, lightFile, initComponents, null); - } - - public LanguageConsoleImpl(@NotNull Project project, - @NotNull String title, - @NotNull LightVirtualFile lightFile, - boolean initComponents, - @Nullable PairFunction psiFileFactory) { myProject = project; myTitle = title; myVirtualFile = lightFile; @@ -142,7 +131,6 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider { myHistoryFile = new LightVirtualFile(getTitle() + ".history.txt", FileTypes.PLAIN_TEXT, ""); myEditorDocument = FileDocumentManager.getInstance().getDocument(lightFile); assert myEditorDocument != null; - myPsiFileFactory = psiFileFactory; myFile = createFile(myVirtualFile, myEditorDocument, myProject); myConsoleEditor = (EditorEx)editorFactory.createEditor(myEditorDocument, myProject); myConsoleEditor.addFocusListener(myFocusListener); @@ -691,12 +679,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider { @NotNull protected PsiFile createFile(@NotNull LightVirtualFile virtualFile, @NotNull Document document, @NotNull Project project) { - if (myPsiFileFactory == null) { - return ObjectUtils.assertNotNull(PsiManager.getInstance(project).findFile(virtualFile)); - } - else { - return myPsiFileFactory.fun(virtualFile, project); - } + return ObjectUtils.assertNotNull(PsiManager.getInstance(project).findFile(virtualFile)); } private class MyLayout extends AbstractLayoutManager { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleAction.java index 9f725754c5bc..308f932ddd18 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleAction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleAction.java @@ -16,11 +16,11 @@ package org.jetbrains.plugins.groovy.console; import com.intellij.execution.console.LanguageConsoleImpl; +import com.intellij.openapi.editor.Document; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; -import com.intellij.util.PairFunction; +import com.intellij.testFramework.LightVirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.GroovyFileType; import org.jetbrains.plugins.groovy.debugger.fragments.GroovyCodeFragment; @@ -40,13 +40,13 @@ public class GroovyConsoleAction extends GroovyShellActionBase { } @Override - protected LanguageConsoleImpl createConsole(@NotNull Project project, String title) { - return new LanguageConsoleImpl(project, title, GroovyFileType.GROOVY_LANGUAGE, new PairFunction() { + protected LanguageConsoleImpl createConsole(Project project, String title) { + return new LanguageConsoleImpl(project, title, GroovyFileType.GROOVY_LANGUAGE) { @NotNull @Override - public PsiFile fun(@NotNull VirtualFile file, @NotNull Project project) { - return new GroovyCodeFragment(project, file); + protected PsiFile createFile(@NotNull LightVirtualFile virtualFile, @NotNull Document document, @NotNull Project project) { + return new GroovyCodeFragment(getProject(), virtualFile); } - }); + }; } } From 4d7c38f3f9bdd23511cb6c8a8f677194d722a94f Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 21 Feb 2014 16:01:29 +0100 Subject: [PATCH 41/75] recover from EA-53754 - IOOBE: CharSequenceSubSequence. (BlockSupportImpl) not only in internal mode --- .../impl/source/text/BlockSupportImpl.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java b/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java index b5070410025f..13a85846a045 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/text/BlockSupportImpl.java @@ -19,6 +19,7 @@ package com.intellij.psi.impl.source.text; import com.intellij.lang.ASTNode; import com.intellij.lang.Language; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.diagnostic.Attachment; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.ex.DocumentBulkUpdateListener; @@ -137,22 +138,24 @@ public class BlockSupportImpl extends BlockSupport { } private static boolean assertFileLength(PsiFile file, CharSequence newFileText, ASTNode node, IElementType elementType, int start, int end) { - if ((end > newFileText.length() || start > end) && ApplicationManager.getApplication().isInternal()) { - String newTextBefore = newFileText.subSequence(0, start).toString(); - String oldTextBefore = file.getText().subSequence(0, start).toString(); + if (end > newFileText.length() || start > end) { String message = "IOOBE: type=" + elementType + + "; file=" + file + + "; file.class=" + file.getClass() + "; start=" + start + "; end=" + end + - "; oldText=" + node.getText() + - "; newText=" + newFileText.subSequence(start, newFileText.length()) + "; length=" + node.getTextLength(); + String newTextBefore = newFileText.subSequence(0, start).toString(); + String oldTextBefore = file.getText().subSequence(0, start).toString(); if (oldTextBefore.equals(newTextBefore)) { message += "; oldTextBefore==newTextBefore"; - } else { - message += "; oldTextBefore=" + oldTextBefore + - "; newTextBefore=" + newTextBefore; } - LOG.error(message); + LOG.error(message, + new Attachment(file.getName() + "_oldText.txt", node.getText()), + new Attachment(file.getName() + "_newText.txt", node.getText()), + new Attachment(file.getName() + "_oldTextBefore.txt", oldTextBefore), + new Attachment(file.getName() + "_newTextBefore.txt", newTextBefore) + ); return false; } return true; From a5c59c2017b5ec3b2ba33c618deb55e9224a18b1 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Fri, 21 Feb 2014 17:59:54 +0400 Subject: [PATCH 42/75] github: fix 'open in browser' url /tree/ - for directories /blob/ - fol files GitHub automatically converts one to another Except one case: root folder. /blob/master -> 404, not into /tree/master --- .../plugins/github/GithubOpenInBrowserAction.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java index f587d44c8cb6..cec5ba269721 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java @@ -22,6 +22,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.SelectionModel; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vfs.VirtualFile; @@ -156,7 +157,12 @@ public class GithubOpenInBrowserAction extends DumbAwareAction { if (githubRepoUrl == null) { return null; } - builder.append(githubRepoUrl).append("/blob/").append(branch).append(relativePath); + if (StringUtil.isEmptyOrSpaces(relativePath)) { + builder.append(githubRepoUrl).append("/tree/").append(branch); + } + else { + builder.append(githubRepoUrl).append("/blob/").append(branch).append(relativePath); + } if (editor != null && editor.getDocument().getLineCount() >= 1) { // lines are counted internally from 0, but from 1 on github From c2a4f0d251604d2c5a771b3b496c0a0e953d75dc Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Fri, 21 Feb 2014 20:17:03 +0400 Subject: [PATCH 43/75] IDEA-80056 Column selection mode improvement fix regression (broken completion) for injected editors --- .../codeInsight/completion/CodeCompletionHandlerBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java index aa32ce31a646..a91a2709c80c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java @@ -628,7 +628,7 @@ public class CodeCompletionHandlerBase { @Override public void perform(Caret caret) { CompletionAssertions.WatchingInsertionContext currentContext = insertItem(indicator, item, completionChar, items, update, editor, caret.getOffset(), caret.getOffset() + idEndOffsetDelta); - if (caret == editor.getCaretModel().getPrimaryCaret()) { + if (caret.getVisualPosition().equals(editor.getCaretModel().getPrimaryCaret().getVisualPosition())) { contextRef.set(currentContext); } } From 7130e5ee370a1e580f7a2a8ff3b68d99674eb171 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 21 Feb 2014 17:03:34 +0100 Subject: [PATCH 44/75] cleanup --- .../python/console/PyOpenDebugConsoleAction.java | 2 +- .../console/PythonDebugLanguageConsoleView.java | 6 +----- .../com/jetbrains/python/debugger/PyDebugRunner.java | 12 +++--------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/python/src/com/jetbrains/python/console/PyOpenDebugConsoleAction.java b/python/src/com/jetbrains/python/console/PyOpenDebugConsoleAction.java index 3f4e8011c88a..45906d513f21 100644 --- a/python/src/com/jetbrains/python/console/PyOpenDebugConsoleAction.java +++ b/python/src/com/jetbrains/python/console/PyOpenDebugConsoleAction.java @@ -22,7 +22,6 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.wm.IdeFocusManager; @@ -53,6 +52,7 @@ public class PyOpenDebugConsoleAction extends AnAction implements DumbAware { } } + @Override public void actionPerformed(final AnActionEvent e) { final Project project = e.getData(CommonDataKeys.PROJECT); if (project != null) { diff --git a/python/src/com/jetbrains/python/console/PythonDebugLanguageConsoleView.java b/python/src/com/jetbrains/python/console/PythonDebugLanguageConsoleView.java index b807b3c0a54b..495c26df74c8 100644 --- a/python/src/com/jetbrains/python/console/PythonDebugLanguageConsoleView.java +++ b/python/src/com/jetbrains/python/console/PythonDebugLanguageConsoleView.java @@ -63,7 +63,7 @@ public class PythonDebugLanguageConsoleView extends JPanel implements ConsoleVie public PythonDebugLanguageConsoleView(final Project project, Sdk sdk, ConsoleView consoleView) { super(new CardLayout()); - myPydevConsoleView = createConsoleView(project, sdk); + myPydevConsoleView = new PythonConsoleView(project, "Python Console", sdk); myTextConsole = consoleView; add(myTextConsole.getComponent(), TEXT_CONSOLE_PANEL); @@ -85,10 +85,6 @@ public class PythonDebugLanguageConsoleView extends JPanel implements ConsoleVie getPydevConsoleView().executeCode(code, e); } - private static PythonConsoleView createConsoleView(Project project, Sdk sdk) { - return new PythonConsoleView(project, "Python Console", sdk); - } - private void doShowConsole(String type) { CardLayout cl = (CardLayout)(getLayout()); cl.show(this, type); diff --git a/python/src/com/jetbrains/python/debugger/PyDebugRunner.java b/python/src/com/jetbrains/python/debugger/PyDebugRunner.java index bec10b801ae0..3199200de432 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebugRunner.java +++ b/python/src/com/jetbrains/python/debugger/PyDebugRunner.java @@ -40,7 +40,6 @@ import com.jetbrains.python.PythonHelpersLocator; import com.jetbrains.python.console.PythonConsoleView; import com.jetbrains.python.console.PythonDebugConsoleCommunication; import com.jetbrains.python.console.PythonDebugLanguageConsoleView; -import com.jetbrains.python.console.pydev.ConsoleCommunication; import com.jetbrains.python.run.AbstractPythonRunConfiguration; import com.jetbrains.python.run.CommandLinePatcher; import com.jetbrains.python.run.PythonCommandLineState; @@ -123,19 +122,14 @@ public class PyDebugRunner extends GenericProgramRunner { @NotNull final ExecutionResult result, @NotNull PyDebugProcess debugProcess) { ExecutionConsole console = result.getExecutionConsole(); - ProcessHandler processHandler = result.getProcessHandler(); - if (console instanceof PythonDebugLanguageConsoleView) { PythonConsoleView pythonConsoleView = ((PythonDebugLanguageConsoleView)console).getPydevConsoleView(); + pythonConsoleView.setConsoleCommunication(new PythonDebugConsoleCommunication(project, debugProcess)); - - ConsoleCommunication consoleCommunication = new PythonDebugConsoleCommunication(project, debugProcess); - pythonConsoleView.setConsoleCommunication(consoleCommunication); - + ProcessHandler processHandler = result.getProcessHandler(); PydevDebugConsoleExecuteActionHandler consoleExecuteActionHandler = new PydevDebugConsoleExecuteActionHandler(pythonConsoleView, processHandler, - consoleCommunication); - + new PythonDebugConsoleCommunication(project, debugProcess)); pythonConsoleView.setExecutionHandler(consoleExecuteActionHandler); debugProcess.getSession().addSessionListener(consoleExecuteActionHandler); From 72c51dc1b88ec699fa97f92f71f14a07103b0eb9 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 21 Feb 2014 17:49:33 +0100 Subject: [PATCH 45/75] configurable oneLineInput --- .../console/LanguageConsoleBuilder.java | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) 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 c38d6b52769c..de559b777eb5 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleBuilder.java @@ -55,6 +55,8 @@ public final class LanguageConsoleBuilder { @Nullable private GutterContentProvider gutterContentProvider; + private boolean oneLineInput; + // todo to be removed public LanguageConsoleBuilder(@SuppressWarnings("NullableProblems") @NotNull LanguageConsoleView consoleView) { this.consoleView = consoleView; @@ -74,6 +76,9 @@ public final class LanguageConsoleBuilder { return this; } + /** + * @see {@link com.intellij.psi.PsiCodeFragment} + */ public LanguageConsoleBuilder psiFileFactory(@NotNull PairFunction value) { psiFileFactory = value; return this; @@ -125,8 +130,24 @@ public final class LanguageConsoleBuilder { return this; } + /** + * @see {@link com.intellij.openapi.editor.ex.EditorEx#setOneLineMode(boolean)} + */ + public LanguageConsoleBuilder oneLineInput() { + oneLineInput(true); + return this; + } + + /** + * @see {@link com.intellij.openapi.editor.ex.EditorEx#setOneLineMode(boolean)} + */ + public LanguageConsoleBuilder oneLineInput(boolean value) { + oneLineInput = value; + return this; + } + public LanguageConsoleView build(@NotNull Project project, @NotNull Language language) { - GutteredLanguageConsole console = new GutteredLanguageConsole(project, language, gutterContentProvider, psiFileFactory); + GutteredLanguageConsole console = new GutteredLanguageConsole(project, language, gutterContentProvider, psiFileFactory, oneLineInput); LanguageConsoleViewImpl consoleView = new LanguageConsoleViewImpl(console, true); if (executeActionHandler != null) { assert historyType != null; @@ -157,15 +178,22 @@ public final class LanguageConsoleBuilder { private final static class GutteredLanguageConsole extends LanguageConsoleImpl { @Nullable private final GutterContentProvider gutterContentProvider; + @Nullable private final PairFunction psiFileFactory; public GutteredLanguageConsole(@NotNull Project project, @NotNull Language language, @Nullable GutterContentProvider gutterContentProvider, - @Nullable PairFunction psiFileFactory) { - super(project, language.getDisplayName() + " Console", language); + @Nullable PairFunction psiFileFactory, + boolean oneLineInput) { + super(project, language.getDisplayName() + " Console", language, false); setShowSeparatorLine(false); + + if (oneLineInput) { + getConsoleEditor().setOneLineMode(true); + } + this.gutterContentProvider = gutterContentProvider; this.psiFileFactory = psiFileFactory; } From 2f80e7d9c09697273e91223075d92836dda01063 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 21 Feb 2014 13:52:02 +0100 Subject: [PATCH 46/75] new inference: reject partial computation --- .../src/com/intellij/psi/LambdaUtil.java | 24 ---------- .../ExpressionCompatibilityConstraint.java | 31 ++++++------- .../highlighting/AmbiguitySpecificReturn.java | 4 +- .../highlighting/ReturnTypeCompatibility.java | 2 +- .../lambda/newLambda/IDEA119535.java | 44 +++++++++++++++++++ .../lambda/NewLambdaHighlightingTest.java | 4 ++ 6 files changed, 64 insertions(+), 45 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA119535.java 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 653b92fc494e..d4f91f9b1166 100644 --- a/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java @@ -376,14 +376,6 @@ public class LambdaUtil { final int lambdaIdx = getLambdaIdx(expressionList, expression); if (lambdaIdx > -1) { - PsiType cachedType = null; - final Pair method = MethodCandidateInfo.getCurrentMethod(parent); - if (method != null) { - final PsiParameter[] parameters = method.first.getParameterList().getParameters(); - cachedType = lambdaIdx < parameters.length ? method.second.substitute(getNormalizedType(parameters[adjustLambdaIdx(lambdaIdx, method.first, parameters)])) : null; - if (!tryToSubstitute) return cachedType; - } - PsiElement gParent = expressionList.getParent(); if (gParent instanceof PsiAnonymousClass) { @@ -399,22 +391,6 @@ public class LambdaUtil { final int finalLambdaIdx = adjustLambdaIdx(lambdaIdx, (PsiMethod)resolve, parameters); if (finalLambdaIdx < parameters.length) { if (!tryToSubstitute) return getNormalizedType(parameters[finalLambdaIdx]); - if (cachedType != null) { - final PsiMethod interfaceMethod = getFunctionalInterfaceMethod(cachedType); - if (interfaceMethod != null) { - final PsiClassType.ClassResolveResult cachedResult = PsiUtil.resolveGenericsClassInType(cachedType); - if (paramIdx == -1) { - if (!dependsOnTypeParams(cachedType, cachedType, expression) && !dependsOnTypeParams(getFunctionalInterfaceReturnType(cachedType), cachedType, expression)) { - return cachedType; - } - } - else { - if (!dependsOnTypeParams(cachedResult.getSubstitutor().substitute(interfaceMethod.getParameterList().getParameters()[paramIdx].getType()), cachedType, expression)) { - return cachedType; - } - } - } - } return PsiResolveHelper.ourGuard.doPreventingRecursion(expression, true, new Computable() { @Override public PsiType compute() { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java index d6a1d834c60f..30628e36beb6 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java @@ -15,7 +15,6 @@ */ package com.intellij.psi.impl.source.resolve.graphInference.constraints; -import com.intellij.openapi.util.Pair; import com.intellij.psi.*; import com.intellij.psi.impl.source.resolve.graphInference.InferenceSession; import com.intellij.psi.impl.source.resolve.graphInference.InferenceVariable; @@ -78,9 +77,8 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm if (myExpression instanceof PsiCallExpression) { final PsiExpressionList argumentList = ((PsiCallExpression)myExpression).getArgumentList(); if (argumentList != null) { - final Pair pair = MethodCandidateInfo.getCurrentMethod(argumentList); - final JavaResolveResult resolveResult = pair == null ? ((PsiCallExpression)myExpression).resolveMethodGenerics() : null; - final PsiMethod method = pair != null ? pair.first : (PsiMethod)resolveResult.getElement(); + final JavaResolveResult resolveResult = ((PsiCallExpression)myExpression).resolveMethodGenerics(); + final PsiMethod method = (PsiMethod)resolveResult.getElement(); PsiType returnType = null; PsiTypeParameter[] typeParams = null; if (method != null && !method.isConstructor()) { @@ -105,21 +103,18 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm session.addCapturedVariable(typeParam); } PsiSubstitutor substitutor = PsiSubstitutor.EMPTY; - if (pair == null) { - if (method != null) { - //typeParams are already included - final Collection params = session.getTypeParams(); - InferenceSession callSession = new InferenceSession(params.toArray(new PsiTypeParameter[params.size()]), ((MethodCandidateInfo)resolveResult).getSiteSubstitutor(), myExpression.getManager(), myExpression); - final PsiExpression[] args = argumentList.getExpressions(); - final PsiParameter[] parameters = method.getParameterList().getParameters(); - callSession.initExpressionConstraints(parameters, args, myExpression, method); - callSession.registerConstraints(returnType, myT); - if (callSession.repeatInferencePhases(true)) { - session.liftBounds(callSession.getInferenceVariables()); - } + if (method != null) { + //typeParams are already included + final Collection params = session.getTypeParams(); + InferenceSession callSession = new InferenceSession(params.toArray(new PsiTypeParameter[params.size()]), resolveResult instanceof MethodCandidateInfo ? ((MethodCandidateInfo)resolveResult).getSiteSubstitutor() + : PsiSubstitutor.EMPTY, myExpression.getManager(), myExpression); + final PsiExpression[] args = argumentList.getExpressions(); + final PsiParameter[] parameters = method.getParameterList().getParameters(); + callSession.initExpressionConstraints(parameters, args, myExpression, method); + callSession.registerConstraints(returnType, myT); + if (callSession.repeatInferencePhases(true)) { + session.liftBounds(callSession.getInferenceVariables()); } - } else { - substitutor = pair.second; } final PsiType capturedReturnType = myExpression instanceof PsiMethodCallExpression ? PsiMethodCallExpressionImpl.captureReturnType((PsiMethodCallExpression)myExpression, method, returnType, substitutor) diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguitySpecificReturn.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguitySpecificReturn.java index 5b9d5d74e31e..5ecd4f5f77ff 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguitySpecificReturn.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguitySpecificReturn.java @@ -1,8 +1,8 @@ class IntStream { private void foo(IntStream s) { - s.map(i -> 1 << i); + s.map(i -> 1 << i); s.map(i -> 1); - s.map(i -> i); + s.map(i -> i); } public static void main(String[] args) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility.java index 10cd3fffeb86..0f7aa7012061 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility.java @@ -25,7 +25,7 @@ class ReturnTypeIncompatibility { } public static void main(String[] args) { - call(i-> {return i;}); + call(i-> {return i;}); } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA119535.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA119535.java new file mode 100644 index 000000000000..9c883308ff1a --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newLambda/IDEA119535.java @@ -0,0 +1,44 @@ +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.BinaryOperator; +import java.util.function.Function; +import java.util.stream.Collector; + +class Stuff { + public enum Type { A } + private final int value; + private final Type type; + public Stuff(int value, Type type) { + this.value = value; + this.type = type; + } + public int getValue() { + return value; + } + public Type getType() { + return type; + } +} + +class FakeErrors { + { + + Collector>> collector = + groupingBy(Stuff::getType, + reducing((d1, d2) -> { + boolean b = d1.getValue() > d2.getValue(); + return d1; + })); + } + + public static Collector> reducing(BinaryOperator op) { + return null; + } + + public static + Collector> groupingBy(Function classifier, + Collector downstream) { + return null; + } +} \ 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 727972a00e5c..a57993717ef8 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 @@ -126,6 +126,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testIDEA119535() throws Exception { + doTest(); + } + private void doTest() { doTest(false); } From 96af56c57263e599f40bc8f5af9f27e447f2a9cf Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 21 Feb 2014 14:04:09 +0100 Subject: [PATCH 47/75] AIOOBE --- .../impl/source/resolve/graphInference/InferenceSession.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 425d20370e0c..cda150db7a15 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 @@ -259,7 +259,9 @@ public class InferenceSession { LOG.assertTrue(method != null); final PsiExpression[] newArgs = argumentList.getExpressions(); final PsiParameter[] newParams = method.getParameterList().getParameters(); - collectAdditionalConstraints(newParams, newArgs, method, ((MethodCandidateInfo)result).getSiteSubstitutor(), additionalConstraints); + if (newParams.length > 0) { + collectAdditionalConstraints(newParams, newArgs, method, ((MethodCandidateInfo)result).getSiteSubstitutor(), additionalConstraints); + } } } } From cf00d70317c32ab0d2aff9eadf80753660db8727 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 21 Feb 2014 18:02:27 +0100 Subject: [PATCH 48/75] delete old inference strategy for java 8 --- ...RedundantLambdaParameterTypeIntention.java | 15 +- .../src/com/intellij/psi/LambdaUtil.java | 145 +---- .../src/com/intellij/psi/util/PsiUtil.java | 4 +- .../psi/impl/source/PsiParameterImpl.java | 50 +- .../source/resolve/GraphInferencePolicy.java | 114 ---- .../source/resolve/PsiOldInferenceHelper.java | 510 ++---------------- .../source/resolve/PsiResolveHelperImpl.java | 10 +- .../CantCollapsedToDiamond.after.java | 2 +- .../LambdaExprNotAccepted.after.java | 2 +- .../daemon/AmbiguousMethodCallTest.java | 6 + .../quickFix/RemoveRedundantArgumentTest.java | 6 + .../Simplify2DiamondInspectionsTest.java | 5 + .../quickFix/VariableTypeFromCallTest.java | 6 + .../refactoring/IntroduceParameterTest.java | 5 + .../refactoring/IntroduceVariableTest.java | 3 +- .../src/misc/registry.properties | 2 - .../CyclicInference_after.java | 4 +- 17 files changed, 138 insertions(+), 751 deletions(-) delete mode 100644 java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/GraphInferencePolicy.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaParameterTypeIntention.java b/java/java-impl/src/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaParameterTypeIntention.java index 949ddceaeb29..4df26a06f4f7 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaParameterTypeIntention.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/quickFix/RedundantLambdaParameterTypeIntention.java @@ -23,6 +23,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.util.PsiUtil; import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; @@ -57,7 +58,7 @@ public class RedundantLambdaParameterTypeIntention extends PsiElementBaseIntenti if (parameter.getTypeElement() == null) return false; } if (parameters.length == 0) return false; - final PsiType functionalInterfaceType = LambdaUtil.getFunctionalInterfaceType(expression, false); + final PsiType functionalInterfaceType = LambdaUtil.getFunctionalInterfaceType(expression, true); if (functionalInterfaceType != null) { final PsiElement lambdaParent = expression.getParent(); if (lambdaParent instanceof PsiExpressionList) { @@ -84,11 +85,12 @@ public class RedundantLambdaParameterTypeIntention extends PsiElementBaseIntenti for (PsiTypeParameter parameter : typeParameters) { final PsiType psiType = substitutor.substitute(parameter); - if (psiType == null || LambdaUtil.dependsOnTypeParams(psiType, expression, parameter)) return false; + if (psiType == null || dependsOnTypeParams(psiType, expression, parameter)) return false; } + return functionalInterfaceType.isAssignableFrom(substitutor.substitute(method.getParameterList().getParameters()[idx].getType())); } } - else if (!LambdaUtil.isLambdaFullyInferred(expression, functionalInterfaceType)) { + if (!LambdaUtil.isLambdaFullyInferred(expression, functionalInterfaceType)) { return false; } return true; @@ -122,4 +124,11 @@ public class RedundantLambdaParameterTypeIntention extends PsiElementBaseIntenti lambdaExpression.getParameterList().replace(expression.getParameterList()); } } + + private static boolean dependsOnTypeParams(PsiType type, + PsiLambdaExpression expr, + PsiTypeParameter param2Check) { + return LambdaUtil.depends(type, new LambdaUtil.TypeParamsChecker(expr, PsiUtil + .resolveGenericsClassInType(LambdaUtil.getFunctionalInterfaceType(expr, false)).getElement()), param2Check); + } } 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 d4f91f9b1166..32a81a764127 100644 --- a/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java @@ -239,12 +239,6 @@ public class LambdaUtil { return -1; } - public static boolean dependsOnTypeParams(PsiType type, - PsiLambdaExpression expr, - PsiTypeParameter param2Check) { - return depends(type, new TypeParamsChecker(expr), param2Check); - } - public static boolean dependsOnTypeParams(PsiType type, PsiType functionalInterfaceType, PsiElement lambdaExpression, @@ -253,13 +247,7 @@ public class LambdaUtil { PsiUtil.resolveClassInType(functionalInterfaceType)), param2Check); } - public static boolean dependsOnTypeParams(PsiType type, - PsiClass aClass, - PsiMethod aMethod) { - return depends(type, new TypeParamsChecker(aMethod, aClass)); - } - - static boolean depends(PsiType type, TypeParamsChecker visitor, PsiTypeParameter... param2Check) { + public static boolean depends(PsiType type, TypeParamsChecker visitor, PsiTypeParameter... param2Check) { if (!visitor.startedInference()) return false; final Boolean accept = type.accept(visitor); if (param2Check.length > 0) { @@ -268,79 +256,8 @@ public class LambdaUtil { return accept != null && accept.booleanValue(); } - public static boolean isFreeFromTypeInferenceArgs(final PsiParameter[] methodParameters, - final PsiLambdaExpression lambdaExpression, - final PsiExpression expression, - final PsiSubstitutor subst, - final PsiType functionalInterfaceType, - final PsiTypeParameter typeParam) { - if (expression instanceof PsiCallExpression && ((PsiCallExpression)expression).getTypeArguments().length > 0) return true; - if (expression instanceof PsiNewExpression) { - final PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)expression).getClassOrAnonymousClassReference(); - if (classReference != null) { - final PsiReferenceParameterList parameterList = classReference.getParameterList(); - if (parameterList != null) { - final PsiTypeElement[] typeParameterElements = parameterList.getTypeParameterElements(); - if (typeParameterElements.length > 0) { - if (!(typeParameterElements[0].getType() instanceof PsiDiamondType)) { - return true; - } - } - } - } - } - final PsiParameter[] lambdaParams = lambdaExpression.getParameterList().getParameters(); - if (lambdaParams.length != methodParameters.length) return false; - final boolean[] independent = {true}; - final PsiMethod interfaceMethod = getFunctionalInterfaceMethod(functionalInterfaceType); - if (interfaceMethod == null) return false; - final TypeParamsChecker paramsChecker = new TypeParamsChecker(lambdaExpression); - for (PsiParameter parameter : interfaceMethod.getParameterList().getParameters()) { - subst.substitute(parameter.getType()).accept(paramsChecker); - } - paramsChecker.myUsedTypeParams.add(typeParam); - - expression.accept(new JavaRecursiveElementWalkingVisitor() { - @Override - public void visitConditionalExpression(PsiConditionalExpression expression) { - final PsiExpression thenExpression = expression.getThenExpression(); - if (thenExpression != null) { - thenExpression.accept(this); - } - final PsiExpression elseExpression = expression.getElseExpression(); - if (elseExpression != null) { - elseExpression.accept(this); - } - } - - @Override - public void visitReferenceExpression(PsiReferenceExpression expression) { - super.visitReferenceExpression(expression); - int usedParamIdx = -1; - for (int i = 0; i < lambdaParams.length; i++) { - PsiParameter param = lambdaParams[i]; - if (expression.isReferenceTo(param)) { - usedParamIdx = i; - break; - } - } - - if (usedParamIdx > -1 && dependsOnTypeParams(subst.substitute(methodParameters[usedParamIdx].getType()), functionalInterfaceType, - lambdaExpression, paramsChecker.myUsedTypeParams.toArray(new PsiTypeParameter[paramsChecker.myUsedTypeParams.size()]))) { - independent[0] = false; - } - } - }); - return independent[0]; - } - @Nullable public static PsiType getFunctionalInterfaceType(PsiElement expression, final boolean tryToSubstitute) { - return getFunctionalInterfaceType(expression, tryToSubstitute, -1); - } - - @Nullable - public static PsiType getFunctionalInterfaceType(PsiElement expression, final boolean tryToSubstitute, int paramIdx) { PsiElement parent = expression.getParent(); PsiElement element = expression; while (parent instanceof PsiParenthesizedExpression || parent instanceof PsiConditionalExpression) { @@ -443,53 +360,6 @@ public class LambdaUtil { return type; } - public static PsiType getLambdaParameterType(PsiParameter param) { - final PsiElement paramParent = param.getParent(); - if (paramParent instanceof PsiParameterList) { - final int parameterIndex = ((PsiParameterList)paramParent).getParameterIndex(param); - if (parameterIndex > -1) { - final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(param, PsiLambdaExpression.class); - if (lambdaExpression != null) { - - PsiType type = getFunctionalInterfaceType(lambdaExpression, true, parameterIndex); - if (type == null) { - type = getFunctionalInterfaceType(lambdaExpression, false); - } - if (type instanceof PsiIntersectionType) { - final PsiType[] conjuncts = ((PsiIntersectionType)type).getConjuncts(); - for (PsiType conjunct : conjuncts) { - final PsiType lambdaParameterFromType = getLambdaParameterFromType(parameterIndex, lambdaExpression, conjunct); - if (lambdaParameterFromType != null) return lambdaParameterFromType; - } - } else { - final PsiType lambdaParameterFromType = getLambdaParameterFromType(parameterIndex, lambdaExpression, type); - if (lambdaParameterFromType != null) { - return lambdaParameterFromType; - } - } - } - } - } - return new PsiLambdaParameterType(param); - } - - private static PsiType getLambdaParameterFromType(int parameterIndex, PsiLambdaExpression lambdaExpression, PsiType conjunct) { - final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(conjunct); - if (resolveResult != null) { - final PsiMethod method = getFunctionalInterfaceMethod(conjunct); - if (method != null) { - final PsiParameter[] parameters = method.getParameterList().getParameters(); - if (parameterIndex < parameters.length) { - final PsiType psiType = getSubstitutor(method, resolveResult).substitute(parameters[parameterIndex].getType()); - if (!dependsOnTypeParams(psiType, conjunct, lambdaExpression)) { - return GenericsUtil.eliminateWildcards(psiType); - } - } - } - } - return null; - } - public static boolean notInferredType(PsiType typeByExpression) { return typeByExpression instanceof PsiMethodReferenceType || typeByExpression instanceof PsiLambdaExpressionType || typeByExpression instanceof PsiLambdaParameterType; } @@ -560,19 +430,10 @@ public class LambdaUtil { return true; } - static class TypeParamsChecker extends PsiTypeVisitor { + public static class TypeParamsChecker extends PsiTypeVisitor { private PsiMethod myMethod; private final PsiClass myClass; - private final Set myUsedTypeParams = new HashSet(); - - private TypeParamsChecker(PsiMethod method, PsiClass aClass) { - myMethod = method; - myClass = aClass; - } - - public TypeParamsChecker(PsiElement expression) { - this(expression, PsiUtil.resolveGenericsClassInType(getFunctionalInterfaceType(expression, false)).getElement()); - } + public final Set myUsedTypeParams = new HashSet(); public TypeParamsChecker(PsiElement expression, PsiClass aClass) { myClass = aClass; diff --git a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java index 73c6b342c01a..32a987937974 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java @@ -1065,11 +1065,11 @@ public final class PsiUtil extends PsiUtilCore { return className + "." + member.getName(); } - static boolean checkSameExpression(PsiExpression templateExpr, final PsiExpression expression) { + static boolean checkSameExpression(PsiElement templateExpr, final PsiExpression expression) { return templateExpr.equals(skipParenthesizedExprDown(expression)); } - public static boolean isCondition(PsiExpression expr, PsiElement parent) { + public static boolean isCondition(PsiElement expr, PsiElement parent) { if (parent instanceof PsiIfStatement) { if (checkSameExpression(expr, ((PsiIfStatement)parent).getCondition())) { return true; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java index 287fba0238e4..ae08b6d342b8 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiParameterImpl.java @@ -32,6 +32,7 @@ import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.search.SearchScope; import com.intellij.psi.stubs.IStubElementType; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.util.PsiUtil; import com.intellij.reference.SoftReference; import com.intellij.ui.RowIcon; import com.intellij.util.IncorrectOperationException; @@ -59,6 +60,53 @@ public class PsiParameterImpl extends JavaStubPsiElement imple super(node); } + public static PsiType getLambdaParameterType(PsiParameter param) { + final PsiElement paramParent = param.getParent(); + if (paramParent instanceof PsiParameterList) { + final int parameterIndex = ((PsiParameterList)paramParent).getParameterIndex(param); + if (parameterIndex > -1) { + final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(param, PsiLambdaExpression.class); + if (lambdaExpression != null) { + + PsiType type = LambdaUtil.getFunctionalInterfaceType(lambdaExpression, true); + if (type == null) { + type = LambdaUtil.getFunctionalInterfaceType(lambdaExpression, false); + } + if (type instanceof PsiIntersectionType) { + final PsiType[] conjuncts = ((PsiIntersectionType)type).getConjuncts(); + for (PsiType conjunct : conjuncts) { + final PsiType lambdaParameterFromType = getLambdaParameterFromType(parameterIndex, lambdaExpression, conjunct); + if (lambdaParameterFromType != null) return lambdaParameterFromType; + } + } else { + final PsiType lambdaParameterFromType = getLambdaParameterFromType(parameterIndex, lambdaExpression, type); + if (lambdaParameterFromType != null) { + return lambdaParameterFromType; + } + } + } + } + } + return new PsiLambdaParameterType(param); + } + + private static PsiType getLambdaParameterFromType(int parameterIndex, PsiLambdaExpression lambdaExpression, PsiType conjunct) { + final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(conjunct); + if (resolveResult != null) { + final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(conjunct); + if (method != null) { + final PsiParameter[] parameters = method.getParameterList().getParameters(); + if (parameterIndex < parameters.length) { + final PsiType psiType = LambdaUtil.getSubstitutor(method, resolveResult).substitute(parameters[parameterIndex].getType()); + if (!LambdaUtil.dependsOnTypeParams(psiType, conjunct, lambdaExpression)) { + return GenericsUtil.eliminateWildcards(psiType); + } + } + } + } + return null; + } + @Override public void subtreeChanged() { super.subtreeChanged(); @@ -138,7 +186,7 @@ public class PsiParameterImpl extends JavaStubPsiElement imple PsiTypeElement typeElement = getTypeElement(); if (typeElement == null) { assert isLambdaParameter() : this; - return LambdaUtil.getLambdaParameterType(this); + return getLambdaParameterType(this); } else { return JavaSharedImplUtil.getType(typeElement, getParameterIdentifier()); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/GraphInferencePolicy.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/GraphInferencePolicy.java deleted file mode 100644 index b6a0baa40f85..000000000000 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/GraphInferencePolicy.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2000-2013 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.psi.impl.source.resolve; - -import com.intellij.psi.*; -import com.intellij.psi.scope.MethodProcessorSetupFailedException; -import com.intellij.psi.scope.processor.MethodCandidatesProcessor; -import com.intellij.psi.scope.util.PsiScopesUtil; -import com.intellij.psi.util.PsiUtil; -import org.jetbrains.annotations.NotNull; - -import java.util.*; - -/** -* User: anna -* Date: 2/14/13 -*/ -public class GraphInferencePolicy extends ProcessCandidateParameterTypeInferencePolicy { - private static final ThreadLocal>> ourResults = new ThreadLocal>>() { - @Override - protected Map> initialValue() { - return new WeakHashMap>(); - } - }; - - @Override - protected List getExpressions(PsiExpression[] expressions, int i) { - final List list = Arrays.asList(expressions); - list.set(i, null); - return list; - } - - @Override - protected PsiSubstitutor getSubstitutor(PsiCallExpression contextCall, PsiExpression[] expressions, int i, JavaResolveResult result) { - Map map = ourResults.get().get(contextCall); - if (map != null) { - final PsiSubstitutor substitutor = map.get(result); - if (substitutor != PsiSubstitutor.UNKNOWN && substitutor != null && substitutor.isValid()) return substitutor; - } - final PsiSubstitutor substitutor = super.getSubstitutor(contextCall, expressions, i, result); - if (map != null) { - map.put(result, substitutor); - } - return substitutor; - } - - @NotNull - @Override - protected JavaResolveResult[] getResults(@NotNull PsiCallExpression contextCall, final int exprIdx) - throws MethodProcessorSetupFailedException { - Map map = ourResults.get().get(contextCall); - if (map != null) { - final Set results = map.keySet(); - return results.toArray(new JavaResolveResult[results.size()]); - } - - PsiFile containingFile = contextCall.getContainingFile(); - final MethodCandidatesProcessor processor = new MethodCandidatesProcessor(contextCall, containingFile) { - @Override - protected PsiType[] getExpressionTypes(PsiExpressionList argumentList) { - if (argumentList != null) { - final PsiExpression[] expressions = argumentList.getExpressions(); - final PsiType[] types = PsiType.createArray(expressions.length); - for (int i = 0; i < expressions.length; i++) { - if (i != exprIdx) { - types[i] = expressions[i].getType(); - } - else { - types[i] = PsiType.NULL; - } - } - return types; - } - else { - return null; - } - } - }; - PsiScopesUtil.setupAndRunProcessor(processor, contextCall, false); - final JavaResolveResult[] results = processor.getResult(); - - map = new WeakHashMap(); - ourResults.get().put(contextCall, map); - for (JavaResolveResult result : results) { - map.put(result, PsiSubstitutor.UNKNOWN); - } - return results; - } - - public static void forget(PsiElement parent) { - if (parent instanceof PsiExpression) { - PsiElement gParent = PsiUtil.skipParenthesizedExprUp(parent.getParent()); - if (gParent instanceof PsiExpressionList) { - final PsiElement ggParent = gParent.getParent(); - if (ggParent instanceof PsiCallExpression) { - ourResults.get().remove(ggParent); - } - } - } - } -} diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java index bb75e07950c4..2fbfc6019309 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiOldInferenceHelper.java @@ -15,29 +15,22 @@ */ package com.intellij.psi.impl.source.resolve; -import com.intellij.codeInsight.ExceptionUtil; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JavaSdkVersion; import com.intellij.openapi.projectRoots.JavaVersionService; -import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.RecursionGuard; -import com.intellij.openapi.util.registry.Registry; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; -import com.intellij.psi.infos.MethodCandidateInfo; import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.util.*; +import com.intellij.psi.util.PsiTypesUtil; +import com.intellij.psi.util.PsiUtil; +import com.intellij.psi.util.TypeConversionUtil; import com.intellij.util.ArrayUtil; -import com.intellij.util.containers.HashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; -import java.util.Map; - /** * User: anna */ @@ -50,7 +43,7 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper { myManager = manager; } - private Pair inferTypeForMethodTypeParameterInner(@NotNull PsiTypeParameter typeParameter, + private Pair inferTypeForMethodTypeParameterInner(@NotNull PsiTypeParameter typeParameter, @NotNull PsiParameter[] parameters, @NotNull PsiExpression[] arguments, @NotNull PsiSubstitutor partialSubstitutor, @@ -98,10 +91,6 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper { PsiType lowerBound = PsiType.NULL; PsiType upperBound = PsiType.NULL; if (paramTypes.length > 0) { - sortLambdaExpressionsLast(paramTypes, argTypes); - boolean rawType = false; - boolean nullPassed = false; - boolean lambdaRaw = false; for (int j = 0; j < argTypes.length; j++) { PsiType argumentType = argTypes[j]; if (argumentType == null) continue; @@ -109,8 +98,6 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper { PsiType parameterType = paramTypes[j]; if (parameterType == null) break; - rawType |= parameterType instanceof PsiClassType && ((PsiClassType)parameterType).isRaw(); - nullPassed |= argumentType == PsiType.NULL; if (parameterType instanceof PsiEllipsisType) { parameterType = ((PsiEllipsisType)parameterType).getComponentType(); @@ -119,26 +106,8 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper { } } final Pair currentSubstitution; - if (argumentType instanceof PsiLambdaExpressionType) { - currentSubstitution = inferSubstitutionFromLambda(typeParameter, (PsiLambdaExpressionType)argumentType, lowerBound, partialSubstitutor); - if (rawType) { - if (currentSubstitution == FAILED_INFERENCE || currentSubstitution == null && lowerBound == PsiType.NULL) return RAW_INFERENCE; - } - if (nullPassed && currentSubstitution == null) return RAW_INFERENCE; - if (currentSubstitution != null && currentSubstitution.first == null) { - lambdaRaw = true; - } - if (currentSubstitution == null && lambdaRaw) { - return new Pair(PsiType.getJavaLangObject(myManager, typeParameter.getResolveScope()), ConstraintType.EQUALS); - } - } else if (argumentType instanceof PsiMethodReferenceType) { - final PsiMethodReferenceExpression referenceExpression = ((PsiMethodReferenceType)argumentType).getExpression(); - currentSubstitution = inferConstraintFromFunctionalInterfaceMethod(typeParameter, referenceExpression, partialSubstitutor.substitute(parameterType), partialSubstitutor, policy); - } - else { - currentSubstitution = getSubstitutionForTypeParameterConstraint(typeParameter, parameterType, - argumentType, true, PsiUtil.getLanguageLevel(typeParameter)); - } + currentSubstitution = getSubstitutionForTypeParameterConstraint(typeParameter, parameterType, + argumentType, true, PsiUtil.getLanguageLevel(typeParameter)); if (currentSubstitution == null) continue; if (currentSubstitution == FAILED_INFERENCE) { return getFailedInferenceConstraint(typeParameter); @@ -210,23 +179,6 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper { return null; } - private static void sortLambdaExpressionsLast(@NotNull PsiType[] paramTypes, @NotNull PsiType[] argTypes) { - for (int i = 0; i < argTypes.length; i++) { - PsiType argType = argTypes[i]; - if ((argType instanceof PsiLambdaExpressionType || argType instanceof PsiMethodReferenceType) && i < argTypes.length - 1) { - int k = i + 1; - while((argTypes[k] instanceof PsiLambdaExpressionType || argTypes[k] instanceof PsiMethodReferenceType) && k < argTypes.length - 1) { - k++; - } - if (!(argTypes[k] instanceof PsiLambdaExpressionType || argTypes[k] instanceof PsiMethodReferenceType)) { - ArrayUtil.swap(paramTypes, i, k); - ArrayUtil.swap(argTypes, i, k); - i = k; - } - } - } - } - private static Pair getFailedInferenceConstraint(@NotNull PsiTypeParameter typeParameter) { return new Pair(JavaPsiFacade.getInstance(typeParameter.getProject()).getElementFactory().createType(typeParameter), ConstraintType.EQUALS); } @@ -321,41 +273,36 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper { } } - try { - for (int i = 0; i < typeParameters.length; i++) { - PsiTypeParameter typeParameter = typeParameters[i]; - PsiType substitution = substitutions[i]; - if (substitution != null) continue; + for (int i = 0; i < typeParameters.length; i++) { + PsiTypeParameter typeParameter = typeParameters[i]; + PsiType substitution = substitutions[i]; + if (substitution != null) continue; - Pair constraint = constraints[i]; - if (constraint == null) { - constraint = inferMethodTypeParameterFromParent(typeParameter, partialSubstitutor, parent, policy); - } - else if (constraint.getSecond() == ConstraintType.SUBTYPE) { - Pair otherConstraint = - inferMethodTypeParameterFromParent(typeParameter, partialSubstitutor, parent, policy); - if (otherConstraint != null) { - if (otherConstraint.getSecond() == ConstraintType.EQUALS || otherConstraint.getSecond() == ConstraintType.SUPERTYPE) { - constraint = otherConstraint; - } + Pair constraint = constraints[i]; + if (constraint == null) { + constraint = inferMethodTypeParameterFromParent(typeParameter, partialSubstitutor, parent, policy); + } + else if (constraint.getSecond() == ConstraintType.SUBTYPE) { + Pair otherConstraint = + inferMethodTypeParameterFromParent(typeParameter, partialSubstitutor, parent, policy); + if (otherConstraint != null) { + if (otherConstraint.getSecond() == ConstraintType.EQUALS || otherConstraint.getSecond() == ConstraintType.SUPERTYPE) { + constraint = otherConstraint; } } - - if (constraint != null) { - substitution = constraint.getFirst(); - } - - if (substitution == null) { - PsiElementFactory factory = JavaPsiFacade.getInstance(myManager.getProject()).getElementFactory(); - return factory.createRawSubstitutor(partialSubstitutor, typeParameters); - } - if (substitution != PsiType.NULL) { - partialSubstitutor = partialSubstitutor.put(typeParameter, substitution); - } } - } - finally { - GraphInferencePolicy.forget(parent); + + if (constraint != null) { + substitution = constraint.getFirst(); + } + + if (substitution == null) { + PsiElementFactory factory = JavaPsiFacade.getInstance(myManager.getProject()).getElementFactory(); + return factory.createRawSubstitutor(partialSubstitutor, typeParameters); + } + if (substitution != PsiType.NULL) { + partialSubstitutor = partialSubstitutor.put(typeParameter, substitution); + } } return partialSubstitutor; } @@ -544,222 +491,6 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper { return getSubstitutionForTypeParameterInner(param, arg, patternType, ConstraintType.SUPERTYPE, 0); } - @Nullable - private Pair inferSubstitutionFromLambda(PsiTypeParameter typeParam, - PsiLambdaExpressionType arg, - PsiType lowerBound, - PsiSubstitutor partialSubstitutor) { - final PsiLambdaExpression lambdaExpression = arg.getExpression(); - if (PsiUtil.getLanguageLevel(lambdaExpression).isAtLeast(LanguageLevel.JDK_1_8)) { - final PsiElement parent = PsiUtil.skipParenthesizedExprUp(lambdaExpression.getParent()); - if (parent instanceof PsiExpressionList) { - final PsiExpressionList expressionList = (PsiExpressionList)parent; - final Map> methodMap = MethodCandidateInfo.CURRENT_CANDIDATE.get(); - final Pair pair = methodMap != null ? methodMap.get(expressionList) : null; - if (pair != null) { - final int i = LambdaUtil.getLambdaIdx(expressionList, lambdaExpression); - if (i < 0) return null; - final PsiParameter[] parameters = pair.first.getParameterList().getParameters(); - if (parameters.length <= i) return null; - final PsiSubstitutor combinedSubst = pair.second.putAll(partialSubstitutor); - methodMap.put(expressionList, Pair.create(pair.first, combinedSubst)); - return inferConstraintFromFunctionalInterfaceMethod(typeParam, lambdaExpression, combinedSubst.substitute(parameters[i].getType()), lowerBound); - } - } - else { - return inferConstraintFromFunctionalInterfaceMethod(typeParam, lambdaExpression, - partialSubstitutor.substitute(lambdaExpression.getFunctionalInterfaceType()), lowerBound); - } - } - return null; - } - - @Nullable - private Pair inferConstraintFromFunctionalInterfaceMethod(final PsiTypeParameter typeParam, - final PsiMethodReferenceExpression methodReferenceExpression, - final PsiType functionalInterfaceType, - final PsiSubstitutor partialSubstitutor, - final ParameterTypeInferencePolicy policy) { - final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType); - final PsiMethod functionalInterfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult); - if (functionalInterfaceMethod != null) { - final PsiSubstitutor subst = LambdaUtil.getSubstitutor(functionalInterfaceMethod, resolveResult); - final PsiParameter[] methodParameters = functionalInterfaceMethod.getParameterList().getParameters(); - PsiType[] methodParamTypes = PsiType.createArray(methodParameters.length); - for (int i = 0; i < methodParameters.length; i++) { - methodParamTypes[i] = GenericsUtil.eliminateWildcards(subst.substitute(methodParameters[i].getType())); - } - - if (methodParamsDependOn(typeParam, methodReferenceExpression, functionalInterfaceType, methodParameters, subst)) { - return null; - } - - final PsiType[] args = PsiType.createArray(methodParameters.length); - Map map = PsiMethodReferenceUtil.ourRefs.get(); - if (map == null) { - map = new HashMap(); - PsiMethodReferenceUtil.ourRefs.set(map); - } - final PsiType added = map.put(methodReferenceExpression, functionalInterfaceType); - final JavaResolveResult methReferenceResolveResult; - try { - methReferenceResolveResult = methodReferenceExpression.advancedResolve(false); - } - finally { - if (added == null) { - map.remove(methodReferenceExpression); - } - } - final PsiElement resolved = methReferenceResolveResult.getElement(); - if (resolved instanceof PsiMethod) { - final PsiMethod method = (PsiMethod)resolved; - final PsiParameter[] parameters = method.getParameterList().getParameters(); - boolean hasReceiver = false; - if (methodParamTypes.length == parameters.length + 1) { - if (!PsiMethodReferenceUtil - .isReceiverType(methodParamTypes[0], method.getContainingClass(), methReferenceResolveResult.getSubstitutor())) return null; - hasReceiver = true; - } else if (parameters.length != methodParameters.length) { - return null; - } - for (int i = 0; i < parameters.length; i++) { - args[i] = methReferenceResolveResult.getSubstitutor().substitute(subst.substitute(parameters[i].getType())); - } - - final PsiType[] typesToInfer = hasReceiver ? ArrayUtil.remove(methodParamTypes, 0) : methodParamTypes; - final Pair constraint = inferTypeForMethodTypeParameterInner(typeParam, typesToInfer, args, subst, null, DefaultParameterTypeInferencePolicy.INSTANCE); - if (constraint != null){ - return constraint; - } - PsiType functionalInterfaceReturnType = functionalInterfaceMethod.getReturnType(); - if (functionalInterfaceReturnType != null && functionalInterfaceReturnType != PsiType.VOID) { - functionalInterfaceReturnType = GenericsUtil.eliminateWildcards(subst.substitute(functionalInterfaceReturnType)); - final PsiType argType; - if (method.isConstructor()) { - argType = JavaPsiFacade.getElementFactory(functionalInterfaceMethod.getProject()).createType(method.getContainingClass(), methReferenceResolveResult.getSubstitutor()); - } else { - argType = methReferenceResolveResult.getSubstitutor().substitute(subst.substitute(method.getReturnType())); - } - final Pair typeParameterConstraint = - getSubstitutionForTypeParameterConstraint(typeParam, functionalInterfaceReturnType, argType, true, PsiUtil.getLanguageLevel(functionalInterfaceMethod)); - if (typeParameterConstraint != null && typeParameterConstraint.getSecond() != ConstraintType.EQUALS && method.isConstructor()) { - final Pair constraintFromParent = - inferMethodTypeParameterFromParent(typeParam, partialSubstitutor, methodReferenceExpression.getParent().getParent(), policy); - if (constraintFromParent != null && constraintFromParent.getSecond() == ConstraintType.EQUALS) return constraintFromParent; - } - return typeParameterConstraint; - } - } - } - return null; - } - - @Nullable - private Pair inferConstraintFromFunctionalInterfaceMethod(PsiTypeParameter typeParam, - final PsiLambdaExpression lambdaExpression, - final PsiType functionalInterfaceType, - PsiType lowerBound) { - final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType); - final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(resolveResult); - if (method != null) { - final PsiSubstitutor subst = LambdaUtil.getSubstitutor(method, resolveResult); - final Pair constraintFromFormalParams = inferConstraintFromLambdaFormalParams(typeParam, subst, method, lambdaExpression); - if (constraintFromFormalParams != null) return constraintFromFormalParams; - - final PsiParameter[] methodParameters = method.getParameterList().getParameters(); - if (methodParamsDependOn(typeParam, lambdaExpression, functionalInterfaceType, methodParameters, subst)) { - return null; - } - - final PsiType returnType = subst.substitute(method.getReturnType()); - if (returnType != null && returnType != PsiType.VOID) { - Pair constraint = null; - final List expressions = LambdaUtil.getReturnExpressions(lambdaExpression); - for (final PsiExpression expression : expressions) { - final boolean independent = lambdaExpression.hasFormalParameterTypes() || LambdaUtil.isFreeFromTypeInferenceArgs(methodParameters, lambdaExpression, expression, subst, functionalInterfaceType, typeParam); - if (!independent) { - if (lowerBound != PsiType.NULL) { - return null; - } - continue; - } - if (expression instanceof PsiReferenceExpression && ((PsiReferenceExpression)expression).resolve() == null) continue; - PsiType exprType = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, true, new Computable() { - @Override - public PsiType compute() { - return expression.getType(); - } - }); - if (exprType instanceof PsiLambdaParameterType) { - final PsiParameter parameter = ((PsiLambdaParameterType)exprType).getParameter(); - final int parameterIndex = lambdaExpression.getParameterList().getParameterIndex(parameter); - if (parameterIndex > -1) { - exprType = subst.substitute(methodParameters[parameterIndex].getType()); - } - } else if (exprType instanceof PsiLambdaExpressionType) { - return inferConstraintFromFunctionalInterfaceMethod(typeParam, ((PsiLambdaExpressionType)exprType).getExpression(), returnType, - lowerBound); - } else if (exprType == null && independent) { - return null; - } - - if (exprType == null){ - return FAILED_INFERENCE; - } - - final Pair returnExprConstraint = - getSubstitutionForTypeParameterConstraint(typeParam, GenericsUtil.eliminateWildcards(returnType), exprType, true, PsiUtil.getLanguageLevel(method)); - if (returnExprConstraint != null) { - if (returnExprConstraint == FAILED_INFERENCE) return returnExprConstraint; - if (constraint != null) { - final PsiType leastUpperBound = GenericsUtil.getLeastUpperBound(constraint.getFirst(), returnExprConstraint.getFirst(), myManager); - constraint = new Pair(leastUpperBound, ConstraintType.SUPERTYPE); - } else { - constraint = returnExprConstraint; - } - } - } - if (constraint != null) return constraint; - } - } - return null; - } - - private static boolean methodParamsDependOn(PsiTypeParameter typeParam, PsiElement psiElement, - PsiType functionalInterfaceType, - PsiParameter[] methodParameters, - PsiSubstitutor subst) { - for (PsiParameter parameter : methodParameters) { - if (LambdaUtil.dependsOnTypeParams(subst.substitute(parameter.getType()), functionalInterfaceType, psiElement, typeParam)) { - return true; - } - } - return false; - } - - @Nullable - private Pair inferConstraintFromLambdaFormalParams(PsiTypeParameter typeParam, - PsiSubstitutor subst, - PsiMethod method, PsiLambdaExpression lambdaExpression) { - final PsiParameter[] parameters = lambdaExpression.getParameterList().getParameters(); - if (parameters.length == 0) return null; - final PsiType[] lambdaArgs = PsiType.createArray(parameters.length); - for (int i = 0; i < parameters.length; i++) { - PsiParameter parameter = parameters[i]; - if (parameter.getTypeElement() == null) { - return null; - } - lambdaArgs[i] = parameter.getType(); - } - - final PsiParameter[] methodParameters = method.getParameterList().getParameters(); - PsiType[] methodParamTypes = PsiType.createArray(methodParameters.length); - for (int i = 0; i < methodParameters.length; i++) { - methodParamTypes[i] = GenericsUtil.eliminateWildcards(subst.substitute(methodParameters[i].getType())); - } - return inferTypeForMethodTypeParameterInner(typeParam, methodParamTypes, lambdaArgs, subst, null, DefaultParameterTypeInferencePolicy.INSTANCE); - } - private static PsiType intersectAllExtends(PsiTypeParameter typeParam, PsiType arg) { if (arg == null) return null; PsiClassType[] superTypes = typeParam.getSuperTypes(); @@ -979,48 +710,10 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper { PsiType expectedType = PsiTypesUtil.getExpectedTypeByParent(methodCall); if (expectedType == null) { - if (parent instanceof PsiReturnStatement) { - final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(parent, PsiLambdaExpression.class); - if (lambdaExpression != null) { - return getFailedInferenceConstraint(typeParameter); - } - } - else if (parent instanceof PsiExpressionList) { + if (parent instanceof PsiExpressionList) { final PsiElement pParent = parent.getParent(); if (pParent instanceof PsiCallExpression && parent.equals(((PsiCallExpression)pParent).getArgumentList())) { constraint = policy.inferTypeConstraintFromCallContext(methodCall, (PsiExpressionList)parent, (PsiCallExpression)pParent, typeParameter); - if (constraint == null && PsiUtil.isLanguageLevel8OrHigher(methodCall)) { - constraint = graphInferenceFromCallContext(methodCall, typeParameter, (PsiCallExpression)pParent); - if (constraint != null) { - final PsiType constraintFirst = constraint.getFirst(); - if (constraintFirst == null || constraintFirst.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) { - constraint = null; - } - } - } - } - } else if (parent instanceof PsiLambdaExpression) { - expectedType = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(methodCall, true, new Computable() { - @Override - public PsiType compute() { - return LambdaUtil.getFunctionalInterfaceReturnType(((PsiLambdaExpression)parent).getFunctionalInterfaceType()); - } - }); - if (expectedType == null) { - return null; - } - expectedType = GenericsUtil.eliminateWildcards(expectedType); - } else if (parent instanceof PsiConditionalExpression) { - if (PsiUtil.isLanguageLevel8OrHigher(parent)) { - try { - final Pair pair = inferFromConditionalExpression(parent, methodCall, typeParameter, substitutor, policy); - if (pair != null) { - return pair; - } - } - finally { - GraphInferencePolicy.forget(parent); - } } } } @@ -1054,33 +747,6 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper { if (constraint == null) { if (methodCall instanceof PsiCallExpression) { - final PsiExpressionList argumentList = ((PsiCallExpression)methodCall).getArgumentList(); - if (argumentList != null && PsiUtil.getLanguageLevel(argumentList).isAtLeast(LanguageLevel.JDK_1_8)) { - for (PsiExpression expression : argumentList.getExpressions()) { - if (expression instanceof PsiLambdaExpression || expression instanceof PsiMethodReferenceExpression) { - final PsiType functionalInterfaceType = LambdaUtil.getFunctionalInterfaceType(expression, false); - if (functionalInterfaceType == null || PsiUtil.resolveClassInType(functionalInterfaceType) == typeParameter){ - return getFailedInferenceConstraint(typeParameter); - } - final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType); - - final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType); - if (method == null || methodParamsDependOn(typeParameter, expression, - functionalInterfaceType, method.getParameterList().getParameters(), - LambdaUtil.getSubstitutor(method, resolveResult))) { - if (expression instanceof PsiMethodReferenceExpression) { - return getFailedInferenceConstraint(typeParameter); - } - return null; - } - final Pair inferredExceptionTypeConstraint = inferExceptionConstrains(typeParameter, expression, method, resolveResult.getSubstitutor()); - if (inferredExceptionTypeConstraint != null) { - return inferredExceptionTypeConstraint; - } - } - } - } - PsiType[] superTypes = typeParameter.getSuperTypes(); if (superTypes.length == 0) return null; final PsiType[] types = PsiType.createArray(superTypes.length); @@ -1090,7 +756,6 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper { superType = TypeConversionUtil.erasure(superType); } if (superType == null) superType = PsiType.getJavaLangObject(myManager, scope); - if (superType == null) return null; types[i] = superType; } return policy.getInferredTypeWithNoConstraint(myManager, PsiIntersectionType.createIntersection(types)); @@ -1120,113 +785,4 @@ public class PsiOldInferenceHelper implements PsiInferenceHelper { return new Pair(guess, constraint.getSecond()); } - - private static boolean checkSameExpression(PsiExpression templateExpr, final PsiExpression expression) { - return templateExpr.equals(PsiUtil.skipParenthesizedExprDown(expression)); - } - - private static Pair inferExceptionConstrains(PsiTypeParameter typeParameter, - PsiExpression expression, - PsiMethod method, - PsiSubstitutor substitutor) { - final PsiClassType[] declaredExceptions = method.getThrowsList().getReferencedTypes(); - for (PsiClassType exception : declaredExceptions) { - final PsiType substitute = substitutor.substitute(exception); - if (PsiUtil.resolveClassInType(substitute) == typeParameter) { - if (expression instanceof PsiLambdaExpression) { - final PsiElement body = ((PsiLambdaExpression)expression).getBody(); - if (body != null) { - final List unhandledExceptions = ExceptionUtil.getUnhandledExceptions(body); - if (unhandledExceptions.isEmpty()) { - return inferUncheckedException(typeParameter, exception, method); - } - } - } - else if (expression instanceof PsiMethodReferenceExpression) { - final PsiElement resolve = ((PsiMethodReferenceExpression)expression).resolve(); - if (resolve instanceof PsiMethod) { - final PsiClassType[] declaredThrowsList = ((PsiMethod)resolve).getThrowsList().getReferencedTypes(); - for (PsiClassType psiClassType : declaredThrowsList) { - if (!ExceptionUtil.isUncheckedException(psiClassType)) return null; - } - return inferUncheckedException(typeParameter, exception, method); - } - } - break; - } - } - return null; - } - - private static Pair inferUncheckedException(PsiTypeParameter typeParameter, - PsiClassType exception, - PsiMethod method) { - final Project project = typeParameter.getProject(); - final PsiClass runtimeException = JavaPsiFacade.getInstance(project).findClass(CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION, method.getResolveScope()); - if (runtimeException != null) { - for (PsiType superType : exception.getSuperTypes()) { - if (!InheritanceUtil.isInheritorOrSelf(runtimeException, PsiUtil.resolveClassInType(superType), true)) { - return getFailedInferenceConstraint(typeParameter); - } - } - return Pair.create(JavaPsiFacade.getElementFactory(project).createType(runtimeException, PsiSubstitutor.EMPTY), ConstraintType.EQUALS); - } - return null; - } - - private Pair inferFromConditionalExpression(@NotNull PsiElement parent, - @NotNull PsiExpression methodCall, - @NotNull PsiTypeParameter typeParameter, - @NotNull PsiSubstitutor substitutor, - @NotNull ParameterTypeInferencePolicy policy) { - Pair pair = - inferMethodTypeParameterFromParent(PsiUtil.skipParenthesizedExprUp(parent.getParent()), (PsiExpression)parent, typeParameter, substitutor, policy); - if (pair == null) { - final PsiExpression thenExpression = ((PsiConditionalExpression)parent).getThenExpression(); - final PsiExpression elseExpression = ((PsiConditionalExpression)parent).getElseExpression(); - final PsiType[] paramTypes = {((PsiMethod)typeParameter.getOwner()).getReturnType()}; - if (methodCall.equals(PsiUtil.skipParenthesizedExprDown(elseExpression)) && thenExpression != null) { - final PsiType thenType = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(parent, true, new Computable() { - @Override - public PsiType compute() { - return thenExpression.getType(); - } - }); - if (thenType != null) { - pair = inferTypeForMethodTypeParameterInner(typeParameter, paramTypes, new PsiType[] {thenType}, substitutor, null, policy); - } - } else if (methodCall.equals(PsiUtil.skipParenthesizedExprDown(thenExpression)) && elseExpression != null) { - final PsiType elseType = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(parent, true, new Computable() { - @Override - public PsiType compute() { - return elseExpression.getType(); - } - }); - if (elseType != null) { - pair = inferTypeForMethodTypeParameterInner(typeParameter, paramTypes, new PsiType[] {elseType}, substitutor, null, policy); - } - } - } - return pair; - } - - private static final ProcessCandidateParameterTypeInferencePolicy GRAPH_INFERENCE_POLICY = new GraphInferencePolicy(); - - private static Pair graphInferenceFromCallContext(@NotNull final PsiExpression methodCall, - @NotNull final PsiTypeParameter typeParameter, - @NotNull final PsiCallExpression parentCall) { - if (Registry.is("disable.graph.inference", false)) return null; - final PsiExpressionList argumentList = parentCall.getArgumentList(); - if (PsiDiamondType.ourDiamondGuard.currentStack().contains(parentCall)) { - PsiDiamondType.ourDiamondGuard.prohibitResultCaching(parentCall); - return FAILED_INFERENCE; - } - return PsiResolveHelper.ourGraphGuard.doPreventingRecursion(methodCall, true, new Computable>() { - @Override - public Pair compute() { - return GRAPH_INFERENCE_POLICY.inferTypeConstraintFromCallContext(methodCall, argumentList, parentCall, typeParameter); - } - }); - } - } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java index dcaf548a2fbe..840d1b43b991 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java @@ -17,7 +17,6 @@ package com.intellij.psi.impl.source.resolve; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.registry.Registry; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper; @@ -26,7 +25,8 @@ import com.intellij.psi.scope.MethodProcessorSetupFailedException; import com.intellij.psi.scope.processor.MethodCandidatesProcessor; import com.intellij.psi.scope.processor.MethodResolverProcessor; import com.intellij.psi.scope.util.PsiScopesUtil; -import com.intellij.psi.util.*; +import com.intellij.psi.util.PsiUtil; +import com.intellij.psi.util.TypeConversionUtil; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -204,10 +204,10 @@ public class PsiResolveHelperImpl implements PsiResolveHelper { } public PsiInferenceHelper getInferenceHelper(LanguageLevel languageLevel) { - if (ApplicationManager.getApplication().isUnitTestMode()) { - return myTestHelper != null ? myTestHelper : new PsiOldInferenceHelper(myManager); + if (ApplicationManager.getApplication().isUnitTestMode() && myTestHelper != null) { + return myTestHelper; } - if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && Registry.is("enable.graph.inference", true)) { + if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) { return new PsiGraphInferenceHelper(myManager); } return new PsiOldInferenceHelper(myManager); diff --git a/java/java-tests/testData/refactoring/introduceVariable/CantCollapsedToDiamond.after.java b/java/java-tests/testData/refactoring/introduceVariable/CantCollapsedToDiamond.after.java index 8598dc443740..d350d8c09391 100644 --- a/java/java-tests/testData/refactoring/introduceVariable/CantCollapsedToDiamond.after.java +++ b/java/java-tests/testData/refactoring/introduceVariable/CantCollapsedToDiamond.after.java @@ -1,6 +1,6 @@ class Test { void foo() { - final Foo a = new Foo(1); + final Foo a = new Foo<>(1); } } diff --git a/java/java-tests/testData/refactoring/introduceVariable/LambdaExprNotAccepted.after.java b/java/java-tests/testData/refactoring/introduceVariable/LambdaExprNotAccepted.after.java index e8d77020330b..a4b5330a289f 100644 --- a/java/java-tests/testData/refactoring/introduceVariable/LambdaExprNotAccepted.after.java +++ b/java/java-tests/testData/refactoring/introduceVariable/LambdaExprNotAccepted.after.java @@ -4,7 +4,7 @@ interface SAM { class Foo { void test() { - SAM c = (i, j) -> "" + i + j; + SAM c = (i, j) -> "" + i + j; SAM s3 = m(c); } SAM m(SAM s) { return null; } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java index 2042e298849e..f528f8fd8bc6 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/AmbiguousMethodCallTest.java @@ -20,6 +20,7 @@ import com.intellij.codeInspection.compiler.JavacQuirksInspection; import com.intellij.codeInspection.redundantCast.RedundantCastInspection; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import com.intellij.pom.java.LanguageLevel; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -52,4 +53,9 @@ public class AmbiguousMethodCallTest extends LightDaemonAnalyzerTestCase { public void testMultipleInheritance() throws Exception { doTest(false, false); } + + @Override + protected LanguageLevel getLanguageLevel() { + return LanguageLevel.JDK_1_7; + } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantArgumentTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantArgumentTest.java index e9b75eaa7c76..064267074868 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantArgumentTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/RemoveRedundantArgumentTest.java @@ -1,5 +1,7 @@ package com.intellij.codeInsight.daemon.quickFix; +import com.intellij.pom.java.LanguageLevel; + public class RemoveRedundantArgumentTest extends LightQuickFixParameterizedTestCase { public void test() throws Exception { doAllTests(); } @@ -9,4 +11,8 @@ public class RemoveRedundantArgumentTest extends LightQuickFixParameterizedTestC return "/codeInsight/daemonCodeAnalyzer/quickFix/removeRedundantArgument"; } + @Override + protected LanguageLevel getLanguageLevel() { + return LanguageLevel.JDK_1_7; + } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java index eb3b79544963..44dcc2e1780b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Simplify2DiamondInspectionsTest.java @@ -17,6 +17,7 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.codeInspection.ExplicitTypeCanBeDiamondInspection; import com.intellij.codeInspection.LocalInspectionTool; +import com.intellij.pom.java.LanguageLevel; import org.jetbrains.annotations.NotNull; @@ -37,4 +38,8 @@ public class Simplify2DiamondInspectionsTest extends LightQuickFixParameterizedT return "/codeInsight/daemonCodeAnalyzer/quickFix/explicit2diamond"; } + @Override + protected LanguageLevel getLanguageLevel() { + return LanguageLevel.JDK_1_7; + } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java index d4f87067355a..ace3cdfdbfb4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/VariableTypeFromCallTest.java @@ -16,6 +16,8 @@ package com.intellij.codeInsight.daemon.quickFix; +import com.intellij.pom.java.LanguageLevel; + public class VariableTypeFromCallTest extends LightQuickFixParameterizedTestCase { public void test() throws Exception { doAllTests(); } @@ -25,5 +27,9 @@ public class VariableTypeFromCallTest extends LightQuickFixParameterizedTestCase return "/codeInsight/daemonCodeAnalyzer/quickFix/varTypeFromCall"; } + @Override + protected LanguageLevel getLanguageLevel() { + return LanguageLevel.JDK_1_7; + } } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java index 618381a194b6..8444c2b547c6 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java @@ -463,4 +463,9 @@ public class IntroduceParameterTest extends LightRefactoringTestCase { IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, declareFinal, false, null, parametersToRemove).run(); } + + @Override + protected LanguageLevel getLanguageLevel() { + return LanguageLevel.JDK_1_7; + } } diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java index 16c7d3398065..09714d4b153e 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java @@ -428,6 +428,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase { } public void testLambdaExpr() throws Exception { + doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM")); } @@ -436,7 +437,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase { } public void testLambdaExprNotAccepted() throws Exception { - doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM")); + doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM")); } public void testOneLineLambdaVoidCompatible() throws Exception { diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index 3518b23a6cca..191555d68323 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -318,8 +318,6 @@ diagrams.rendering.no.cache=true wolf.the.problem.solver=true ui.no.bangs.and.whistles=false -disable.graph.inference=false -enable.graph.inference=true comment.by.line.bulk.lines.trigger=100 diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/lambda2anonymous/CyclicInference_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/lambda2anonymous/CyclicInference_after.java index dfa25f3d143b..f99f071cb472 100644 --- a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/lambda2anonymous/CyclicInference_after.java +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/lambda2anonymous/CyclicInference_after.java @@ -8,9 +8,9 @@ class Test2 { static I bar(I i){return i;} { - bar(new I() { + bar(new I() { @Override - public Object foo(Y x) { + public Object foo(Y x) { return x; } }); From 6cc57f84849f73e337b50943bef4c0390b248a44 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Fri, 21 Feb 2014 20:13:56 +0100 Subject: [PATCH 49/75] EA-54183 (CCE: BooleanConstructorInspection$BooleanConstructorFix.doFix) --- .../BooleanConstructorInspection.java | 9 ++-- .../com/siyeh/ig/IGQuickFixesTestCase.java | 43 ++++++++++++++++++- .../BooleanConstructorFixTest.java | 43 +++++++++++++++++++ 3 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/performance/BooleanConstructorFixTest.java diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/BooleanConstructorInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/BooleanConstructorInspection.java index 1a560a01b1db..882496df4484 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/BooleanConstructorInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/BooleanConstructorInspection.java @@ -20,7 +20,6 @@ import com.intellij.openapi.project.Project; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.util.PsiUtil; -import com.intellij.util.IncorrectOperationException; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; @@ -84,8 +83,12 @@ public class BooleanConstructorInspection extends BaseInspection { } @Override - public void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException { - final PsiNewExpression expression = (PsiNewExpression)descriptor.getPsiElement(); + public void doFix(Project project, ProblemDescriptor descriptor) { + final PsiElement element = descriptor.getPsiElement().getParent(); + if (!(element instanceof PsiNewExpression)) { + return; + } + final PsiNewExpression expression = (PsiNewExpression)element; final PsiExpressionList argumentList = expression.getArgumentList(); if (argumentList == null) { return; diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/IGQuickFixesTestCase.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/IGQuickFixesTestCase.java index f8013fd5acfa..b56c340f5400 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/IGQuickFixesTestCase.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/IGQuickFixesTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,14 @@ package com.siyeh.ig; import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.ide.highlighter.JavaFileType; import com.intellij.openapi.application.PluginPathManager; import com.intellij.pom.java.LanguageLevel; import com.intellij.testFramework.builders.JavaModuleFixtureBuilder; import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase; +import org.intellij.lang.annotations.Language; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; /** * @author anna @@ -30,6 +34,20 @@ public abstract class IGQuickFixesTestCase extends JavaCodeInsightFixtureTestCas protected String myDefaultHint = null; protected String myRelativePath = null; + @Override + protected void setUp() throws Exception { + super.setUp(); + + final BaseInspection inspection = getInspection(); + if (inspection != null) { + myFixture.enableInspections(inspection); + } + } + + protected BaseInspection getInspection() { + return null; + } + @Override protected void tuneFixture(final JavaModuleFixtureBuilder builder) throws Exception { builder.setLanguageLevel(LanguageLevel.JDK_1_7); @@ -59,6 +77,29 @@ public abstract class IGQuickFixesTestCase extends JavaCodeInsightFixtureTestCas myFixture.checkResultByFile(getRelativePath() + "/" + testName + ".after.java"); } + protected void doExpressionTest( + String hint, + @Language(value = "JAVA", prefix = "class X {{System.out.print(", suffix = ");}}") @NotNull @NonNls String before, + @Language(value = "JAVA", prefix = "class X {{System.out.print(", suffix = ");}}") @NotNull @NonNls String after) { + doTest(hint, "class X {{System.out.print(" + before + ");}}", "class X {{System.out.print(" + after + ");}}"); + } + + protected void doMemberTest( + String hint, + @Language(value = "JAVA", prefix = "class X {", suffix = "}") @NotNull @NonNls String before, + @Language(value = "JAVA", prefix = "class X {", suffix = "}") @NotNull @NonNls String after) { + doTest(hint, "class X {" + before + "}", "class X {" + after + "}"); + } + + protected void doTest(String hint, @Language("JAVA") @NotNull @NonNls String before, @Language("JAVA") @NotNull @NonNls String after) { + before = before.replace("/**/", ""); + myFixture.configureByText(JavaFileType.INSTANCE, before); + final IntentionAction intention = myFixture.findSingleIntention(hint); + assertNotNull(intention); + myFixture.launchAction(intention); + myFixture.checkResult(after); + } + protected String getRelativePath() { assertNotNull(myRelativePath); return myRelativePath; diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/performance/BooleanConstructorFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/performance/BooleanConstructorFixTest.java new file mode 100644 index 000000000000..feb1ad046183 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/performance/BooleanConstructorFixTest.java @@ -0,0 +1,43 @@ +/* + * 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.siyeh.ig.fixes.performance; + +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.BaseInspection; +import com.siyeh.ig.IGQuickFixesTestCase; +import com.siyeh.ig.performance.BooleanConstructorInspection; + +/** + * @author Bas Leijdekkers + */ +public class BooleanConstructorFixTest extends IGQuickFixesTestCase { + + @Override + protected BaseInspection getInspection() { + return new BooleanConstructorInspection(); + } + + public void testSimple() { + doExpressionTest(InspectionGadgetsBundle.message("boolean.constructor.simplify.quickfix"), + "new Boolean/**/(true)", "Boolean.TRUE"); + } + + public void testSimple2() { + doMemberTest(InspectionGadgetsBundle.message("boolean.constructor.simplify.quickfix"), + "void m(boolean b) { Boolean c = new /**/Boolean(b); }", + "void m(boolean b) { Boolean c = Boolean.valueOf(b); }"); + } +} From d9dcac5802269b6aa2873f2d2555c1e04d26c4d2 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 21 Feb 2014 12:32:58 +0100 Subject: [PATCH 50/75] Cleanup (typos) --- .../com/intellij/openapi/actionSystem/DataConstants.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/DataConstants.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/DataConstants.java index 6aade96ca923..2c81a6603c0c 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/DataConstants.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/DataConstants.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. @@ -35,7 +35,7 @@ public interface DataConstants { /** * Returns {@link com.intellij.openapi.module.Module} * - * @depreacated use {@link com.intellij.openapi.actionSystem.LangDataKeys#MODULE} instead + * @deprecated use {@link com.intellij.openapi.actionSystem.LangDataKeys#MODULE} instead */ @NonNls String MODULE = "module"; @@ -166,7 +166,7 @@ public interface DataConstants { @NonNls String LANGUAGE = "Language"; /** - * Returns java.awt.Component currently in focus, DataContext should be retreived for + * Returns java.awt.Component currently in focus, DataContext should be retrieved for * * @deprecated use {@link com.intellij.openapi.actionSystem.PlatformDataKeys#CONTEXT_COMPONENT} instead */ @@ -232,7 +232,7 @@ public interface DataConstants { String DELETE_ELEMENT_PROVIDER = PlatformDataKeys.DELETE_ELEMENT_PROVIDER.getName(); /** - * Returns com.intellij.openapi.editor.Editor even if foces currently is in find bar + * Returns com.intellij.openapi.editor.Editor even if focuses currently is in find bar * * @deprecated use {@link com.intellij.openapi.actionSystem.PlatformDataKeys#EDITOR} instead */ From d128928c92afb90d211dd40773ced3d449b6e2e3 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 21 Feb 2014 12:34:15 +0100 Subject: [PATCH 51/75] Cleanup (configuration tests correctly generified and annotated) --- .../execution/BaseConfigurationTestCase.java | 50 +++++++++---- .../ConfigurationRefactoringsTest.java | 73 ++++++++++++++----- 2 files changed, 88 insertions(+), 35 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/execution/BaseConfigurationTestCase.java b/java/java-tests/testSrc/com/intellij/execution/BaseConfigurationTestCase.java index 2ddd8d11aa40..9092e2551a8d 100644 --- a/java/java-tests/testSrc/com/intellij/execution/BaseConfigurationTestCase.java +++ b/java/java-tests/testSrc/com/intellij/execution/BaseConfigurationTestCase.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.execution; import com.intellij.execution.actions.ConfigurationContext; @@ -5,7 +20,9 @@ import com.intellij.execution.actions.ConfigurationFromContext; import com.intellij.execution.actions.RunConfigurationProducer; import com.intellij.execution.configurations.RunConfiguration; import com.intellij.execution.junit.JUnitConfiguration; -import com.intellij.openapi.actionSystem.DataConstants; +import com.intellij.execution.junit.JUnitConfigurationProducer; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ex.PathManagerEx; import com.intellij.openapi.module.Module; @@ -25,6 +42,7 @@ import com.intellij.testFramework.IdeaTestCase; import com.intellij.testFramework.MapDataContext; import com.intellij.testFramework.PsiTestUtil; import com.intellij.testFramework.TempFiles; +import org.jetbrains.annotations.NotNull; import java.io.File; import java.io.IOException; @@ -64,7 +82,7 @@ public abstract class BaseConfigurationTestCase extends IdeaTestCase { ModuleRootModificationUtil.addModuleLibrary(module, mockJUnit.getUrl()); ModuleRootModificationUtil.setModuleSdk(module, ModuleRootManager.getInstance(myModule).getSdk()); GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module); - VirtualFile testCase = mockJUnit.findChild("junit").findChild("framework").findChild("TestCase.java"); + VirtualFile testCase = mockJUnit.findFileByRelativePath("junit/framework/TestCase.java"); assertNotNull(testCase); assertTrue(scope.contains(testCase)); Module missingModule = createTempModule(); @@ -139,37 +157,39 @@ public abstract class BaseConfigurationTestCase extends IdeaTestCase { return JavaPsiFacade.getInstance(myProject).findClass(qualifiedName, scope); } - protected JUnitConfiguration createJUnitConfiguration(final PsiElement psiElement, - final Class producerClass, - final MapDataContext dataContext) { + protected JUnitConfiguration createJUnitConfiguration(@NotNull PsiElement psiElement, + @NotNull Class producerClass, + @NotNull MapDataContext dataContext) { ConfigurationContext context = createContext(psiElement, dataContext); RunConfigurationProducer producer = RunConfigurationProducer.getInstance(producerClass); assert producer != null; ConfigurationFromContext fromContext = producer.createConfigurationFromContext(context); + assertNotNull(fromContext); return (JUnitConfiguration)fromContext.getConfiguration(); } - protected final T createConfiguration(PsiElement psiElement) { - return (T)createConfiguration(psiElement, new MapDataContext()); + protected final T createConfiguration(@NotNull PsiElement psiElement) { + return createConfiguration(psiElement, new MapDataContext()); } - protected T createConfiguration(PsiElement psiElement, MapDataContext dataContext) { + protected T createConfiguration(@NotNull PsiElement psiElement, @NotNull MapDataContext dataContext) { ConfigurationContext context = createContext(psiElement, dataContext); RunnerAndConfigurationSettings settings = context.getConfiguration(); - return settings == null ? null : (T)settings.getConfiguration(); + @SuppressWarnings("unchecked") T configuration = settings == null ? null : (T)settings.getConfiguration(); + return configuration; } - public ConfigurationContext createContext(PsiElement psiClass) { + public ConfigurationContext createContext(@NotNull PsiElement psiClass) { MapDataContext dataContext = new MapDataContext(); return createContext(psiClass, dataContext); } - public ConfigurationContext createContext(PsiElement psiClass, MapDataContext dataContext) { - dataContext.put(DataConstants.PROJECT, myProject); - if (dataContext.getData(DataConstants.MODULE) == null) { - dataContext.put(DataConstants.MODULE, ModuleUtilCore.findModuleForPsiElement(psiClass)); + public ConfigurationContext createContext(@NotNull PsiElement psiClass, @NotNull MapDataContext dataContext) { + dataContext.put(CommonDataKeys.PROJECT, myProject); + if (LangDataKeys.MODULE.getData(dataContext) == null) { + dataContext.put(LangDataKeys.MODULE, ModuleUtilCore.findModuleForPsiElement(psiClass)); } - dataContext.put(Location.LOCATION, PsiLocation.fromPsiElement(psiClass)); + dataContext.put(Location.DATA_KEY, PsiLocation.fromPsiElement(psiClass)); return ConfigurationContext.getFromContext(dataContext); } diff --git a/java/java-tests/testSrc/com/intellij/execution/ConfigurationRefactoringsTest.java b/java/java-tests/testSrc/com/intellij/execution/ConfigurationRefactoringsTest.java index a5d882c89026..174b9af3507a 100644 --- a/java/java-tests/testSrc/com/intellij/execution/ConfigurationRefactoringsTest.java +++ b/java/java-tests/testSrc/com/intellij/execution/ConfigurationRefactoringsTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.execution; import com.intellij.execution.application.ApplicationConfiguration; @@ -6,6 +21,7 @@ import com.intellij.execution.configurations.RuntimeConfigurationException; import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl; import com.intellij.execution.junit.AllInPackageConfigurationProducer; import com.intellij.execution.junit.JUnitConfiguration; +import com.intellij.execution.junit.JUnitConfigurationProducer; import com.intellij.execution.junit.JUnitConfigurationType; import com.intellij.openapi.application.Result; import com.intellij.openapi.command.WriteCommandAction; @@ -19,6 +35,7 @@ import com.intellij.refactoring.move.moveMembers.MoveMembersProcessor; import com.intellij.refactoring.rename.RenameProcessor; import com.intellij.testFramework.MapDataContext; import com.intellij.util.containers.HashSet; +import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -38,6 +55,7 @@ public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase { "}"; public void testRenameApplication() throws IOException { PsiClass psiClass = mySource.createClass("Application", APPLICATION_CODE); + assertNotNull(psiClass); ApplicationConfiguration configuration = createConfiguration(psiClass); assertNotNull(configuration); rename(psiClass, "NewName"); @@ -52,6 +70,7 @@ public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase { public void testMoveApplication() throws IOException { PsiClass psiClass = mySource.createClass("Application", APPLICATION_CODE); + assertNotNull(psiClass); ApplicationConfiguration configuration = createConfiguration(psiClass); move(psiClass, "pkg"); try { @@ -71,15 +90,16 @@ public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase { JUnitConfiguration configuration = createJUnitConfiguration(psiPackage, AllInPackageConfigurationProducer.class, new MapDataContext()); rename(psiPackage, "pkg2"); checkPackage("pkg2", configuration); - PsiPackage outter = mySource.createPackage("outterPkg"); - move(JavaPsiFacade.getInstance(myProject).findPackage("pkg2"), outter.getQualifiedName()); - checkPackage("outterPkg.pkg2", configuration); - rename(outter, "outter2"); - checkPackage("outter2.pkg2", configuration); + PsiPackage outer = mySource.createPackage("outerPkg"); + move(JavaPsiFacade.getInstance(myProject).findPackage("pkg2"), outer.getQualifiedName()); + checkPackage("outerPkg.pkg2", configuration); + rename(outer, "outer2"); + checkPackage("outer2.pkg2", configuration); } public void testRenameJUnitContainingPackage() throws IOException { PsiClass psiClass = mySource.createClass("ATest", TEST_CODE); + assertNotNull(psiClass); JUnitConfiguration configuration = createConfiguration(psiClass); PsiPackage psiPackage = mySource.createPackage("pkg"); move(psiClass, "pkg"); @@ -95,6 +115,7 @@ public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase { public void testRefactorTestMethod() throws IOException { PsiClass psiClass = mySource.createClass("ATest", TEST_CODE); + assertNotNull(psiClass); PsiMethod testMethod = psiClass.findMethodsByName("test", false)[0]; JUnitConfiguration configuration = createConfiguration(testMethod); rename(testMethod, "test1"); @@ -110,6 +131,7 @@ public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase { PsiClass otherTest = mySource.createClass("ATest", TEST_CODE); HashSet members = new HashSet(); + assertNotNull(psiClass); members.add(psiClass.findMethodsByName("test1", false)[0]); moveMembers(otherTest, members); psiClass = configuration.getConfigurationModule().findClass(configuration.getPersistentData().getMainClassName()); @@ -117,6 +139,7 @@ public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase { checkClassName("ATest", configuration); assertEquals("ATest.test1", configuration.getName()); + assertNotNull(psiClass); PsiMethod otherMethod = psiClass.findMethodsByName("otherMethod", false)[0]; rename(otherMethod, "newName"); checkMethodName("test1", configuration); @@ -124,11 +147,13 @@ public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase { public void testRenameBadTestClass() throws IOException { PsiClass psiClass = mySource.createClass("NotATest", NOT_A_TEST); - JUnitConfiguration configuration = new JUnitConfiguration("notATest", myProject, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]); + assertNotNull(psiClass); + JUnitConfigurationType instance = JUnitConfigurationType.getInstance(); + assertNotNull(instance); + JUnitConfiguration configuration = new JUnitConfiguration("notATest", myProject, instance.getConfigurationFactories()[0]); configuration.setMainClass(psiClass); configuration.setModule(configuration.getValidModules().iterator().next()); - checkConfigurationException("NotATest isn't test class", configuration); RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(new RunnerAndConfigurationSettingsImpl(null, configuration, false)); @@ -144,7 +169,7 @@ public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase { assertEquals("test2", data.getMethodName()); } - private void checkConfigurationException(String expectedExceptionMessage, JUnitConfiguration configuration) { + private static void checkConfigurationException(String expectedExceptionMessage, JUnitConfiguration configuration) { try { configuration.checkConfiguration(); } @@ -156,13 +181,18 @@ public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase { } public void testRefactorOtherClass() throws IOException { - JUnitConfiguration configuration = createConfiguration(mySource.createClass("ATest", TEST_CODE)); - PsiClass psiClass = mySource.createClass("Application", APPLICATION_CODE); + PsiClass psiClass = mySource.createClass("ATest", TEST_CODE); + assertNotNull(psiClass); + JUnitConfiguration configuration = createConfiguration(psiClass); + + psiClass = mySource.createClass("Application", APPLICATION_CODE); + assertNotNull(psiClass); rename(psiClass, "NewName"); checkClassName("ATest", configuration); mySource.createPackage("pkg"); psiClass = mySource.findClass("NewName"); + assertNotNull(psiClass); move(psiClass, "pkg"); checkClassName("ATest", configuration); } @@ -170,7 +200,7 @@ public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase { private void moveMembers(final PsiClass otherTest, final HashSet members) { new WriteCommandAction(myProject) { @Override - protected void run(final Result result) throws Throwable { + protected void run(@NotNull Result result) throws Throwable { MockMoveMembersOptions options = new MockMoveMembersOptions(otherTest.getQualifiedName(), members); new MoveMembersProcessor(myProject, null, options).run(); } @@ -186,12 +216,13 @@ public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase { private void move(final PsiElement psiElement, String packageName) { VirtualFile pkgFile = mySource.createPackageDir(packageName); final PsiDirectory toDir = PsiManager.getInstance(myProject).findDirectory(pkgFile); + assertNotNull(toDir); new WriteCommandAction(myProject, psiElement.getContainingFile()) { @Override - protected void run(final Result result) throws Throwable { + protected void run(@NotNull Result result) throws Throwable { + PackageWrapper wrapper = PackageWrapper.create(JavaDirectoryService.getInstance().getPackage(toDir)); new MoveClassesOrPackagesProcessor(myProject, new PsiElement[]{psiElement}, - new SingleSourceRootMoveDestination( - PackageWrapper.create(JavaDirectoryService.getInstance().getPackage(toDir)), toDir), + new SingleSourceRootMoveDestination(wrapper, toDir), false, false, null).run(); } }.executeSilently(); @@ -200,11 +231,11 @@ public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase { private void rename(final PsiElement psiElement, final String newName) { new WriteCommandAction(myProject, psiElement.getContainingFile()) { @Override - protected void run(final Result result) throws Throwable { + protected void run(@NotNull Result result) throws Throwable { new RenameProcessor(myProject, psiElement, newName, false, false).run(); } }.executeSilently(); - } + } @Override protected void setUp() throws Exception { @@ -218,18 +249,20 @@ public class ConfigurationRefactoringsTest extends BaseConfigurationTestCase { protected void tearDown() throws Exception { mySource.tearDown(); mySource = null; - super.tearDown(); //To change body of overriden methods use Options | File Templates. + super.tearDown(); } @Override - protected T createConfiguration(PsiElement psiClass, MapDataContext dataContext) { - T configuration = (T)super.createConfiguration(psiClass, dataContext); + protected T createConfiguration(@NotNull PsiElement psiClass, @NotNull MapDataContext dataContext) { + T configuration = super.createConfiguration(psiClass, dataContext); RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(new RunnerAndConfigurationSettingsImpl(null, configuration, false)); return configuration; } @Override - protected JUnitConfiguration createJUnitConfiguration(final PsiElement psiElement, final Class producerClass, final MapDataContext dataContext) { + protected JUnitConfiguration createJUnitConfiguration(@NotNull PsiElement psiElement, + @NotNull Class producerClass, + @NotNull MapDataContext dataContext) { final JUnitConfiguration configuration = super.createJUnitConfiguration(psiElement, producerClass, dataContext); RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(new RunnerAndConfigurationSettingsImpl(null, configuration, false)); return configuration; From b877311f4a7a4626e09ef759f38b365e38933530 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 21 Feb 2014 13:53:44 +0100 Subject: [PATCH 52/75] Cleanup (unneeded test case inheritance) --- .../refactoring/IntroduceVariableSuite.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableSuite.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableSuite.java index b84f95e95cd7..d8123bfc7cd4 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableSuite.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableSuite.java @@ -1,13 +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.refactoring; import junit.framework.Test; -import junit.framework.TestCase; import junit.framework.TestSuite; /** * @author dsl */ -public class IntroduceVariableSuite extends TestCase { +public class IntroduceVariableSuite { public static Test suite() { final TestSuite suite = new TestSuite(); suite.addTestSuite(IntroduceVariableTest.class); From 7f5ae7e5ede44c655fdfc1b5efb9fabd0aab408a Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 21 Feb 2014 14:55:34 +0100 Subject: [PATCH 53/75] Cleanup (formatting) --- .../LightQuickFixParameterizedTestCase.java | 6 +++-- .../quickFix/LightQuickFixTestCase.java | 22 ++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java index 73e94a9669dc..e5b8772026d2 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java @@ -16,11 +16,12 @@ package com.intellij.codeInsight.daemon.quickFix; import com.intellij.testFramework.FileBasedTestCaseHelperEx; +import com.intellij.testFramework.Parameterized; import org.jetbrains.annotations.Nullable; import org.junit.Test; import org.junit.runner.RunWith; -@RunWith(com.intellij.testFramework.Parameterized.class) +@RunWith(Parameterized.class) public abstract class LightQuickFixParameterizedTestCase extends LightQuickFixTestCase implements FileBasedTestCaseHelperEx { @Override public String getRelativeBasePath() { @@ -34,11 +35,13 @@ public abstract class LightQuickFixParameterizedTestCase extends LightQuickFixTe return fileName.substring(BEFORE_PREFIX.length()); } + @SuppressWarnings("deprecation") @Override protected void doAllTests() { super.doAllTests(); } + @SuppressWarnings("JUnit4AnnotatedMethodInJUnit3TestCase") @Test public void runSingle() throws Throwable { final Throwable[] throwables = new Throwable[1]; @@ -60,6 +63,5 @@ public abstract class LightQuickFixParameterizedTestCase extends LightQuickFixTe if (throwables[0] != null) { throw throwables[0]; } - } } diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java index eafc24d7d15f..9bf434c3e0f5 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixTestCase.java @@ -114,7 +114,9 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase } @NotNull - public static Pair parseActionHint(@NotNull PsiFile file, @NotNull String contents, @NotNull @NonNls @RegExp String actionPattern) { + public static Pair parseActionHint(@NotNull PsiFile file, + @NotNull String contents, + @NotNull @NonNls @RegExp String actionPattern) { PsiFile hostFile = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file); final Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(hostFile.getLanguage()); @@ -198,6 +200,14 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase return null; } + /** + * @deprecated use {@link com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase} + * to get separate tests for all data files in testData directory. + */ + protected void doAllTests() { + doAllTests(createWrapper()); + } + public static void doAllTests(QuickFixTestCase testCase) { assertNotNull("getBasePath() should not return null!", testCase.getBasePath()); @@ -210,7 +220,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase } }); - if (files == null) { + if (files == null || files.length == 0) { fail("Test files not found in " + testDirPath); } @@ -218,20 +228,12 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase final String testName = file.getName().substring(BEFORE_PREFIX.length()); doTestFor(testName, testCase); } - assertTrue("Test files not found in "+testDirPath,files.length != 0); } protected void doSingleTest(String fileSuffix) { doTestFor(fileSuffix, createWrapper()); } - /** - * @deprecated use com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase to get separate tests for all data files in - * testData directory - */ - protected void doAllTests() { - doAllTests(createWrapper()); - } protected void doSingleTest(String fileSuffix, String testDataPath) { doTestFor(fileSuffix, createWrapper(testDataPath)); } From bdf35bd0a19e5f88815d9b97dbba14b0dc2f2503 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 21 Feb 2014 14:58:12 +0100 Subject: [PATCH 54/75] Cleanup (unneeded cast) --- .../codeStyle/JavaCodeStyleManagerImpl.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java index 10d4584be81d..7749d956c318 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.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. @@ -13,10 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.psi.impl.source.codeStyle; import com.intellij.lang.ASTNode; @@ -47,6 +43,9 @@ import org.jetbrains.annotations.Nullable; import java.beans.Introspector; import java.util.*; +/** + * @author max + */ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.codeStyle.JavaCodeStyleManagerImpl"); @@ -87,8 +86,7 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager { } @Override - public void shortenClassReferences(@NotNull PsiElement element, int startOffset, int endOffset) - throws IncorrectOperationException { + public void shortenClassReferences(@NotNull PsiElement element, int startOffset, int endOffset) throws IncorrectOperationException { CheckUtil.checkWritable(element); if (SourceTreeToPsiMap.hasTreeElement(element)) { final ReferenceAdjuster adjuster = ReferenceAdjuster.Extension.getReferenceAdjuster(element.getLanguage()); @@ -164,7 +162,7 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager { ContainerUtil.addAll(redundant, imports); redundant.removeAll(allImports); for (PsiImportStatementBase importStatement : imports) { - if (importStatement instanceof JspxImportStatement && ((JspxImportStatement)importStatement).isForeignFileImport()) { + if (importStatement instanceof JspxImportStatement && importStatement.isForeignFileImport()) { redundant.remove(importStatement); } } @@ -481,7 +479,7 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager { if (fromLiterals != null) { ContainerUtil.addAll(names, fromLiterals); } - + ContainerUtil.addAll(names, suggestVariableNameByExpressionOnly(expr, variableKind, correctKeywords, false).names); ContainerUtil.addAll(names, suggestVariableNameByExpressionPlace(expr, variableKind, correctKeywords).names); From dd456d2faaa7dc8c9667abdac40040a690a023f5 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 21 Feb 2014 15:29:10 +0100 Subject: [PATCH 55/75] Cleanup (typos) --- .../after/Test.java | 0 .../before/Super.java | 0 .../before/Test.java | 0 .../inlineSuperClass/{newexpr => newExpr}/after/Test.java | 0 .../{newexpr => newExpr}/after/Usage.java | 0 .../{newexpr => newExpr}/before/Super.java | 0 .../{newexpr => newExpr}/before/Test.java | 0 .../{newexpr => newExpr}/before/Usage.java | 0 .../com/intellij/refactoring/InlineSuperClassTest.java | 8 ++++---- 9 files changed, 4 insertions(+), 4 deletions(-) rename java/java-tests/testData/refactoring/inlineSuperClass/{innerclassReference => innerClassReference}/after/Test.java (100%) rename java/java-tests/testData/refactoring/inlineSuperClass/{innerclassReference => innerClassReference}/before/Super.java (100%) rename java/java-tests/testData/refactoring/inlineSuperClass/{innerclassReference => innerClassReference}/before/Test.java (100%) rename java/java-tests/testData/refactoring/inlineSuperClass/{newexpr => newExpr}/after/Test.java (100%) rename java/java-tests/testData/refactoring/inlineSuperClass/{newexpr => newExpr}/after/Usage.java (100%) rename java/java-tests/testData/refactoring/inlineSuperClass/{newexpr => newExpr}/before/Super.java (100%) rename java/java-tests/testData/refactoring/inlineSuperClass/{newexpr => newExpr}/before/Test.java (100%) rename java/java-tests/testData/refactoring/inlineSuperClass/{newexpr => newExpr}/before/Usage.java (100%) diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/innerclassReference/after/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/innerClassReference/after/Test.java similarity index 100% rename from java/java-tests/testData/refactoring/inlineSuperClass/innerclassReference/after/Test.java rename to java/java-tests/testData/refactoring/inlineSuperClass/innerClassReference/after/Test.java diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/innerclassReference/before/Super.java b/java/java-tests/testData/refactoring/inlineSuperClass/innerClassReference/before/Super.java similarity index 100% rename from java/java-tests/testData/refactoring/inlineSuperClass/innerclassReference/before/Super.java rename to java/java-tests/testData/refactoring/inlineSuperClass/innerClassReference/before/Super.java diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/innerclassReference/before/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/innerClassReference/before/Test.java similarity index 100% rename from java/java-tests/testData/refactoring/inlineSuperClass/innerclassReference/before/Test.java rename to java/java-tests/testData/refactoring/inlineSuperClass/innerClassReference/before/Test.java diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/newexpr/after/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/newExpr/after/Test.java similarity index 100% rename from java/java-tests/testData/refactoring/inlineSuperClass/newexpr/after/Test.java rename to java/java-tests/testData/refactoring/inlineSuperClass/newExpr/after/Test.java diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/newexpr/after/Usage.java b/java/java-tests/testData/refactoring/inlineSuperClass/newExpr/after/Usage.java similarity index 100% rename from java/java-tests/testData/refactoring/inlineSuperClass/newexpr/after/Usage.java rename to java/java-tests/testData/refactoring/inlineSuperClass/newExpr/after/Usage.java diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/newexpr/before/Super.java b/java/java-tests/testData/refactoring/inlineSuperClass/newExpr/before/Super.java similarity index 100% rename from java/java-tests/testData/refactoring/inlineSuperClass/newexpr/before/Super.java rename to java/java-tests/testData/refactoring/inlineSuperClass/newExpr/before/Super.java diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/newexpr/before/Test.java b/java/java-tests/testData/refactoring/inlineSuperClass/newExpr/before/Test.java similarity index 100% rename from java/java-tests/testData/refactoring/inlineSuperClass/newexpr/before/Test.java rename to java/java-tests/testData/refactoring/inlineSuperClass/newExpr/before/Test.java diff --git a/java/java-tests/testData/refactoring/inlineSuperClass/newexpr/before/Usage.java b/java/java-tests/testData/refactoring/inlineSuperClass/newExpr/before/Usage.java similarity index 100% rename from java/java-tests/testData/refactoring/inlineSuperClass/newexpr/before/Usage.java rename to java/java-tests/testData/refactoring/inlineSuperClass/newExpr/before/Usage.java diff --git a/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java b/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java index 690f7ac7ba0e..a82752a0ac9b 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java @@ -86,7 +86,7 @@ public class InlineSuperClassTest extends MultiFileTestCase { public void testInlineOneClass() throws Exception { doTest(false, true); } - + public void testInlineOneClassWithConflicts() throws Exception { doTest(true, true); } @@ -115,7 +115,7 @@ public class InlineSuperClassTest extends MultiFileTestCase { doTest(); } - public void testNewexpr() throws Exception { + public void testNewExpr() throws Exception { doTest(); } @@ -143,7 +143,7 @@ public class InlineSuperClassTest extends MultiFileTestCase { doTest(); } - public void testInnerclassReference() throws Exception { + public void testInnerClassReference() throws Exception { doTest(); } @@ -154,7 +154,7 @@ public class InlineSuperClassTest extends MultiFileTestCase { public void testNewArrayInitializerExpr() throws Exception { doTest(); } - + public void testNewArrayDimensionsExpr() throws Exception { doTest(); } From 19a15169ba510054284264ddb4bd74999c68a158 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 21 Feb 2014 18:43:39 +0100 Subject: [PATCH 56/75] Cleanup (pointless exceptions dropped; test reformatted) --- .../refactoring/InlineSuperClassTest.java | 206 +++++------------- .../refactoring/MultiFileTestCase.java | 48 ++-- 2 files changed, 80 insertions(+), 174 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java b/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java index a82752a0ac9b..701a967ad2a5 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/InlineSuperClassTest.java @@ -13,11 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * User: anna - * Date: 20-Aug-2008 - */ package com.intellij.refactoring; import com.intellij.JavaTestUtil; @@ -28,6 +23,10 @@ import com.intellij.refactoring.inlineSuperClass.InlineSuperClassRefactoringProc import com.intellij.refactoring.util.DocCommentPolicy; import org.jetbrains.annotations.NotNull; +/** + * @author anna + * @since 20-Aug-2008 + */ public class InlineSuperClassTest extends MultiFileTestCase { @NotNull @Override @@ -40,33 +39,55 @@ public class InlineSuperClassTest extends MultiFileTestCase { return JavaTestUtil.getJavaTestDataPath(); } - private void doTest() throws Exception { - doTest(false); + public void testInlineOneClass() { doTest(false, true); } + public void testInlineOneClassWithConflicts() { doTest(true, true); } + public void testAbstractOverrides() { doTest(); } + public void testSimple() { doTest(); } + public void testSimpleGenerics() { doTest(); } + public void testConflictGenerics() { doTest(true, false); } + public void testImports() { doTest(); } + public void testGenerics() { doTest(); } + public void testNewExpr() { doTest(); } + public void testConflictConstructors() { doTest(true, false); } + public void testConflictMultipleConstructors() { doTest(true, false); } + public void testMultipleConstructors() { doTest(); } + public void testImplicitChildConstructor() { doTest(); } + public void testStaticMembers() { doTest(); } + public void testSuperReference() { doTest(); } + public void testInnerClassReference() { doTest(); } + public void testStaticImport() { doTest(); } + public void testNewArrayInitializerExpr() { doTest(); } + public void testNewArrayDimensionsExpr() { doTest(); } + public void testNewArrayComplexDimensionsExpr() { doTest(); } + public void testSuperConstructorWithReturnInside() { doTest(true, false); } + public void testSuperConstructorWithFieldInitialization() { doTest(); } + public void testSuperConstructorWithParam() { doTest(); } + public void testChildConstructorImplicitlyCallsSuper() { doTest(); } + public void testNoChildConstructorCallsSuperDefault() { doTest(); } + public void testReplaceGenericsInside() { doTest(); } + public void testMultipleSubclasses() { doTestMultipleSubclasses(); } + public void testMultipleSubstitutions() { doTestMultipleSubclasses(); } + public void testMultipleSubclassesInheritsOneBaseBase() { doTestMultipleSubclasses(); } + public void testInlineSuperclassExtendsList() { doTest(); } + public void testInterfaceHierarchyWithSubstitution() { doTest(); } + + private void doTest() { + doTest(false, false); } - private void doTest(final boolean fail) throws Exception { - doTest(fail, false); - } - - private void doTest(final boolean fail, final boolean inlineOne) throws Exception { + private void doTest(boolean fail, final boolean inlineOne) { try { doTest(new PerformAction() { @Override public void performAction(final VirtualFile rootDir, final VirtualFile rootAfter) throws Exception { - PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.allScope(myProject)); - - if (aClass == null) aClass = myJavaFacade.findClass("p.Test", GlobalSearchScope.allScope(myProject)); + GlobalSearchScope scope = GlobalSearchScope.allScope(myProject); + PsiClass aClass = myJavaFacade.findClass("Test", scope); + if (aClass == null) aClass = myJavaFacade.findClass("p.Test", scope); assertNotNull("Class Test not found", aClass); - - PsiClass superClass = myJavaFacade.findClass("Super", GlobalSearchScope.allScope(myProject)); - - if (superClass == null) superClass = myJavaFacade.findClass("p1.Super", GlobalSearchScope.allScope(myProject)); + PsiClass superClass = myJavaFacade.findClass("Super", scope); + if (superClass == null) superClass = myJavaFacade.findClass("p1.Super", scope); assertNotNull("Class Super not found", superClass); - - new InlineSuperClassRefactoringProcessor(getProject(), inlineOne ? aClass : null, superClass, DocCommentPolicy.ASIS, aClass).run(); - - //LocalFileSystem.getInstance().refresh(false); - //FileDocumentManager.getInstance().saveAllDocuments(); + new InlineSuperClassRefactoringProcessor(myProject, inlineOne ? aClass : null, superClass, DocCommentPolicy.ASIS, aClass).run(); } }); } @@ -83,140 +104,17 @@ public class InlineSuperClassTest extends MultiFileTestCase { } } - public void testInlineOneClass() throws Exception { - doTest(false, true); - } - - public void testInlineOneClassWithConflicts() throws Exception { - doTest(true, true); - } - - public void testAbstractOverrides() throws Exception { - doTest(); - } - - public void testSimple() throws Exception { - doTest(); - } - - public void testSimpleGenerics() throws Exception { - doTest(); - } - - public void testConflictGenerics() throws Exception { - doTest(true); - } - - public void testImports() throws Exception { - doTest(); - } - - public void testGenerics() throws Exception { - doTest(); - } - - public void testNewExpr() throws Exception { - doTest(); - } - - public void testConflictConstructors() throws Exception { - doTest(true); - } - - public void testConflictMultipleConstructors() throws Exception { - doTest(true); - } - - public void testMultipleConstructors() throws Exception { - doTest(); - } - - public void testImplicitChildConstructor() throws Exception { - doTest(); - } - - public void testStaticMembers() throws Exception { - doTest(); - } - - public void testSuperReference() throws Exception { - doTest(); - } - - public void testInnerClassReference() throws Exception { - doTest(); - } - - public void testStaticImport() throws Exception { - doTest(); - } - - public void testNewArrayInitializerExpr() throws Exception { - doTest(); - } - - public void testNewArrayDimensionsExpr() throws Exception { - doTest(); - } - - public void testNewArrayComplexDimensionsExpr() throws Exception { - doTest(); - } - - public void testSuperConstructorWithReturnInside() throws Exception { - doTest(true); - } - - public void testSuperConstructorWithFieldInitialization() throws Exception { - doTest(); - } - - public void testSuperConstructorWithParam() throws Exception { - doTest(); - } - - public void testChildConstructorImplicitlyCallsSuper() throws Exception { - doTest(); - } - - public void testNoChildConstructorCallsSuperDefault() throws Exception { - doTest(); - } - - public void testReplaceGenericsInside() throws Exception { - doTest(); - } - - public void testMultipleSubclasses() throws Exception { - doTestMultipleSubclasses(); - } - - public void testMultipleSubstitutions() throws Exception { - doTestMultipleSubclasses(); - } - - public void testMultipleSubclassesInheritsOneBaseBase() throws Exception { - doTestMultipleSubclasses(); - } - - public void testInlineSuperclassExtendsList() throws Exception { - doTest(); - } - - public void testInterfaceHierarchyWithSubstitution() throws Exception { - doTest(); - } - - private void doTestMultipleSubclasses() throws Exception { + private void doTestMultipleSubclasses() { doTest(new PerformAction() { @Override public void performAction(final VirtualFile rootDir, final VirtualFile rootAfter) throws Exception { - PsiClass superClass = myJavaFacade.findClass("Super", GlobalSearchScope.allScope(myProject)); - if (superClass == null) superClass = myJavaFacade.findClass("p1.Super", GlobalSearchScope.allScope(myProject)); + GlobalSearchScope scope = GlobalSearchScope.allScope(myProject); + PsiClass superClass = myJavaFacade.findClass("Super", scope); + if (superClass == null) superClass = myJavaFacade.findClass("p1.Super", scope); assertNotNull("Class Super not found", superClass); - new InlineSuperClassRefactoringProcessor(getProject(), null, superClass, DocCommentPolicy.ASIS, - myJavaFacade.findClass("Test", GlobalSearchScope.allScope(myProject)), - myJavaFacade.findClass("Test1", GlobalSearchScope.allScope(myProject))).run(); + PsiClass target1 = myJavaFacade.findClass("Test", scope); + PsiClass target2 = myJavaFacade.findClass("Test1", scope); + new InlineSuperClassRefactoringProcessor(myProject, null, superClass, DocCommentPolicy.ASIS, target1, target2).run(); } }); } diff --git a/java/testFramework/src/com/intellij/refactoring/MultiFileTestCase.java b/java/testFramework/src/com/intellij/refactoring/MultiFileTestCase.java index cadc61af8dbd..7f2716e8179e 100644 --- a/java/testFramework/src/com/intellij/refactoring/MultiFileTestCase.java +++ b/java/testFramework/src/com/intellij/refactoring/MultiFileTestCase.java @@ -35,36 +35,44 @@ import java.io.File; public abstract class MultiFileTestCase extends CodeInsightTestCase { protected boolean myDoCompare = true; - protected void doTest(final PerformAction performAction) throws Exception { + protected void doTest(final PerformAction performAction) { doTest(performAction, getTestName(true)); } - protected void doTest(final PerformAction performAction, final boolean lowercaseFirstLetter) throws Exception { + protected void doTest(final PerformAction performAction, final boolean lowercaseFirstLetter) { doTest(performAction, getTestName(lowercaseFirstLetter)); } - protected void doTest(final PerformAction performAction, final String testName) throws Exception { - String path = getTestDataPath() + getTestRoot() + testName; + protected void doTest(final PerformAction performAction, final String testName) { + try { + String path = getTestDataPath() + getTestRoot() + testName; - String pathBefore = path + "/before"; - final VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, pathBefore, myFilesToDelete, false); - prepareProject(rootDir); - PsiDocumentManager.getInstance(myProject).commitAllDocuments(); + String pathBefore = path + "/before"; + VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, pathBefore, myFilesToDelete, false); + prepareProject(rootDir); + PsiDocumentManager.getInstance(myProject).commitAllDocuments(); - String pathAfter = path + "/after"; - final VirtualFile rootAfter = LocalFileSystem.getInstance().findFileByPath(pathAfter.replace(File.separatorChar, '/')); + String pathAfter = path + "/after"; + final VirtualFile rootAfter = LocalFileSystem.getInstance().findFileByPath(pathAfter.replace(File.separatorChar, '/')); - performAction.performAction(rootDir, rootAfter); - WriteCommandAction.runWriteCommandAction(getProject(), new Runnable() { - public void run() { - myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting(); + performAction.performAction(rootDir, rootAfter); + WriteCommandAction.runWriteCommandAction(getProject(), new Runnable() { + public void run() { + myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting(); + } + }); + + FileDocumentManager.getInstance().saveAllDocuments(); + + if (myDoCompare) { + PlatformTestUtil.assertDirectoriesEqual(rootAfter, rootDir); } - }); - - FileDocumentManager.getInstance().saveAllDocuments(); - - if (myDoCompare) { - PlatformTestUtil.assertDirectoriesEqual(rootAfter, rootDir); + } + catch (RuntimeException e) { + throw e; + } + catch (Exception e) { + throw new RuntimeException(e); } } From 307a9b994282b301d98fd5a51559eb328062c0b5 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 21 Feb 2014 20:36:59 +0100 Subject: [PATCH 57/75] github: assertion relaxed for tests --- .../org/jetbrains/plugins/github/api/GithubApiUtil.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 aad06e1f24f7..2036b3546030 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java +++ b/plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.jetbrains.plugins.github.api; import com.google.gson.*; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.net.HttpConfigurable; @@ -93,8 +94,8 @@ public class GithubApiUtil { @Nullable String requestBody, @NotNull Collection
headers, @NotNull HttpVerb verb) throws IOException { - LOG.assertTrue(!EventQueue.isDispatchThread(), "Network operation in EDT"); - EventQueue.isDispatchThread(); + LOG.assertTrue(!EventQueue.isDispatchThread() || ApplicationManager.getApplication().isUnitTestMode(), "Network operation in EDT"); + HttpMethod method = null; try { String uri = GithubUrlUtil.getApiUrl(auth.getHost()) + path; From ca5b7392bf787941f744ffba1556405ee1e802fa Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Fri, 21 Feb 2014 20:45:56 +0100 Subject: [PATCH 58/75] check disposed in read action (EA-53960 - assert: ComponentManagerImpl.getPicoContainer) --- .../src/com/intellij/find/impl/livePreview/SearchResults.java | 2 ++ 1 file changed, 2 insertions(+) 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 893072bb0ccc..754c3c6204ed 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 @@ -219,6 +219,8 @@ public class SearchResults implements DocumentListener { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { + Project project = getProject(); + if (project != null && project.isDisposed()) return; int[] starts = new int[0]; int[] ends = new int[0]; try { From e37b8532b58290d51a75eb99e04337cc98ad3512 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Fri, 21 Feb 2014 21:08:09 +0100 Subject: [PATCH 59/75] avoid invalid regions --- .../src/com/intellij/find/impl/livePreview/LivePreview.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreview.java b/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreview.java index bf172257afb4..c20b5925721d 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreview.java +++ b/platform/lang-impl/src/com/intellij/find/impl/livePreview/LivePreview.java @@ -262,6 +262,7 @@ public class LivePreview extends DocumentAdapter implements SearchResults.Search @Override public void run() { for (FoldRegion region : allRegions) { + if (!region.isValid()) continue; if (cursor.intersects(TextRange.create(region))) { region.setExpanded(true); } From 7544243f8d914f17d02575219b0f34665aecfd49 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Fri, 21 Feb 2014 21:44:17 +0100 Subject: [PATCH 60/75] platform project open processor starts to work as last one, to avoid its interception with SBT / Gradle / Maven / etc (IDEA-121111 ) --- resources/src/META-INF/IdeaPlugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index ed828dfb3200..967283cbc4cd 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -1466,7 +1466,7 @@ - + From 527e1de459dac8cd851bc3d2a62b19ed36a590e8 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 21 Feb 2014 20:40:53 +0100 Subject: [PATCH 61/75] runSingleTest(Runnable) extracted for parameterized tests --- .../LightQuickFixParameterizedTestCase.java | 12 +++------- .../LightPlatformCodeInsightTestCase.java | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java index e5b8772026d2..c8e17a9c96fc 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java @@ -44,18 +44,12 @@ public abstract class LightQuickFixParameterizedTestCase extends LightQuickFixTe @SuppressWarnings("JUnit4AnnotatedMethodInJUnit3TestCase") @Test public void runSingle() throws Throwable { - final Throwable[] throwables = new Throwable[1]; - - Runnable runnable = new Runnable() { + runSingleTest(new Runnable() { @Override public void run() { - try { - doSingleTest(myFileSuffix, myTestDataPath); - } - catch (Throwable e) { - throwables[0] = e; - } + doSingleTest(myFileSuffix, myTestDataPath); } + }); }; invokeTestRunnable(runnable); diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java index 3c6911e18dca..0b608f2a5fe2 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java @@ -747,4 +747,27 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest } } + protected void runSingleTest(Runnable testRunnable) throws Throwable { + final Throwable[] throwables = new Throwable[1]; + + Runnable runnable = new Runnable() { + @Override + public void run() { + try { + testRunnable.run(); + } + catch (Throwable e) { + throwables[0] = e; + } + } + }; + + invokeTestRunnable(runnable); + + if (throwables[0] != null) { + throw throwables[0]; + } + + } + } From b587af715127020e18462e1402af288de5e6f037 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 21 Feb 2014 20:46:50 +0100 Subject: [PATCH 62/75] exact method refs most specific: void compatibility --- .../graphInference/InferenceSession.java | 6 +- .../lambda/mostSpecific/VoidConflict.java | 46 ++++++++++++++++ .../lambda/MostSpecificResolutionTest.java | 55 +++++++++++++++++++ 3 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/VoidConflict.java create mode 100644 java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java 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 cda150db7a15..c5b5e9a928bf 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 @@ -1106,15 +1106,15 @@ public class InferenceSession { return false; } - final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType; - final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType; + final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType && sReturnType != PsiType.VOID; + final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType && tReturnType != PsiType.VOID; if (sPrimitive ^ tPrimitive) { final PsiMember member = ((PsiMethodReferenceExpression)arg).getPotentiallyApplicableMember(); LOG.assertTrue(member != null); if (member instanceof PsiMethod) { final PsiType methodReturnType = ((PsiMethod)member).getReturnType(); - if (sPrimitive && methodReturnType instanceof PsiPrimitiveType || + if (sPrimitive && methodReturnType instanceof PsiPrimitiveType && methodReturnType != PsiType.VOID || tPrimitive && methodReturnType instanceof PsiClassType) { return true; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/VoidConflict.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/VoidConflict.java new file mode 100644 index 000000000000..64e942c759b6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific/VoidConflict.java @@ -0,0 +1,46 @@ +class Test { + + interface I { void i_bar(); } + interface I1 { T i1_bar(); } + + private void m(I i) {System.out.println(i);} + private void m(I1 i1) {System.out.println(i1);} + + void test() { + m(Test::foo); + } + + public static int foo() { + return 0; + } +} + +class Test1 { + + interface I { void i_bar(); } + interface I1 { T i1_bar(); } + + void m(I i) { System.out.println(i);} + void m(I1 i1) { System.out.println(i1);} + + void test() { + m(Test1::foo); + } + + public static String foo() {return "";} +} + +class Test2 { + + interface I { void i_bar(); } + interface I1 { T i1_bar(); } + + void m(I i) { System.out.println(i);} + void m(I1 i1) { System.out.println(i1);} + + void test() { + m(Test2::foo); + } + + public static void foo() {} +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java new file mode 100644 index 000000000000..0cb2f0ecc65c --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java @@ -0,0 +1,55 @@ +/* + * 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.codeInsight.daemon.lambda; + +import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase; +import com.intellij.codeInspection.LocalInspectionTool; +import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection; +import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.testFramework.IdeaTestUtil; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase { + @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific"; + + @NotNull + @Override + protected LocalInspectionTool[] configureLocalInspectionTools() { + return new LocalInspectionTool[]{ + new UnusedSymbolLocalInspection(), + }; + } + + public void testVoidConflict() throws Exception { + doTest(); + } + + private void doTest() { + doTest(true); + } + + private void doTest(boolean warnings) { + IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable()); + doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false); + } + + @Override + protected Sdk getProjectJDK() { + return IdeaTestUtil.getMockJdk18(); + } +} From 07de1517e59449f1a524eea48ab4280d3f15611c Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 21 Feb 2014 21:11:47 +0100 Subject: [PATCH 63/75] AIOOBE --- .../impl/source/resolve/graphInference/InferenceSession.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c5b5e9a928bf..59089f5c16eb 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 @@ -1089,8 +1089,8 @@ public class InferenceSession { if (arg instanceof PsiMethodReferenceExpression && ((PsiMethodReferenceExpression)arg).isExact()) { final PsiParameter[] sParameters = sInterfaceMethod.getParameterList().getParameters(); final PsiParameter[] tParameters = tInterfaceMethod.getParameterList().getParameters(); - LOG.assertTrue(sParameters.length == tParameters.length); if (session != null) { + LOG.assertTrue(sParameters.length == tParameters.length); for (int i = 0; i < tParameters.length; i++) { session.addConstraint(new TypeEqualityConstraint(tSubstitutor.substitute(tParameters[i].getType()), sSubstitutor.substitute(sParameters[i].getType()))); From 0f39a4ca18d7863b5864f3893677899142b387bf Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 21 Feb 2014 21:42:49 +0100 Subject: [PATCH 64/75] method refs: restore error on invalid array creation --- .../java/PsiMethodReferenceExpressionImpl.java | 16 +++++----------- .../IncorrectArrayCreationSignature.java | 11 +++++++++++ .../lambda/NewMethodRefHighlightingTest.java | 4 ++++ 3 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IncorrectArrayCreationSignature.java diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java index 78005ac40b84..fdd02e86ebb3 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java @@ -17,11 +17,9 @@ package com.intellij.psi.impl.source.tree.java; import com.intellij.lang.ASTNode; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; -import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.impl.PsiManagerEx; import com.intellij.psi.impl.source.resolve.ParameterTypeInferencePolicy; @@ -62,18 +60,14 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase super(JavaElementType.METHOD_REF_EXPRESSION); } - public static boolean onArrayType(PsiClass containingClass, MethodSignature signature) { + private static boolean arrayCreationSignature(MethodSignature signature) { if (arrayCompatibleSignature(signature.getParameterTypes(), new Function() { @Override public PsiType fun(PsiType[] types) { return types[0]; } })) { - if (containingClass != null) { - final Project project = containingClass.getProject(); - final LanguageLevel level = PsiUtil.getLanguageLevel(containingClass); - return containingClass == JavaPsiFacade.getElementFactory(project).getArrayClass(level); - } + return true; } return false; } @@ -438,9 +432,9 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase substitutor = session.infer(); } ClassCandidateInfo candidateInfo = null; - if ((containingClass.getContainingClass() == null || !isLocatedInStaticContext(containingClass)) && - signature.getParameterTypes().length == 0 || - onArrayType(containingClass, signature)) { + final boolean isArray = containingClass == JavaPsiFacade.getElementFactory(getProject()).getArrayClass(PsiUtil.getLanguageLevel(containingClass)); + if (!isArray && (containingClass.getContainingClass() == null || !isLocatedInStaticContext(containingClass)) && signature.getParameterTypes().length == 0 || + isArray && arrayCreationSignature(signature)) { candidateInfo = new ClassCandidateInfo(containingClass, substitutor); } return candidateInfo == null ? JavaResolveResult.EMPTY_ARRAY : new JavaResolveResult[]{candidateInfo}; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IncorrectArrayCreationSignature.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IncorrectArrayCreationSignature.java new file mode 100644 index 000000000000..112449245cfb --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/IncorrectArrayCreationSignature.java @@ -0,0 +1,11 @@ +class Test { + interface I { + Object m(); + } + + void m(I i) {} + + { + m(String[]::new); + } +} 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 342337c3c278..8386a4c327b9 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 @@ -165,6 +165,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testIncorrectArrayCreationSignature() throws Exception { + doTest(); + } + private void doTest() { doTest(false); } From 41624fba53629af71d94bcf0f35923bbc0d2a65c Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 21 Feb 2014 21:48:50 +0100 Subject: [PATCH 65/75] merged --- .../quickFix/LightQuickFixParameterizedTestCase.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java index c8e17a9c96fc..b4cd26ef5ffd 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/quickFix/LightQuickFixParameterizedTestCase.java @@ -50,12 +50,5 @@ public abstract class LightQuickFixParameterizedTestCase extends LightQuickFixTe doSingleTest(myFileSuffix, myTestDataPath); } }); - }; - - invokeTestRunnable(runnable); - - if (throwables[0] != null) { - throw throwables[0]; - } } } From 57ebb8641197d124ed8b59e12aba1ef127060118 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 21 Feb 2014 21:40:05 +0100 Subject: [PATCH 66/75] Cleanup (interface adapter) --- .../ApplicationActivationListener.java | 31 ++++++++++++++++--- .../src/com/intellij/util/Alarm.java | 6 +--- .../fileChooser/ex/FileChooserDialogImpl.java | 8 ++--- .../openapi/ui/playback/PlaybackRunner.java | 8 ++--- .../src/com/intellij/ui/AppIcon.java | 10 ++---- 5 files changed, 34 insertions(+), 29 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/application/ApplicationActivationListener.java b/platform/platform-api/src/com/intellij/openapi/application/ApplicationActivationListener.java index badabf49e5e6..ad67106c56eb 100644 --- a/platform/platform-api/src/com/intellij/openapi/application/ApplicationActivationListener.java +++ b/platform/platform-api/src/com/intellij/openapi/application/ApplicationActivationListener.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.openapi.application; import com.intellij.openapi.wm.IdeFrame; @@ -7,17 +22,23 @@ import com.intellij.util.messages.Topic; * @author yole */ public interface ApplicationActivationListener { + Topic TOPIC = Topic.create("Application activation notifications", ApplicationActivationListener.class); + /** - * Is called when app is activated by transferring focus to it - * @param ideFrame + * Called when app is activated by transferring focus to it. */ void applicationActivated(IdeFrame ideFrame); /** - * Is called when app is de-activated by transferring focus from it - * @param ideFrame + * Called when app is de-activated by transferring focus from it. */ void applicationDeactivated(IdeFrame ideFrame); - Topic TOPIC = Topic.create("com.intellij.openapi.application.ApplicationActivationListener", ApplicationActivationListener.class); + abstract class Adapter implements ApplicationActivationListener { + @Override + public void applicationActivated(IdeFrame ideFrame) { } + + @Override + public void applicationDeactivated(IdeFrame ideFrame) { } + } } diff --git a/platform/platform-api/src/com/intellij/util/Alarm.java b/platform/platform-api/src/com/intellij/util/Alarm.java index 1462df1888e4..269b81b630c3 100644 --- a/platform/platform-api/src/com/intellij/util/Alarm.java +++ b/platform/platform-api/src/com/intellij/util/Alarm.java @@ -116,16 +116,12 @@ public class Alarm implements Disposable { if (runWithActiveFrameOnly && !ApplicationManager.getApplication().isActive()) { final MessageBus bus = ApplicationManager.getApplication().getMessageBus(); final MessageBusConnection connection = bus.connect(this); - connection.subscribe(ApplicationActivationListener.TOPIC, new ApplicationActivationListener() { + connection.subscribe(ApplicationActivationListener.TOPIC, new ApplicationActivationListener.Adapter() { @Override public void applicationActivated(IdeFrame ideFrame) { connection.disconnect(); addRequest(request, delay); } - - @Override - public void applicationDeactivated(IdeFrame ideFrame) { - } }); } else { addRequest(request, delay); diff --git a/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java index b1165471f28f..d585ec5a7b7d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.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. @@ -335,15 +335,11 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD ApplicationManager.getApplication().getMessageBus().connect(getDisposable()) - .subscribe(ApplicationActivationListener.TOPIC, new ApplicationActivationListener() { + .subscribe(ApplicationActivationListener.TOPIC, new ApplicationActivationListener.Adapter() { @Override public void applicationActivated(IdeFrame ideFrame) { SaveAndSyncHandlerImpl.getInstance().maybeRefresh(ModalityState.current()); } - - @Override - public void applicationDeactivated(IdeFrame ideFrame) { - } }); return panel; diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/PlaybackRunner.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/PlaybackRunner.java index 609e239c15e4..7de5fc0d30e0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/PlaybackRunner.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/PlaybackRunner.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. @@ -74,11 +74,7 @@ public class PlaybackRunner { myUseDirectActionCall = useDirectActionCall; myUseTypingTargets = useTypingTargets; myStopOnAppDeactivation = stopOnAppDeactivation; - myAppListener = new ApplicationActivationListener() { - @Override - public void applicationActivated(IdeFrame ideFrame) { - } - + myAppListener = new ApplicationActivationListener.Adapter() { @Override public void applicationDeactivated(IdeFrame ideFrame) { if (myStopOnAppDeactivation) { diff --git a/platform/platform-impl/src/com/intellij/ui/AppIcon.java b/platform/platform-impl/src/com/intellij/ui/AppIcon.java index 4dba3bebacb3..f8b4b062dbe1 100644 --- a/platform/platform-impl/src/com/intellij/ui/AppIcon.java +++ b/platform/platform-impl/src/com/intellij/ui/AppIcon.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -143,22 +143,18 @@ public abstract class AppIcon { Application app = ApplicationManager.getApplication(); if (app != null && myAppListener == null) { - myAppListener = new ApplicationActivationListener() { + myAppListener = new ApplicationActivationListener.Adapter() { @Override public void applicationActivated(IdeFrame ideFrame) { hideProgress(ideFrame.getProject(), myCurrentProcessId); _setOkBadge(ideFrame, false); _setTextBadge(ideFrame, null); } - - @Override - public void applicationDeactivated(IdeFrame ideFrame) { - } }; app.getMessageBus().connect().subscribe(ApplicationActivationListener.TOPIC, myAppListener); } - return app != null ? app.isActive() : false; + return app != null && app.isActive(); } } From 7f105db9310b47dd009fddba847a6e9e81c6ec5b Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 21 Feb 2014 22:03:35 +0100 Subject: [PATCH 67/75] Compilation fix --- .../LightPlatformCodeInsightTestCase.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java index 0b608f2a5fe2..070dab81e348 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java @@ -350,9 +350,9 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest * @param ignoreTrailingSpaces - whether trailing spaces in editor in data file should be stripped prior to comparing. */ protected void checkResultByText(final String message, @NotNull String fileText, final boolean ignoreTrailingSpaces) { - checkResultByText(message, fileText, ignoreTrailingSpaces, null); + checkResultByText(message, fileText, ignoreTrailingSpaces, null); } - + /** * Same as checkResultByFile but text is provided directly. * @param message - this check specific message. Added to text, caret position, selection checking. May be null @@ -547,7 +547,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest protected static void paste() { executeAction(IdeActions.ACTION_EDITOR_PASTE); } - + protected static void moveCaretToPreviousWordWithSelection() { executeAction("EditorPreviousWordWithSelection"); } @@ -559,7 +559,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest protected static void cutLineBackward() { executeAction("EditorCutLineBackward"); } - + protected static void cutToLineEnd() { executeAction("EditorCutLineEnd"); } @@ -567,7 +567,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest protected static void killToWordStart() { executeAction("EditorKillToWordStart"); } - + protected static void killToWordEnd() { executeAction("EditorKillToWordEnd"); } @@ -591,7 +591,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest protected static void lineComment() { new CommentByLineCommentHandler().invoke(getProject(), getEditor(), getFile()); } - + protected static void executeAction(@NonNls @NotNull final String actionId) { CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() { @Override @@ -636,14 +636,14 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest */ /** - * @Parameterized.Parameter fields are injected on parameterized test creation. + * @Parameterized.Parameter fields are injected on parameterized test creation. */ @Parameterized.Parameter(0) public String myFileSuffix; /** - * path to the root of test data in case of com.intellij.testFramework.FileBasedTestCaseHelperEx - * or + * path to the root of test data in case of com.intellij.testFramework.FileBasedTestCaseHelperEx + * or * path to the directory with current test data in case of @TestDataPath */ @Parameterized.Parameter(1) @@ -697,7 +697,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest } return result; } - + @Override public String getName() { if (myFileSuffix != null) { @@ -747,7 +747,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest } } - protected void runSingleTest(Runnable testRunnable) throws Throwable { + protected void runSingleTest(final Runnable testRunnable) throws Throwable { final Throwable[] throwables = new Throwable[1]; Runnable runnable = new Runnable() { From f786d1e87297514208c1d86fade092066167fbe0 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Sun, 23 Feb 2014 01:55:59 +0100 Subject: [PATCH 68/75] IDEA-120066 Auto indent on closing curly brace --- .../editorActions/TypedHandler.java | 32 +++++++++++++---- .../highlighting/BraceMatchingUtil.java | 34 +++++++++++++++++++ .../src/misc/registry.properties | 1 + 3 files changed, 61 insertions(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TypedHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TypedHandler.java index 2ced9a6b55b2..044e621edf34 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TypedHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TypedHandler.java @@ -33,10 +33,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.EditorModificationUtil; -import com.intellij.openapi.editor.ScrollType; +import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.actionSystem.TypedActionHandler; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.highlighter.EditorHighlighter; @@ -48,6 +45,7 @@ import com.intellij.openapi.fileTypes.FileTypes; import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.fileTypes.PlainTextLanguage; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.registry.Registry; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -582,13 +580,35 @@ public class TypedHandler extends TypedActionHandlerBase { final FileType fileType = file.getFileType(); BraceMatcher braceMatcher = BraceMatchingUtil.getBraceMatcher(fileType, iterator); - final boolean isBrace = braceMatcher.isLBraceToken(iterator, chars, fileType) || braceMatcher.isRBraceToken(iterator, chars, fileType); + boolean rBraceToken = braceMatcher.isRBraceToken(iterator, chars, fileType); + final boolean isBrace = braceMatcher.isLBraceToken(iterator, chars, fileType) || rBraceToken; + int lBraceOffset = -1; + + if (Registry.is("typing.rbrace.reformats.block") && + rBraceToken && + braceMatcher.isStructuralBrace(iterator, chars, fileType) && offset > 0) { + lBraceOffset = BraceMatchingUtil.findLeftLParen( + highlighter.createIterator(offset - 1), + braceMatcher.getOppositeBraceTokenType(iterator.getTokenType()), + editor.getDocument().getCharsSequence(), + fileType + ); + } if (element.getNode() != null && isBrace) { + final int finalLBraceOffset = lBraceOffset; ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run(){ try{ - int newOffset = CodeStyleManager.getInstance(project).adjustLineIndent(file, offset); + int newOffset; + if (finalLBraceOffset != -1) { + RangeMarker marker = document.createRangeMarker(offset, offset + 1); + CodeStyleManager.getInstance(project).reformatRange(file, finalLBraceOffset, offset, true); + newOffset = marker.getStartOffset(); + } else { + newOffset = CodeStyleManager.getInstance(project).adjustLineIndent(file, offset); + } + editor.getCaretModel().moveToOffset(newOffset + 1); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); editor.getSelectionModel().removeSelection(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java index c9d4d88d9529..c3fc814181b3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java @@ -301,6 +301,40 @@ public class BraceMatchingUtil { return lastLbraceOffset; } + public static int findLeftLParen(HighlighterIterator iterator, + IElementType lparenTokenType, + CharSequence fileText, + FileType fileType) { + int lastLbraceOffset = -1; + + Stack braceStack = new Stack(); + for (; !iterator.atEnd(); iterator.retreat()) { + final IElementType tokenType = iterator.getTokenType(); + + if (isLBraceToken(iterator, fileText, fileType)) { + if (!braceStack.isEmpty()) { + IElementType topToken = braceStack.pop(); + if (!isPairBraces(tokenType, topToken, fileType)) { + break; // unmatched braces + } + } + else { + if (tokenType == lparenTokenType) { + return iterator.getStart(); + } + else { + break; + } + } + } + else if (isRBraceToken(iterator, fileText, fileType)) { + braceStack.push(iterator.getTokenType()); + } + } + + return lastLbraceOffset; + } + // TODO: better name for this method public static int findRightmostRParen(HighlighterIterator iterator, IElementType rparenTokenType, diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index 191555d68323..15451cf444e4 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -365,3 +365,4 @@ ide.open.file.in.temp.project.dir.description=Enables opening file in temp proje editor.allow.multiple.carets=false embed.scene.builder=false +typing.rbrace.reformats.block=true \ No newline at end of file From d55d2bb64b6693d2dc62ba5b6dda4b4c0f7a095a Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 23 Feb 2014 20:42:45 +0100 Subject: [PATCH 69/75] rename physical->eventSystemEnabled to reduce confusion when constructing FileViewProvider --- .../intellij/psi/ClassFileViewProvider.java | 4 ++-- .../psi/ClassFileViewProviderFactory.java | 8 ++++---- .../intellij/psi/FileViewProviderFactory.java | 2 +- .../src/com/intellij/psi/PsiFileFactory.java | 8 ++++---- ...plePsiFilesPerDocumentFileViewProvider.java | 4 ++-- .../psi/SingleRootFileViewProvider.java | 8 ++++---- .../intellij/psi/impl/EmptyFileManager.java | 4 ++-- .../intellij/psi/impl/PsiFileFactoryImpl.java | 18 +++++++++--------- .../psi/impl/file/impl/FileManager.java | 2 +- .../psi/impl/file/impl/FileManagerImpl.java | 6 +++--- .../src/com/intellij/mock/MockFileManager.java | 4 ++-- .../rest/RestFileProviderFactory.java | 4 ++-- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProvider.java b/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProvider.java index bdcc3f11188f..ef89a6cc70be 100644 --- a/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProvider.java +++ b/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProvider.java @@ -31,8 +31,8 @@ public class ClassFileViewProvider extends SingleRootFileViewProvider { super(manager, file); } - public ClassFileViewProvider(@NotNull final PsiManager manager, @NotNull final VirtualFile virtualFile, final boolean physical) { - super(manager, virtualFile, physical); + public ClassFileViewProvider(@NotNull final PsiManager manager, @NotNull final VirtualFile virtualFile, final boolean eventSystemEnabled) { + super(manager, virtualFile, eventSystemEnabled); } @Override diff --git a/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java b/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java index d9b77117801d..de870b9cfcbf 100644 --- a/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java +++ b/java/java-psi-impl/src/com/intellij/psi/ClassFileViewProviderFactory.java @@ -29,20 +29,20 @@ import static com.intellij.psi.compiled.ClassFileDecompilers.Full; */ public class ClassFileViewProviderFactory implements FileViewProviderFactory { @Override - public FileViewProvider createFileViewProvider(@NotNull VirtualFile file, Language language, @NotNull PsiManager manager, boolean physical) { + public FileViewProvider createFileViewProvider(@NotNull VirtualFile file, Language language, @NotNull PsiManager manager, boolean eventSystemEnabled) { ClassFileDecompilers.Decompiler decompiler = ClassFileDecompilers.find(file); if (decompiler instanceof Full) { - return ((Full)decompiler).createFileViewProvider(file, manager, physical); + return ((Full)decompiler).createFileViewProvider(file, manager, eventSystemEnabled); } for (ContentBasedFileSubstitutor processor : Extensions.getExtensions(ContentBasedFileSubstitutor.EP_NAME)) { Language lang = processor.obtainLanguageForFile(file); if (lang != null) { FileViewProviderFactory factory = LanguageFileViewProviders.INSTANCE.forLanguage(language); - return factory.createFileViewProvider(file, language, manager, physical); + return factory.createFileViewProvider(file, language, manager, eventSystemEnabled); } } - return new ClassFileViewProvider(manager, file, physical); + return new ClassFileViewProvider(manager, file, eventSystemEnabled); } } \ No newline at end of file diff --git a/platform/core-api/src/com/intellij/psi/FileViewProviderFactory.java b/platform/core-api/src/com/intellij/psi/FileViewProviderFactory.java index 4fe3ecdaae78..60fdf43dad58 100644 --- a/platform/core-api/src/com/intellij/psi/FileViewProviderFactory.java +++ b/platform/core-api/src/com/intellij/psi/FileViewProviderFactory.java @@ -26,5 +26,5 @@ import org.jetbrains.annotations.NotNull; * @author yole */ public interface FileViewProviderFactory { - FileViewProvider createFileViewProvider(@NotNull VirtualFile file, Language language, @NotNull PsiManager manager, boolean physical); + FileViewProvider createFileViewProvider(@NotNull VirtualFile file, Language language, @NotNull PsiManager manager, boolean eventSystemEnabled); } \ No newline at end of file diff --git a/platform/core-api/src/com/intellij/psi/PsiFileFactory.java b/platform/core-api/src/com/intellij/psi/PsiFileFactory.java index b96a0fbddba9..b31c03b6640a 100644 --- a/platform/core-api/src/com/intellij/psi/PsiFileFactory.java +++ b/platform/core-api/src/com/intellij/psi/PsiFileFactory.java @@ -55,19 +55,19 @@ public abstract class PsiFileFactory { @NotNull public abstract PsiFile createFileFromText(@NonNls @NotNull String name, @NotNull FileType fileType, @NotNull CharSequence text, - long modificationStamp, boolean physical); + long modificationStamp, boolean eventSystemEnabled); @NotNull public abstract PsiFile createFileFromText(@NonNls @NotNull String name, @NotNull FileType fileType, @NotNull CharSequence text, - long modificationStamp, boolean physical, boolean markAsCopy); + long modificationStamp, boolean eventSystemEnabled, boolean markAsCopy); public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text); public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text, - boolean physical, boolean markAsCopy); + boolean eventSystemEnabled, boolean markAsCopy); public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text, - boolean physical, boolean markAsCopy, boolean noSizeLimit); + boolean eventSystemEnabled, boolean markAsCopy, boolean noSizeLimit); public abstract PsiFile createFileFromText(FileType fileType, String fileName, CharSequence chars, int startOffset, int endOffset); diff --git a/platform/core-impl/src/com/intellij/psi/MultiplePsiFilesPerDocumentFileViewProvider.java b/platform/core-impl/src/com/intellij/psi/MultiplePsiFilesPerDocumentFileViewProvider.java index 0d0e16ce4967..c6554f83fb7a 100644 --- a/platform/core-impl/src/com/intellij/psi/MultiplePsiFilesPerDocumentFileViewProvider.java +++ b/platform/core-impl/src/com/intellij/psi/MultiplePsiFilesPerDocumentFileViewProvider.java @@ -42,8 +42,8 @@ public abstract class MultiplePsiFilesPerDocumentFileViewProvider extends Single private final ConcurrentMap myRoots = new ConcurrentHashMap(1, ConcurrentHashMap.DEFAULT_LOAD_FACTOR, 1); private MultiplePsiFilesPerDocumentFileViewProvider myOriginal = null; - public MultiplePsiFilesPerDocumentFileViewProvider(PsiManager manager, VirtualFile virtualFile, boolean physical) { - super(manager, virtualFile, physical, Language.ANY); + public MultiplePsiFilesPerDocumentFileViewProvider(PsiManager manager, VirtualFile virtualFile, boolean eventSystemEnabled) { + super(manager, virtualFile, eventSystemEnabled, Language.ANY); } @Override diff --git a/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java b/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java index 742483a8d5ab..777eea35a1a5 100644 --- a/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java +++ b/platform/core-impl/src/com/intellij/psi/SingleRootFileViewProvider.java @@ -77,14 +77,14 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi this(manager, file, true); } - public SingleRootFileViewProvider(@NotNull PsiManager manager, @NotNull VirtualFile virtualFile, final boolean physical) { - this(manager, virtualFile, physical, calcBaseLanguage(virtualFile, manager.getProject())); + public SingleRootFileViewProvider(@NotNull PsiManager manager, @NotNull VirtualFile virtualFile, final boolean eventSystemEnabled) { + this(manager, virtualFile, eventSystemEnabled, calcBaseLanguage(virtualFile, manager.getProject())); } - protected SingleRootFileViewProvider(@NotNull PsiManager manager, @NotNull VirtualFile virtualFile, final boolean physical, @NotNull Language language) { + protected SingleRootFileViewProvider(@NotNull PsiManager manager, @NotNull VirtualFile virtualFile, final boolean eventSystemEnabled, @NotNull Language language) { myManager = manager; myVirtualFile = virtualFile; - myEventSystemEnabled = physical; + myEventSystemEnabled = eventSystemEnabled; myBaseLanguage = language; setContent(new VirtualFileContent()); myPhysical = isEventSystemEnabled() && diff --git a/platform/core-impl/src/com/intellij/psi/impl/EmptyFileManager.java b/platform/core-impl/src/com/intellij/psi/impl/EmptyFileManager.java index c415487237ed..8479be924ee7 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/EmptyFileManager.java +++ b/platform/core-impl/src/com/intellij/psi/impl/EmptyFileManager.java @@ -78,8 +78,8 @@ class EmptyFileManager implements FileManager { @Override @NotNull - public FileViewProvider createFileViewProvider(@NotNull final VirtualFile file, final boolean physical) { - return new SingleRootFileViewProvider(myManager, file, physical); + public FileViewProvider createFileViewProvider(@NotNull final VirtualFile file, final boolean eventSystemEnabled) { + return new SingleRootFileViewProvider(myManager, file, eventSystemEnabled); } @Override diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiFileFactoryImpl.java b/platform/core-impl/src/com/intellij/psi/impl/PsiFileFactoryImpl.java index 39e302c73ac5..a24a942bcfea 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/PsiFileFactoryImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/PsiFileFactoryImpl.java @@ -51,8 +51,8 @@ public class PsiFileFactoryImpl extends PsiFileFactory { @Override @NotNull public PsiFile createFileFromText(@NotNull String name, @NotNull FileType fileType, @NotNull CharSequence text, - long modificationStamp, final boolean physical) { - return createFileFromText(name, fileType, text, modificationStamp, physical, true); + long modificationStamp, final boolean eventSystemEnabled) { + return createFileFromText(name, fileType, text, modificationStamp, eventSystemEnabled, true); } @Override @@ -61,22 +61,22 @@ public class PsiFileFactoryImpl extends PsiFileFactory { } @Override - public PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text, boolean physical, boolean markAsCopy) { - return createFileFromText(name, language, text, physical, markAsCopy, false); + public PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text, boolean eventSystemEnabled, boolean markAsCopy) { + return createFileFromText(name, language, text, eventSystemEnabled, markAsCopy, false); } @Override public PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text, - boolean physical, + boolean eventSystemEnabled, boolean markAsCopy, boolean noSizeLimit) { LightVirtualFile virtualFile = new LightVirtualFile(name, language, text); if (noSizeLimit) { SingleRootFileViewProvider.doNotCheckFileSizeLimit(virtualFile); } - return trySetupPsiForFile(virtualFile, language, physical, markAsCopy); + return trySetupPsiForFile(virtualFile, language, eventSystemEnabled, markAsCopy); } @Override @@ -85,17 +85,17 @@ public class PsiFileFactoryImpl extends PsiFileFactory { @NotNull FileType fileType, @NotNull CharSequence text, long modificationStamp, - final boolean physical, + final boolean eventSystemEnabled, boolean markAsCopy) { final LightVirtualFile virtualFile = new LightVirtualFile(name, fileType, text, modificationStamp); if(fileType instanceof LanguageFileType){ final Language language = LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)fileType).getLanguage(), virtualFile, myManager.getProject()); - final PsiFile file = trySetupPsiForFile(virtualFile, language, physical, markAsCopy); + final PsiFile file = trySetupPsiForFile(virtualFile, language, eventSystemEnabled, markAsCopy); if (file != null) return file; } final SingleRootFileViewProvider singleRootFileViewProvider = - new SingleRootFileViewProvider(myManager, virtualFile, physical); + new SingleRootFileViewProvider(myManager, virtualFile, eventSystemEnabled); final PsiPlainTextFileImpl plainTextFile = new PsiPlainTextFileImpl(singleRootFileViewProvider); if(markAsCopy) CodeEditUtil.setNodeGenerated(plainTextFile.getNode(), true); return plainTextFile; diff --git a/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManager.java b/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManager.java index 4a94b3adb40b..b95946c1d5e2 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManager.java +++ b/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManager.java @@ -50,5 +50,5 @@ public interface FileManager extends Disposable { List getAllCachedFiles(); @NotNull - FileViewProvider createFileViewProvider(@NotNull VirtualFile file, boolean physical); + FileViewProvider createFileViewProvider(@NotNull VirtualFile file, boolean eventSystemEnabled); } diff --git a/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManagerImpl.java b/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManagerImpl.java index 2e94b48e4b7a..60b19f3d76fa 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManagerImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/file/impl/FileManagerImpl.java @@ -193,14 +193,14 @@ public class FileManagerImpl implements FileManager { @Override @NotNull - public FileViewProvider createFileViewProvider(@NotNull final VirtualFile file, boolean physical) { + public FileViewProvider createFileViewProvider(@NotNull final VirtualFile file, boolean eventSystemEnabled) { Language language = getLanguage(file); final FileViewProviderFactory factory = language == null ? FileTypeFileViewProviders.INSTANCE.forFileType(file.getFileType()) : LanguageFileViewProviders.INSTANCE.forLanguage(language); - FileViewProvider viewProvider = factory == null ? null : factory.createFileViewProvider(file, language, myManager, physical); + FileViewProvider viewProvider = factory == null ? null : factory.createFileViewProvider(file, language, myManager, eventSystemEnabled); - return viewProvider == null ? new SingleRootFileViewProvider(myManager, file, physical) : viewProvider; + return viewProvider == null ? new SingleRootFileViewProvider(myManager, file, eventSystemEnabled) : viewProvider; } @Nullable diff --git a/platform/lang-impl/src/com/intellij/mock/MockFileManager.java b/platform/lang-impl/src/com/intellij/mock/MockFileManager.java index f5cb2e19c236..2197dff2b9fa 100644 --- a/platform/lang-impl/src/com/intellij/mock/MockFileManager.java +++ b/platform/lang-impl/src/com/intellij/mock/MockFileManager.java @@ -42,8 +42,8 @@ public class MockFileManager implements FileManager { @Override @NotNull - public FileViewProvider createFileViewProvider(@NotNull final VirtualFile file, final boolean physical) { - return new SingleRootFileViewProvider(myManager, file, physical); + public FileViewProvider createFileViewProvider(@NotNull final VirtualFile file, final boolean eventSystemEnabled) { + return new SingleRootFileViewProvider(myManager, file, eventSystemEnabled); } public MockFileManager(final PsiManagerEx manager) { diff --git a/python/python-rest/src/com/jetbrains/rest/RestFileProviderFactory.java b/python/python-rest/src/com/jetbrains/rest/RestFileProviderFactory.java index 121ef6ecd8f4..5c61251d9ba6 100644 --- a/python/python-rest/src/com/jetbrains/rest/RestFileProviderFactory.java +++ b/python/python-rest/src/com/jetbrains/rest/RestFileProviderFactory.java @@ -27,7 +27,7 @@ import org.jetbrains.annotations.NotNull; */ public class RestFileProviderFactory implements FileViewProviderFactory { - public FileViewProvider createFileViewProvider(@NotNull VirtualFile virtualFile, Language language, @NotNull PsiManager psiManager, boolean physical) { - return new RestFileViewProvider(psiManager, virtualFile, physical); + public FileViewProvider createFileViewProvider(@NotNull VirtualFile virtualFile, Language language, @NotNull PsiManager psiManager, boolean eventSystemEnabled) { + return new RestFileViewProvider(psiManager, virtualFile, eventSystemEnabled); } } From e52b01a70454e1b785d6a84e75a4e1cf919d3439 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 23 Feb 2014 21:02:39 +0100 Subject: [PATCH 70/75] an API to avoid CCEs when doing StubIndex.process --- .../src/com/intellij/psi/stubs/StubIndex.java | 22 +++++++++- .../psi/stubs/StubProcessingHelperBase.java | 41 +++++++++++-------- .../com/intellij/psi/stubs/StubIndexImpl.java | 10 +++-- .../psi/stubs/StubProcessingHelper.java | 12 ++---- 4 files changed, 54 insertions(+), 31 deletions(-) diff --git a/platform/indexing-api/src/com/intellij/psi/stubs/StubIndex.java b/platform/indexing-api/src/com/intellij/psi/stubs/StubIndex.java index f2533463f855..53bd28fdc803 100644 --- a/platform/indexing-api/src/com/intellij/psi/stubs/StubIndex.java +++ b/platform/indexing-api/src/com/intellij/psi/stubs/StubIndex.java @@ -64,10 +64,20 @@ public abstract class StubIndex { return get(indexKey, key, project, scope); } - public abstract boolean process(@NotNull StubIndexKey indexKey, + @Deprecated + public boolean process(@NotNull StubIndexKey indexKey, @NotNull Key key, @NotNull Project project, GlobalSearchScope scope, + @NotNull Processor processor) { + return processElements(indexKey, key, project, scope, (Class)PsiElement.class, processor); + } + + public abstract boolean processElements(@NotNull StubIndexKey indexKey, + @NotNull Key key, + @NotNull Project project, + GlobalSearchScope scope, + Class requiredClass, @NotNull Processor processor); public boolean process(@NotNull StubIndexKey indexKey, @@ -79,6 +89,16 @@ public abstract class StubIndex { return process(indexKey, key, project, scope, processor); } + public boolean processElements(@NotNull StubIndexKey indexKey, + @NotNull Key key, + @NotNull Project project, + GlobalSearchScope scope, + IdFilter idFilter, + Class requiredClass, + @NotNull Processor processor) { + return process(indexKey, key, project, scope, processor); + } + @NotNull public abstract Collection getAllKeys(@NotNull StubIndexKey indexKey, @NotNull Project project); diff --git a/platform/indexing-impl/src/com/intellij/psi/stubs/StubProcessingHelperBase.java b/platform/indexing-impl/src/com/intellij/psi/stubs/StubProcessingHelperBase.java index 6b2493373fb4..05fada9b8fc7 100644 --- a/platform/indexing-impl/src/com/intellij/psi/stubs/StubProcessingHelperBase.java +++ b/platform/indexing-impl/src/com/intellij/psi/stubs/StubProcessingHelperBase.java @@ -32,21 +32,21 @@ public abstract class StubProcessingHelperBase { return stub.getStubType(); } - public boolean processStubsInFile(final Project project, final VirtualFile file, StubIdList value, final Processor processor) { - return processStubsInFile(project, file, value, processor, false); + public boolean processStubsInFile(final Project project, final VirtualFile file, StubIdList value, final Processor processor, Class requiredClass) { + return processStubsInFile(project, file, value, processor, requiredClass, false); } - public boolean processStubsInFile(final Project project, final VirtualFile file, StubIdList value, final Processor processor, final boolean skipOnErrors) { + public boolean processStubsInFile(final Project project, final VirtualFile file, StubIdList value, final Processor processor, Class requiredClass, final boolean skipOnErrors) { StubTree stubTree = null; - PsiFile _psifile = PsiManager.getInstance(project).findFile(file); + PsiFile someRoot = PsiManager.getInstance(project).findFile(file); PsiFileWithStubSupport psiFile = null; boolean customStubs = false; - if (_psifile != null && !(_psifile instanceof PsiPlainTextFile)) { - _psifile = _psifile.getViewProvider().getStubBindingRoot(); - if (_psifile instanceof PsiFileWithStubSupport) { - psiFile = (PsiFileWithStubSupport)_psifile; + if (someRoot != null && !(someRoot instanceof PsiPlainTextFile)) { + someRoot = someRoot.getViewProvider().getStubBindingRoot(); + if (someRoot instanceof PsiFileWithStubSupport) { + psiFile = (PsiFileWithStubSupport)someRoot; stubTree = psiFile.getStubTree(); if (stubTree == null && psiFile instanceof PsiFileImpl) { IElementType contentElementType = ((PsiFileImpl)psiFile).getContentElementType(); @@ -91,6 +91,10 @@ public abstract class StubProcessingHelperBase { if (tree.getElementType() == stubType(stub)) { Psi psi = (Psi)tree.getPsi(); PsiUtilCore.ensureValid(psi); + if (!skipOnErrors && !requiredClass.isInstance(psi)) { + inconsistencyDetected(stubTree, psiFile); + break; + } if (!processor.process(psi)) return false; } else if (!skipOnErrors) { @@ -121,31 +125,32 @@ public abstract class StubProcessingHelperBase { final int stubTreeIndex = value.get(i); if (stubTreeIndex >= plained.size()) { if (!skipOnErrors) { - final VirtualFile virtualFile = psiFile.getVirtualFile(); - StubTree stubTreeFromIndex = (StubTree)StubTreeLoader.getInstance().readFromVFile(project, file); - LOG.error(stubTreeAndIndexDoNotMatch(stubTree, psiFile, plained, virtualFile, stubTreeFromIndex)); - - onInternalError(file); + inconsistencyDetected(stubTree, psiFile); } break; } Psi psi = (Psi)plained.get(stubTreeIndex).getPsi(); PsiUtilCore.ensureValid(psi); + if (!skipOnErrors && !requiredClass.isInstance(psi)) { + inconsistencyDetected(stubTree, psiFile); + break; + } if (!processor.process(psi)) return false; } } return true; } + private void inconsistencyDetected(StubTree stubTree, PsiFileWithStubSupport psiFile) { + LOG.error(stubTreeAndIndexDoNotMatch(stubTree, psiFile)); + onInternalError(psiFile.getVirtualFile()); + } + /*** * Returns a message to log when stub tree and index do not match */ - protected abstract Object stubTreeAndIndexDoNotMatch(StubTree stubTree, - PsiFileWithStubSupport psiFile, - List> plained, - VirtualFile virtualFile, - StubTree stubTreeFromIndex); + protected abstract Object stubTreeAndIndexDoNotMatch(StubTree stubTree, PsiFileWithStubSupport psiFile); protected abstract void onInternalError(VirtualFile file); diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java index ac97ea9a491c..0877a65f51bc 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java @@ -219,20 +219,22 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe } @Override - public boolean process(@NotNull StubIndexKey indexKey, + public boolean processElements(@NotNull StubIndexKey indexKey, @NotNull Key key, @NotNull Project project, GlobalSearchScope scope, + Class requiredClass, @NotNull Processor processor) { - return process(indexKey, key, project, scope, null, processor); + return processElements(indexKey, key, project, scope, null, requiredClass, processor); } @Override - public boolean process(@NotNull final StubIndexKey indexKey, + public boolean processElements(@NotNull final StubIndexKey indexKey, @NotNull final Key key, @NotNull final Project project, @Nullable final GlobalSearchScope scope, @Nullable IdFilter idFilter, + final Class requiredClass, @NotNull final Processor processor) { final FileBasedIndexImpl fileBasedIndex = (FileBasedIndexImpl)FileBasedIndex.getInstance(); fileBasedIndex.ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, scope); @@ -259,7 +261,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe if (file == null || scope != null && !scope.contains(file)) { return true; } - return myStubProcessingHelper.processStubsInFile(project, file, value, processor); + return myStubProcessingHelper.processStubsInFile(project, file, value, processor, requiredClass); } }); diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubProcessingHelper.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubProcessingHelper.java index 92844c7d00b1..2e0b5c578550 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/StubProcessingHelper.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubProcessingHelper.java @@ -1,16 +1,14 @@ package com.intellij.psi.stubs; import com.intellij.diagnostic.LogMessageEx; -import com.intellij.openapi.diagnostic.Attachment; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; +import com.intellij.openapi.diagnostic.Attachment; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiCompiledElement; import com.intellij.psi.impl.source.PsiFileWithStubSupport; import com.intellij.util.indexing.FileBasedIndex; -import java.util.List; - /** * Author: dmitrylomov */ @@ -35,11 +33,9 @@ public class StubProcessingHelper extends StubProcessingHelperBase { @Override - protected Object stubTreeAndIndexDoNotMatch(StubTree stubTree, - PsiFileWithStubSupport psiFile, - List> plained, - VirtualFile virtualFile, - StubTree stubTreeFromIndex) { + protected Object stubTreeAndIndexDoNotMatch(StubTree stubTree, PsiFileWithStubSupport psiFile) { + final VirtualFile virtualFile = psiFile.getVirtualFile(); + StubTree stubTreeFromIndex = (StubTree)StubTreeLoader.getInstance().readFromVFile(psiFile.getProject(), virtualFile); String details = "Please report the problem to JetBrains with the file attached"; details += "\npsiFile" + psiFile; details += "\npsiFile.class" + psiFile.getClass(); From adaef156d4cf08b478f227e9567a08f151baff84 Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Mon, 24 Feb 2014 12:19:17 +0400 Subject: [PATCH 71/75] rearrange checkbox in reformat files dialog moved before "only VCS changed text" --- .../intellij/codeInsight/actions/ReformatFilesDialog.form | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatFilesDialog.form b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatFilesDialog.form index f27be63f56da..97a3afccbb10 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatFilesDialog.form +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatFilesDialog.form @@ -3,7 +3,7 @@ - + @@ -34,7 +34,7 @@ - + @@ -47,7 +47,7 @@ - + From 06933eb0f999f572b8ad556da2107770045d1a80 Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Mon, 24 Feb 2014 12:53:00 +0400 Subject: [PATCH 72/75] IDEA-117902 Commit message wrapping behaves strangely --- .../editor/TextLineWrapPositionStrategy.java | 36 +++++ .../src/META-INF/PlatformExtensions.xml | 2 + .../AbstractLineWrapPositionStrategyTest.java | 135 ++++++++++++++++++ .../DefaultLineWrapPositionStrategyTest.java | 128 +---------------- .../TextLineWrapPositionStrategyTest.java | 37 +++++ 5 files changed, 217 insertions(+), 121 deletions(-) create mode 100644 platform/platform-api/src/com/intellij/openapi/editor/TextLineWrapPositionStrategy.java create mode 100644 platform/platform-tests/testSrc/com/intellij/openapi/editor/AbstractLineWrapPositionStrategyTest.java create mode 100644 platform/platform-tests/testSrc/com/intellij/openapi/editor/TextLineWrapPositionStrategyTest.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/TextLineWrapPositionStrategy.java b/platform/platform-api/src/com/intellij/openapi/editor/TextLineWrapPositionStrategy.java new file mode 100644 index 000000000000..21e232a1c038 --- /dev/null +++ b/platform/platform-api/src/com/intellij/openapi/editor/TextLineWrapPositionStrategy.java @@ -0,0 +1,36 @@ +/* + * 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.openapi.editor; + +public class TextLineWrapPositionStrategy extends GenericLineWrapPositionStrategy { + + public TextLineWrapPositionStrategy() { + // Commas. + addRule(new Rule(',', WrapCondition.AFTER, Rule.DEFAULT_WEIGHT)); + + // Symbols to wrap either before or after. + addRule(new Rule(' ')); + addRule(new Rule('\t')); + + // Symbols to wrap after. + addRule(new Rule(';', WrapCondition.AFTER)); + addRule(new Rule(')', WrapCondition.AFTER)); + + // Symbols to wrap before + addRule(new Rule('(', WrapCondition.BEFORE)); + addRule(new Rule('.', WrapCondition.BEFORE)); + } +} diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index d02dd820f454..bd5693a0cfb9 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -288,6 +288,8 @@ + + diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/AbstractLineWrapPositionStrategyTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/AbstractLineWrapPositionStrategyTest.java new file mode 100644 index 000000000000..5946038158a4 --- /dev/null +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/AbstractLineWrapPositionStrategyTest.java @@ -0,0 +1,135 @@ +/* + * 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.openapi.editor; + +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; +import org.jmock.Expectations; +import org.jmock.Mockery; +import org.jmock.integration.junit4.JUnit4Mockery; +import org.jmock.lib.legacy.ClassImposteriser; + +import static org.junit.Assert.assertSame; + +public abstract class AbstractLineWrapPositionStrategyTest { + private static final String EDGE_MARKER = ""; + private static final String WRAP_MARKER = ""; + private Mockery myMockery; + private Project myProject; + + public void setUp() { + myMockery = new JUnit4Mockery() {{ + setImposteriser(ClassImposteriser.INSTANCE); + }}; + myProject = myMockery.mock(Project.class); + } + + protected void doTest(@NotNull LineWrapPositionStrategy strategy, final String document) { + doTest(strategy, document, true); + } + + protected void doTest(@NotNull LineWrapPositionStrategy strategy, final String document, boolean allowToBeyondMaxPreferredOffset) { + final Context context = new Context(document); + context.init(); + int actual = strategy.calculateWrapPosition( + createMockDocument(context.document), myProject, 0, context.document.length(), context.edgeIndex, + allowToBeyondMaxPreferredOffset, true + ); + assertSame(context.wrapIndex, actual); + } + + private Document createMockDocument(@NotNull final String text) { + final Document result = myMockery.mock(Document.class); + myMockery.checking(new Expectations() {{ + allowing(result).getCharsSequence(); will(returnValue(text)); + }}); + return result; + } + + /** + * Utility class for parsing and initialising test data. + *

+ * Note: this class is line-oriented, i.e. it assumes that target document doesn't contain line feeds. + */ + private static class Context { + + private final StringBuilder buffer = new StringBuilder(); + private final String rawDocument; + + private String document; + private int index; + private int wrapIndex = -1; + private int tmpWrapIndex; + private int edgeIndex; + private int tmpEdgeIndex; + + Context(String rawDocument) { + if (rawDocument.contains("\n")) { + throw new IllegalArgumentException( + String.format("Don't expect to test multi-line documents but the one is detected: '%s'", rawDocument) + ); + } + this.rawDocument = rawDocument; + } + + public void init() { + tmpWrapIndex = rawDocument.indexOf(WRAP_MARKER); + tmpEdgeIndex = rawDocument.indexOf(EDGE_MARKER); + if (tmpWrapIndex >= 0 && tmpEdgeIndex >= 0) { + if (tmpWrapIndex < tmpEdgeIndex) { + processWrap(); + processMaxPreferredIndex(); + } + else { + processMaxPreferredIndex(); + processWrap(); + } + } + else { + if (tmpWrapIndex >= 0) { + processWrap(); + } + if (tmpEdgeIndex >= 0) { + processMaxPreferredIndex(); + } + } + + buffer.append(rawDocument.substring(index)); + document = buffer.toString(); + if (edgeIndex <= 0) { + edgeIndex = document.length(); + } + } + + private void processWrap() { + buffer.append(rawDocument.substring(index, tmpWrapIndex)); + index = tmpWrapIndex + WRAP_MARKER.length(); + wrapIndex = buffer.length(); + if (rawDocument.indexOf(WRAP_MARKER, index) >= 0) { + throw new IllegalArgumentException(String.format("More than one wrap indicator is found at the document '%s'", rawDocument)); + } + } + + private void processMaxPreferredIndex() { + buffer.append(rawDocument.substring(index, tmpEdgeIndex)); + index = tmpEdgeIndex + EDGE_MARKER.length(); + edgeIndex = buffer.length(); + if (rawDocument.indexOf(EDGE_MARKER, index) >= 0) { + throw new IllegalArgumentException(String.format("More than one max preferred offset is found at the document '%s'", rawDocument)); + } + } + } +} diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/DefaultLineWrapPositionStrategyTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/DefaultLineWrapPositionStrategyTest.java index a4b8ddf29bab..f0e1cf354ef5 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/DefaultLineWrapPositionStrategyTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/DefaultLineWrapPositionStrategyTest.java @@ -15,161 +15,47 @@ */ package com.intellij.openapi.editor; -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; -import org.jmock.Expectations; -import org.jmock.Mockery; -import org.jmock.integration.junit4.JUnit4Mockery; -import org.jmock.lib.legacy.ClassImposteriser; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertSame; - /** * @author Denis Zhdanov * @since Aug 25, 2010 3:20:41 PM */ -public class DefaultLineWrapPositionStrategyTest { - - private static final String EDGE_MARKER = ""; - private static final String WRAP_MARKER = ""; - - private Mockery myMockery; - private DefaultLineWrapPositionStrategy myStrategy; - private Project myProject; +public class DefaultLineWrapPositionStrategyTest extends AbstractLineWrapPositionStrategyTest { + private LineWrapPositionStrategy myStrategy; @Before public void setUp() { + super.setUp(); myStrategy = new DefaultLineWrapPositionStrategy(); - - myMockery = new JUnit4Mockery() {{ - setImposteriser(ClassImposteriser.INSTANCE); - }}; - myProject = myMockery.mock(Project.class); } @Test public void commaNotSeparated() { String document = "void method(String p1, String p2) {}"; - doTest(document, false); + doTest(myStrategy, document, false); } @Test public void wrapOnExceedingWhiteSpace() { String document = "void method(String p1, String p2) {}"; - doTest(document); + doTest(myStrategy, document); } @Test public void preferWrapOnComma() { String document = "int variable = testMethod(var1 + var2, var3 + var4);"; - doTest(document); + doTest(myStrategy, document); } @Test public void longStringWithoutWrapPositionIsNotWrapped() { String document = "--------------------------------------------------------------------------"; - doTest(document); - } - - private void doTest(final String document) { - doTest(document, true); - } - - private void doTest(final String document, boolean allowToBeyondMaxPreferredOffset) { - final Context context = new Context(document); - context.init(); - int actual = myStrategy.calculateWrapPosition( - createMockDocument(context.document), myProject, 0, context.document.length(), context.edgeIndex, - allowToBeyondMaxPreferredOffset, true - ); - assertSame(context.wrapIndex, actual); - } - - private Document createMockDocument(@NotNull final String text) { - final Document result = myMockery.mock(Document.class); - myMockery.checking(new Expectations() {{ - allowing(result).getCharsSequence(); will(returnValue(text)); - }}); - return result; - } - - /** - * Utility class for parsing and initialising test data. - *

- * Note: this class is line-oriented, i.e. it assumes that target document doesn't contain line feeds. - */ - private static class Context { - - private final StringBuilder buffer = new StringBuilder(); - private final String rawDocument; - - private String document; - private int index; - private int wrapIndex = -1; - private int tmpWrapIndex; - private int edgeIndex; - private int tmpEdgeIndex; - - Context(String rawDocument) { - if (rawDocument.contains("\n")) { - throw new IllegalArgumentException( - String.format("Don't expect to test multi-line documents but the one is detected: '%s'", rawDocument) - ); - } - this.rawDocument = rawDocument; - } - - public void init() { - tmpWrapIndex = rawDocument.indexOf(WRAP_MARKER); - tmpEdgeIndex = rawDocument.indexOf(EDGE_MARKER); - if (tmpWrapIndex >= 0 && tmpEdgeIndex >= 0) { - if (tmpWrapIndex < tmpEdgeIndex) { - processWrap(); - processMaxPreferredIndex(); - } - else { - processMaxPreferredIndex(); - processWrap(); - } - } - else { - if (tmpWrapIndex >= 0) { - processWrap(); - } - if (tmpEdgeIndex >= 0) { - processMaxPreferredIndex(); - } - } - - buffer.append(rawDocument.substring(index)); - document = buffer.toString(); - if (edgeIndex <= 0) { - edgeIndex = document.length(); - } - } - - private void processWrap() { - buffer.append(rawDocument.substring(index, tmpWrapIndex)); - index = tmpWrapIndex + WRAP_MARKER.length(); - wrapIndex = buffer.length(); - if (rawDocument.indexOf(WRAP_MARKER, index) >= 0) { - throw new IllegalArgumentException(String.format("More than one wrap indicator is found at the document '%s'", rawDocument)); - } - } - - private void processMaxPreferredIndex() { - buffer.append(rawDocument.substring(index, tmpEdgeIndex)); - index = tmpEdgeIndex + EDGE_MARKER.length(); - edgeIndex = buffer.length(); - if (rawDocument.indexOf(EDGE_MARKER, index) >= 0) { - throw new IllegalArgumentException(String.format("More than one max preferred offset is found at the document '%s'", rawDocument)); - } - } + doTest(myStrategy, document); } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/TextLineWrapPositionStrategyTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/TextLineWrapPositionStrategyTest.java new file mode 100644 index 000000000000..7d43d7954ada --- /dev/null +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/TextLineWrapPositionStrategyTest.java @@ -0,0 +1,37 @@ +/* + * 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.openapi.editor; + +import org.junit.Before; +import org.junit.Test; + +public class TextLineWrapPositionStrategyTest extends AbstractLineWrapPositionStrategyTest { + private LineWrapPositionStrategy myStrategy; + + @Before + public void setUp() { + super.setUp(); + myStrategy = new TextLineWrapPositionStrategy(); + } + + @Test + public void preferNearestWhiteSpaceWrap_InsteadOf_Comma() { + String document = + "queueing the JSON for later submission, we retain the SimpleRequestData"; + doTest(myStrategy, document, false); + } + +} From 26ff86f7c82cb4b7018a12edf66eb3e53ce12c7b Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 24 Feb 2014 08:59:08 +0100 Subject: [PATCH 73/75] typo --- .../src/com/intellij/openapi/wm/IdeFocusManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java b/platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java index 7f9fbb337ddc..d8f7e86d4b9e 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java @@ -42,7 +42,7 @@ import java.awt.event.KeyEvent; * comp.requestFocus(); * * - * This class is also responsible for delivering key events while focus tranferring is in progress. + * This class is also responsible for delivering key events while focus transferring is in progress. *

* IdeFocusManager instance can be received per project or the global instance. The preferred way is * to use instance IdeFocusManager.getInstance(project). If no project instance is available, then From 917357987e1e3457dcbe093c9f3cb55a504f898a Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Mon, 24 Feb 2014 09:20:07 +0100 Subject: [PATCH 74/75] new DSM legend --- platform/platform-resources-en/src/misc/registry.properties | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index 15451cf444e4..ead490913d66 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -365,4 +365,7 @@ ide.open.file.in.temp.project.dir.description=Enables opening file in temp proje editor.allow.multiple.carets=false embed.scene.builder=false -typing.rbrace.reformats.block=true \ No newline at end of file +typing.rbrace.reformats.block=true + +dsm.retina.darcula.legend=false +dsm.retina.darcula.legend.description=Experimental DSM legend component From e26dc5ba1c2677db6e5ff81b5acec67012686514 Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Mon, 24 Feb 2014 13:25:00 +0400 Subject: [PATCH 75/75] IDEA-120157 Reformat code ignores keep dependent methods together order --- .../codeStyle/arrangement/JavaRearranger.java | 4 +- .../JavaRearrangerGrouperTest.groovy | 133 ++++++++++++++++++ 2 files changed, 136 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java index 7e3f95a692a2..369c5b2cc832 100644 --- a/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java +++ b/java/java-impl/src/com/intellij/psi/codeStyle/arrangement/JavaRearranger.java @@ -180,12 +180,14 @@ public class JavaRearranger implements Rearranger, private static void setupBreadthFirstDependency(@NotNull ArrangementEntryDependencyInfo info) { Deque toProcess = new ArrayDeque(); toProcess.add(info); + JavaElementArrangementEntry prev = info.getAnchorEntry(); while (!toProcess.isEmpty()) { ArrangementEntryDependencyInfo current = toProcess.removeFirst(); for (ArrangementEntryDependencyInfo dependencyInfo : current.getDependentEntriesInfos()) { JavaElementArrangementEntry dependencyMethod = dependencyInfo.getAnchorEntry(); if (dependencyMethod.getDependencies() == null) { - dependencyMethod.addDependency(current.getAnchorEntry()); + dependencyMethod.addDependency(prev); + prev = dependencyMethod; } toProcess.addLast(dependencyInfo); } diff --git a/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerGrouperTest.groovy b/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerGrouperTest.groovy index e094e866573e..6c8be11b9ece 100644 --- a/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerGrouperTest.groovy +++ b/java/java-tests/testSrc/com/intellij/psi/codeStyle/arrangement/JavaRearrangerGrouperTest.groovy @@ -236,4 +236,137 @@ class Test { } + void "test dependent methods DFS"() { + doTest( + initial: ''' +public class Q { + + void E() { + ER(); + } + + void B() { + E(); + F(); + } + + void A() { + B(); + C(); + } + + void F() { + } + + void C() { + G(); + } + + void ER() { + } + + void G() { + } + +} +''', + expected: ''' +public class Q { + + void A() { + B(); + C(); + } + void B() { + E(); + F(); + } + void E() { + ER(); + } + void ER() { + } + void F() { + } + void C() { + G(); + } + void G() { + } + +} +''', + groups: [group(DEPENDENT_METHODS, DEPTH_FIRST)] + ) + } + + + void "test dependent methods BFS"() { + doTest( + initial: ''' +public class Q { + + void E() { + ER(); + } + + void B() { + E(); + F(); + } + + void A() { + B(); + C(); + } + + void F() { + } + + void C() { + G(); + } + + void ER() { + } + + void G() { + } + +} +''', + expected: ''' +public class Q { + + void A() { + B(); + C(); + } + void B() { + E(); + F(); + } + void C() { + G(); + } + void E() { + ER(); + } + void F() { + } + void G() { + } + void ER() { + } + +} +''', + groups: [group(DEPENDENT_METHODS, BREADTH_FIRST)] + ) + } + + + + + }