mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Minor code simplification.
This commit is contained in:
parent
326759fe8c
commit
247faec624
1 changed files with 15 additions and 14 deletions
|
@ -70,7 +70,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
public ICPPClassType getOriginalClassType() {
|
public ICPPClassType getOriginalClassType() {
|
||||||
return specialClass.getSpecializedBinding();
|
return specialClass.getSpecializedBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final IBinding getBinding(IASTName name, boolean resolve) {
|
public final IBinding getBinding(IASTName name, boolean resolve) {
|
||||||
return getBinding(name, resolve, IIndexFileSet.EMPTY);
|
return getBinding(name, resolve, IIndexFileSet.EMPTY);
|
||||||
|
@ -84,7 +84,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
@Override
|
@Override
|
||||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) {
|
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) {
|
||||||
char[] c = name.getLookupKey();
|
char[] c = name.getLookupKey();
|
||||||
|
|
||||||
if (CharArrayUtils.equals(c, specialClass.getNameCharArray())
|
if (CharArrayUtils.equals(c, specialClass.getNameCharArray())
|
||||||
&& !CPPClassScope.shallReturnConstructors(name, false)) {
|
&& !CPPClassScope.shallReturnConstructors(name, false)) {
|
||||||
return specialClass;
|
return specialClass;
|
||||||
|
@ -94,10 +94,10 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
IScope classScope = specialized.getCompositeScope();
|
IScope classScope = specialized.getCompositeScope();
|
||||||
IBinding[] bindings = classScope != null ?
|
IBinding[] bindings = classScope != null ?
|
||||||
classScope.getBindings(new ScopeLookupData(name, resolve, false)) : null;
|
classScope.getBindings(new ScopeLookupData(name, resolve, false)) : null;
|
||||||
|
|
||||||
if (bindings == null)
|
if (bindings == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IBinding[] specs = IBinding.EMPTY_BINDING_ARRAY;
|
IBinding[] specs = IBinding.EMPTY_BINDING_ARRAY;
|
||||||
for (IBinding binding : bindings) {
|
for (IBinding binding : bindings) {
|
||||||
specs = ArrayUtil.append(specs, specialClass.specializeMember(binding, name));
|
specs = ArrayUtil.append(specs, specialClass.specializeMember(binding, name));
|
||||||
|
@ -145,12 +145,12 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
}
|
}
|
||||||
return type1.isSameType(type2);
|
return type1.isSameType(type2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPClassSpecialization getClassType() {
|
public ICPPClassSpecialization getClassType() {
|
||||||
return specialClass;
|
return specialClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPBase[] getBases(IASTNode point) {
|
public ICPPBase[] getBases(IASTNode point) {
|
||||||
if (fBases == null) {
|
if (fBases == null) {
|
||||||
|
@ -187,8 +187,9 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
if (origClass instanceof IType) {
|
if (origClass instanceof IType) {
|
||||||
ICPPBase specBase = base.clone();
|
ICPPBase specBase = base.clone();
|
||||||
ICPPClassSpecialization specializationContext = specialClass;
|
ICPPClassSpecialization specializationContext = specialClass;
|
||||||
if (specialClass.getOwner() instanceof ICPPClassSpecialization) {
|
IBinding owner = specialClass.getOwner();
|
||||||
specializationContext = (ICPPClassSpecialization) specialClass.getOwner();
|
if (owner instanceof ICPPClassSpecialization) {
|
||||||
|
specializationContext = (ICPPClassSpecialization) owner;
|
||||||
}
|
}
|
||||||
IType specClass= CPPTemplates.instantiateType((IType) origClass, tpmap, -1, specializationContext, point);
|
IType specClass= CPPTemplates.instantiateType((IType) origClass, tpmap, -1, specializationContext, point);
|
||||||
specClass = SemanticUtil.getUltimateType(specClass, false);
|
specClass = SemanticUtil.getUltimateType(specClass, false);
|
||||||
|
@ -208,10 +209,10 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
}
|
}
|
||||||
return fBases;
|
return fBases;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T extends IBinding> T[] specializeMembers(T[] array, IASTNode point) {
|
private <T extends IBinding> T[] specializeMembers(T[] array, IASTNode point) {
|
||||||
if (array == null || array.length == 0)
|
if (array == null || array.length == 0)
|
||||||
return array;
|
return array;
|
||||||
|
|
||||||
T[] newArray= array.clone();
|
T[] newArray= array.clone();
|
||||||
|
@ -256,7 +257,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||||
return getConstructors(null);
|
return getConstructors(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPConstructor[] getConstructors(IASTNode point) {
|
public ICPPConstructor[] getConstructors(IASTNode point) {
|
||||||
ICPPConstructor[] ctors= ClassTypeHelper.getConstructors(specialClass.getSpecializedBinding(), point);
|
ICPPConstructor[] ctors= ClassTypeHelper.getConstructors(specialClass.getSpecializedBinding(), point);
|
||||||
|
@ -275,7 +276,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
if (ownInheritedConstructors == null) {
|
if (ownInheritedConstructors == null) {
|
||||||
if (!hasInheritedConstructorsSources(point))
|
if (!hasInheritedConstructorsSources(point))
|
||||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||||
|
|
||||||
IType[][] existingConstructorParamTypes = new IType[existingConstructors.length][];
|
IType[][] existingConstructorParamTypes = new IType[existingConstructors.length][];
|
||||||
for (int i = 0; i < existingConstructors.length; i++) {
|
for (int i = 0; i < existingConstructors.length; i++) {
|
||||||
ICPPParameter[] params = existingConstructors[i].getParameters();
|
ICPPParameter[] params = existingConstructors[i].getParameters();
|
||||||
|
@ -364,7 +365,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
// may be created, but scopes are sometimes stored in hash maps
|
// may be created, but scopes are sometimes stored in hash maps
|
||||||
// under the assumption that two objects representing the same
|
// under the assumption that two objects representing the same
|
||||||
// scope will compare equal().
|
// scope will compare equal().
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (other instanceof ICPPClassSpecializationScope) {
|
if (other instanceof ICPPClassSpecializationScope) {
|
||||||
|
@ -372,7 +373,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return specialClass.hashCode();
|
return specialClass.hashCode();
|
||||||
|
|
Loading…
Add table
Reference in a new issue