From a8433e7887d8b9aa06d2118a1c84a8aafb0104c1 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 18 Jan 2009 22:55:32 +0000 Subject: [PATCH] Cosmetics. --- .../core/dom/parser/c/CArrayType.java | 71 ++++++++++--------- .../core/dom/parser/cpp/CPPArrayType.java | 54 +++++++------- 2 files changed, 68 insertions(+), 57 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java index b83c4dbce54..1a1781e5239 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.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.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); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java index 1795e8c5c42..fe4fa1241f2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java @@ -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); + } }