mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
prework: refactor clones, add further template composite bindings (currently unused)
This commit is contained in:
parent
acb2de5ef9
commit
ec8a6daaa4
28 changed files with 621 additions and 271 deletions
|
@ -545,7 +545,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// class Foo<A> {};
|
||||
//
|
||||
// Foo<B> b2;
|
||||
public void testClassSpecializations() {
|
||||
public void _testClassSpecializations_180738() {
|
||||
IBinding b1a = getBindingFromASTName("Foo<B> b1;", 3);
|
||||
IBinding b1b = getBindingFromASTName("Foo<B> b1;", 6, true);
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
|
@ -40,6 +41,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -235,7 +237,11 @@ public class CPPClassSpecialization extends CPPSpecialization implements
|
|||
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
|
||||
*/
|
||||
public boolean isSameType(IType type) {
|
||||
return type == this;
|
||||
if( type == this )
|
||||
return true;
|
||||
if( type instanceof ITypedef || type instanceof IIndexType )
|
||||
return type.isSameType( this );
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -55,6 +55,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
|
@ -1641,4 +1642,39 @@ public class CPPTemplates {
|
|||
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of specialised bases. The bases will be specialised versions of
|
||||
* the template instances associated specialised bindings bases.
|
||||
* binding.
|
||||
* @param classInstance
|
||||
* @return
|
||||
* @throws DOMException
|
||||
*/
|
||||
public static ICPPBase[] getBases(ICPPTemplateInstance classInstance) throws DOMException {
|
||||
assert classInstance instanceof ICPPClassType;
|
||||
ICPPBase[] pdomBases = ((ICPPClassType) classInstance.getTemplateDefinition()).getBases();
|
||||
|
||||
if (pdomBases != null) {
|
||||
ICPPBase[] result = null;
|
||||
|
||||
for (int i = 0; i < pdomBases.length; i++) {
|
||||
ICPPBase origBase = pdomBases[i];
|
||||
ICPPBase specBase = (ICPPBase) ((ICPPInternalBase)origBase).clone();
|
||||
IBinding origClass = origBase.getBaseClass();
|
||||
if (origClass instanceof IType) {
|
||||
IType specClass = CPPTemplates.instantiateType((IType) origClass, classInstance.getArgumentMap());
|
||||
specClass = CPPSemantics.getUltimateType(specClass, true);
|
||||
if (specClass instanceof IBinding) {
|
||||
((ICPPInternalBase)specBase).setBaseClass((IBinding) specClass);
|
||||
}
|
||||
result = (ICPPBase[]) ArrayUtil.append(ICPPBase.class, result, specBase);
|
||||
}
|
||||
}
|
||||
|
||||
return (ICPPBase[]) ArrayUtil.trim(ICPPBase.class, result);
|
||||
}
|
||||
|
||||
return new ICPPBase[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*/
|
||||
public class ArrayTypeClone implements IIndexType, IArrayType, ITypeContainer {
|
||||
private final IArrayType delegate;
|
||||
private IType type = null;
|
||||
|
||||
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 ))
|
||||
return false;
|
||||
|
||||
try {
|
||||
IType type1= this.getType();
|
||||
if( type1 == null )
|
||||
return false;
|
||||
|
||||
IArrayType rhs = (IArrayType) type;
|
||||
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;
|
||||
}
|
||||
public Object clone() {
|
||||
return new ArrayTypeClone(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*/
|
||||
public class CPPReferenceTypeClone implements ICPPReferenceType, ITypeContainer, IIndexType {
|
||||
private final ICPPReferenceType delegate;
|
||||
private IType type = null;
|
||||
|
||||
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 )
|
||||
return type.isSameType(this);
|
||||
|
||||
if( !( type instanceof ICPPReferenceType ))
|
||||
return false;
|
||||
|
||||
ICPPReferenceType rhs = (ICPPReferenceType) type;
|
||||
try {
|
||||
IType type1= getType();
|
||||
if (type1 != null) {
|
||||
return type1.isSameType(rhs.getType());
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public Object clone() {
|
||||
return new CPPReferenceTypeClone(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*/
|
||||
public class CPPTypedefClone implements ITypedef, ITypeContainer, IIndexType, ICPPBinding {
|
||||
protected final ITypedef delegate;
|
||||
private IType type = null;
|
||||
|
||||
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 Object getAdapter(Class adapter) {
|
||||
return delegate.getAdapter(adapter);
|
||||
}
|
||||
public boolean isSameType(IType type) {
|
||||
try {
|
||||
IType myrtype = getType();
|
||||
if (myrtype == null)
|
||||
return false;
|
||||
|
||||
if (type instanceof ITypedef) {
|
||||
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();
|
||||
}
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
return ((ICPPBinding)delegate).getQualifiedNameCharArray();
|
||||
}
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
return ((ICPPBinding)delegate).isGloballyQualified();
|
||||
}
|
||||
public Object clone() {
|
||||
return new CPPTypedefClone(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*/
|
||||
public class PointerTypeClone implements IPointerType, ITypeContainer, IIndexType {
|
||||
protected final IPointerType delegate;
|
||||
private IType type = null;
|
||||
|
||||
public PointerTypeClone(IPointerType pointer) {
|
||||
this.delegate = pointer;
|
||||
}
|
||||
public IType getType() throws DOMException {
|
||||
if (type == null) {
|
||||
return delegate.getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
public boolean isConst() throws DOMException {
|
||||
return delegate.isConst();
|
||||
}
|
||||
public boolean isVolatile() throws DOMException {
|
||||
return delegate.isVolatile();
|
||||
}
|
||||
public boolean isSameType(IType type) {
|
||||
if( type instanceof ITypedef )
|
||||
return ((ITypedef)type).isSameType( this );
|
||||
|
||||
if( !( type instanceof IPointerType ))
|
||||
return false;
|
||||
|
||||
IPointerType rhs = (IPointerType) type;
|
||||
try {
|
||||
if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) {
|
||||
IType type1= getType();
|
||||
if (type1 != null) {
|
||||
return type1.isSameType(rhs.getType());
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public Object clone() {
|
||||
return new PointerTypeClone(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*/
|
||||
public class QualifierTypeClone implements IQualifierType, ITypeContainer, IIndexType {
|
||||
private final IQualifierType delegate;
|
||||
private IType type = null;
|
||||
|
||||
public QualifierTypeClone(IQualifierType qualifier) {
|
||||
this.delegate = qualifier;
|
||||
}
|
||||
public IType getType() throws DOMException {
|
||||
if (type == null) {
|
||||
return delegate.getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
public boolean isConst() throws DOMException {
|
||||
return delegate.isConst();
|
||||
}
|
||||
public boolean isVolatile() throws DOMException {
|
||||
return delegate.isVolatile();
|
||||
}
|
||||
public boolean isSameType(IType type) {
|
||||
if( type instanceof ITypedef )
|
||||
return type.isSameType( this );
|
||||
if( !( type instanceof IQualifierType ) )
|
||||
return false;
|
||||
|
||||
IQualifierType pt = (IQualifierType) type;
|
||||
try {
|
||||
if( isConst() == pt.isConst() && isVolatile() == pt.isVolatile() ) {
|
||||
IType myType= getType();
|
||||
return myType != null && myType.isSameType( pt.getType() );
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public Object clone() {
|
||||
return new QualifierTypeClone(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -75,7 +75,8 @@ public abstract class AbstractCompositeFactory implements ICompositesFactory {
|
|||
|
||||
/**
|
||||
* Convenience method for finding a binding with a definition in the specified index
|
||||
* context, which is equivalent to the specified binding
|
||||
* context, which is equivalent to the specified binding, or null if no definitions were
|
||||
* found.
|
||||
* @param index
|
||||
* @param binding
|
||||
* @return
|
||||
|
@ -84,7 +85,7 @@ public abstract class AbstractCompositeFactory implements ICompositesFactory {
|
|||
try{
|
||||
CIndex cindex = (CIndex) index;
|
||||
IIndexFragmentBinding[] ibs = cindex.findEquivalentBindings(binding);
|
||||
IBinding def = ibs[0];
|
||||
IBinding def = ibs.length>0 ? ibs[0] : null;
|
||||
for(int i=0; i<ibs.length; i++) {
|
||||
if(ibs[i].hasDefinition()) {
|
||||
def = ibs[i];
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.index.ArrayTypeClone;
|
||||
|
||||
public class CompositeArrayType extends CompositeTypeContainer implements IArrayType, ITypeContainer {
|
||||
public CompositeArrayType(IArrayType arrayType, ICompositesFactory cf) {
|
||||
|
@ -23,4 +24,8 @@ public class CompositeArrayType extends CompositeTypeContainer implements IArray
|
|||
public IASTExpression getArraySizeExpression() throws DOMException {
|
||||
fail(); return null;
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
return new ArrayTypeClone(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.index.PointerTypeClone;
|
||||
|
||||
public class CompositePointerType extends CompositeTypeContainer implements IPointerType, ITypeContainer {
|
||||
public CompositePointerType(IPointerType pointerType, ICompositesFactory cf) throws DOMException {
|
||||
|
@ -31,4 +32,8 @@ public class CompositePointerType extends CompositeTypeContainer implements IPoi
|
|||
public boolean isSameType(IType other) {
|
||||
return ((IPointerType)type).isSameType(other);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
return new PointerTypeClone(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.index.QualifierTypeClone;
|
||||
|
||||
public class CompositeQualifierType extends CompositeTypeContainer implements IQualifierType, ITypeContainer {
|
||||
public CompositeQualifierType(IQualifierType qualifierType, ICompositesFactory cf) throws DOMException {
|
||||
|
@ -31,4 +32,8 @@ public class CompositeQualifierType extends CompositeTypeContainer implements IQ
|
|||
public boolean isSameType(IType other) {
|
||||
return ((IQualifierType)type).isSameType(other);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
return new QualifierTypeClone(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPConstructorInstance extends CompositeCPPMethodInstance implements ICPPConstructor {
|
||||
public CompositeCPPConstructorInstance(ICompositesFactory cf, ICPPConstructor rbinding) {
|
||||
super(cf, rbinding);
|
||||
}
|
||||
|
||||
public boolean isExplicit() throws DOMException {
|
||||
return ((ICPPConstructor)rbinding).isExplicit();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPConstructorTemplateSpecialization
|
||||
extends CompositeCPPMethodTemplateSpecialization
|
||||
implements ICPPConstructor {
|
||||
|
||||
public CompositeCPPConstructorTemplateSpecialization(ICompositesFactory cf,
|
||||
ICPPFunction ft) {
|
||||
super(cf, ft);
|
||||
}
|
||||
|
||||
public boolean isExplicit() throws DOMException {
|
||||
return ((ICPPConstructor)rbinding).isExplicit();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPFunctionTemplateSpecialization
|
||||
extends CompositeCPPFunctionSpecialization
|
||||
implements ICPPFunctionTemplate, ICPPInternalTemplateInstantiator {
|
||||
|
||||
public CompositeCPPFunctionTemplateSpecialization(ICompositesFactory cf, ICPPFunction ft) {
|
||||
super(cf, ft);
|
||||
}
|
||||
|
||||
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
|
||||
ICPPTemplateParameter[] result= ((ICPPClassTemplate)rbinding).getTemplateParameters();
|
||||
for(int i=0; i<result.length; i++) {
|
||||
result[i]= (ICPPTemplateParameter) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
||||
fail(); return null;
|
||||
}
|
||||
|
||||
public ICPPSpecialization getInstance(IType[] arguments) {
|
||||
return InternalTemplateInstantiatorUtil.getInstance(arguments, cf, this);
|
||||
}
|
||||
|
||||
public IBinding instantiate(IType[] arguments) {
|
||||
return InternalTemplateInstantiatorUtil.instantiate(arguments, cf, rbinding);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPMethodInstance extends CompositeCPPFunctionInstance implements ICPPMethod {
|
||||
|
||||
public CompositeCPPMethodInstance(ICompositesFactory cf, ICPPMethod rbinding) {
|
||||
super(cf, rbinding);
|
||||
}
|
||||
|
||||
public boolean isDestructor() throws DOMException {
|
||||
return ((ICPPMethod)rbinding).isDestructor();
|
||||
}
|
||||
|
||||
public boolean isImplicit() {
|
||||
return ((ICPPMethod)rbinding).isImplicit();
|
||||
}
|
||||
|
||||
public boolean isVirtual() throws DOMException {
|
||||
return ((ICPPMethod)rbinding).isDestructor();
|
||||
}
|
||||
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
IIndexFragmentBinding rowner = (IIndexFragmentBinding) ((ICPPMethod)rbinding).getClassOwner();
|
||||
return (ICPPClassType) cf.getCompositeBinding(rowner);
|
||||
}
|
||||
|
||||
public int getVisibility() throws DOMException {
|
||||
return ((ICPPMethod)rbinding).getVisibility();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPMethodTemplateSpecialization
|
||||
extends CompositeCPPFunctionTemplateSpecialization
|
||||
implements ICPPMethod {
|
||||
|
||||
public CompositeCPPMethodTemplateSpecialization(ICompositesFactory cf,
|
||||
ICPPFunction ft) {
|
||||
super(cf, ft);
|
||||
}
|
||||
|
||||
public boolean isDestructor() throws DOMException {
|
||||
return ((ICPPMethod)rbinding).isDestructor();
|
||||
}
|
||||
|
||||
public boolean isImplicit() {
|
||||
return ((ICPPMethod)rbinding).isImplicit();
|
||||
}
|
||||
|
||||
public boolean isVirtual() throws DOMException {
|
||||
return ((ICPPMethod)rbinding).isVirtual();
|
||||
}
|
||||
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
IIndexFragmentBinding rowner = (IIndexFragmentBinding) ((ICPPMethod)rbinding).getClassOwner();
|
||||
return (ICPPClassType) cf.getCompositeBinding(rowner);
|
||||
}
|
||||
|
||||
public int getVisibility() throws DOMException {
|
||||
return ((ICPPMethod)rbinding).getVisibility();
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.index.CPPReferenceTypeClone;
|
||||
import org.eclipse.cdt.internal.core.index.composite.CompositeTypeContainer;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
|
@ -20,4 +21,8 @@ class CompositeCPPReferenceType extends CompositeTypeContainer implements ICPPRe
|
|||
public CompositeCPPReferenceType(ICPPReferenceType referenceType, ICompositesFactory cf) throws DOMException {
|
||||
super((ITypeContainer) referenceType, cf);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
return new CPPReferenceTypeClone(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.index.CPPTypedefClone;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
|
@ -32,11 +33,11 @@ class CompositeCPPTypedef extends CompositeCPPBinding implements ITypedef, IInde
|
|||
return ((ITypedef)rbinding).isSameType(type);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
fail(); return null;
|
||||
}
|
||||
|
||||
public void setType(IType type) {
|
||||
fail();
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
return new CPPTypedefClone(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IArrayType;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.index.ArrayTypeClone;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
|
@ -93,48 +94,6 @@ public class PDOMArrayType extends PDOMNode implements IIndexType, IArrayType, I
|
|||
}
|
||||
|
||||
public Object clone() {
|
||||
return new PDOMArrayTypeClone(this);
|
||||
}
|
||||
|
||||
private static class PDOMArrayTypeClone implements IIndexType, IArrayType, ITypeContainer {
|
||||
private final IArrayType delegate;
|
||||
private IType type = null;
|
||||
|
||||
public PDOMArrayTypeClone(IArrayType array) {
|
||||
this.delegate = array;
|
||||
}
|
||||
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 )
|
||||
return false;
|
||||
|
||||
IArrayType rhs = (IArrayType) type;
|
||||
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;
|
||||
}
|
||||
public Object clone() {
|
||||
return new PDOMArrayTypeClone(this);
|
||||
}
|
||||
return new ArrayTypeClone(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
|
|||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.PointerTypeClone;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -136,52 +137,6 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
|
|||
}
|
||||
|
||||
public Object clone() {
|
||||
return new PDOMPointerTypeClone(this);
|
||||
}
|
||||
|
||||
protected static class PDOMPointerTypeClone implements IPointerType, ITypeContainer, IIndexType {
|
||||
protected final IPointerType delegate;
|
||||
private IType type = null;
|
||||
|
||||
public PDOMPointerTypeClone(IPointerType pointer) {
|
||||
this.delegate = pointer;
|
||||
}
|
||||
public IType getType() throws DOMException {
|
||||
if (type == null) {
|
||||
return delegate.getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
public boolean isConst() throws DOMException {
|
||||
return delegate.isConst();
|
||||
}
|
||||
public boolean isVolatile() throws DOMException {
|
||||
return delegate.isVolatile();
|
||||
}
|
||||
public boolean isSameType(IType type) {
|
||||
if( type instanceof ITypedef )
|
||||
return ((ITypedef)type).isSameType( this );
|
||||
|
||||
if( !( type instanceof IPointerType ))
|
||||
return false;
|
||||
|
||||
IPointerType rhs = (IPointerType) type;
|
||||
try {
|
||||
if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) {
|
||||
IType type1= getType();
|
||||
if (type1 != null) {
|
||||
return type1.isSameType(rhs.getType());
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public Object clone() {
|
||||
return new PDOMPointerTypeClone(this);
|
||||
}
|
||||
return new PointerTypeClone(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICQualifierType;
|
|||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.QualifierTypeClone;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -150,49 +151,6 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQua
|
|||
}
|
||||
|
||||
public Object clone() {
|
||||
return new PDOMQualifierTypeClone(this);
|
||||
}
|
||||
|
||||
private static class PDOMQualifierTypeClone implements IQualifierType, ITypeContainer, IIndexType {
|
||||
private final IQualifierType delegate;
|
||||
private IType type = null;
|
||||
|
||||
public PDOMQualifierTypeClone(IQualifierType qualifier) {
|
||||
this.delegate = qualifier;
|
||||
}
|
||||
public IType getType() throws DOMException {
|
||||
if (type == null) {
|
||||
return delegate.getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
public boolean isConst() throws DOMException {
|
||||
return delegate.isConst();
|
||||
}
|
||||
public boolean isVolatile() throws DOMException {
|
||||
return delegate.isVolatile();
|
||||
}
|
||||
public boolean isSameType(IType type) {
|
||||
if( type instanceof ITypedef )
|
||||
return type.isSameType( this );
|
||||
if( !( type instanceof IQualifierType ) )
|
||||
return false;
|
||||
|
||||
IQualifierType pt = (IQualifierType) type;
|
||||
try {
|
||||
if( isConst() == pt.isConst() && isVolatile() == pt.isVolatile() ) {
|
||||
IType myType= getType();
|
||||
return myType != null && myType.isSameType( pt.getType() );
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public Object clone() {
|
||||
return new PDOMQualifierTypeClone(this);
|
||||
}
|
||||
return new QualifierTypeClone(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter, IIndexFragment
|
|||
}
|
||||
|
||||
public Object getAdapter(Class adapter) {
|
||||
throw new PDOMNotImplementedError();
|
||||
return null;
|
||||
}
|
||||
|
||||
public char[] getNameCharArray() {
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBase;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
|
@ -80,29 +79,7 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
|
|||
}
|
||||
|
||||
public ICPPBase[] getBases() throws DOMException {
|
||||
ICPPBase[] pdomBases = ((ICPPClassType) getTemplateDefinition()).getBases();
|
||||
|
||||
if (pdomBases != null) {
|
||||
ICPPBase[] result = null;
|
||||
|
||||
for (int i = 0; i < pdomBases.length; i++) {
|
||||
ICPPBase origBase = pdomBases[i];
|
||||
ICPPBase specBase = (ICPPBase) ((ICPPInternalBase)origBase).clone();
|
||||
IBinding origClass = origBase.getBaseClass();
|
||||
if (origClass instanceof IType) {
|
||||
IType specClass = CPPTemplates.instantiateType((IType) origClass, getArgumentMap());
|
||||
specClass = CPPSemantics.getUltimateType(specClass, true);
|
||||
if (specClass instanceof IBinding) {
|
||||
((ICPPInternalBase)specBase).setBaseClass((IBinding) specClass);
|
||||
}
|
||||
result = (ICPPBase[]) ArrayUtil.append(ICPPBase.class, result, specBase);
|
||||
}
|
||||
}
|
||||
|
||||
return (ICPPBase[]) ArrayUtil.trim(ICPPBase.class, result);
|
||||
}
|
||||
|
||||
return new ICPPBase[0];
|
||||
return CPPTemplates.getBases(this);
|
||||
}
|
||||
|
||||
private static class ConstructorCollector implements IPDOMVisitor {
|
||||
|
|
|
@ -182,7 +182,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IIndexFra
|
|||
}
|
||||
|
||||
public Object getAdapter(Class adapter) {
|
||||
throw new PDOMNotImplementedError();
|
||||
return null;
|
||||
}
|
||||
|
||||
public char[] getNameCharArray() {
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.PointerTypeClone;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
|
@ -72,7 +73,7 @@ implements ICPPPointerToMemberType, IIndexType {
|
|||
return new PDOMCPPPointerToMemberTypeClone(this);
|
||||
}
|
||||
|
||||
private static class PDOMCPPPointerToMemberTypeClone extends PDOMPointerType.PDOMPointerTypeClone implements ICPPPointerToMemberType {
|
||||
private static class PDOMCPPPointerToMemberTypeClone extends PointerTypeClone implements ICPPPointerToMemberType {
|
||||
public PDOMCPPPointerToMemberTypeClone(ICPPPointerToMemberType pointer) {
|
||||
super(pointer);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.index.CPPReferenceTypeClone;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
|
@ -99,44 +100,6 @@ class PDOMCPPReferenceType extends PDOMNode implements ICPPReferenceType,
|
|||
}
|
||||
|
||||
public Object clone() {
|
||||
return new PDOMCPPReferenceTypeClone(this);
|
||||
}
|
||||
|
||||
private static class PDOMCPPReferenceTypeClone implements ICPPReferenceType, ITypeContainer, IIndexType {
|
||||
private final ICPPReferenceType delegate;
|
||||
private IType type = null;
|
||||
|
||||
public PDOMCPPReferenceTypeClone(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 )
|
||||
return type.isSameType(this);
|
||||
|
||||
if( !( type instanceof ICPPReferenceType ))
|
||||
return false;
|
||||
|
||||
ICPPReferenceType rhs = (ICPPReferenceType) type;
|
||||
try {
|
||||
IType type1= getType();
|
||||
if (type1 != null) {
|
||||
return type1.isSameType(rhs.getType());
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public Object clone() {
|
||||
return new PDOMCPPReferenceTypeClone(this);
|
||||
}
|
||||
return new CPPReferenceTypeClone(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,14 +12,12 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.index.CPPTypedefClone;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
|
@ -88,65 +86,6 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
|
|||
public void setType(IType type) { fail(); }
|
||||
|
||||
public Object clone() {
|
||||
return new PDOMCPPTypedefClone(this);
|
||||
}
|
||||
|
||||
private static class PDOMCPPTypedefClone implements ITypedef, ITypeContainer, IIndexType, ICPPBinding {
|
||||
protected final ITypedef delegate;
|
||||
private IType type = null;
|
||||
|
||||
public PDOMCPPTypedefClone(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 Object getAdapter(Class adapter) {
|
||||
return delegate.getAdapter(adapter);
|
||||
}
|
||||
public boolean isSameType(IType type) {
|
||||
try {
|
||||
IType myrtype = getType();
|
||||
if (myrtype == null)
|
||||
return false;
|
||||
|
||||
if (type instanceof ITypedef) {
|
||||
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();
|
||||
}
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
return ((ICPPBinding)delegate).getQualifiedNameCharArray();
|
||||
}
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
return ((ICPPBinding)delegate).isGloballyQualified();
|
||||
}
|
||||
public Object clone() {
|
||||
return new PDOMCPPTypedefClone(this);
|
||||
}
|
||||
return new CPPTypedefClone(this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue