Search in sources :

Example 1 with AbortCompilation

use of org.eclipse.jdt.internal.compiler.problem.AbortCompilation in project xtext-eclipse by eclipse.

the class JdtBasedTypeFactory method setParameterNamesAndAnnotations.

private void setParameterNamesAndAnnotations(IMethodBinding method, ITypeBinding[] parameterTypes, String[] parameterNames, JvmExecutable result) {
    InternalEList<JvmFormalParameter> parameters = (InternalEList<JvmFormalParameter>) result.getParameters();
    for (int i = 0; i < parameterTypes.length; i++) {
        IAnnotationBinding[] parameterAnnotations;
        try {
            parameterAnnotations = method.getParameterAnnotations(i);
        } catch (AbortCompilation aborted) {
            parameterAnnotations = null;
        }
        ITypeBinding parameterType = parameterTypes[i];
        String parameterName = parameterNames == null ? null : /* lazy */
        i < parameterNames.length ? parameterNames[i] : "arg" + i;
        JvmFormalParameter formalParameter = createFormalParameter(parameterType, parameterName, parameterAnnotations);
        parameters.addUnique(formalParameter);
    }
}
Also used : JvmFormalParameter(org.eclipse.xtext.common.types.JvmFormalParameter) IAnnotationBinding(org.eclipse.jdt.core.dom.IAnnotationBinding) ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding) InternalEList(org.eclipse.emf.ecore.util.InternalEList) AbortCompilation(org.eclipse.jdt.internal.compiler.problem.AbortCompilation) JvmTypeConstraint(org.eclipse.xtext.common.types.JvmTypeConstraint)

Example 2 with AbortCompilation

use of org.eclipse.jdt.internal.compiler.problem.AbortCompilation in project xtext-eclipse by eclipse.

the class JdtBasedTypeFactory method createAnnotationValues.

protected void createAnnotationValues(IBinding annotated, JvmAnnotationTarget result) {
    try {
        resolveAnnotations.start();
        IAnnotationBinding[] annotationBindings = annotated.getAnnotations();
        if (annotationBindings.length != 0) {
            InternalEList<JvmAnnotationReference> annotations = (InternalEList<JvmAnnotationReference>) result.getAnnotations();
            for (IAnnotationBinding annotation : annotationBindings) {
                annotations.addUnique(createAnnotationReference(annotation));
            }
        }
    } catch (AbortCompilation aborted) {
        if (aborted.problem.getID() == IProblem.IsClassPathCorrect) {
        // ignore
        } else {
            log.info("Couldn't resolve annotations of " + annotated, aborted);
        }
    } finally {
        resolveAnnotations.stop();
    }
}
Also used : IAnnotationBinding(org.eclipse.jdt.core.dom.IAnnotationBinding) InternalEList(org.eclipse.emf.ecore.util.InternalEList) AbortCompilation(org.eclipse.jdt.internal.compiler.problem.AbortCompilation) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference)

Aggregations

InternalEList (org.eclipse.emf.ecore.util.InternalEList)2 IAnnotationBinding (org.eclipse.jdt.core.dom.IAnnotationBinding)2 AbortCompilation (org.eclipse.jdt.internal.compiler.problem.AbortCompilation)2 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)1 JvmAnnotationReference (org.eclipse.xtext.common.types.JvmAnnotationReference)1 JvmFormalParameter (org.eclipse.xtext.common.types.JvmFormalParameter)1 JvmTypeConstraint (org.eclipse.xtext.common.types.JvmTypeConstraint)1