src/java/de/uhilger/filecms/api/CompileService.java | ●●●●● patch | view | raw | blame | history | |
src/java/de/uhilger/filecms/data/CompilerIssue.java | ●●●●● patch | view | raw | blame | history | |
web/ui/index.html | ●●●●● patch | view | raw | blame | history | |
web/ui/ui.js | ●●●●● patch | view | raw | blame | history |
src/java/de/uhilger/filecms/api/CompileService.java
@@ -21,6 +21,7 @@ import static de.uhilger.filecms.api.FileMgr.HOME_DIR_PATH; import static de.uhilger.filecms.api.FileMgr.PUB_DIR_NAME; import static de.uhilger.filecms.api.FileMgr.PUB_DIR_PATH; import de.uhilger.filecms.data.CompilerIssue; import de.uhilger.filecms.data.FileRef; import de.uhilger.filecms.web.Initialiser; import de.uhilger.transit.web.RequestKontext; @@ -42,7 +43,6 @@ import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; import javax.tools.ToolProvider; import org.apache.commons.io.FileUtils; /** * @@ -54,7 +54,7 @@ private ServletContext ctx; private HttpServletRequest request; public String compile(String relPath, List fileNames) throws IOException { public List<CompilerIssue> compile(String relPath, List fileNames) throws IOException { //Files[] files1 = ... ; // input for first compilation task //Files[] files2 = ... ; // input for second compilation task @@ -79,13 +79,16 @@ Iterable<? extends JavaFileObject> compilationUnits1 = fileManager.getJavaFileObjectsFromFiles(files); /* final Iterable<String> options = Arrays.asList(new String[]{"-Xlint", /*"-cp", project.getClassPath(),*/ "-cp", project.getClassPath(), "-d", targetDir.getAbsolutePath() }); compiler.getTask(null, fileManager, diagnostics, options, null, compilationUnits1).call(); */ compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits1).call(); /* Iterable<? extends JavaFileObject> compilationUnits2 @@ -95,23 +98,25 @@ */ fileManager.close(); StringBuilder msg = new StringBuilder(); msg.append("Result of compile to Java bytecode (empty means no error):"); for (Diagnostic<? extends JavaFileObject> err : diagnostics.getDiagnostics()) { msg.append('\n'); msg.append(err.getKind()); msg.append(": "); if (err.getSource() != null) { msg.append(err.getSource().getName()); List compileResults = diagnostics.getDiagnostics(); List<CompilerIssue> compilerIssues = new ArrayList(); Iterator i = compileResults.iterator(); while(i.hasNext()) { Object o = i.next(); Diagnostic<? extends JavaFileObject> err; if(o instanceof Diagnostic) { err = (Diagnostic) o; CompilerIssue issue = new CompilerIssue(); issue.setKind(err.getKind().name()); issue.setLineNumber(err.getLineNumber()); issue.setMessage(err.getMessage(Locale.GERMANY)); issue.setSoureName(err.getSource().getName()); compilerIssues.add(issue); } msg.append(':'); msg.append(err.getLineNumber()); msg.append(": "); msg.append(err.getMessage(Locale.GERMANY)); } return msg.toString(); } return compilerIssues; } private File getTargetDir(String relPath) { logger.fine(relPath); String targetPath = null; src/java/de/uhilger/filecms/data/CompilerIssue.java
New file @@ -0,0 +1,63 @@ /* Dateiverwaltung - File management in your browser Copyright (C) 2017 Ulrich Hilger, http://uhilger.de This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ package de.uhilger.filecms.data; /** * */ public class CompilerIssue { private String soureName; private String message; private String kind; private long lineNumber; public String getSoureName() { return soureName; } public void setSoureName(String soureName) { this.soureName = soureName; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String getKind() { return kind; } public void setKind(String kind) { this.kind = kind; } public long getLineNumber() { return lineNumber; } public void setLineNumber(long lineNumber) { this.lineNumber = lineNumber; } } web/ui/index.html
@@ -218,6 +218,7 @@ <script src="/jslib/codemirror/addon/display/fullscreen.js"></script> <script src="/jslib/tinymce/tinymce.min.js"></script> <script src="/jslib/tether/tether.min.js"></script> <script src="/jslib/bootstrap/js/bootstrap.min.js"></script> <script src="/jslib/mustache/mustache.min.js"></script> <script src="ui.js"></script> web/ui/ui.js
@@ -31,6 +31,7 @@ var loc; var PERS_DIR = "Persoenlich"; var PUB_DIR = "Oeffentlich"; var compilerIssues; function fm_init() { $("#mce-editor").hide(); @@ -281,9 +282,24 @@ var liste = fm_gewaehlte_dateien(); var m = '?c=de.uhilger.filecms.api.CompileService&m=compile&p=' + pfad + '&p=' + encodeURIComponent(liste); var u = '../svc' + m; fm_get(u, "text", function(resp) { console.log('compile gab folgendes zurueck: '); console.log(resp); fm_get(u, "json", function(resp) { cm.clearGutter("breakpoints"); if(resp.List[0].CompilerIssue !== undefined) { 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); fm_set_code_marker(resp.List[0].CompilerIssue[issueNo].lineNumber, resp.List[0].CompilerIssue[issueNo].kind + ' ' + resp.List[0].CompilerIssue[issueNo].message); issueNo++; } } else { fm_set_code_marker(resp.List[0].CompilerIssue.lineNumber, resp.List[0].CompilerIssue.kind + ' ' + resp.List[0].CompilerIssue.message); } } }); } @@ -843,6 +859,7 @@ function fm_code_edit(content, m) { cm = CodeMirror.fromTextArea(document.getElementById("editspace"), { lineNumbers: true, gutters: ["CodeMirror-linenumbers", "breakpoints"], mode: m, viewportMargin : Infinity, tabSize: 2, @@ -859,6 +876,30 @@ //cm.setValue(content); cm.setValue(unescapeHtml(content)); cm.getDoc().markClean(); cm.on("gutterClick", function(theEditor, lineNumber) { var info = theEditor.lineInfo(lineNumber); //--lineNumber; //console.log(info.gutterMarkers.breakpoints.message); //var marker = info.gutterMarkers.breakpoints; //$(marker).tooltip('toggle'); }); } function fm_set_code_marker(lineNumber, message) { cm.setGutterMarker(lineNumber-1, "breakpoints", makeMarker(message)); } function makeMarker(msg) { var marker = document.createElement("div"); marker.style.color = "#822"; marker.innerHTML = "●"; //marker.message = msg; $(marker).tooltip({ placement: 'right', title: msg, offset: '10 -10' }); return marker; }