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;
}
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(")");
}
}
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();
}
}
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;
}
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;
}
Aggregations