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 2019/04/25 04:47:41 UTC

[GitHub] [incubator-netbeans] vikasprabhakar commented on a change in pull request #1212: [NETBEANS-2448] Add jdk 10, 12 migrate configs under Inspect and Transform

vikasprabhakar commented on a change in pull request #1212: [NETBEANS-2448] Add jdk 10, 12 migrate configs under Inspect and Transform
URL: https://github.com/apache/incubator-netbeans/pull/1212#discussion_r278394832
 
 

 ##########
 File path: java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/refactoring/ConfigurationsManager.java
 ##########
 @@ -75,7 +79,32 @@ public int size() {
     private void init() {
         Preferences prefs = NbPreferences.forModule(this.getClass());
         try {
-            for (String kid:prefs.childrenNames()) {
+            String[] configList = prefs.childrenNames();
+            //fix sorting for JDK migrators
+            List<String> sl = Arrays.asList(configList);
+            final String exp = "([0-9]+)$"; //NOI18N
+
+            sl.sort(new Comparator<String>() {
+                @Override
+                public int compare(String s1, String s2) {
+                    Pattern pattern = Pattern.compile(exp);
+                    Matcher m1 = pattern.matcher(s1);
+                    if (m1.find()) {
+                        Matcher m2 = pattern.matcher(s2);
+                        if (m2.find()) {
+                            String part_s1 = s1.substring(0, m1.start());
+                            String part_s2 = s2.substring(0, m2.start());
+                            if (part_s1.equals(part_s2)) {
+                                int val1 = Integer.parseInt(m1.group());
+                                int val2 = Integer.parseInt(m2.group());
+                                return val1 - val2;
+                            }
+                        }
+                    }
+                    return s1.compareTo(s2);
+                }
+            });
+            for (String kid:sl.toArray(configList)) {
 
 Review comment:
   Formatting require in line 107

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
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