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

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