From 3477bff512bb59dd0e386fbddc4ffaff8d736d8e Mon Sep 17 00:00:00 2001 From: uogau Date: Tue, 29 Jun 2021 12:07:19 +0200 Subject: [PATCH 1/2] Fixed off by one error for english error message --- .../view/content/errorcontent/ErrorView.java | 13 +++++++------ .../resources/language/translation_de.properties | 2 +- .../resources/language/translation_en.properties | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/kit/typicalc/view/content/errorcontent/ErrorView.java b/src/main/java/edu/kit/typicalc/view/content/errorcontent/ErrorView.java index 10cc13f..e11eb99 100644 --- a/src/main/java/edu/kit/typicalc/view/content/errorcontent/ErrorView.java +++ b/src/main/java/edu/kit/typicalc/view/content/errorcontent/ErrorView.java @@ -61,19 +61,20 @@ public class ErrorView extends VerticalLayout implements LocaleChangeObserver { case UNEXPECTED_TOKEN: Optional cause = error.getCause(); if (cause.isPresent()) { - additionalInformation.add(new Span(new Pre(getTranslation("root.term") + term))); + additionalInformation.add(new Span(new Pre(getTranslation("root.termForError") + term))); additionalInformation.add( - new Span(new Pre(" ".repeat(Math.max(getTranslation("root.term").length(), - cause.get().getPos() + "root.term".length())) + new Span(new Pre(" ".repeat(Math.max(getTranslation("root.termForError").length(), + cause.get().getPos() + getTranslation("root.termForError").length())) + "^ " + getTranslation("root.wrongCharacter") + cause.get().getText()))); } break; case UNEXPECTED_CHARACTER: char c = error.getWrongCharacter(); if (c != '\0') { - additionalInformation.add(new Span(new Pre(getTranslation("root.term") + term))); - additionalInformation.add(new Span(new Pre(" ".repeat(Math.max(getTranslation("root.term").length(), - error.getPosition() + "root.term".length())) + additionalInformation.add(new Span(new Pre(getTranslation("root.termForError") + term))); + additionalInformation.add(new Span( + new Pre(" ".repeat(Math.max(getTranslation("root.termForError").length(), + error.getPosition() + getTranslation("root.termForError").length())) + "^ " + getTranslation("root.wrongCharacter") + c))); } else { return summary; diff --git a/src/main/resources/language/translation_de.properties b/src/main/resources/language/translation_de.properties index 16f8e8c..ba8f1b8 100644 --- a/src/main/resources/language/translation_de.properties +++ b/src/main/resources/language/translation_de.properties @@ -106,7 +106,7 @@ root.tooFewTokensHelp=Überprüfe, ob alle Let-, Abs- und App-Terme über die n root.UNEXPECTED_TOKEN=Die Eingabe entspricht nicht der im Info-Dialog spezifizierten Syntax! root.UNEXPECTED_CHARACTER=Die Eingabe enthält ein Zeichen, welches an dieser Stelle nicht erlaubt ist! error.heading=Syntaktisch falsche Eingabe! -root.term=Eingabe:\u0020 +root.termForError=Eingabe:\u0020 root.wrongCharacter=Falsches Zeichen:\u0020 error.expectedToken=Erwartet: {0} error.hint=Die Grammatiken, die die korrekte Syntax eines Terms und der Typannahmen beschreiben, \ diff --git a/src/main/resources/language/translation_en.properties b/src/main/resources/language/translation_en.properties index 34e853a..2d7eb03 100644 --- a/src/main/resources/language/translation_en.properties +++ b/src/main/resources/language/translation_en.properties @@ -100,7 +100,7 @@ root.UNEXPECTED_TOKEN=The input does not match the syntax specified in the info root.UNEXPECTED_CHARACTER=The input contains a character which is not allowed at this position. error.heading=Input is syntactically wrong! root.wrongCharacter=Wrong character:\u0020 -root.term=Input:\u0020 +root.termForError=Input:\u0020 error.expectedToken=Expected: {0} error.hint=The grammars describing the correct syntax of a term or a type assumption can also be reached \ via the info icon. From fea2b7035aecffdacd15d7dc438f5520d88d30ca Mon Sep 17 00:00:00 2001 From: uogau Date: Tue, 29 Jun 2021 12:25:35 +0200 Subject: [PATCH 2/2] Removed unnecessary information in error changed spacing in error message "Term" instead of "Input" --- .../view/content/errorcontent/ErrorView.java | 14 ++++++-------- .../resources/language/translation_de.properties | 2 +- .../resources/language/translation_en.properties | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/java/edu/kit/typicalc/view/content/errorcontent/ErrorView.java b/src/main/java/edu/kit/typicalc/view/content/errorcontent/ErrorView.java index e11eb99..7ca9f89 100644 --- a/src/main/java/edu/kit/typicalc/view/content/errorcontent/ErrorView.java +++ b/src/main/java/edu/kit/typicalc/view/content/errorcontent/ErrorView.java @@ -61,19 +61,17 @@ public class ErrorView extends VerticalLayout implements LocaleChangeObserver { case UNEXPECTED_TOKEN: Optional cause = error.getCause(); if (cause.isPresent()) { - additionalInformation.add(new Span(new Pre(getTranslation("root.termForError") + term))); - additionalInformation.add( - new Span(new Pre(" ".repeat(Math.max(getTranslation("root.termForError").length(), - cause.get().getPos() + getTranslation("root.termForError").length())) + additionalInformation.add(new Span(new Pre(getTranslation("root.termForError") + term + + "\n" + " ".repeat(Math.max(getTranslation("root.termForError").length(), + cause.get().getPos() + getTranslation("root.termForError").length())) + "^ " + getTranslation("root.wrongCharacter") + cause.get().getText()))); } break; case UNEXPECTED_CHARACTER: char c = error.getWrongCharacter(); if (c != '\0') { - additionalInformation.add(new Span(new Pre(getTranslation("root.termForError") + term))); - additionalInformation.add(new Span( - new Pre(" ".repeat(Math.max(getTranslation("root.termForError").length(), + additionalInformation.add(new Span(new Pre(getTranslation("root.termForError") + term + + "\n" + " ".repeat(Math.max(getTranslation("root.termForError").length(), error.getPosition() + getTranslation("root.termForError").length())) + "^ " + getTranslation("root.wrongCharacter") + c))); } else { @@ -107,7 +105,7 @@ public class ErrorView extends VerticalLayout implements LocaleChangeObserver { getTranslation("error.expectedToken", correct)))); } - return new Div(summary, additionalInformation); + return new Div(additionalInformation); } @Override diff --git a/src/main/resources/language/translation_de.properties b/src/main/resources/language/translation_de.properties index ba8f1b8..6ff5e52 100644 --- a/src/main/resources/language/translation_de.properties +++ b/src/main/resources/language/translation_de.properties @@ -106,7 +106,7 @@ root.tooFewTokensHelp=Überprüfe, ob alle Let-, Abs- und App-Terme über die n root.UNEXPECTED_TOKEN=Die Eingabe entspricht nicht der im Info-Dialog spezifizierten Syntax! root.UNEXPECTED_CHARACTER=Die Eingabe enthält ein Zeichen, welches an dieser Stelle nicht erlaubt ist! error.heading=Syntaktisch falsche Eingabe! -root.termForError=Eingabe:\u0020 +root.termForError=Term:\u0020 root.wrongCharacter=Falsches Zeichen:\u0020 error.expectedToken=Erwartet: {0} error.hint=Die Grammatiken, die die korrekte Syntax eines Terms und der Typannahmen beschreiben, \ diff --git a/src/main/resources/language/translation_en.properties b/src/main/resources/language/translation_en.properties index 2d7eb03..5a57287 100644 --- a/src/main/resources/language/translation_en.properties +++ b/src/main/resources/language/translation_en.properties @@ -100,7 +100,7 @@ root.UNEXPECTED_TOKEN=The input does not match the syntax specified in the info root.UNEXPECTED_CHARACTER=The input contains a character which is not allowed at this position. error.heading=Input is syntactically wrong! root.wrongCharacter=Wrong character:\u0020 -root.termForError=Input:\u0020 +root.termForError=Term:\u0020 error.expectedToken=Expected: {0} error.hint=The grammars describing the correct syntax of a term or a type assumption can also be reached \ via the info icon.