Skip to content

Commit

Permalink
Fixes #1131 (still with wrong Portuguese translations
Browse files Browse the repository at this point in the history
  • Loading branch information
codemanyak committed Mar 9, 2024
1 parent 6d51db2 commit 3a21b5a
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 15 deletions.
5 changes: 3 additions & 2 deletions 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 (also see https://github.com/fesch/Structorizer.Desktop/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-17 (2024-03-08)
Current development version 3.32-17 (2024-03-09)
- 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 @@ -196,9 +196,10 @@ Current development version 3.32-17 (2024-03-08)
- 16: Completion and corrections of the Portuguese/Brazilian locale <T. Cruz>
- 17: Menu mnemonics for the PT_BR locale rectified <T. Cruz>
- 17: Bugfix #1128 Risk of getting stuck on record component retrieval (in
Analyser or Input assist) eliminated [K.-P. Reimer]<2>
Analyser or Input assist) eliminated [K.-P. Reimers]<2>
- 17: Issue #1129 Analyser popup didn't open with too many error entries <2>
- 17: Bugfix #1130 C import expanded macros within char literals [csrabak]2
- 17: Issue #1131 Handling of anonymous inner classes on Java import <2>
- 17: Bugfix #1132 Java import defect on backslashes in string literals <2>

Version 3.32 (2021-09-19) requiring Java 11 or newer
Expand Down
2 changes: 2 additions & 0 deletions src/lu/fisch/structorizer/gui/parsers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
</plugin>
<plugin title="Java-SE8" class="lu.fisch.structorizer.parsers.JavaParser" icon="">
<option name="convert_syntax" type="Boolean" title="Convert declarations etc. to Pascal/Structorizer style" help="This setting slightly raises the chance of executability and re-export in Structorizer" default="true" />
<option name="dissect_anon_inner_class" type="Boolean" title="Dissect anonymous inner classes into diagrams" help="Otherwise on-the-fly-defined subclasses will be passed as very long source code expressions to the instantiation element." default="true" />
</plugin>
<plugin title="Processing" class="lu.fisch.structorizer.parsers.ProcessingParser" icon="">
<option name="convert_syntax" type="Boolean" title="Convert declarations etc. to Pascal/Structorizer style" help="This setting slightly raises the chance of executability and re-export in Structorizer" default="true" />
<option name="dissect_anon_inner_class" type="Boolean" title="Dissect anonymous inner classes into diagrams" help="Otherwise on-the-fly-defined subclasses will be passed as very long source code expressions to the instantiation element." default="true" />
</plugin>

