NicolaIsotta commented on code in PR #9540:
URL: https://github.com/apache/netbeans/pull/9540#discussion_r3820293022


##########
ide/xml.xdm/src/org/netbeans/modules/xml/xdm/nodes/XMLSyntaxParser.java:
##########
@@ -44,22 +46,8 @@ public Document parse(BaseDocument basedoc)
             List<Token> currentTokens = new ArrayList<Token>();
             TokenHierarchy th = TokenHierarchy.get(basedoc);
             TokenSequence<XMLTokenId> tokenSequence = th.tokenSequence();
-            org.netbeans.api.lexer.Token<XMLTokenId> token = 
tokenSequence.token();
-            // Add the text token, if any, before xml decalration to document 
node
-            if(token != null && token.id() == XMLTokenId.TEXT) {
-                
currentTokens.add(Token.create(token.text().toString(),TokenType.TOKEN_CHARACTER_DATA));
-                if(tokenSequence.moveNext()) {
-                    token = tokenSequence.token();
-                }
-                // if the xml decalration is not there assign this token to 
document
-                if(token.id() != XMLTokenId.PI_START) {
-                    currentNode.setTokens(new ArrayList<Token>(currentTokens));
-                    currentTokens.clear();
-                }
-            }

Review Comment:
   Dead code.
   The condition in the if is always false, because `TokenSequence.token()` 
returns null if `moveNext()` hasn't been called - see the javadocs: 
https://github.com/apache/netbeans/blob/97742f11c04cd5e03cf3900bc7e68f9806269e61/ide/lexer/src/org/netbeans/api/lexer/TokenSequence.java#L156-L195
   I tried to "enable" the if by adding a `tokenSequence.moveNext()` before, 
lots of test failed, even after some tentative fixes. I tought it would be 
better to avoid the pain to next who's gonna touch this :)



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