Search in sources :

Example 1 with TypeSymbol

use of org.eclipse.ceylon.langtools.tools.javac.code.Symbol.TypeSymbol in project ceylon by eclipse.

the class CeylonModelLoader method implemented.

/**
 * Copied from MethodSymbol.implemented and adapted for ignoring methods
 */
private Symbol implemented(MethodSymbol m, TypeSymbol c, Types types) {
    Symbol impl = null;
    for (List<Type> is = types.interfaces(c.type); impl == null && is.nonEmpty(); is = is.tail) {
        TypeSymbol i = is.head.tsym;
        impl = implementedIn(m, i, types);
        if (impl == null)
            impl = implemented(m, i, types);
    }
    return impl;
}
Also used : MethodType(org.eclipse.ceylon.langtools.tools.javac.code.Type.MethodType) Type(org.eclipse.ceylon.langtools.tools.javac.code.Type) UnknownType(org.eclipse.ceylon.model.typechecker.model.UnknownType) ArrayType(org.eclipse.ceylon.langtools.tools.javac.code.Type.ArrayType) JavacType(org.eclipse.ceylon.compiler.java.loader.mirror.JavacType) FunctionalInterfaceType(org.eclipse.ceylon.model.loader.mirror.FunctionalInterfaceType) MethodSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.MethodSymbol) TypeSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.TypeSymbol) ClassSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.ClassSymbol) Symbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol) PackageSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.PackageSymbol) TypeSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.TypeSymbol)

Example 2 with TypeSymbol

use of org.eclipse.ceylon.langtools.tools.javac.code.Symbol.TypeSymbol in project ceylon by eclipse.

the class CeylonModelLoader method isOverloadingMethod.

/**
 * Returns true if the given method is overloading an inherited method (from super class or interfaces).
 */
private boolean isOverloadingMethod(final MethodSymbol method) {
    /*
         * Copied from getOverriddenMethod and adapted for overloading
         */
    try {
        // interfaces have a different way to work
        if (method.owner.isInterface())
            return overloaded(method, method.owner.type.tsym, types);
        // so we stop there for it, especially since it does not have any overloading
        if (method.owner.type.tsym.getQualifiedName().toString().equals("ceylon.language.Exception"))
            return false;
        for (Type superType = types.supertype(method.owner.type); superType.tsym != null; superType = types.supertype(superType)) {
            TypeSymbol i = superType.tsym;
            String fqn = i.getQualifiedName().toString();
            // never go above this type since it has no supertype in Ceylon (does in Java though)
            if (fqn.equals("ceylon.language.Anything"))
                break;
            try {
                for (Entry e = i.members().lookup(method.name); e.scope != null; e = e.next()) {
                    // ignore some methods
                    if (isIgnored(e.sym))
                        continue;
                    if (!method.overrides(e.sym, (TypeSymbol) method.owner, types, false)) {
                        return true;
                    }
                }
                // try in the interfaces
                if (overloaded(method, i, types))
                    return true;
            } catch (Symbol.CompletionFailure x) {
            // just ignore unresolved interfaces, error will be logged when we try to add it
            }
            // so we stop there for it, especially since it does not have any overloading
            if (fqn.equals("ceylon.language.Exception"))
                break;
        }
        // try in the interfaces
        if (overloaded(method, method.owner.type.tsym, types))
            return true;
        return false;
    } catch (CompletionFailure x) {
        handleCompletionFailure(method, x);
        return false;
    }
}
Also used : MethodType(org.eclipse.ceylon.langtools.tools.javac.code.Type.MethodType) Type(org.eclipse.ceylon.langtools.tools.javac.code.Type) UnknownType(org.eclipse.ceylon.model.typechecker.model.UnknownType) ArrayType(org.eclipse.ceylon.langtools.tools.javac.code.Type.ArrayType) JavacType(org.eclipse.ceylon.compiler.java.loader.mirror.JavacType) FunctionalInterfaceType(org.eclipse.ceylon.model.loader.mirror.FunctionalInterfaceType) Entry(org.eclipse.ceylon.langtools.tools.javac.code.Scope.Entry) CompletionFailure(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.CompletionFailure) MethodSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.MethodSymbol) TypeSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.TypeSymbol) ClassSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.ClassSymbol) Symbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol) PackageSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.PackageSymbol) CompletionFailure(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.CompletionFailure) TypeSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.TypeSymbol)

Example 3 with TypeSymbol

use of org.eclipse.ceylon.langtools.tools.javac.code.Symbol.TypeSymbol in project ceylon by eclipse.

the class JavacTrees method getTree.

public JCTree getTree(Element element) {
    Symbol symbol = (Symbol) element;
    TypeSymbol enclosing = symbol.enclClass();
    Env<AttrContext> env = enter.getEnv(enclosing);
    if (env == null)
        return null;
    JCClassDecl classNode = env.enclClass;
    if (classNode != null) {
        if (TreeInfo.symbolFor(classNode) == element)
            return classNode;
        for (JCTree node : classNode.getMembers()) if (TreeInfo.symbolFor(node) == element)
            return node;
    }
    return null;
}
Also used : JCClassDecl(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCClassDecl) VarSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.VarSymbol) MethodSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.MethodSymbol) TypeSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.TypeSymbol) ClassSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.ClassSymbol) Symbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol) JCTree(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree) TypeSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.TypeSymbol) AttrContext(org.eclipse.ceylon.langtools.tools.javac.comp.AttrContext)

Aggregations

Symbol (org.eclipse.ceylon.langtools.tools.javac.code.Symbol)3 ClassSymbol (org.eclipse.ceylon.langtools.tools.javac.code.Symbol.ClassSymbol)3 MethodSymbol (org.eclipse.ceylon.langtools.tools.javac.code.Symbol.MethodSymbol)3 TypeSymbol (org.eclipse.ceylon.langtools.tools.javac.code.Symbol.TypeSymbol)3 JavacType (org.eclipse.ceylon.compiler.java.loader.mirror.JavacType)2 PackageSymbol (org.eclipse.ceylon.langtools.tools.javac.code.Symbol.PackageSymbol)2 Type (org.eclipse.ceylon.langtools.tools.javac.code.Type)2 ArrayType (org.eclipse.ceylon.langtools.tools.javac.code.Type.ArrayType)2 MethodType (org.eclipse.ceylon.langtools.tools.javac.code.Type.MethodType)2 FunctionalInterfaceType (org.eclipse.ceylon.model.loader.mirror.FunctionalInterfaceType)2 UnknownType (org.eclipse.ceylon.model.typechecker.model.UnknownType)2 Entry (org.eclipse.ceylon.langtools.tools.javac.code.Scope.Entry)1 CompletionFailure (org.eclipse.ceylon.langtools.tools.javac.code.Symbol.CompletionFailure)1 VarSymbol (org.eclipse.ceylon.langtools.tools.javac.code.Symbol.VarSymbol)1 AttrContext (org.eclipse.ceylon.langtools.tools.javac.comp.AttrContext)1 JCTree (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree)1 JCClassDecl (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCClassDecl)1