asbachb commented on code in PR #6160:
URL: https://github.com/apache/netbeans/pull/6160#discussion_r1257323204


##########
enterprise/web.jsf.editor/src/org/netbeans/modules/web/jsf/editor/facelets/FaceletsLibrarySupport.java:
##########
@@ -358,38 +361,66 @@ public Collection<URI> getResources(ServletContext sc) {
             }
         });
 
-        //3. last add a provider for default jsf libs
-        //
-        //Add a facelet taglib provider which provides the libraries from
-        //netbeans jsf2.0 library
-        //
-        //This is needed for the standart JSF 2.0 libraries since it may
-        //happen that there is no javax-faces.jar with the .taglib.xml files
-        //on the compile classpath and we still want the features like code
-        //completion work. This happens for example in Maven web projects.
-        //
-        //The provider is last in the list so the provided libraries will
-        //be overridden if the descriptors are found in any of the jars
-        //on compile classpath.
-        Collection<FileObject> libraryDescriptorFiles = 
DefaultFaceletLibraries.getInstance().getLibrariesDescriptorsFiles();
-        final Collection<URI> libraryURIs = new ArrayList<>();
-        for(FileObject fo : libraryDescriptorFiles) {
-            try {
-                libraryURIs.add(fo.toURL().toURI());
-            } catch (URISyntaxException ex) {
-                LOGGER.log(Level.INFO, null, ex);
+
+        // try to find reference implementation based on jsf version
+        JsfVersion jsfVersion = getJsfSupport().getJsfVersion();
+        JsfReferenceImplementationProvider jsfRIProvider = 
Lookup.getDefault().lookup(JsfReferenceImplementationProvider.class);
+        Path jsfReferenceImplementation = jsfRIProvider.of(jsfVersion);
+
+        List<URL> jsfRIJars = new ArrayList<>();
+        try {
+            if (jsfReferenceImplementation != null) {
+                DefaultFaceletLibraries jsfRIFaceletLibraries = new 
DefaultFaceletLibraries(jsfReferenceImplementation.toFile());
+                List<URI> jsfRIDescriptors = 
jsfRIFaceletLibraries.getLibrariesDescriptorsFiles().stream()
+                        .map(FileObject::toURI)
+                        .collect(Collectors.toList());
+                faceletTaglibProviders.add(new ConfigurationResourceProvider() 
{
+                    @Override
+                    public Collection<URI> getResources(ServletContext sc) {
+                        return jsfRIDescriptors;
+                    }
+                });

Review Comment:
   Converted to lambda.



##########
enterprise/web.jsf/src/org/netbeans/modules/web/jsf/api/facesmodel/JsfVersionUtils.java:
##########
@@ -58,48 +59,31 @@
  *
  * @author Petr Pisl, ads, Martin Fousek
  */
-public enum JSFVersion {
-    JSF_1_0("JSF 1.0"),
-    JSF_1_1("JSF 1.1"),
-    JSF_1_2("JSF 1.2"),
-    JSF_2_0("JSF 2.0"),
-    JSF_2_1("JSF 2.1"),
-    JSF_2_2("JSF 2.2"),
-    JSF_2_3("JSF 2.3"),
-    JSF_3_0("JSF 3.0"),
-    JSF_4_0("JSF 4.0");
+public final class JsfVersionUtils {
 
-    private static final LinkedHashMap<JSFVersion, String> 
SPECIFIC_CLASS_NAMES = new LinkedHashMap<>();
+    private static final LinkedHashMap<JsfVersion, String> 
SPECIFIC_CLASS_NAMES = new LinkedHashMap<>();
 
     static {
-        SPECIFIC_CLASS_NAMES.put(JSFVersion.JSF_4_0, 
JSFUtils.JSF_4_0__API_SPECIFIC_CLASS);
-        SPECIFIC_CLASS_NAMES.put(JSFVersion.JSF_3_0, 
JSFUtils.JSF_3_0__API_SPECIFIC_CLASS);
-        SPECIFIC_CLASS_NAMES.put(JSFVersion.JSF_2_3, 
JSFUtils.JSF_2_3__API_SPECIFIC_CLASS);
-        SPECIFIC_CLASS_NAMES.put(JSFVersion.JSF_2_2, 
JSFUtils.JSF_2_2__API_SPECIFIC_CLASS);
-        SPECIFIC_CLASS_NAMES.put(JSFVersion.JSF_2_1, 
JSFUtils.JSF_2_1__API_SPECIFIC_CLASS);
-        SPECIFIC_CLASS_NAMES.put(JSFVersion.JSF_2_0, 
JSFUtils.JSF_2_0__API_SPECIFIC_CLASS);
-        SPECIFIC_CLASS_NAMES.put(JSFVersion.JSF_1_2, 
JSFUtils.JSF_1_2__API_SPECIFIC_CLASS);
-        SPECIFIC_CLASS_NAMES.put(JSFVersion.JSF_1_1, JSFUtils.FACES_EXCEPTION);
+        SPECIFIC_CLASS_NAMES.put(JsfVersion.JSF_4_0, 
JSFUtils.JSF_4_0__API_SPECIFIC_CLASS);
+        SPECIFIC_CLASS_NAMES.put(JsfVersion.JSF_3_0, 
JSFUtils.JSF_3_0__API_SPECIFIC_CLASS);
+        SPECIFIC_CLASS_NAMES.put(JsfVersion.JSF_2_3, 
JSFUtils.JSF_2_3__API_SPECIFIC_CLASS);
+        SPECIFIC_CLASS_NAMES.put(JsfVersion.JSF_2_2, 
JSFUtils.JSF_2_2__API_SPECIFIC_CLASS);
+        SPECIFIC_CLASS_NAMES.put(JsfVersion.JSF_2_1, 
JSFUtils.JSF_2_1__API_SPECIFIC_CLASS);
+        SPECIFIC_CLASS_NAMES.put(JsfVersion.JSF_2_0, 
JSFUtils.JSF_2_0__API_SPECIFIC_CLASS);
+        SPECIFIC_CLASS_NAMES.put(JsfVersion.JSF_1_2, 
JSFUtils.JSF_1_2__API_SPECIFIC_CLASS);
+        SPECIFIC_CLASS_NAMES.put(JsfVersion.JSF_1_1, JSFUtils.FACES_EXCEPTION);
     }
 
-    private final String shortName;
-
-
-    private JSFVersion(String shortName) {
-        this.shortName = shortName;
-    }
-
-    public String getShortName() {
-        return shortName;
-    }
-
-    private static final RequestProcessor RP = new 
RequestProcessor(JSFVersion.class);
-    private static final Logger LOG = 
Logger.getLogger(JSFVersion.class.getName());
+    private static final RequestProcessor RP = new 
RequestProcessor(JsfVersion.class);

Review Comment:
   Removed.



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