From fd0b4cf7236de6f05f3df2ed5bdd9508fd5fbb01 Mon Sep 17 00:00:00 2001
From: ulrich <undisclosed>
Date: Thu, 16 Mar 2017 18:35:44 +0000
Subject: [PATCH] Versuche mit dem Java-Compiler (in Arbeit)

---
 src/java/de/uhilger/filecms/api/CompileService.java |   27 +++++++++----
 web/ui/ui.js                                        |   57 ++++++++++++++++------------
 2 files changed, 52 insertions(+), 32 deletions(-)

diff --git a/src/java/de/uhilger/filecms/api/CompileService.java b/src/java/de/uhilger/filecms/api/CompileService.java
index d65fba2..21f3464 100644
--- a/src/java/de/uhilger/filecms/api/CompileService.java
+++ b/src/java/de/uhilger/filecms/api/CompileService.java
@@ -54,7 +54,15 @@
   private ServletContext ctx;
   private HttpServletRequest request;
   
-  public List<CompilerIssue> compile(String relPath, List fileNames) throws IOException {
+  /**
+   * 
+   * @param relPath
+   * @param fileNames
+   * @param mode 0 = test, 1 = build
+   * @return
+   * @throws IOException 
+   */
+  public List<CompilerIssue> compile(String relPath, List fileNames, String mode) throws IOException {
     //Files[] files1 = ... ; // input for first compilation task
     //Files[] files2 = ... ; // input for second compilation task
     
@@ -79,16 +87,19 @@
 
     Iterable<? extends JavaFileObject> compilationUnits1 = fileManager.getJavaFileObjectsFromFiles(files);
     
-    /*
-    final Iterable<String> options =
-            Arrays.asList(new String[]{"-Xlint",
-              "-cp", project.getClassPath(),
+    
+    
+    if( mode.equals("1")) {
+      final Iterable<String> options = Arrays.asList(new String[]{"-Xlint",
+              /*"-cp", project.getClassPath(),*/
               "-d", targetDir.getAbsolutePath()
               });
+      compiler.getTask(null, fileManager, diagnostics, options, null, compilationUnits1).call();
+    } else {
+      compiler.getTask(null, null, diagnostics, null, null, compilationUnits1).call();
+    }     
     
-    compiler.getTask(null, fileManager, diagnostics, options, null, compilationUnits1).call();
-    */
-    compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits1).call();
+    //compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits1).call();
 
     /*
     Iterable<? extends JavaFileObject> compilationUnits2
diff --git a/web/ui/ui.js b/web/ui/ui.js
index 3cceaaf..0fd2167 100644
--- a/web/ui/ui.js
+++ b/web/ui/ui.js
@@ -279,33 +279,42 @@
 }
 
 function fm_menu_test_2() {
+  fm_compile('0', fm_mark_compile_results_in_editor);
+}
+
+function fm_mark_compile_results_in_editor(resp) {
+  cm.clearGutter("breakpoints");
+
+  if(resp.List[0].CompilerIssue !== undefined) {
+    var lno;
+    var eMsg;
+    if(resp.List[0].CompilerIssue instanceof Array) {
+      var issueNo = 0;
+      while(issueNo < resp.List[0].CompilerIssue.length) {
+        // console.log(resp.List[0].CompilerIssue[issueNo].kind);
+        // console.log(resp.List[0].CompilerIssue[issueNo].lineNumber);
+        // console.log(resp.List[0].CompilerIssue[issueNo].sourceName);
+        // console.log(resp.List[0].CompilerIssue[issueNo].message);
+        lno = resp.List[0].CompilerIssue[issueNo].lineNumber;
+        eMsg = resp.List[0].CompilerIssue[issueNo].kind + ' ' + resp.List[0].CompilerIssue[issueNo].message;
+        cm.setGutterMarker(lno-1, "breakpoints", makeMarker(eMsg));
+        issueNo++;
+      }
+    } else {
+      lno = resp.List[0].CompilerIssue.lineNumber;
+      eMsg = resp.List[0].CompilerIssue.kind + ' ' + resp.List[0].CompilerIssue.message;
+      cm.setGutterMarker(lno-1, "breakpoints", makeMarker(eMsg));
+    }
+  }
+}
+
+function fm_compile(modeStr, callback) {
   var liste = fm_gewaehlte_dateien();
-  var m = '?c=de.uhilger.filecms.api.CompileService&m=compile&p=' + pfad + '&p=' + encodeURIComponent(liste);
+  var m = '?c=de.uhilger.filecms.api.CompileService&m=compile&p=' + pfad + '&p=' + encodeURIComponent(liste) + 
+          '&p=' + modeStr;
   var u = '../svc' + m;
   fm_get(u, "json", function(resp) {
-    cm.clearGutter("breakpoints");
-    
-    if(resp.List[0].CompilerIssue !== undefined) {
-      var lno;
-      var eMsg;
-      if(resp.List[0].CompilerIssue instanceof Array) {
-        var issueNo = 0;
-        while(issueNo < resp.List[0].CompilerIssue.length) {
-          // console.log(resp.List[0].CompilerIssue[issueNo].kind);
-          // console.log(resp.List[0].CompilerIssue[issueNo].lineNumber);
-          // console.log(resp.List[0].CompilerIssue[issueNo].sourceName);
-          // console.log(resp.List[0].CompilerIssue[issueNo].message);
-          lno = resp.List[0].CompilerIssue[issueNo].lineNumber;
-          eMsg = resp.List[0].CompilerIssue[issueNo].kind + ' ' + resp.List[0].CompilerIssue[issueNo].message;
-          cm.setGutterMarker(lno-1, "breakpoints", makeMarker(eMsg));
-          issueNo++;
-        }
-      } else {
-        lno = resp.List[0].CompilerIssue.lineNumber;
-        eMsg = resp.List[0].CompilerIssue.kind + ' ' + resp.List[0].CompilerIssue.message;
-        cm.setGutterMarker(lno-1, "breakpoints", makeMarker(eMsg));
-      }
-    }
+    callback(resp);
   });
 }
 

--
Gitblit v1.9.3