Search in sources :

Example 1 with JvmExecutableImplCustom

use of org.eclipse.xtext.common.types.impl.JvmExecutableImplCustom in project xtext-eclipse by eclipse.

the class JdtBasedTypeFactory method enhanceExecutable.

/**
 * @since 2.4
 */
protected void enhanceExecutable(StringBuilder fqn, String handleIdentifier, String[] path, JvmExecutable result, IMethodBinding method) {
    String name = method.getName();
    fqn.append(name);
    fqn.append('(');
    ITypeBinding[] parameterTypes = method.getParameterTypes();
    for (int i = 0; i < parameterTypes.length; i++) {
        if (i != 0)
            fqn.append(',');
        fqn.append(getQualifiedName(parameterTypes[i]));
    }
    fqn.append(')');
    result.internalSetIdentifier(fqn.toString());
    result.setSimpleName(name);
    setVisibility(result, method.getModifiers());
    result.setDeprecated(method.isDeprecated());
    if (parameterTypes.length > 0) {
        result.setVarArgs(method.isVarargs());
        String[] parameterNames = null;
        // If the method is derived from source, we can efficiently determine the parameter names now.
        // 
        ITypeBinding declaringClass = method.getDeclaringClass();
        if (declaringClass.isFromSource()) {
            parameterNames = getParameterNamesFromSource(fqn, method);
        } else {
            // Use the key to determine the signature for the method.
            // 
            SegmentSequence signaturex = getSignatureAsSegmentSequence(method);
            ParameterNameInitializer initializer = jdtCompliance.createParameterNameInitializer(method, workingCopyOwner, result, handleIdentifier, path, name, signaturex);
            ((JvmExecutableImplCustom) result).setParameterNameInitializer(initializer);
        }
        setParameterNamesAndAnnotations(method, parameterTypes, parameterNames, result);
    }
    ITypeBinding[] exceptionTypes = method.getExceptionTypes();
    if (exceptionTypes.length > 0) {
        InternalEList<JvmTypeReference> exceptions = (InternalEList<JvmTypeReference>) result.getExceptions();
        for (ITypeBinding exceptionType : exceptionTypes) {
            exceptions.addUnique(createTypeReference(exceptionType));
        }
    }
}
Also used : SegmentSequence(org.eclipse.emf.common.util.SegmentSequence) JvmExecutableImplCustom(org.eclipse.xtext.common.types.impl.JvmExecutableImplCustom) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding) InternalEList(org.eclipse.emf.ecore.util.InternalEList) JvmTypeConstraint(org.eclipse.xtext.common.types.JvmTypeConstraint)

Aggregations

SegmentSequence (org.eclipse.emf.common.util.SegmentSequence)1 InternalEList (org.eclipse.emf.ecore.util.InternalEList)1 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)1 JvmTypeConstraint (org.eclipse.xtext.common.types.JvmTypeConstraint)1 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)1 JvmExecutableImplCustom (org.eclipse.xtext.common.types.impl.JvmExecutableImplCustom)1