Package org.eclipse.jdt.core.dom

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


      init(parent);

      String stub = "public class Stub { " + declaration + " }";
      JavaClass temp = (JavaClass) JavaParser.parse(stub);
      List<Field<JavaClass>> fields = temp.getFields();
      FieldDeclaration newField = (FieldDeclaration) fields.get(0).getInternal();
      FieldDeclaration subtree = (FieldDeclaration) ASTNode.copySubtree(ast, newField);
      this.field = subtree;
   }
View Full Code Here


   @Override
   public Field<O> setLiteralInitializer(final String value)
   {
      String stub = "public class Stub { private Field<O> stub = " + value + " }";
      JavaClass temp = (JavaClass) JavaParser.parse(stub);
      FieldDeclaration internal = (FieldDeclaration) temp.getFields().get(0).getInternal();

      for (Object f : internal.fragments())
      {
         if (f instanceof VariableDeclarationFragment)
         {
            VariableDeclarationFragment tempFrag = (VariableDeclarationFragment) f;
            VariableDeclarationFragment localFrag = getFragment(field);
View Full Code Here

                               new CompletionCandidate(
                                                       ((MethodDeclaration) awnode
                                                           .getNode()))
                                   .toString());
    } else if (awnode.getNode() instanceof FieldDeclaration) {
      FieldDeclaration fd = (FieldDeclaration) awnode.getNode();
      for (VariableDeclarationFragment vdf : (List<VariableDeclarationFragment>) fd
          .fragments()) {
        DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(
                                                                    new ASTNodeWrapper(
                                                                                       vdf.getName(),
                                                                                       new CompletionCandidate(
View Full Code Here

    } else if (thisNode instanceof MethodDeclaration) {
      altStartPos = getJavadocOffset((MethodDeclaration) thisNode);
      jd = ((MethodDeclaration) thisNode).getJavadoc();
      log("Has m jdoc " + jd);
    } else if (thisNode instanceof FieldDeclaration) {
      FieldDeclaration fd = ((FieldDeclaration) thisNode);
      jd = fd.getJavadoc();
      log("Has f jdoc " + fd.getJavadoc());
      altStartPos = getJavadocOffset(fd);
      //nodeOffset = ((VariableDeclarationFragment)(fd.fragments().get(0))).getName().getStartPosition();
    }
   
    if(jd == null){
View Full Code Here

   * @return the unique field name
   */
  private String getUniqueFieldName(String fieldName, List<BodyDeclaration> bodyDeclarations) {
    Iterator<BodyDeclaration> iter = bodyDeclarations.iterator();
    BodyDeclaration bodyDeclaration;
    FieldDeclaration fieldDeclaration;
    String foundName;
    while (iter.hasNext()) {
      bodyDeclaration = iter.next();
      if (bodyDeclaration instanceof FieldDeclaration) {
        fieldDeclaration = (FieldDeclaration) bodyDeclaration;
        for (Iterator<VariableDeclarationFragment> iterator = fieldDeclaration.fragments()
            .iterator(); iterator.hasNext();) {
          foundName = iterator.next()
              .getName().getIdentifier();
          if (foundName.startsWith(fieldName)) {
            fieldName = foundName + '_';
View Full Code Here

              Flags.isStatic(enclosingMethodDeclaration
                  .getModifiers()), bodyDeclarations,
              getTypeName(node.getType()), source);

        } else if (parent instanceof FieldDeclaration) {
          FieldDeclaration enclosingFieldDeclaration = (FieldDeclaration) parent;

          if (Flags
              .isStatic(enclosingFieldDeclaration.getModifiers())) {
            fSource.append("static "); //$NON-NLS-1$
          }

          Type type = getParentType(enclosingFieldDeclaration
              .getType());
          fSource.append(getQualifiedIdentifier(((SimpleType) type)
              .getName()));
          fSource.append(' ');
          fSource.append(getUniqueFieldName(EVAL_FIELD_NAME,
View Full Code Here

      final List<BodyDeclaration> bodyDeclarations = getBody().bodyDeclarations();
      for (BodyDeclaration bodyDeclaration : bodyDeclarations)
      {
         if (bodyDeclaration instanceof FieldDeclaration)
         {
            FieldDeclaration fieldDeclaration = (FieldDeclaration) bodyDeclaration;
            List<VariableDeclarationFragment> fragments = fieldDeclaration.fragments();
            for (VariableDeclarationFragment fragment : fragments)
            {
               result.add(new FieldImpl<Body>(this, fragment));
            }
         }
View Full Code Here

      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)
                  {
                     declarationsIterator.remove();
View Full Code Here

   {
      init(parent);
      if (copy)
      {
         VariableDeclarationFragment newFieldFragment = (VariableDeclarationFragment) internal;
         FieldDeclaration newFieldDeclaration = (FieldDeclaration) newFieldFragment.getParent();
         this.field = (FieldDeclaration) ASTNode.copySubtree(ast, newFieldDeclaration);
         Iterator<VariableDeclarationFragment> fragmentsIterator = this.field.fragments().iterator();
         VariableDeclarationFragment temp = null;
         while (fragmentsIterator.hasNext())
         {
View Full Code Here

        VariableDeclarationFragment fieldId = ast
            .newVariableDeclarationFragment();
        fieldId.setName(ast.newSimpleName(id.toLowerCase()));

        FieldDeclaration fieldDeclaration = ast
            .newFieldDeclaration(fieldId);

        Modifier m = getAccessModifier(vis);
        if (m != null)
          fieldDeclaration.modifiers().add(m);

        Type t = getType(type);
        fieldDeclaration.setType(t);

        // inicializa o field
        VariableDeclarationFragment variable = (VariableDeclarationFragment) fieldDeclaration
            .fragments().get(0);
        Expression inializer;
        if (type.equals("Int__0") || type.equals("Long__0")) {
          // pega o valor que sera inicializado a partir da inst�ncia
          String value = "1" + field.substring(field.length() - 1);
View Full Code Here

TOP

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

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.