From a444ee785a2cfcaf325190ee742c47f0eab3441d Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Wed, 20 Dec 2023 08:57:56 +0100 Subject: [PATCH] also verify the error's position for hierarchy cycles --- .../tests/validation/XtendValidationTest.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/validation/XtendValidationTest.java b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/validation/XtendValidationTest.java index b95459ee958..1a4e35df08a 100644 --- a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/validation/XtendValidationTest.java +++ b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/validation/XtendValidationTest.java @@ -914,8 +914,11 @@ public void clearPreferences() { } @Test public void testClassExtendsItself() throws Exception { - XtendClass clazz = clazz("class Foo extends Foo {}"); - helper.assertError(clazz, XTEND_CLASS, CYCLIC_INHERITANCE, "hierarchy", "cycles"); + var source = "class Foo extends Foo {}"; + XtendClass clazz = clazz(source); + helper.assertError(clazz, XTEND_CLASS, CYCLIC_INHERITANCE, + source.indexOf("Foo"), "Foo".length(), + "hierarchy", "cycles"); } @Test public void testClassUniqueNames() throws Exception { @@ -956,13 +959,20 @@ public void clearPreferences() { } @Test public void testInheritanceCycle() throws Exception { - Iterator types = file("package test " + var source = "package test " + "class Foo extends Bar {}" + "class Bar extends Baz {}" - + "class Baz extends Foo {}").getXtendTypes().iterator(); - helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE, "hierarchy", "cycles"); - helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE, "hierarchy", "cycles"); - helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE, "hierarchy", "cycles"); + + "class Baz extends Foo {}"; + Iterator types = file(source).getXtendTypes().iterator(); + helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE, + source.indexOf("Foo"), "Foo".length(), + "hierarchy", "cycles"); + helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE, + source.lastIndexOf("Bar"), "Bar".length(), + "hierarchy", "cycles"); + helper.assertError(types.next(), XTEND_CLASS, CYCLIC_INHERITANCE, + source.lastIndexOf("Baz"), "Baz".length(), + "hierarchy", "cycles"); } @Test public void testInheritanceCycle_1() throws Exception {