mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
toString method.
This commit is contained in:
parent
e34b9fc378
commit
648ade1628
7 changed files with 71 additions and 22 deletions
|
@ -18,19 +18,19 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* internal interface representing types that contain other types
|
||||
* Internal interface representing types that contain other types
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ITypeContainer extends IType{
|
||||
public interface ITypeContainer extends IType {
|
||||
/**
|
||||
* get the type this contains
|
||||
* @throws DOMException
|
||||
*/
|
||||
IType getType() throws DOMException;
|
||||
|
||||
|
||||
/**
|
||||
* set the type this contains
|
||||
* @param type
|
||||
*/
|
||||
void setType( IType type );
|
||||
void setType(IType type);
|
||||
}
|
||||
|
|
|
@ -22,43 +22,53 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
|||
*/
|
||||
public class ArrayTypeClone implements IIndexType, IArrayType, ITypeContainer {
|
||||
private final IArrayType delegate;
|
||||
private IType type = null;
|
||||
private IType type;
|
||||
|
||||
public ArrayTypeClone(IArrayType array) {
|
||||
this.delegate = array;
|
||||
}
|
||||
public boolean isSameType(IType type) {
|
||||
if( type instanceof ITypedef )
|
||||
return ((ITypedef)type).isSameType( this );
|
||||
|
||||
if( !( type instanceof IArrayType ))
|
||||
public boolean isSameType(IType type) {
|
||||
if (type instanceof ITypedef)
|
||||
return ((ITypedef) type).isSameType(this);
|
||||
|
||||
if (!(type instanceof IArrayType))
|
||||
return false;
|
||||
|
||||
try {
|
||||
IType type1= this.getType();
|
||||
if( type1 == null )
|
||||
if (type1 == null)
|
||||
return false;
|
||||
|
||||
IArrayType rhs = (IArrayType) type;
|
||||
return type1.isSameType( rhs.getType() );
|
||||
return type1.isSameType(rhs.getType());
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public IASTExpression getArraySizeExpression() throws DOMException {
|
||||
return delegate.getArraySizeExpression();
|
||||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
if (type == null) {
|
||||
return delegate.getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new ArrayTypeClone(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,22 +21,24 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
|||
*/
|
||||
public class CPPReferenceTypeClone implements ICPPReferenceType, ITypeContainer, IIndexType {
|
||||
private final ICPPReferenceType delegate;
|
||||
private IType type = null;
|
||||
private IType type;
|
||||
|
||||
public CPPReferenceTypeClone(ICPPReferenceType reference) {
|
||||
this.delegate = reference;
|
||||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
if (type == null) {
|
||||
return delegate.getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
if( type instanceof ITypedef )
|
||||
if (type instanceof ITypedef)
|
||||
return type.isSameType(this);
|
||||
|
||||
if( !( type instanceof ICPPReferenceType ))
|
||||
if (!(type instanceof ICPPReferenceType))
|
||||
return false;
|
||||
|
||||
ICPPReferenceType rhs = (ICPPReferenceType) type;
|
||||
|
@ -49,11 +51,18 @@ public class CPPReferenceTypeClone implements ICPPReferenceType, ITypeContainer,
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new CPPReferenceTypeClone(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,36 +25,44 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
public class CPPTypedefClone implements ITypedef, ITypeContainer, IIndexType, ICPPBinding {
|
||||
protected final ITypedef delegate;
|
||||
private IType type = null;
|
||||
private IType type;
|
||||
|
||||
public CPPTypedefClone(ITypedef typedef) {
|
||||
this.delegate = typedef;
|
||||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
if (type == null) {
|
||||
return delegate.getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public ILinkage getLinkage() throws CoreException {
|
||||
return delegate.getLinkage();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return delegate.getName();
|
||||
}
|
||||
|
||||
public char[] getNameCharArray() {
|
||||
return delegate.getNameCharArray();
|
||||
}
|
||||
|
||||
public IScope getScope() throws DOMException {
|
||||
return delegate.getScope();
|
||||
}
|
||||
|
||||
public IBinding getOwner() throws DOMException {
|
||||
return delegate.getOwner();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapter) {
|
||||
return delegate.getAdapter(adapter);
|
||||
}
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
try {
|
||||
IType myrtype = getType();
|
||||
|
@ -62,27 +70,37 @@ public class CPPTypedefClone implements ITypedef, ITypeContainer, IIndexType, IC
|
|||
return false;
|
||||
|
||||
if (type instanceof ITypedef) {
|
||||
type= ((ITypedef)type).getType();
|
||||
type= ((ITypedef) type).getType();
|
||||
}
|
||||
return myrtype.isSameType(type);
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
return ((ICPPBinding)delegate).getQualifiedName();
|
||||
return ((ICPPBinding) delegate).getQualifiedName();
|
||||
}
|
||||
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
return ((ICPPBinding)delegate).getQualifiedNameCharArray();
|
||||
return ((ICPPBinding) delegate).getQualifiedNameCharArray();
|
||||
}
|
||||
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
return ((ICPPBinding)delegate).isGloballyQualified();
|
||||
return ((ICPPBinding) delegate).isGloballyQualified();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new CPPTypedefClone(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
|||
*/
|
||||
public class PointerTypeClone implements IPointerType, ITypeContainer, IIndexType {
|
||||
protected final IPointerType delegate;
|
||||
private IType type = null;
|
||||
private IType type;
|
||||
|
||||
public PointerTypeClone(IPointerType pointer) {
|
||||
this.delegate = pointer;
|
||||
|
|
|
@ -26,18 +26,22 @@ public class QualifierTypeClone implements IQualifierType, ITypeContainer, IInde
|
|||
public QualifierTypeClone(IQualifierType qualifier) {
|
||||
this.delegate = qualifier;
|
||||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
if (type == null) {
|
||||
return delegate.getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isConst() {
|
||||
return delegate.isConst();
|
||||
}
|
||||
|
||||
public boolean isVolatile() {
|
||||
return delegate.isVolatile();
|
||||
}
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
if (type instanceof ITypedef)
|
||||
return type.isSameType(this);
|
||||
|
@ -54,12 +58,19 @@ public class QualifierTypeClone implements IQualifierType, ITypeContainer, IInde
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new QualifierTypeClone(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,9 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMPointerType;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
class PDOMCPPPointerToMemberType extends PDOMPointerType implements ICPPPointerToMemberType {
|
||||
|
||||
private static final int TYPE = PDOMPointerType.RECORD_SIZE;
|
||||
@SuppressWarnings("hiding")
|
||||
private static final int RECORD_SIZE= TYPE+4;
|
||||
private static final int RECORD_SIZE= TYPE + 4;
|
||||
|
||||
public PDOMCPPPointerToMemberType(PDOM pdom, int record) {
|
||||
super(pdom, record);
|
||||
|
@ -79,9 +78,11 @@ class PDOMCPPPointerToMemberType extends PDOMPointerType implements ICPPPointerT
|
|||
public PDOMCPPPointerToMemberTypeClone(ICPPPointerToMemberType pointer) {
|
||||
super(pointer);
|
||||
}
|
||||
|
||||
public IType getMemberOfClass() {
|
||||
return ((ICPPPointerToMemberType) delegate).getMemberOfClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new PDOMCPPPointerToMemberTypeClone((ICPPPointerToMemberType) delegate);
|
||||
|
|
Loading…
Add table
Reference in a new issue