1
/*******************************************************************************
2
* Copyright (c) 2004, 2008 IBM Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* IBM - Initial API and implementation
10
* Markus Schorn (Wind River Systems)
11
*******************************************************************************/
12
package org.eclipse.cdt.internal.core.dom.parser.cpp;
14
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
15
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
16
import org.eclipse.cdt.core.dom.ast.IASTNode;
17
import org.eclipse.cdt.core.dom.ast.IASTStatement;
18
import org.eclipse.cdt.core.dom.ast.IScope;
19
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
20
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
21
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
26
public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler, IASTAmbiguityParent {
28
private boolean isCatchAll;
29
private IASTStatement body;
30
private IASTDeclaration declaration;
33
public CPPASTCatchHandler() {
36
public CPPASTCatchHandler(IASTDeclaration declaration, IASTStatement body) {
38
setDeclaration(declaration);
41
public CPPASTCatchHandler copy() {
42
CPPASTCatchHandler copy = new CPPASTCatchHandler();
43
copy.setDeclaration(declaration == null ? null : declaration.copy());
44
copy.setCatchBody(body == null ? null : body.copy());
45
copy.setIsCatchAll(isCatchAll);
46
copy.setOffsetAndLength(this);
50
public void setIsCatchAll(boolean isEllipsis) {
52
isCatchAll = isEllipsis;
55
public boolean isCatchAll() {
59
public void setCatchBody(IASTStatement compoundStatement) {
61
body = compoundStatement;
62
if (compoundStatement != null) {
63
compoundStatement.setParent(this);
64
compoundStatement.setPropertyInParent(CATCH_BODY);
68
public IASTStatement getCatchBody() {
72
public void setDeclaration(IASTDeclaration decl) {
77
decl.setPropertyInParent(DECLARATION);
81
public IASTDeclaration getDeclaration() {
86
public boolean accept( ASTVisitor action ){
87
if( action.shouldVisitStatements ){
88
switch( action.visit( this ) ){
89
case ASTVisitor.PROCESS_ABORT : return false;
90
case ASTVisitor.PROCESS_SKIP : return true;
94
if( declaration != null ) if( !declaration.accept( action ) ) return false;
95
if( body != null ) if( !body.accept( action ) ) return false;
97
if( action.shouldVisitStatements ){
98
switch( action.leave( this ) ){
99
case ASTVisitor.PROCESS_ABORT : return false;
100
case ASTVisitor.PROCESS_SKIP : return true;
107
public void replace(IASTNode child, IASTNode other) {
110
other.setPropertyInParent( child.getPropertyInParent() );
111
other.setParent( child.getParent() );
112
body = (IASTStatement) other;
114
if( declaration == child )
116
other.setParent( child.getParent() );
117
other.setPropertyInParent( child.getPropertyInParent() );
118
declaration = (IASTDeclaration) other;
123
public IScope getScope() {
125
scope = new CPPBlockScope(this);