Warning and error parsing can now look backwards at previous lines for information. Button of selected view in the results grid is now left pressed.

This commit is contained in:
Scott Duensing 2023-05-24 18:02:34 -05:00
parent 75a9d5aa98
commit 0d50e3bc83
2 changed files with 72 additions and 45 deletions

View file

@ -60,6 +60,7 @@ void compilerDeleteContext(CompilerContextT **context) {
static void compilerErrorHandler(void *opaque, const char *msg) {
(void)opaque;
//***TODO*** Use the error list from results.c
message(strstr(msg, " warning: ") == NULL ? MSG_ERROR : MSG_WARN, "%s", msg);
}
@ -67,6 +68,7 @@ static void compilerErrorHandler(void *opaque, const char *msg) {
gboolean compilerHadError(CompilerContextT **context) {
CompilerContextT *c = *context;
//***TODO*** Use the error list from results.c
if (c->compilerResult != COMPILER_ERROR_NONE) {
// Handle errors not handled elsewhere.
switch (c->compilerResult) {

View file

@ -33,6 +33,7 @@ typedef struct ResultsDataS {
WindowDataT windowData;
ProjectDataT *project;
GtkWidget *gridResults;
GtkWidget *pressedButton;
GtkWidget *notebookResults;
GtkWidget *lstDebug;
GtkWidget *lstRelease;
@ -46,19 +47,23 @@ static ResultsDataT **_resultWindows = NULL;
EVENT void resultClicked(GtkButton *widget, gpointer userData);
static void resultLoadRaw(gboolean release, int target, int arch, ResultsDataT *self);
static void resultParseRaw(gboolean release, char *line, ResultsDataT *self);
static void resultParseRaw(gboolean release, char **lineArray, ResultsDataT *self);
static void resultsUpdate(ResultsDataT *self);
EVENT gboolean winBuildResultsClose(GtkWidget *object, gpointer userData);
static void winBuildResultsDelete(gpointer userData);
EVENT void resultClicked(GtkButton *widget, gpointer userData) {
ResultsDataT *self = (ResultsDataT *)userData;
const char *name = gtk_widget_get_name(GTK_WIDGET(widget));
int t;
int a;
gboolean r;
// ***TODO*** Highlight the button somehow so we know what we're viewing.
// Highlight the button pressed button.
gtk_button_set_relief(widget, GTK_RELIEF_NONE);
gtk_button_set_relief(GTK_BUTTON(self->pressedButton), GTK_RELIEF_NORMAL);
self->pressedButton = GTK_WIDGET(widget);
// Extract button info from widget name.
r = (name[0] == 'r');
@ -72,9 +77,10 @@ EVENT void resultClicked(GtkButton *widget, gpointer userData) {
static void resultLoadRaw(gboolean release, int target, int arch, ResultsDataT *self) {
FILE *in;
char *temp;
TargetT *t;
char *line = NULL;
size_t len = 0;
TargetT *t;
char **lineArray = NULL;
// Clear existing contents.
utilClearContainer(GTK_CONTAINER(release ? self->lstRelease : self->lstDebug));
@ -90,7 +96,7 @@ static void resultLoadRaw(gboolean release, int target, int arch, ResultsDataT *
while (utilGetLine(&line, &len, in) != -1) {
if (strlen(line) > 0) line[strlen(line) - 1] = 0;
utilAddTextToListBox(GTK_LIST_BOX(release ? self->lstRawRelease : self->lstRawDebug), line, FALSE);
resultParseRaw(release, line, self);
arrput(lineArray, strdup(line)); // We put everything into an array so we can "rewind" later to previous lines.
}
}
fclose(in);
@ -98,31 +104,46 @@ static void resultLoadRaw(gboolean release, int target, int arch, ResultsDataT *
}
DEL(temp);
// Parse it for warnings and errors.
resultParseRaw(release, lineArray, self);
// Clear array.
while (arrlen(lineArray) > 0) {
DEL(lineArray[0]);
arrdel(lineArray, 0);
}
//ARRFREE(lineArray);
// Display appropriate tab.
gtk_notebook_set_current_page(GTK_NOTEBOOK(self->notebookResults), release ? 1 : 0);
}
static void resultParseRaw(gboolean release, char *line, ResultsDataT *self) {
static void resultParseRaw(gboolean release, char **lineArray, ResultsDataT *self) {
GtkWidget *messages;
GtkWidget *row;
GtkWidget *box;
GtkWidget *label;
GtkWidget *button;
int i;
char *temp;
char *text = NULL;
gboolean isWarning = FALSE;
char *text;
gboolean isWarning;
messages = release ? self->lstRelease : self->lstDebug;
for (i=0; i<arrlen(lineArray); i++) {
text = NULL;
isWarning = FALSE;
// ***TODO*** This is going to need to be a lot more complicated.
// We need the line number and filename from multiple compilers.
if (strstr(line, " warning: ") != NULL) {
text = line;
if (strstr(lineArray[i], " warning: ") != NULL) {
text = lineArray[i];
isWarning = TRUE;
}
if (strstr(line, " error: ") != NULL) {
text = line;
if (strstr(lineArray[i], " error: ") != NULL) {
text = lineArray[i];
}
if (text) {
@ -148,6 +169,7 @@ static void resultParseRaw(gboolean release, char *line, ResultsDataT *self) {
gtk_list_box_insert(GTK_LIST_BOX(messages), row, -1);
gtk_widget_show_all(GTK_WIDGET(messages));
}
}
}
@ -176,10 +198,6 @@ static void resultsUpdate(ResultsDataT *self) {
for (j=0; j<arrlen(t->archs); j++) {
if (t->archs[j]->selected) {
if (firstSystem < 0) {
firstSystem = i;
}
// Add to grid. Name.
w = gtk_label_new(t->longName);
gtk_label_set_line_wrap(GTK_LABEL(w), FALSE);
@ -233,6 +251,13 @@ static void resultsUpdate(ResultsDataT *self) {
gtk_grid_attach(GTK_GRID(self->gridResults), w, 3, gridLine, 1, 1);
g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(resultClicked), self);
if (firstSystem < 0) {
firstSystem = i;
// Highlight the button pressed button.
gtk_button_set_relief(GTK_BUTTON(w), GTK_RELIEF_NONE);
self->pressedButton = w;
}
// Next result!
gridLine++;
}
@ -240,7 +265,7 @@ static void resultsUpdate(ResultsDataT *self) {
}
// Did we load anything?
if (gridLine > 0) {
if (firstSystem >= 0) {
resultLoadRaw(FALSE, firstSystem, 0, self);
resultLoadRaw(TRUE, firstSystem, 0, self);
}