use of abs.frontend.ast.Decl in project abstools by abstools.
the class PureExpressionBuilder method importType.
void importType(Decl decl) {
importModules.add(decl.getModuleDecl().getName());
if (decl instanceof TypeSynDecl) {
decl = resolveTypeSynonym((TypeSynDecl) decl);
importModules.add(decl.getModuleDecl().getName());
}
// import type parameters
if (decl instanceof ParametricDataTypeDecl) {
for (TypeParameterDecl t : ((ParametricDataTypeDecl) decl).getTypeParameters()) {
Decl type = getDecl(model, Decl.class, namePred(t.getName()));
if (type == null) {
// most likely a generic type
continue;
}
importType(type);
}
}
}
use of abs.frontend.ast.Decl 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());
}
}
}
}
}
}
}
}
use of abs.frontend.ast.Decl in project abstools by abstools.
the class DeltaAddFunctionalTest method addFun.
@Test
public void addFun() throws DeltaModellingException {
Model model = assertParseOk("module M;" + "def Int i() = 1;" + "delta I; uses M;" + "adds def Int j<A>(A a) = 2;" + "adds def Int h() = 2;");
Decl funI = findDecl(model, "M", "i");
assertNotNull(funI);
assertThat(funI, instanceOf(FunctionDecl.class));
DeltaDecl delta = findDelta(model, "I");
assertNotNull(delta);
assertThat(delta, instanceOf(DeltaDecl.class));
Decl funj = findDecl(model, "M", "j");
assertNull(funj);
Decl funh = findDecl(model, "M", "h");
assertNull(funh);
model.applyDelta(delta);
funj = findDecl(model, "M", "j");
assertNotNull(funj);
assertThat(funj, instanceOf(FunctionDecl.class));
funh = findDecl(model, "M", "h");
assertNotNull(funh);
assertThat(funh, instanceOf(FunctionDecl.class));
}
use of abs.frontend.ast.Decl in project abstools by abstools.
the class WizardUtil method validateInterface.
/**
* Same as {@link #validate(String)} but additionally checks, whether the specified
* interface name already exists in the given module declaration
*
* @param text
* Name to be checked.
* @param decl
* Target ModuleDecl.
* @return In case of a duplicate name, this method returns
* ErrorType.ERROR_NO_DUPLICATE_NAME with the duplicate name set in
* its information string.
*/
public static ErrorType validateInterface(String text, ModuleDecl decl) {
if (decl != null) {
for (Decl d : decl.getDecls()) {
if (d instanceof InterfaceDecl && d.getName().equals(text)) {
ErrorType type = ErrorType.ERROR_DUPLICATE_NAME;
type.setInformationString(text);
return type;
}
}
}
return validate(text);
}
use of abs.frontend.ast.Decl in project abstools by abstools.
the class WizardUtil method validateClass.
/**
* Same as {@link #validate(String)} but additionally checks, whether the specified
* class name already exists in the given module declaration
*
* @param text
* Name to be checked.
* @param decl
* Target ModuleDecl.
* @return In case of a duplicate name, this method returns
* ErrorType.ERROR_NO_DUPLICATE_NAME with the duplicate name set in
* its information string.
*/
public static ErrorType validateClass(String text, ModuleDecl decl) {
if (decl != null) {
for (Decl d : decl.getDecls()) {
if (d instanceof ClassDecl && d.getName().equals(text)) {
ErrorType type = ErrorType.ERROR_DUPLICATE_NAME;
type.setInformationString(text);
return type;
}
}
}
return validate(text);
}
Aggregations