From de0c393eaef212f1908dd5e1e7f807da58b09c24 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Wed, 21 Dec 2022 16:56:32 +0100 Subject: [PATCH] Fixes inconveniences #1028, #1076, #1077 --- .../structorizer/elements/DetectedError.java | 16 ++- src/lu/fisch/structorizer/gui/changelog.txt | 4 +- .../fisch/structorizer/parsers/D7Parser.java | 17 +-- src/lu/fisch/turtle/TurtleBox.java | 1 + src/lu/fisch/utils/BString.java | 117 ++++++++---------- src/lu/fisch/utils/StringList.java | 15 ++- 6 files changed, 87 insertions(+), 83 deletions(-) diff --git a/src/lu/fisch/structorizer/elements/DetectedError.java b/src/lu/fisch/structorizer/elements/DetectedError.java index 4044b667..4aab0539 100644 --- a/src/lu/fisch/structorizer/elements/DetectedError.java +++ b/src/lu/fisch/structorizer/elements/DetectedError.java @@ -37,6 +37,7 @@ * Kay Gürtzig 2016-07-27 Enh. #207: New general substitutions to support warnings introduced * Kay Gürtzig 2021-01-06/09 Enh. #905: New field to tell hints from errors/warnings, field * error renamed to message, new method getMessage() introduced + * Kay Gürtzig 2022-12-21 Deprecation annotation added to getError() * ****************************************************************************************************** * @@ -62,9 +63,10 @@ public class DetectedError /** * Creates a true error or warning entry with the given text {@code _error} * associated to Element {@code _ele} + * * @param _error - the error or warning message * @param _ele - the affected {@link Element} (or {@code null} for general - * warnings) + * warnings) */ public DetectedError(String _error, Element _ele) { @@ -76,11 +78,12 @@ public DetectedError(String _error, Element _ele) /** * Creates an entry for an error, a warning or a hint with the given text * {@code _error} associated to Element {@code _ele} + * * @param _error - the error or warning message * @param _ele - the affected {@link Element} (or {@code null} for general - * warnings) + * warnings) * @param _isWarning - whether the entry is a true warning (related to an error - * or mode, otherwise it would be treated as a mere tutorial hint) + * or mode, otherwise it would be treated as a mere tutorial hint) */ public DetectedError(String _error, Element _ele, boolean _isWarning) { @@ -95,6 +98,7 @@ public DetectedError(String _error, Element _ele, boolean _isWarning) /** * @deprecated Use {@link #getMessage()} instead */ + @Deprecated public String getError() { return getMessage(); @@ -108,6 +112,9 @@ public String getMessage() } // END KGU#906 2021-01-09 + /** + * @return the associated (causing) diagram {@link Element} + */ public Element getElement() { return element; @@ -116,7 +123,7 @@ public Element getElement() // START KGU#906 2021-01-06: Enh. #905 /** * @return {@code true} if this is a regular Analyser complaint, - * {@code false} in case of a tutorial hint + * {@code false} in case of a tutorial hint */ public boolean isWarning() { @@ -152,6 +159,7 @@ public String toString() // tester /** * Compares the messages of {@code this} and {@code _error}. + * * @param _error - another instance of this class * @return {@code true} iff both messages are equal */ diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index a064b508..0d0bdc4b 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -23,7 +23,7 @@ Known issues: - ARM export is still experimental and relies on a specific and very restricted syntax for the element contents in order to produce meaningful results. -Current development version 3.32-12 (2022-09-29) +Current development version 3.32-12 (2022-12-21) - 01: Bugfix #987: Duplicate subroutine comment export by Pascal generator <2> - 01: Bugfix #988: Syntax error in Structorizer.bat and Arranger.bat fixed <2> - 01: Bugfix #989: Expressions in EXIT elements (e.g. return) were forgotten @@ -132,6 +132,8 @@ Current development version 3.32-12 (2022-09-29) - 12: Bugfix #1072: The FOR loop editor now warns on entering step keyword in end value field <2> - 12: Bugfix #1073: CALL comments were exported twice to C, C++, Java etc. <2> +- 12: Issues #1028, #1076: Launcher message on Java trouble improved <2> +- 12: Issue #1077: Javadoc warnings avoided by annotation completion <2> Version 3.32 (2021-09-19) requiring Java 11 or newer - 01: Bugfix #851/2: SPECIAL-NAMES sections caused COBOL parser abort <2> diff --git a/src/lu/fisch/structorizer/parsers/D7Parser.java b/src/lu/fisch/structorizer/parsers/D7Parser.java index 2ae8c364..54d51fa5 100644 --- a/src/lu/fisch/structorizer/parsers/D7Parser.java +++ b/src/lu/fisch/structorizer/parsers/D7Parser.java @@ -32,9 +32,9 @@ * * Author Date Description * ------ ---- ----------- - * Bob Fisch 2008.01.06 First Issue - * Bob Fisch 2008.05.02 Added filter for (* ... *) comment filtering - * Kay Gürtzig 2015.10.20 New setting stepFor (KGU#3, to be made configurable!) + * Bob Fisch 2008-01-06 First Issue + * Bob Fisch 2008-05-02 Added filter for (* ... *) comment filtering + * Kay Gürtzig 2015-10-20 New setting stepFor (KGU#3, to be made configurable!) * Kay Gürtzig 2016-03-20 New settings preForIn and postForIn added (KGU#61, #84/#135) * Kay Gürtzig 2016-03-25 KGU#163: New static method getAllPropeties() added for Analyser * KGU#165: New option ignoreCase @@ -67,13 +67,14 @@ * Kay Gürtzig 2019-03-23 Enh. #56: Import of Try and Raise instructions implemented. * Kay Gürtzig 2019-11-19 Enh. #739: Genuine enumeration type import (revision of #558) * Kay Gürtzig 2020-03-08 Bugfix #833: Parameter parentheses ensured, superfluous Includable suppressed - * Kay Gürtzig 2020-03-09 Bugfix #835: Structure preference kywords must not be glued to expressions + * Kay Gürtzig 2020-03-09 Bugfix #835: Structure preference keywords must not be glued to expressions * Kay Gürtzig 2020-04-12 Bugfix #847 ensured that ids like 'false', 'true', and built-in functions be lowercase * Kay Gürtzig 2020-04-24 Bugfix #861/2 duplicate procedure comments prevented (was revealed by * by a modification of the block comment in PasGenerator. * Kay Gürtzig 2021-02-15/16 Unicode import enabled after eliminating a grammar ambiguity, comment - * processing no longer necessary, either, hence \n substitution also dropped + * processing no longer necessary, either, hence '\n' substitution also dropped * Kay Gürtzig 2021-10-03 Mechanism to ensure case-sensitive matching of result variables with function name + * Kay Gürtzig 2022-12-21 Deprecation annotation added to filterNonAscii() * ****************************************************************************************************** * @@ -909,11 +910,13 @@ private interface RuleConstants /** * Removes all non-Ascii characters from the given string {@code inString} + * * @param inString - the string to be filtered * @return - the filter result - * @deprecated No longer needed for Pascal import - if for others then it - * should go to {@link CodeParser} instead. + * @deprecated No longer needed for Pascal import - if it turns out to be for others + * then it should go to {@link CodeParser} instead. */ + @Deprecated public String filterNonAscii(String inString) { // Create the encoder and decoder for the character encoding diff --git a/src/lu/fisch/turtle/TurtleBox.java b/src/lu/fisch/turtle/TurtleBox.java index 73111141..448fbb9f 100644 --- a/src/lu/fisch/turtle/TurtleBox.java +++ b/src/lu/fisch/turtle/TurtleBox.java @@ -2519,6 +2519,7 @@ public void setPenColor(Integer red, Integer green, Integer blue) * in integral (!?) degrees * @deprecated */ + @Deprecated public double getAngleToHome() { // START #272 2016-10-16 (KGU) diff --git a/src/lu/fisch/utils/BString.java b/src/lu/fisch/utils/BString.java index b57cdcbf..d26f7b67 100644 --- a/src/lu/fisch/utils/BString.java +++ b/src/lu/fisch/utils/BString.java @@ -45,6 +45,7 @@ * Kay Gürtzig 2019-11-22 Dead code in encodeToHtml() disabled, bugfix in explode() * Kay Gürtzig 2020-04-21 Bugfix #852: method breakup completely rewritten, signature changed * Kay Gürtzig 2022-08-18 replaceInsensitive() rewritten, croissantStrict() hardened against empty strings + * Kay Gürtzig 2022-12-21 Deprecated method explodeWithDelimiter removed, deprecation annotations added * ****************************************************************************************************** * @@ -60,8 +61,10 @@ public abstract class BString /** * Encodes some characters to HTML-encoded symbols + * + * @param str - The string to encode * @return The encoded string - * @param str The string to encode + * * @see #encodeVectorToHtml(Vector) * @see #encodeToXML(String) */ @@ -93,9 +96,11 @@ public static String encodeToHtml(String str) // START KGU#363 2017-03-13: Enh. #372 - workaround for XML coding of potentially very long texts /** * Returns a string from text where all characters with special meaning in XML and all non- - * ASCII characters are converted into XML escapes. + * ASCII characters are converted into XML escapes. + * * @param text - the source string * @return the XML-escaped string + * * @see #decodeFromXML(String) * @see #encodeToHtml(String) */ @@ -125,9 +130,11 @@ public static String encodeToXML(String text) { * are converted back to the original characters with that code. * This method is less likely to be needed than {@link #encodeToXML(String)} (because usually an XML * framework will be usd to parse XML files. But well, for symmetry reasons, it's provided here.) - * @see #encodeToXML(String) + * * @param text - the XML-escaped string * @return the decoded original string + * + * @see #encodeToXML(String) */ public static String decodeFromXML(String text) { int state = 0; @@ -176,9 +183,10 @@ public static String decodeFromXML(String text) { /** * Replaces '.' and '_' throughout the string with spaces and then turns all characters - * behind spaces into upper-case ones + * behind spaces into upper-case ones. + * + *@param myS - The string to encode *@return The encoded string - *@param myS The string to encode */ public static String phrase(String myS) { @@ -201,8 +209,10 @@ public static String phrase(String myS) /** * Encodes an entire STRING-Vector to HTML-encoded STRING-Vector + * + * @param vec - The vector to encode * @return The encoded vector - * @param vec The vector to encode + * * @see #encodeToHtml(String) * @see #encodeToXML(String) */ @@ -229,34 +239,42 @@ public static String cutOut(String str) /** * Checks whether a string contains any non-blank characters. + * *@param str - The string to check *@return true iff there is at least one non-blank character - *@deprecated Use {@code !str.trim().isEmpty()} instead + *@deprecated Use {@code !str.isBlank()} or {@code !str.trim().isEmpty()} instead */ + @Deprecated public static boolean containsSomething(String str) { - boolean result = false; - - for (int i = 0; i < str.length(); i++) - { - if (!Character.isWhitespace(str.charAt(i))) - { - result = true; - break; - } - } - - return result; + // START KGU 2022-12-21: Content delegated + //boolean result = false; + // + //for (int i = 0; i < str.length(); i++) + //{ + // if (!Character.isWhitespace(str.charAt(i))) + // { + // result = true; + // break; + // } + //} + // + //return result; + return !str.isBlank(); + // END KGU 2022-12-21 } /** * Replaces all substrings with another substring - *@param str The original string - *@param substr The substring to be replaced - *@param with The substring to put in + * + *@param str - The original string + *@param substr - The substring to be replaced + *@param with - The substring to put in *@return The replaced string - *@deprecated Use {@link String#replace(CharSequence, CharSequence)} instead. + * + *@deprecated Use {@code str.replace(substr, with)} instead. */ + @Deprecated public static String replace(String str, String substr, String with) { String outi = new String(""); @@ -307,8 +325,9 @@ public static String replaceInsensitive(String str, String substr, String with) /** * Checks that the character codes of string {@code s} are strictly monotonous, - * i.e. i ≤ j --> s[i] ≤ s[j], but not all equal (if there are + * i.e. i ≤ j → s[i] ≤ s[j], but not all equal (if there are * at least two characters). + * * @param s - the string to be analysed * @return {@code true} iff the monotony described above holds */ @@ -324,21 +343,20 @@ public static boolean croissantStrict(String s) return false; } } - if (s.charAt(0) >= s.charAt(s.length()-1)) - { - return false; - } - return true; + return (s.charAt(0) < s.charAt(s.length()-1)); } /** * Checks whether {@code str} starts with {@code pre}. + * * @param pre - the prefix to be confirmed * @param str - the analysed string * @return true iff {@code str} starts with prefix {@code pre} + * * @see String#startsWith(String) * @deprecated Use {@code str.startsWith(pre)} instead. */ + @Deprecated public static boolean isPrefixOf(String pre, String str) { // boolean ret = false; @@ -358,11 +376,13 @@ public static boolean isPrefixOf(String pre, String str) * Splits the string {@code _source} around occurrences of delimiter string {@code _by} * and returns a {@link StringList} consisting of the split parts (without the separating * delimiters) in order of occurrence.
+ * * @param _source - the string to be split * @param _by - the separating string (not interpreted as regular expression!) * @return the split result + * * @see StringList#explode(String, String) - * @see String#explodeWithDelimiter(String, String) + * @see StringList#explodeWithDelimiter(String, String) */ public static StringList explode(String _source, String _by) { @@ -388,40 +408,6 @@ public static StringList explode(String _source, String _by) return sl; } - /** - * Splits the string {@code _source} around occurrences of delimiter string {@code _by} - * and returns a StringList consisting of the split parts and the separating - * delimiters in order of occurrence. - * @param _source - the string to be split - * @param _by - the separating string - * @return the split result - * @deprecated Use method {@link StringList#explodeWithDelimiter(String, String)} instead. - */ - public static StringList explodeWithDelimiter(String _source, String _by) - { - // START KGU 2017-06-18: Delegated to StringList.explode() where it belongs -// StringList sl = new StringList(); -// int lenBy = _by.length(); -// while(!_source.equals("")) -// { -// int pos = _source.indexOf(_by); -// if (pos >= 0) -// { -// sl.add(_source.substring(0, pos)); -// sl.add(_by); -// _source = _source.substring(pos + lenBy, _source.length()); -// } -// else -// { -// sl.add(_source); -// _source = ""; -// } -// } -// return sl; - return StringList.explodeWithDelimiter(_source, _by); - // END KGU 2017-06-18 - } - /** * Produces a regular expression allowing to match the given string in a case-insensitive way. * All letters 'x' are replaced by "[xX]", meta symbols like '[', ']', '^', '$' are escaped or @@ -432,7 +418,8 @@ public static StringList explodeWithDelimiter(String _source, String _by) * groups (this may be important if the pattern is to be used as part of a regex replacement * with several groups following, as it will compromise the group counting). The disadvantage * is that possible matches may be missed for letters the lowercase or uppercase representation - * of which would require more than one character as is the case with 'ß' (uppercase --> "SS"). + * of which would require more than one character as is the case with 'ß' (uppercase → "SS"). + * * @param _searched - the string (not supposed to be regular expression)! * @param _noGroups - if true then capturing groups are to be avoided by all means (see above). * @return a regular expression pattern as string diff --git a/src/lu/fisch/utils/StringList.java b/src/lu/fisch/utils/StringList.java index 7fe411ea..5f63034d 100644 --- a/src/lu/fisch/utils/StringList.java +++ b/src/lu/fisch/utils/StringList.java @@ -110,6 +110,7 @@ public StringList(String[] _strings) { * * @param _string - the single element * @return the created StringList + * * @see #StringList(String[]) * @see #explode(String, String) */ @@ -132,12 +133,13 @@ public static StringList getNew(String _string) { * * * - * @see #explodeFirstOnly(String, String) - * @see #explode(StringList, String) - * @see #explodeWithDelimiter(String, String, boolean) * @param _source - the string to be split * @param _by - the splitting regular expression * @return the StringLits containing all splitting shards + * + * @see #explodeFirstOnly(String, String) + * @see #explode(StringList, String) + * @see #explodeWithDelimiter(String, String, boolean) */ public static StringList explode(String _source, String _by) { String[] multi = _source.split(_by); @@ -198,13 +200,14 @@ public static StringList explodeFirstOnly(String _source, String _by) { * given REGULAR EXPRESSION(!) {@code _by} and returns a single StringList * containing all split results of all element strngs in sequential order. * Trailing empty strings are not included in the resulting StringList. + * + * @param _source - the StringList further to be split + * @param _by - the separator (delimiter) pattern (regex!) + * @return The split results as StringList * * @see #explode(String, String) * @see #explodeFirstOnly(String, String) * @see #explodeWithDelimiter(StringList, String, boolean) - * @param _source - the StringList further to be split - * @param _by - the separator (delimiter) pattern (regex!) - * @return The split results as StringList */ public static StringList explode(StringList _source, String _by) { StringList sl = new StringList();