Example usage for org.eclipse.jdt.internal.compiler.ast Javadoc Javadoc

List of usage examples for org.eclipse.jdt.internal.compiler.ast Javadoc Javadoc

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.ast Javadoc Javadoc.

Prototype

public Javadoc(int sourceStart, int sourceEnd) 

Source Link

Usage

From source file:lombok.eclipse.handlers.ast.EclipseASTMaker.java

License:Open Source License

@Override
public ASTNode visitJavaDoc(final lombok.ast.JavaDoc node, final Void p) {
    final Javadoc javadoc = new Javadoc(0, 0);
    setGeneratedByAndCopyPos(javadoc, source, posHintOf(node));
    // TODO node.getMessage()
    final List<JavadocSingleNameReference> argumentReferences = new ArrayList<JavadocSingleNameReference>();
    for (Map.Entry<String, String> argumentReference : node.getArgumentReferences().entrySet()) {
        final JavadocSingleNameReference ref = new JavadocSingleNameReference(
                (argumentReference.getKey()).toCharArray(), 0, 0, 0); // TODO argumentReference.getValue()
        setGeneratedByAndCopyPos(ref, source, posHintOf(node));
        argumentReferences.add(ref);//from   ww  w. j  a v a2s.  c  om
    }
    javadoc.paramReferences = toArray(argumentReferences, new JavadocSingleNameReference[0]);
    final List<JavadocSingleTypeReference> paramTypeReferences = new ArrayList<JavadocSingleTypeReference>();
    for (Map.Entry<String, String> paramTypeReference : node.getParamTypeReferences().entrySet()) {
        final JavadocSingleTypeReference ref = new JavadocSingleTypeReference(
                (paramTypeReference.getKey()).toCharArray(), 0, 0, 0); // TODO paramTypeReference.getValue()
        setGeneratedByAndCopyPos(ref, source, posHintOf(node));
        paramTypeReferences.add(ref);
    }
    javadoc.paramTypeParameters = toArray(paramTypeReferences, new JavadocSingleTypeReference[0]);
    final List<TypeReference> exceptionReferences = new ArrayList<TypeReference>();
    for (Map.Entry<lombok.ast.TypeRef, String> exceptionReference : node.getExceptionReferences().entrySet()) {
        final TypeReference ref = build(exceptionReference.getKey()); // TODO exceptionReference.getValue()
        setGeneratedByAndCopyPos(ref, source, posHintOf(node));
        exceptionReferences.add(ref);
    }
    javadoc.exceptionReferences = toArray(exceptionReferences, new TypeReference[0]);
    if (node.getReturnMessage() != null)
        javadoc.returnStatement = new JavadocReturnStatement(0, 0); // TODO node.getReturnStatement()
    return javadoc;
}

From source file:org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.java

License:Open Source License

/**
 * Find any javadoc that terminates on one of the two lines before the specified line, return the first bit encountered. A
 * little crude but will cover a lot of common cases... <br>
 */// w  ww . j av  a  2s. c om
// FIXASC when the parser correctly records javadoc for nodes alongside them during a parse, we will not have to search
private Javadoc findJavadoc(int line) {
    // System.out.println("Looking for javadoc for line " + line);
    for (Comment comment : groovySourceUnit.getComments()) {
        if (comment.isJavadoc()) {
            // System.out.println("Checking against comment ending on " + comment.getLastLine());
            if (comment.getLastLine() + 1 == line || (comment.getLastLine() + 2 == line && !comment.usedUp)) {
                int[] pos = comment.getPositions(compilationResult.lineSeparatorPositions);
                // System.out.println("Comment says it is from line=" + comment.sline + ",col=" + comment.scol + " to line="
                // + comment.eline + ",col=" + comment.ecol);
                // System.out.println("Returning positions " + pos[0] + ">" + pos[1]);
                comment.usedUp = true;
                return new Javadoc(pos[0], pos[1]);
            }
        }
    }
    return null;
}

From source file:org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.java

License:Open Source License

/**
 * Build JDT representations of all the fields on the groovy type. <br>
 * Enum field handling<br>/*from w w  w  .ja  v  a2  s . c o  m*/
 * Groovy handles them as follows: they have the ACC_ENUM bit set and the type is the type of the declaring enum type. When
 * building declarations, if you want the SourceTypeBinding to correctly build an enum field binding (in
 * SourceTypeBinding.resolveTypeFor(FieldBinding)) then you need to: (1) avoid setting modifiers, the enum fields are not
 * expected to have any modifiers (2) leave the type as null, that is how these things are identified by JDT.
 */
private FieldDeclaration[] createFieldDeclarations(ClassNode classNode) {
    List<FieldDeclaration> fieldDeclarations = new ArrayList<FieldDeclaration>();
    List<FieldNode> fieldNodes = classNode.getFields();
    if (fieldNodes != null) {
        for (FieldNode fieldNode : fieldNodes) {
            boolean isEnumField = (fieldNode.getModifiers() & Opcodes.ACC_ENUM) != 0;
            boolean isSynthetic = (fieldNode.getModifiers() & Opcodes.ACC_SYNTHETIC) != 0;
            if (!isSynthetic) {
                // JavaStubGenerator ignores private fields but I don't
                // think we want to here
                FieldDeclarationWithInitializer fieldDeclaration = new FieldDeclarationWithInitializer(
                        fieldNode.getName().toCharArray(), 0, 0);
                fieldDeclaration.annotations = transformAnnotations(fieldNode.getAnnotations());
                if (!isEnumField) {
                    fieldDeclaration.modifiers = fieldNode.getModifiers() & ~0x4000; // 4000 == AccEnum
                    fieldDeclaration.type = createTypeReferenceForClassNode(fieldNode.getType());
                }
                fieldDeclaration.javadoc = new Javadoc(108, 132);
                fixupSourceLocationsForFieldDeclaration(fieldDeclaration, fieldNode, isEnumField);
                fieldDeclaration.setGroovyInitializer(fieldNode.getInitialExpression());
                fieldDeclarations.add(fieldDeclaration);
            }
        }
    }
    return fieldDeclarations.toArray(new FieldDeclaration[fieldDeclarations.size()]);
}