1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 09:15:38 +02:00

Code streamlining.

Change-Id: I7a90e1b97d65813c80a52dfc36fc368bc20a7399
This commit is contained in:
Sergey Prigogin 2016-03-16 20:18:56 -07:00
parent 7c859a9b92
commit f838c07db6

View file

@ -10,6 +10,7 @@
* Markus Schorn (Wind River Systems)
* Bryan Wilkinson (QNX)
* Anton Leherbauer (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -94,18 +95,16 @@ public class CPPASTName extends CPPASTNameBase implements ICPPASTCompletionConte
return filterByElaboratedTypeSpecifier(kind, bindings);
} else if (parent instanceof IASTDeclarator) {
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix, namespaces);
if (!isPrefix) {
// The lookup does not find the binding, that is defined by this name
if (bindings.length == 0) {
bindings= new IBinding[] {n.resolveBinding()};
}
} else {
if (isPrefix) {
for (int i = 0; i < bindings.length; i++) {
if (bindings[i] instanceof ICPPNamespace || bindings[i] instanceof ICPPClassType) {
} else {
IBinding binding = bindings[i];
if (!(binding instanceof ICPPNamespace) && !(binding instanceof ICPPClassType)) {
bindings[i] = null;
}
}
} else if (bindings.length == 0) {
// The lookup did not find the binding that is defined by this name.
bindings= new IBinding[] { n.resolveBinding() };
}
return ArrayUtil.removeNulls(IBinding.class, bindings);
}
@ -114,27 +113,11 @@ public class CPPASTName extends CPPASTNameBase implements ICPPASTCompletionConte
private IBinding[] filterByElaboratedTypeSpecifier(int kind, IBinding[] bindings) {
for (int i = 0; i < bindings.length; i++) {
if (bindings[i] instanceof ICPPNamespace) {
} else if (bindings[i] instanceof ICPPClassType) {
ICPPClassType type = (ICPPClassType) bindings[i];
switch (type.getKey()) {
case ICompositeType.k_struct:
if (kind != ICompositeType.k_struct) {
IBinding binding = bindings[i];
if (binding instanceof ICPPClassType) {
if (((ICPPClassType) binding).getKey() != kind)
bindings[i] = null;
}
break;
case ICompositeType.k_union:
if (kind != ICompositeType.k_union) {
bindings[i] = null;
}
break;
case ICPPClassType.k_class:
if (kind != ICPPASTElaboratedTypeSpecifier.k_class) {
bindings[i] = null;
}
break;
}
} else {
} else if (!(binding instanceof ICPPNamespace)) {
bindings[i]= null;
}
}