Package org.eclipse.jdt.core.dom

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


      IBinding exprBinding = var.resolveBinding();

      if ( "it".equals(varName) && exprBinding instanceof IVariableBinding ) // call on 'it' field
      {
        IVariableBinding varBinding = (IVariableBinding) exprBinding;
        IMethodBinding mockMethod = getSurroundingMockMethod(node);

        if( mockMethod != null && varBinding.isField() && mockMethod.isSubsignature(meth)
            && varBinding.getDeclaringClass().equals(mockMethod.getDeclaringClass()) )
        {
          ITypeBinding mockedType = MockUtil.findMockedType(node);

          if( mockedType.equals(varBinding.getType()) // field type is correct mocked type
              && !MockUtil.isReentrantMockMethod(mockMethod) )
          {
            addMarker( node,
                "Method calls itself. Set @Mock(reentrant=true) on method '"
                    + mockMethod.getName() + "'", true);
View Full Code Here


  }
 
  public boolean visit(VariableDeclarationFragment node) {
    insert(containment, getParent(), ownValue);
    scopeManager.push((ISourceLocation) ownValue);
    IVariableBinding binding = node.resolveBinding();
   
    if (binding != null) {
      IConstructor type = bindingsResolver.resolveType(binding.getType(), false);
      insert(types, ownValue, type);
    }
    else {
      insert(messages, values.constructor(DATATYPE_RASCAL_MESSAGE_ERROR_NODE_TYPE,
          values.string("No binding for: " + node),
View Full Code Here

      else if (node instanceof MethodDeclaration) {
        IMethodBinding binding = ((MethodDeclaration) node).resolveBinding();
          return bindingsResolver.resolveType(binding, true);
      }
      else if (node instanceof VariableDeclaration) {
        IVariableBinding binding = ((VariableDeclaration) node).resolveBinding();
        return bindingsResolver.resolveType(binding.getType(), false);
      }
    } catch (NullPointerException e) {
      System.err.println("Got NPE for node " + node);
    }
   
View Full Code Here

      parentNode = parentNode.getParent();
      parentBinding = resolveBinding(parentNode);
    }

    // TODO: @ashimshahi please check this additional null check and the way we return an unresolved binding here
    IVariableBinding resolvedBinding = thisNode.resolveBinding();
    if (resolvedBinding == null) {
      return makeBinding("unresolved", null, null);
    }
   
    String key = resolvedBinding.getKey();
    // Binding keys for initializers are not unique so we always force them to be recomputed
    if (!(parentNode instanceof Initializer)) {
      if (EclipseJavaCompiler.cache.containsKey(key)) {
        return EclipseJavaCompiler.cache.get(key);
      }
View Full Code Here

    if (fMarkMethodOccurrences && kind == IBinding.METHOD)
      return true;

    if (kind == IBinding.VARIABLE) {
      IVariableBinding variableBinding = (IVariableBinding) binding;
      if (variableBinding.isField()) {
        int constantModifier = IModifierConstants.ACC_STATIC
            | IModifierConstants.ACC_FINAL;
        boolean isConstant = (variableBinding.getModifiers() & constantModifier) == constantModifier;
        if (isConstant)
          return fMarkConstantOccurrences;
        else
          return fMarkFieldOccurrences;
      }
View Full Code Here

      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

    SimpleName name = node.getName();
    Name qualifier = node.getQualifier();
    IBinding nameBinding = name.resolveBinding();
    // If this is a Field access, then add children to CFG
    if(nameBinding.getKind() == IBinding.VARIABLE) {
      IVariableBinding variableBinding = (IVariableBinding) nameBinding;
      if(variableBinding.isField()) {
        ControlFlowNode nameCFN = controlFlowNode.newControlFlowNode(name);
        ControlFlowNode qualifierCFN = controlFlowNode.newControlFlowNode(qualifier);
        controlFlowNode.moveEdges(ControlFlowNode.Direction.BACKWARDS, qualifierCFN);
        qualifierCFN.addEdge(ControlFlowNode.Direction.FORWARDS, nameCFN);
        nameCFN.addEdge(ControlFlowNode.Direction.FORWARDS, controlFlowNode);
View Full Code Here

   * @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

    }
    if(targetNode instanceof QualifiedName) {
      QualifiedName target = (QualifiedName) targetNode;
      IBinding binding = target.resolveBinding();
      if(binding instanceof IVariableBinding) {
        IVariableBinding vb = (IVariableBinding) binding;
        if(vb.isField()) {
          return new StoreFieldInstructionImpl(
              node,
              source,
              new EclipseBrokenFieldAccess(target, eclipseVariableQuery),
              eclipseVariableQuery);
        }
      }
    }
    if(targetNode instanceof SimpleName) {
      SimpleName target = (SimpleName) targetNode;
      IBinding binding = target.resolveBinding();
      if(binding instanceof IVariableBinding) {
        IVariableBinding vb = (IVariableBinding) binding;
        if(vb.isField()) {
          // implicit field access on this
          return new StoreFieldInstructionImpl(
              node,
              source,
              new EclipseImplicitFieldAccess(target, eclipseVariableQuery),
              eclipseVariableQuery);
        }
        else if(!vb.isEnumConstant()) {
          // local
          return new CopyInstructionImpl(node, source,
              true,
              eclipseVariableQuery.variable(targetNode),
              eclipseVariableQuery);
View Full Code Here

      IEclipseVariableQuery eclipseVariableQuery) {
    // careful with the disambiguation of field accesses
    IBinding binding = node.resolveBinding();
    if(binding instanceof IVariableBinding) {
      // expect this to be a field
      IVariableBinding var = (IVariableBinding) binding;
      if(var.isField() || var.isEnumConstant()) {
        if(isLoad(node))
          return new LoadFieldInstructionImpl(
              node,
              new EclipseBrokenFieldAccess(node, eclipseVariableQuery),
              eclipseVariableQuery);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.IVariableBinding

Copyright © 2018 www.massapicom. 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.