@Test public void missingTypeSpecification() { String body = "console[attr] = function(msg) {\n" + " @org.netbeans.html.charts.Main::log(msg);\n" + "};\n"; JsCallback instance = new JsCallbackImpl(); try { String result = instance.parse(body); fail("The parsing should fail!"); } catch (IllegalStateException ex) { } }
final String parse(String body) { StringBuilder sb = new StringBuilder(); int pos = 0; for (;;) { int next = body.indexOf(".@", pos); if (next == -1) { sb.append(body.substring(pos)); body = sb.toString(); break; } int ident = next; while (ident > 0) { if (!Character.isJavaIdentifierPart(body.charAt(--ident))) { ident++; break; } } String refId = body.substring(ident, next); sb.append(body.substring(pos, ident)); int sigBeg = body.indexOf('(', next); int sigEnd = body.indexOf(')', sigBeg); int colon4 = body.indexOf("::", next); if (sigBeg == -1 || sigEnd == -1 || colon4 == -1) { throw new IllegalStateException( "Wrong format of instance callback. " + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body ); } String fqn = body.substring(next + 2, colon4); String method = body.substring(colon4 + 2, sigBeg); String params = body.substring(sigBeg, sigEnd + 1); int paramBeg = body.indexOf('(', sigEnd + 1); if (paramBeg == -1) { throw new IllegalStateException( "Wrong format of instance callback. " + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body ); } sb.append(callMethod(refId, fqn, method, params)); if (body.charAt(paramBeg + 1) != (')')) { sb.append(","); } pos = paramBeg + 1; } pos = 0; sb = null; for (;;) { int next = body.indexOf("@", pos); if (next == -1) { if (sb == null) { return body; } sb.append(body.substring(pos)); return sb.toString(); } if (sb == null) { sb = new StringBuilder(); } sb.append(body.substring(pos, next)); int sigBeg = body.indexOf('(', next); int sigEnd = body.indexOf(')', sigBeg); int colon4 = body.indexOf("::", next); int paramBeg = body.indexOf('(', sigEnd + 1); if (sigBeg == -1 || sigEnd == -1 || colon4 == -1 || paramBeg == -1) { throw new IllegalStateException( "Wrong format of static callback. " + "Should be: '@pkg.Class::staticMethod(Ljava/lang/Object;)(param)':\n" + body ); } String fqn = body.substring(next + 1, colon4); String method = body.substring(colon4 + 2, sigBeg); String params = body.substring(sigBeg, sigEnd + 1); sb.append(callMethod(null, fqn, method, params)); pos = paramBeg + 1; } }
JsCallback { final String parse(String body) { StringBuilder sb = new StringBuilder(); int pos = 0; for (;;) { int next = body.indexOf(".@", pos); if (next == -1) { sb.append(body.substring(pos)); body = sb.toString(); break; } int ident = next; while (ident > 0) { if (!Character.isJavaIdentifierPart(body.charAt(--ident))) { ident++; break; } } String refId = body.substring(ident, next); sb.append(body.substring(pos, ident)); int sigBeg = body.indexOf('(', next); int sigEnd = body.indexOf(')', sigBeg); int colon4 = body.indexOf("::", next); if (sigBeg == -1 || sigEnd == -1 || colon4 == -1) { throw new IllegalStateException( "Wrong format of instance callback. " + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body ); } String fqn = body.substring(next + 2, colon4); String method = body.substring(colon4 + 2, sigBeg); String params = body.substring(sigBeg, sigEnd + 1); int paramBeg = body.indexOf('(', sigEnd + 1); if (paramBeg == -1) { throw new IllegalStateException( "Wrong format of instance callback. " + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body ); } sb.append(callMethod(refId, fqn, method, params)); if (body.charAt(paramBeg + 1) != (')')) { sb.append(","); } pos = paramBeg + 1; } pos = 0; sb = null; for (;;) { int next = body.indexOf("@", pos); if (next == -1) { if (sb == null) { return body; } sb.append(body.substring(pos)); return sb.toString(); } if (sb == null) { sb = new StringBuilder(); } sb.append(body.substring(pos, next)); int sigBeg = body.indexOf('(', next); int sigEnd = body.indexOf(')', sigBeg); int colon4 = body.indexOf("::", next); int paramBeg = body.indexOf('(', sigEnd + 1); if (sigBeg == -1 || sigEnd == -1 || colon4 == -1 || paramBeg == -1) { throw new IllegalStateException( "Wrong format of static callback. " + "Should be: '@pkg.Class::staticMethod(Ljava/lang/Object;)(param)':\n" + body ); } String fqn = body.substring(next + 1, colon4); String method = body.substring(colon4 + 2, sigBeg); String params = body.substring(sigBeg, sigEnd + 1); sb.append(callMethod(null, fqn, method, params)); pos = paramBeg + 1; } } }
JsCallback { final String parse(String body) { StringBuilder sb = new StringBuilder(); int pos = 0; for (;;) { int next = body.indexOf(".@", pos); if (next == -1) { sb.append(body.substring(pos)); body = sb.toString(); break; } int ident = next; while (ident > 0) { if (!Character.isJavaIdentifierPart(body.charAt(--ident))) { ident++; break; } } String refId = body.substring(ident, next); sb.append(body.substring(pos, ident)); int sigBeg = body.indexOf('(', next); int sigEnd = body.indexOf(')', sigBeg); int colon4 = body.indexOf("::", next); if (sigBeg == -1 || sigEnd == -1 || colon4 == -1) { throw new IllegalStateException( "Wrong format of instance callback. " + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body ); } String fqn = body.substring(next + 2, colon4); String method = body.substring(colon4 + 2, sigBeg); String params = body.substring(sigBeg, sigEnd + 1); int paramBeg = body.indexOf('(', sigEnd + 1); if (paramBeg == -1) { throw new IllegalStateException( "Wrong format of instance callback. " + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body ); } sb.append(callMethod(refId, fqn, method, params)); if (body.charAt(paramBeg + 1) != (')')) { sb.append(","); } pos = paramBeg + 1; } pos = 0; sb = null; for (;;) { int next = body.indexOf("@", pos); if (next == -1) { if (sb == null) { return body; } sb.append(body.substring(pos)); return sb.toString(); } if (sb == null) { sb = new StringBuilder(); } sb.append(body.substring(pos, next)); int sigBeg = body.indexOf('(', next); int sigEnd = body.indexOf(')', sigBeg); int colon4 = body.indexOf("::", next); int paramBeg = body.indexOf('(', sigEnd + 1); if (sigBeg == -1 || sigEnd == -1 || colon4 == -1 || paramBeg == -1) { throw new IllegalStateException( "Wrong format of static callback. " + "Should be: '@pkg.Class::staticMethod(Ljava/lang/Object;)(param)':\n" + body ); } String fqn = body.substring(next + 1, colon4); String method = body.substring(colon4 + 2, sigBeg); String params = body.substring(sigBeg, sigEnd + 1); sb.append(callMethod(null, fqn, method, params)); pos = paramBeg + 1; } }  }
JsCallback { final String parse(String body) { StringBuilder sb = new StringBuilder(); int pos = 0; for (;;) { int next = body.indexOf(".@", pos); if (next == -1) { sb.append(body.substring(pos)); body = sb.toString(); break; } int ident = next; while (ident > 0) { if (!Character.isJavaIdentifierPart(body.charAt(--ident))) { ident++; break; } } String refId = body.substring(ident, next); sb.append(body.substring(pos, ident)); int sigBeg = body.indexOf('(', next); int sigEnd = body.indexOf(')', sigBeg); int colon4 = body.indexOf("::", next); if (sigBeg == -1 || sigEnd == -1 || colon4 == -1) { throw new IllegalStateException( "Wrong format of instance callback. " + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body ); } String fqn = body.substring(next + 2, colon4); String method = body.substring(colon4 + 2, sigBeg); String params = body.substring(sigBeg, sigEnd + 1); int paramBeg = body.indexOf('(', sigEnd + 1); if (paramBeg == -1) { throw new IllegalStateException( "Wrong format of instance callback. " + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body ); } sb.append(callMethod(refId, fqn, method, params)); if (body.charAt(paramBeg + 1) != (')')) { sb.append(","); } pos = paramBeg + 1; } pos = 0; sb = null; for (;;) { int next = body.indexOf("@", pos); if (next == -1) { if (sb == null) { return body; } sb.append(body.substring(pos)); return sb.toString(); } if (sb == null) { sb = new StringBuilder(); } sb.append(body.substring(pos, next)); int sigBeg = body.indexOf('(', next); int sigEnd = body.indexOf(')', sigBeg); int colon4 = body.indexOf("::", next); int paramBeg = body.indexOf('(', sigEnd + 1); if (sigBeg == -1 || sigEnd == -1 || colon4 == -1 || paramBeg == -1) { throw new IllegalStateException( "Wrong format of static callback. " + "Should be: '@pkg.Class::staticMethod(Ljava/lang/Object;)(param)':\n" + body ); } String fqn = body.substring(next + 1, colon4); String method = body.substring(colon4 + 2, sigBeg); String params = body.substring(sigBeg, sigEnd + 1); sb.append(callMethod(null, fqn, method, params)); pos = paramBeg + 1; } }   }
JsCallback { final String parse(String body) { StringBuilder sb = new StringBuilder(); int pos = 0; for (;;) { int next = body.indexOf(".@", pos); if (next == -1) { sb.append(body.substring(pos)); body = sb.toString(); break; } int ident = next; while (ident > 0) { if (!Character.isJavaIdentifierPart(body.charAt(--ident))) { ident++; break; } } String refId = body.substring(ident, next); sb.append(body.substring(pos, ident)); int sigBeg = body.indexOf('(', next); int sigEnd = body.indexOf(')', sigBeg); int colon4 = body.indexOf("::", next); if (sigBeg == -1 || sigEnd == -1 || colon4 == -1) { throw new IllegalStateException( "Wrong format of instance callback. " + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body ); } String fqn = body.substring(next + 2, colon4); String method = body.substring(colon4 + 2, sigBeg); String params = body.substring(sigBeg, sigEnd + 1); int paramBeg = body.indexOf('(', sigEnd + 1); if (paramBeg == -1) { throw new IllegalStateException( "Wrong format of instance callback. " + "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body ); } sb.append(callMethod(refId, fqn, method, params)); if (body.charAt(paramBeg + 1) != (')')) { sb.append(","); } pos = paramBeg + 1; } pos = 0; sb = null; for (;;) { int next = body.indexOf("@", pos); if (next == -1) { if (sb == null) { return body; } sb.append(body.substring(pos)); return sb.toString(); } if (sb == null) { sb = new StringBuilder(); } sb.append(body.substring(pos, next)); int sigBeg = body.indexOf('(', next); int sigEnd = body.indexOf(')', sigBeg); int colon4 = body.indexOf("::", next); int paramBeg = body.indexOf('(', sigEnd + 1); if (sigBeg == -1 || sigEnd == -1 || colon4 == -1 || paramBeg == -1) { throw new IllegalStateException( "Wrong format of static callback. " + "Should be: '@pkg.Class::staticMethod(Ljava/lang/Object;)(param)':\n" + body ); } String fqn = body.substring(next + 1, colon4); String method = body.substring(colon4 + 2, sigBeg); String params = body.substring(sigBeg, sigEnd + 1); sb.append(callMethod(null, fqn, method, params)); pos = paramBeg + 1; } }    }