Example usage for org.eclipse.jdt.core.dom MethodRefParameter isVarargs

List of usage examples for org.eclipse.jdt.core.dom MethodRefParameter isVarargs

Introduction

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

Prototype

public boolean isVarargs() 

Source Link

Document

Returns whether this method reference parameter is for the last parameter of a variable arity method (added in JLS3 API).

Usage

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

License:Open Source License

@Override
public boolean visit(MethodRefParameter node) {
    node.getType().accept(this);
    if (node.getAST().apiLevel() >= JLS3) {
        if (node.isVarargs()) {
            this.fBuffer.append("...");//$NON-NLS-1$
        }/*  w ww . j a  v a 2  s  .c  o  m*/
    }
    if (node.getName() != null) {
        this.fBuffer.append(" ");//$NON-NLS-1$
        node.getName().accept(this);
    }
    return false;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(MethodRefParameter node) {
    node.getType().accept(this);
    if (node.getAST().apiLevel() >= AST.JLS3) {
        if (node.isVarargs()) {
            this.buffer.append("...");//$NON-NLS-1$
        }//from   ww w .jav a 2 s. c  om
    }
    if (node.getName() != null) {
        this.buffer.append(" ");//$NON-NLS-1$
        node.getName().accept(this);
    }
    return false;
}

From source file:de.akra.idocit.java.utils.JavadocUtils.java

License:Apache License

/**
 * Extracts the plain text from the <code>fragments</code>.
 * /*from   ww w .  j  a v a2  s. c  om*/
 * @param fragments
 *            The fragments to read.
 * @param offset
 *            The index at which should be started to read. If the fragments are e.g.
 *            from a "@param" tag, then it is followed by the the variable name which
 *            should be skipped. Therefore the <code>offset</code> should be 1.
 * @return The text from the <code>fragments</code>.
 */
@SuppressWarnings("unchecked")
public static String readFragments(final List<ASTNode> fragments, final int offset) {
    final StringBuffer html = new StringBuffer();

    if (fragments != null && fragments.size() >= offset) {
        for (final ASTNode fragment : fragments.subList(offset, fragments.size())) {
            final StringBuffer tempText = new StringBuffer(fragment.getLength());

            switch (fragment.getNodeType()) {
            case ASTNode.TEXT_ELEMENT: {
                final TextElement textElem = (TextElement) fragment;
                tempText.append(textElem.getText());
                break;
            }
            case ASTNode.SIMPLE_NAME:
            case ASTNode.QUALIFIED_NAME: {
                final Name name = (Name) fragment;
                tempText.append(name.getFullyQualifiedName());
                break;
            }
            case ASTNode.METHOD_REF: {
                final MethodRef mRef = (MethodRef) fragment;
                if (mRef.getQualifier() != null) {
                    final Name qualifier = mRef.getQualifier();
                    tempText.append(qualifier.getFullyQualifiedName());
                }

                tempText.append('#');
                tempText.append(mRef.getName().getIdentifier());
                tempText.append('(');

                // write parameter list
                final List<MethodRefParameter> mRefParameters = (List<MethodRefParameter>) mRef.parameters();
                for (final MethodRefParameter mRefParam : mRefParameters) {
                    tempText.append(ReflectionHelper.extractIdentifierFrom(mRefParam.getType()));
                    if (mRefParam.isVarargs()) {
                        tempText.append("...");
                    }
                    if (mRefParam.getName() != null) {
                        tempText.append(' ');
                        tempText.append(mRefParam.getName().getFullyQualifiedName());
                    }
                    tempText.append(',');
                }
                if (!mRefParameters.isEmpty()) {
                    // remove last comma
                    tempText.deleteCharAt(tempText.length() - 1);
                }

                tempText.append(')');
                break;
            }
            case ASTNode.MEMBER_REF: {
                final MemberRef mRef = (MemberRef) fragment;
                if (mRef.getQualifier() != null) {
                    final Name qualifier = mRef.getQualifier();
                    tempText.append(qualifier.getFullyQualifiedName());
                }
                tempText.append('#');
                tempText.append(mRef.getName().getIdentifier());
                break;
            }
            case ASTNode.TAG_ELEMENT: {
                final TagElement tagElem = (TagElement) fragment;
                if (tagElem.isNested()) {
                    tempText.append('{');
                }

                tempText.append(tagElem.getTagName());
                tempText.append(' ');
                tempText.append(readFragments((List<ASTNode>) tagElem.fragments(), 0));

                if (tagElem.isNested()) {
                    tempText.append('}');
                }
                break;
            }
            default: {
                // Do nothing!
                logger.info("The fragment " + String.valueOf(fragment) + " has nodetype-value "
                        + fragment.getNodeType());
            }
            }
            appendWithSpace(html, tempText);
        }
        // delete leading space, that was added by Javadoc to separate a tag
        // from the following text (e.g. '@param My documentation').
        if (html.length() > 0 && html.charAt(0) == ' ') {
            html.deleteCharAt(0);
        }
    }
    return html.toString();
}

From source file:java5totext.input.JDTVisitor.java

License:Open Source License

@Override
public void endVisit(org.eclipse.jdt.core.dom.MethodRefParameter node) {
    MethodRefParameter element = (MethodRefParameter) this.binding.get(node);
    this.initializeNode(element, node);
    if (node.getName() != null)
        element.setName(node.getName().getIdentifier());
    element.setIsVarargs(node.isVarargs());
    if (this.binding.get(node.getType()) != null)
        element.setType((NamedElementRef) this.binding.get(node.getType()));
}

From source file:org.codemucker.jmutate.ast.JAstFlattener.java

License:Open Source License

public boolean visit(MethodRefParameter node) {
    node.getType().accept(this);
    if (node.getAST().apiLevel() >= JLS3) {
        if (node.isVarargs()) {
            this.buffer.append("...");//$NON-NLS-1$
        }/*  w  w w . ja  v  a2s  .c o m*/
    }
    if (node.getName() != null) {
        this.buffer.append(" ");//$NON-NLS-1$
        node.getName().accept(this);
    }
    return false;
}

From source file:org.eclipse.modisco.java.discoverer.internal.io.java.JDTVisitor.java

License:Open Source License

@Override
public void endVisit(final org.eclipse.jdt.core.dom.MethodRefParameter node) {
    MethodRefParameter element = (MethodRefParameter) this.binding.get(node);
    initializeNode(element, node);/*  w ww  .j  a v  a 2s  .  co m*/

    if (node.getName() != null) {
        element.setName(node.getName().getIdentifier());
    }

    element.setVarargs(node.isVarargs());

    if (this.binding.get(node.getType()) != null) {
        element.setType(JDTVisitorUtils.completeTypeAccess(this.binding.get(node.getType()), this));
    }
}

From source file:org.eclipse.xtend.core.javaconverter.JavaASTFlattener.java

License:Open Source License

@Override
public boolean visit(final MethodRefParameter node) {
    node.getType().accept(this);
    boolean _isVarargs = node.isVarargs();
    if (_isVarargs) {
        this.appendToBuffer("...");
    }/*from w  w  w .j av  a  2  s .  com*/
    SimpleName _name = node.getName();
    boolean _tripleNotEquals = (_name != null);
    if (_tripleNotEquals) {
        this.appendSpaceToBuffer();
        node.getName().accept(this);
    }
    return false;
}

From source file:org.whole.lang.java.util.JDTTransformerVisitor.java

License:Open Source License

public boolean visit(MethodRefParameter node) {
    this.methodRefParameter = lf.createMethodRefParameter();

    acceptChild(node.getType());// www  .j a va  2s .  c o  m
    this.methodRefParameter.setType(this.type);

    if (node.isVarargs())
        this.methodRefParameter.setVarargs(lf.createVarargs(true));

    this.methodRefParameter
            .setName(acceptChild(node.getName()) ? (org.whole.lang.java.model.SimpleName) this.name
                    : createResolver(JavaEntityDescriptorEnum.SimpleName));
    return false;
}