Package org.eclipse.jdt.core.dom

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


   @Override
   @SuppressWarnings("unchecked")
   public O removeField(final Field<O> field)
   {
      VariableDeclarationFragment fragment = (VariableDeclarationFragment) field.getInternal();
      Iterator<Object> declarationsIterator = getBodyDeclaration().bodyDeclarations().iterator();
      while (declarationsIterator.hasNext())
      {
         Object next = declarationsIterator.next();
         if (next instanceof FieldDeclaration)
         {
            FieldDeclaration declaration = (FieldDeclaration) next;
            if (declaration.equals(fragment.getParent()))
            {
               List<VariableDeclarationFragment> fragments = declaration.fragments();
               if (fragments.contains(fragment))
               {
                  if (fragments.size() == 1)
View Full Code Here


      String result = null;
      for (Object f : field.fragments())
      {
         if (f instanceof VariableDeclarationFragment)
         {
            VariableDeclarationFragment frag = (VariableDeclarationFragment) f;
            result = frag.getName().getFullyQualifiedName();
            break;
         }
      }
      return result;
   }
View Full Code Here

   {
      for (Object f : field.fragments())
      {
         if (f instanceof VariableDeclarationFragment)
         {
            VariableDeclarationFragment frag = (VariableDeclarationFragment) f;
            frag.setName(ast.newSimpleName(name));
            break;
         }
      }
      return this;
   }
View Full Code Here

      String result = null;
      for (Object f : field.fragments())
      {
         if (f instanceof VariableDeclarationFragment)
         {
            VariableDeclarationFragment frag = (VariableDeclarationFragment) f;
            result = frag.getInitializer().toString();
            break;
         }
      }
      return result;
   }
View Full Code Here

      String result = null;
      for (Object f : field.fragments())
      {
         if (f instanceof VariableDeclarationFragment)
         {
            VariableDeclarationFragment frag = (VariableDeclarationFragment) f;
            result = Strings.unquote(frag.getInitializer().toString());
            break;
         }
      }
      return result;
   }
View Full Code Here

      for (Object f : internal.fragments())
      {
         if (f instanceof VariableDeclarationFragment)
         {
            VariableDeclarationFragment tempFrag = (VariableDeclarationFragment) f;
            VariableDeclarationFragment localFrag = getFragment(field);
            localFrag.setInitializer((Expression) ASTNode.copySubtree(ast, tempFrag.getInitializer()));
            break;
         }
      }

      return this;
View Full Code Here

      return setLiteralInitializer(Strings.enquote(value));
   }

   private VariableDeclarationFragment getFragment(final FieldDeclaration field)
   {
      VariableDeclarationFragment result = null;
      for (Object f : field.fragments())
      {
         if (f instanceof VariableDeclarationFragment)
         {
            result = (VariableDeclarationFragment) f;
View Full Code Here

   *
   * @see net.sourceforge.earticleast.app.AbstractManipulator#deleteOldVariableDeclaration(net.sourceforge.earticleast.app.VariableBindingManager)
   */
  @Override
  protected void deleteOldVariableDeclaration(VariableBindingManager manager) {
    VariableDeclarationFragment fragment = manager
        .getVariableDeclarationFragment();
    VariableDeclarationStatement statement = (VariableDeclarationStatement) fragment
        .getParent();
    fragment.delete();
    if (statement.fragments().size() == 0) {
      statement.delete();
    }
  }
View Full Code Here

   *         reference
   */
  @Override
  public boolean visit(VariableDeclarationStatement node) {
    for (Iterator iter = node.fragments().iterator(); iter.hasNext();) {
      VariableDeclarationFragment fragment = (VariableDeclarationFragment) iter
          .next();

      // VariableDeclarationFragment: is the plain variable declaration
      // part. Example:
      // "int x=0, y=0;" contains two VariableDeclarationFragments, "x=0"
      // and "y=0"

      IVariableBinding binding = fragment.resolveBinding();
      VariableBindingManager manager = new VariableBindingManager(
          fragment); // create the manager fro the fragment
      localVariableManagers.put(binding, manager);
      manager.variableInitialized(fragment.getInitializer());
      // first assignment is the initalizer
    }
    return false; // prevent that SimpleName is interpreted as
    // reference
  }
View Full Code Here

   *
   * @see net.sourceforge.earticleast.app.AbstractManipulator#addNewVariableDeclaration(net.sourceforge.earticleast.app.VariableBindingManager)
   */
  @Override
  protected void addNewVariableDeclaration(VariableBindingManager manager) {
    VariableDeclarationFragment fragment = manager
        .getVariableDeclarationFragment();
    VariableDeclarationStatement statement = (VariableDeclarationStatement) fragment
        .getParent();
    // add a remove command to the protocol
    rewrite.remove(fragment, null);
    ListRewrite fragmentsListRewrite = rewrite.getListRewrite(statement,
        VariableDeclarationStatement.FRAGMENTS_PROPERTY);
View Full Code Here

TOP

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

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.