Example usage for org.eclipse.jdt.core.dom FieldDeclaration getJavadoc

List of usage examples for org.eclipse.jdt.core.dom FieldDeclaration getJavadoc

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom FieldDeclaration getJavadoc.

Prototype

public Javadoc getJavadoc() 

Source Link

Document

Returns the doc comment node.

Usage

From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java

License:Open Source License

@Override
public boolean visit(FieldDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }/*from  w w  w .j  a  va2s.co  m*/
    if (node.getAST().apiLevel() >= JLS3) {
        printModifiers(node.modifiers());
    }
    node.getType().accept(this);
    this.fBuffer.append(" ");//$NON-NLS-1$
    for (Iterator<VariableDeclarationFragment> it = node.fragments().iterator(); it.hasNext();) {
        VariableDeclarationFragment f = it.next();
        f.accept(this);
        if (it.hasNext()) {
            this.fBuffer.append(", ");//$NON-NLS-1$
        }
    }
    this.fBuffer.append(";");//$NON-NLS-1$
    return false;
}

From source file:chibi.gumtreediff.gen.jdt.cd.CdJdtVisitor.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from  w w w . ja va  2s.co m
public boolean visit(FieldDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }

    // @Inria
    pushNode(node, node.toString());
    //
    visitListAsNode(EntityType.MODIFIERS, node.modifiers());
    node.getType().accept(this);
    visitListAsNode(EntityType.FRAGMENTS, node.fragments());

    return false;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(FieldDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }//w  w w  .j a v a  2s .c o m
    printIndent();
    if (node.getAST().apiLevel() >= AST.JLS3) {
        printModifiers(node.modifiers());
    }
    node.getType().accept(this);
    this.buffer.append(" ");//$NON-NLS-1$
    for (Iterator it = node.fragments().iterator(); it.hasNext();) {
        VariableDeclarationFragment f = (VariableDeclarationFragment) it.next();
        f.accept(this);
        if (it.hasNext()) {
            this.buffer.append(", ");//$NON-NLS-1$
        }
    }
    this.buffer.append(";\n");//$NON-NLS-1$
    return false;
}

From source file:com.crispico.flower.mp.metamodel.codesyncjava.algorithm.reverse.ReverseJavaClass_OwnedFields.java

License:Open Source License

/**
 * @flowerModelElementId _zb9VMpiOEd6aNMdNFvR5WQ
 *///from   w  w  w .  j  a  v  a  2  s.c  om
@Override
protected String getUIDForAstElement(FieldDeclaration astElement) {
    Javadoc docComment = astElement.getJavadoc();
    if (docComment == null)
        return null;
    else
        return SyncUtils.getFlowerModelElementID((String) docComment.getProperty("comment"));
}

From source file:com.google.devtools.j2objc.ast.DebugASTPrinter.java

License:Apache License

@Override
public boolean visit(FieldDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }//from   ww w.jav  a2  s. com
    sb.printIndent();
    printModifiers(node.getModifiers());
    node.getType().accept(this);
    sb.print(' ');
    for (Iterator<VariableDeclarationFragment> it = node.getFragments().iterator(); it.hasNext();) {
        it.next().accept(this);
        if (it.hasNext()) {
            sb.print(", ");
        }
    }
    sb.println(';');
    return false;
}

From source file:com.j2swift.ast.DebugASTPrinter.java

License:Apache License

@Override
public boolean visit(FieldDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }//  w  ww .ja v a2s  .  c om
    sb.printIndent();
    printAnnotations(node.getAnnotations());
    printModifiers(node.getModifiers());
    node.getType().accept(this);
    sb.print(' ');
    for (Iterator<VariableDeclarationFragment> it = node.getFragments().iterator(); it.hasNext();) {
        it.next().accept(this);
        if (it.hasNext()) {
            sb.print(", ");
        }
    }
    sb.println(';');
    return false;
}

From source file:ctrus.pa.bow.java.token.ClassTokens.java

License:Apache License

@SuppressWarnings("unchecked")
private void addTokensFromFieldDeclaration(FieldDeclaration fd) {
    // Add field type to tokens
    addToken(fd.getType().toString());//from   ww  w .j  av a  2s .c om

    // Add field variable declaration and its expression to tokens
    List<VariableDeclarationFragment> frags = (List<VariableDeclarationFragment>) fd.fragments();
    for (VariableDeclarationFragment f : frags) {
        addToken(f.getName().getFullyQualifiedName());
        Expression ex = f.getInitializer();
        if (ex != null && !(ex instanceof NullLiteral)) {
            addToken(ex.toString());
        }
    }

    // Add any javadocs associated with the field to tokens
    // Block and line comments are added later
    if (!_ignoreComments && !_stateAnalysis) {
        addTokensFromJavaDoc(fd.getJavadoc());
    }
}

From source file:de.gebit.integrity.ui.utils.JavadocUtil.java

License:Open Source License

/**
 * Returns the Javadoc description attached to a given {@link IField}.
 * /* w  w w  .  j a  va2  s .com*/
 * @param aField
 *            the field to explore
 * @return the Javadoc String, or null if there is none
 */
public static String getFieldJavadoc(IField aField) {
    ICompilationUnit tempCompilationUnit = aField.getCompilationUnit();
    AbstractTypeDeclaration tempType = parseCompilationUnit(tempCompilationUnit);

    if (tempType instanceof TypeDeclaration) {
        List<TypeDeclaration> tempTypes = new ArrayList<TypeDeclaration>();
        tempTypes.add((TypeDeclaration) tempType);
        // also visit all subtypes (inner classes!)
        Collections.addAll(tempTypes, ((TypeDeclaration) tempType).getTypes());

        for (TypeDeclaration tempTypeDeclaration : tempTypes) {
            for (FieldDeclaration tempField : tempTypeDeclaration.getFields()) {
                if (compareFields(tempField, aField)) {
                    Javadoc tempJavadoc = tempField.getJavadoc();
                    if (tempJavadoc != null) {
                        return getJavadocMainText(tempJavadoc);
                    } else {
                        break;
                    }
                }
            }
        }
    }

    return null;
}

From source file:edu.buffalo.cse.green.editor.controller.FieldPart.java

License:Open Source License

/**
 * @see edu.buffalo.cse.green.editor.controller.MemberPart#getJavadocGrabber()
 */// w ww .  j av  a  2 s . co  m
@Override
protected JavadocGrabber getJavadocGrabber() {
    return new JavadocGrabber() {
        private boolean _alive = true;

        /**
         * @see org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core.dom.FieldDeclaration)
         */
        @Override
        public boolean visit(FieldDeclaration node) {
            if (!_alive)
                return false;

            for (VariableDeclarationFragment vdf : (AbstractList<VariableDeclarationFragment>) (List) node
                    .fragments()) {
                if (compareElements(vdf.resolveBinding().getJavaElement())) {
                    _alive = false;
                    _doc = getDoc(node.getJavadoc());
                    break;
                }
            }

            return _alive;
        }
    };
}

From source file:edu.uci.ics.sourcerer.extractor.ast.ReferenceExtractorVisitor.java

License:Open Source License

/**
 * This method writes:/*from w w w . j a  va  2  s.  c om*/
 * <ul>
 *   <li>Field entity to <code>IEntityWriter</code>.
 *   <ul>
 *     <li>Inside relation to <code>IRelationWriter</code>.</li>
 *     <li>Holds relation to <code>IRelationWriter</code>.</li>
 *   </ul></li>
 *   <li>Local variable to <code>ILocalVariableWriter</code>.
 *   <ul>
 *     <li>Uses relation to <code>IRelationWriter</codE>.</li>
 *   </ul></li>
 * </ul>
 * 
 * Field fully qualified names (FQNs) adhere to the following format:<br> 
 * parent fqn + . + simple name
 */
@Override
public boolean visit(VariableDeclarationFragment node) {
    if (node.getParent() instanceof FieldDeclaration) {
        FieldDeclaration parent = (FieldDeclaration) node.getParent();

        // Get the fqn
        String fqn = fqnStack.getTypeFqn(node.getName().getIdentifier());

        // Write the entity
        entityWriter.writeField(fqn, parent.getModifiers(),
                MetricsCalculator.computeLinesOfCode(getSource(node)), getLocation(node));

        // Write the inside relation
        relationWriter.writeInside(fqn, fqnStack.getFqn(), getUnknownLocation());

        Type type = parent.getType();
        String typeFqn = getTypeFqn(type);

        // Write the holds relation
        relationWriter.writeHolds(fqn, typeFqn, getLocation(type));

        // Add the field to the fqnstack
        fqnStack.push(fqn, Entity.FIELD);

        // Write the uses relation
        accept(parent.getType());

        // Write the javadoc comment
        accept(parent.getJavadoc());
    } else if (node.getParent() instanceof VariableDeclarationStatement) {
        VariableDeclarationStatement parent = (VariableDeclarationStatement) node.getParent();

        Type type = parent.getType();
        String typeFqn = getTypeFqn(type);

        // Write the local variable
        localVariableWriter.writeLocalVariable(node.getName().getIdentifier(), parent.getModifiers(), typeFqn,
                type.getStartPosition(), type.getLength(), fqnStack.getFqn(), getLocation(node));
    } else if (node.getParent() instanceof VariableDeclarationExpression) {
        VariableDeclarationExpression parent = (VariableDeclarationExpression) node.getParent();

        Type type = parent.getType();
        String typeFqn = getTypeFqn(type);

        // Write the local variable
        localVariableWriter.writeLocalVariable(node.getName().getIdentifier(), parent.getModifiers(), typeFqn,
                type.getStartPosition(), type.getLength(), fqnStack.getFqn(), getLocation(node));
    } else {
        logger.log(Level.SEVERE, "Unknown parent for variable declaration fragment.");
    }

    IVariableBinding binding = node.resolveBinding();
    if (binding != null && binding.isField() && !(node.getParent() instanceof FieldDeclaration)) {
        logger.log(Level.SEVERE, "It's a field but it shouldn't be!");
    }

    if (node.getInitializer() != null) {
        inLhsAssignment = true;
        accept(node.getName());
        inLhsAssignment = false;
        accept(node.getInitializer());
    }

    return false;
}