1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2010-05-17 06:30:21 +00:00
parent ee53c2d94d
commit da79fc4ed3
2 changed files with 46 additions and 44 deletions

View file

@ -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;
}

View file

@ -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);
}
}