use of abs.frontend.ast.Annotation in project abstools by abstools.
the class ABSUnitTestCaseTranslatorHelper method createTestClass.
ClassDecl createTestClass(InterfaceDecl inf) {
ClassDecl ct = new ClassDecl(testCaseNameBuilder.className(inf.getName()), new abs.frontend.ast.List<Annotation>(), new abs.frontend.ast.List<ParamDecl>(), new abs.frontend.ast.List<InterfaceTypeUse>(), new Opt<InitBlock>(), new abs.frontend.ast.List<CaseBranchStmt>(), new abs.frontend.ast.List<FieldDecl>(), new abs.frontend.ast.List<MethodImpl>());
ct.addAnnotation(getTestAnnotation(suiteType));
ct.addImplementedInterfaceUse(new InterfaceTypeUse(inf.getName(), new abs.frontend.ast.List<abs.frontend.ast.Annotation>()));
for (MethodSig m : inf.getAllMethodSigs()) {
ct.addMethod(createMethodImpl(m));
}
FieldDecl assertImpl = new FieldDecl();
assertImpl.setName(ASSERT_HELPER);
assertImpl.setAccess(absAssertImpl.getImplementedInterfaceUse(0).treeCopyNoTransform());
ct.addField(assertImpl);
InitBlock block = new InitBlock();
block.addStmtNoTransform(getVAssign(ASSERT_HELPER, newObj(absAssertImpl, false)));
ct.setInitBlock(block);
return ct;
}
use of abs.frontend.ast.Annotation in project abstools by abstools.
the class DeltaForGetSetFieldsBuilder method addSetter.
/**
* Add an add method modifier
* @param fieldName
* @param exp
* @param decl
* @return
*/
AddMethodModifier addSetter(String fieldName, Access type) {
MethodSig sig = new MethodSig(testCaseNameBuilder.setterMethodName(fieldName), new abs.frontend.ast.List<Annotation>(), getUnit(), new abs.frontend.ast.List<ParamDecl>());
sig.addParam(new ParamDecl("v", type, new abs.frontend.ast.List<Annotation>()));
Block block = new Block();
block.addStmtNoTransform(getVAssign(new FieldUse(fieldName), new VarUse("v")));
MethodImpl method = new MethodImpl(sig, block, false);
AddMethodModifier modifier = new AddMethodModifier(method);
return modifier;
}
use of abs.frontend.ast.Annotation 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.ast.Annotation in project abstools by abstools.
the class JavaGeneratorHelper method generateAsyncCall.
public static void generateAsyncCall(PrintStream stream, AsyncCall call) {
final PureExp callee = call.getCallee();
final List<PureExp> params = call.getParams();
final MethodSig sig = call.getMethodSig();
final List<Annotation> annotations = call.getAnnotations();
generateAsyncCall(stream, null, callee, callee.getType(), params, null, sig, annotations);
}
use of abs.frontend.ast.Annotation in project abstools by abstools.
the class ABSUnitRunner method analyzeModelUnit.
private void analyzeModelUnit(Model model) {
System.out.println("Analyzing model:");
for (CompilationUnit cu : model.getCompilationUnits()) {
System.out.println(cu.getFileName());
for (ModuleDecl m : cu.getModuleDecls()) {
for (Decl cd : m.getDecls()) {
if (cd instanceof ClassDecl) {
for (MethodSig ms : ((ClassDecl) cd).getAllMethodSigs()) {
for (Annotation a : ms.getAnnotations()) {
if (a.getType().getSimpleName().equals("Test")) {
System.out.println("Found test method:" + ms.getName());
testMethods.add(ms);
} else if (a.getType().getSimpleName().equals("Suite")) {
System.out.println("Found test suite:" + ms.getName());
}
}
}
}
}
}
}
}
Aggregations