summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Weinstein2013-03-08 17:59:05 (EST)
committerSergey Prigogin2013-03-11 15:44:53 (EDT)
commit88411d63e5e806a5dad0723877e537e9ef2cad47 (patch)
treec07017163f4d3530e66553ef2a84e2ef0a9ca6aa
parent0d2decffcfbbe453c6c58fb2f9cb5c0be0082589 (diff)
downloadorg.eclipse.cdt-88411d63e5e806a5dad0723877e537e9ef2cad47.zip
org.eclipse.cdt-88411d63e5e806a5dad0723877e537e9ef2cad47.tar.gz
org.eclipse.cdt-88411d63e5e806a5dad0723877e537e9ef2cad47.tar.bz2
Bug 393883 - Implement Method loses throw()refs/changes/13/11013/4
Change-Id: Ic14046dd3a97f209a56704a22f7d3f2e417a69c9 Reviewed-on: https://git.eclipse.org/r/11013 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rwxr-xr-x[-rw-r--r--]core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java33
-rwxr-xr-x[-rw-r--r--]core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java9
2 files changed, 41 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java
index 9071317..9233b17 100644..100755
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java
@@ -788,4 +788,37 @@ public class ImplementMethodRefactoringTest extends RefactoringTestBase {
public void testExplicitConstructor_Bug363111() throws Exception {
assertRefactoringSuccess();
}
+
+ //A.h
+ //
+ //class TestClass {
+ //public:
+ // /*$*/void foo() throw ();/*$$*/
+ //};
+ //
+
+ //A.cpp
+ //====================
+ //void TestClass::foo() throw () {
+ //}
+ public void testEmptyThowsClause_Bug393833() throws Exception {
+ assertRefactoringSuccess();
+ }
+
+ //A.h
+ //
+ //class TestClass {
+ //public:
+ // /*$*/void foo() throw (TestClass);/*$$*/
+ //};
+ //
+
+ //A.cpp
+ //====================
+ //void TestClass::foo() throw (TestClass) {
+ //}
+ public void testNonEmptyThowsClause_Bug393833() throws Exception {
+ assertRefactoringSuccess();
+ }
+
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java
index 0fef24d..5385fd8 100644..100755
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java
@@ -38,6 +38,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
@@ -266,7 +267,13 @@ public class ImplementMethodRefactoring extends CRefactoring {
for (IASTPointerOperator pop : functionDeclarator.getPointerOperators()) {
createdMethodDeclarator.addPointerOperator(pop.copy(CopyStyle.withLocations));
}
-
+ IASTTypeId[] exceptionSpecification = functionDeclarator.getExceptionSpecification();
+ if (exceptionSpecification != ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION) {
+ createdMethodDeclarator.setEmptyExceptionSpecification();
+ for (IASTTypeId typeId : exceptionSpecification) {
+ createdMethodDeclarator.addExceptionSpecificationTypeId(typeId == null ? null : typeId.copy(CopyStyle.withLocations));
+ }
+ }
IASTFunctionDefinition functionDefinition = nodeFactory.newFunctionDefinition(declSpecifier, createdMethodDeclarator, nodeFactory.newCompoundStatement());
functionDefinition.setParent(unit);