junichi11 commented on a change in pull request #2674:
URL: https://github.com/apache/netbeans/pull/2674#discussion_r556167592
##########
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:
for the following case:
```php
class Example {
public function __construct(
private string $x = "default",
$y,
) {}
}
```
In this case, I think that users don't prefer to be recreated the parameters
as one line. So, I've changed the behavior.
----------------------------------------------------------------
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