From 9b52cd7684832c2ccf2c1965609555931c3d39d5 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Thu, 4 Jan 2024 18:59:09 +0100 Subject: [PATCH] also verify error position for constructors' errors --- .../core/tests/validation/XtendValidationTest.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 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 7247f6cead0..b459b26dd4f 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 @@ -408,13 +408,19 @@ public void clearPreferences() { } @Test public void testMissingConstructor() throws Exception { - XtendClass clazz = clazz("class K extends test.NoDefaultConstructor {}"); - helper.assertError(clazz, XTEND_CLASS, MISSING_CONSTRUCTOR); + var source = "class K extends test.NoDefaultConstructor {}"; + XtendClass clazz = clazz(source); + helper.assertError(clazz, XTEND_CLASS, MISSING_CONSTRUCTOR, + source.indexOf("K"), 1, + "must define an explicit constructor"); } @Test public void testMissingSuperConstructorCall() throws Exception { - XtendClass clazz = clazz("class K extends test.NoDefaultConstructor { new() {} }"); - helper.assertError(clazz, XTEND_CONSTRUCTOR, MUST_INVOKE_SUPER_CONSTRUCTOR); + var source = "class K extends test.NoDefaultConstructor { new() {} }"; + XtendClass clazz = clazz(source); + helper.assertError(clazz, XTEND_CONSTRUCTOR, MUST_INVOKE_SUPER_CONSTRUCTOR, + source.indexOf("new() {}"), "new() {}".length(), + "Another constructor must be invoked explicitly"); } @Test public void testSuperConstructorCall() throws Exception {