use of org.eclipse.xtext.validation.IResourceValidator in project xtext-core by eclipse.
the class XtextValidationTest method testOutOfSequenceArgument_02.
@Test
public void testOutOfSequenceArgument_02() throws Exception {
XtextResource resource = getResourceFromString("grammar com.acme.Bar with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'myURI'\n" + "Model: rule=Rule<true, B=false, C=true>;\n" + "Rule<A, B, C>: name=ID;");
IResourceValidator validator = get(IResourceValidator.class);
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 0, issues.size());
}
use of org.eclipse.xtext.validation.IResourceValidator in project xtext-core by eclipse.
the class XtextValidationTest method testRuleCalledSuper.
@Test
public void testRuleCalledSuper() throws Exception {
XtextResource resource = getResourceFromString("grammar com.acme.Bar with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'myURI'\n" + "Model: super=super;\n" + "super: name=ID;");
IResourceValidator validator = get(IResourceValidator.class);
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 1, issues.size());
assertEquals("Discouraged rule name 'super'", issues.get(0).getMessage());
Grammar grammar = (Grammar) resource.getContents().get(0);
AbstractRule model = grammar.getRules().get(0);
Assignment assignment = (Assignment) model.getAlternatives();
RuleCall ruleCall = (RuleCall) assignment.getTerminal();
assertSame(grammar.getRules().get(1), ruleCall.getRule());
}
use of org.eclipse.xtext.validation.IResourceValidator in project xtext-core by eclipse.
the class XtextValidationTest method testExplicitOverride04.
@Test
public void testExplicitOverride04() throws Exception {
IResourceValidator validator = get(IResourceValidator.class);
XtextResource resource = getResourceFromString("grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" + "@Override\n" + "terminal ID: ('a'..'z'|'A'..'Z'|'_');");
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 0, issues.size());
}
use of org.eclipse.xtext.validation.IResourceValidator in project xtext-core by eclipse.
the class XtextValidationTest method testDuplicateArgument.
@Test
public void testDuplicateArgument() throws Exception {
XtextResource resource = getResourceFromString("grammar com.acme.Bar with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'myURI'\n" + "Model: rule=Rule<Single=true, Single=false>;\n" + "Rule<Single>: name=ID;");
IResourceValidator validator = get(IResourceValidator.class);
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 1, issues.size());
assertEquals("Duplicate value for parameter Single", issues.get(0).getMessage());
}
use of org.eclipse.xtext.validation.IResourceValidator in project xtext-core by eclipse.
the class XtextValidationTest method testMissingArgument3.
@Test
public void testMissingArgument3() throws Exception {
XtextResource resource = getResourceFromString("grammar com.acme.Bar with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'myURI'\n" + "Model: rule=Rule<true>;\n" + "Rule<First, Missing, AlsoMissing>: name=ID;");
IResourceValidator validator = get(IResourceValidator.class);
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertEquals(issues.toString(), 1, issues.size());
assertEquals("Expected 3 arguments but got 1", issues.get(0).getMessage());
}
Aggregations