List of usage examples for org.eclipse.jdt.core.dom SuperFieldAccess getParent
public final ASTNode getParent()
null if this is the root node. From source file:fr.labri.harmony.rta.junit.jdt.JDTVisitorRTA.java
License:Open Source License
public boolean visit(SuperFieldAccess a) { IVariableBinding b = a.resolveFieldBinding(); if (b != null && currentJavaMethod != null) { if (b.getDeclaringClass() != null) { if (!(a.getParent() instanceof Assignment)) { String fieldId = getVariableBindingId(b); //System.err.println("Add "+fieldId); currentJavaMethod.getCallsSite().add(fieldId); } else { if (((Assignment) a.getParent()).getLeftHandSide() instanceof SuperFieldAccess) { if (!((SuperFieldAccess) ((Assignment) a.getParent()).getLeftHandSide()) .resolveFieldBinding().getKey().equals(b.getKey())) { String fieldId = getVariableBindingId(b); //System.err.println("Add "+fieldId); currentJavaMethod.getCallsSite().add(fieldId); }/*from w w w. jav a 2 s.co m*/ } } } } return true; }
From source file:net.sf.j2s.core.astvisitors.ASTScriptVisitor.java
License:Open Source License
public boolean visit(SuperFieldAccess node) { ASTNode xparent = node.getParent(); while (xparent != null && !(xparent instanceof AbstractTypeDeclaration) && !(xparent instanceof AnonymousClassDeclaration)) { xparent = xparent.getParent();/* w ww . ja va 2 s. c om*/ } ITypeBinding typeBinding = null; if (xparent != null) { if (xparent instanceof AbstractTypeDeclaration) { AbstractTypeDeclaration type = (AbstractTypeDeclaration) xparent; typeBinding = type.resolveBinding(); } else if (xparent instanceof AnonymousClassDeclaration) { AnonymousClassDeclaration type = (AnonymousClassDeclaration) xparent; typeBinding = type.resolveBinding().getSuperclass(); } } String fieldName = getJ2SName(node.getName()); if (isInheritedFieldName(typeBinding, fieldName)) { if (typeBinding != null) { IVariableBinding[] declaredFields = typeBinding.getDeclaredFields(); for (int i = 0; i < declaredFields.length; i++) { String superFieldName = getJ2SName(declaredFields[i]); if (fieldName.equals(superFieldName)) { buffer.append("this."); if (checkKeyworkViolation(fieldName)) { buffer.append('$'); } fieldName = getFieldName(typeBinding.getSuperclass(), fieldName); buffer.append(fieldName); return false; } } } } buffer.append("this."); if (checkKeyworkViolation(fieldName)) { buffer.append('$'); } buffer.append(fieldName); return false; }