Search in sources :

Example 1 with MethodRefParameter

use of org.eclipse.jdt.core.dom.MethodRefParameter in project che by eclipse.

the class ImportReferencesCollector method visit.

@Override
public boolean visit(MethodRef node) {
    Name qualifier = node.getQualifier();
    if (qualifier != null) {
        typeRefFound(qualifier);
    }
    List<MethodRefParameter> list = node.parameters();
    if (list != null) {
        // visit MethodRefParameter with Type
        doVisitChildren(list);
    }
    return false;
}
Also used : MethodRefParameter(org.eclipse.jdt.core.dom.MethodRefParameter) SimpleName(org.eclipse.jdt.core.dom.SimpleName) Name(org.eclipse.jdt.core.dom.Name) QualifiedName(org.eclipse.jdt.core.dom.QualifiedName)

Example 2 with MethodRefParameter

use of org.eclipse.jdt.core.dom.MethodRefParameter in project che by eclipse.

the class JavadocContentAccess2 method handleLink.

private void handleLink(List<? extends ASTNode> fragments) {
    //TODO: Javadoc shortens type names to minimal length according to context
    int fs = fragments.size();
    if (fs > 0) {
        Object first = fragments.get(0);
        String refTypeName = null;
        String refMemberName = null;
        String[] refMethodParamTypes = null;
        String[] refMethodParamNames = null;
        if (first instanceof Name) {
            Name name = (Name) first;
            refTypeName = name.getFullyQualifiedName();
        } else if (first instanceof MemberRef) {
            MemberRef memberRef = (MemberRef) first;
            Name qualifier = memberRef.getQualifier();
            //$NON-NLS-1$
            refTypeName = qualifier == null ? "" : qualifier.getFullyQualifiedName();
            refMemberName = memberRef.getName().getIdentifier();
        } else if (first instanceof MethodRef) {
            MethodRef methodRef = (MethodRef) first;
            Name qualifier = methodRef.getQualifier();
            //$NON-NLS-1$
            refTypeName = qualifier == null ? "" : qualifier.getFullyQualifiedName();
            refMemberName = methodRef.getName().getIdentifier();
            List<MethodRefParameter> params = methodRef.parameters();
            int ps = params.size();
            refMethodParamTypes = new String[ps];
            refMethodParamNames = new String[ps];
            for (int i = 0; i < ps; i++) {
                MethodRefParameter param = params.get(i);
                refMethodParamTypes[i] = ASTNodes.asString(param.getType());
                SimpleName paramName = param.getName();
                if (paramName != null)
                    refMethodParamNames[i] = paramName.getIdentifier();
            }
        }
        if (refTypeName != null) {
            //$NON-NLS-1$
            fBuf.append("<a href='");
            try {
                String scheme = urlPrefix;
                String uri = JavaElementLinks.createURI(scheme, fElement, refTypeName, refMemberName, refMethodParamTypes);
                fBuf.append(uri);
            } catch (URISyntaxException e) {
                LOG.error(e.getMessage(), e);
            }
            //$NON-NLS-1$
            fBuf.append("'>");
            if (fs > 1 && !(fs == 2 && isWhitespaceTextElement(fragments.get(1)))) {
                handleContentElements(fragments.subList(1, fs), true);
            } else {
                fBuf.append(refTypeName);
                if (refMemberName != null) {
                    if (refTypeName.length() > 0) {
                        fBuf.append('.');
                    }
                    fBuf.append(refMemberName);
                    if (refMethodParamTypes != null) {
                        fBuf.append('(');
                        for (int i = 0; i < refMethodParamTypes.length; i++) {
                            String pType = refMethodParamTypes[i];
                            fBuf.append(pType);
                            String pName = refMethodParamNames[i];
                            if (pName != null) {
                                fBuf.append(' ').append(pName);
                            }
                            if (i < refMethodParamTypes.length - 1) {
                                //$NON-NLS-1$
                                fBuf.append(", ");
                            }
                        }
                        fBuf.append(')');
                    }
                }
            }
            //$NON-NLS-1$
            fBuf.append("</a>");
        } else {
            handleContentElements(fragments);
        }
    }
}
Also used : MethodRef(org.eclipse.jdt.core.dom.MethodRef) SimpleName(org.eclipse.jdt.core.dom.SimpleName) MethodRefParameter(org.eclipse.jdt.core.dom.MethodRefParameter) MemberRef(org.eclipse.jdt.core.dom.MemberRef) URISyntaxException(java.net.URISyntaxException) SimpleName(org.eclipse.jdt.core.dom.SimpleName) Name(org.eclipse.jdt.core.dom.Name)

Example 3 with MethodRefParameter

use of org.eclipse.jdt.core.dom.MethodRefParameter in project flux by eclipse.

the class ImportReferencesCollector method visit.

@Override
public boolean visit(MethodRef node) {
    Name qualifier = node.getQualifier();
    if (qualifier != null) {
        typeRefFound(qualifier);
    }
    List<MethodRefParameter> list = node.parameters();
    if (list != null) {
        // visit MethodRefParameter with Type
        doVisitChildren(list);
    }
    return false;
}
Also used : MethodRefParameter(org.eclipse.jdt.core.dom.MethodRefParameter) SimpleName(org.eclipse.jdt.core.dom.SimpleName) Name(org.eclipse.jdt.core.dom.Name) QualifiedName(org.eclipse.jdt.core.dom.QualifiedName)

Example 4 with MethodRefParameter

use of org.eclipse.jdt.core.dom.MethodRefParameter in project che by eclipse.

the class DelegateMethodCreator method createArguments.

@SuppressWarnings("unchecked")
private void createArguments(final MethodDeclaration declaration, final List<? extends ASTNode> arguments, boolean methodInvocation) {
    Assert.isNotNull(declaration);
    Assert.isNotNull(arguments);
    SingleVariableDeclaration variable = null;
    final int size = declaration.parameters().size();
    for (int index = 0; index < size; index++) {
        variable = (SingleVariableDeclaration) declaration.parameters().get(index);
        if (methodInvocation) {
            // we are creating method invocation parameters
            final SimpleName expression = getAst().newSimpleName(variable.getName().getIdentifier());
            ((List<Expression>) arguments).add(expression);
        } else {
            // we are creating type info for the javadoc
            final MethodRefParameter parameter = getAst().newMethodRefParameter();
            parameter.setType(ASTNodeFactory.newType(getAst(), variable));
            if ((index == size - 1) && declaration.isVarargs())
                parameter.setVarargs(true);
            ((List<MethodRefParameter>) arguments).add(parameter);
        }
    }
}
Also used : SingleVariableDeclaration(org.eclipse.jdt.core.dom.SingleVariableDeclaration) SimpleName(org.eclipse.jdt.core.dom.SimpleName) MethodRefParameter(org.eclipse.jdt.core.dom.MethodRefParameter) List(java.util.List)

Aggregations

MethodRefParameter (org.eclipse.jdt.core.dom.MethodRefParameter)4 SimpleName (org.eclipse.jdt.core.dom.SimpleName)4 Name (org.eclipse.jdt.core.dom.Name)3 QualifiedName (org.eclipse.jdt.core.dom.QualifiedName)2 URISyntaxException (java.net.URISyntaxException)1 List (java.util.List)1 MemberRef (org.eclipse.jdt.core.dom.MemberRef)1 MethodRef (org.eclipse.jdt.core.dom.MethodRef)1 SingleVariableDeclaration (org.eclipse.jdt.core.dom.SingleVariableDeclaration)1