Examples of VariableDeclarationFragment


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

                if (decl.getInitializer() != null && decl.getInitializer() instanceof StringLiteral) {
                    StringLiteral l = (StringLiteral) decl.getInitializer();
                    return true;
                }
            } else {
                VariableDeclarationFragment decl = (VariableDeclarationFragment) varDecl;
                if (decl.getInitializer() != null) {
                    return isStringContant(decl.getInitializer(), unit, resource);
                }
            }
        } else if (arg instanceof MethodInvocation) {
            MethodInvocation inv = (MethodInvocation) arg;
            if (inv.getName().getIdentifier().equals("toString")) {
View Full Code Here

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

                if (decl.getInitializer() != null && decl.getInitializer() instanceof StringLiteral) {
                    StringLiteral l = (StringLiteral) decl.getInitializer();
                    return true;
                }
            } else {
                VariableDeclarationFragment decl = (VariableDeclarationFragment) varDecl;
                if (decl.getInitializer() != null) {
                    return isStringContant(decl.getInitializer(), unit, resource);
                }
            }
        } else if (arg instanceof MethodInvocation) {
            MethodInvocation inv = (MethodInvocation) arg;
            if (inv.getName().getIdentifier().equals("toString")) {
View Full Code Here

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

        FieldDeclaration field = iterator.next();
        if (field.fragments().size() == 0) {
          continue;
        }

        VariableDeclarationFragment varibleDeclaration = (VariableDeclarationFragment) field.fragments().get(0);
        if (varibleDeclaration.getName().toString().equals(targetField)) {
          if (isAnnotationAlreadyUsedOnDeclaration(annotation, field)) {
            warnings.add(String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.1"), annotation.getCanonicalName(), targetClass + "." + targetField)); //$NON-NLS-1$
            return;
          }
View Full Code Here

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

  public void addField(String targetClass, String fieldName, String fieldType) {
    try {
      CompilationUnit compilationUnit = compilationUnitCache.getCompilationUnit(targetClass);
      TypeDeclaration typeDeclaration = compilationUnitCache.getTypeDeclaration(targetClass);

      VariableDeclarationFragment variableDeclaration = typeDeclaration.getAST().newVariableDeclarationFragment();
      variableDeclaration.setName(typeDeclaration.getAST().newSimpleName(fieldName));

      FieldDeclaration fieldDeclaration = typeDeclaration.getAST().newFieldDeclaration(variableDeclaration);
      Type type = JDTUtils.createQualifiedType(compilationUnit.getAST(), fieldType);
      fieldDeclaration.setType(type);
      Modifier privateModifier = fieldDeclaration.getAST().newModifier(ModifierKeyword.PRIVATE_KEYWORD);
View Full Code Here

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

        FieldDeclaration field = iterator.next();
        if (field.fragments().size() == 0) {
          continue;
        }

        VariableDeclarationFragment varibleDeclaration = (VariableDeclarationFragment) field.fragments().get(0);
        if (field.getType().resolveBinding().getQualifiedName().toString().equals(targetClass)) {
          if (isAnnotationAlreadyUsedOnDeclaration(annotation, field)) {
            warnings.add(String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.1"), annotation.getCanonicalName(), targetClass + "." + varibleDeclaration.getName().toString())); //$NON-NLS-1$
            return;
          }
         
          Annotation modifier = createModifier(cu.getAST(), annotation, properties, cu);
          field.modifiers().add(0, modifier);
View Full Code Here

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

                vds.setType(returnType);
              }
             
              ASTNode varDeclarationFragment = node.getParent();
              if (varDeclarationFragment instanceof VariableDeclarationFragment) {
                VariableDeclarationFragment vdf = (VariableDeclarationFragment) varDeclarationFragment;
               
                ClassInstanceCreation newClassInstanceCreation = vdf.getAST().newClassInstanceCreation();
                Type newType = JDTUtils.createQualifiedType(vdf.getAST(), toClass);
                newClassInstanceCreation.setType(newType);
                List arguments = newClassInstanceCreation.arguments();
                arguments.clear();
               
                MethodInvocation initializer = (MethodInvocation) vdf.getInitializer();
                List newArguments = ASTNode.copySubtrees(newClassInstanceCreation.getAST(), initializer.arguments());
                arguments.addAll(newArguments);
                 
                vdf.setInitializer(newClassInstanceCreation);
              }
            }
          } catch (JavaModelException e) {
            e.printStackTrace();
          }
View Full Code Here

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

             
              if (node.getParent() instanceof VariableDeclarationFragment) {
                Statement expressionStatement = (Statement) block.statements().get(expressionIndex);
               
                if (expressionStatement instanceof ExpressionStatement) {
                  VariableDeclarationFragment vdf = (VariableDeclarationFragment) node.getParent();
                  Expression expression = (Expression) ASTNode.copySubtree(node.getAST(), ((ExpressionStatement) expressionStatement).getExpression());
                  vdf.setInitializer(expression);
                  block.statements().remove(expressionIndex);
                  assignmentAdded = true;
                }
              }
             
View Full Code Here

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

        .result();
  }

  @Override
  public FieldDeclaration toFieldDeclaration(AST ast) {
    VariableDeclarationFragment fragment = ast.newVariableDeclarationFragment();
    fragment.setName(ast.newSimpleName(name));

    FieldDeclaration field = ast.newFieldDeclaration(fragment);
    field.setType(simpleTypeInfo.toType(ast));

    return field;
View Full Code Here

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

 
  /** (non-Javadoc)
   * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.VariableDeclarationFragment)
   */
  public boolean visit(VariableDeclarationFragment node) {
    VariableDeclarationFragment vdf = (VariableDeclarationFragment) node;
    IVariableBinding binding = vdf.resolveBinding();
    localVariables.add(new VarProposal(binding, "Local"));
    return true;
  }
View Full Code Here

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

    }

    case ASTNode.VARIABLE_DECLARATION_STATEMENT: {
      final VariableDeclarationStatement vds = (VariableDeclarationStatement) node;
      for (final Iterator it = vds.fragments().iterator(); it.hasNext();) {
        final VariableDeclarationFragment vdf = (VariableDeclarationFragment) it
            .next();
        final IJavaElement elem = vdf.resolveBinding().getJavaElement();
        if (elem.isReadOnly() || vdf.getName().resolveBoxing())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, vdf);
        if (vdf.resolveBinding().getType().isEqualTo(
            node.getAST().resolveWellKnownType("java.lang.Object"))) //$NON-NLS-1$
          throw new NonEnumerizableASTException(
              Messages.ASTNodeProcessor_IllegalArrayUpcast, vdf);
        this.found.add(elem);
        this.processExpression(vdf.getInitializer());
      }
      break;
    }

    case ASTNode.VARIABLE_DECLARATION_FRAGMENT: {
      final VariableDeclarationFragment vdf = (VariableDeclarationFragment) node;
      final IJavaElement elem = vdf.resolveBinding().getJavaElement();
      if (!this.constFields.contains(elem)) {
        if (elem == null || vdf == null || vdf.getName() == null)
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);
        if (elem.isReadOnly() || vdf.getName().resolveBoxing())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);
        if (vdf.resolveBinding().getType().isEqualTo(
            node.getAST().resolveWellKnownType("java.lang.Object"))) //$NON-NLS-1$
          throw new NonEnumerizableASTException(
              Messages.ASTNodeProcessor_IllegalArrayUpcast, vdf);
        this.found.add(elem);
        this.processExpression(vdf.getInitializer());
      }
      break;
    }

    case ASTNode.FIELD_DECLARATION: {
      final FieldDeclaration fd = (FieldDeclaration) node;
      for (final Iterator it = fd.fragments().iterator(); it.hasNext();) {
        final VariableDeclarationFragment vdf = (VariableDeclarationFragment) it
            .next();
        final IJavaElement elem = vdf.resolveBinding().getJavaElement();
        if (!this.constFields.contains(elem)) {
          if (elem.isReadOnly() || vdf.getName().resolveBoxing())
            throw new DefinitelyNotEnumerizableException(
                Messages.ASTNodeProcessor_SourceNotPresent, vdf);
          if (vdf.resolveBinding().getType().isEqualTo(
              node.getAST().resolveWellKnownType(
                  "java.lang.Object"))) //$NON-NLS-1$
            throw new NonEnumerizableASTException(
                Messages.ASTNodeProcessor_IllegalArrayUpcast, vdf);
          this.found.add(elem);
          this.processExpression(vdf.getInitializer());
        }
      }
      break;
    }
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.