Fix diagnostics tests

This commit is contained in:
Alexey Andreev 2017-01-24 23:42:41 +03:00
parent 55836d6ed7
commit c7829a77cf
2 changed files with 7 additions and 9 deletions

View File

@ -337,7 +337,7 @@ class JSClassProcessor {
if (invoke.getInstance() != null) { if (invoke.getInstance() != null) {
if (!typeHelper.isSupportedType(ValueType.object(method.getOwnerName()))) { if (!typeHelper.isSupportedType(ValueType.object(method.getOwnerName()))) {
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method " diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method "
+ " declaration. It is non-static and declared on a non-overlay class {{c1}}", + "declaration. It is non-static and declared on a non-overlay class {{c1}}",
invoke.getMethod(), method.getOwnerName()); invoke.getMethod(), method.getOwnerName());
valid = false; valid = false;
} }
@ -443,7 +443,7 @@ class JSClassProcessor {
private boolean validateSignature(MethodReader method, CallLocation callLocation, boolean[] byRefParams) { private boolean validateSignature(MethodReader method, CallLocation callLocation, boolean[] byRefParams) {
if (method.getResultType() != ValueType.VOID && !typeHelper.isSupportedType(method.getResultType())) { if (method.getResultType() != ValueType.VOID && !typeHelper.isSupportedType(method.getResultType())) {
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method " diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method "
+ "declaration", method.getReference()); + "declaration, since it returns wrong type", method.getReference());
return false; return false;
} }
@ -453,13 +453,13 @@ class JSClassProcessor {
ValueType paramType = parameterTypes[i]; ValueType paramType = parameterTypes[i];
if (!typeHelper.isSupportedType(paramType)) { if (!typeHelper.isSupportedType(paramType)) {
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method " diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method "
+ "declaration: its " + (i + 1) + "th argument has wrong type", method.getReference()); + "declaration: its " + (i + 1) + "th parameter has wrong type", method.getReference());
return false; return false;
} }
if (parameterAnnotations[i].get(JSByRef.class.getName()) != null) { if (parameterAnnotations[i].get(JSByRef.class.getName()) != null) {
if (!typeHelper.isSupportedByRefType(paramType)) { if (!typeHelper.isSupportedByRefType(paramType)) {
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method " diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method "
+ "declaration: its " + (i + 1) + "th argument is declared as JSByRef, " + "declaration: its " + (i + 1) + "th parameter is declared as JSByRef, "
+ "which has incompatible type", method.getReference()); + "which has incompatible type", method.getReference());
return false; return false;
} }

View File

@ -35,14 +35,13 @@ public class JSOTest {
Problem foundProblem = build("callJSBodyWithWrongParameter").stream().filter(problem -> { Problem foundProblem = build("callJSBodyWithWrongParameter").stream().filter(problem -> {
return problem.getLocation().getMethod().getName().equals("callJSBodyWithWrongParameter") return problem.getLocation().getMethod().getName().equals("callJSBodyWithWrongParameter")
&& problem.getText().equals("Method {{m0}} is not a proper native JavaScript method " && problem.getText().equals("Method {{m0}} is not a proper native JavaScript method "
+ " declaration. Its parameter #1 has invalid type {{t1}}"); + "declaration: its 1th parameter has wrong type");
}).findAny().orElse(null); }).findAny().orElse(null);
assertNotNull(foundProblem); assertNotNull(foundProblem);
Object[] params = foundProblem.getParams(); Object[] params = foundProblem.getParams();
assertThat(params[0], is(new MethodReference(JSOTest.class, "jsBodyWithWrongParameter", assertThat(params[0], is(new MethodReference(JSOTest.class, "jsBodyWithWrongParameter",
Object.class, void.class))); Object.class, void.class)));
assertThat(params[1], is(ValueType.parse(Object.class)));
} }
private static void callJSBodyWithWrongParameter() { private static void callJSBodyWithWrongParameter() {
@ -57,7 +56,7 @@ public class JSOTest {
Problem foundProblem = build("callWrongNonStaticJSBody").stream().filter(problem -> { Problem foundProblem = build("callWrongNonStaticJSBody").stream().filter(problem -> {
return problem.getLocation().getMethod().getName().equals("callWrongNonStaticJSBody") return problem.getLocation().getMethod().getName().equals("callWrongNonStaticJSBody")
&& problem.getText().equals("Method {{m0}} is not a proper native JavaScript method " && problem.getText().equals("Method {{m0}} is not a proper native JavaScript method "
+ " declaration. It is non-static and declared on a non-overlay class {{c1}}"); + "declaration. It is non-static and declared on a non-overlay class {{c1}}");
}).findAny().orElse(null); }).findAny().orElse(null);
assertNotNull(foundProblem); assertNotNull(foundProblem);
@ -78,14 +77,13 @@ public class JSOTest {
Problem foundProblem = build("callJSBodyWithWrongReturningType").stream().filter(problem -> { Problem foundProblem = build("callJSBodyWithWrongReturningType").stream().filter(problem -> {
return problem.getLocation().getMethod().getName().equals("callJSBodyWithWrongReturningType") return problem.getLocation().getMethod().getName().equals("callJSBodyWithWrongReturningType")
&& problem.getText().equals("Method {{m0}} is not a proper native JavaScript method " && problem.getText().equals("Method {{m0}} is not a proper native JavaScript method "
+ " declaration, since it returns invalid type {{t1}}"); + "declaration, since it returns wrong type");
}).findAny().orElse(null); }).findAny().orElse(null);
assertNotNull(foundProblem); assertNotNull(foundProblem);
Object[] params = foundProblem.getParams(); Object[] params = foundProblem.getParams();
assertThat(params[0], is(new MethodReference(JSOTest.class, "jsBodyWithWrongReturningType", String.class, assertThat(params[0], is(new MethodReference(JSOTest.class, "jsBodyWithWrongReturningType", String.class,
Object.class))); Object.class)));
assertThat(params[1], is(ValueType.parse(Object.class)));
} }
private static void callJSBodyWithWrongReturningType() { private static void callJSBodyWithWrongReturningType() {