List of usage examples for org.eclipse.jdt.core.dom IVariableBinding isRecovered
public boolean isRecovered();
From source file:edu.uci.ics.sourcerer.extractor.ast.ReferenceExtractorVisitor.java
License:Open Source License
/** * This method writes://w w w . j a v a 2 s . c o m *<ul> * <li>For field access expressions: * <ul> * <li>Writes relation to <code>IRelationWriter</code>.</li> * <li>Reads relation to <code>IRelationWriter</code>.</li> * </ul></li> *</ul> */ @Override public boolean visit(FieldAccess node) { // Get the fqn String fqn = null; IVariableBinding binding = node.resolveFieldBinding(); if (binding == null) { fqn = getUnknownFqn(node.getName().getIdentifier()); } else { ITypeBinding declaringClass = binding.getDeclaringClass(); if (declaringClass != null) { declaringClass = declaringClass.getErasure(); } if (declaringClass == null) { if (binding.isRecovered()) { fqn = getUnknownFqn(binding.getName()); } else if (node.getExpression().resolveTypeBinding().isArray() && binding.getName().equals("length")) { // Ignore array length return true; } else { logger.log(Level.SEVERE, "Non-recovered field binding without a declaring class that's not an array.length!"); } } else { fqn = getTypeFqn(declaringClass) + "." + binding.getName(); } } // Write the relation if (inLhsAssignment) { relationWriter.writeWrites(fqnStack.getFqn(), fqn, getLocation(node.getName())); } else { relationWriter.writeReads(fqnStack.getFqn(), fqn, getLocation(node.getName())); } inLhsAssignment = false; node.getExpression().accept(this); return false; }
From source file:edu.uci.ics.sourcerer.tools.java.extractor.eclipse.ReferenceExtractorVisitor.java
License:Open Source License
/** * This method writes://from w w w .j ava 2 s. c o m *<ul> * <li>For field access expressions: * <ul> * <li>Writes relation to <code>IRelationWriter</code>.</li> * <li>Reads relation to <code>IRelationWriter</code>.</li> * </ul></li> *</ul> */ @Override public boolean visit(FieldAccess node) { // Get the fqn String fqn = null; IVariableBinding binding = node.resolveFieldBinding(); if (binding == null) { fqn = createUnknownFqn(node.getName().getIdentifier()); } else { ITypeBinding declaringClass = binding.getDeclaringClass(); if (declaringClass != null) { declaringClass = declaringClass.getErasure(); } if (declaringClass == null) { if (binding.isRecovered()) { fqn = createUnknownFqn(binding.getName()); } else if (node.getExpression().resolveTypeBinding().isArray() && binding.getName().equals("length")) { // Ignore array length return true; } else { logger.log(Level.SEVERE, "Non-recovered field binding without a declaring class that's not an array.length!"); } } else { fqn = getTypeFqn(declaringClass) + "." + binding.getName(); } } // Write the relation if (inLhsAssignment) { relationWriter.writeRelation(Relation.WRITES, fqnStack.getFqn(), fqn, createLocation(node.getName())); } else { relationWriter.writeRelation(Relation.READS, fqnStack.getFqn(), fqn, createLocation(node.getName())); } inLhsAssignment = false; node.getExpression().accept(this); return false; }