This is an automated email from the ASF dual-hosted git repository. arusinha pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push: new 4f85b23 [NETBEANS-2448] Add jdk 10, 12 migrate configs under Inspect and Transform (#1212) 4f85b23 is described below commit 4f85b238cf70f0f6828e59de735b1b027ff8b03e Author: Reema Taneja <32299405+rtane...@users.noreply.github.com> AuthorDate: Thu May 2 15:10:10 2019 +0530 [NETBEANS-2448] Add jdk 10, 12 migrate configs under Inspect and Transform (#1212) * add jdk-12 migrate config * [NETBEANS-2448] JDK 10, 12 syntax migration support * corrected code formatting --- .../spiimpl/refactoring/ConfigurationsManager.java | 31 +++++++++++++++++++++- .../modules/java/hints/resources/jdk10.properties | 17 ++++++++++++ .../modules/java/hints/resources/jdk12.properties | 17 ++++++++++++ .../modules/java/hints/resources/layer.xml | 29 ++++++++++++++++++++ 4 files changed, 93 insertions(+), 1 deletion(-) diff --git a/java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/refactoring/ConfigurationsManager.java b/java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/refactoring/ConfigurationsManager.java index 8553662..2fff3fa 100644 --- a/java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/refactoring/ConfigurationsManager.java +++ b/java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/refactoring/ConfigurationsManager.java @@ -19,10 +19,14 @@ package org.netbeans.modules.java.hints.spiimpl.refactoring; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.swing.event.ChangeListener; import org.openide.util.ChangeSupport; import org.openide.util.Exceptions; @@ -75,7 +79,32 @@ public class ConfigurationsManager { 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)) { if (kid.startsWith(RULE_PREFIX)) { Preferences p = NbPreferences.forModule(this.getClass()).node(kid); String displayName = p.get("display.name", "unknown"); diff --git a/java/java.hints/src/org/netbeans/modules/java/hints/resources/jdk10.properties b/java/java.hints/src/org/netbeans/modules/java/hints/resources/jdk10.properties new file mode 100644 index 0000000..36e5ce4 --- /dev/null +++ b/java/java.hints/src/org/netbeans/modules/java/hints/resources/jdk10.properties @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +display.name=Migrate to JDK 10 diff --git a/java/java.hints/src/org/netbeans/modules/java/hints/resources/jdk12.properties b/java/java.hints/src/org/netbeans/modules/java/hints/resources/jdk12.properties new file mode 100644 index 0000000..8da1aae --- /dev/null +++ b/java/java.hints/src/org/netbeans/modules/java/hints/resources/jdk12.properties @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +display.name=Migrate to JDK 12 diff --git a/java/java.hints/src/org/netbeans/modules/java/hints/resources/layer.xml b/java/java.hints/src/org/netbeans/modules/java/hints/resources/layer.xml index 96786f7..5814dfe 100644 --- a/java/java.hints/src/org/netbeans/modules/java/hints/resources/layer.xml +++ b/java/java.hints/src/org/netbeans/modules/java/hints/resources/layer.xml @@ -388,11 +388,40 @@ <file name="org.netbeans.modules.java.hints.jdk.ConvertToStringSwitch.properties" url="enabled.properties"/> <file name="org.netbeans.modules.java.hints.jdk.UnnecessaryBoxing.run.properties" url="enabled.properties"/> </folder> + <folder name="rule_config_jdk10"> + <file name="Javac_canUseDiamond.properties" url="enabled.properties"/> + <file name="Javac_canUseLambda.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.IteratorToFor.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.UnnecessaryUnboxing.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.ConvertToARM.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.JoinCatches.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.Tiny.containsForIndexOf.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.StaticImport.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.ConvertToStringSwitch.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.UnnecessaryBoxing.run.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.ConvertToVarHint.properties" url="enabled.properties"/> + </folder> + <folder name="rule_config_jdk12"> + <file name="Javac_canUseDiamond.properties" url="enabled.properties"/> + <file name="Javac_canUseLambda.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.IteratorToFor.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.UnnecessaryUnboxing.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.ConvertToARM.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.JoinCatches.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.Tiny.containsForIndexOf.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.StaticImport.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.ConvertToStringSwitch.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.UnnecessaryBoxing.run.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.ConvertToVarHint.properties" url="enabled.properties"/> + <file name="org.netbeans.modules.java.hints.jdk.ConvertSwitchToRuleSwitch.properties" url="enabled.properties"/> + </folder> <folder name="ui"> <file name="rule_config_default.properties" url="nbresloc:/org/netbeans/modules/java/hints/resources/default.properties"/> <file name="rule_config_jdk5.properties" url="nbresloc:/org/netbeans/modules/java/hints/resources/jdk5.properties"/> <file name="rule_config_jdk7.properties" url="nbresloc:/org/netbeans/modules/java/hints/resources/jdk7.properties"/> <file name="rule_config_jdk8.properties" url="nbresloc:/org/netbeans/modules/java/hints/resources/jdk8.properties"/> + <file name="rule_config_jdk10.properties" url="nbresloc:/org/netbeans/modules/java/hints/resources/jdk10.properties"/> + <file name="rule_config_jdk12.properties" url="nbresloc:/org/netbeans/modules/java/hints/resources/jdk12.properties"/> </folder> </folder></folder></folder></folder></folder> </folder> --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists