use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.
the class LinkRenderer method processTypedDeclaration.
private String processTypedDeclaration(TypedDeclaration decl) {
String declName = Util.getDeclarationName(decl);
Scope declContainer = decl.getContainer();
if (isLinkable(decl)) {
String url = getUrl(declContainer, declName);
if (url != null) {
return buildLinkElement(url, getLinkText(decl), "Go to " + decl.getQualifiedNameString());
}
}
String result = declName;
if (withinText) {
result = "<code>" + result + "</code>";
}
if (customText != null) {
result = customText;
}
return result;
}
use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.
the class ExpressionVisitor method getBaseReceivingType.
protected Type getBaseReceivingType(Tree.InvocationExpression that, Declaration dec) {
Scope scope = that.getScope();
if (dec.isClassOrInterfaceMember() && !dec.isStatic() && !dec.isDefinedInScope(scope)) {
ClassOrInterface ci = (ClassOrInterface) dec.getContainer();
Type qualifyingType = scope.getDeclaringType(dec);
List<Type> inferredArgs = new TypeArgumentInference(unit).getInferredTypeArgsForReference(that, dec, ci, qualifyingType);
return ci.appliedType(null, inferredArgs);
} else {
return null;
}
}
use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.
the class ExpressionVisitor method visitBaseMemberExpression.
private void visitBaseMemberExpression(Tree.StaticMemberOrTypeExpression that, TypedDeclaration member, List<Type> typeArgs, Tree.TypeArguments tal, Type receivingType) {
if (acceptsTypeArguments(member, null, typeArgs, tal, that) || true) {
Scope scope = that.getScope();
Type outerType = scope.getDeclaringType(member);
if (outerType == null) {
outerType = receivingType;
}
TypedReference pr = member.appliedTypedReference(outerType, typeArgs, that.getAssigned());
that.setTarget(pr);
boolean direct = that.getDirectlyInvoked();
Type fullType = accountForGenericFunctionRef(direct, tal, outerType, typeArgs, pr.getFullType());
if (!dynamic && !isNativeForWrongBackend(scope, unit) && !isAbstraction(member) && isTypeUnknown(fullType) && !hasError(that)) {
that.addError("could not determine type of function or value reference: the type of '" + member.getName(unit) + "' is not known" + getTypeUnknownError(fullType));
}
if (dynamic && isTypeUnknown(fullType)) {
// type information we have
return;
}
that.setTypeModel(fullType);
}
}
use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.
the class ExpressionVisitor method resolveBaseTypeExpression.
private TypeDeclaration resolveBaseTypeExpression(Tree.BaseTypeExpression that, boolean error) {
Tree.Identifier id = that.getIdentifier();
String name = name(id);
Scope scope = that.getScope();
TypeDeclaration type = getTypeDeclaration(scope, name, that.getSignature(), that.getEllipsis(), that.getUnit());
if (type == null) {
if (error && !dynamic && !isNativeForWrongBackend(scope, unit)) {
that.addError("type is not defined: '" + name + "'" + correctionMessage(name, scope, unit, cancellable), 102);
unit.setUnresolvedReferences();
}
} else {
type = (TypeDeclaration) handleAbstractionOrHeader(type, that, error);
that.setDeclaration(type);
if (error) {
if (checkConcreteClass(type, that)) {
if (checkVisibleConstructor(that, type)) {
checkBaseTypeAndConstructorVisibility(that, name, type);
}
}
}
}
return type;
}
use of org.eclipse.ceylon.model.typechecker.model.Scope in project ceylon by eclipse.
the class ExpressionVisitor method resolveQualifiedTypeExpression.
private TypeDeclaration resolveQualifiedTypeExpression(Tree.QualifiedTypeExpression that, boolean error) {
if (checkMember(that)) {
Tree.Primary primary = that.getPrimary();
Tree.Identifier id = that.getIdentifier();
List<Type> signature = that.getSignature();
boolean spread = that.getEllipsis();
String name = name(id);
String container;
boolean ambiguous;
TypeDeclaration type;
Type pt;
if (primary instanceof Tree.Package) {
Package pack = unit.getPackage();
container = "package '" + pack.getNameAsString() + "'";
type = getPackageTypeDeclaration(name, signature, spread, unit);
ambiguous = false;
pt = null;
} else {
pt = primary.getTypeModel().resolveAliases();
TypeDeclaration d = getDeclaration(that, pt);
if (d instanceof Constructor) {
d = d.getExtendedType().getDeclaration();
}
container = "type '" + d.getName(unit) + "'";
Scope scope = that.getScope();
type = getTypeMember(d, name, signature, spread, unit, scope);
ambiguous = type == null && d.isMemberAmbiguous(name, unit, signature, spread);
if (type == null) {
container += memberCorrectionMessage(name, d, scope, unit, cancellable);
}
}
if (type == null) {
if (error) {
if (ambiguous) {
that.addError("member type is ambiguous: '" + name + "' for " + container);
} else {
that.addError("member type is not defined: '" + name + "' in " + container, 100);
unit.setUnresolvedReferences();
}
}
} else {
type = (TypeDeclaration) handleAbstractionOrHeader(type, that, error);
if (error) {
checkStaticPrimary(that, primary, type, pt);
}
that.setDeclaration(type);
resetSuperReference(that);
if (!isSelfReference(primary) && !type.isShared()) {
type.setOtherInstanceAccess(true);
}
if (error) {
if (checkConcreteClass(type, that)) {
if (checkVisibleConstructor(that, type)) {
checkQualifiedTypeAndConstructorVisibility(that, type, name, container);
}
}
if (!inExtendsClause) {
checkSuperMember(that, signature, spread);
}
}
}
return type;
} else {
return null;
}
}
Aggregations