You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2021/11/21 12:02:02 UTC
[GitHub] [netbeans] mklaehn commented on a change in pull request #3241: [NETBEANS-6081] - Cleaning enterprise module part 4/8
mklaehn commented on a change in pull request #3241:
URL: https://github.com/apache/netbeans/pull/3241#discussion_r753789466
##########
File path: enterprise/web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFClientGenerator.java
##########
@@ -1016,45 +1014,43 @@ public void run(CompilationController compilationController) throws IOException
getIdBody = new StringBuffer();
int params = paramSetters.size();
if(params > 0){
- getIdBody.append(idPropertyType[0] + " id = new " + idPropertyType[0] + "();\n");
+ getIdBody.append(idPropertyType[0]).append(" id = new ").append(idPropertyType[0]).append("();\n");
}
else {
- getIdBody.append(idPropertyType[0] + " id;\n");//do not initialize, user need to update code and may be use not default constructor
+ getIdBody.append(idPropertyType[0]).append(" id;\n");//do not initialize, user need to update code and may be use not default constructor
}
- getIdBody.append("String params[] = new String[" + params + "];\n" +
- "int p = 0;\n" +
- "int grabStart = 0;\n" +
- "String delim = \"#\";\n" +
- "String escape = \"~\";\n" +
- "Pattern pattern = Pattern.compile(escape + \"*\" + delim);\n" +
- "Matcher matcher = pattern.matcher(string);\n" +
- "while (matcher.find()) {\n" +
- "String found = matcher.group();\n" +
- "if (found.length() % 2 == 1) {\n" +
- "params[p] = string.substring(grabStart, matcher.start());\n" +
- "p++;\n" +
- "grabStart = matcher.end();\n" +
- "}\n" +
- "}\n" +
- "if (p != params.length - 1) {\n" +
- "throw new IllegalArgumentException(\"string \" + string + \" is not in expected format. expected " + params + " ids delimited by \" + delim);\n" +
- "}\n" +
- "params[p] = string.substring(grabStart);\n" +
- "for (int i = 0; i < params.length; i++) {\n" +
- "params[i] = params[i].replace(escape + delim, delim);\n" +
- "params[i] = params[i].replace(escape + escape, escape);\n" +
- "}\n\n"
- );
+ getIdBody.append("String params[] = new String[").append(params).append("];\n")
+ .append("int p = 0;\n")
+ .append("int grabStart = 0;\n")
+ .append("String delim = \"#\";\n")
+ .append("String escape = \"~\";\n")
+ .append("Pattern pattern = Pattern.compile(escape + \"*\" + delim);\n")
+ .append("Matcher matcher = pattern.matcher(string);\n")
+ .append("while (matcher.find()) {\n")
+ .append("String found = matcher.group();\n")
+ .append("if (found.length() % 2 == 1) {\n")
+ .append("params[p] = string.substring(grabStart, matcher.start());\n")
+ .append("p++;\n")
+ .append("grabStart = matcher.end();\n")
+ .append("}\n")
+ .append("}\n")
+ .append("if (p != params.length - 1) {\n")
+ .append("throw new IllegalArgumentException(\"string \" + string + \" is not in expected format. expected ").append(params).append(" ids delimited by \" + delim);\n")
+ .append("}\n")
+ .append("params[p] = string.substring(grabStart);\n")
+ .append("for (int i = 0; i < params.length; i++) {\n")
+ .append("params[i] = params[i].replace(escape + delim, delim);\n")
+ .append("params[i] = params[i].replace(escape + escape, escape);\n")
+ .append("}\n\n");
Review comment:
True.
My initial concern was for the readabiility of the automatic cleanup. Future features for the moment are that, future features. Until then my preference is that I'd rather read a multiline version of code/pseudo code like this instead of a single line string hundreds of characters long.
Had we had textblocks available I'd have preferred that even over the current state of the change, but we don't.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists