use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class DeclarativeValidatorTest method testWarning.
@Test
public void testWarning() {
AbstractDeclarativeValidator test = new AbstractDeclarativeValidator() {
@Check
public void foo(Object x) {
warning("Error Message", EcorePackage.Literals.ENAMED_ELEMENT__NAME);
}
};
BasicDiagnostic chain = new BasicDiagnostic();
test.validate(EcorePackage.eINSTANCE.getEClass(), chain, Collections.emptyMap());
assertEquals(1, chain.getChildren().size());
Diagnostic diag = chain.getChildren().get(0);
assertEquals("Error Message", diag.getMessage());
assertEquals(EcorePackage.eINSTANCE.getEClass().toString(), diag.getSource());
assertEquals(Diagnostic.WARNING, diag.getSeverity());
}
use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class ImportUriValidatorTest method testInvalidURI.
@Test
public void testInvalidURI() throws Exception {
String model = "import 'classpath:/org/eclipse/xtext/linking/ImportUriTestLanguage.unknown'";
Resource resource = getResourceFromString(model);
Diagnostic diagnostics = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
assertEquals(Diagnostic.ERROR, diagnostics.getSeverity());
}
use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class ImportUriValidatorTest method testValidURI.
@Test
public void testValidURI() throws Exception {
String model = "import 'classpath:/org/eclipse/xtext/linking/ImportUriTestLanguage.xtext'";
Resource resource = getResourceFromString(model);
Diagnostic diagnostics = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
assertEquals(Diagnostic.OK, diagnostics.getSeverity());
}
use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class Bug456789Test method doesNotHang_01.
@Test(timeout = 5000)
public void doesNotHang_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar com.acme.G with org.eclipse.xtext.common.Terminals");
_builder.newLine();
_builder.newLine();
_builder.append("generate g \"bug456789\"");
_builder.newLine();
_builder.newLine();
_builder.append("CompoundStatement: Declaration;");
_builder.newLine();
_builder.append("suite: simpleStatement | NL INDENT stmt+ DEDENT;");
_builder.newLine();
_builder.newLine();
_builder.append("test: or_test (\'if\' or_test \'else\' test)? | lambdef;");
_builder.newLine();
_builder.append("or_test: and_test (\'or\' and_test)*;");
_builder.newLine();
_builder.append("and_test: not_test (\'and\' not_test)*;");
_builder.newLine();
_builder.append("not_test: \'not\' not_test | comparison;");
_builder.newLine();
_builder.append("comparison: expr (comp_op expr)*;");
_builder.newLine();
_builder.append("comp_op: \'<\'|\'>\'|\'==\'|\'>=\'|\'<=\'|\'<>\'|\'!=\'|\'in\'|\'not\' \'in\'|\'is\'|\'is\' \'not\';");
_builder.newLine();
_builder.append("expr: xorExpression (\'|\' xorExpression)*;");
_builder.newLine();
_builder.append("xorExpression: andExpression (\'^\' andExpression)*;");
_builder.newLine();
_builder.append("andExpression: shiftExpression (\'&\' shiftExpression)*;");
_builder.newLine();
_builder.append("shiftExpression: arithExpression ((\'<<\'|\'>>\') arithExpression)*;");
_builder.newLine();
_builder.append("arithExpression: term ((\'+\'|\'-\') term)*;");
_builder.newLine();
_builder.append("term: factor ((\'*\'|\'/\'|\'%\'|\'//\') factor)*;");
_builder.newLine();
_builder.append("factor: (\'+\'|\'-\'|\'~\') factor | power;");
_builder.newLine();
_builder.append("power: atom trailer* (\'**\' factor)?;");
_builder.newLine();
_builder.append("atom: (\'(\' (yieldExpression|testlist_comp)? \')\' |");
_builder.newLine();
_builder.append(" ");
_builder.append("\'(\' (listmaker)? \')?\' |");
_builder.newLine();
_builder.append(" ");
_builder.append("\'{\' (dictorsetmaker)? \'}\' |");
_builder.newLine();
_builder.append(" ");
_builder.append("\'`\' testlist1 \'`\' |");
_builder.newLine();
_builder.append(" ");
_builder.append("ID | NUMBER | STRING+);");
_builder.newLine();
_builder.append("listmaker: test ( list_for | (\',\' test)* (\',\')? );");
_builder.newLine();
_builder.append("testlist_comp: test ( comp_for | (\',\' test)* (\',\')? );");
_builder.newLine();
_builder.append("lambdef: \'lambda\' (varargslist)? \':\' test;");
_builder.newLine();
_builder.append("trailer: \'(\' (arglist)? \')\' | \'(\' subscriptlist \')?\' | \'.\' ID;");
_builder.newLine();
_builder.append("subscriptlist: subscript (\',\' subscript)* (\',\')?;");
_builder.newLine();
_builder.append("subscript: \'.\' \'.\' \'.\' | test | (test)? \':\' (test)? (sliceop)?;");
_builder.newLine();
_builder.append("sliceop: \':\' (test)?;");
_builder.newLine();
_builder.append("exprlist: expr (\',\' expr)* (\',\')?;");
_builder.newLine();
_builder.append("testlist: test (\',\' test)* (\',\')?;");
_builder.newLine();
_builder.append("dictorsetmaker: ( (test \':\' test (comp_for | (\',\' test \':\' test)* (\',\')?)) |");
_builder.newLine();
_builder.append(" ");
_builder.append("(test (comp_for | (\',\' test)* (\',\')?)) );");
_builder.newLine();
final XtextResource resource = this.getResourceFromStringAndExpect(_builder.toString(), AbstractXtextTests.UNKNOWN_EXPECTATION);
final Diagnostic diag = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
Assert.assertNotNull("diag", diag);
Assert.assertEquals("diag.isError", diag.getSeverity(), Diagnostic.ERROR);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class XtextValidationTest method testBug_283534_03.
@Test
public void testBug_283534_03() throws Exception {
XtextResource resource = getResourceFromString("grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'myURI'\n" + "terminal TERMINAL: ID;\n" + "Model: name=STRING;\n");
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
assertTrue(resource.getWarnings().toString(), resource.getWarnings().isEmpty());
Diagnostic diag = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
assertNotNull("diag", diag);
assertEquals(diag.getChildren().toString(), 1, diag.getChildren().size());
assertEquals("diag.isError", diag.getSeverity(), Diagnostic.ERROR);
}
Aggregations