use of org.eclipse.xtext.TypeRef in project xtext-core by eclipse.
the class XtextValidationTest method testCheckCrossReferenceTerminal_01.
@Test
public void testCheckCrossReferenceTerminal_01() throws Exception {
XtextValidator validator = get(XtextValidator.class);
CrossReference reference = XtextFactory.eINSTANCE.createCrossReference();
RuleCall call = XtextFactory.eINSTANCE.createRuleCall();
reference.setTerminal(call);
ParserRule rule = XtextFactory.eINSTANCE.createParserRule();
call.setRule(rule);
TypeRef typeRef = XtextFactory.eINSTANCE.createTypeRef();
rule.setType(typeRef);
typeRef.setClassifier(EcorePackage.Literals.ESTRING);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(null, false, false);
validator.setMessageAcceptor(messageAcceptor);
validator.checkCrossReferenceTerminal(reference);
messageAcceptor.validate();
}
use of org.eclipse.xtext.TypeRef in project xtext-core by eclipse.
the class TreeConstTest method assertTypes.
private void assertTypes(Collection<TypeRef> actual, String... expected) {
Set<String> refs = Sets.newHashSet();
for (TypeRef t : actual) refs.add(t == null ? "null" : t.getClassifier().getName());
Set<String> actual2 = Sets.newHashSet(refs);
for (String e : expected) {
if (refs.contains(e))
refs.remove(e);
else
fail("Type '" + e + "' not found. Actual:" + actual2 + " Expected: " + Joiner.on(", ").join(expected));
}
if (!refs.isEmpty())
fail("Types '" + refs + "' are not expected. Actual:" + actual2 + " Expected: " + Joiner.on(", ").join(expected));
}
Aggregations