diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/UpdateInfoTree.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/UpdateInfoTree.java index 995af2527ae7..d24ddab1ccd8 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/UpdateInfoTree.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/UpdateInfoTree.java @@ -229,6 +229,9 @@ public class UpdateInfoTree extends PanelWithActionsAndCloseButton implements Di private void updateTreeModel() { myRoot.rebuild(VcsConfiguration.getInstance(myProject).UPDATE_GROUP_BY_PACKAGES, getScopeFilter(), myShowOnlyFilteredItems); + if (myTreeModel != null) { + myTreeModel.reload(); + } } public Object getData(String dataId) { diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/ThrowsRuntimeExceptionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/ThrowsRuntimeExceptionInspection.java index 46794e51ee75..e09265b74513 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/ThrowsRuntimeExceptionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/ThrowsRuntimeExceptionInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2012 Bas Leijdekkers + * Copyright 2011-2013 Bas Leijdekkers * * 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,8 @@ package com.siyeh.ig.errorhandling; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.lang.LanguageDocumentation; import com.intellij.lang.documentation.CodeDocumentationProvider; +import com.intellij.lang.documentation.CompositeDocumentationProvider; +import com.intellij.lang.documentation.DocumentationProvider; import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.psi.javadoc.PsiDocComment; @@ -91,9 +93,20 @@ public class ThrowsRuntimeExceptionInspection extends BaseInspection { else { final PsiDocComment docComment = factory.createDocCommentFromText("/** */"); final PsiComment resultComment = (PsiComment)method.addBefore(docComment, method.getModifierList()); - final CodeDocumentationProvider documentationProvider = - (CodeDocumentationProvider)LanguageDocumentation.INSTANCE.forLanguage(method.getLanguage()); - final String commentStub = documentationProvider.generateDocumentationContentStub(resultComment); + final DocumentationProvider documentationProvider = LanguageDocumentation.INSTANCE.forLanguage(method.getLanguage()); + final CodeDocumentationProvider codeDocumentationProvider; + if (documentationProvider instanceof CodeDocumentationProvider) { + codeDocumentationProvider = (CodeDocumentationProvider)documentationProvider; + } else if (documentationProvider instanceof CompositeDocumentationProvider) { + final CompositeDocumentationProvider compositeDocumentationProvider = (CompositeDocumentationProvider)documentationProvider; + codeDocumentationProvider = compositeDocumentationProvider.getFirstCodeDocumentationProvider(); + if (codeDocumentationProvider == null) { + return; + } + } else { + return; + } + final String commentStub = codeDocumentationProvider.generateDocumentationContentStub(resultComment); final PsiDocComment newComment = factory.createDocCommentFromText("/**\n" + commentStub + "*/"); resultComment.replace(newComment); } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/MoveThrows.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/MoveThrows.after.java new file mode 100644 index 000000000000..2a8a561991d8 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/MoveThrows.after.java @@ -0,0 +1,6 @@ +class C { + /** + * @throws RuntimeException + */ + void foo() {} +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/MoveThrowsExistingComment.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/MoveThrowsExistingComment.after.java new file mode 100644 index 000000000000..3727d489d70f --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/MoveThrowsExistingComment.after.java @@ -0,0 +1,8 @@ +class C { + + /** + * bla bla bla + * @throws RuntimeException + */ + void foo() {} +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/MoveThrowsExistingComment.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/MoveThrowsExistingComment.java new file mode 100644 index 000000000000..e1a66f77fcee --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/MoveThrowsExistingComment.java @@ -0,0 +1,7 @@ +class C { + + /** + * bla bla bla + */ + void foo() throws RuntimeException {} +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/RemoveThrows.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/RemoveThrows.after.java new file mode 100644 index 000000000000..a9706e21c8db --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/RemoveThrows.after.java @@ -0,0 +1,3 @@ +class C { + void foo() throws Exception {} +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/RemoveThrows.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/RemoveThrows.java new file mode 100644 index 000000000000..4d59f12ab08d --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/RemoveThrows.java @@ -0,0 +1,3 @@ +class C { + void foo() throws RuntimeException, Exception {} +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/moveThrows.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/moveThrows.java new file mode 100644 index 000000000000..ea95fddcf155 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/throws_runtime_exception/moveThrows.java @@ -0,0 +1,3 @@ +class C { + void foo() throws RuntimeException {} +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/errorhandling/ThrowsRuntimeExceptionInspectionFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/errorhandling/ThrowsRuntimeExceptionInspectionFixTest.java new file mode 100644 index 000000000000..500d8244adad --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/errorhandling/ThrowsRuntimeExceptionInspectionFixTest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2012 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.errorhandling; + +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.IGQuickFixesTestCase; +import com.siyeh.ig.errorhandling.CaughtExceptionImmediatelyRethrownInspection; +import com.siyeh.ig.errorhandling.EmptyFinallyBlockInspection; +import com.siyeh.ig.errorhandling.ThrowsRuntimeExceptionInspection; + +public class ThrowsRuntimeExceptionInspectionFixTest extends IGQuickFixesTestCase { + @Override + protected void setUp() throws Exception { + super.setUp(); + myFixture.enableInspections(new ThrowsRuntimeExceptionInspection()); + } + + @Override + protected String getRelativePath() { + return "errorhandling/throws_runtime_exception"; + } + + public void testMoveThrows() { + doTest(InspectionGadgetsBundle.message("throws.runtime.exception.move.quickfix", "RuntimeException")); + } + + public void testMoveThrowsExistingComment() { + doTest(InspectionGadgetsBundle.message("throws.runtime.exception.move.quickfix", "RuntimeException")); + } + + public void testRemoveThrows() { + doTest(InspectionGadgetsBundle.message("throws.runtime.exception.quickfix", "RuntimeException")); + } +} diff --git a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/tools/DragTracker.java b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/tools/DragTracker.java index d8c37dc5d9f8..b506ff73f957 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/tools/DragTracker.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/tools/DragTracker.java @@ -93,12 +93,7 @@ public class DragTracker extends SelectionTracker { @Override protected void updateContext(RadComponent target) { - if (myContext.getComponents().get(0).getParent() == target) { - myContext.setType(OperationContext.MOVE); - } - else { - myContext.setType(OperationContext.ADD); - } + updateContextType(target); } }; RadComponent target = myArea.findTarget(myCurrentScreenX, myCurrentScreenY, filter); @@ -112,6 +107,15 @@ public class DragTracker extends SelectionTracker { } } + protected void updateContextType(RadComponent target) { + if (myContext.getComponents().get(0).getParent() == target) { + myContext.setType(OperationContext.MOVE); + } + else { + myContext.setType(OperationContext.ADD); + } + } + @Override protected void updateContext() { super.updateContext();