KacerCZ commented on a change in pull request #2674:
URL: https://github.com/apache/netbeans/pull/2674#discussion_r556818570
##########
File path:
php/php.editor/src/org/netbeans/modules/php/editor/verification/WrongOrderOfArgsHint.java
##########
@@ -150,12 +150,18 @@ public String getDescription() {
@Override
public void implement() throws Exception {
EditList edits = new EditList(doc);
- OffsetRange offsetRange = getOffsetRange();
- StringBuilder sb = new StringBuilder();
- for (ParameterElement param :
functionDeclarationInfo.getParameters()) {
-
sb.append(param.asString(OutputType.COMPLETE_DECLARATION)).append(", ");
//NOI18N
+ List<FormalParameter> originalParameters =
node.getFormalParameters();
+ List<ParameterElement> parameters =
functionDeclarationInfo.getParameters();
+ assert originalParameters.size() == parameters.size();
+ // maybe, in the case of constructor property promotion
+ // parameters can be declared with multiple lines
+ // so, replace the rearranged parameters with positions of
original parameters
+ // instead of replacing whole parameters as one line
+ for (int i = 0; i < originalParameters.size(); i++) {
+ FormalParameter originalParameter = originalParameters.get(i);
+ OffsetRange originalRange = new
OffsetRange(originalParameter.getStartOffset(),
originalParameter.getEndOffset());
+ edits.replace(originalRange.getStart(),
originalRange.getLength(),
parameters.get(i).asString(OutputType.COMPLETE_DECLARATION), false, 0);
Review comment:
Yes, this is more user friendly.
If user spends time splitting parameters on separate line then it is better
to keep the formatting after reordering parameters.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists