use of org.eclipse.xtext.diagnostics.Diagnostic in project xtext-core by eclipse.
the class Bug437669Test method testUnresolved_01.
@Test
public void testUnresolved_01() {
Type type = resolve("BlaBlaBla");
Resource resource = type.eResource();
assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size());
Diagnostic diagnostic = (Diagnostic) resource.getErrors().get(0);
assertEquals(0, diagnostic.getOffset());
assertEquals(1, diagnostic.getLength());
assertEquals(1, diagnostic.getLine());
assertEquals(1, diagnostic.getColumn());
assertEquals("Couldn't resolve reference to Type 'BlaBlaBla'.", diagnostic.getMessage());
}
use of org.eclipse.xtext.diagnostics.Diagnostic in project xtext-core by eclipse.
the class Bug437669Test method testUnresolved_02.
@Test
public void testUnresolved_02() {
Type type = getContext();
INode nameNode = NodeModelUtils.findNodesForFeature(type, ImportedURIPackage.Literals.TYPE__NAME).get(0);
resolve(type, "BlaBlaBla", nameNode.getOffset(), nameNode.getLength());
Resource resource = type.eResource();
assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size());
LineAndColumn lineAndColumn = NodeModelUtils.getLineAndColumn(nameNode, nameNode.getOffset());
Diagnostic diagnostic = (Diagnostic) resource.getErrors().get(0);
assertEquals(nameNode.getOffset(), diagnostic.getOffset());
assertEquals(nameNode.getLength(), diagnostic.getLength());
assertEquals(lineAndColumn.getLine(), diagnostic.getLine());
assertEquals(lineAndColumn.getColumn(), diagnostic.getColumn());
assertEquals("Couldn't resolve reference to Type 'BlaBlaBla'.", diagnostic.getMessage());
}
use of org.eclipse.xtext.diagnostics.Diagnostic in project xtext-core by eclipse.
the class LinkingErrorTest method testLinkError.
@Test
public void testLinkError() throws Exception {
XtextResource resource = getResourceFromStringAndExpect(" type A extends B \n type B extends C", 1);
Main model = (Main) getModel(resource);
assertEquals(2, model.getTypes().size());
assertEquals(1, resource.getErrors().size());
assertEquals(0, resource.getWarnings().size());
Diagnostic error = (Diagnostic) resource.getErrors().get(0);
assertEquals(2, error.getLine());
Diagnostic verboseError = error;
assertEquals(35, verboseError.getOffset());
assertEquals(1, verboseError.getLength());
}
use of org.eclipse.xtext.diagnostics.Diagnostic in project xtext-core by eclipse.
the class LinkingErrorTest method testLinkingErrorMessage.
@Test
public void testLinkingErrorMessage() throws Exception {
XtextResource resource = getResourceFromStringAndExpect("type A extends B", 1);
assertEquals(1, resource.getErrors().size());
Diagnostic error = (Diagnostic) resource.getErrors().get(0);
assertEquals(1, error.getLine());
assertEquals("Couldn't resolve reference to Type 'B'.", error.getMessage());
}
use of org.eclipse.xtext.diagnostics.Diagnostic in project xtext-core by eclipse.
the class LinkingWarningsTest method testLinkingProblemAsWarning.
@Test
public void testLinkingProblemAsWarning() throws Exception {
String modelAsText = "type A extends B \n type B extends C";
XtextResource resource = getResourceFromStringAndExpect(modelAsText, 0);
assertTrue(resource.getErrors().isEmpty());
assertEquals(1, resource.getWarnings().size());
Diagnostic warning = (Diagnostic) resource.getWarnings().get(0);
assertEquals(2, warning.getLine());
assertEquals(expected, warning.getMessage());
}
Aggregations