use of org.eclipse.xtext.validation.IResourceValidator in project xtext-core by eclipse.
the class XtextValidationTest method testMissingArgument.
@Test
public void testMissingArgument() throws Exception {
XtextResource resource = getResourceFromString("grammar com.acme.Bar with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'myURI'\n" + "Model: rule=Rule<First=true, Second=false>;\n" + "Rule<First, Missing, Second>: 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("Missing argument for parameter Missing", issues.get(0).getMessage());
}
use of org.eclipse.xtext.validation.IResourceValidator in project xtext-core by eclipse.
the class XtextValidationTest method testSupressedWarning_02.
@Test
public void testSupressedWarning_02() throws Exception {
XtextResource resource = getResourceFromString("grammar org.acme.Bar with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'myURI'\n" + "/* SuppressWarnings[potentialOverride] */\n" + "Parens: \n" + " ('(' Parens ')'|name=ID) em='!'?;");
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
assertTrue(resource.getWarnings().toString(), resource.getWarnings().isEmpty());
IResourceValidator validator = get(IResourceValidator.class);
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertTrue(issues.toString(), issues.isEmpty());
}
use of org.eclipse.xtext.validation.IResourceValidator in project xtext-core by eclipse.
the class XtextValidationTest method testSupressedWarning_01.
@Test
public void testSupressedWarning_01() throws Exception {
XtextResource resource = getResourceFromString("grammar org.acme.Bar with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'myURI'\n" + "Model: child=Child;\n" + "/* SuppressWarnings[noInstantiation] */\n" + "Child: name=ID?;");
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
assertTrue(resource.getWarnings().toString(), resource.getWarnings().isEmpty());
IResourceValidator validator = get(IResourceValidator.class);
List<Issue> issues = validator.validate(resource, CheckMode.FAST_ONLY, CancelIndicator.NullImpl);
assertTrue(issues.toString(), issues.isEmpty());
}
use of org.eclipse.xtext.validation.IResourceValidator in project xtext-xtend by eclipse.
the class XtendBatchCompiler method validate.
protected List<Issue> validate(ResourceSet resourceSet) {
List<Issue> issues = Lists.newArrayList();
List<Resource> resources = Lists.newArrayList(resourceSet.getResources());
for (Resource resource : resources) {
IResourceServiceProvider resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(resource.getURI());
if (resourceServiceProvider != null && isSourceFile(resource)) {
IResourceValidator resourceValidator = resourceServiceProvider.getResourceValidator();
List<Issue> result = resourceValidator.validate(resource, CheckMode.ALL, null);
addAll(issues, result);
}
}
return issues;
}
use of org.eclipse.xtext.validation.IResourceValidator in project xtext-xtend by eclipse.
the class LinkingTest method testBug345433_02.
@Test
public void testBug345433_02() throws Exception {
String classAsString = "import static extension org.eclipse.xtext.GrammarUtil.*\n" + "class Foo {" + " org.eclipse.xtext.Grammar grammar\n" + " def function1() {\n" + " grammar.containedRuleCalls.filter(e0 | " + " !e0.isAssigned() && !e0.isEObjectRuleCall()" + " ).map(e1 | e1.rule)\n" + " }\n" + "}";
XtendClass clazz = clazz(classAsString);
IResourceValidator validator = ((XtextResource) clazz.eResource()).getResourceServiceProvider().getResourceValidator();
List<Issue> issues = validator.validate(clazz.eResource(), CheckMode.ALL, CancelIndicator.NullImpl);
assertTrue("Resource contained errors : " + issues.toString(), issues.isEmpty());
XtendFunction function = (XtendFunction) clazz.getMembers().get(1);
XExpression body = function.getExpression();
LightweightTypeReference bodyType = getType(body);
assertEquals("java.lang.Iterable<org.eclipse.xtext.AbstractRule>", bodyType.getIdentifier());
XBlockExpression block = (XBlockExpression) body;
XMemberFeatureCall featureCall = (XMemberFeatureCall) block.getExpressions().get(0);
XClosure closure = (XClosure) featureCall.getMemberCallArguments().get(0);
JvmFormalParameter e1 = closure.getFormalParameters().get(0);
assertEquals("e1", e1.getSimpleName());
assertEquals("org.eclipse.xtext.RuleCall", getType(e1).getIdentifier());
}
Aggregations