</plugins>
3 changes: 3 additions & 0 deletions src/lu/fisch/structorizer/locales/de.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
* Kay Gürtzig 2023-10-13 Issues #980,#1096: New messages for declaration syntax check (error31_*)
* Kay Gürtzig 2023-11-13 Enh. #1115: New messages for C99 import option definesToConstants
* Kay Gürtzig 2024-03-04 Mnemonic changed on Find&Replace, PluginOptionDialog message added
* Kay Gürtzig 2024-03-09 Issue #1117: Messages for new PuginOptionDialog option dissect_anon_inner_class
*
******************************************************************************************************
*
Expand Down Expand Up @@ -1207,6 +1208,8 @@ PluginOptionDialog.btnOk.text=OK
PluginOptionDialog.btnCancel.text=Abbrechen
PluginOptionDialog.optionComponents.convert_syntax.text=Deklarationen/Ausdrücke usw. in Pascal-ähnlichen Stil wandeln
PluginOptionDialog.optionComponents.convert_syntax.tooltip=Diese Einstellung vergrößert die Chancen der Ausführbarkeit oder des Re-Exports in Structorizer
PluginOptionDialog.optionComponents.dissect_anon_inner_class.text=Anonyme innere Klassen in Diagramme zerlegen
PluginOptionDialog.optionComponents.dissect_anon_inner_class.tooltip=Anderenfalls würde die en passant definierte innere Klasse einfach als sehr langer Quellcode-Ausdruck in das instanziierende Element durchgereicht.
PluginOptionDialog.optionComponents.debugLines.text[getPluginKey():COBOLParser]=Debug-Zeilen als aktiven Code importieren
PluginOptionDialog.optionComponents.debugLines.tooltip[getPluginKey():COBOLParser]=Falls aktiviert, werden Debug-Zeilen ggf. als gültiger Code importiert, anderenfalls in Kommentarzeilen "DEBUG ..." umgewandelt.
PluginOptionDialog.optionComponents.decimalComma.text[getPluginKey():COBOLParser]=Dezimalkomma (statt Dezimalpunkt) im Quelltext
Expand Down
5 changes: 4 additions & 1 deletion src/lu/fisch/structorizer/locales/en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@
* Kay Gürtzig 2022-09-29 Bugfix #1072: New message InputBoxFor.msgIllegalWordInField added
* Kay Gürtzig 2023-08-01 Enh. #1082: Function name now included in messages Menu.error13_*
* Kay Gürtzig 2023-10-06 Issue #311: Menu reorganisation (menuDiagram split)
* Kay Gürtzig 2023-10-16 Issue #980/#1096: New messages for declaration syntax check (error31_*)
* Kay Gürtzig 2023-10-16 Issue #980/#1096: New messages for declaration syntax check (error31_*)
* Kay Gürtzig 2024-03-09 Issue #1117: Messages for new PuginOptionDialog option dissect_anon_inner_class
*
******************************************************************************************************
*
Expand Down Expand Up @@ -1202,6 +1203,8 @@ PluginOptionDialog.btnOk.text=OK
PluginOptionDialog.btnCancel.text=Cancel
PluginOptionDialog.optionComponents.convert_syntax.text=
PluginOptionDialog.optionComponents.convert_syntax.tooltip=
PluginOptionDialog.optionComponents.dissect_anon_inner_class.text=
PluginOptionDialog.optionComponents.dissect_anon_inner_class.tooltip=
PluginOptionDialog.optionComponents.debugLines.text[getPluginKey():COBOLParser]=
PluginOptionDialog.optionComponents.debugLines.tooltip[getPluginKey():COBOLParser]=
PluginOptionDialog.optionComponents.decimalComma.text[getPluginKey():COBOLParser]=
Expand Down
5 changes: 4 additions & 1 deletion src/lu/fisch/structorizer/locales/es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@
* Kay Gürtzig 2023-10-13 Issue #980: New messages for declaration syntax check (error31_*)
* Kay Gürtzig 2023-11-13 Enh. #1115: New messages for C99 import option definesToConstants
* Kay Gürtzig 2024-01-26 Issue #311/bugfix #1126: Menu reorganisation (menuDiagram split)
* Kay Gürtzig 2024-03-04 Menmonics for Find&Replace dialog specified.
* Kay Gürtzig 2024-03-04 Mnemonics for Find&Replace dialog specified.
* Kay Gürtzig 2024-03-09 Issue #1117: Messages for new PuginOptionDialog option dissect_anon_inner_class
*
******************************************************************************************************
*
Expand Down Expand Up @@ -1209,6 +1210,8 @@ PluginOptionDialog.btnOk.text=Aceptar
PluginOptionDialog.btnCancel.text=Cancelar
PluginOptionDialog.optionComponents.convert_syntax.text=Convertir declaraciones/expresiones a un estilo como Pascal
PluginOptionDialog.optionComponents.convert_syntax.tooltip=Esta opción aumenta la probabilidad de poder ejecutar o re-exportar el resultado en Structorizer
PluginOptionDialog.optionComponents.dissect_anon_inner_class.text=Desglosar clases anónimas interiores a diagramas
PluginOptionDialog.optionComponents.dissect_anon_inner_class.tooltip=De otro modo, una clase anónima definida en pasada simplemente sería puesto como una larga expresión de código fuente al elemento que contiene su instanciación.
PluginOptionDialog.optionComponents.debugLines.text[getPluginKey():COBOLParser]=Importar líneas debug como código válido
PluginOptionDialog.optionComponents.debugLines.tooltip[getPluginKey():COBOLParser]=Si es activada, líneas debug serán importadas como código válido, de otro modo serían convertidas en comentarios "DEBUG ...".
PluginOptionDialog.optionComponents.decimalComma.text[getPluginKey():COBOLParser]=Coma decimal (en lugar de punto decimal) en el código
Expand Down
8 changes: 5 additions & 3 deletions src/lu/fisch/structorizer/locales/pt_br.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,8 @@ PluginOptionDialog.btnOk.text=OK
PluginOptionDialog.btnCancel.text=Cancelar
PluginOptionDialog.optionComponents.convert_syntax.text=Converter declarações/expreções a um estilo como Pascal
PluginOptionDialog.optionComponents.convert_syntax.tooltip=Esta opção aumenta la probabilidade de poder executar ou re-exportar o resultado em Structorizer.
PluginOptionDialog.optionComponents.dissect_anon_inner_class.text=Desmembrar clases anônimas interiores em diagramas
PluginOptionDialog.optionComponents.dissect_anon_inner_class.tooltip=Caso contrário, uma clase anônima definida de passagem simplesmente seja pousado como longa expressão de código-fonte em o elemento que contém sua instânciasão.
PluginOptionDialog.optionComponents.debugLines.text[getPluginKey():COBOLParser]=
PluginOptionDialog.optionComponents.debugLines.tooltip[getPluginKey():COBOLParser]=
PluginOptionDialog.optionComponents.decimalComma.text[getPluginKey():COBOLParser]=
Expand Down Expand Up @@ -1272,11 +1274,11 @@ FindAndReplace.txtComm.border=Comentário
FindAndReplace.chkElementwise.text=Elemento por elemento
FindAndReplace.chkElementwise.mnemonic=e
FindAndReplace.btnFind.text=Procurar
FindAndReplace.btnFind.mnemonic=r
FindAndReplace.btnFind.mnemonic=a
FindAndReplace.btnReplace.text=Substituir
FindAndReplace.btnReplace.mnemonic=s
FindAndReplace.btnReplace.mnemonic=u
FindAndReplace.btnReplaceFind.text=Substituir/Procurar
FindAndReplace.btnReplaceFind.mnemonic=u
FindAndReplace.btnReplaceFind.mnemonic=r
FindAndReplace.btnReplaceAll.text=Substituir tudo
FindAndReplace.btnReplaceAll.mnemonic=d
FindAndReplace.btnReplaceAll.tooltip=Substituir todas as ocorrências restantes do padrão de pesquisa na direção especificada a partir da posição atual.
Expand Down
111 changes: 103 additions & 8 deletions src/lu/fisch/structorizer/parsers/JavaParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
* KGU#961: Array initialiser conversion in declarations improved
* Kay Gürtzig 2023-11-08 Bugfix #1110 method translateContent() returned the argument instead of the result
* Kay Gürtzig 2024-03-08 KGU#1117: Missing backward replacement of c_l_a_s_s in one case mended.
* Kay Gürtzig 2024-03-09 Issue #1131: Handling of anonymous inner class instantiations
*
******************************************************************************************************
*
Expand Down Expand Up @@ -836,8 +837,8 @@ private interface RuleConstants
// final int PROD_PRIMARYNONEWARRAY6 = 355; // <PrimaryNoNewArray> ::= <ProcessingTypeConversion>
final int PROD_CLASSINSTANCECREATIONEXPRESSION_NEW_LPAREN_RPAREN = 356; // <ClassInstanceCreationExpression> ::= new <ClassType> '(' <ArgumentList> ')'
final int PROD_CLASSINSTANCECREATIONEXPRESSION_NEW_LPAREN_RPAREN2 = 357; // <ClassInstanceCreationExpression> ::= new <ClassType> '(' ')'
// final int PROD_CLASSINSTANCECREATIONEXPRESSION_NEW_LPAREN_RPAREN3 = 358; // <ClassInstanceCreationExpression> ::= new <ClassType> '(' <ArgumentList> ')' <ClassBody>
// final int PROD_CLASSINSTANCECREATIONEXPRESSION_NEW_LPAREN_RPAREN4 = 359; // <ClassInstanceCreationExpression> ::= new <ClassType> '(' ')' <ClassBody>
final int PROD_CLASSINSTANCECREATIONEXPRESSION_NEW_LPAREN_RPAREN3 = 358; // <ClassInstanceCreationExpression> ::= new <ClassType> '(' <ArgumentList> ')' <ClassBody>
final int PROD_CLASSINSTANCECREATIONEXPRESSION_NEW_LPAREN_RPAREN4 = 359; // <ClassInstanceCreationExpression> ::= new <ClassType> '(' ')' <ClassBody>
// final int PROD_ARGUMENTLIST = 360; // <ArgumentList> ::= <Expression>
final int PROD_ARGUMENTLIST_COMMA = 361; // <ArgumentList> ::= <ArgumentList> ',' <Expression>
final int PROD_ARRAYCREATIONEXPRESSION_NEW = 362; // <ArrayCreationExpression> ::= new <PrimitiveType> <DimExprs> <Dims>
Expand Down Expand Up @@ -1161,7 +1162,12 @@ protected void doExtraPreparations(StringBuilder _srcCode, File _file) throws Pa
/** Represents the class definitions in the hierarchical class context */
private Stack<Root> includables = null;

