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


##########
enterprise/web.jsf.editor/src/org/netbeans/modules/web/jsf/editor/JsfUtils.java:
##########
@@ -99,12 +100,9 @@ public static Result getEmbeddedParserResult(ResultIterator 
resultIterator, Stri
         return null;
     }
 
-    public static Node getRoot(HtmlParserResult parserResult, LibraryInfo 
library) {
-        Node rootNode = parserResult.root(library.getNamespace());
-        if ((rootNode == null || rootNode.children().isEmpty()) && 
library.getLegacyNamespace() != null) {
-            rootNode = parserResult.root(library.getLegacyNamespace());
-        }
-        return rootNode;
+    public static Node getRoot(HtmlParserResult parserResult, LibraryInfo 
library, JsfVersion jsfVersion) {
+        String namespace = 
jsfVersion.getNamespaceUri(library.getDefaultPrefix());
+        return parserResult.root(namespace);

Review Comment:
   I entered this into a facelets file:
   
   ```xml
   <f:view
        xmlns="http://www.w3.org/1999/xhtml";
        xmlns:c="http://java.sun.com/jsp/jstl/core";
        xmlns:f="http://java.sun.com/jsf/core";
        xmlns:h="http://java.sun.com/jsf/html";
        xmlns:p="http://primefaces.org/ui";
        xmlns:ui="http://java.sun.com/jsf/facelets";>
        
        <h:head>
        </h:head>
        <h:body>
               <ui:define name="|" />
           </h:body>
   </f:view>
   ```
   
   I called completion at position marked with "|". At that point 
`JsfUtils#getRoot` is called with the `DefaultLibraryInfo` `FACELETS`. In my 
exampled I used the legacy namespace. Because the original method checks both 
namespaces it finds the `f:view` element, with your change that would have not 
happenend and an empty pseudo node had been returned.
   
   So sorry, but your change introduces a bug, you need to scan all possible 
namespaces for the libraries.



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