matthiasblaesing commented on code in PR #6620:
URL: https://github.com/apache/netbeans/pull/6620#discussion_r1372149784


##########
enterprise/micronaut/src/org/netbeans/modules/micronaut/completion/MicronautDataCompletionCollector.java:
##########
@@ -53,6 +53,7 @@ public Completion createSQLItem(CompletionItem item) {
                 return 
CompletionCollector.newBuilder(item.getInsertPrefix().toString())
                         
.insertText(item.getInsertPrefix().toString().replace("\"", "\\\""))
                         .kind(Completion.Kind.Property)
+                        .sortText(String.format("%04d%s", 
item.getSortPriority(), item.getSortText()))

Review Comment:
   This is really ugly. The moment someone decides to report a priority of 
10000 this will become a mess to debug. Given that this can't be easily changes 
as it seems to be baked into the protocol, I suggest to encode it like this:
   
   ```suggestion
                           .sortText(String.format("%010d%s",
                                   Long.valueOf(item.getSortPriority()) + 
Math.abs(Long.valueOf(Integer.MIN_VALUE)),
                                   item.getSortText())
                           )
   ```
   
   The shift of  `Math.abs(Long.valueOf(Integer.MIN_VALUE))` ensures we get 
only positive values and using 10 digits allows to encode all possible values 



-- 
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: [email protected]

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

Reply via email to