Package org.eclipse.jdt.core.dom

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


     * @param fname
     */
    public void addAssignVariableToField(String vname, String fname) {
        Assignment asgn = m_ast.newAssignment();
        if (fname.equals(vname)) {
            FieldAccess access = m_ast.newFieldAccess();
            access.setExpression(m_ast.newThisExpression());
            access.setName(m_ast.newSimpleName(fname));
            asgn.setLeftHandSide(access);
        } else {
            asgn.setLeftHandSide(m_ast.newSimpleName(fname));
        }
        asgn.setRightHandSide(m_ast.newSimpleName(vname));
View Full Code Here


     */
    public void addIndexedForStatement(String name, String array, BlockBuilder block) {
        InfixExpression test = m_ast.newInfixExpression();
        test.setOperator(Operator.LESS);
        test.setLeftOperand(m_ast.newSimpleName(name));
        FieldAccess access = m_ast.newFieldAccess();
        access.setExpression(m_ast.newSimpleName(array));
        access.setName(m_ast.newSimpleName("length"));
        test.setRightOperand(access);
        PrefixExpression post = m_ast.newPrefixExpression();
        post.setOperator(PrefixExpression.Operator.INCREMENT);
        post.setOperand(m_ast.newSimpleName(name));
        addForStatement(name, m_ast.newPrimitiveType(PrimitiveType.INT), m_ast.newNumberLiteral("0"), test,
View Full Code Here

    if (optional == null) {
      return adaptable.isRoot();
    } else if (optional instanceof ThisExpression) {
      return adaptable.isRoot();
    } else if (optional instanceof FieldAccess) {
      FieldAccess fieldAccess = (FieldAccess) optional;
      Expression accessExpression = fieldAccess.getExpression();
      if (accessExpression instanceof SimpleName) {
        String fieldName = ((SimpleName) accessExpression).getFullyQualifiedName();
        if (fieldName.equals(adaptable.getName()))
          return true;
      }
View Full Code Here

          node, (ArrayAccess) targetNode,
          source,
          eclipseVariableQuery);
    }
    if(targetNode instanceof FieldAccess) {
      FieldAccess target = (FieldAccess) targetNode;
      return new StoreFieldInstructionImpl(
          node, 
          source,
          new EclipseReferenceFieldAccess(target, eclipseVariableQuery),
          eclipseVariableQuery);
    }
    if(targetNode instanceof SuperFieldAccess) {
      SuperFieldAccess target = (SuperFieldAccess) targetNode;
      return new StoreFieldInstructionImpl(
          node, 
          source,
          new EclipseSuperFieldAccess(target, eclipseVariableQuery),
          eclipseVariableQuery);
    }
    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(
View Full Code Here

  @Test
  public void testReadThis() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("ThisRead", THIS_READ);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    FieldAccess read = (FieldAccess) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(read);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof LoadFieldInstruction);
    LoadFieldInstruction load = (LoadFieldInstruction) instr;
    Assert.assertTrue(load.getSourceObject() instanceof ThisVariable);
    Assert.assertTrue(load.getSourceObject().isUnqualifiedThis());
    Assert.assertNull(((ThisVariable) load.getSourceObject()).getQualifier());
    Assert.assertEquals(tac.variable(read.getExpression()), load.getSourceObject());
    Assert.assertEquals("f", load.getFieldName());
  }
View Full Code Here

      this.processExpression(ce.getElseExpression());
      break;
    }

    case ASTNode.FIELD_ACCESS: {
      final FieldAccess fieldAccess = (FieldAccess) node;

      if (fieldAccess.resolveFieldBinding().getJavaElement() == null)
        throw new DefinitelyNotEnumerizableException(
            Messages.ASTNodeProcessor_NonEnumerizableTypeEncountered, node);
      else {
        final IJavaElement elem = fieldAccess.resolveFieldBinding()
            .getJavaElement();
        if (elem.isReadOnly() || fieldAccess.resolveBoxing())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);
        if (fieldAccess.resolveTypeBinding().isEqualTo(
            node.getAST().resolveWellKnownType("java.lang.Object"))) //$NON-NLS-1$
          throw new NonEnumerizableASTException(
              Messages.ASTNodeProcessor_IllegalArrayUpcast, fieldAccess);
        this.found.add(elem);
      }
View Full Code Here

          continue;
        }
      }
      // all "dataSource.x = X" fields assignment must be before
      if (parentNode instanceof FieldAccess) {
        FieldAccess fieldAccess = (FieldAccess) parentNode;
        if (isRepresentedBy(fieldAccess.getExpression())
            && fieldAccess.getParent() instanceof Assignment) {
          nodes.add(node);
          continue;
        }
      }
    }
View Full Code Here

          + "Property Lower: " + property.getLower());

      // Left expression
      SimpleName simpleName = ast.newSimpleName(property.getName());
      ThisExpression thisExpression = ast.newThisExpression();
      FieldAccess fieldAccess = ast.newFieldAccess();
      fieldAccess.setName(simpleName);
      fieldAccess.setExpression(thisExpression);

      // Right expression
      SimpleName parameter = ast.newSimpleName(property.getName());

      Assignment assignment = ast.newAssignment();
View Full Code Here

        // Here, -> binds tighter than new, thus we get an error without
        // parens.
        return true;
      }
    } else if (parent instanceof FieldAccess) {
      FieldAccess fi = (FieldAccess) parent;
      if (fi.getExpression() == creation) {
        // Here, -> binds tighter than new, thus we get an error without
        // parens.
        return true;
      }
    }
View Full Code Here

      if (node == qn.getName()) {
        return qn.getQualifier().resolveTypeBinding();
      }
    } else if (parent instanceof FieldAccess) {
      FieldAccess fa = (FieldAccess) parent;
      if (node == fa.getName()) {
        return fa.getExpression().resolveTypeBinding();
      }
    } else if (parent instanceof MethodInvocation) {
      MethodInvocation mi = (MethodInvocation) parent;
      if (node == mi.getName() && mi.getExpression() != null) {
        return mi.getExpression().resolveTypeBinding();
View Full Code Here

TOP

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

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.