mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 393883 - Implement Method loses throw()
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>
This commit is contained in:
parent
0d2decffcf
commit
88411d63e5
2 changed files with 41 additions and 1 deletions
33
core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java
Normal file → Executable file
33
core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java
Normal file → Executable file
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
9
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java
Normal file → Executable file
9
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java
Normal file → Executable file
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue