Commit 183a4cdd authored by Sarah Grebing's avatar Sarah Grebing

BUGFIX IndexOutOfRange+NullPointerExc

parent a96b1eac
Pipeline #12991 failed with stage
in 2 minutes and 35 seconds
......@@ -112,10 +112,14 @@ public class ScriptArea extends CodeArea {
textProperty().addListener((prop, oldValue, newValue) -> {
dirty.set(true);
updateMainScriptMarker();
updateHighlight();
highlightProblems();
highlightNonExecutionArea();
if (newValue.isEmpty()) {
System.err.println("text cleared");
} else {
updateMainScriptMarker();
updateHighlight();
highlightProblems();
highlightNonExecutionArea();
}
});
......@@ -192,13 +196,14 @@ public class ScriptArea extends CodeArea {
clearStyle(0, newValue.length());
StyleSpans<? extends Collection<String>> spans = highlighter.highlight(newValue);
if (spans != null) setStyleSpans(0, spans);
markedRegions.forEach(reg -> {
Collection<String> list = new HashSet<>();
list.add(reg.clazzName);
setStyle(reg.start, reg.stop, list);
});
}
markedRegions.forEach(reg -> {
Collection<String> list = new HashSet<>();
list.add(reg.clazzName);
setStyle(reg.start, reg.stop, list);
});
}
private void highlightProblems() {
......
......@@ -289,9 +289,10 @@ public class ScriptController {
private ScriptArea.RegionStyle asRegion(ASTNode node) {
assert node != null;
if (node.getRuleContext() != null)
return new ScriptArea.RegionStyle(node.getRuleContext().getStart().getStartIndex(),
node.getRuleContext().getStop().getStopIndex(), clazzName);
else return new ScriptArea.RegionStyle(0, 1, "");
}
}
}
......@@ -106,7 +106,7 @@ public class ProofTreeController {
//set value of newly computed node
nextComputedNode.setValue(nodeAddedEvent.getAddedNode());
//setNewState(this.statePointer.getState());
//Events.fire(new Events.NewNodeExecuted(nodeAddedEvent.getAddedNode().getScriptstmt()));
Events.fire(new Events.NewNodeExecuted(nodeAddedEvent.getAddedNode().getScriptstmt()));
}
};
......
......@@ -47,6 +47,13 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
return scripts;
}
@Override
public List<ProofScript> visitStart(ScriptLanguageParser.StartContext ctx) {
ctx.script().forEach(s ->
scripts.add((ProofScript) s.accept(this)));
return scripts;
}
@Override
public ProofScript visitScript(ScriptLanguageParser.ScriptContext ctx) {
ProofScript s = new ProofScript();
......@@ -58,13 +65,6 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
return s;
}
@Override
public List<ProofScript> visitStart(ScriptLanguageParser.StartContext ctx) {
ctx.script().forEach(s ->
scripts.add((ProofScript) s.accept(this)));
return scripts;
}
@Override
public Signature visitArgList(ScriptLanguageParser.ArgListContext ctx) {
Signature signature = new Signature();
......@@ -72,6 +72,7 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
signature.put(new Variable(decl.name),
TypeFacade.findType(decl.type.getText()));
}
signature.setRuleContext(ctx);
return signature;
}
......@@ -133,12 +134,9 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
return be;
}
private UnaryExpression createUnaryExpression(ParserRuleContext ctx, ScriptLanguageParser.ExpressionContext expression, Operator op) {
UnaryExpression ue = new UnaryExpression();
ue.setRuleContext(ctx);
ue.setExpression((Expression<ParserRuleContext>) expression.accept(this));
ue.setOperator(op);
return ue;
@Override
public Object visitExprNot(ScriptLanguageParser.ExprNotContext ctx) {
return createUnaryExpression(ctx, ctx.expression(), Operator.NOT);
}
@Override
......@@ -146,9 +144,12 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
return createUnaryExpression(ctx, ctx.expression(), Operator.NEGATE);
}
@Override
public Object visitExprNot(ScriptLanguageParser.ExprNotContext ctx) {
return createUnaryExpression(ctx, ctx.expression(), Operator.NOT);
private UnaryExpression createUnaryExpression(ParserRuleContext ctx, ScriptLanguageParser.ExpressionContext expression, Operator op) {
UnaryExpression ue = new UnaryExpression();
ue.setRuleContext(ctx);
ue.setExpression((Expression<ParserRuleContext>) expression.accept(this));
ue.setOperator(op);
return ue;
}
@Override
......@@ -214,15 +215,6 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
return ctx.literals().accept(this);
}
@Override
public Object visitExprDivision(ScriptLanguageParser.ExprDivisionContext ctx) {
return createBinaryExpression(ctx, ctx.expression(), Operator.DIVISION);
}
//TODO implement
@Override
public Object visitExprSubst(ScriptLanguageParser.ExprSubstContext ctx) {
SubstituteExpression se = new SubstituteExpression();
......@@ -232,6 +224,14 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
return se;
}
//TODO implement
@Override
public Object visitExprDivision(ScriptLanguageParser.ExprDivisionContext ctx) {
return createBinaryExpression(ctx, ctx.expression(), Operator.DIVISION);
}
@Override
public Map<String, Expression> visitSubstExpressionList(ScriptLanguageParser.SubstExpressionListContext ctx) {
Map<String, Expression> map = new LinkedHashMap<>();
......
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