mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 354086: CCE in composite index.
This commit is contained in:
parent
ea5c5cf0d9
commit
fa05cfd37d
4 changed files with 52 additions and 50 deletions
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
@ -1829,5 +1830,40 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
assertTrue(reference instanceof ICPPSpecialization);
|
assertTrue(reference instanceof ICPPSpecialization);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename T> struct Base {
|
||||||
|
// int bfield;
|
||||||
|
// void bmethod();
|
||||||
|
// };
|
||||||
|
// template<typename T> struct XT : Base<T> {
|
||||||
|
// int field;
|
||||||
|
// void method() {};
|
||||||
|
// friend void f();
|
||||||
|
// struct Nested {};
|
||||||
|
// };
|
||||||
|
// struct TXT : XT<int> {};
|
||||||
|
|
||||||
|
// TXT x;
|
||||||
|
public void testClassSpecialization_Bug354086() throws Exception {
|
||||||
|
ICPPClassType ct= getBindingFromASTName("TXT", 0, ICPPClassType.class);
|
||||||
|
ICPPMethod[] methods = ct.getAllDeclaredMethods();
|
||||||
|
assertEquals(2, methods.length);
|
||||||
|
|
||||||
|
methods= ct.getConstructors();
|
||||||
|
assertEquals(2, methods.length);
|
||||||
|
|
||||||
|
methods= ct.getMethods();
|
||||||
|
assertEquals(14, methods.length);
|
||||||
|
|
||||||
|
ICPPBase[] bases = ct.getBases();
|
||||||
|
assertEquals(1, bases.length);
|
||||||
|
|
||||||
|
IField field = ct.findField("bfield");
|
||||||
|
assertNotNull(field);
|
||||||
|
|
||||||
|
IField[] fields = ct.getFields();
|
||||||
|
assertEquals(2, fields.length);
|
||||||
|
|
||||||
|
IBinding[] friends = ct.getFriends();
|
||||||
|
assertEquals(0, friends.length); // not yet supported
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,7 +425,7 @@ public class ClassTypeHelper {
|
||||||
IField[] fields = ct.getDeclaredFields();
|
IField[] fields = ct.getDeclaredFields();
|
||||||
ICPPClassType[] bases = getAllBases(ct);
|
ICPPClassType[] bases = getAllBases(ct);
|
||||||
for (ICPPClassType base : bases) {
|
for (ICPPClassType base : bases) {
|
||||||
fields = (IField[]) ArrayUtil.addAll(IField.class, fields, base.getFields());
|
fields = (IField[]) ArrayUtil.addAll(IField.class, fields, base.getDeclaredFields());
|
||||||
}
|
}
|
||||||
return (IField[]) ArrayUtil.trim(IField.class, fields);
|
return (IField[]) ArrayUtil.trim(IField.class, fields);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IField;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||||
|
@ -25,7 +24,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
|
@ -105,7 +103,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPBase[] getBases() {
|
public final ICPPBase[] getBases() {
|
||||||
IScope scope= getCompositeScope();
|
IScope scope= getCompositeScope();
|
||||||
if (scope instanceof ICPPClassSpecializationScope) {
|
if (scope instanceof ICPPClassSpecializationScope) {
|
||||||
return ((ICPPClassSpecializationScope) scope).getBases();
|
return ((ICPPClassSpecializationScope) scope).getBases();
|
||||||
|
@ -114,7 +112,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPConstructor[] getConstructors() {
|
public final ICPPConstructor[] getConstructors() {
|
||||||
IScope scope= getCompositeScope();
|
IScope scope= getCompositeScope();
|
||||||
if (scope instanceof ICPPClassSpecializationScope) {
|
if (scope instanceof ICPPClassSpecializationScope) {
|
||||||
return ((ICPPClassSpecializationScope) scope).getConstructors();
|
return ((ICPPClassSpecializationScope) scope).getConstructors();
|
||||||
|
@ -123,7 +121,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPMethod[] getDeclaredMethods() {
|
public final ICPPMethod[] getDeclaredMethods() {
|
||||||
IScope scope= getCompositeScope();
|
IScope scope= getCompositeScope();
|
||||||
if (scope instanceof ICPPClassSpecializationScope) {
|
if (scope instanceof ICPPClassSpecializationScope) {
|
||||||
return ((ICPPClassSpecializationScope) scope).getDeclaredMethods();
|
return ((ICPPClassSpecializationScope) scope).getDeclaredMethods();
|
||||||
|
@ -132,7 +130,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPField[] getDeclaredFields() {
|
public final ICPPField[] getDeclaredFields() {
|
||||||
IScope scope= getCompositeScope();
|
IScope scope= getCompositeScope();
|
||||||
if (scope instanceof ICPPClassSpecializationScope) {
|
if (scope instanceof ICPPClassSpecializationScope) {
|
||||||
return ((ICPPClassSpecializationScope) scope).getDeclaredFields();
|
return ((ICPPClassSpecializationScope) scope).getDeclaredFields();
|
||||||
|
@ -141,7 +139,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinding[] getFriends() {
|
public final IBinding[] getFriends() {
|
||||||
IScope scope= getCompositeScope();
|
IScope scope= getCompositeScope();
|
||||||
if (scope instanceof ICPPClassSpecializationScope) {
|
if (scope instanceof ICPPClassSpecializationScope) {
|
||||||
return ((ICPPClassSpecializationScope) scope).getFriends();
|
return ((ICPPClassSpecializationScope) scope).getFriends();
|
||||||
|
@ -150,7 +148,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPClassType[] getNestedClasses() {
|
public final ICPPClassType[] getNestedClasses() {
|
||||||
IScope scope= getCompositeScope();
|
IScope scope= getCompositeScope();
|
||||||
if (scope instanceof ICPPClassSpecializationScope) {
|
if (scope instanceof ICPPClassSpecializationScope) {
|
||||||
return ((ICPPClassSpecializationScope) scope).getNestedClasses();
|
return ((ICPPClassSpecializationScope) scope).getNestedClasses();
|
||||||
|
@ -158,26 +156,6 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
||||||
return super.getNestedClasses();
|
return super.getNestedClasses();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IField findField(String name) {
|
|
||||||
return ClassTypeHelper.findField(this, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ICPPMethod[] getAllDeclaredMethods() {
|
|
||||||
return ClassTypeHelper.getAllDeclaredMethods(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IField[] getFields() {
|
|
||||||
return ClassTypeHelper.getFields(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ICPPMethod[] getMethods() {
|
|
||||||
return ClassTypeHelper.getMethods(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ObjectMap getArgumentMap() {
|
public ObjectMap getArgumentMap() {
|
||||||
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
|
||||||
|
|
|
@ -21,6 +21,7 @@ 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.ICPPField;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
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.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.IIndexFragmentBinding;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
@ -35,17 +36,12 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
||||||
fail(); return null;
|
fail(); return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IField findField(String name) {
|
public final IField findField(String name) {
|
||||||
IField preResult = ((ICPPClassType)rbinding).findField(name);
|
return ClassTypeHelper.findField(this, name);
|
||||||
return (IField) cf.getCompositeBinding((IIndexFragmentBinding)preResult);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPMethod[] getAllDeclaredMethods() {
|
public final ICPPMethod[] getAllDeclaredMethods() {
|
||||||
ICPPMethod[] result = ((ICPPClassType)rbinding).getAllDeclaredMethods();
|
return ClassTypeHelper.getAllDeclaredMethods(this);
|
||||||
for(int i=0; i<result.length; i++) {
|
|
||||||
result[i] = (ICPPMethod) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CPPBaseDelegate implements ICPPBase {
|
private class CPPBaseDelegate implements ICPPBase {
|
||||||
|
@ -129,12 +125,8 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IField[] getFields() {
|
public final IField[] getFields() {
|
||||||
IField[] result = ((ICPPClassType)rbinding).getFields();
|
return ClassTypeHelper.getFields(this);
|
||||||
for(int i=0; i<result.length; i++) {
|
|
||||||
result[i]= (IField) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] getFriends() {
|
public IBinding[] getFriends() {
|
||||||
|
@ -146,12 +138,8 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPMethod[] getMethods() {
|
public final ICPPMethod[] getMethods() {
|
||||||
ICPPMethod[] result = ((ICPPClassType)rbinding).getMethods();
|
return ClassTypeHelper.getMethods(this);
|
||||||
for(int i=0; i<result.length; i++) {
|
|
||||||
result[i] = (ICPPMethod) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPClassType[] getNestedClasses() {
|
public ICPPClassType[] getNestedClasses() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue