Search in sources :

Example 76 with Unit

use of org.eclipse.ceylon.model.typechecker.model.Unit in project ceylon by eclipse.

the class Decl method isJavaArrayFrom.

public static boolean isJavaArrayFrom(Declaration decl) {
    if (decl.isClassMember() && "from".equals(decl.getName())) {
        Unit unit = decl.getUnit();
        Scope cls = decl.getContainer();
        if (cls instanceof Class) {
            return cls.equals(unit.getJavaObjectArrayDeclaration()) || cls.equals(unit.getJavaIntArrayDeclaration()) || cls.equals(unit.getJavaLongArrayDeclaration()) || cls.equals(unit.getJavaShortArrayDeclaration()) || cls.equals(unit.getJavaDoubleArrayDeclaration()) || cls.equals(unit.getJavaFloatArrayDeclaration()) || cls.equals(unit.getJavaCharArrayDeclaration()) || cls.equals(unit.getJavaByteArrayDeclaration()) || cls.equals(unit.getJavaBooleanArrayDeclaration());
        }
    }
    return false;
}
Also used : Scope(org.eclipse.ceylon.model.typechecker.model.Scope) ConditionScope(org.eclipse.ceylon.model.typechecker.model.ConditionScope) LazyClass(org.eclipse.ceylon.model.loader.model.LazyClass) Class(org.eclipse.ceylon.model.typechecker.model.Class) Unit(org.eclipse.ceylon.model.typechecker.model.Unit)

Example 77 with Unit

use of org.eclipse.ceylon.model.typechecker.model.Unit in project ceylon by eclipse.

the class ClassOrPackageDoc method writeParameterList.

protected final void writeParameterList(Functional f, Referenceable scope) throws IOException {
    Unit unit = scope.getUnit();
    for (ParameterList lists : f.getParameterLists()) {
        write("(");
        boolean first = true;
        for (Parameter param : lists.getParameters()) {
            if (!first) {
                write(", ");
            } else {
                first = false;
            }
            if (param.getModel() instanceof Function) {
                writeFunctionalParameter(param, scope);
            } else {
                if (!Decl.isDynamic(param.getModel())) {
                    Type type = param.getType();
                    if (param.isSequenced()) {
                        type = unit.getSequentialElementType(type);
                    }
                    linkRenderer().to(type).useScope(scope).write();
                    if (param.isSequenced()) {
                        write(param.isAtLeastOne() ? "+" : "*");
                    }
                } else {
                    around("span class='dynamic'", "dynamic");
                }
                write(" ");
                around("span class='parameter'", param.getName());
            }
            if (param.isDefaulted()) {
                String defaultValue = getParameterDefaultValue(param);
                if (defaultValue != null) {
                    around("span class='parameter-default-value'", " = ");
                    if (simpleDefaultValues.contains(defaultValue)) {
                        around("span class='parameter-default-value' title='Parameter default value'", defaultValue);
                    } else {
                        around("a class='parameter-default-value' href='#" + f.getName() + "-" + param.getName() + "' title='Go to parameter default value'", "...");
                    }
                }
            }
        }
        write(")");
    }
}
Also used : Function(org.eclipse.ceylon.model.typechecker.model.Function) Util.isAbbreviatedType(org.eclipse.ceylon.ceylondoc.Util.isAbbreviatedType) Type(org.eclipse.ceylon.model.typechecker.model.Type) ParameterList(org.eclipse.ceylon.model.typechecker.model.ParameterList) Parameter(org.eclipse.ceylon.model.typechecker.model.Parameter) TypeParameter(org.eclipse.ceylon.model.typechecker.model.TypeParameter) Unit(org.eclipse.ceylon.model.typechecker.model.Unit) PhasedUnit(org.eclipse.ceylon.compiler.typechecker.context.PhasedUnit)

Example 78 with Unit

use of org.eclipse.ceylon.model.typechecker.model.Unit in project ceylon by eclipse.

the class AnnotationModelVisitor method getCollectionLiteralFactory.

private LiteralAnnotationTerm getCollectionLiteralFactory(Node err) {
    Unit unit = err.getUnit();
    Type iteratedType = unit.getIteratedType(parameter().getType());
    if (iteratedType.isString()) {
        return StringLiteralAnnotationTerm.FACTORY;
    } else if (iteratedType.isInteger()) {
        return IntegerLiteralAnnotationTerm.FACTORY;
    } else if (iteratedType.isCharacter()) {
        return CharacterLiteralAnnotationTerm.FACTORY;
    } else if (iteratedType.isBoolean()) {
        return BooleanLiteralAnnotationTerm.FACTORY;
    } else if (iteratedType.isFloat()) {
        return FloatLiteralAnnotationTerm.FACTORY;
    } else if (Decl.isEnumeratedTypeWithAnonCases(iteratedType)) {
        return ObjectLiteralAnnotationTerm.FACTORY;
    } else if (Decl.isAnnotationClass(iteratedType.getDeclaration())) {
        err.addError("compiler bug: iterables of annotation classes or annotation constructors not supported as literal " + (checkingDefaults ? "defaulted parameters" : "arguments"), Backend.Java);
        return null;
    } else if (iteratedType.isSubtypeOf(((TypeDeclaration) unit.getLanguageModuleDeclarationDeclaration("Declaration")).getType())) {
        return DeclarationLiteralAnnotationTerm.FACTORY;
    } else {
        throw new RuntimeException();
    }
}
Also used : Type(org.eclipse.ceylon.model.typechecker.model.Type) Unit(org.eclipse.ceylon.model.typechecker.model.Unit) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)

Example 79 with Unit

use of org.eclipse.ceylon.model.typechecker.model.Unit in project ceylon by eclipse.

the class TypePrinter method abbreviateSequential.

public static boolean abbreviateSequential(Type pt) {
    if (pt.isSequential()) {
        Unit unit = pt.getDeclaration().getUnit();
        Type et = unit.getIteratedType(pt);
        // && et.isPrimitiveAbbreviatedType();
        return et != null;
    }
    return false;
}
Also used : Type(org.eclipse.ceylon.model.typechecker.model.Type) Unit(org.eclipse.ceylon.model.typechecker.model.Unit)

Example 80 with Unit

use of org.eclipse.ceylon.model.typechecker.model.Unit in project ceylon by eclipse.

the class TypePrinter method abbreviateSequence.

public static boolean abbreviateSequence(Type pt) {
    if (pt.isSequence()) {
        Unit unit = pt.getDeclaration().getUnit();
        Type et = unit.getIteratedType(pt);
        // && et.isPrimitiveAbbreviatedType();
        return et != null;
    }
    return false;
}
Also used : Type(org.eclipse.ceylon.model.typechecker.model.Type) Unit(org.eclipse.ceylon.model.typechecker.model.Unit)

Aggregations

Unit (org.eclipse.ceylon.model.typechecker.model.Unit)82 Type (org.eclipse.ceylon.model.typechecker.model.Type)41 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)31 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)25 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)23 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)16 AnalyzerUtil.getTypedDeclaration (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTypedDeclaration)11 ArrayList (java.util.ArrayList)10 Class (org.eclipse.ceylon.model.typechecker.model.Class)10 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)10 ClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)9 Function (org.eclipse.ceylon.model.typechecker.model.Function)9 FunctionOrValue (org.eclipse.ceylon.model.typechecker.model.FunctionOrValue)9 ModelUtil.intersectionType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.intersectionType)9 Scope (org.eclipse.ceylon.model.typechecker.model.Scope)9 Value (org.eclipse.ceylon.model.typechecker.model.Value)9 Constructor (org.eclipse.ceylon.model.typechecker.model.Constructor)7 Module (org.eclipse.ceylon.model.typechecker.model.Module)7 IntersectionType (org.eclipse.ceylon.model.typechecker.model.IntersectionType)6 LazyType (org.eclipse.ceylon.model.typechecker.model.LazyType)6