From bf66f816f06bd62c932bffae43da93c4484632be Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Mon, 18 Dec 2023 18:18:01 +0100 Subject: [PATCH] [html] Remove @Image attributes of text nodes --- .../pmd/lang/html/ast/ASTHtmlTextNode.java | 5 - .../lang/html/ast/testdata/SimpleHtmlFile.txt | 18 ++-- .../lang/html/ast/testdata/SimpleXmlFile.txt | 10 +- .../html/ast/testdata/TemplateFragment.txt | 92 +++++++++---------- 4 files changed, 60 insertions(+), 65 deletions(-) diff --git a/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/ast/ASTHtmlTextNode.java b/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/ast/ASTHtmlTextNode.java index 524a8a931e..1fb41518d4 100644 --- a/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/ast/ASTHtmlTextNode.java +++ b/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/ast/ASTHtmlTextNode.java @@ -25,9 +25,4 @@ public class ASTHtmlTextNode extends AbstractHtmlNode { public String getText() { return node.getWholeText(); } - - @Override - public String getImage() { - return getNormalizedText(); - } } diff --git a/pmd-html/src/test/resources/net/sourceforge/pmd/lang/html/ast/testdata/SimpleHtmlFile.txt b/pmd-html/src/test/resources/net/sourceforge/pmd/lang/html/ast/testdata/SimpleHtmlFile.txt index 6d8af325b6..105c079501 100644 --- a/pmd-html/src/test/resources/net/sourceforge/pmd/lang/html/ast/testdata/SimpleHtmlFile.txt +++ b/pmd-html/src/test/resources/net/sourceforge/pmd/lang/html/ast/testdata/SimpleHtmlFile.txt @@ -1,15 +1,15 @@ +- #document[@NodeName = "#document"] +- #doctype[@Name = "html", @NodeName = "#doctype", @PublicId = "", @SystemId = ""] - +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n"] + +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n"] +- html[@NodeName = "html"] - | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | +- head[@NodeName = "head"] - | | +- #text[@Image = "hello", @NodeName = "#text", @NormalizedText = "hello", @Text = "hello"] - | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | +- #text[@NodeName = "#text", @NormalizedText = "hello", @Text = "hello"] + | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | +- body[@NodeName = "body"] - | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | +- h1[@NodeName = "h1"] - | | | +- #text[@Image = "world", @NodeName = "#text", @NormalizedText = "world", @Text = "world"] - | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] - | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n"] - +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n"] + | | | +- #text[@NodeName = "#text", @NormalizedText = "world", @Text = "world"] + | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n"] + +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n"] diff --git a/pmd-html/src/test/resources/net/sourceforge/pmd/lang/html/ast/testdata/SimpleXmlFile.txt b/pmd-html/src/test/resources/net/sourceforge/pmd/lang/html/ast/testdata/SimpleXmlFile.txt index 9c25c1a1fc..36d3505504 100644 --- a/pmd-html/src/test/resources/net/sourceforge/pmd/lang/html/ast/testdata/SimpleXmlFile.txt +++ b/pmd-html/src/test/resources/net/sourceforge/pmd/lang/html/ast/testdata/SimpleXmlFile.txt @@ -1,9 +1,9 @@ +- #document[@NodeName = "#document"] +- #declaration[@Name = "xml", @NodeName = "#declaration"] - +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n"] + +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n"] +- root[@NodeName = "root"] - | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | +- child[@NodeName = "child", @attr1 = "value1"] - | | +- #text[@Image = "text & entities", @NodeName = "#text", @NormalizedText = "text & entities", @Text = "text & entities"] - | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n"] - +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n"] + | | +- #text[@NodeName = "#text", @NormalizedText = "text & entities", @Text = "text & entities"] + | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n"] + +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n"] diff --git a/pmd-html/src/test/resources/net/sourceforge/pmd/lang/html/ast/testdata/TemplateFragment.txt b/pmd-html/src/test/resources/net/sourceforge/pmd/lang/html/ast/testdata/TemplateFragment.txt index 6b4d6a4f40..9777d47d07 100644 --- a/pmd-html/src/test/resources/net/sourceforge/pmd/lang/html/ast/testdata/TemplateFragment.txt +++ b/pmd-html/src/test/resources/net/sourceforge/pmd/lang/html/ast/testdata/TemplateFragment.txt @@ -1,83 +1,83 @@ +- #document[@NodeName = "#document"] +- #comment[@Data = " from https://raw.githubusercontent.com/trailheadapps/lwc-recipes-oss/main/src/modules/ui/app/app.html ", @NodeName = "#comment"] - +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n"] + +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n"] +- template[@NodeName = "template"] - | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | +- section[@NodeName = "section", @class = "content container page-background"] - | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | +- ui-navbar[@NodeName = "ui-navbar", @nav-items = "{navigationItems}", @oncategorychange = "{handleCategoryChange}", @selected-item = "{currentNavigationItem}"] - | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] - | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n\n "] + | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n\n "] | | +- article[@NodeName = "article", @class = "container"] - | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | +- div[@NodeName = "div"] - | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | +- template[@NodeName = "template", @if:true = "{navigationItems.hello.visible}"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-hello[@NodeName = "recipe-hello"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-hello-binding[@NodeName = "recipe-hello-binding"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-hello-expressions[@NodeName = "recipe-hello-expressions"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-hello-expressions-track[@NodeName = "recipe-hello-expressions-track"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-hello-conditional-rendering[@NodeName = "recipe-hello-conditional-rendering"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-hello-for-each[@NodeName = "recipe-hello-for-each"] | | | | | +- recipe-hello-iterator[@NodeName = "recipe-hello-iterator"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] - | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | +- template[@NodeName = "template", @if:true = "{navigationItems.composition.visible}"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-composition-basics[@NodeName = "recipe-composition-basics"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-composition-iteration[@NodeName = "recipe-composition-iteration"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-composition-contact-search[@NodeName = "recipe-composition-contact-search"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-composition-dynamic[@NodeName = "recipe-composition-dynamic"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] - | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | +- template[@NodeName = "template", @if:true = "{navigationItems.child.visible}"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-event-simple[@NodeName = "recipe-event-simple"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-event-with-data[@NodeName = "recipe-event-with-data"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-event-bubbling[@NodeName = "recipe-event-bubbling"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] - | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | +- template[@NodeName = "template", @if:true = "{navigationItems.parent.visible}"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-api-property[@NodeName = "recipe-api-property"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-api-function[@NodeName = "recipe-api-function"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-api-setter-getter[@NodeName = "recipe-api-setter-getter"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] - | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | +- template[@NodeName = "template", @if:true = "{navigationItems.misc.visible}"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-misc-shared-java-script[@NodeName = "recipe-misc-shared-java-script"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-misc-rest-api-call[@NodeName = "recipe-misc-rest-api-call"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-misc-dom-query[@NodeName = "recipe-misc-dom-query"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-misc-multiple-templates[@NodeName = "recipe-misc-multiple-templates"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] - | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | +- template[@NodeName = "template", @if:true = "{navigationItems.party.visible}"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-libs-d3[@NodeName = "recipe-libs-d3"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | | +- recipe-libs-chartjs[@NodeName = "recipe-libs-chartjs"] - | | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] - | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] | | | | +- ui-navfooter[@NodeName = "ui-navfooter", @label-next = "{nextNavigationItem}", @label-previous = "{previousNavigationItem}", @onnextclicked = "{handleNavigateNext}", @onpreviousclicked = "{handleNavigatePrevious}"] - | | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] - | | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] - | | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n "] - | +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n"] - +- #text[@Image = " ", @NodeName = "#text", @NormalizedText = " ", @Text = "\n"] + | | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n "] + | +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n"] + +- #text[@NodeName = "#text", @NormalizedText = " ", @Text = "\n"]