use of abs.frontend.analyser.TypeError in project abstools by abstools.
the class ClassKindTypeExtension method checkNewExp.
@Override
public void checkNewExp(NewExp e) {
ClassDecl d = (ClassDecl) e.lookup(new KindedName(Kind.CLASS, e.getClassName()));
List<Annotation> anns = AnnotationHelper.getAnnotationsOfType(d.getAnnotations(), "ABS.StdLib.ClassKindAnnotation");
if (!anns.isEmpty()) {
String name = ((DataConstructorExp) anns.get(0).getValue()).getDecl().getName();
if (e.hasLocal()) {
if (name.equals("COG")) {
errors.add(new TypeError(e, ErrorMessage.CLASSKIND_PLAIN, d.getName()));
}
} else {
if (!name.equals("COG")) {
errors.add(new TypeError(e, ErrorMessage.CLASSKIND_COG, d.getName()));
}
}
}
}
use of abs.frontend.analyser.TypeError in project abstools by abstools.
the class HttpExportChecker method checkDataTypeDecl.
@Override
public void checkDataTypeDecl(DataTypeDecl decl) {
for (DataConstructor c : decl.getDataConstructors()) {
Set<String> names = new HashSet<>();
for (ConstructorArg ca : c.getConstructorArgs()) {
ASTNode arg = null;
String key = null;
abs.frontend.ast.List<Annotation> ann = ca.getTypeUse().getAnnotations();
PureExp keyann = CompilerUtils.getAnnotationValueFromName(ann, "ABS.StdLib.HTTPName");
if (keyann != null) {
if (!(keyann instanceof StringLiteral)) {
errors.add(new TypeError(keyann, ErrorMessage.WRONG_HTTPNAME, keyann.getType()));
} else {
key = ((StringLiteral) keyann).getContent();
arg = keyann;
}
}
if (ca.hasSelectorName() && key == null) {
key = ca.getSelectorName().toString();
arg = ca.getSelectorName();
}
if (key != null) {
if (names.contains(key)) {
errors.add(new SemanticWarning(arg, ErrorMessage.DUPLICATE_HTTPNAME, key));
} else {
names.add(key);
}
}
}
}
}
use of abs.frontend.analyser.TypeError in project abstools by abstools.
the class DeltaSamplesTest method test_ticket329.
@Test
public void test_ticket329() throws Exception {
Model m = assertParseFileOk("tests/abssamples/deltas/bug329.abs", true);
SemanticConditionList errs = m.typeCheck();
/* We are expecting a missing delta in product M.PL: */
assertThat(errs.getFirstError(), instanceOf(TypeError.class));
TypeError te = (TypeError) errs.getFirstError();
Assert.assertEquals(ErrorMessage.NAME_NOT_RESOLVABLE, te.msg);
}
use of abs.frontend.analyser.TypeError in project abstools by abstools.
the class DeltaSamplesTest method test_ticket329_missingLineNo.
@Test
public void test_ticket329_missingLineNo() throws Exception {
Model m = assertParseFileOk("tests/abssamples/deltas/bug329.abs", true);
SemanticConditionList errs = m.typeCheck();
/* We are expecting a missing delta in product M.PL: */
assertThat(errs.getFirstError(), instanceOf(TypeError.class));
TypeError te = (TypeError) errs.getFirstError();
Assert.assertEquals(ErrorMessage.NAME_NOT_RESOLVABLE, te.msg);
Assert.assertEquals(10, te.getLine());
}
use of abs.frontend.analyser.TypeError in project abstools by abstools.
the class LocationTypeExtension method getLocationTypeFromAnnotations.
public static LocationType getLocationTypeFromAnnotations(Type t, ASTNode<?> originatingNode) {
LocationType res = null;
for (TypeAnnotation an : t.getTypeAnnotations()) {
if (an.getType().getQualifiedName().equals("ABS.StdLib.LocationType")) {
DataConstructorExp de = (DataConstructorExp) an.getValue();
String name = de.getDecl().getName();
if (res != null) {
throw new LocationTypeCheckerException(new TypeError(an.getValue(), ErrorMessage.LOCATION_TYPE_MULTIPLE, new String[0]));
} else {
res = LocationType.createFromName(name);
}
}
}
/*
if (originatingNode != null && originatingNode instanceof ConstructorArg) {
if (res == null || !res.isSomewhere()) {
throw new LocationTypeCheckerException(new TypeError(originatingNode,ErrorMessage.LOCATION_TYPE_DATACONSTR_MUST_BE_SOMEWHERE, new String[0]));
}
}*/
return res;
}
Aggregations