Skip to content
Snippets Groups Projects
Commit 8a840bfa authored by Martín's avatar Martín
Browse files

Fix en el parseo de errores en el frontend. Ahora en el repo correcto.

parent 7873d02a
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ export class GHCIService {
private error :string ="";
private warnings: any = [];
private codemirrorRef :any = null;
private warningStepReaded :number = 0;
private waitingForError : boolean = false;
private waitingForWarning : boolean = false;
private waitingForWarning2 : boolean = false;
......@@ -52,6 +52,7 @@ export class GHCIService {
}
loadFile(fileId, dependencias) {
this.waitingForWarning = true;
var message = {
'token': this.authService.getToken(),
'load': fileId,
......@@ -129,7 +130,7 @@ export class GHCIService {
setTimeout(this.checkConsole.bind(this),100);
}
}
hayError(text){
hayError(text){
var line = -1;
if(this.waitingForError){
var line = this.lastError;
......@@ -163,24 +164,30 @@ export class GHCIService {
}
}
resetGutters(){
if(this.codemirrorRef!==null){
this.codemirrorRef.clearGutter("breakpoints");
}
}
hayWarnings(text){
hayWarnings(text){
var line = -1;
if(this.waitingForWarning){
if(this.waitingForWarning2){
//se completa el mensaje de warning
this.warningText = this.warningText.trim() + "\n" + JSON.parse(text).resultado.split("OUT")[1].trim();
this.waitingForWarning = false;
this.waitingForWarning2 = false;
var m = JSON.parse(text);
if(this.warningStepReaded===1){
try{
var warningText2 = m.resultado.split("OUT")[1].trim();
this.warningStepReaded = 2;
this.warningText = this.warningText + '\n\n' + warningText2;
var line = this.lastWarning;
this.lastWarning = -1;
var title = this.warningText;
var columna = title.split("columna:")[1].split("}")[0];
var warningTextToShow = title.split("}")[1];
var warningFinalText = "En columna " + columna + ": " + warningTextToShow;
if(this.codemirrorRef!==null){
var makeMarker = function() {
var marker = document.createElement("div");
......@@ -189,30 +196,43 @@ export class GHCIService {
marker.style.marginLeft = "-5px";
marker.style.cursor = "pointer";
marker.innerHTML = "<a href='@' title='cuidado , advertencia matefun'></a>";
marker.title = title;
marker.title = warningFinalText;
marker.style["background-image"] = "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=')";
marker.innerHTML = "";
return marker;
}
this.codemirrorRef.setGutterMarker(line, "breakpoints", makeMarker());
}
}else {
this.waitingForWarning2 = true;
this.warningText = JSON.parse(text).resultado.split("OUT")[1];
}catch(err){
}
}else {
}
if(this.warningStepReaded===0){
try{
line = Number(JSON.parse(text).resultado.split("OUTAdvertencia:")[1].trim().split("línea:")[1].split(" ")[1])-1;
this.waitingForWarning = true;
this.waitingForWarning2 = false;
var line = m.resultado.split("OUTAdvertencia:")[1].trim().split("línea:")[1].split(" ")[1]-1;
this.lastWarning = line;
this.warnings.push(line);
var warningText = m.resultado.split("OUTAdvertencia:")[1].trim();
this.warningStepReaded = 1;
this.warningText = warningText;
debugger;
if(this.waitingForWarning){
this.outputConsole('El programa contiene advertencias\n');
this.waitingForWarning = false;
}
}catch(err){
line = -1
} catch(err){
}
this.warnings.push(line);
return line!==-1;
}
}
......@@ -230,18 +250,20 @@ export class GHCIService {
} else {
this.error = "";
}
if(this.hayWarnings(server_message)){
//parseo los warnings.
//los cargo en la variable de warnings.
this.hayWarnings(server_message);
if(this.warningStepReaded==2){
this.warningStepReaded = 0;
return;
} else if(this.warningStepReaded==1){
return;
}
var json_server_message = JSON.parse(server_message);
if(json_server_message.tipo=='salida'){
if(json_server_message.resultado.includes("<svg")){
var svg = json_server_message.resultado;
$("#svgHaskell").html(svg);
} else {
var line = json_server_message.resultado.trim();
if(line.startsWith("OUT")){
this.outputConsole(line.substring(3) + '\n');
......@@ -256,7 +278,7 @@ export class GHCIService {
this.startPrompt();
}
}
} else if (json_server_message.tipo=='error'){
if(this.modoAvanzado){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment