Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2017-01-31 19:56:59 -0500
committerNathan Ridge2017-02-11 20:04:01 -0500
commita0820d3efd61ee1d6240bdc1017677296267aefc (patch)
tree47777e490396a4d70492ca3128a78b366f659b43
parenteaca7d04a521390ead79fef93f790aaefcd440cb (diff)
downloadorg.eclipse.cdt-a0820d3efd61ee1d6240bdc1017677296267aefc.tar.gz
org.eclipse.cdt-a0820d3efd61ee1d6240bdc1017677296267aefc.tar.xz
org.eclipse.cdt-a0820d3efd61ee1d6240bdc1017677296267aefc.zip
Bug 511427 - ClassCastException in CompositeCPPClassType.wrapBindings()
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeIndexBinding.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java4
2 files changed, 20 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeIndexBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeIndexBinding.java
index f6c535c112..71405a40f3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeIndexBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/CompositeIndexBinding.java
@@ -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;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java
index c828c13a7d..56c449f823 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java
@@ -29,7 +29,6 @@ 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.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;
@@ -206,7 +205,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;
}

Back to the top