Skip to content

Commit

Permalink
fixed verify error's position for parameter INVALID_USE_OF_TYPE
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Dec 20, 2023
1 parent 9c8360d commit b7467a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public abstract class AbstractXtendTestCase extends Assert {
*/
protected static final String TEMPLATE_CLASS = "class Foo { %s }";
/**
* Use it to subtract from the index position of a source element of a function or constructor
* Use it to add it to the index position of a source element of a function or constructor
*/
protected static final int TEMPLATE_CLASS_SIZE = TEMPLATE_CLASS.length() - 2; // 2 is the length of placeholder %s
protected static final int TEMPLATE_CLASS_PREFIX_SIZE = TEMPLATE_CLASS.indexOf("%s");

protected XtendClass clazz(String string) throws Exception {
return (XtendClass) file(string).getXtendTypes().get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,10 @@ public void clearPreferences() {
@Test public void testParameterTypeMayNotBeVoid() throws Exception {
var source = "def void foo(void myParam) { }";
XtendFunction function = function(source);
var lastIndexOf = source.lastIndexOf("void");
helper.assertError(function, TypesPackage.Literals.JVM_TYPE_REFERENCE,
INVALID_USE_OF_TYPE,
source.lastIndexOf("void") - TEMPLATE_CLASS_SIZE, "void".length());
lastIndexOf + TEMPLATE_CLASS_PREFIX_SIZE, "void".length());
}

@Test public void testVarArgIsNotExtension() throws Exception {
Expand Down

0 comments on commit b7467a3

Please sign in to comment.