eclipse-lemminx / lemminx

XML Language Server
Eclipse Public License 2.0
272 stars 93 forks source link

org.eclipse.lemminx.dom.DOMNode.getTextContent() seem to be implemented wrong (or incomplete) #1695

Closed laeubi closed 1 week ago

laeubi commented 3 weeks ago

org.eclipse.lemminx.dom.DOMNode.getTextContent() always return null if Eclipse is correct no class overrides DOMNode here

https://github.com/eclipse/lemminx/blob/744de35767bf762a6abcfd2337f7e931ecbaf8d1/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/dom/DOMNode.java#L829

that simply return the value of an element while [the javadoc says](https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/org/w3c/dom/Node.html#getTextContent())

ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE concatenation of the textContent attribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the node has no children.

For the following example document

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>test</groupId>
    <artifactId>bnd-integration-test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>BND-M2E Integration Test Project</name>
    <description>This project test the BND-m2e integration</description>
    <build>
        <plugins>
            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
                <version>7.0.0</version>
                <executions>
                    <execution>
                        <id>bnd-process</id>
                        <goals>
                            <goal>bnd-process</goal>
                        </goals>
                        <configuration>
                        <bnd>
                        ssss
                        <test>me</test>
                        <![CDATA[ 

                        ]]>
                        </bnd>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.core</artifactId>
            <version><![CDATA[8.0.0]]></version>
        </dependency>
    </dependencies>
</project>

I get the following output for element <bnd>

Okt. 27, 2024 3:07:58 PM org.eclipse.m2e.lemminx.bnd.BndLemminxPlugin$1 onXMLContent
INFORMATION: text content=null
Okt. 27, 2024 3:07:58 PM org.eclipse.m2e.lemminx.bnd.BndLemminxPlugin$1 onXMLContent
INFORMATION: substring=<bnd>
                        ssss
                        <test>me</test>
                        <![CDATA[ 

                        ]]>
                        </bnd>

while the text content has to be something like


                        ssss
                        me
angelozerr commented 2 weeks ago

Any contribution are welcome!