mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
start of support for template parameter qualified types
This commit is contained in:
parent
037b93c764
commit
641fbeb7a6
14 changed files with 671 additions and 4 deletions
|
@ -9506,7 +9506,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
|||
buffer.append("typename T::X x; // illformed: finds the data member X\n"); //$NON-NLS-1$
|
||||
buffer.append("// not the member type X\n"); //$NON-NLS-1$
|
||||
buffer.append("}\n"); //$NON-NLS-1$
|
||||
parse(buffer.toString(), ParserLanguage.CPP, true, 2);
|
||||
parse(buffer.toString(), ParserLanguage.CPP, true, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1174,4 +1174,65 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
assertTrue( x4 instanceof ICPPSpecialization );
|
||||
assertEquals( ((ICPPSpecialization)x4).getSpecializedBinding(), x2 );
|
||||
}
|
||||
|
||||
public void testTemplateParameterQualifiedType_1() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("template <class T> class A { \n"); //$NON-NLS-1$
|
||||
buffer.append(" typedef typename T::X _xx; \n"); //$NON-NLS-1$
|
||||
buffer.append(" _xx s; \n"); //$NON-NLS-1$
|
||||
buffer.append("}; \n"); //$NON-NLS-1$
|
||||
buffer.append("class B {}; \n"); //$NON-NLS-1$
|
||||
buffer.append("template < class T > class C { \n"); //$NON-NLS-1$
|
||||
buffer.append(" typedef T X; \n"); //$NON-NLS-1$
|
||||
buffer.append("}; \n"); //$NON-NLS-1$
|
||||
buffer.append("void f() { \n"); //$NON-NLS-1$
|
||||
buffer.append(" A< C<B> > a; a.s; \n"); //$NON-NLS-1$
|
||||
buffer.append("}; \n"); //$NON-NLS-1$
|
||||
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept( col );
|
||||
|
||||
ICPPTemplateTypeParameter T = (ICPPTemplateTypeParameter) col.getName(0).resolveBinding();
|
||||
ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding();
|
||||
|
||||
IBinding T1 = col.getName(3).resolveBinding();
|
||||
assertSame( T1, T );
|
||||
|
||||
ICPPClassType X = (ICPPClassType) col.getName(4).resolveBinding();
|
||||
|
||||
ITypedef _xx = (ITypedef) col.getName(5).resolveBinding();
|
||||
|
||||
IBinding _xx2 = col.getName(6).resolveBinding();
|
||||
assertSame( _xx, _xx2 );
|
||||
assertSame( _xx.getType(), X );
|
||||
|
||||
ICPPField s = (ICPPField) col.getName(7).resolveBinding();
|
||||
|
||||
ICPPClassType B = (ICPPClassType) col.getName(8).resolveBinding();
|
||||
ITypedef X2 = (ITypedef) col.getName(12).resolveBinding();
|
||||
|
||||
ICPPClassType Acb = (ICPPClassType) col.getName(14).resolveBinding();
|
||||
assertTrue( Acb instanceof ICPPTemplateInstance );
|
||||
assertSame( ((ICPPTemplateInstance)Acb).getTemplateDefinition(), A );
|
||||
|
||||
ICPPField s2 = (ICPPField) col.getName(21).resolveBinding();
|
||||
assertTrue( s2 instanceof ICPPSpecialization );
|
||||
assertSame( ((ICPPSpecialization)s2).getSpecializedBinding(), s );
|
||||
|
||||
IType t = s2.getType();
|
||||
// assertTrue( t instanceof ITypedef );
|
||||
// assertTrue( t instanceof ICPPSpecialization );
|
||||
// assertSame( ((ICPPSpecialization)t).getSpecializedBinding(), _xx );
|
||||
|
||||
t = ((ITypedef)t).getType();
|
||||
assertTrue( t instanceof ICPPSpecialization );
|
||||
assertSame( ((ICPPSpecialization)t).getSpecializedBinding(), X2 );
|
||||
|
||||
t = ((ITypedef)t).getType();
|
||||
assertSame( t, B );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
* @author Doug Schaefer
|
||||
*/
|
||||
public interface IBinding {
|
||||
|
||||
public static final IBinding[] EMPTY_BINDING_ARRAY = new IBinding[0];
|
||||
/**
|
||||
* The name of the binding.
|
||||
*
|
||||
|
|
|
@ -15,4 +15,6 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
*/
|
||||
public interface IField extends IVariable {
|
||||
|
||||
public static final IField[] EMPTY_FIELD_ARRAY = new IField[0];
|
||||
|
||||
}
|
||||
|
|
|
@ -16,5 +16,6 @@ import org.eclipse.cdt.core.dom.ast.IField;
|
|||
* @author Doug Schaefer
|
||||
*/
|
||||
public interface ICPPField extends IField, ICPPMember, ICPPVariable {
|
||||
public static final ICPPField [] EMPTY_CPPFIELD_ARRAY = new ICPPField[0];
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
|
@ -42,10 +43,11 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class CPPTemplateTemplateParameter extends CPPTemplateParameter implements
|
||||
ICPPTemplateTemplateParameter, ICPPClassType, ICPPInternalTemplate {
|
||||
ICPPTemplateTemplateParameter, ICPPClassType, ICPPInternalTemplate, ICPPInternalUnknown {
|
||||
|
||||
private ICPPTemplateParameter [] templateParameters = null;
|
||||
private ObjectMap instances = null;
|
||||
private ICPPScope unknownScope = null;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
|
@ -55,6 +57,13 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
|||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ICPPScope getUnknownScope() {
|
||||
if( unknownScope == null ) {
|
||||
unknownScope = new CPPUnknownScope( this, null );
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter#getTemplateParameters()
|
||||
*/
|
||||
|
@ -288,4 +297,12 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
|||
instances = new ObjectMap( 2 );
|
||||
instances.put( types, spec );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
|
||||
*/
|
||||
public IBinding resolveUnknown( ObjectMap argMap ) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,17 +16,21 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
|
||||
ICPPTemplateTypeParameter, IType {
|
||||
ICPPTemplateTypeParameter, IType, ICPPInternalUnknown {
|
||||
|
||||
private ICPPScope unknownScope = null;
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
|
@ -34,6 +38,12 @@ public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
|
|||
super(name);
|
||||
}
|
||||
|
||||
public ICPPScope getUnknownScope() {
|
||||
if( unknownScope == null ) {
|
||||
unknownScope = new CPPUnknownScope( this, null );
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter#getDefault()
|
||||
*/
|
||||
|
@ -62,4 +72,12 @@ public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
|
|||
return ((ITypedef)type).isSameType( this );
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
|
||||
*/
|
||||
public IBinding resolveUnknown( ObjectMap argMap ) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||
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.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||
|
@ -542,6 +543,8 @@ public class CPPTemplates {
|
|||
spec = new CPPMethodSpecialization( decl, scope, argMap );
|
||||
} else if( decl instanceof ICPPFunction ) {
|
||||
spec = new CPPFunctionSpecialization( decl, scope, argMap );
|
||||
} else if( decl instanceof ITypedef ){
|
||||
spec = new CPPTypedefSpecialization( decl, scope, argMap );
|
||||
}
|
||||
return spec;
|
||||
}
|
||||
|
@ -588,6 +591,15 @@ public class CPPTemplates {
|
|||
newType = (IType) argMap.get( type );
|
||||
} else if( type instanceof CPPDeferredClassInstance ){
|
||||
newType = ((CPPDeferredClassInstance)type).instantiate( argMap );
|
||||
} else if( type instanceof ICPPInternalUnknown ){
|
||||
IBinding binding;
|
||||
try {
|
||||
binding = ((ICPPInternalUnknown)type).resolveUnknown( argMap );
|
||||
} catch ( DOMException e ) {
|
||||
binding = e.getProblem();
|
||||
}
|
||||
if( binding instanceof IType )
|
||||
newType = (IType) binding;
|
||||
}
|
||||
|
||||
return newType;
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on May 3, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedef.CPPTypedefDelegate;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPTypedefSpecialization extends CPPSpecialization implements
|
||||
ITypedef {
|
||||
|
||||
private IType type = null;
|
||||
/**
|
||||
* @param specialized
|
||||
* @param scope
|
||||
* @param argumentMap
|
||||
*/
|
||||
public CPPTypedefSpecialization( IBinding specialized, ICPPScope scope,
|
||||
ObjectMap argumentMap ) {
|
||||
super( specialized, scope, argumentMap );
|
||||
}
|
||||
|
||||
private ITypedef getTypedef() {
|
||||
return (ITypedef) getSpecializedBinding();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.ITypedef#getType()
|
||||
*/
|
||||
public IType getType() throws DOMException {
|
||||
if( type == null ){
|
||||
type = CPPTemplates.instantiateType( getTypedef().getType(), argumentMap );
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
public Object clone() {
|
||||
// IType t = null;
|
||||
// try {
|
||||
// t = (IType) super.clone();
|
||||
// } catch ( CloneNotSupportedException e ) {
|
||||
// //not going to happen
|
||||
// }
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
|
||||
*/
|
||||
public boolean isSameType( IType o ) {
|
||||
if( o == this )
|
||||
return true;
|
||||
if( o instanceof ITypedef )
|
||||
try {
|
||||
IType t = getType();
|
||||
if( t != null )
|
||||
return t.isSameType( ((ITypedef)o).getType());
|
||||
return false;
|
||||
} catch ( DOMException e ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
IType t = getType();
|
||||
if( t != null )
|
||||
return t.isSameType( o );
|
||||
} catch ( DOMException e ) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
return new CPPTypedefDelegate( name, this );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on May 3, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPUnknownBinding implements ICPPInternalUnknown {
|
||||
private ICPPScope unknownScope = null;
|
||||
private IBinding scopeBinding = null;
|
||||
private ICPPScope scope = null;
|
||||
private IASTName name = null;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CPPUnknownBinding( ICPPScope scope, IBinding scopeBinding, IASTName name ) {
|
||||
super();
|
||||
this.scope = scope;
|
||||
this.name = name;
|
||||
this.scopeBinding = scopeBinding;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)```
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#getUnknownScope()
|
||||
*/
|
||||
public ICPPScope getUnknownScope() {
|
||||
if( unknownScope == null ){
|
||||
unknownScope = new CPPUnknownScope( this, name );
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDeclarations()
|
||||
*/
|
||||
public IASTNode[] getDeclarations() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDefinition()
|
||||
*/
|
||||
public IASTNode getDefinition() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
|
||||
*/
|
||||
public void addDefinition( IASTNode node ) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
|
||||
*/
|
||||
public void addDeclaration( IASTNode node ) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#removeDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
|
||||
*/
|
||||
public void removeDeclaration( IASTNode node ) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
return name.toCharArray();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
|
||||
*/
|
||||
public IBinding resolveUnknown( ObjectMap argMap ) throws DOMException {
|
||||
IBinding result = this;
|
||||
if( argMap.containsKey( scopeBinding ) ){
|
||||
IType t = (IType) argMap.get( scopeBinding );
|
||||
t = CPPSemantics.getUltimateType( t, false );
|
||||
if( t instanceof ICPPClassType ){
|
||||
IScope s = ((ICPPClassType)t).getCompositeScope();
|
||||
|
||||
if( s.isFullyCached() )
|
||||
result = s.getBinding( name, true );
|
||||
// CPPSemantics.LookupData data = CPPSemantics.createLookupData( name, false );
|
||||
// CPPSemantics.lookup( data, s );
|
||||
// IBinding result = CPPSemantics.resolveAmbiguities( data, name );
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on May 3, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
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.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPUnknownClass extends CPPUnknownBinding implements ICPPClassType {
|
||||
|
||||
/**
|
||||
* @param scope
|
||||
* @param name
|
||||
*/
|
||||
public CPPUnknownClass( ICPPScope scope, IBinding scopeBinding, IASTName name ) {
|
||||
super( scope, scopeBinding, name );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
|
||||
*/
|
||||
public ICPPBase[] getBases() {
|
||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
|
||||
*/
|
||||
public IField[] getFields() {
|
||||
return IField.EMPTY_FIELD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#findField(java.lang.String)
|
||||
*/
|
||||
public IField findField( String name ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
|
||||
*/
|
||||
public ICPPField[] getDeclaredFields() {
|
||||
return ICPPField.EMPTY_CPPFIELD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
|
||||
*/
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
|
||||
*/
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
|
||||
*/
|
||||
public ICPPMethod[] getDeclaredMethods() {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getConstructors()
|
||||
*/
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
|
||||
*/
|
||||
public IBinding[] getFriends() {
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
|
||||
*/
|
||||
public int getKey() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope()
|
||||
*/
|
||||
public IScope getCompositeScope() {
|
||||
return getUnknownScope();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
public Object clone() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
|
||||
*/
|
||||
public boolean isSameType( IType type ) {
|
||||
return type == this;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on May 3, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPUnknownScope implements ICPPScope {
|
||||
private ICPPScope parentScope = null;
|
||||
private IBinding binding = null;
|
||||
private IASTName scopeName = null;
|
||||
private CharArrayObjectMap map = null;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CPPUnknownScope( IBinding binding, IASTName name ) {
|
||||
super();
|
||||
this.scopeName = name;
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName()
|
||||
*/
|
||||
public IASTName getScopeName() {
|
||||
return scopeName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getParent()
|
||||
*/
|
||||
public IScope getParent() throws DOMException {
|
||||
return binding.getScope();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
||||
*/
|
||||
public IBinding[] find( String name ) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getPhysicalNode()
|
||||
*/
|
||||
public IASTNode getPhysicalNode() {
|
||||
return scopeName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
public void addName( IASTName name ) {
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
public void removeBinding( IBinding binding ) {
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean)
|
||||
*/
|
||||
public IBinding getBinding( IASTName name, boolean resolve ) {
|
||||
if( map == null )
|
||||
map = new CharArrayObjectMap(2);
|
||||
|
||||
char [] c = name.toCharArray();
|
||||
if( map.containsKey( c ) ){
|
||||
return (IBinding) map.get( c );
|
||||
}
|
||||
|
||||
IBinding b = new CPPUnknownClass( this, binding, name );
|
||||
name.setBinding( b );
|
||||
map.put( c, b );
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#setFullyCached(boolean)
|
||||
*/
|
||||
public void setFullyCached( boolean b ) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#isFullyCached()
|
||||
*/
|
||||
public boolean isFullyCached() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#flushCache()
|
||||
*/
|
||||
public void flushCache() {
|
||||
}
|
||||
|
||||
}
|
|
@ -712,6 +712,8 @@ public class CPPVisitor {
|
|||
return ((ICPPClassType)binding).getCompositeScope();
|
||||
} else if( binding instanceof ICPPNamespace ){
|
||||
return ((ICPPNamespace)binding).getNamespaceScope();
|
||||
} else if( binding instanceof ICPPInternalUnknown ){
|
||||
return ((ICPPInternalUnknown)binding).getUnknownScope();
|
||||
} else if( binding instanceof IProblemBinding ){
|
||||
if( binding instanceof ICPPScope )
|
||||
return (IScope) binding;
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on May 3, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPInternalUnknown extends ICPPInternalBinding {
|
||||
public ICPPScope getUnknownScope();
|
||||
|
||||
/**
|
||||
* @param argMap
|
||||
* @return
|
||||
* @throws DOMException
|
||||
*/
|
||||
public IBinding resolveUnknown( ObjectMap argMap ) throws DOMException;
|
||||
}
|
Loading…
Add table
Reference in a new issue