1.1 --- a/dew/pom.xml Sun Sep 22 21:56:49 2013 +0200
1.2 +++ b/dew/pom.xml Mon Sep 23 00:59:14 2013 +0200
1.3 @@ -87,5 +87,18 @@
1.4 <artifactId>javaquery.api</artifactId>
1.5 <version>${project.version}</version>
1.6 </dependency>
1.7 + <dependency>
1.8 + <groupId>org.apidesign.bck2brwsr</groupId>
1.9 + <artifactId>vmtest</artifactId>
1.10 + <version>${project.version}</version>
1.11 + <scope>test</scope>
1.12 + <type>jar</type>
1.13 + </dependency>
1.14 + <dependency>
1.15 + <groupId>${project.groupId}</groupId>
1.16 + <artifactId>launcher.http</artifactId>
1.17 + <version>${project.version}</version>
1.18 + <scope>test</scope>
1.19 + </dependency>
1.20 </dependencies>
1.21 </project>
2.1 --- a/dew/src/main/java/org/apidesign/bck2brwsr/dew/Compile.java Sun Sep 22 21:56:49 2013 +0200
2.2 +++ b/dew/src/main/java/org/apidesign/bck2brwsr/dew/Compile.java Mon Sep 23 00:59:14 2013 +0200
2.3 @@ -29,8 +29,6 @@
2.4 import java.util.HashMap;
2.5 import java.util.List;
2.6 import java.util.Map;
2.7 -import java.util.regex.Matcher;
2.8 -import java.util.regex.Pattern;
2.9 import javax.tools.Diagnostic;
2.10 import javax.tools.DiagnosticListener;
2.11 import javax.tools.FileObject;
2.12 @@ -55,8 +53,8 @@
2.13 private final String html;
2.14
2.15 private Compile(String html, String code) throws IOException {
2.16 - this.pkg = findPkg(code);
2.17 - this.cls = findCls(code);
2.18 + this.pkg = find("package", ';', code);
2.19 + this.cls = find("class", ' ', code);
2.20 this.html = html;
2.21 classes = compile(html, code);
2.22 }
2.23 @@ -177,23 +175,20 @@
2.24 public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
2.25 errors.add(diagnostic);
2.26 }
2.27 - private static String findPkg(String java) throws IOException {
2.28 - Pattern p = Pattern.compile("package\\p{javaWhitespace}*([\\p{Alnum}\\.]+)\\p{javaWhitespace}*;", Pattern.MULTILINE);
2.29 - Matcher m = p.matcher(java);
2.30 - if (!m.find()) {
2.31 - throw new IOException("Can't find package declaration in the java file");
2.32 + private static String find(String pref, char term, String java) throws IOException {
2.33 + int pkg = java.indexOf(pref);
2.34 + if (pkg != -1) {
2.35 + pkg += pref.length();
2.36 + while (Character.isWhitespace(java.charAt(pkg))) {
2.37 + pkg++;
2.38 + }
2.39 + int semicolon = java.indexOf(term, pkg);
2.40 + if (semicolon != -1) {
2.41 + String pkgName = java.substring(pkg, semicolon).trim();
2.42 + return pkgName;
2.43 + }
2.44 }
2.45 - String pkg = m.group(1);
2.46 - return pkg;
2.47 - }
2.48 - private static String findCls(String java) throws IOException {
2.49 - Pattern p = Pattern.compile("class\\p{javaWhitespace}*([\\p{Alnum}\\.]+)\\p{javaWhitespace}", Pattern.MULTILINE);
2.50 - Matcher m = p.matcher(java);
2.51 - if (!m.find()) {
2.52 - throw new IOException("Can't find package declaration in the java file");
2.53 - }
2.54 - String cls = m.group(1);
2.55 - return cls;
2.56 + throw new IOException("Can't find " + pref + " declaration in the java file");
2.57 }
2.58
2.59 String getHtml() {
3.1 --- a/dew/src/test/java/org/apidesign/bck2brwsr/dew/CompileTest.java Sun Sep 22 21:56:49 2013 +0200
3.2 +++ b/dew/src/test/java/org/apidesign/bck2brwsr/dew/CompileTest.java Mon Sep 23 00:59:14 2013 +0200
3.3 @@ -18,15 +18,17 @@
3.4 package org.apidesign.bck2brwsr.dew;
3.5
3.6 import java.io.IOException;
3.7 +import org.apidesign.bck2brwsr.vmtest.Compare;
3.8 +import org.apidesign.bck2brwsr.vmtest.VMTest;
3.9 import static org.testng.Assert.*;
3.10 -import org.testng.annotations.Test;
3.11 +import org.testng.annotations.Factory;
3.12
3.13 /**
3.14 *
3.15 * @author Jaroslav Tulach <jtulach@netbeans.org>
3.16 */
3.17 public class CompileTest {
3.18 - @Test public void testCompile() throws IOException {
3.19 + @Compare public void testCompile() throws IOException {
3.20 String html = "<html><body>"
3.21 + " <button id='btn'>Hello!</button>"
3.22 + "</body></html>";
3.23 @@ -42,4 +44,8 @@
3.24 assertNotNull(result.get("x/y/z/X.class"), "Class X is compiled: " + result);
3.25 assertNotNull(result.get("x/y/z/Index.class"), "Class Index is compiled: " + result);
3.26 }
3.27 +
3.28 + @Factory public static Object[] create() {
3.29 + return VMTest.create(CompileTest.class);
3.30 + }
3.31 }
4.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Sun Sep 22 21:56:49 2013 +0200
4.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Mon Sep 23 00:59:14 2013 +0200
4.3 @@ -44,6 +44,7 @@
4.4 import java.util.concurrent.TimeUnit;
4.5 import java.util.logging.Level;
4.6 import java.util.logging.Logger;
4.7 +import javax.tools.ToolProvider;
4.8 import org.apidesign.bck2brwsr.launcher.InvocationContext.Resource;
4.9 import org.glassfish.grizzly.PortRange;
4.10 import org.glassfish.grizzly.http.server.HttpHandler;
4.11 @@ -81,6 +82,7 @@
4.12 public BaseHTTPLauncher(String cmd) {
4.13 this.cmd = cmd;
4.14 addClassLoader(BaseHTTPLauncher.class.getClassLoader());
4.15 + addClassLoader(ToolProvider.getSystemToolClassLoader());
4.16 setTimeout(180000);
4.17 }
4.18
5.1 --- a/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java Sun Sep 22 21:56:49 2013 +0200
5.2 +++ b/launcher/http/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java Mon Sep 23 00:59:14 2013 +0200
5.3 @@ -51,9 +51,13 @@
5.4 "(function WrapperVM(global) {"
5.5 + " function ldCls(res) {\n"
5.6 + " var request = new XMLHttpRequest();\n"
5.7 + + " console.log('Loading ' + res);\n"
5.8 + " request.open('GET', '/classes/' + res, false);\n"
5.9 + " request.send();\n"
5.10 - + " if (request.status !== 200) return null;\n"
5.11 + + " if (request.status !== 200) {\n"
5.12 + + " console.warn(' cannot load ' + res);\n"
5.13 + + " return null;\n"
5.14 + + " }\n"
5.15 + " var arr = eval('(' + request.responseText + ')');\n"
5.16 + " return arr;\n"
5.17 + " }\n"
6.1 --- a/pom.xml Sun Sep 22 21:56:49 2013 +0200
6.2 +++ b/pom.xml Mon Sep 23 00:59:14 2013 +0200
6.3 @@ -16,6 +16,7 @@
6.4 <netbeans.version>RELEASE73</netbeans.version>
6.5 <license>COPYING</license>
6.6 <net.java.html.version>0.6</net.java.html.version>
6.7 + <netbeans.compile.on.save>none</netbeans.compile.on.save>
6.8 </properties>
6.9 <modules>
6.10 <module>dew</module>