use of org.eclipse.ceylon.model.typechecker.model.TypedDeclaration in project ceylon by eclipse.
the class ClassOrPackageDoc method doc.
protected final void doc(String id, String name, Declaration d) throws IOException {
String declarationName = Util.getDeclarationName(d);
id = (id != null ? id : name);
boolean alias = Util.nullSafeCompare(name, declarationName) != 0;
// put the id on the td because IE8 doesn't support id attributes on tr (yeah right)
open("tr");
open("td id='" + id + "' nowrap");
writeIcon(d);
if (!(d instanceof Constructor)) {
around("code class='decl-label'", name);
close("td");
open("td");
}
writeLinkOneSelf(id);
if (alias) {
writeTagged(d);
writeAlias(d);
} else {
writeLinkSource(d);
writeTagged(d);
if (d instanceof Functional) {
writeParameterLinksIfRequired((Functional) d);
}
open("code class='signature'");
around("span class='modifiers'", getModifiers(d));
write(" ");
if (!ModelUtil.isConstructor(d)) {
if (!Decl.isDynamic(d)) {
if (d instanceof Functional && ((Functional) d).isDeclaredVoid()) {
around("span class='void'", "void");
} else if (d instanceof TypedDeclaration) {
linkRenderer().to(((TypedDeclaration) d).getType()).useScope(d).write();
} else {
linkRenderer().to(d).useScope(d).write();
}
} else {
around("span class='dynamic'", "dynamic");
}
}
write(" ");
open("span class='identifier'");
write(name);
close("span");
if (isConstantValue(d)) {
writeConstantValue((Value) d);
}
if (d instanceof Generic) {
writeTypeParameters(d.getTypeParameters(), d);
}
if (d instanceof Functional) {
writeParameterList((Functional) d, d);
}
if (d instanceof Generic) {
writeTypeParametersConstraints(d.getTypeParameters(), d);
}
if (d instanceof Value) {
Setter setter = ((Value) d).getSetter();
if (setter != null && Util.getAnnotation(setter.getUnit(), setter.getAnnotations(), "doc") != null) {
tool.warningSetterDoc(d.getQualifiedNameString(), d);
}
}
close("code");
writeDescription(d);
}
close("td");
close("tr");
}
use of org.eclipse.ceylon.model.typechecker.model.TypedDeclaration in project ceylon by eclipse.
the class ExpressionVisitor method visit.
@Override
public void visit(Tree.Variable that) {
super.visit(that);
if (that instanceof CustomTree.GuardedVariable) {
CustomTree.GuardedVariable gv = (CustomTree.GuardedVariable) that;
setTypeForGuardedVariable(that, gv.getConditionList(), gv.isReversed());
Tree.BaseMemberExpression bme = (Tree.BaseMemberExpression) that.getSpecifierExpression().getExpression().getTerm();
Declaration original = bme.getDeclaration();
if (original instanceof TypedDeclaration) {
that.getDeclarationModel().setOriginalDeclaration((TypedDeclaration) original);
}
} else {
Tree.SpecifierExpression se = that.getSpecifierExpression();
if (se != null) {
inferType(that, se);
Tree.Type type = that.getType();
if (type != null) {
Type t = type.getTypeModel();
if (!isTypeUnknown(t)) {
checkType(t, se);
}
}
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.TypedDeclaration in project ceylon by eclipse.
the class ExpressionVisitor method setType.
private void setType(Tree.LocalModifier local, Tree.SpecifierOrInitializerExpression s, Tree.TypedDeclaration that) {
Tree.Expression e = s.getExpression();
if (e != null) {
Type type = e.getTypeModel();
if (type != null) {
TypedDeclaration dec = that.getDeclarationModel();
handleUncheckedNulls(local, e, dec);
Type t = inferrableType(type);
local.setTypeModel(t);
dec.setType(t);
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.TypedDeclaration in project ceylon by eclipse.
the class ExpressionVisitor method checkNamedArgument.
private void checkNamedArgument(Tree.NamedArgument arg, Reference reference, Parameter param) {
arg.setParameter(param);
Type argType = null;
if (arg instanceof Tree.SpecifiedArgument) {
Tree.SpecifiedArgument sa = (Tree.SpecifiedArgument) arg;
Tree.Expression e = sa.getSpecifierExpression().getExpression();
if (e != null) {
argType = e.getTypeModel();
}
} else if (arg instanceof Tree.TypedArgument) {
Tree.TypedArgument typedArg = (Tree.TypedArgument) arg;
TypedDeclaration argDec = typedArg.getDeclarationModel();
argType = argumentType(arg.getScope(), argDec);
checkArgumentToVoidParameter(param, typedArg);
if (!dynamic && isTypeUnknown(argType) && !hasError(arg)) {
arg.addError("could not determine type of named argument: the type of '" + param.getName() + "' is not known");
}
}
FunctionOrValue paramModel = param.getModel();
if (paramModel != null) {
TypedReference paramRef = reference.getTypedParameter(param);
Type paramType = paramType(arg.getScope(), paramRef, paramModel);
if (!isTypeUnknown(argType) && !isTypeUnknown(paramType)) {
Node node;
if (arg instanceof Tree.SpecifiedArgument) {
Tree.SpecifiedArgument specifiedArg = (Tree.SpecifiedArgument) arg;
node = specifiedArg.getSpecifierExpression();
} else {
node = arg;
}
checkAssignable(argType, paramType, node, "named argument must be assignable to parameter " + argdesc(param, reference), 2100);
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.TypedDeclaration in project ceylon by eclipse.
the class ExpressionVisitor method visit.
@Override
public void visit(Tree.MemberLiteral that) {
if (that instanceof Tree.FunctionLiteral || that instanceof Tree.ValueLiteral) {
declarationLiteral = true;
} else {
modelLiteral = true;
}
try {
super.visit(that);
} finally {
declarationLiteral = false;
modelLiteral = false;
}
Tree.Identifier id = that.getIdentifier();
if (id != null) {
String name = name(id);
Tree.StaticType type = that.getType();
if (type == null) {
TypedDeclaration result;
if (that.getPackageQualified()) {
result = getPackageTypedDeclaration(name, null, false, unit);
} else {
result = getTypedDeclaration(that.getScope(), name, null, false, unit);
}
if (result != null) {
checkBaseVisibility(that, result, name);
setMemberMetatype(that, result);
} else {
that.addError("function or value is not defined: '" + name(id) + "'", 100);
unit.setUnresolvedReferences();
}
} else {
TypeDeclaration qtd = type.getTypeModel().getDeclaration();
// checkNonlocalType(that.getType(), qtd);
String container = "type '" + qtd.getName(unit) + "'";
TypedDeclaration member = getTypedMember(qtd, name, null, false, unit, that.getScope());
if (member == null) {
if (qtd.isMemberAmbiguous(name, unit, null, false)) {
that.addError("method or attribute is ambiguous: '" + name + "' for " + container);
} else {
that.addError("method or attribute is not defined: '" + name + "' in " + container);
}
} else {
checkQualifiedVisibility(that, member, name, container, false);
setMemberMetatype(that, member);
}
}
}
}
Aggregations