This is an automated email from the ASF dual-hosted git repository.

mbien 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 0ec0a985da calculate javadoc links dynamically.
     new cbacd2b7db Merge pull request #4837 from mbien/javadoc-link-gen
0ec0a985da is described below

commit 0ec0a985da4d07e464b657e8a4622d3286ed60c3
Author: Michael Bien <mbie...@gmail.com>
AuthorDate: Fri Oct 21 19:50:15 2022 +0200

    calculate javadoc links dynamically.
---
 .../J2SEPlatformDefaultJavadocImpl.java            | 29 ++++++++++++----------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git 
a/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/platformdefinition/J2SEPlatformDefaultJavadocImpl.java
 
b/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/platformdefinition/J2SEPlatformDefaultJavadocImpl.java
index b41084cebf..4800d3635e 100644
--- 
a/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/platformdefinition/J2SEPlatformDefaultJavadocImpl.java
+++ 
b/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/platformdefinition/J2SEPlatformDefaultJavadocImpl.java
@@ -22,6 +22,9 @@ import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.time.LocalDate;
+import java.time.Month;
+import java.time.Period;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -57,19 +60,19 @@ public final class J2SEPlatformDefaultJavadocImpl 
implements J2SEPlatformDefault
         OFFICIAL_JAVADOC.put("1.6", 
"https://docs.oracle.com/javase/6/docs/api/";); // NOI18N
         OFFICIAL_JAVADOC.put("1.7", 
"https://docs.oracle.com/javase/7/docs/api/";); // NOI18N
         OFFICIAL_JAVADOC.put("1.8", 
"https://docs.oracle.com/javase/8/docs/api/";); // NOI18N
-        OFFICIAL_JAVADOC.put("9", 
"https://docs.oracle.com/javase/9/docs/api/";); // NOI18N
-        OFFICIAL_JAVADOC.put("10", 
"https://docs.oracle.com/javase/10/docs/api/";); // NOI18N
-        OFFICIAL_JAVADOC.put("11", 
"https://docs.oracle.com/en/java/javase/11/docs/api/";); // NOI18N
-        OFFICIAL_JAVADOC.put("12", 
"https://docs.oracle.com/en/java/javase/12/docs/api/";); // NOI18N
-        OFFICIAL_JAVADOC.put("13", 
"https://docs.oracle.com/en/java/javase/13/docs/api/";); // NOI18N
-        OFFICIAL_JAVADOC.put("14", 
"https://docs.oracle.com/en/java/javase/14/docs/api/";); // NOI18N
-        OFFICIAL_JAVADOC.put("15", 
"https://docs.oracle.com/en/java/javase/15/docs/api/";); // NOI18N
-        OFFICIAL_JAVADOC.put("16", 
"https://docs.oracle.com/en/java/javase/16/docs/api/";); // NOI18N
-        OFFICIAL_JAVADOC.put("17", 
"https://docs.oracle.com/en/java/javase/17/docs/api/";); // NOI18N
-        OFFICIAL_JAVADOC.put("18", 
"https://docs.oracle.com/en/java/javase/18/docs/api/";); // NOI18N
-        OFFICIAL_JAVADOC.put("19", 
"https://docs.oracle.com/en/java/javase/19/docs/api/";); // NOI18N
-        OFFICIAL_JAVADOC.put("20", 
"https://download.java.net/java/early_access/jdk20/docs/api/";); // NOI18N Early 
access
-        OFFICIAL_JAVADOC.put("21", 
"https://download.java.net/java/early_access/jdk21/docs/api/";); // NOI18N Early 
access
+
+        // timezone shouldn't matter since the accuracy is worse than a day
+        LocalDate jdk9 = LocalDate.of(2017, Month.SEPTEMBER, 21); // start of 
6 month schedule
+        LocalDate now = LocalDate.now();
+
+        if (now.isAfter(jdk9)) { // time traveler -> only java 8 doc for you
+            int[] jdk = new int[] {9};
+            jdk9.datesUntil(now, Period.ofMonths(6)).forEach((t) -> {
+                OFFICIAL_JAVADOC.put(String.valueOf(jdk[0]), 
"https://docs.oracle.com/javase/"+jdk[0]+"/docs/api/";); // NOI18N
+                jdk[0]++;
+            });
+            OFFICIAL_JAVADOC.put(String.valueOf(jdk[0]), 
"https://download.java.net/java/early_access/jdk"+jdk[0]+"/docs/api/";); // 
NOI18N Early access
+        }
     }
 
     @Override


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

Reply via email to