1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 17:25:38 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2009-01-18 22:55:32 +00:00
parent ec30f112e9
commit a8433e7887
2 changed files with 68 additions and 57 deletions

View file

@ -10,6 +10,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c; package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IArrayType;
@ -24,34 +25,33 @@ import org.eclipse.cdt.internal.core.index.IIndexType;
* @author dsteffle * @author dsteffle
*/ */
public class CArrayType implements ICArrayType, ITypeContainer { public class CArrayType implements ICArrayType, ITypeContainer {
IType type;
IType type = null; ICASTArrayModifier mod;
ICASTArrayModifier mod = null;
public CArrayType(IType type) { public CArrayType(IType type) {
this.type = type; this.type = type;
} }
public boolean isSameType(IType obj) { public boolean isSameType(IType obj) {
if( obj == this ) if (obj == this)
return true; return true;
if( obj instanceof ITypedef ) if (obj instanceof ITypedef)
return obj.isSameType( this ); return obj.isSameType(this);
if( obj instanceof ICArrayType ){ if (obj instanceof ICArrayType) {
ICArrayType at = (ICArrayType) obj; ICArrayType at = (ICArrayType) obj;
try { try {
if( isConst() != at.isConst() ) return false; if (isConst() != at.isConst()) return false;
if( isRestrict() != at.isRestrict() ) return false; if (isRestrict() != at.isRestrict()) return false;
if( isStatic() != at.isStatic() ) return false; if (isStatic() != at.isStatic()) return false;
if( isVolatile() != at.isVolatile() ) return false; if (isVolatile() != at.isVolatile()) return false;
if( isVariableLength() != at.isVariableLength() ) return false; if (isVariableLength() != at.isVariableLength()) return false;
return at.getType().isSameType( type ); return at.getType().isSameType(type);
} catch ( DOMException e ) { } catch (DOMException e) {
return false; return false;
} }
} }
// work around for bug 182976, no PDOMCArrayType. // Workaround for bug 182976, no PDOMCArrayType.
else if (obj instanceof IArrayType && obj instanceof IIndexType) { else if (obj instanceof IArrayType && obj instanceof IIndexType) {
return obj.isSameType(this); return obj.isSameType(this);
} }
@ -65,7 +65,7 @@ public class CArrayType implements ICArrayType, ITypeContainer {
return type; return type;
} }
public void setType( IType t ){ public void setType(IType t) {
this.type = t; this.type = t;
} }
@ -77,7 +77,7 @@ public class CArrayType implements ICArrayType, ITypeContainer {
* @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isConst() * @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isConst()
*/ */
public boolean isConst() { public boolean isConst() {
if (mod==null) return false; if (mod == null) return false;
return mod.isConst(); return mod.isConst();
} }
@ -85,7 +85,7 @@ public class CArrayType implements ICArrayType, ITypeContainer {
* @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isRestrict() * @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isRestrict()
*/ */
public boolean isRestrict() { public boolean isRestrict() {
if (mod==null) return false; if (mod == null) return false;
return mod.isRestrict(); return mod.isRestrict();
} }
@ -93,7 +93,7 @@ public class CArrayType implements ICArrayType, ITypeContainer {
* @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isVolatile() * @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isVolatile()
*/ */
public boolean isVolatile() { public boolean isVolatile() {
if (mod==null) return false; if (mod == null) return false;
return mod.isVolatile(); return mod.isVolatile();
} }
@ -101,7 +101,7 @@ public class CArrayType implements ICArrayType, ITypeContainer {
* @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isStatic() * @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isStatic()
*/ */
public boolean isStatic() { public boolean isStatic() {
if (mod==null) return false; if (mod == null) return false;
return mod.isStatic(); return mod.isStatic();
} }
@ -109,21 +109,10 @@ public class CArrayType implements ICArrayType, ITypeContainer {
* @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isVariableLength() * @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isVariableLength()
*/ */
public boolean isVariableLength() { public boolean isVariableLength() {
if( mod == null ) return false; if (mod == null) return false;
return mod.isVariableSized(); return mod.isVariableSized();
} }
@Override
public Object clone(){
IType t = null;
try {
t = (IType) super.clone();
} catch ( CloneNotSupportedException e ) {
//not going to happen
}
return t;
}
public ICASTArrayModifier getModifier() { public ICASTArrayModifier getModifier() {
return mod; return mod;
} }
@ -132,8 +121,24 @@ public class CArrayType implements ICArrayType, ITypeContainer {
* @see org.eclipse.cdt.core.dom.ast.IArrayType#getArraySizeExpression() * @see org.eclipse.cdt.core.dom.ast.IArrayType#getArraySizeExpression()
*/ */
public IASTExpression getArraySizeExpression() { public IASTExpression getArraySizeExpression() {
if( mod != null ) if (mod != null)
return mod.getConstantExpression(); return mod.getConstantExpression();
return null; return null;
} }
@Override
public Object clone() {
IType t = null;
try {
t = (IType) super.clone();
} catch (CloneNotSupportedException e) {
// Not going to happen
}
return t;
}
@Override
public String toString() {
return ASTTypeUtil.getType(this);
}
} }

View file

@ -14,6 +14,7 @@
*/ */
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IArrayType;
@ -25,59 +26,64 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
* @author aniefer * @author aniefer
*/ */
public class CPPArrayType implements IArrayType, ITypeContainer { public class CPPArrayType implements IArrayType, ITypeContainer {
private IType type = null; private IType type;
private IASTExpression sizeExpression = null; private IASTExpression sizeExpression;
public CPPArrayType( IType type ){ public CPPArrayType(IType type) {
this.type = type; this.type = type;
} }
public CPPArrayType( IType type, IASTExpression sizeExp ){ public CPPArrayType(IType type, IASTExpression sizeExp) {
this.type = type; this.type = type;
this.sizeExpression = sizeExp; this.sizeExpression = sizeExp;
} }
public IType getType(){ public IType getType() {
return type; return type;
} }
public void setType( IType t ){ public void setType(IType t) {
this.type = t; this.type = t;
} }
public boolean isSameType(IType obj) { public boolean isSameType(IType obj) {
if( obj == this ) if (obj == this)
return true; return true;
if( obj instanceof ITypedef ) if (obj instanceof ITypedef)
return ((ITypedef)obj).isSameType( this ); return ((ITypedef) obj).isSameType(this);
if( obj instanceof IArrayType ){ if (obj instanceof IArrayType) {
try { try {
IType objType = ((IArrayType)obj).getType(); IType objType = ((IArrayType) obj).getType();
if (objType != null) if (objType != null)
return objType.isSameType( type ); return objType.isSameType(type);
} catch ( DOMException e ) { } catch (DOMException e) {
return false; return false;
} }
} }
return false; return false;
} }
@Override
public Object clone(){
IType t = null;
try {
t = (IType) super.clone();
} catch ( CloneNotSupportedException e ) {
//not going to happen
}
return t;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IArrayType#getArraySizeExpression() * @see org.eclipse.cdt.core.dom.ast.IArrayType#getArraySizeExpression()
*/ */
public IASTExpression getArraySizeExpression() { public IASTExpression getArraySizeExpression() {
return sizeExpression; return sizeExpression;
} }
@Override
public Object clone() {
IType t = null;
try {
t = (IType) super.clone();
} catch (CloneNotSupportedException e) {
// Not going to happen
}
return t;
}
@Override
public String toString() {
return ASTTypeUtil.getType(this);
}
} }