use of org.eclipse.ceylon.model.typechecker.model.Value in project ceylon by eclipse.
the class MethodOrValueReferenceVisitor method visit.
@Override
public void visit(Tree.AttributeDeclaration that) {
final SpecifierOrInitializerExpression specifier = that.getSpecifierOrInitializerExpression();
Value model = that.getDeclarationModel();
boolean lse = inLazySpecifierExpression;
if (specifier != null && model.isLate() && model.isClassMember()) {
model.setCaptured(true);
inLazySpecifierExpression = true;
}
super.visit(that);
inLazySpecifierExpression = lse;
}
use of org.eclipse.ceylon.model.typechecker.model.Value in project ceylon by eclipse.
the class DeclarationErrorVisitor method planAccordingToErrors.
/**
* Update the plan according to the errors on the node
*/
private void planAccordingToErrors(Node that) {
List<Message> errors = that.getErrors();
for (Message message : errors) {
if (isError(that, message)) {
TransformationPlan plan;
/*if (message.getCode() == MEMBER_HAS_WRONG_NUMBER_OF_PARAMETERS
&& model.isActual()
&& model.isClassMember()) {
plan = new ThrowerMethod(that, message);
} else if (message.getCode() == TYPE_OF_PARAMETER_IS_DIFFERENT_TO_CORRESPONDING_PARAMETER
&& model.isActual()
&& model.isClassMember()) {
plan = new ThrowerMethod(that, message);
} else if (message.getCode() == COULD_NOT_DETERMINE_PARAMETER_TYPE_SAME_AS_CORRESPONDING_PARAMETER
&& model.isActual()
&& model.isClassMember()) {
plan = new ThrowerMethod(that, message);
} else if ((message.getCode() == REFINED_MEMBER_WRONG_NUM_PL
|| message.getCode() == MISSING_PL_FUNCTION_DECL)
&& model.isActual()
&& model.isClassMember()) {
plan = new ThrowerMethod(that, message);
} else*/
if (message.getCode() == FORMAL_MEMBER_UNIMPLEMENTED_IN_CLASS_HIERARCHY && (model instanceof Class || (model instanceof Value && ((Value) model).getTypeDeclaration().isAnonymous()))) {
plan = new ThrowerMethod(that, message);
} else if ((message.getCode() == PL_AND_CONSTRUCTORS || message.getCode() == NO_CONSTRUCTORS) && (model instanceof Class || (model instanceof Value && ((Value) model).getTypeDeclaration().isAnonymous()))) {
if (message.getCode() == NO_CONSTRUCTORS) {
plan = new PrivateConstructorOnly(that, message);
} else {
plan = new ThrowerCatchallConstructor(that, message);
}
} else if (message.getCode() == FORWARD_DECL_NOT_IN_DECL_SECTION) {
plan = Errors.GENERATE;
} else {
plan = new Drop(that, message);
}
newplan(plan);
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.Value in project ceylon by eclipse.
the class AbstractModelLoader method addConstructorMethorOrValue.
protected FunctionOrValue addConstructorMethorOrValue(Class klass, ClassMirror classMirror, MethodMirror ctor, Constructor constructor, boolean isNativeHeader) {
boolean isCeylon = classMirror.getAnnotation(CEYLON_CEYLON_ANNOTATION) != null;
if (ctor.getAnnotation(CEYLON_ENUMERATED_ANNOTATION) != null) {
klass.setEnumerated(true);
Value v = new Value();
v.setName(constructor.getName());
v.setType(constructor.getType());
v.setContainer(klass);
v.setScope(klass);
v.setUnit(klass.getUnit());
v.setVisibleScope(constructor.getVisibleScope());
// read annotations from the getter method
setNonLazyDeclarationProperties(v, ctor, ctor, classMirror, isCeylon);
setAnnotations(v, ctor, isNativeHeader);
klass.addMember(v);
return v;
} else {
setParameters(constructor, classMirror, ctor, true, klass, false);
klass.setConstructors(true);
Function f = new Function();
f.setName(constructor.getName());
f.setType(constructor.getType());
f.addParameterList(constructor.getParameterList());
f.setContainer(klass);
f.setScope(klass);
f.setUnit(klass.getUnit());
f.setVisibleScope(constructor.getVisibleScope());
// read annotations from the constructor
setNonLazyDeclarationProperties(f, ctor, ctor, classMirror, isCeylon);
setAnnotations(f, ctor, isNativeHeader);
klass.addMember(f);
return f;
}
}
use of org.eclipse.ceylon.model.typechecker.model.Value in project ceylon by eclipse.
the class AbstractModelLoader method isRaw.
private boolean isRaw(Module module, TypeMirror type) {
// See https://github.com/ceylon/ceylon-compiler/issues/1085
switch(type.getKind()) {
// arrays are never raw
case ARRAY:
case BOOLEAN:
case BYTE:
case CHAR:
case DOUBLE:
case ERROR:
case FLOAT:
case INT:
case LONG:
case NULL:
case SHORT:
case TYPEVAR:
case VOID:
case WILDCARD:
return false;
case DECLARED:
ClassMirror klass = type.getDeclaredClass();
if (klass.isJavaSource()) {
// I suppose this should work
return type.isRaw();
}
List<String> path = new LinkedList<String>();
String pkgName = klass.getPackage().getQualifiedName();
String unquotedPkgName = unquotePackageName(klass.getPackage());
String qualifiedName = klass.getQualifiedName();
String relativeName = pkgName.isEmpty() ? qualifiedName : qualifiedName.substring(pkgName.length() + 1);
for (String name : relativeName.split("[\\$\\.]")) {
if (!name.isEmpty()) {
path.add(name);
}
}
if (path.size() > 1) {
// find the proper class mirror for the container
klass = loadClass(module, pkgName, new StringBuilder(pkgName).append('.').append(path.get(0)).toString());
if (klass == null)
return false;
}
if (!path.isEmpty() && klass.isLoadedFromSource()) {
// we need to find its model
Scope scope = packagesByName.get(cacheKeyByModule(module, unquotedPkgName));
if (scope == null)
return false;
for (String name : path) {
Declaration decl = scope.getDirectMember(name, null, false);
if (decl == null)
return false;
// if we get a value, we want its type
if (JvmBackendUtil.isValue(decl) && ((Value) decl).getTypeDeclaration().getName().equals(name))
decl = ((Value) decl).getTypeDeclaration();
if (decl instanceof TypeDeclaration == false)
return false;
scope = (TypeDeclaration) decl;
}
TypeDeclaration typeDecl = (TypeDeclaration) scope;
return typeDecl.isParameterized() && type.getTypeArguments().isEmpty();
}
try {
return type.isRaw();
} catch (Exception x) {
// it will be logged somewhere else
return false;
}
default:
return false;
}
}
use of org.eclipse.ceylon.model.typechecker.model.Value in project ceylon by eclipse.
the class AbstractModelLoader method makeSetter.
private SetterWithLocalDeclarations makeSetter(Value value, ClassMirror classMirror) {
SetterWithLocalDeclarations setter = new SetterWithLocalDeclarations(classMirror);
Scope scope = value.getContainer();
setter.setContainer(scope);
setter.setScope(scope);
setter.setType(value.getType());
setter.setName(value.getName());
Parameter p = new Parameter();
p.setHidden(true);
Value v = new Value();
v.setType(value.getType());
v.setUnboxed(value.getUnboxed());
v.setInitializerParameter(p);
v.setContainer(setter);
v.setScope(setter);
p.setModel(v);
v.setName(setter.getName());
p.setName(setter.getName());
p.setDeclaration(setter);
setter.setParameter(p);
value.setSetter(setter);
setter.setGetter(value);
return setter;
}
Aggregations