mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Use generics.
This commit is contained in:
parent
5698ac7333
commit
d64fdf7905
2 changed files with 36 additions and 34 deletions
|
@ -40,7 +40,8 @@ public class CPPASTFieldReference extends CPPASTNode implements
|
||||||
public CPPASTFieldReference() {
|
public CPPASTFieldReference() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPPASTFieldReference(IASTName name, IASTExpression owner, boolean isTemplate, boolean isDeref) {
|
public CPPASTFieldReference(IASTName name, IASTExpression owner, boolean isTemplate,
|
||||||
|
boolean isDeref) {
|
||||||
setFieldName(name);
|
setFieldName(name);
|
||||||
setFieldOwner(owner);
|
setFieldOwner(owner);
|
||||||
this.isTemplate = isTemplate;
|
this.isTemplate = isTemplate;
|
||||||
|
@ -100,8 +101,8 @@ public class CPPASTFieldReference extends CPPASTNode implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( owner != null ) if( !owner.accept( action ) ) return false;
|
if (owner != null && !owner.accept(action)) return false;
|
||||||
if( name != null ) if( !name.accept( action ) ) return false;
|
if (name != null && !name.accept(action)) return false;
|
||||||
|
|
||||||
if (action.shouldVisitExpressions) {
|
if (action.shouldVisitExpressions) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
|
@ -120,8 +121,7 @@ public class CPPASTFieldReference extends CPPASTNode implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( child == owner )
|
if (child == owner) {
|
||||||
{
|
|
||||||
other.setPropertyInParent(child.getPropertyInParent());
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setParent(child.getParent());
|
other.setParent(child.getParent());
|
||||||
owner = (IASTExpression) other;
|
owner = (IASTExpression) other;
|
||||||
|
@ -134,7 +134,7 @@ public class CPPASTFieldReference extends CPPASTNode implements
|
||||||
|
|
||||||
public IBinding[] findBindings(IASTName n, boolean isPrefix) {
|
public IBinding[] findBindings(IASTName n, boolean isPrefix) {
|
||||||
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix);
|
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix);
|
||||||
List filtered = new ArrayList();
|
List<IBinding> filtered = new ArrayList<IBinding>();
|
||||||
|
|
||||||
for (int i = 0; i < bindings.length; i++) {
|
for (int i = 0; i < bindings.length; i++) {
|
||||||
if (bindings[i] instanceof ICPPMethod) {
|
if (bindings[i] instanceof ICPPMethod) {
|
||||||
|
@ -146,6 +146,6 @@ public class CPPASTFieldReference extends CPPASTNode implements
|
||||||
filtered.add(bindings[i]);
|
filtered.add(bindings[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (IBinding[]) filtered.toArray(new IBinding[filtered.size()]);
|
return filtered.toArray(new IBinding[filtered.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
public class CPPASTQualifiedName extends CPPASTNode implements
|
public class CPPASTQualifiedName extends CPPASTNode implements
|
||||||
ICPPASTQualifiedName, IASTCompletionContext {
|
ICPPASTQualifiedName, IASTCompletionContext {
|
||||||
|
|
||||||
|
|
||||||
public CPPASTQualifiedName() {
|
public CPPASTQualifiedName() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +63,6 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (signature == null)
|
if (signature == null)
|
||||||
return ""; //$NON-NLS-1$
|
return ""; //$NON-NLS-1$
|
||||||
|
@ -79,7 +77,6 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void removeNullNames() {
|
private void removeNullNames() {
|
||||||
names = (IASTName[]) ArrayUtil.removeNullsAfter( IASTName.class, names, namesPos );
|
names = (IASTName[]) ArrayUtil.removeNullsAfter( IASTName.class, names, namesPos );
|
||||||
}
|
}
|
||||||
|
@ -183,7 +180,6 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isDeclaration() {
|
public boolean isDeclaration() {
|
||||||
IASTNode parent = getParent();
|
IASTNode parent = getParent();
|
||||||
if (parent instanceof IASTNameOwner) {
|
if (parent instanceof IASTNameOwner) {
|
||||||
|
@ -233,12 +229,16 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
||||||
IASTName[] nonNullNames = getNames(); // ensure no null names
|
IASTName[] nonNullNames = getNames(); // ensure no null names
|
||||||
|
|
||||||
int len=nonNullNames.length;
|
int len=nonNullNames.length;
|
||||||
if (nonNullNames[len-1] instanceof ICPPASTConversionName || nonNullNames[len-1] instanceof ICPPASTOperatorName) return true;
|
if (nonNullNames[len-1] instanceof ICPPASTConversionName || nonNullNames[len-1] instanceof ICPPASTOperatorName) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// check templateId's name
|
// check templateId's name
|
||||||
if (nonNullNames[len-1] instanceof ICPPASTTemplateId) {
|
if (nonNullNames[len-1] instanceof ICPPASTTemplateId) {
|
||||||
IASTName tempName = ((ICPPASTTemplateId)nonNullNames[len-1]).getTemplateName();
|
IASTName tempName = ((ICPPASTTemplateId)nonNullNames[len-1]).getTemplateName();
|
||||||
if (tempName instanceof ICPPASTConversionName || tempName instanceof ICPPASTOperatorName) return true;
|
if (tempName instanceof ICPPASTConversionName || tempName instanceof ICPPASTOperatorName) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -262,10 +262,10 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
||||||
if (binding instanceof ICPPClassType) {
|
if (binding instanceof ICPPClassType) {
|
||||||
ICPPClassType classType = (ICPPClassType) binding;
|
ICPPClassType classType = (ICPPClassType) binding;
|
||||||
final boolean isDeclaration = getParent().getParent() instanceof IASTSimpleDeclaration;
|
final boolean isDeclaration = getParent().getParent() instanceof IASTSimpleDeclaration;
|
||||||
List filtered = filterClassScopeBindings(classType, bindings, isDeclaration);
|
List<IBinding> filtered = filterClassScopeBindings(classType, bindings, isDeclaration);
|
||||||
|
|
||||||
if (isDeclaration && nameMatches(classType.getNameCharArray(), n
|
if (isDeclaration && nameMatches(classType.getNameCharArray(),
|
||||||
.toCharArray(), isPrefix)) {
|
n.toCharArray(), isPrefix)) {
|
||||||
try {
|
try {
|
||||||
ICPPConstructor[] constructors = classType.getConstructors();
|
ICPPConstructor[] constructors = classType.getConstructors();
|
||||||
for (int i = 0; i < constructors.length; i++) {
|
for (int i = 0; i < constructors.length; i++) {
|
||||||
|
@ -277,16 +277,16 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (IBinding[]) filtered.toArray(new IBinding[filtered.size()]);
|
return filtered.toArray(new IBinding[filtered.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bindings;
|
return bindings;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List filterClassScopeBindings(ICPPClassType classType,
|
private List<IBinding> filterClassScopeBindings(ICPPClassType classType,
|
||||||
IBinding[] bindings, final boolean isDeclaration) {
|
IBinding[] bindings, final boolean isDeclaration) {
|
||||||
List filtered = new ArrayList();
|
List<IBinding> filtered = new ArrayList<IBinding>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < bindings.length; i++) {
|
for (int i = 0; i < bindings.length; i++) {
|
||||||
|
@ -298,7 +298,9 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
||||||
if (method.isImplicit()) continue;
|
if (method.isImplicit()) continue;
|
||||||
if (method.isDestructor() || method instanceof ICPPConstructor) {
|
if (method.isDestructor() || method instanceof ICPPConstructor) {
|
||||||
if (!isDeclaration) continue;
|
if (!isDeclaration) continue;
|
||||||
} else if (!method.isStatic() && !isDeclaration) continue;
|
} else if (!method.isStatic() && !isDeclaration) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
} else if (bindings[i] instanceof ICPPClassType) {
|
} else if (bindings[i] instanceof ICPPClassType) {
|
||||||
ICPPClassType type = (ICPPClassType) bindings[i];
|
ICPPClassType type = (ICPPClassType) bindings[i];
|
||||||
if (type.isSameType(classType)) continue;
|
if (type.isSameType(classType)) continue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue