diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompoundStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompoundStatement.java index acbffeb83be..b038547e0e6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompoundStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompoundStatement.java @@ -25,70 +25,66 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; * @author jcamelon */ public class CASTCompoundStatement extends ASTNode implements IASTCompoundStatement, IASTAmbiguityParent { - private IASTStatement [] statements = null; private IScope scope = null; - public CASTCompoundStatement copy() { CASTCompoundStatement copy = new CASTCompoundStatement(); - for(IASTStatement statement : getStatements()) + for (IASTStatement statement : getStatements()) copy.addStatement(statement == null ? null : statement.copy()); copy.setOffsetAndLength(this); return copy; } public IASTStatement[] getStatements() { - if( statements == null ) return IASTStatement.EMPTY_STATEMENT_ARRAY; - return (IASTStatement[]) ArrayUtil.trim( IASTStatement.class, statements ); + if (statements == null) return IASTStatement.EMPTY_STATEMENT_ARRAY; + return (IASTStatement[]) ArrayUtil.trim(IASTStatement.class, statements); } public void addStatement(IASTStatement statement) { assertNotFrozen(); - statements = (IASTStatement[]) ArrayUtil.append( IASTStatement.class, statements, statement ); - if(statement != null) { + statements = (IASTStatement[]) ArrayUtil.append(IASTStatement.class, statements, statement); + if (statement != null) { statement.setParent(this); statement.setPropertyInParent(NESTED_STATEMENT); } } public IScope getScope() { - if( scope == null ) + if (scope == null) scope = new CScope(this, EScopeKind.eLocal); return scope; } @Override - public boolean accept( ASTVisitor action ){ - if( action.shouldVisitStatements ){ - switch( action.visit( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + public boolean accept(ASTVisitor action){ + if (action.shouldVisitStatements){ + switch (action.visit(this)){ + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } IASTStatement [] s = getStatements(); - for ( int i = 0; i < s.length; i++ ) { - if( !s[i].accept( action ) ) return false; + for (int i = 0; i < s.length; i++) { + if (!s[i].accept(action)) return false; } - if( action.shouldVisitStatements ){ - switch( action.leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; + if (action.shouldVisitStatements){ + switch (action.leave(this)){ + case ASTVisitor.PROCESS_ABORT: return false; + case ASTVisitor.PROCESS_SKIP: return true; + default: break; } } return true; } public void replace(IASTNode child, IASTNode other) { - if( statements == null ) return; - for( int i = 0; i < statements.length; ++i ) - { - if( statements[i] == child ) - { - other.setParent( statements[i].getParent() ); - other.setPropertyInParent( statements[i].getPropertyInParent() ); + if (statements == null) return; + for (int i = 0; i < statements.length; ++i) { + if (statements[i] == child) { + other.setParent(statements[i].getParent()); + other.setPropertyInParent(statements[i].getPropertyInParent()); statements[i] = (IASTStatement) other; break; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java index fa8247e0ca0..757408d759d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; +import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.c.ICPointerType; @@ -19,9 +20,9 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.core.runtime.CoreException; public class CPointerType implements ICPointerType, ITypeContainer, ISerializableType { - static public final int IS_CONST = 1; - static public final int IS_RESTRICT = 1 << 1; - static public final int IS_VOLATILE = 1 << 2; + static public final int IS_CONST = 1; + static public final int IS_RESTRICT = 1 << 1; + static public final int IS_VOLATILE = 1 << 2; IType nextType = null; private int qualifiers = 0; @@ -33,19 +34,19 @@ public class CPointerType implements ICPointerType, ITypeContainer, ISerializabl this.qualifiers = qualifiers; } - public boolean isSameType( IType obj ){ - if( obj == this ) + public boolean isSameType(IType obj) { + if (obj == this) return true; - if( obj instanceof ITypedef ) - return obj.isSameType( this ); - - if( obj instanceof ICPointerType ){ + if (obj instanceof ITypedef) + return obj.isSameType(this); + + if (obj instanceof ICPointerType) { ICPointerType pt = (ICPointerType) obj; - if( isConst() != pt.isConst() ) return false; - if( isRestrict() != pt.isRestrict() ) return false; - if( isVolatile() != pt.isVolatile() ) return false; + if (isConst() != pt.isConst()) return false; + if (isRestrict() != pt.isRestrict()) return false; + if (isVolatile() != pt.isVolatile()) return false; - return pt.getType().isSameType( nextType ); + return pt.getType().isSameType(nextType); } return false; } @@ -83,12 +84,12 @@ public class CPointerType implements ICPointerType, ITypeContainer, ISerializabl } @Override - public Object clone(){ + public Object clone() { IType t = null; try { t = (IType) super.clone(); - } catch ( CloneNotSupportedException e ) { - //not going to happen + } catch (CloneNotSupportedException e) { + // Not going to happen. } return t; } @@ -110,4 +111,9 @@ public class CPointerType implements ICPointerType, ITypeContainer, ISerializabl IType nested= buffer.unmarshalType(); return new CPointerType(nested, firstByte/ITypeMarshalBuffer.FLAG1); } + + @Override + public String toString() { + return ASTTypeUtil.getType(this); + } }