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

Fix parseo de warnings en el editor.

parent a19352b7
No related branches found
No related tags found
No related merge requests found
//export const SERVER = 'https://matefun.mybluemix.net';
//export const GHCI_URL = 'wss://matefun.mybluemix.net/endpoint';
export const SERVER = 'https://matefun.mybluemix.net';
export const GHCI_URL = 'wss://matefun.mybluemix.net/endpoint';
//export const SERVER = 'http://localhost:9090';
//export const GHCI_URL = 'ws://localhost:9090/endpoint';
//Configuracion dinamica pensando en servidor con ip dinamica
export const SERVER = window.location.protocol + '//' + window.location.host;//'http://localhost:9090';
export const GHCI_URL = window.location.protocol == 'http:'? 'ws://'+window.location.host+'/endpoint': 'wss://'+window.location.host+'/endpoint';
//export const SERVER = window.location.protocol + '//' + window.location.host;//'http://localhost:9090';
//export const GHCI_URL = window.location.protocol == 'http:'? 'ws://'+window.location.host+'/endpoint': 'wss://'+window.location.host+'/endpoint';
......@@ -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,
......@@ -162,17 +163,25 @@ export class GHCIService {
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");
......@@ -181,30 +190,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;
}
}
......@@ -222,18 +244,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');
......@@ -248,7 +272,7 @@ export class GHCIService {
this.startPrompt();
}
}
} else if (json_server_message.tipo=='error'){
if(this.modoAvanzado){
......
......@@ -105,9 +105,6 @@ export class HaskellService {
.catch(this.handleError);
}
/**
* Handle HTTP error
*/
private handleError (error: any) {
// In a real world app, we might use a remote logging infrastructure
// We'd also dig deeper into the error to get a better message
......
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