Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/ExceptionTest.java')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/ExceptionTest.java74
1 files changed, 74 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/ExceptionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/ExceptionTest.java
new file mode 100644
index 00000000000..f82e7e024c7
--- /dev/null
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/ExceptionTest.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.append;
+
+import junit.framework.Test;
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
+import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
+import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
+import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
+import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
+
+public class ExceptionTest extends ChangeGeneratorTest {
+
+ public ExceptionTest(){
+ super("Append Exception Declaration"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ source = "void foo(int parameter){\n}\n\n"; //$NON-NLS-1$
+ expectedSource = "void foo(int parameter) throw (int){\n}\n\n"; //$NON-NLS-1$
+ super.setUp();
+ }
+
+ @Override
+ protected CPPASTVisitor createModificator(
+ final ASTModificationStore modStore) {
+ return new CPPASTVisitor() {
+ {
+ shouldVisitDeclarators = true;
+ }
+
+ @Override
+ public int visit(IASTDeclarator declarator) {
+ if (declarator instanceof CPPASTFunctionDeclarator) {
+ IASTTypeId exception = new CPPASTTypeId();
+ CPPASTDeclarator exceptionDeclarator = new CPPASTDeclarator();
+ exceptionDeclarator.setName(new CPPASTName());
+ CPPASTSimpleDeclSpecifier exDeclSpec = new CPPASTSimpleDeclSpecifier();
+ exDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
+ exception.setDeclSpecifier(exDeclSpec);
+ exception.setAbstractDeclarator(exceptionDeclarator);
+ ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD, declarator, exception, null);
+ modStore.storeModification(null, modification);
+
+ }
+ return PROCESS_CONTINUE;
+ }
+ };
+ }
+
+ public static Test suite() {
+ return new ExceptionTest();
+
+ }
+}

Back to the top