mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Bug 511427 - ClassCastException in CompositeCPPClassType.wrapBindings()
Change-Id: Id02d59a67b98131aaa4afc8936f89d0985ef93cf
This commit is contained in:
parent
27775e3393
commit
0d35254d82
2 changed files with 20 additions and 2 deletions
|
@ -12,11 +12,14 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -130,4 +133,19 @@ public abstract class CompositeIndexBinding implements IIndexBinding {
|
|||
public IIndexBinding getRawBinding() {
|
||||
return rbinding;
|
||||
}
|
||||
|
||||
protected IIndexFragmentBinding adaptBinding(IBinding binding) {
|
||||
if (binding instanceof IIndexFragmentBinding) {
|
||||
return (IIndexFragmentBinding) binding;
|
||||
}
|
||||
ILinkage linkage = rbinding.getLinkage();
|
||||
if (linkage instanceof PDOMLinkage) {
|
||||
try {
|
||||
return ((PDOMLinkage) linkage).adaptBinding(binding);
|
||||
} catch(CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ 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.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
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;
|
||||
|
||||
|
@ -213,7 +212,8 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
|||
protected <T extends IBinding> T[] wrapBindings(T[] bindings) {
|
||||
T[] result = Arrays.copyOf(bindings, bindings.length);
|
||||
for (int i= 0; i < bindings.length; i++) {
|
||||
result[i] = (T) cf.getCompositeBinding((IIndexFragmentBinding) bindings[i]);
|
||||
// Cannot assume the incoming binding is an index binding in all cases.
|
||||
result[i] = (T) cf.getCompositeBinding(adaptBinding(bindings[i]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue