mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 299911. Added ICPPClassSpecialization.getBases(IASTNode point)
method to avoid loss of instantiation context.
This commit is contained in:
parent
a86fdeca46
commit
3400d21110
8 changed files with 38 additions and 10 deletions
|
@ -36,4 +36,11 @@ public interface ICPPClassSpecialization extends ICPPSpecialization, ICPPClassTy
|
||||||
* @since 5.5
|
* @since 5.5
|
||||||
*/
|
*/
|
||||||
IBinding specializeMember(IBinding binding, IASTNode point);
|
IBinding specializeMember(IBinding binding, IASTNode point);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to {@link ICPPClassType#getBases()} but a accepts a starting point for template
|
||||||
|
* instantiation.
|
||||||
|
* @since 5.5
|
||||||
|
*/
|
||||||
|
public ICPPBase[] getBases(IASTNode point);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,14 +124,13 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPBase[] getBases() {
|
public ICPPBase[] getBases(IASTNode point) {
|
||||||
if (fBases == null) {
|
if (fBases == null) {
|
||||||
ICPPBase[] result = null;
|
ICPPBase[] result = null;
|
||||||
ICPPBase[] bases = specialClass.getSpecializedBinding().getBases();
|
ICPPBase[] bases = specialClass.getSpecializedBinding().getBases();
|
||||||
if (bases.length == 0) {
|
if (bases.length == 0) {
|
||||||
fBases= bases;
|
fBases= bases;
|
||||||
} else {
|
} else {
|
||||||
IASTNode point= null; // Instantiation of dependent expression may not work.
|
|
||||||
final ICPPTemplateParameterMap tpmap = specialClass.getTemplateParameterMap();
|
final ICPPTemplateParameterMap tpmap = specialClass.getTemplateParameterMap();
|
||||||
for (ICPPBase base : bases) {
|
for (ICPPBase base : bases) {
|
||||||
IBinding origClass = base.getBaseClass();
|
IBinding origClass = base.getBaseClass();
|
||||||
|
|
|
@ -122,11 +122,16 @@ public class CPPClassSpecialization extends CPPSpecialization
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPBase[] getBases() {
|
public ICPPBase[] getBases() {
|
||||||
|
return getBases(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPBase[] getBases(IASTNode point) {
|
||||||
ICPPClassSpecializationScope scope= getSpecializationScope();
|
ICPPClassSpecializationScope scope= getSpecializationScope();
|
||||||
if (scope == null)
|
if (scope == null)
|
||||||
return ClassTypeHelper.getBases(this);
|
return ClassTypeHelper.getBases(this);
|
||||||
|
|
||||||
return scope.getBases();
|
return scope.getBases(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
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;
|
||||||
|
@ -39,7 +40,7 @@ public interface ICPPClassSpecializationScope extends ICPPClassScope {
|
||||||
/**
|
/**
|
||||||
* Computes the bases via the original class.
|
* Computes the bases via the original class.
|
||||||
*/
|
*/
|
||||||
ICPPBase[] getBases();
|
ICPPBase[] getBases(IASTNode point);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the methods via the original class.
|
* Computes the methods via the original class.
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
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;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
@ -182,7 +183,11 @@ class BaseClassLookup {
|
||||||
ICPPClassType baseClass= result.getClassType();
|
ICPPClassType baseClass= result.getClassType();
|
||||||
if (baseClass != null) {
|
if (baseClass != null) {
|
||||||
ICPPBase[] grandBases= null;
|
ICPPBase[] grandBases= null;
|
||||||
grandBases= baseClass.getBases();
|
if (baseClass instanceof ICPPClassSpecialization) {
|
||||||
|
grandBases = ((ICPPClassSpecialization) baseClass).getBases(data.getLookupPoint());
|
||||||
|
} else {
|
||||||
|
grandBases= baseClass.getBases();
|
||||||
|
}
|
||||||
if (grandBases != null && grandBases.length > 0) {
|
if (grandBases != null && grandBases.length > 0) {
|
||||||
HashSet<IBinding> grandBaseBindings= null;
|
HashSet<IBinding> grandBaseBindings= null;
|
||||||
BitSet selectedBases= null;
|
BitSet selectedBases= null;
|
||||||
|
|
|
@ -129,9 +129,14 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final ICPPBase[] getBases() {
|
public final ICPPBase[] getBases() {
|
||||||
|
return getBases(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final ICPPBase[] getBases(IASTNode point) {
|
||||||
IScope scope= getCompositeScope();
|
IScope scope= getCompositeScope();
|
||||||
if (scope instanceof ICPPClassSpecializationScope) {
|
if (scope instanceof ICPPClassSpecializationScope) {
|
||||||
return ((ICPPClassSpecializationScope) scope).getBases();
|
return ((ICPPClassSpecializationScope) scope).getBases(point);
|
||||||
}
|
}
|
||||||
return super.getBases();
|
return super.getBases();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
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.ICPPClassSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||||
|
@ -108,9 +109,9 @@ public class CompositeCPPClassSpecializationScope extends CompositeScope impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPBase[] getBases() {
|
public ICPPBase[] getBases(IASTNode point) {
|
||||||
createDelegate();
|
createDelegate();
|
||||||
return fDelegate.getBases();
|
return fDelegate.getBases(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -207,9 +207,14 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPBase[] getBases() {
|
public ICPPBase[] getBases() {
|
||||||
|
return getBases(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICPPBase[] getBases(IASTNode point) {
|
||||||
IScope scope= getCompositeScope();
|
IScope scope= getCompositeScope();
|
||||||
if (scope instanceof ICPPClassSpecializationScope) {
|
if (scope instanceof ICPPClassSpecializationScope) {
|
||||||
return ((ICPPClassSpecializationScope) scope).getBases();
|
return ((ICPPClassSpecializationScope) scope).getBases(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is an explicit specialization
|
// This is an explicit specialization
|
||||||
|
|
Loading…
Add table
Reference in a new issue