Dateiverwaltung für die WebBox
ulrich
2017-03-16 fd0b4cf7236de6f05f3df2ed5bdd9508fd5fbb01
Versuche mit dem Java-Compiler (in Arbeit)
2 files modified
84 ■■■■■ changed files
src/java/de/uhilger/filecms/api/CompileService.java 27 ●●●● patch | view | raw | blame | history
web/ui/ui.js 57 ●●●●● patch | view | raw | blame | history
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
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);
  });
}