assertNotNull(num);
assertEquals(1, num.longValue());
}
+
+ // template<typename T>
+ // struct meta {
+ // enum {
+ // a = T::value,
+ // b = a
+ // };
+ // };
+
+ // struct S {
+ // static const int value = 42;
+ // };
+ //
+ // template <int> struct waldo;
+ //
+ // template <>
+ // struct waldo<42> {
+ // double operator()();
+ // };
+ //
+ // template <typename>
+ // struct C : public waldo<meta<S>::b> {};
+ //
+ // void bar(double);
+ //
+ // void foo(C<S> x){
+ // bar(x());
+ // }
+ public void testDependentEnumerator_482421a() throws Exception {
+ checkBindings();
+ }
+
+ // template<typename T>
+ // struct meta {
+ // enum {
+ // b = T::value,
+ // a = b
+ // };
+ // };
+
+ // struct S {
+ // static const int value = 42;
+ // };
+ //
+ // template <int> struct waldo;
+ //
+ // template <>
+ // struct waldo<42> {
+ // double operator()();
+ // };
+ //
+ // template <typename>
+ // struct C : public waldo<meta<S>::a> {};
+ //
+ // void bar(double);
+ //
+ // void foo(C<S> x){
+ // bar(x());
+ // }
+ public void testDependentEnumerator_482421b() throws Exception {
+ checkBindings();
+ }
// template<typename U>
// struct A {
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
+import java.util.List;
+
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
import org.eclipse.cdt.core.index.IIndexName;
-import org.eclipse.cdt.core.parser.util.CharArrayMap;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding;
/**
* Called by the scope to access the enumerators.
+ * Returns the enumerators in the order of declaration.
*/
- void loadEnumerators(CharArrayMap<IPDOMCPPEnumerator> map);
+ void loadEnumerators(List<IPDOMCPPEnumerator> enumerators);
}
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
if (map == null) {
// there is no cache, build it:
- map= new CharArrayMap<IPDOMCPPEnumerator>();
- enumeration.loadEnumerators(map);
+ List<IPDOMCPPEnumerator> enumerators = new ArrayList<>();
+ enumeration.loadEnumerators(enumerators);
+ map = new CharArrayMap<IPDOMCPPEnumerator>();
+ for (IPDOMCPPEnumerator enumerator : enumerators) {
+ map.put(enumerator.getNameCharArray(), enumerator);
+ }
pdom.putCachedResult(key, new SoftReference<CharArrayMap<?>>(map));
}
return map;
public static IEnumerator[] getEnumerators(IPDOMCPPEnumType enumType) {
try {
- CharArrayMap<IPDOMCPPEnumerator> map = getBindingMap(enumType);
+ // We want to return the enumerators in order of declaration, so we don't
+ // use the cache (getBindingsMap()) which stores them in a hash map and thus
+ // loses the order.
+ List<IPDOMCPPEnumerator> enumerators = new ArrayList<>();
+ enumType.loadEnumerators(enumerators);
List<IEnumerator> result= new ArrayList<IEnumerator>();
- for (IEnumerator value : map.values()) {
+ for (IEnumerator value : enumerators) {
if (IndexFilter.ALL_DECLARED.acceptBinding(value)) {
result.add(value);
}
}
- Collections.reverse(result);
return result.toArray(new IEnumerator[result.size()]);
} catch (CoreException e) {
CCorePlugin.log(e);
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
+import java.util.List;
+
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
-import org.eclipse.cdt.core.parser.util.CharArrayMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
}
@Override
- public void loadEnumerators(final CharArrayMap<IPDOMCPPEnumerator> map) {
+ public void loadEnumerators(final List<IPDOMCPPEnumerator> enumerators) {
try {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
list.accept(new IPDOMVisitor() {
@Override
public boolean visit(IPDOMNode node) throws CoreException {
if (node instanceof IPDOMCPPEnumerator) {
- final IPDOMCPPEnumerator item = (IPDOMCPPEnumerator) node;
- map.put(item.getNameCharArray(), item);
+ enumerators.add((IPDOMCPPEnumerator) node);
}
return true;
}
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
+import java.util.List;
+
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
-import org.eclipse.cdt.core.parser.util.CharArrayMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
}
@Override
- public void loadEnumerators(final CharArrayMap<IPDOMCPPEnumerator> map) {
+ public void loadEnumerators(final List<IPDOMCPPEnumerator> enumerators) {
try {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + OFFSET_ENUMERATOR_LIST);
list.accept(new IPDOMVisitor() {
@Override
public boolean visit(IPDOMNode node) throws CoreException {
if (node instanceof IPDOMCPPEnumerator) {
- final IPDOMCPPEnumerator item = (IPDOMCPPEnumerator) node;
- map.put(item.getNameCharArray(), item);
+ enumerators.add((IPDOMCPPEnumerator) node);
}
return true;
}