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(IASTName name, IASTExpression owner, boolean isTemplate, boolean isDeref) {
|
||||
public CPPASTFieldReference(IASTName name, IASTExpression owner, boolean isTemplate,
|
||||
boolean isDeref) {
|
||||
setFieldName(name);
|
||||
setFieldOwner(owner);
|
||||
this.isTemplate = isTemplate;
|
||||
|
@ -91,39 +92,38 @@ public class CPPASTFieldReference extends CPPASTNode implements
|
|||
isDeref = value;
|
||||
}
|
||||
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if( action.shouldVisitExpressions ){
|
||||
switch( action.visit( this ) ){
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitExpressions) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
if( owner != null ) if( !owner.accept( action ) ) return false;
|
||||
if( name != null ) if( !name.accept( action ) ) return false;
|
||||
if (owner != null && !owner.accept(action)) return false;
|
||||
if (name != null && !name.accept(action)) return false;
|
||||
|
||||
if( action.shouldVisitExpressions ){
|
||||
switch( action.leave( this ) ){
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
if (action.shouldVisitExpressions) {
|
||||
switch (action.leave(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getRoleForName(IASTName n) {
|
||||
if( n == name )
|
||||
if (n == name)
|
||||
return r_reference;
|
||||
return r_unclear;
|
||||
}
|
||||
|
||||
public void replace(IASTNode child, IASTNode other) {
|
||||
if( child == owner )
|
||||
{
|
||||
other.setPropertyInParent( child.getPropertyInParent() );
|
||||
other.setParent( child.getParent() );
|
||||
if (child == owner) {
|
||||
other.setPropertyInParent(child.getPropertyInParent());
|
||||
other.setParent(child.getParent());
|
||||
owner = (IASTExpression) other;
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class CPPASTFieldReference extends CPPASTNode implements
|
|||
|
||||
public IBinding[] findBindings(IASTName n, boolean 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++) {
|
||||
if (bindings[i] instanceof ICPPMethod) {
|
||||
|
@ -146,6 +146,6 @@ public class CPPASTFieldReference extends CPPASTNode implements
|
|||
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
|
||||
ICPPASTQualifiedName, IASTCompletionContext {
|
||||
|
||||
|
||||
public CPPASTQualifiedName() {
|
||||
}
|
||||
|
||||
|
@ -64,7 +63,6 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
if (signature == null)
|
||||
return ""; //$NON-NLS-1$
|
||||
|
@ -79,7 +77,6 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void removeNullNames() {
|
||||
names = (IASTName[]) ArrayUtil.removeNullsAfter( IASTName.class, names, namesPos );
|
||||
}
|
||||
|
@ -183,7 +180,6 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDeclaration() {
|
||||
IASTNode parent = getParent();
|
||||
if (parent instanceof IASTNameOwner) {
|
||||
|
@ -233,12 +229,16 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
|||
IASTName[] nonNullNames = getNames(); // ensure no null names
|
||||
|
||||
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
|
||||
if (nonNullNames[len-1] instanceof ICPPASTTemplateId) {
|
||||
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;
|
||||
|
@ -262,10 +262,10 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
|||
if (binding instanceof ICPPClassType) {
|
||||
ICPPClassType classType = (ICPPClassType) binding;
|
||||
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
|
||||
.toCharArray(), isPrefix)) {
|
||||
if (isDeclaration && nameMatches(classType.getNameCharArray(),
|
||||
n.toCharArray(), isPrefix)) {
|
||||
try {
|
||||
ICPPConstructor[] constructors = classType.getConstructors();
|
||||
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;
|
||||
}
|
||||
|
||||
private List filterClassScopeBindings(ICPPClassType classType,
|
||||
private List<IBinding> filterClassScopeBindings(ICPPClassType classType,
|
||||
IBinding[] bindings, final boolean isDeclaration) {
|
||||
List filtered = new ArrayList();
|
||||
List<IBinding> filtered = new ArrayList<IBinding>();
|
||||
|
||||
try {
|
||||
for (int i = 0; i < bindings.length; i++) {
|
||||
|
@ -298,7 +298,9 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
|||
if (method.isImplicit()) continue;
|
||||
if (method.isDestructor() || method instanceof ICPPConstructor) {
|
||||
if (!isDeclaration) continue;
|
||||
} else if (!method.isStatic() && !isDeclaration) continue;
|
||||
} else if (!method.isStatic() && !isDeclaration) {
|
||||
continue;
|
||||
}
|
||||
} else if (bindings[i] instanceof ICPPClassType) {
|
||||
ICPPClassType type = (ICPPClassType) bindings[i];
|
||||
if (type.isSameType(classType)) continue;
|
||||
|
|
Loading…
Add table
Reference in a new issue