Examples of IVariableBinding


Examples of org.eclipse.jdt.core.dom.IVariableBinding

  public TACInstruction create(SimpleName node,
      IEclipseVariableQuery eclipseVariableQuery) {
    // careful with the disambiguation of field accesses
    IBinding binding = node.resolveBinding();
    if(binding instanceof IVariableBinding) {
      IVariableBinding vb = (IVariableBinding) binding;
      if(vb.isField() || vb.isEnumConstant()) {
        if((node.getParent() instanceof QualifiedName) &&
            (((QualifiedName) node.getParent()).getName() == node))
          // trying to avoid double-creation of field accesses through
          // QualifiedName and nested SimpleName
          return null;
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IVariableBinding

  public final boolean isStaticFieldAccess() {
    return EclipseTAC.isStaticBinding(resolveFieldBinding());
  }

  public final Variable getAccessedObject() {
    IVariableBinding field = resolveFieldBinding();
    if(!field.isField() && !field.isEnumConstant())
      throw new IllegalStateException("Not a field or enum constant: " + field);
    if(EclipseTAC.isStaticBinding(field))
      return query.typeVariable(field.getDeclaringClass());
    else
      return getAccessedInstanceInternal(field);
  }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IVariableBinding

   */
  private Variable getVariable(IBinding binding) {
    Variable result = variables.get(binding);
    if(result == null) {
      if(binding instanceof IVariableBinding) {
        IVariableBinding vb = (IVariableBinding) binding;
        if(vb.isEnumConstant() || vb.isField())
          throw new IllegalArgumentException("Not a local: " + binding);
        // figure out whether it's declared locally
        IMethodBinding declaredIn = vb.getDeclaringMethod();
        while(declaredIn != null && declaredIn != declaredIn.getMethodDeclaration()) {
          declaredIn = declaredIn.getMethodDeclaration();
        }
        result = new SourceVariable(vb.getName(), vb, method.equals(declaredIn));
      }
      else if(binding instanceof ITypeBinding) {
        ITypeBinding tb = (ITypeBinding) binding;
        result = new TypeVariable(tb);
      }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IVariableBinding

   * @param tac
   * @see AbstractTACInstruction#AbstractTACInstruction(ASTNode, IEclipseVariableQuery)
   */
  public SourceVariableDeclarationImpl(VariableDeclaration node, IEclipseVariableQuery tac) {
    super(node, tac);
    IVariableBinding b = node.resolveBinding();
    if(b.isField())
      throw new IllegalArgumentException("Field declaration: " + node);
    if(b.isEnumConstant())
      throw new IllegalArgumentException("Enum declaration: " + node);
  }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IVariableBinding

      return new CrystalAnnotation();
    }
  }

  public void addAnnotationToField(ICrystalAnnotation anno, FieldDeclaration field) {
    IVariableBinding binding;
    String name;
    List<ICrystalAnnotation> annoList;

    if (field.fragments().isEmpty())
      return;

    binding = ((VariableDeclarationFragment) field.fragments().get(0)).resolveBinding();
    name = binding.getKey();
    annoList = fields.get(name);
    if (annoList == null) {
      annoList = new ArrayList<ICrystalAnnotation>();
      fields.put(name, annoList);
    }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IVariableBinding

    public void endVisit(Assignment node) {
      Expression left = node.getLeftHandSide();
      Expression right = node.getRightHandSide();
     
      if (left instanceof Name && ((Name)left).resolveBinding() instanceof IVariableBinding) {
        IVariableBinding binding = (IVariableBinding) ((Name)left).resolveBinding();
     
        if (binding.isParameter()) {
          IMethodBinding method = Utilities.getMethodDeclaration(node).resolveBinding();
          AnnotationSummary summary = getInput().getAnnoDB().getSummaryForMethod(method);
       
          if (summary.getParameter(binding.getName(), NON_NULL_ANNO) != null)
            checkVariable(flowAnalysis.getResultsBefore(left), right);
        }
      }
    }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IVariableBinding

    public void endVisit(Assignment node) {
      Expression left = node.getLeftHandSide();
      Expression right = node.getRightHandSide();
     
      if (left instanceof Name && ((Name)left).resolveBinding() instanceof IVariableBinding) {
        IVariableBinding binding = (IVariableBinding) ((Name)left).resolveBinding();
     
        if (binding.isParameter()) {
          IMethodBinding method = Utilities.getMethodDeclaration(node).resolveBinding();
          AnnotationSummary summary = getInput().getAnnoDB().getSummaryForMethod(method);
       
          if (summary.getParameter(binding.getName(), NON_NULL_ANNO) != null)
            checkVariable(flowAnalysis.getResultsBefore(left), right);
        }
      }
    }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IVariableBinding

   */
  private Variable getVariable(IBinding binding) {
    Variable result = variables.get(binding);
    if(result == null) {
      if(binding instanceof IVariableBinding) {
        IVariableBinding vb = (IVariableBinding) binding;
        if(vb.isEnumConstant() || vb.isField())
          throw new IllegalArgumentException("Not a local: " + binding);
        // figure out whether it's declared locally
        IMethodBinding declaredIn = vb.getDeclaringMethod();
        while(declaredIn != null && declaredIn != declaredIn.getMethodDeclaration()) {
          declaredIn = declaredIn.getMethodDeclaration();
        }
        result = new SourceVariable(vb.getName(), vb, method.equals(declaredIn));
      }
      else if(binding instanceof ITypeBinding) {
        ITypeBinding tb = (ITypeBinding) binding;
        result = new TypeVariable(tb);
      }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IVariableBinding

   */
  public class LiveVariableVisitor extends ASTVisitor {

    @Override
    public void endVisit(Assignment node) {
      IVariableBinding binding = null;
      Expression left = node.getLeftHandSide();
      TupleLatticeElement<Variable, LiveVariableLE> lattice = fa.getResultsAfter(node);
     
      if (left instanceof Name && ((Name)left).resolveBinding() instanceof IVariableBinding)
        binding = (IVariableBinding) ((Name)left).resolveBinding();
      else if (left instanceof FieldAccess)
        binding = ((FieldAccess)left).resolveFieldBinding();
     
      if (binding == null)
        return;
     
      if (binding.isField() || binding.isParameter())
        return;
     
      if (lattice.get(fa.getSourceVariable(binding)) == LiveVariableLE.DEAD)
        reporter.reportUserProblem("The variable " + node.getLeftHandSide() + " is dead and is no longer used.", node, getName(), SEVERITY.WARNING);
    }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IVariableBinding

            if ((binding == null) || (binding.getKind() != IBinding.VARIABLE)) {
                return false;
            }

            IVariableBinding variableBinding = (IVariableBinding) binding;
            return variableBinding.isField()
                    && Modifier.isPrivate(variableBinding.getModifiers())
                    && !Modifier.isStatic(variableBinding.getModifiers());
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.