Commit 25f7a8e8 authored by Johannes Roith's avatar Johannes Roith

Improve overview.

parent 744a5d0e
......@@ -11,31 +11,42 @@ public class ControllerStatistics {
private long parserRunFailures; // TODO!
private long lastParserRunNanos;
private Date lastParserRunDate;
private boolean lastParserFailed;
private long lalrRuns;
private long lalrRunFailures; // TODO!
private long lastLALRRunNanos;
private Date lastLALRRunDate;
public long getParserRuns () { return parserRuns; }
public long getParserRunFailures () { return parserRunFailures; }
public long getLastParserRunNanos () { return lastParserRunNanos; }
public Date getLastParserRunDate () { return lastParserRunDate; }
public long getLalrRuns () { return lalrRuns; }
public long getLalrRunFailures () { return lalrRunFailures; }
public long getLastLALRRunNanos () { return lastLALRRunNanos; }
public Date getLastLALRRunDate () { return lastLALRRunDate; }
public void addParserRun(long nanos, Date dt) {
private boolean lastLALRFailed;
public long getParserRuns () { return parserRuns; }
public long getParserRunFailures () { return parserRunFailures; }
public long getLastParserRunNanos () { return lastParserRunNanos; }
public Date getLastParserRunDate () { return lastParserRunDate; }
public boolean getLastParserFailed () { return lastParserFailed; }
public long getLalrRuns () { return lalrRuns; }
public long getLalrRunFailures () { return lalrRunFailures; }
public long getLastLALRRunNanos () { return lastLALRRunNanos; }
public Date getLastLALRRunDate () { return lastLALRRunDate; }
public boolean getLastLALRFailed () { return lastLALRFailed; }
public void addParserRun(long nanos, Date dt, boolean failed) {
parserRuns++;
if (failed)
parserRunFailures++;
lastParserRunNanos = nanos;
lastParserRunDate = dt;
lastParserFailed = failed;
}
public void addTableRun(long nanos, Date dt) {
public void addTableRun(long nanos, Date dt, boolean failed) {
lalrRuns++;
if (failed)
lalrRunFailures++;
lastLALRRunNanos = nanos;
lastLALRRunDate = dt;
lastLALRFailed = failed;
}
@Override
......
......@@ -77,14 +77,18 @@ public class DocumentDidChangeJob extends Job {
if (setup.getResult() == Status.CANCEL_STATUS)
return Status.CANCEL_STATUS;
if (editor == null || editor.getDocument() == null)
if (editor == null || editor.getDocument() == null) {
System.err.println("DocumentDidChangeJob.run(): editor or document NULL.");
return Status.CANCEL_STATUS;
}
Date parserDate = null;
Date lalrDate = null;
long parseTimeNano = -1;
long tableTimeNano = -1;
boolean hasParserErrors = false;
boolean hasTableErrors = false;
IFile file = ((FileEditorInput) editor.getEditorInput()).getFile();
CupEditorErrorReporter errorReporter = new CupEditorErrorReporter(file);
errorReporter.resetOnNextPush();
......@@ -110,6 +114,9 @@ public class DocumentDidChangeJob extends Job {
errorReporter.pushToUIThread();
if (result != null) {
if (parser.hasParseErrors())
hasParserErrors = true;
jobStatusList.add(new JobStatus(JobsToDo.parseCode, false));
ParserResultJob resultModelJob = new ParserResultJob(editor,
result, context, revNumber);
......@@ -120,7 +127,9 @@ public class DocumentDidChangeJob extends Job {
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
hasParserErrors = true;
if (context != null) {
StatisticsIfFailedJob statisticsJob = new StatisticsIfFailedJob(
editor, context, revNumber);
......@@ -133,8 +142,6 @@ public class DocumentDidChangeJob extends Job {
if (jobs.contains(JobsToDo.buildTable)) {
boolean hasParserErrors = false;
lalrResult = null;
try {
if (parser != null && !parser.hasParseErrors()) {
......@@ -143,8 +150,6 @@ public class DocumentDidChangeJob extends Job {
lalrResult = LALRResult.Compute(context, context.start_production);
tableTimeNano = tmxb.getCurrentThreadCpuTime() - before;
}
else
hasParserErrors = true;
} catch (internal_error e) {
e.printStackTrace();
}
......@@ -161,7 +166,7 @@ public class DocumentDidChangeJob extends Job {
e.printStackTrace();
}
} else {
hasTableErrors = true;
// TODO: we run the statistics job twice, here, even if we failed
// to build the parser. This should only run once.
if (context != null) {
......@@ -186,10 +191,11 @@ public class DocumentDidChangeJob extends Job {
jobs.clear();
controllerStats = (ControllerStatistics) controllerStats.clone();
if (parseTimeNano != -1)
controllerStats.addParserRun(parseTimeNano, parserDate);
controllerStats.addParserRun(parseTimeNano, parserDate, hasParserErrors);
if (tableTimeNano != -1)
controllerStats.addTableRun(tableTimeNano, lalrDate);
controllerStats.addTableRun(tableTimeNano, lalrDate, hasTableErrors);
currentlyRunning = false;
CallbackJob cb = new CallbackJob(editor, jobStatusList, controllerStats);
......
......@@ -14,6 +14,7 @@ import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
......@@ -22,6 +23,7 @@ import org.eclipse.ui.forms.widgets.Section;
import de.in.tum.www2.cup.ErrorManager;
import de.in.tum.www2.cup.Statistics;
import de.in.tum.www2.cup.ast.ParserResult;
import de.tum.in.www2.cupplugin.Colors;
import de.tum.in.www2.cupplugin.Pair;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.controller.Controller;
......@@ -46,9 +48,16 @@ public class CupOverviewView extends FailableView
private Statistics stats;
private ControllerStatistics controllerStats;
class SimpleTable {
static class SimpleTable {
private final Color NORMAL_COLOR = new Color(Display.getCurrent(), Colors.darkGray);
private final Color FAILED_COLOR = new Color(Display.getCurrent(), Colors.red);
private final Color OK_COLOR = new Color(Display.getCurrent(), Colors.green);
public static final String FAILED = "FAILED";
public static final String OK = "OK";
private List<Label> labels;
private List<Label> values;
......@@ -70,6 +79,12 @@ public class CupOverviewView extends FailableView
public void setRowValue(int index, String val) {
values.get(index).setText(val);
if (val.equals(FAILED))
values.get(index).setForeground(FAILED_COLOR);
else if (val.equals(OK))
values.get(index).setForeground(OK_COLOR);
else
values.get(index).setForeground(NORMAL_COLOR);
}
public void setRowLabel(int index, String val) {
......@@ -87,31 +102,31 @@ public class CupOverviewView extends FailableView
}
}
private static final int ANALYSIS_ERROR_ROW = 0;
private static final int STATUS_PACKAGE = 0;
private static final int STATUS_CLASS = 1;
private static final int STATUS_TERMINALS = 2;
private static final int STATUS_NONTERMINALS = 3;
private static final int STATUS_PRODUCTIONS = 4;
private static final int STATUS_PRODUCTIONRIGHTS = 5;
private static final int STATUS_ERRORS = 6;
private static final int PLUGIN_STATS_PARSER_RUNS = 0;
private static final int PLUGIN_STATS_PARSER_RUN_FAILURES = 1;
private static final int PLUGIN_STATS_PARSER_RUN_NANOS = 2;
private static final int PLUGIN_STATS_PARSER_RUN_LAST = 3;
private static final int PLUGIN_STATS_LALR_RUNS = 4;
private static final int PLUGIN_STATS_LALR_RUN_FAILURES = 5;
private static final int PLUGIN_STATS_LALR_RUN_NANOS = 6;
private static final int PLUGIN_STATS_LALR_RUN_LAST = 7;
private static final int PLUGIN_STATS_PARSER_RUN_LAST_STATUS = 4;
private static final int PLUGIN_STATS_LALR_RUNS = 5;
private static final int PLUGIN_STATS_LALR_RUN_FAILURES = 6;
private static final int PLUGIN_STATS_LALR_RUN_NANOS = 7;
private static final int PLUGIN_STATS_LALR_RUN_LAST = 8;
private static final int PLUGIN_STATS_LALR_RUN_LAST_STATUS = 9;
private static final int OUTER_MARGIN = 10;
private static final int INNER_MARGIN = 10;
private static final String SECTION_PARSE_TABLES = "Parse Tables";
private static final String SECTION_PARSE_TABLES_DESCRIPTION_TEMPLATE = "last created, up2date, number of states, number of entries";
private static final String SECTION_CONTENT = "Content";
private static final String SECTION_CONTENT_DESCRIPTION_TEMPLATE = "start production, package, parser class, terminals, non-terminals";
private static final String SECTION_GRAMMAR = "Grammar";
private static final String SECTION_GRAMMAR_DESCRIPTION_TEMPLATE = "last checked, up2date, syntax correct";
private static final String SECTION_CONFLICTS = "Conflicts";
private static final String SECTION_CONFLICTS_DESCRIPTION_TEMPLATE = "Number of conflicts, etc.";
private Pair<Composite,SimpleTable> analysisSection;
private Pair<Composite,SimpleTable> pluginSection;
private Pair<Composite,SimpleTable> debuggerSection;
boolean visible = false;
......@@ -131,8 +146,32 @@ public class CupOverviewView extends FailableView
// Controller.getInstance(editor).registerObserver(this);
Model.getInstanceForDocument(doc).registerModelObserver(this);
analysisSection = createTableSection("Analysis", "", false, 3);
analysisSection.getSecond().setRowLabel(ANALYSIS_ERROR_ROW, "Errors:");
analysisSection = createTableSection("Status", "", false, 7);
analysisSection.getSecond().setRowLabel(STATUS_PACKAGE, "Package:"); // TODO: index!
analysisSection.getSecond().setRowLabel(STATUS_CLASS, "Parser class:"); // TODO: index!
analysisSection.getSecond().setRowLabel(STATUS_TERMINALS, "Terminals:");
analysisSection.getSecond().setRowLabel(STATUS_NONTERMINALS, "Non-Terminals:");
analysisSection.getSecond().setRowLabel(STATUS_PRODUCTIONS, "Productions Definitions:");
analysisSection.getSecond().setRowLabel(STATUS_PRODUCTIONRIGHTS, "Productions:");
analysisSection.getSecond().setRowLabel(STATUS_ERRORS, "Errors:");
createTableSection("Conflicts", "", false, 3);
debuggerSection = createTableSection("Debugger", "", false, 10);
/*
*
*
private static final String SECTION_PARSE_TABLES = "Parse Tables";
private static final String SECTION_PARSE_TABLES_DESCRIPTION_TEMPLATE = "number of states, number of entries";
"start production, package, parser class, terminals, non-terminals";
"Number of conflicts, etc.";
createSection(SECTION_PARSE_TABLES,
SECTION_PARSE_TABLES_DESCRIPTION_TEMPLATE, false);
......@@ -143,16 +182,20 @@ public class CupOverviewView extends FailableView
createSection(SECTION_CONFLICTS,
SECTION_CONFLICTS_DESCRIPTION_TEMPLATE, false);
pluginSection = createTableSection("Plugin Statistics", "", false, 8);
*/
pluginSection = createTableSection("Statistics", "", false, 10);
pluginSection.getSecond().setRowLabel(PLUGIN_STATS_PARSER_RUNS, "Parser runs:");
pluginSection.getSecond().setRowLabel(PLUGIN_STATS_PARSER_RUN_FAILURES, "Parser failures:");
pluginSection.getSecond().setRowLabel(PLUGIN_STATS_PARSER_RUN_NANOS, "Last parser time (ms):");
pluginSection.getSecond().setRowLabel(PLUGIN_STATS_PARSER_RUN_LAST, "Last parser run:");
pluginSection.getSecond().setRowLabel(PLUGIN_STATS_PARSER_RUN_LAST_STATUS, "Last parser status:");
pluginSection.getSecond().setRowLabel(PLUGIN_STATS_LALR_RUNS, "Table runs:");
pluginSection.getSecond().setRowLabel(PLUGIN_STATS_LALR_RUN_FAILURES, "Table failures:");
pluginSection.getSecond().setRowLabel(PLUGIN_STATS_LALR_RUN_NANOS, "Last table time (ms):");
pluginSection.getSecond().setRowLabel(PLUGIN_STATS_LALR_RUN_LAST, "Last table run:");
pluginSection.getSecond().setRowLabel(PLUGIN_STATS_LALR_RUN_LAST_STATUS, "Last table status:");
}
private Pair<Composite,SimpleTable> createTableSection(String title, String description, boolean doSpan, int rowCount) {
......@@ -169,9 +212,9 @@ public class CupOverviewView extends FailableView
for (int i=0; i < rowCount; i++) {
Label label = new Label(sectionComp, SWT.NONE);
label.setText("TODO");
label.setText("-");
Label val = new Label(sectionComp, SWT.NONE);
val.setText("TODO");
val.setText("-");
tbl.addRow(label, val);
}
......@@ -252,7 +295,7 @@ public class CupOverviewView extends FailableView
private void updateStatistics() {
if (this.stats != null) {
SimpleTable tbl = analysisSection.getSecond();
tbl.setRowValue(ANALYSIS_ERROR_ROW, stats.getErrorCount());
tbl.setRowValue(STATUS_ERRORS, stats.getErrorCount());
this.stats = null;
analysisSection.getFirst().layout();
......@@ -268,6 +311,9 @@ public class CupOverviewView extends FailableView
tbl.setRowValue(PLUGIN_STATS_PARSER_RUN_LAST, parserDate);
else
tbl.setRowValue(PLUGIN_STATS_PARSER_RUN_LAST, "-");
tbl.setRowValue(PLUGIN_STATS_PARSER_RUN_LAST_STATUS,
controllerStats.getLastParserFailed() ? SimpleTable.FAILED : SimpleTable.OK);
tbl.setRowValue(PLUGIN_STATS_LALR_RUNS, controllerStats.getLalrRuns());
tbl.setRowValue(PLUGIN_STATS_LALR_RUN_FAILURES, controllerStats.getLalrRunFailures());
......@@ -278,6 +324,9 @@ public class CupOverviewView extends FailableView
else
tbl.setRowValue(PLUGIN_STATS_LALR_RUN_LAST, "-");
tbl.setRowValue(PLUGIN_STATS_LALR_RUN_LAST_STATUS,
controllerStats.getLastLALRFailed() ? SimpleTable.FAILED : SimpleTable.OK);
pluginSection.getFirst().layout();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment