use of abs.frontend.ast.InterfaceDecl in project abstools by abstools.
the class TypeHierarchyContentProvider method getChildren.
@Override
public Object[] getChildren(Object node) {
if (node instanceof InterfaceDecl) {
InterfaceDecl interfaceDecl = (InterfaceDecl) node;
Collection<HasTypeHierarchy> subTypes = interfaceDecl.getDirectSubTypes();
return subTypes.toArray();
} else if (node instanceof DataTypeDecl) {
DataTypeDecl dataTypeDecl = (DataTypeDecl) node;
Object[] result = new Object[dataTypeDecl.getNumDataConstructor()];
int i = 0;
for (DataConstructor d : dataTypeDecl.getDataConstructors()) {
result[i] = d;
i++;
}
return result;
} else if (node instanceof TypeSynDecl) {
TypeSynDecl typeSynDecl = (TypeSynDecl) node;
return new Object[] { typeSynDecl.getType().getDecl() };
}
return nothing;
}
use of abs.frontend.ast.InterfaceDecl in project abstools by abstools.
the class DeltaSamplesTest method test_ticket322_P.
@Test
public void test_ticket322_P() throws Exception {
Model m = assertTypeCheckFileOk("tests/abssamples/deltas/bug322.abs", true);
m.flattenForProduct("P");
m.flushCache();
assertFalse(m.hasErrors());
assertFalse(m.hasTypeErrors());
InterfaceDecl i = (InterfaceDecl) DeltaTest.findDecl(m, "M", "I");
assertNotNull(i);
InterfaceDecl j = (InterfaceDecl) DeltaTest.findDecl(m, "M", "J");
assertNotNull(j);
}
use of abs.frontend.ast.InterfaceDecl 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.InterfaceDecl in project abstools by abstools.
the class WizardUtilsTests method testValidateInterface.
@Test
public void testValidateInterface() {
ModuleDecl mockDecl = mock(ModuleDecl.class);
List<Decl> list = new List<Decl>();
InterfaceDecl m1 = mock(InterfaceDecl.class);
InterfaceDecl m2 = mock(InterfaceDecl.class);
when(m1.getName()).thenReturn("Interface1");
when(m2.getName()).thenReturn("Interface2");
list.add(m1);
list.add(m2);
when(mockDecl.getDecls()).thenReturn(list);
String valid1 = "A";
String valid2 = "Abc3";
String valid3 = "ABC3";
String invalid1 = "";
String invalid2 = "a";
String invalid3 = "a.b";
String invalid4 = ";";
String invalid5 = "module";
String invalid6 = "Interface1";
String invalid7 = "Interface2";
assertTrue(validateInterface(valid1, mockDecl).equals(ErrorType.NO_ERROR));
assertTrue(validateInterface(valid2, mockDecl).equals(ErrorType.NO_ERROR));
assertTrue(validateInterface(valid3, mockDecl).equals(ErrorType.NO_ERROR));
assertTrue(validateInterface(invalid1, mockDecl).equals(ErrorType.ERROR_NO_NAME));
assertTrue(validateInterface(invalid2, mockDecl).equals(ErrorType.ERROR_NO_UPPER_CASE));
assertTrue(validateInterface(invalid3, mockDecl).equals(ErrorType.ERROR_NO_UPPER_CASE));
assertTrue(validateInterface(invalid4, mockDecl).equals(ErrorType.ERROR_INVALID_NAME));
assertTrue(validateInterface(invalid5, mockDecl).equals(ErrorType.ERROR_KEYWORD));
assertTrue(validateInterface(invalid6, mockDecl).equals(ErrorType.ERROR_DUPLICATE_NAME));
assertTrue(validateInterface(invalid7, mockDecl).equals(ErrorType.ERROR_DUPLICATE_NAME));
}
use of abs.frontend.ast.InterfaceDecl in project abstools by abstools.
the class DeltaSamplesTest method test_ticket322_Q.
@Test
public void test_ticket322_Q() throws Exception {
Model m = assertTypeCheckFileOk("tests/abssamples/deltas/bug322.abs", true);
m.flattenForProduct("Q");
m.flushCache();
assertFalse(m.hasErrors());
assertFalse(m.hasTypeErrors());
InterfaceDecl i = (InterfaceDecl) DeltaTest.findDecl(m, "M", "I");
assertNull(i);
InterfaceDecl j = (InterfaceDecl) DeltaTest.findDecl(m, "M", "J");
assertNull(j);
}
Aggregations