/** Holds the value of the Java-specific import option "convert_syntax" */
private boolean optionConvertSyntax = false;
// START KGU#1117 2024-03-09: Issue #1131 Handle anonymous inne class instantiations properly
/** Holds the value of the Java-specific import option "dissect_anon_inner_class" */
private boolean optionDissectInnerClass = true;
// END KGU#1117 2024-03-09

/** Maps the labels of labelled statements to the respective first element of the statement */
private HashMap<String, Element> labels = new HashMap<String, Element>();
Expand Down Expand Up @@ -1207,6 +1213,9 @@ protected void initializeBuildNSD() throws ParserCancelled
root.children.addElement(new Forever());

optionConvertSyntax = (Boolean)this.getPluginOption("convert_syntax", false);
// START KGU#1117 2024-03-09: Issue #1131 Allow to construct diagrams from anonymous classes
optionDissectInnerClass = (Boolean)this.getPluginOption("dissect_anon_inner_class", true);
// END KGU#1117 2024-03-09

// START KGU#407 2018-03-26: Enh. #420: Configure the lookup table for comment retrieval
this.registerStatementRuleIds(statementIds);
Expand Down Expand Up @@ -2318,15 +2327,20 @@ else if (exprs.count() == 1) {
* the expression such that embedded implicit or explicit assignments are extracted
* to an own preceding line, combined assignment operator expressions are also
* decomposed, e.g. {@code <var> += <expr>} to {@code <var> <- <var> + <expr>}.
*
* @param exprToken - the {@link Token} representing the top-level expression.
* @param isStatement - whether the expression represents a statement
* @param leftHandSide - indicates whether the expression represents an assignment
* target expression.
* @param redExpr - the top-level expression {@link Reduction}.
* target expression.
* @param optInstNameSubst - optionally a name substitution pair (in case of an
* anonymous inner class instantiation
*
* @return a {@code StringList} each elements of which contain an expression, all
* but the very last one are necessarily expression statements.
* but the very last one are necessarily expression statements.
* @throws ParserCancelled
*/
protected StringList decomposeExpression(Token exprToken, boolean isStatement, boolean leftHandSide) throws ParserCancelled {
protected StringList decomposeExpression(Token exprToken, boolean isStatement, boolean leftHandSide)
throws ParserCancelled {
// We expect redExpr to represent one of the following
// <Assignment>
// <PreIncrementExpression>
Expand All @@ -2342,7 +2356,8 @@ protected StringList decomposeExpression(Token exprToken, boolean isStatement, b
StringList exprs = new StringList();
if (exprToken.getType() == SymbolType.NON_TERMINAL) {
Reduction exprRed = exprToken.asReduction();
switch (exprRed.getParent().getTableIndex()) {
int ruleIx = exprRed.getParent().getTableIndex();
switch (ruleIx) {
case RuleConstants.PROD_ASSIGNMENT:
{
// <Assignment> ::= <LeftHandSide> <AssignmentOperator> <AssignmentExpression>
Expand Down Expand Up @@ -2737,7 +2752,28 @@ else if (!optionConvertSyntax) {
exprs.set(ixLast, cast + exprs.get(ixLast));
}
break;

// START KGU#1117 2024-03-09: Issue #1131: Handle anonymous inner classes
// ATTENTION: THIS CASE MUST REMAIN AT LAST POSITION BEFORE DEFAULT!
case RuleConstants.PROD_CLASSINSTANCECREATIONEXPRESSION_NEW_LPAREN_RPAREN3:
case RuleConstants.PROD_CLASSINSTANCECREATIONEXPRESSION_NEW_LPAREN_RPAREN4:
// <ClassInstanceCreationExpression> ::= new <ClassType> '(' <ArgumentList> ')' <ClassBody>
// <ClassInstanceCreationExpression> ::= new <ClassType> '(' ')' <ClassBody>
if (this.optionDissectInnerClass) {
String className = this.deriveAnonInnerClass(exprRed);
StringList result = new StringList();
result.add("new");
result.add(className);
if (ruleIx == RuleConstants.PROD_CLASSINSTANCECREATIONEXPRESSION_NEW_LPAREN_RPAREN3) {
Token argListToken = exprRed.get(3);
processArguments(argListToken, result, exprs);
}
else {
exprs.add(result.concatenate(null) + "()");
}
break;
}
// No break; here (or an else branch with the content of default would have to be added)!
// END KGU#1117 2024-03-09
default:
// START KGU#1117 2024-03-08: Some expressions slipped through without replacement
//exprs.add(this.getContent_R(exprToken));
Expand All @@ -2752,10 +2788,69 @@ else if (!optionConvertSyntax) {
return exprs;
}

// START KGU#1117 2024-03-09: Issue #1131 Handle anonymous inner classes
/**
* Creates the diagrams defining an anonymous inner class and its methods and
* returns a name mapping from the instantiated super class to the made-up
* generic class name of the anonymous class.
*
* @param instCreaRed - the instance creation expression {@link Reduction}
* @return the made-up name for the instantiated anonymous inner class.
* @throws ParserCancelled
*/
private String deriveAnonInnerClass(Reduction instCreaRed) throws ParserCancelled {
// <ClassInstanceCreationExpression> ::= new <ClassType> '(' <ArgumentList> ')' <ClassBody>
// <ClassInstanceCreationExpression> ::= new <ClassType> '(' ')' <ClassBody>
// FIXME Try to delegate as much as possible to a submethod shared with ClassDeclaration section
String className0 = getContent_R(instCreaRed.get(1).asReduction(), "");
String qualifier = packageStr;
Root classRoot = root;
if (!this.includables.isEmpty()) {
// (Should always be the case here)
qualifier = this.includables.peek().getQualifiedName();
classRoot = new Root();
classRoot.setInclude();
classRoot.addToIncludeList(includables.peek());
// Add temporary dummy loops in order to gather fields and method signatures
classRoot.children.addElement(new Forever());
classRoot.children.addElement(new Forever());
this.addRoot(classRoot);
}
includables.push(classRoot);
classRoot.setNamespace(qualifier);
String className = className0 + "_" + Integer.toHexString(classRoot.hashCode());
classRoot.setText(className);
// FIXME: Is this necessary here?
if (this.includables.size() == 1 && packageStr != null) {
classRoot.comment.add("==== package: " + packageStr);
if (!imports.isEmpty()) {
imports.insert("==== imports:", 0);
classRoot.comment.add(imports);
}
}
classRoot.comment.insert("CLASS"
+ (this.includables.size() > 1 ? " in class " + qualifier : ""), 0);
classRoot.getComment().add(("Anonymous inner class").trim());
classRoot.comment.add("==== " + className0);

// Now descend into the body
int ixBody = 4;
if (instCreaRed.getParent().getTableIndex() == RuleConstants.PROD_CLASSINSTANCECREATIONEXPRESSION_NEW_LPAREN_RPAREN3) {
ixBody++;
}
this.buildNSD_R(instCreaRed.get(ixBody).asReduction(), classRoot.children);
// Dissolve the field and method containers
dissolveDummyContainers(classRoot);
this.includables.pop();
return className;
}
// END KGU#1117 2024-03-09

// START KGU#957 2021-03-05: Issue #959 - Processing conversion function handling
/**
* Processes a conversion function of the "Processing" language. The JavaParser base
* code won't do anything here.
*
* @param exprRed - a {@code <ProcessingTypeConversion>} reduction
* @return a StringList containing the necessary sequence of Structorizer instructions
* and expressions to achieve the same effect.
Expand Down

0 comments on commit 3a21b5a

Please sign in to comment.