1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

176708: fix two exceptions in composite classes

This commit is contained in:
Andrew Ferguson 2007-03-19 13:06:18 +00:00
parent 1ee016eee8
commit 0c28b3d6ea
30 changed files with 313 additions and 172 deletions

View file

@ -13,7 +13,11 @@ package org.eclipse.cdt.internal.index.tests;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
/**
* For testing PDOM binding resolution
@ -127,4 +131,33 @@ public class IndexBindingResolutionBugs extends IndexBindingResolutionTestBase {
getBindingFromASTName("k=2", 1);
getBindingFromASTName("l=2", 1);
}
// namespace X {}
// namespace Y {
// class Ambiguity {};
// enum Ambiguity {A1,A2,A3};
// void foo() {
// Ambiguity problem;
// }
// }
public void testBug176708_CCE() throws Exception {
IBinding binding= getBindingFromASTName("Y {", 1);
assertTrue(binding instanceof ICPPNamespace);
ICPPNamespace adapted= (ICPPNamespace) strategy.getIndex().adaptBinding(binding);
IASTName[] names= findNames("Ambiguity problem", 9);
assertEquals(1, names.length);
IBinding binding2= adapted.getNamespaceScope().getBinding(names[0], true);
}
// namespace X {int i;}
// // references
// #include "header.h"
// int a= X::i;
public void testBug176708_NPE() throws Exception {
IBinding binding= getBindingFromASTName("i;", 1);
assertTrue(binding instanceof ICPPVariable);
IScope scope= binding.getScope();
}
}

View file

@ -36,6 +36,7 @@ import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
@ -55,7 +56,7 @@ import org.osgi.framework.Bundle;
* the PDOM purely from AST information (i.e. without a real binding from the DOM)
*/
public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
private ITestStrategy strategy;
protected ITestStrategy strategy;
public void setStrategy(ITestStrategy strategy) {
this.strategy = strategy;
@ -68,8 +69,8 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
protected void tearDown() throws Exception {
strategy.tearDown();
}
protected IBinding getBindingFromASTName(String section, int len) {
protected IASTName[] findNames(String section, int len) {
// get the language from the language manager
ILanguage language = null;
ICProject cproject = strategy.getCProject();
@ -83,8 +84,11 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
assertNotNull("No language for file " + ast.getFilePath().toString(), language);
IASTName[] names= language.getSelectedNames(ast, strategy.getTestData()[1].indexOf(section), len);
return language.getSelectedNames(ast, strategy.getTestData()[1].indexOf(section), len);
}
protected IBinding getBindingFromASTName(String section, int len) {
IASTName[] names= findNames(section, len);
assertEquals("<>1 name found for \""+section+"\"", 1, names.length);
IBinding binding = names[0].resolveBinding();
assertNotNull("No binding for "+names[0].getRawSignature(), binding);
@ -163,6 +167,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
public IASTTranslationUnit getAst();
public StringBuffer[] getTestData();
public ICProject getCProject();
public boolean isCompositeIndex();
}
class SinglePDOMTestStrategy implements ITestStrategy {
@ -200,6 +205,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
IFile cppfile= TestSourceReader.createFile(cproject.getProject(), new Path("references.c" + (cpp ? "pp" : "")), testData[1].toString());
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
// ((PDOM)CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
index= CCorePlugin.getIndexManager().getIndex(cproject);
@ -219,6 +225,10 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
public IIndex getIndex() {
return index;
}
public boolean isCompositeIndex() {
return false;
}
}
class ReferencedProject implements ITestStrategy {
@ -249,8 +259,8 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
}
public void setUp() throws Exception {
cproject= cpp ? CProjectHelper.createCCProject("OnlineContent", "bin", IPDOMManager.ID_NO_INDEXER)
: CProjectHelper.createCProject("OnlineContent", "bin", IPDOMManager.ID_NO_INDEXER);
cproject= cpp ? CProjectHelper.createCCProject("OnlineContent"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
: CProjectHelper.createCProject("OnlineContent"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
Bundle b= CTestPlugin.getDefault().getBundle();
testData= TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2);
referenced = createReferencedContent();
@ -262,8 +272,13 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
pd.setReferencedProjects(refs);
cproject.getProject().setDescription(pd, new NullProgressMonitor());
CCoreInternals.getPDOMManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
CCoreInternals.getPDOMManager().reindex(cproject);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
// System.out.println("Online: "+getName());
// ((PDOM)CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
index= CCorePlugin.getIndexManager().getIndex(cproject);
index.acquireReadLock();
@ -274,11 +289,16 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
ICProject referenced = cpp ? CProjectHelper.createCCProject("ReferencedContent"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
: CProjectHelper.createCProject("ReferencedContent"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
String content = testData[0].toString();
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), content);
CCoreInternals.getPDOMManager().setIndexerId(referenced, IPDOMManager.ID_FAST_INDEXER);
IFile file = TestSourceReader.createFile(referenced.getProject(), new Path("header.h"), content);
IndexerPreferences.set(referenced.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
IndexerPreferences.set(referenced.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
CCoreInternals.getPDOMManager().reindex(referenced);
//System.out.println("Referenced: "+getName());
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
//((PDOM)CCoreInternals.getPDOMManager().getPDOM(referenced)).accept(new PDOMPrettyPrinter());
return referenced;
}
@ -293,5 +313,9 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
public StringBuffer[] getTestData() {
return testData;
}
public boolean isCompositeIndex() {
return true;
}
}
}

View file

@ -67,5 +67,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
assertEquals(1, params.length);
IType param= params[0].getType();
assertTrue(param instanceof IBasicType);
IType returnType= f0.getType().getReturnType();
assertTrue(returnType instanceof IBasicType);
}
}

View file

@ -71,9 +71,10 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
// };
// // referencing file
// #include "referenced.h"
// #include "header.h"
//
// C *cp = new C(); /*b0, b1*/
// void references() {
// C *cp = new C(); /*b0, b1*/
// long l = 5, *lp;
// lp = &l;
// cp->cs.*cp->ouch = lp = cp->cs.*cp->autsch; /*b2, b3, b4*/
@ -1039,8 +1040,18 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
assertEquals(binding2, getBindingFromASTName("f(const_int_ptr_const)", 1));
assertEquals(binding2, getBindingFromASTName("f(int_const_ptr_const)", 1));
assertEquals(2, getIndex().findNames(binding1, IIndex.FIND_DECLARATIONS).length);
assertEquals(4, getIndex().findNames(binding2, IIndex.FIND_DECLARATIONS).length);
if(strategy.isCompositeIndex()) {
// getIndex() returns the index for the referencing content only
assertEquals(0, getIndex().findNames(binding1, IIndex.FIND_DECLARATIONS).length);
assertEquals(0, getIndex().findNames(binding2, IIndex.FIND_DECLARATIONS).length);
assertEquals(1, getIndex().findNames(binding1, IIndex.FIND_DEFINITIONS).length);
assertEquals(1, getIndex().findNames(binding2, IIndex.FIND_DEFINITIONS).length);
} else {
assertEquals(2, getIndex().findNames(binding1, IIndex.FIND_DECLARATIONS).length);
assertEquals(4, getIndex().findNames(binding2, IIndex.FIND_DECLARATIONS).length);
assertEquals(1, getIndex().findNames(binding1, IIndex.FIND_DEFINITIONS).length);
assertEquals(1, getIndex().findNames(binding2, IIndex.FIND_DEFINITIONS).length);
}
}
// typedef struct S {int a;} S;

View file

@ -54,7 +54,8 @@ public class CIndex implements IIndex {
final private IIndexFragment[] fFragments;
final private int fPrimaryFragmentCount;
private int fReadLock;
private ICompositesFactory cppCF, cCF, fCF;
public CIndex(IIndexFragment[] fragments, int primaryFragmentCount) {
fFragments= fragments;
fPrimaryFragmentCount= primaryFragmentCount;
@ -328,18 +329,23 @@ public class CIndex implements IIndex {
}
}
public IIndexBinding adaptBinding(IBinding binding) {
try {
if(SPECIALCASE_SINGLES && fFragments.length==1) {
return fFragments[0].adaptBinding(binding);
} else {
return getCompositesFactory(binding.getLinkage().getID()).getCompositeBinding(binding);
for (int i = 0; i < fPrimaryFragmentCount; i++) {
IIndexFragmentBinding adaptedBinding= fFragments[i].adaptBinding(binding);
if (adaptedBinding != null) {
return getCompositesFactory(binding.getLinkage().getID()).getCompositeBinding(adaptedBinding);
}
}
}
} catch(CoreException ce) {
CCorePlugin.log(ce);
return null;
}
return null;
}
public IIndexBinding[] findBindings(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
@ -391,7 +397,6 @@ public class CIndex implements IIndex {
return (IIndexFragmentBinding[]) result.toArray(new IIndexFragmentBinding[result.size()]);
}
ICompositesFactory cppCF, cCF, fCF;
private ICompositesFactory getCompositesFactory(String linkageID) {
if(linkageID.equals(ILinkage.CPP_LINKAGE_ID)) {
if(cppCF==null) {
@ -423,7 +428,7 @@ public class CIndex implements IIndex {
}
public boolean acceptImplicitMethods() {
return filter.acceptImplicitMethods();
};
}
public boolean acceptLinkage(ILinkage other) {
return linkage.getID().equals(other.getID());
}

View file

@ -34,7 +34,7 @@ public abstract class AbstractCompositeFactory implements ICompositesFactory {
* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.composite.ICompositesFactory#getCompositeBindings(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.internal.core.index.IIndexFragmentBinding[])
*/
public final IIndexBinding[] getCompositeBindings(IBinding[] bindings) {
public final IIndexBinding[] getCompositeBindings(IIndexFragmentBinding[] bindings) {
IIndexBinding[] result = new IIndexBinding[bindings.length];
for(int i=0; i<result.length; i++)
result[i] = getCompositeBinding(bindings[i]);

View file

@ -13,9 +13,10 @@ package org.eclipse.cdt.internal.core.index.composite;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.core.runtime.CoreException;
/**
@ -36,9 +37,9 @@ public abstract class CompositeIndexBinding implements IIndexBinding {
* and some ignore it as a representative binding from each fragment is needed to meet interface
* contracts.
*/
protected final IBinding rbinding;
protected final IIndexFragmentBinding rbinding;
public CompositeIndexBinding(ICompositesFactory cf, IBinding rbinding) {
public CompositeIndexBinding(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
if(rbinding == null || cf == null)
throw new IllegalArgumentException();
this.cf = cf;
@ -69,7 +70,7 @@ public abstract class CompositeIndexBinding implements IIndexBinding {
}
public IScope getScope() throws DOMException {
return cf.getCompositeScope(rbinding.getScope());
return cf.getCompositeScope((IIndexScope)rbinding.getScope());
}
public boolean hasDefinition() throws CoreException {

View file

@ -10,10 +10,14 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPCompositeBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope;
public abstract class CompositeScope implements IIndexScope {
@ -27,9 +31,9 @@ public abstract class CompositeScope implements IIndexScope {
* and some ignore it as a representative binding from each fragment is needed to meet interface
* contracts.
*/
protected final IBinding rbinding;
protected final IIndexFragmentBinding rbinding;
public CompositeScope(ICompositesFactory cf, IBinding rbinding) {
public CompositeScope(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
if(cf==null || rbinding==null)
throw new NullPointerException();
this.cf = cf;
@ -37,15 +41,14 @@ public abstract class CompositeScope implements IIndexScope {
}
final public IScope getParent() throws DOMException {
IScope rscope = rbinding.getScope();
IIndexScope rscope = (IIndexScope) rbinding.getScope();
if(rscope!=null) {
return cf.getCompositeScope(rscope);
}
return null;
}
// Note: for c++ namespaces we are returning an arbitrary name
final public IName getScopeName() throws DOMException {
public IName getScopeName() throws DOMException {
if(rbinding instanceof IScope)
return ((IScope) rbinding).getScopeName();
return null;
@ -59,4 +62,39 @@ public abstract class CompositeScope implements IIndexScope {
public IBinding getRawScopeBinding() {
return rbinding;
}
/**
* For bindings that are not known statically to be index bindings, we must decide how to
* process them by run-time type. This method processes a single binding accordingly.
* @param binding
* @return
*/
protected final IBinding processUncertainBinding(IBinding binding) {
if(binding instanceof IIndexFragmentBinding) {
return cf.getCompositeBinding((IIndexFragmentBinding)binding);
} else if(binding instanceof ProblemBinding) {
return binding;
} else if(binding instanceof CPPCompositeBinding /* AST composite */) {
return new CPPCompositeBinding(
processUncertainBindings(((CPPCompositeBinding)binding).getBindings())
);
} else if(binding == null) {
return null;
}
CCorePlugin.log("CompositeFactory unsure how to process: "+binding.getClass().getName()); //$NON-NLS-1$
return binding;
}
/**
* A convenience method for processing an array of bindings with {@link CompositeScope#processUncertainBinding(IBinding)}
* @param fragmentBindings
* @return
*/
protected final IBinding[] processUncertainBindings(IBinding[] fragmentBindings) {
IBinding[] result= new IBinding[fragmentBindings.length];
for(int i=0; i<result.length; i++) {
result[i]= processUncertainBinding(fragmentBindings[i]);
}
return result;
}
}

View file

@ -40,7 +40,7 @@ public abstract class CompositeType implements IType, IIndexType, ITypeContainer
}
public final IType getType() throws DOMException {
return cf.getCompositeType(type.getType());
return cf.getCompositeType((IIndexType)type.getType());
}
protected void fail() {

View file

@ -11,15 +11,16 @@
package org.eclipse.cdt.internal.core.index.composite;
import org.eclipse.cdt.core.dom.ast.DOMException;
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.index.IIndexBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.index.IIndexType;
public interface ICompositesFactory {
public IScope getCompositeScope(IScope rscope) throws DOMException;
public IScope getCompositeScope(IIndexScope rscope) throws DOMException;
/**
* Returns a composite (in the sense of potentially spanning multiple index fragments - i.e. not to be confused
@ -28,7 +29,7 @@ public interface ICompositesFactory {
* @param type
* @return
*/
public IType getCompositeType(IType rtype) throws DOMException;
public IType getCompositeType(IIndexType rtype) throws DOMException;
/**
* Returns a composite (index context carrying) binding for the specified binding. It does not
@ -38,16 +39,8 @@ public interface ICompositesFactory {
* binding methods
* @return a composite (index context carrying) binding for the specified binding
*/
public IIndexBinding getCompositeBinding(IBinding binding);
public IIndexBinding getCompositeBinding(IIndexFragmentBinding binding);
/**
* A convenience method that operates as getCompositeBinding but over the contents of an array
* @param index the context to construct the composite binding for
* @param bindings an array of composite bindings to use when pair-wise constructing the result via getCompositeBinding
* @return an array of composite bindings pair-wise constructed via getCompositeBinding
*/
public IIndexBinding[] getCompositeBindings(IBinding[] bindings);
/**
* Identifies common bindings, calls getCompositeBindings
* @param index

View file

@ -14,7 +14,6 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
@ -31,6 +30,8 @@ import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.AbstractCompositeFactory;
import org.eclipse.cdt.internal.core.index.composite.CompositeArrayType;
import org.eclipse.cdt.internal.core.index.composite.CompositePointerType;
@ -47,7 +48,7 @@ public class CCompositesFactory extends AbstractCompositeFactory implements ICom
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeScope(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IScope)
*/
public IScope getCompositeScope(IScope rscope) {
public IScope getCompositeScope(IIndexScope rscope) {
if(rscope==null)
return null;
if(rscope instanceof ICCompositeTypeScope) {
@ -65,7 +66,7 @@ public class CCompositesFactory extends AbstractCompositeFactory implements ICom
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeType(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IType)
*/
public IType getCompositeType(IType rtype) throws DOMException {
public IType getCompositeType(IIndexType rtype) throws DOMException {
IType result;
if(rtype==null) {
@ -95,7 +96,7 @@ public class CCompositesFactory extends AbstractCompositeFactory implements ICom
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeBinding(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IBinding)
*/
public IIndexBinding getCompositeBinding(IBinding rbinding) {
public IIndexBinding getCompositeBinding(IIndexFragmentBinding rbinding) {
IIndexBinding result;
if(rbinding==null) {

View file

@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.c;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.composite.CompositeIndexBinding;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
abstract class CompositeCBinding extends CompositeIndexBinding {
public CompositeCBinding(ICompositesFactory cf, IBinding rbinding) {
public CompositeCBinding(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
super(cf, rbinding);
}
}

View file

@ -14,17 +14,15 @@ 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.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.composite.CompositeScope;
import org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCCompositeScope extends CompositeScope implements ICCompositeTypeScope {
public CompositeCCompositeScope(ICompositesFactory cf, IBinding rbinding) {
public CompositeCCompositeScope(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
super(cf, rbinding);
}
@ -38,25 +36,18 @@ class CompositeCCompositeScope extends CompositeScope implements ICCompositeType
public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
IBinding binding = ((ICompositeType)rbinding).getCompositeScope().getBinding(name, resolve);
if(binding instanceof IIndexFragmentBinding) {
IIndexFragmentBinding preresult = (IIndexFragmentBinding) binding;
return cf.getCompositeBinding(preresult);
}
if(binding!=null && !(binding instanceof IProblemBinding)) {
throw new CompositingNotImplementedError(binding.getClass().toString());
}
return binding;
return processUncertainBinding(binding);
}
public IBinding[] find(String name, boolean prefixLookup)
throws DOMException {
IBinding[] preresult = ((ICompositeType)rbinding).getCompositeScope().find(name, prefixLookup);
return cf.getCompositeBindings(preresult);
return processUncertainBindings(preresult);
}
public IBinding[] find(String name) throws DOMException {
IBinding[] preresult = ((ICompositeType)rbinding).getCompositeScope().find(name);
return cf.getCompositeBindings(preresult);
return processUncertainBindings(preresult);
}
public IIndexBinding getScopeBinding() {

View file

@ -11,18 +11,19 @@
package org.eclipse.cdt.internal.core.index.composite.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCEnumerator extends CompositeCBinding implements IIndexBinding, IEnumerator {
public CompositeCEnumerator(ICompositesFactory cf, IBinding rbinding) {
public CompositeCEnumerator(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
super(cf, rbinding);
}
public IType getType() throws DOMException {
return cf.getCompositeType(((IEnumerator)rbinding).getType());
return cf.getCompositeType((IIndexType)((IEnumerator)rbinding).getType());
}
}

View file

@ -15,15 +15,16 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCField extends CompositeCVariable implements IIndexBinding, IField {
public CompositeCField(ICompositesFactory cf, IBinding rbinding) {
public CompositeCField(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
super(cf, rbinding);
}
public ICompositeType getCompositeTypeOwner() throws DOMException {
IBinding preresult = ((IField)rbinding).getCompositeTypeOwner();
return (ICompositeType) cf.getCompositeBinding(preresult);
return (ICompositeType) cf.getCompositeBinding((IIndexFragmentBinding)preresult);
}
}

View file

@ -11,18 +11,19 @@
package org.eclipse.cdt.internal.core.index.composite.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCFunction extends CompositeCBinding implements IIndexBinding, IFunction {
public CompositeCFunction(ICompositesFactory cf, IBinding rbinding) {
public CompositeCFunction(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
super(cf, rbinding);
}
@ -32,11 +33,11 @@ class CompositeCFunction extends CompositeCBinding implements IIndexBinding, IFu
IParameter[] preResult = ((IFunction)rbinding).getParameters();
IParameter[] result = new IParameter[preResult.length];
for(int i=0; i<preResult.length; i++) {
result[i] = (IParameter) cf.getCompositeBinding(preResult[i]);
result[i] = (IParameter) cf.getCompositeBinding((IIndexFragmentBinding) preResult[i]);
}
return result;
}
public IFunctionType getType() throws DOMException {
/* @see PDOMCFunction.getType() */
return new IFunctionType() {
@ -45,18 +46,22 @@ class CompositeCFunction extends CompositeCBinding implements IIndexBinding, IFu
IType[] result = new IType[preresult.length];
for(int i=0; i<preresult.length; i++) {
assert preresult!=null;
result[i] = cf.getCompositeType(preresult[i]);
result[i] = cf.getCompositeType((IIndexType)preresult[i]);
}
return result;
}
public IType getReturnType() throws DOMException {
IType type = ((IFunctionType)rbinding).getReturnType();
return cf.getCompositeType(type);
IType type = ((IFunction)rbinding).getType().getReturnType();
return cf.getCompositeType((IIndexType)type);
}
public boolean isSameType(IType type) {
return ((IFunctionType)rbinding).isSameType(type);
try {
return ((IFunction)rbinding).getType().isSameType(type);
} catch(DOMException de) {
return false;
}
}
public Object clone() {fail(); return null;}

View file

@ -11,21 +11,22 @@
package org.eclipse.cdt.internal.core.index.composite.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCParameter extends CompositeCBinding implements IIndexBinding, IParameter {
public CompositeCParameter(ICompositesFactory cf, IBinding rbinding) {
public CompositeCParameter(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
super(cf, rbinding);
}
public IType getType() throws DOMException {
IType rtype = ((IParameter)rbinding).getType();
return cf.getCompositeType(rtype);
return cf.getCompositeType((IIndexType)rtype);
}
public boolean isAuto() throws DOMException {

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.internal.core.index.composite.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope;
@ -23,7 +22,7 @@ import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCStructure extends CompositeCBinding implements IIndexBinding, ICompositeType, IIndexType {
public CompositeCStructure(ICompositesFactory cf, IBinding rbinding) {
public CompositeCStructure(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
super(cf, rbinding);
}

View file

@ -11,21 +11,21 @@
package org.eclipse.cdt.internal.core.index.composite.c;
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.ITypedef;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCTypedef extends CompositeCBinding implements ITypedef, IIndexType, ITypeContainer {
public CompositeCTypedef(ICompositesFactory cf, IBinding rbinding) {
public CompositeCTypedef(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
super(cf, rbinding);
}
public IType getType() throws DOMException {
IType type = ((ITypedef)rbinding).getType();
return cf.getCompositeType(type);
return cf.getCompositeType((IIndexType)type);
}
public boolean isSameType(IType type) {

View file

@ -11,21 +11,22 @@
package org.eclipse.cdt.internal.core.index.composite.c;
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.IVariable;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCVariable extends CompositeCBinding implements IIndexBinding, IVariable {
public CompositeCVariable(ICompositesFactory cf, IBinding rbinding) {
public CompositeCVariable(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
super(cf, rbinding);
}
public IType getType() throws DOMException {
IType rtype = ((IVariable)rbinding).getType();
return cf.getCompositeType(rtype);
return cf.getCompositeType((IIndexType)rtype);
}
public boolean isAuto() throws DOMException {

View file

@ -40,7 +40,8 @@ import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.index.CIndex;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.AbstractCompositeFactory;
import org.eclipse.cdt.internal.core.index.composite.CompositeArrayType;
import org.eclipse.cdt.internal.core.index.composite.CompositePointerType;
@ -54,41 +55,46 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
public CPPCompositesFactory(IIndex index) {
super(index);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeScope(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IScope)
*/
public IScope getCompositeScope(IScope rscope) throws DOMException {
public IScope getCompositeScope(IIndexScope rscope) throws DOMException {
IScope result;
if(rscope == null) {
return null;
} else if(rscope instanceof ICPPClassScope) {
ICPPClassScope classScope = (ICPPClassScope) rscope;
result = new CompositeCPPClassScope(this,
findOneDefinition(classScope.getClassType()));
} else if(rscope instanceof ICPPNamespaceScope) {
ICPPNamespaceScope nScope = (ICPPNamespaceScope) rscope;
try {
IBinding binding = ((IIndexFragmentName) nScope.getScopeName()).getBinding();
result = ((ICPPNamespace)binding).getNamespaceScope();
} catch(CoreException ce) {
CCorePlugin.log(ce);
throw new CompositingNotImplementedError(ce.getMessage());
try {
if(rscope == null) {
return null;
} else if(rscope instanceof ICPPClassScope) {
ICPPClassScope classScope = (ICPPClassScope) rscope;
result = new CompositeCPPClassScope(this,
findOneDefinition(classScope.getClassType()));
} else if(rscope instanceof ICPPNamespaceScope) {
ICPPNamespace[] namespaces;
if(rscope instanceof CompositeCPPNamespace) {
// avoid duplicating the search
namespaces = ((CompositeCPPNamespace)rscope).namespaces;
} else {
namespaces = getNamespaces(rscope.getScopeBinding());
}
return new CompositeCPPNamespaceScope(this, namespaces);
} else {
throw new CompositingNotImplementedError();
}
} else {
throw new CompositingNotImplementedError();
}
} catch(CoreException ce) {
CCorePlugin.log(ce);
throw new CompositingNotImplementedError(ce.getMessage());
}
return result;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeType(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IType)
*/
public IType getCompositeType(IType rtype) throws DOMException {
public IType getCompositeType(IIndexType rtype) throws DOMException {
IType result;
if(rtype instanceof ICPPClassType) {
result = (ICPPClassType) getCompositeBinding((IIndexFragmentBinding) rtype);
} else if(rtype instanceof ITypedef) {
@ -116,7 +122,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
return result;
}
private ICPPNamespace[] getNamespaces(IBinding rbinding) throws CoreException {
CIndex cindex = (CIndex) index;
IIndexBinding[] ibs = cindex.findEquivalentBindings(rbinding);
@ -129,7 +135,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeBinding(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IBinding)
*/
public IIndexBinding getCompositeBinding(IBinding binding) {
public IIndexBinding getCompositeBinding(IIndexFragmentBinding binding) {
IIndexBinding result;
try {
@ -169,7 +175,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
CCorePlugin.log(ce);
throw new CompositingNotImplementedError(ce.getMessage());
}
return result;
}
}

View file

@ -14,19 +14,16 @@ import org.eclipse.cdt.core.CCorePlugin;
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.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPCompositeBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.composite.CompositeScope;
import org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCPPClassScope extends CompositeScope implements ICPPClassScope {
public CompositeCPPClassScope(ICompositesFactory cf, IBinding rbinding) {
public CompositeCPPClassScope(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
super(cf, rbinding);
}
@ -39,7 +36,7 @@ class CompositeCPPClassScope extends CompositeScope implements ICPPClassScope {
ICPPClassScope rscope = (ICPPClassScope) ((ICPPClassType)rbinding).getCompositeScope();
ICPPMethod[] result = rscope.getImplicitMethods();
for(int i=0; i<result.length; i++) {
result[i] = (ICPPMethod) cf.getCompositeBinding(result[i]);
result[i] = (ICPPMethod) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
}
return result;
} catch (DOMException de) {
@ -50,29 +47,18 @@ class CompositeCPPClassScope extends CompositeScope implements ICPPClassScope {
public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
IBinding binding = ((ICPPClassType)rbinding).getCompositeScope().getBinding(name, resolve);
if(binding instanceof IIndexFragmentBinding) {
return cf.getCompositeBinding((IIndexFragmentBinding) binding);
}
if(binding instanceof CPPCompositeBinding /* AST composite */) {
return new CPPCompositeBinding(
cf.getCompositeBindings(((CPPCompositeBinding)binding).getBindings())
);
}
if(binding!=null && !(binding instanceof IProblemBinding)) {
throw new CompositingNotImplementedError(binding.getClass().toString());
}
return binding;
return processUncertainBinding(binding);
}
public IBinding[] find(String name, boolean prefixLookup)
throws DOMException {
IBinding[] preresult = ((ICPPClassType)rbinding).getCompositeScope().find(name, prefixLookup);
return cf.getCompositeBindings(preresult);
return processUncertainBindings(preresult);
}
public IBinding[] find(String name) throws DOMException {
IBinding[] preresult = ((ICPPClassType)rbinding).getCompositeScope().find(name);
return cf.getCompositeBindings(preresult);
return processUncertainBindings(preresult);
}
public IIndexBinding getScopeBinding() {

View file

@ -21,6 +21,7 @@ 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.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
@ -35,14 +36,13 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
public IField findField(String name) throws DOMException {
IField preResult = ((ICPPClassType)rbinding).findField(name);
return (IField) cf.getCompositeBinding(preResult);
return (IField) cf.getCompositeBinding((IIndexFragmentBinding)preResult);
}
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
ICPPMethod[] preResult = ((ICPPClassType)rbinding).getAllDeclaredMethods();
ICPPMethod[] result = new ICPPMethod[preResult.length];
for(int i=0; i<preResult.length; i++) {
result[i] = (ICPPMethod) cf.getCompositeBinding(preResult[i]);
ICPPMethod[] result = ((ICPPClassType)rbinding).getAllDeclaredMethods();
for(int i=0; i<result.length; i++) {
result[i] = (ICPPMethod) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
}
return result;
}
@ -54,7 +54,7 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
final int n = i;
result[i] = new ICPPBase() {
public IBinding getBaseClass() throws DOMException {
return cf.getCompositeBinding(preresult[n].getBaseClass());
return cf.getCompositeBinding((IIndexFragmentBinding)preresult[n].getBaseClass());
}
public int getVisibility() throws DOMException {
@ -74,37 +74,33 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
}
public ICPPConstructor[] getConstructors() throws DOMException {
ICPPConstructor[] preResult = ((ICPPClassType)rbinding).getConstructors();
ICPPConstructor[] result = new ICPPConstructor[preResult.length];
for(int i=0; i<preResult.length; i++) {
result[i] = (ICPPConstructor) cf.getCompositeBinding(preResult[i]);
ICPPConstructor[] result = ((ICPPClassType)rbinding).getConstructors();
for(int i=0; i<result.length; i++) {
result[i] = (ICPPConstructor) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
}
return result;
}
public ICPPField[] getDeclaredFields() throws DOMException {
ICPPField[] preResult = ((ICPPClassType)rbinding).getDeclaredFields();
ICPPField[] result = new ICPPField[preResult.length];
for(int i=0; i<preResult.length; i++) {
result[i] = (ICPPField) cf.getCompositeBinding(preResult[i]);
ICPPField[] result = ((ICPPClassType)rbinding).getDeclaredFields();
for(int i=0; i<result.length; i++) {
result[i] = (ICPPField) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
}
return result;
}
public ICPPMethod[] getDeclaredMethods() throws DOMException {
ICPPMethod[] preResult = ((ICPPClassType)rbinding).getDeclaredMethods();
ICPPMethod[] result = new ICPPMethod[preResult.length];
for(int i=0; i<preResult.length; i++) {
result[i] = (ICPPMethod) cf.getCompositeBinding(preResult[i]);
ICPPMethod[] result = ((ICPPClassType)rbinding).getDeclaredMethods();
for(int i=0; i<result.length; i++) {
result[i]= (ICPPMethod) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
}
return result;
}
public IField[] getFields() throws DOMException {
IField[] preResult = ((ICPPClassType)rbinding).getFields();
IField[] result = new IField[preResult.length];
for(int i=0; i<preResult.length; i++) {
result[i] = (IField) cf.getCompositeBinding(preResult[i]);
IField[] result = ((ICPPClassType)rbinding).getFields();
for(int i=0; i<result.length; i++) {
result[i]= (IField) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
}
return result;
}
@ -113,7 +109,7 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
IBinding[] preResult = ((ICPPClassType)rbinding).getFriends();
IBinding[] result = new IBinding[preResult.length];
for(int i=0; i<preResult.length; i++) {
result[i] = cf.getCompositeBinding(preResult[i]);
result[i] = cf.getCompositeBinding((IIndexFragmentBinding) preResult[i]);
}
return result;
}
@ -121,16 +117,15 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
public ICPPMethod[] getMethods() throws DOMException {
ICPPMethod[] result = ((ICPPClassType)rbinding).getMethods();
for(int i=0; i<result.length; i++) {
result[i] = (ICPPMethod) cf.getCompositeBinding(result[i]);
result[i] = (ICPPMethod) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
}
return result;
}
public ICPPClassType[] getNestedClasses() throws DOMException {
ICPPClassType[] preResult = ((ICPPClassType)rbinding).getNestedClasses();
ICPPClassType[] result = new ICPPClassType[preResult.length];
for(int i=0; i<preResult.length; i++) {
result[i] = (ICPPClassType) cf.getCompositeBinding(preResult[i]);
ICPPClassType[] result = ((ICPPClassType)rbinding).getNestedClasses();
for(int i=0; i<result.length; i++) {
result[i] = (ICPPClassType) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
}
return result;
}

View file

@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCPPEnumerator extends CompositeCPPBinding implements IEnumerator {
@ -23,6 +24,6 @@ class CompositeCPPEnumerator extends CompositeCPPBinding implements IEnumerator
public IType getType() throws DOMException {
IType type = ((IEnumerator)rbinding).getType();
return cf.getCompositeType(type);
return cf.getCompositeType((IIndexType)type);
}
}

View file

@ -35,6 +35,6 @@ class CompositeCPPField extends CompositeCPPVariable implements ICPPField {
public ICompositeType getCompositeTypeOwner() throws DOMException {
IBinding preresult = ((IField)rbinding).getCompositeTypeOwner();
return (ICompositeType) cf.getCompositeBinding(preresult);
return (ICompositeType) cf.getCompositeBinding((IIndexFragmentBinding) preresult);
}
}

View file

@ -83,13 +83,13 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction,
public IType[] getParameterTypes() throws DOMException {
IType[] result = ((ICPPFunctionType)rbinding).getParameterTypes();
for(int i=0; i<result.length; i++) {
result[i] = cf.getCompositeType(result[i]);
result[i] = cf.getCompositeType((IIndexType)result[i]);
}
return result;
}
public IType getReturnType() throws DOMException {
return cf.getCompositeType(((ICPPFunctionType)rbinding).getReturnType());
return cf.getCompositeType((IIndexType)((ICPPFunctionType)rbinding).getReturnType());
}
public boolean isSameType(IType type) {

View file

@ -10,10 +10,12 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.IName;
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.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.index.IIndexBinding;
@ -25,7 +27,7 @@ class CompositeCPPNamespaceScope extends CompositeScope implements ICPPNamespace
ICPPNamespace[] namespaces;
public CompositeCPPNamespaceScope(ICompositesFactory cf, ICPPNamespace[] namespaces) {
super(cf, namespaces[0]);
super(cf, (IIndexFragmentBinding) namespaces[0]);
this.namespaces = namespaces;
}
@ -39,11 +41,11 @@ class CompositeCPPNamespaceScope extends CompositeScope implements ICPPNamespace
public IBinding getBinding(IASTName name, boolean resolve)
throws DOMException {
IIndexFragmentBinding preresult = null;
IBinding preresult = null;
for(int i=0; preresult==null && i<namespaces.length; i++) {
preresult = (IIndexFragmentBinding) namespaces[i].getNamespaceScope().getBinding(name, resolve);
preresult = namespaces[i].getNamespaceScope().getBinding(name, resolve);
}
return cf.getCompositeBinding(preresult);
return processUncertainBinding(preresult);
}
final public IBinding[] find(String name) throws DOMException {
@ -69,4 +71,16 @@ class CompositeCPPNamespaceScope extends CompositeScope implements ICPPNamespace
public IIndexBinding getScopeBinding() {
return cf.getCompositeBinding(rbinding);
}
public IName getScopeName() throws DOMException {
for(int i=0; i<namespaces.length; i++) {
if(namespaces[i] instanceof IScope) {
IScope s= (IScope) namespaces[i];
IName nm= s.getScopeName();
if(nm!=null)
return nm;
}
}
return null;
}
}

View file

@ -25,7 +25,7 @@ class CompositeCPPTypedef extends CompositeCPPBinding implements ITypedef, IInde
public IType getType() throws DOMException {
IType type = ((ITypedef)rbinding).getType();
return cf.getCompositeType(type);
return cf.getCompositeType((IIndexType)type);
}
public boolean isSameType(IType type) {

View file

@ -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.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
class CompositeCPPVariable extends CompositeCPPBinding implements ICPPVariable {
@ -27,7 +28,7 @@ class CompositeCPPVariable extends CompositeCPPBinding implements ICPPVariable {
public IType getType() throws DOMException {
IType rtype = ((ICPPVariable)rbinding).getType();
return cf.getCompositeType(rtype);
return cf.getCompositeType((IIndexType)rtype);
}
public boolean isAuto() throws DOMException {

View file

@ -21,6 +21,8 @@ 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.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
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.PDOMLinkage;
@ -34,7 +36,7 @@ import org.eclipse.core.runtime.CoreException;
*
* @author Doug Schaefer
*/
class PDOMCParameter extends PDOMNamedNode implements IParameter {
class PDOMCParameter extends PDOMNamedNode implements IParameter, IIndexFragmentBinding {
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE + 0;
private static final int TYPE = PDOMNamedNode.RECORD_SIZE + 4;
@ -137,4 +139,33 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter {
return new char[0];
}
}
public IIndexFragment getFragment() {
return pdom;
}
public boolean hasDefinition() throws CoreException {
// parameter bindings do not span index fragments
return true;
}
public int compareTo(Object arg0) {
throw new PDOMNotImplementedError();
}
public boolean isFileLocal() throws CoreException {
return true;
}
public String[] getQualifiedName() {
throw new PDOMNotImplementedError();
}
public char[][] getQualifiedNameCharArray() throws DOMException {
throw new PDOMNotImplementedError();
}
public boolean isGloballyQualified() throws DOMException {
throw new PDOMNotImplementedError();
}
}