mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Cosmetics.
This commit is contained in:
parent
ec30f112e9
commit
a8433e7887
2 changed files with 68 additions and 57 deletions
|
@ -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.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||
|
@ -24,34 +25,33 @@ import org.eclipse.cdt.internal.core.index.IIndexType;
|
|||
* @author dsteffle
|
||||
*/
|
||||
public class CArrayType implements ICArrayType, ITypeContainer {
|
||||
|
||||
IType type = null;
|
||||
ICASTArrayModifier mod = null;
|
||||
IType type;
|
||||
ICASTArrayModifier mod;
|
||||
|
||||
public CArrayType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean isSameType(IType obj) {
|
||||
if( obj == this )
|
||||
if (obj == this)
|
||||
return true;
|
||||
if( obj instanceof ITypedef )
|
||||
return obj.isSameType( this );
|
||||
if( obj instanceof ICArrayType ){
|
||||
if (obj instanceof ITypedef)
|
||||
return obj.isSameType(this);
|
||||
if (obj instanceof ICArrayType) {
|
||||
ICArrayType at = (ICArrayType) obj;
|
||||
try {
|
||||
if( isConst() != at.isConst() ) return false;
|
||||
if( isRestrict() != at.isRestrict() ) return false;
|
||||
if( isStatic() != at.isStatic() ) return false;
|
||||
if( isVolatile() != at.isVolatile() ) return false;
|
||||
if( isVariableLength() != at.isVariableLength() ) return false;
|
||||
if (isConst() != at.isConst()) return false;
|
||||
if (isRestrict() != at.isRestrict()) return false;
|
||||
if (isStatic() != at.isStatic()) return false;
|
||||
if (isVolatile() != at.isVolatile()) return false;
|
||||
if (isVariableLength() != at.isVariableLength()) return false;
|
||||
|
||||
return at.getType().isSameType( type );
|
||||
} catch ( DOMException e ) {
|
||||
return at.getType().isSameType(type);
|
||||
} catch (DOMException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// work around for bug 182976, no PDOMCArrayType.
|
||||
// Workaround for bug 182976, no PDOMCArrayType.
|
||||
else if (obj instanceof IArrayType && obj instanceof IIndexType) {
|
||||
return obj.isSameType(this);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class CArrayType implements ICArrayType, ITypeContainer {
|
|||
return type;
|
||||
}
|
||||
|
||||
public void setType( IType t ){
|
||||
public void setType(IType t) {
|
||||
this.type = t;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class CArrayType implements ICArrayType, ITypeContainer {
|
|||
* @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isConst()
|
||||
*/
|
||||
public boolean isConst() {
|
||||
if (mod==null) return false;
|
||||
if (mod == null) return false;
|
||||
return mod.isConst();
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class CArrayType implements ICArrayType, ITypeContainer {
|
|||
* @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isRestrict()
|
||||
*/
|
||||
public boolean isRestrict() {
|
||||
if (mod==null) return false;
|
||||
if (mod == null) return false;
|
||||
return mod.isRestrict();
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class CArrayType implements ICArrayType, ITypeContainer {
|
|||
* @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isVolatile()
|
||||
*/
|
||||
public boolean isVolatile() {
|
||||
if (mod==null) return false;
|
||||
if (mod == null) return false;
|
||||
return mod.isVolatile();
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class CArrayType implements ICArrayType, ITypeContainer {
|
|||
* @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isStatic()
|
||||
*/
|
||||
public boolean isStatic() {
|
||||
if (mod==null) return false;
|
||||
if (mod == null) return false;
|
||||
return mod.isStatic();
|
||||
}
|
||||
|
||||
|
@ -109,21 +109,10 @@ public class CArrayType implements ICArrayType, ITypeContainer {
|
|||
* @see org.eclipse.cdt.core.dom.ast.c.ICArrayType#isVariableLength()
|
||||
*/
|
||||
public boolean isVariableLength() {
|
||||
if( mod == null ) return false;
|
||||
if (mod == null) return false;
|
||||
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() {
|
||||
return mod;
|
||||
}
|
||||
|
@ -132,8 +121,24 @@ public class CArrayType implements ICArrayType, ITypeContainer {
|
|||
* @see org.eclipse.cdt.core.dom.ast.IArrayType#getArraySizeExpression()
|
||||
*/
|
||||
public IASTExpression getArraySizeExpression() {
|
||||
if( mod != null )
|
||||
if (mod != null)
|
||||
return mod.getConstantExpression();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
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.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||
|
@ -25,59 +26,64 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class CPPArrayType implements IArrayType, ITypeContainer {
|
||||
private IType type = null;
|
||||
private IASTExpression sizeExpression = null;
|
||||
private IType type;
|
||||
private IASTExpression sizeExpression;
|
||||
|
||||
public CPPArrayType( IType type ){
|
||||
public CPPArrayType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public CPPArrayType( IType type, IASTExpression sizeExp ){
|
||||
public CPPArrayType(IType type, IASTExpression sizeExp) {
|
||||
this.type = type;
|
||||
this.sizeExpression = sizeExp;
|
||||
}
|
||||
|
||||
public IType getType(){
|
||||
public IType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType( IType t ){
|
||||
public void setType(IType t) {
|
||||
this.type = t;
|
||||
}
|
||||
|
||||
public boolean isSameType(IType obj) {
|
||||
if( obj == this )
|
||||
if (obj == this)
|
||||
return true;
|
||||
if( obj instanceof ITypedef )
|
||||
return ((ITypedef)obj).isSameType( this );
|
||||
if (obj instanceof ITypedef)
|
||||
return ((ITypedef) obj).isSameType(this);
|
||||
|
||||
if( obj instanceof IArrayType ){
|
||||
if (obj instanceof IArrayType) {
|
||||
try {
|
||||
IType objType = ((IArrayType)obj).getType();
|
||||
IType objType = ((IArrayType) obj).getType();
|
||||
if (objType != null)
|
||||
return objType.isSameType( type );
|
||||
} catch ( DOMException e ) {
|
||||
return objType.isSameType(type);
|
||||
} catch (DOMException e) {
|
||||
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)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IArrayType#getArraySizeExpression()
|
||||
*/
|
||||
public IASTExpression getArraySizeExpression() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue