Search in sources :

Example 6 with JavaMethod

use of org.eclipse.ceylon.model.loader.model.JavaMethod in project ceylon by eclipse.

the class AbstractModelLoader method completeActual.

@Override
public void completeActual(Declaration decl) {
    Scope container = decl.getContainer();
    if (container instanceof ClassOrInterface) {
        ClassOrInterface klass = (ClassOrInterface) container;
        decl.setRefinedDeclaration(decl);
        // we never consider Interface and other stuff, since we never register the actualCompleter for them
        if (decl instanceof Class) {
            // Java member classes are never actual
            if (!ModelUtil.isCeylonDeclaration((Class) decl))
                return;
            // we already set the actual bit for member classes, we just need the refined decl
            if (decl.isActual()) {
                Declaration refined = klass.getRefinedMember(decl.getName(), getSignature(decl), klass.isVariadic());
                decl.setRefinedDeclaration(refined);
            }
        } else {
            // Function or Value
            MethodMirror methodMirror;
            if (decl instanceof JavaBeanValue)
                methodMirror = ((JavaBeanValue) decl).mirror;
            else if (decl instanceof JavaMethod)
                methodMirror = ((JavaMethod) decl).mirror;
            else
                throw new ModelResolutionException("Unknown type of declaration: " + decl + ": " + decl.getClass().getName());
            decl.setRefinedDeclaration(decl);
            // For Ceylon interfaces we rely on annotation
            if (klass instanceof LazyInterface && ((LazyInterface) klass).isCeylon()) {
                boolean actual = methodMirror.getAnnotation(CEYLON_LANGUAGE_ACTUAL_ANNOTATION) != null;
                decl.setActual(actual);
                if (actual) {
                    Declaration refined = klass.getRefinedMember(decl.getName(), getSignature(decl), decl.isVariadic());
                    decl.setRefinedDeclaration(refined);
                }
            } else {
                if (isOverridingMethod(methodMirror)) {
                    Declaration refined = klass.getRefinedMember(decl.getName(), getSignature(decl), decl.isVariadic());
                    if (refined instanceof FieldValue == false) {
                        decl.setActual(true);
                        decl.setRefinedDeclaration(refined);
                    }
                }
            }
            // for Ceylon methods
            if (decl instanceof JavaMethod && ModelUtil.isCeylonDeclaration(klass)) {
                if (!methodMirror.getTypeParameters().isEmpty() && // lazy loading just to check.
                JvmBackendUtil.supportsReified(decl)) {
                    checkReifiedTypeDescriptors(methodMirror.getTypeParameters().size(), container.getQualifiedNameString(), methodMirror, false);
                }
            }
        }
    }
    completeVariable(decl);
}
Also used : ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) MethodMirror(org.eclipse.ceylon.model.loader.mirror.MethodMirror) Scope(org.eclipse.ceylon.model.typechecker.model.Scope) LazyInterface(org.eclipse.ceylon.model.loader.model.LazyInterface) JavaMethod(org.eclipse.ceylon.model.loader.model.JavaMethod) AnnotationProxyClass(org.eclipse.ceylon.model.loader.model.AnnotationProxyClass) LazyClass(org.eclipse.ceylon.model.loader.model.LazyClass) Class(org.eclipse.ceylon.model.typechecker.model.Class) TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) Declaration(org.eclipse.ceylon.model.typechecker.model.Declaration) JavaBeanValue(org.eclipse.ceylon.model.loader.model.JavaBeanValue) FieldValue(org.eclipse.ceylon.model.loader.model.FieldValue)

Aggregations

JavaMethod (org.eclipse.ceylon.model.loader.model.JavaMethod)6 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)4 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)4 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)4 FieldValue (org.eclipse.ceylon.model.loader.model.FieldValue)3 JavaBeanValue (org.eclipse.ceylon.model.loader.model.JavaBeanValue)3 JavaParameterValue (org.eclipse.ceylon.model.loader.model.JavaParameterValue)2 LazyClass (org.eclipse.ceylon.model.loader.model.LazyClass)2 LazyFunction (org.eclipse.ceylon.model.loader.model.LazyFunction)2 LazyValue (org.eclipse.ceylon.model.loader.model.LazyValue)2 Class (org.eclipse.ceylon.model.typechecker.model.Class)2 Function (org.eclipse.ceylon.model.typechecker.model.Function)2 FunctionOrValue (org.eclipse.ceylon.model.typechecker.model.FunctionOrValue)2 Parameter (org.eclipse.ceylon.model.typechecker.model.Parameter)2 ParameterList (org.eclipse.ceylon.model.typechecker.model.ParameterList)2 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)2 Value (org.eclipse.ceylon.model.typechecker.model.Value)2 ArrayList (java.util.ArrayList)1 FunctionalInterfaceType (org.eclipse.ceylon.model.loader.mirror.FunctionalInterfaceType)1 MethodMirror (org.eclipse.ceylon.model.loader.mirror.MethodMirror)1