Show expected input in UI

This commit is contained in:
Arne Keller 2021-07-05 09:41:37 +02:00
parent f6d0777fd0
commit 93ec136970
3 changed files with 14 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import com.vaadin.flow.component.html.Pre;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.i18n.LocaleChangeEvent;
import com.vaadin.flow.i18n.LocaleChangeObserver;
import edu.kit.typicalc.model.parser.ExpectedInput;
import edu.kit.typicalc.model.parser.ParseError;
import edu.kit.typicalc.model.parser.Token;
import edu.kit.typicalc.view.main.InfoContent;
@ -82,6 +83,15 @@ public class ErrorView extends VerticalLayout implements LocaleChangeObserver {
throw new IllegalStateException(); // delete when updating to Java 12+
}
// state expected input, if available
Optional<ExpectedInput> expectedInput = error.getExpectedInput();
if (expectedInput.isPresent()) {
ExpectedInput e = expectedInput.get();
additionalInformation.add(new Span(new Pre(
getTranslation("error.expectedToken",
getTranslation("expectedinput." + e)))));
}
// add expected tokens, if available
Optional<Collection<Token.TokenType>> expected = error.getExpected();
if (expected.isPresent()) {

View File

@ -123,6 +123,7 @@ tokentype.DOT=.
tokentype.EQUALS==
tokentype.ARROW=->
tokentype.EOF=Ende der Eingabe
expectedinput.TERM=beliebiger Term
root.or=oder
root.slideExp=Typicalc ist eine Anwendung zur Visualisierung von Typinferenz. In der folgenden Slideshow wird ein \
Beispielszenario mit den wichtigsten Funktionen der Website vorgeführt. Das relevante Bedienelement ist jeweils mit \

View File

@ -116,6 +116,7 @@ tokentype.DOT=.
tokentype.EQUALS==
tokentype.ARROW=->
tokentype.EOF=End of input
expectedinput.TERM=any lambda term
root.or=or
root.slideExp=Typicalc is an application for the visualisation of type inference. The slideshow below the text \
demonstrates the most important features of the website. In each slide the relevant operating element is surrounded \