1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

180948: fix ClassCastException (follow up)

This commit is contained in:
Andrew Ferguson 2007-04-04 17:23:21 +00:00
parent ca26fe7a9d
commit 19a895a652
3 changed files with 58 additions and 2 deletions

View file

@ -47,7 +47,7 @@ import org.eclipse.core.runtime.CoreException;
* additionally check that the binding obtained has characteristics as * additionally check that the binding obtained has characteristics as
* expected (type,name,etc..) * expected (type,name,etc..)
*/ */
public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBase { public abstract class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBase {
public static class SingleProject extends IndexCPPBindingResolutionTest { public static class SingleProject extends IndexCPPBindingResolutionTest {
public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true));} public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true));}

View file

@ -42,6 +42,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndex;
@ -86,8 +87,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
namespaces = getNamespaces(rscope.getScopeBinding()); namespaces = getNamespaces(rscope.getScopeBinding());
} }
return new CompositeCPPNamespaceScope(this, namespaces); return new CompositeCPPNamespaceScope(this, namespaces);
} else if(rscope instanceof ICPPTemplateScope) {
return new CompositeCPPTemplateScope(this, (ICPPTemplateScope) rscope);
} else { } else {
throw new CompositingNotImplementedError(); throw new CompositingNotImplementedError(rscope.getClass().getName());
} }
} catch(CoreException ce) { } catch(CoreException ce) {
CCorePlugin.log(ce); CCorePlugin.log(ce);

View file

@ -0,0 +1,53 @@
/*******************************************************************************
* 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.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
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.ICompositesFactory;
public class CompositeCPPTemplateScope extends CompositeScope implements ICPPTemplateScope {
public CompositeCPPTemplateScope(ICompositesFactory cf,
ICPPTemplateScope rbinding) {
super(cf, (IIndexFragmentBinding) rbinding);
}
public ICPPTemplateDefinition getTemplateDefinition() throws DOMException {
ICPPTemplateDefinition preresult= ((ICPPTemplateScope) rbinding).getTemplateDefinition();
return (ICPPTemplateDefinition) processUncertainBinding(preresult);
}
public IBinding[] find(String name, boolean prefixLookup)
throws DOMException {
IBinding[] preresult = ((ICPPTemplateScope)rbinding).find(name, prefixLookup);
return processUncertainBindings(preresult);
}
public IBinding[] find(String name) throws DOMException {
IBinding[] preresult = ((ICPPTemplateScope)rbinding).find(name);
return processUncertainBindings(preresult);
}
public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
IBinding binding = ((ICPPTemplateScope)rbinding).getBinding(name, resolve);
return processUncertainBinding(binding);
}
public IIndexBinding getScopeBinding() {
return cf.getCompositeBinding(rbinding);
}
}