Skip to content

Commit

Permalink
Fixes inconveniences #1028, #1076, #1077
Browse files Browse the repository at this point in the history
  • Loading branch information
codemanyak committed Dec 21, 2022
1 parent 6b8a299 commit de0c393
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 83 deletions.
16 changes: 12 additions & 4 deletions src/lu/fisch/structorizer/elements/DetectedError.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
*
******************************************************************************************************
*
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -95,6 +98,7 @@ public DetectedError(String _error, Element _ele, boolean _isWarning)
/**
* @deprecated Use {@link #getMessage()} instead
*/
@Deprecated
public String getError()
{
return getMessage();
Expand All @@ -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;
Expand All @@ -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()
{
Expand Down Expand Up @@ -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
*/
Expand Down
4 changes: 3 additions & 1 deletion src/lu/fisch/structorizer/gui/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>
Expand Down
17 changes: 10 additions & 7 deletions src/lu/fisch/structorizer/parsers/D7Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
*
******************************************************************************************************
*
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/lu/fisch/turtle/TurtleBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
117 changes: 52 additions & 65 deletions src/lu/fisch/utils/BString.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
******************************************************************************************************
*
Expand All @@ -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)
*/
Expand Down Expand Up @@ -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)
*/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
*/
Expand All @@ -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("");
Expand Down Expand Up @@ -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 &le; j --&gt; s[i] &le; s[j], but not all equal (if there are
* i.e. i &le; j &rarr; s[i] &le; 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
*/
Expand All @@ -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;
Expand All @@ -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.<br/>
*
* @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)
{
Expand All @@ -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
Expand All @@ -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 &rarr; "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
Expand Down
Loading

0 comments on commit de0c393

Please sign in to comment.