[jsp] Avoid using @Image, add AbstractContentNode
This commit is contained in:
+22
-22
@@ -395,7 +395,7 @@ void JspScriptlet() :
|
||||
{ Token t; }
|
||||
{
|
||||
<JSP_SCRIPTLET_START>
|
||||
t = <JSP_SCRIPTLET> { jjtThis.setImage(t.image.trim()); }
|
||||
t = <JSP_SCRIPTLET> { jjtThis.setContent(t.image.trim()); }
|
||||
<JSP_SCRIPTLET_END>
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ void JspExpression() :
|
||||
{ Token t; }
|
||||
{
|
||||
<JSP_EXPRESSION_START>
|
||||
t = <JSP_EXPRESSION> { jjtThis.setImage(t.image.trim()); }
|
||||
t = <JSP_EXPRESSION> { jjtThis.setContent(t.image.trim()); }
|
||||
<JSP_EXPRESSION_END>
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ void JspDeclaration() :
|
||||
{ Token t; }
|
||||
{
|
||||
<JSP_DECLARATION_START>
|
||||
t = <JSP_DECLARATION> { jjtThis.setImage(t.image.trim()); }
|
||||
t = <JSP_DECLARATION> { jjtThis.setContent(t.image.trim()); }
|
||||
<JSP_DECLARATION_END>
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ void JspComment() :
|
||||
{ Token t; }
|
||||
{
|
||||
<JSP_COMMENT_START>
|
||||
t = <JSP_COMMENT_CONTENT> { jjtThis.setImage(t.image.trim()); }
|
||||
t = <JSP_COMMENT_CONTENT> { jjtThis.setContent(t.image.trim()); }
|
||||
<JSP_COMMENT_END>
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ void JspComment() :
|
||||
*/
|
||||
void Text() :
|
||||
{
|
||||
StringBuffer content = new StringBuffer();
|
||||
StringBuilder content = new StringBuilder();
|
||||
String tmp;
|
||||
}
|
||||
{
|
||||
@@ -438,7 +438,7 @@ void Text() :
|
||||
tmp = UnparsedText() { content.append(tmp); }
|
||||
| tmp = ElExpression() { content.append(tmp); }
|
||||
)+
|
||||
{jjtThis.setImage(content.toString());}
|
||||
{jjtThis.setContent(content.toString());}
|
||||
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ String UnparsedText() :
|
||||
{
|
||||
t = <UNPARSED_TEXT>
|
||||
{
|
||||
jjtThis.setImage(t.image);
|
||||
jjtThis.setContent(t.image);
|
||||
return t.image;
|
||||
}
|
||||
}
|
||||
@@ -459,7 +459,7 @@ String UnparsedTextNoWhitespace() #UnparsedText :
|
||||
t = <UNPARSED_TEXT_NO_WHITESPACE>
|
||||
)
|
||||
{
|
||||
jjtThis.setImage(t.image);
|
||||
jjtThis.setContent(t.image);
|
||||
return t.image;
|
||||
}
|
||||
}
|
||||
@@ -475,7 +475,7 @@ String UnparsedTextNoSingleQuotes() #UnparsedText :
|
||||
{
|
||||
t = <UNPARSED_TEXT_NO_SINGLE_QUOTES>
|
||||
{
|
||||
jjtThis.setImage(t.image);
|
||||
jjtThis.setContent(t.image);
|
||||
return t.image;
|
||||
}
|
||||
}
|
||||
@@ -489,7 +489,7 @@ String UnparsedTextNoDoubleQuotes() #UnparsedText :
|
||||
{
|
||||
t = <UNPARSED_TEXT_NO_DOUBLE_QUOTES>
|
||||
{
|
||||
jjtThis.setImage(t.image);
|
||||
jjtThis.setContent(t.image);
|
||||
return t.image;
|
||||
}
|
||||
}
|
||||
@@ -502,7 +502,7 @@ String ElExpression() :
|
||||
{
|
||||
t = <EL_EXPRESSION>
|
||||
{
|
||||
jjtThis.setImage(expressionContent(t.image));
|
||||
jjtThis.setContent(expressionContent(t.image));
|
||||
return t.image;
|
||||
}
|
||||
}
|
||||
@@ -512,7 +512,7 @@ String ValueBindingInAttribute() #ValueBinding :
|
||||
{
|
||||
t = <VALUE_BINDING_IN_ATTRIBUTE>
|
||||
{
|
||||
jjtThis.setImage(expressionContent(t.image));
|
||||
jjtThis.setContent(expressionContent(t.image));
|
||||
return t.image;
|
||||
}
|
||||
}
|
||||
@@ -522,20 +522,20 @@ String ElExpressionInAttribute() #ElExpression :
|
||||
{
|
||||
t = <EL_EXPRESSION_IN_ATTRIBUTE>
|
||||
{
|
||||
jjtThis.setImage(expressionContent(t.image));
|
||||
jjtThis.setContent(expressionContent(t.image));
|
||||
return t.image;
|
||||
}
|
||||
}
|
||||
|
||||
void CData() :
|
||||
{
|
||||
StringBuffer content = new StringBuffer();
|
||||
StringBuilder content = new StringBuilder();
|
||||
Token t;
|
||||
}
|
||||
{
|
||||
<CDATA_START> ( t = <UNPARSED> { content.append(t.image); } )* <CDATA_END>
|
||||
{
|
||||
jjtThis.setImage(content.toString());
|
||||
jjtThis.setContent(content.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,7 +595,7 @@ void Attribute() :
|
||||
*/
|
||||
void AttributeValue() :
|
||||
{
|
||||
StringBuffer content = new StringBuffer();
|
||||
StringBuilder content = new StringBuilder();
|
||||
String tmp;
|
||||
Token t = null ;
|
||||
}
|
||||
@@ -626,7 +626,7 @@ void AttributeValue() :
|
||||
)
|
||||
| <IN_ATTR_WHITESPACE>
|
||||
)
|
||||
{ jjtThis.setImage( content.toString() );
|
||||
{ jjtThis.setValue( content.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -649,14 +649,14 @@ String JspExpressionInAttribute() :
|
||||
{
|
||||
t = <JSP_EXPRESSION_IN_ATTRIBUTE>
|
||||
{
|
||||
jjtThis.setImage(t.image.substring(3, t.image.length()-2).trim()); // without <% and %>
|
||||
jjtThis.setContent(t.image.substring(3, t.image.length()-2).trim()); // without <% and %>
|
||||
return t.image;
|
||||
}
|
||||
}
|
||||
|
||||
void CommentTag() :
|
||||
{
|
||||
StringBuffer content = new StringBuffer();
|
||||
StringBuilder content = new StringBuilder();
|
||||
Token t;
|
||||
}
|
||||
{
|
||||
@@ -664,7 +664,7 @@ void CommentTag() :
|
||||
( t = <COMMENT_TEXT> { content.append(t.image); } )*
|
||||
<COMMENT_END>
|
||||
{
|
||||
jjtThis.setImage(content.toString().trim());
|
||||
jjtThis.setContent(content.toString().trim());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -712,7 +712,7 @@ void DoctypeExternalId() :
|
||||
|
||||
void HtmlScript() :
|
||||
{
|
||||
StringBuffer content = new StringBuffer();
|
||||
StringBuilder content = new StringBuilder();
|
||||
String tagName;
|
||||
Token t;
|
||||
}
|
||||
@@ -723,7 +723,7 @@ void HtmlScript() :
|
||||
(
|
||||
<TAG_END> {token_source.SwitchTo(HtmlScriptContentState);}
|
||||
(t = <HTML_SCRIPT_CONTENT> { content.append(t.image); })*
|
||||
<HTML_SCRIPT_END_TAG> { jjtThis.setImage(content.toString().trim());}
|
||||
<HTML_SCRIPT_END_TAG> { jjtThis.setContent(content.toString().trim());}
|
||||
)
|
||||
|
|
||||
(
|
||||
|
||||
@@ -6,6 +6,8 @@ package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
public final class ASTAttributeValue extends AbstractJspNode {
|
||||
|
||||
private String value;
|
||||
|
||||
ASTAttributeValue(int id) {
|
||||
super(id);
|
||||
}
|
||||
@@ -14,4 +16,12 @@ public final class ASTAttributeValue extends AbstractJspNode {
|
||||
protected <P, R> R acceptVisitor(JspVisitor<? super P, ? extends R> visitor, P data) {
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
public final class ASTCData extends AbstractJspNode {
|
||||
public final class ASTCData extends AbstractContentNode {
|
||||
|
||||
ASTCData(int id) {
|
||||
super(id);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
public final class ASTCommentTag extends AbstractJspNode {
|
||||
public final class ASTCommentTag extends AbstractContentNode {
|
||||
|
||||
ASTCommentTag(int id) {
|
||||
super(id);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
public final class ASTElExpression extends AbstractJspNode {
|
||||
public final class ASTElExpression extends AbstractExpression {
|
||||
|
||||
ASTElExpression(int id) {
|
||||
super(id);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
public final class ASTHtmlScript extends AbstractJspNode {
|
||||
public final class ASTHtmlScript extends AbstractContentNode {
|
||||
|
||||
ASTHtmlScript(int id) {
|
||||
super(id);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
public final class ASTJspComment extends AbstractJspNode {
|
||||
public final class ASTJspComment extends AbstractContentNode {
|
||||
|
||||
ASTJspComment(int id) {
|
||||
super(id);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
public final class ASTJspDeclaration extends AbstractJspNode {
|
||||
public final class ASTJspDeclaration extends AbstractContentNode {
|
||||
ASTJspDeclaration(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
public final class ASTJspExpression extends AbstractJspNode {
|
||||
public final class ASTJspExpression extends AbstractExpression {
|
||||
|
||||
ASTJspExpression(int id) {
|
||||
super(id);
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
public final class ASTJspExpressionInAttribute extends AbstractJspNode {
|
||||
public final class ASTJspExpressionInAttribute extends AbstractExpression {
|
||||
|
||||
ASTJspExpressionInAttribute(int id) {
|
||||
super(id);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
public final class ASTJspScriptlet extends AbstractJspNode {
|
||||
public final class ASTJspScriptlet extends AbstractContentNode {
|
||||
|
||||
ASTJspScriptlet(int id) {
|
||||
super(id);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
public final class ASTText extends AbstractJspNode {
|
||||
public final class ASTText extends AbstractContentNode {
|
||||
|
||||
ASTText(int id) {
|
||||
super(id);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
public final class ASTUnparsedText extends AbstractJspNode {
|
||||
public final class ASTUnparsedText extends AbstractContentNode {
|
||||
|
||||
ASTUnparsedText(int id) {
|
||||
super(id);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
public final class ASTValueBinding extends AbstractJspNode {
|
||||
public final class ASTValueBinding extends AbstractExpression {
|
||||
|
||||
ASTValueBinding(int id) {
|
||||
super(id);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
abstract class AbstractContentNode extends AbstractJspNode {
|
||||
|
||||
private String content;
|
||||
|
||||
protected AbstractContentNode(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.jsp.ast;
|
||||
|
||||
abstract class AbstractExpression extends AbstractContentNode {
|
||||
protected AbstractExpression(int id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -24,12 +24,6 @@ abstract class AbstractJspNode extends AbstractJjtreeNode<AbstractJspNode, JspNo
|
||||
|
||||
protected abstract <P, R> R acceptVisitor(JspVisitor<? super P, ? extends R> visitor, P data);
|
||||
|
||||
|
||||
@Override // override to make protected member accessible to parser
|
||||
protected void setImage(String image) {
|
||||
super.setImage(image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getXPathNodeName() {
|
||||
return JspParserImplTreeConstants.jjtNodeName[id];
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class DuplicateJspImportsRule extends AbstractJspRule {
|
||||
for (int ix = 0; ix < count; ix++) {
|
||||
String token = st.nextToken();
|
||||
if (imports.contains(token)) {
|
||||
addViolation(data, node, node.getImage());
|
||||
addViolation(data, node, token);
|
||||
} else {
|
||||
imports.add(token);
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class NoUnsanitizedJSPExpressionRule extends AbstractJspRule {
|
||||
boolean elInTaglib = parentASTElement != null && parentASTElement.getName() != null
|
||||
&& parentASTElement.getName().contains(":");
|
||||
|
||||
boolean elWithFnEscapeXml = node.getImage() != null && node.getImage().matches("^fn:escapeXml\\(.+\\)$");
|
||||
boolean elWithFnEscapeXml = node.getContent() != null && node.getContent().matches("^fn:escapeXml\\(.+\\)$");
|
||||
|
||||
return !elInTaglib && !elWithFnEscapeXml;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ Externalized script could be reused between pages. Browsers can also cache the
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//HtmlScript[@Image != '']
|
||||
//HtmlScript[@Content != '']
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
|
||||
@@ -25,7 +25,7 @@ A missing 'meta' tag or page directive will trigger this rule, as well as a non-
|
||||
<![CDATA[
|
||||
//CompilationUnit/Content[
|
||||
not(Element[@Name="meta"][
|
||||
Attribute[@Name="content"]/AttributeValue[contains(lower-case(@Image),"charset=utf-8")]
|
||||
Attribute[@Name="content"]/AttributeValue[contains(lower-case(@Value),"charset=utf-8")]
|
||||
])
|
||||
and
|
||||
not(JspDirective[@Name='page']/JspDirectiveAttribute[@Name='contentType'][contains(lower-case(@Value),"charset=utf-8")])
|
||||
|
||||
@@ -74,15 +74,15 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
ASTAttribute attr = attrsList.get(0);
|
||||
|
||||
assertEquals("something", attr.getName(), "Correct attribute name expected!");
|
||||
assertEquals("#yes#", attr.getFirstDescendantOfType(ASTAttributeValue.class).getImage(), "Correct attribute value expected!");
|
||||
assertEquals("#yes#", attr.getFirstDescendantOfType(ASTAttributeValue.class).getValue(), "Correct attribute value expected!");
|
||||
|
||||
attr = attrsList.get(1);
|
||||
assertEquals("foo", attr.getName(), "Correct attribute name expected!");
|
||||
assertEquals("CREATE", attr.getFirstDescendantOfType(ASTAttributeValue.class).getImage(), "Correct attribute value expected!");
|
||||
assertEquals("CREATE", attr.getFirstDescendantOfType(ASTAttributeValue.class).getValue(), "Correct attribute value expected!");
|
||||
|
||||
attr = attrsList.get(2);
|
||||
assertEquals("href", attr.getName(), "Correct attribute name expected!");
|
||||
assertEquals("#", attr.getFirstDescendantOfType(ASTAttributeValue.class).getImage(), "Correct attribute value expected!");
|
||||
assertEquals("#", attr.getFirstDescendantOfType(ASTAttributeValue.class).getValue(), "Correct attribute value expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
|
||||
assertEquals(1, cdataNodes.size(), "One CDATA node expected!");
|
||||
ASTCData cdata = cdataNodes.get(0);
|
||||
assertEquals(" some <cdata> ]] ]> ", cdata.getImage(), "Content incorrectly parsed!");
|
||||
assertEquals(" some <cdata> ]] ]> ", cdata.getContent(), "Content incorrectly parsed!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +126,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTCommentTag> comments = jsp.getNodes(ASTCommentTag.class, TEST_COMMENT);
|
||||
assertEquals(1, comments.size(), "One comment expected!");
|
||||
ASTCommentTag comment = comments.iterator().next();
|
||||
assertEquals("comment", comment.getImage(), "Correct comment content expected!");
|
||||
assertEquals("comment", comment.getContent(), "Correct comment content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTHtmlScript> scripts = jsp.getNodes(ASTHtmlScript.class, TEST_HTML_SCRIPT);
|
||||
assertEquals(1, scripts.size(), "One script expected!");
|
||||
ASTHtmlScript script = scripts.iterator().next();
|
||||
assertEquals("Script!", script.getImage(), "Correct script content expected!");
|
||||
assertEquals("Script!", script.getContent(), "Correct script content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,7 +150,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
assertEquals(1, scripts.size(), "One script expected!");
|
||||
ASTHtmlScript script = scripts.iterator().next();
|
||||
List<ASTAttributeValue> value = script.findDescendantsOfType(ASTAttributeValue.class);
|
||||
assertEquals("filename.js", value.get(0).getImage());
|
||||
assertEquals("filename.js", value.get(0).getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,9 +161,9 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTHtmlScript> scripts = jsp.getNodes(ASTHtmlScript.class, TEST_HTML_SCRIPT_WITH_ATTRIBUTE);
|
||||
assertEquals(1, scripts.size(), "One script expected!");
|
||||
ASTHtmlScript script = scripts.iterator().next();
|
||||
assertEquals("Script!", script.getImage(), "Correct script content expected!");
|
||||
assertEquals("Script!", script.getContent(), "Correct script content expected!");
|
||||
List<ASTAttributeValue> attrs = script.findDescendantsOfType(ASTAttributeValue.class);
|
||||
assertEquals("text/javascript", attrs.get(0).getImage());
|
||||
assertEquals("text/javascript", attrs.get(0).getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTHtmlScript> script = jsp.getNodes(ASTHtmlScript.class, TEST_COMPLEX_SCRIPT);
|
||||
assertEquals(1, script.size(), "One script expected!");
|
||||
ASTHtmlScript next = script.iterator().next();
|
||||
assertThat(next.getImage(), containsString("<!--"));
|
||||
assertThat(next.getContent(), containsString("<!--"));
|
||||
List<ASTCommentTag> comments = jsp.getNodes(ASTCommentTag.class, TEST_COMPLEX_SCRIPT);
|
||||
assertEquals(1, comments.size(), "One comment expected!");
|
||||
}
|
||||
@@ -196,7 +196,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTText> scripts = jsp.getNodes(ASTText.class, TEST_TEXT_IN_TAG);
|
||||
assertEquals(1, scripts.size(), "One text chunk expected!");
|
||||
ASTText script = scripts.iterator().next();
|
||||
assertEquals(" some text ", script.getImage(), "Correct content expected!");
|
||||
assertEquals(" some text ", script.getContent(), "Correct content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,7 +220,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTText> scripts = jsp.getNodes(ASTText.class, TEST_TAGS_WITH_DOLLAR);
|
||||
assertEquals(2, scripts.size(), "Two text chunks expected!");
|
||||
ASTText script = scripts.iterator().next();
|
||||
assertEquals(" $ ", script.getImage(), "Correct content expected!");
|
||||
assertEquals(" $ ", script.getContent(), "Correct content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,8 +231,8 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
void unclosedTagsWithELWithin() {
|
||||
List<ASTElExpression> scripts = jsp.getNodes(ASTElExpression.class, TEST_TAGS_WITH_EL_WITHIN);
|
||||
assertEquals(2, scripts.size(), "Two EL expressions expected!");
|
||||
assertEquals("expr1", scripts.get(0).getImage(), "Correct content expected!");
|
||||
assertEquals("expr2", scripts.get(1).getImage(), "Correct content expected!");
|
||||
assertEquals("expr1", scripts.get(0).getContent(), "Correct content expected!");
|
||||
assertEquals("expr2", scripts.get(1).getContent(), "Correct content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,21 +242,21 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
void mixedExpressions() {
|
||||
List<ASTJspExpression> exprs = jsp.getNodes(ASTJspExpression.class, TEST_TAGS_WITH_MIXED_EXPRESSIONS);
|
||||
assertEquals(1, exprs.size(), "One JSP expression expected!");
|
||||
assertEquals("expr", exprs.iterator().next().getImage(), "Image of expression should be \"expr\"");
|
||||
assertEquals("expr", exprs.iterator().next().getContent(), "Image of expression should be \"expr\"");
|
||||
List<ASTElExpression> els = jsp.getNodes(ASTElExpression.class, TEST_TAGS_WITH_MIXED_EXPRESSIONS);
|
||||
assertEquals(2, els.size(), "Two EL expression expected!");
|
||||
assertEquals("expr", els.iterator().next().getImage(), "Image of el should be \"expr\"");
|
||||
assertEquals("expr", els.iterator().next().getContent(), "Image of el should be \"expr\"");
|
||||
|
||||
List<ASTUnparsedText> unparsedtexts = jsp.getNodes(ASTUnparsedText.class, TEST_TAGS_WITH_MIXED_EXPRESSIONS);
|
||||
assertEquals(2, unparsedtexts.size(), "Two unparsed texts expected!");
|
||||
assertEquals(" aaa ", unparsedtexts.get(0).getImage(), "Image of text should be \" aaa \"");
|
||||
assertEquals(" \\${expr} ", unparsedtexts.get(1).getImage(), "Image of text should be \"\\${expr}\"");
|
||||
assertEquals(" aaa ", unparsedtexts.get(0).getContent(), "Image of text should be \" aaa \"");
|
||||
assertEquals(" \\${expr} ", unparsedtexts.get(1).getContent(), "Image of text should be \"\\${expr}\"");
|
||||
|
||||
// ASTText should contain the text between two tags.
|
||||
List<ASTText> texts = jsp.getNodes(ASTText.class, TEST_TAGS_WITH_MIXED_EXPRESSIONS);
|
||||
assertEquals(2, texts.size(), "Two regular texts expected!");
|
||||
assertEquals(" \\${expr} ", texts.get(1).getImage(), "Image of text should be \"\\${expr}\"");
|
||||
assertEquals(" aaa ${expr}#{expr}", texts.get(0).getImage(), "Image of text should be all text between two nodes"
|
||||
assertEquals(" \\${expr} ", texts.get(1).getContent(), "Image of text should be \"\\${expr}\"");
|
||||
assertEquals(" aaa ${expr}#{expr}", texts.get(0).getContent(), "Image of text should be all text between two nodes"
|
||||
+ " \" aaa ${expr}#{expr} \"");
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTJspExpression> scripts = jsp.getNodes(ASTJspExpression.class, TEST_TAGS_WITH_EXPRESSION_WITHIN);
|
||||
assertEquals(2, scripts.size(), "Two JSP expressions expected!");
|
||||
ASTJspExpression script = scripts.iterator().next();
|
||||
assertEquals("expr", script.getImage(), "Correct content expected!");
|
||||
assertEquals("expr", script.getContent(), "Correct content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,7 +283,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTText> scripts = jsp.getNodes(ASTText.class, TEST_TEXT_WITH_UNOPENED_TAG);
|
||||
assertEquals(2, scripts.size(), "Two text chunks expected!");
|
||||
ASTText script = scripts.iterator().next();
|
||||
assertEquals("$", script.getImage(), "Correct content expected!");
|
||||
assertEquals("$", script.getContent(), "Correct content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,7 +297,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTText> scripts = jsp.getNodes(ASTText.class, TEST_MULTIPLE_CLOSING_TAGS);
|
||||
assertEquals(4, scripts.size(), "Four text chunks expected!");
|
||||
ASTText script = scripts.iterator().next();
|
||||
assertEquals(" some text ", script.getImage(), "Correct content expected!");
|
||||
assertEquals(" some text ", script.getContent(), "Correct content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,7 +321,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTAttributeValue> attributes = jsp.getNodes(ASTAttributeValue.class, TEST_QUOTE_EL);
|
||||
assertEquals(1, attributes.size(), "One attribute expected!");
|
||||
ASTAttributeValue attr = attributes.iterator().next();
|
||||
assertEquals("${something}", attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
assertEquals("${something}", attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -329,7 +329,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTAttributeValue> attributes = jsp.getNodes(ASTAttributeValue.class, TEST_QUOTE_EXPRESSION);
|
||||
assertEquals(1, attributes.size(), "One attribute expected!");
|
||||
ASTAttributeValue attr = attributes.iterator().next();
|
||||
assertEquals("<%=something%>", attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
assertEquals("<%=something%>", attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -339,7 +339,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
assertEquals(1, attributes.size(), "One attribute expected!");
|
||||
ASTAttributeValue attr = attributes.iterator().next();
|
||||
assertEquals("<bean:write name=\"x\" property=\"z\">",
|
||||
attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,7 +350,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTAttributeValue> attributes = jsp.getNodes(ASTAttributeValue.class, TEST_NO_QUOTE_ATTR);
|
||||
assertEquals(1, attributes.size(), "One attribute expected!");
|
||||
ASTAttributeValue attr = attributes.iterator().next();
|
||||
assertEquals("yes|", attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
assertEquals("yes|", attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,12 +362,12 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
assertEquals(2, attributes.size(), "two attributes expected!");
|
||||
Iterator<ASTAttributeValue> iterator = attributes.iterator();
|
||||
ASTAttributeValue attr2 = iterator.next();
|
||||
if ("url".equals(attr2.getImage())) {
|
||||
if ("url".equals(attr2.getValue())) {
|
||||
// we have to employ this nasty work-around
|
||||
// in order to ensure that we check the proper attribute
|
||||
attr2 = iterator.next();
|
||||
}
|
||||
assertEquals("${something}", attr2.getImage(), "Expected to detect proper value for EL in attribute!");
|
||||
assertEquals("${something}", attr2.getValue(), "Expected to detect proper value for EL in attribute!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -379,7 +379,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTAttributeValue> attributes = jsp.getNodes(ASTAttributeValue.class, TEST_NO_QUOTE_ATTR_WITH_EXPRESSION);
|
||||
assertEquals(1, attributes.size(), "One attribute expected!");
|
||||
ASTAttributeValue attr = attributes.iterator().next();
|
||||
assertEquals("<%=something%>", attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
assertEquals("<%=something%>", attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,12 +391,12 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
assertEquals(2, attributes.size(), "two attributes expected!");
|
||||
Iterator<ASTAttributeValue> iterator = attributes.iterator();
|
||||
ASTAttributeValue attr = iterator.next();
|
||||
if ("http://someHost:/some_URL".equals(attr.getImage())) {
|
||||
if ("http://someHost:/some_URL".equals(attr.getValue())) {
|
||||
// we have to employ this nasty work-around
|
||||
// in order to ensure that we check the proper attribute
|
||||
attr = iterator.next();
|
||||
}
|
||||
assertEquals("", attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
assertEquals("", attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -408,12 +408,12 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
assertEquals(2, attributes.size(), "One attribute expected!");
|
||||
Iterator<ASTAttributeValue> iterator = attributes.iterator();
|
||||
ASTAttributeValue attr = iterator.next();
|
||||
if ("http://someHost:/some_URL".equals(attr.getImage())) {
|
||||
if ("http://someHost:/some_URL".equals(attr.getValue())) {
|
||||
// we have to employ this nasty work-around
|
||||
// in order to ensure that we check the proper attribute
|
||||
attr = iterator.next();
|
||||
}
|
||||
assertEquals("\n", attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
assertEquals("\n", attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
assertEquals(1, attributes.size(), "One attribute expected!");
|
||||
Iterator<ASTAttributeValue> iterator = attributes.iterator();
|
||||
ASTAttributeValue attr = iterator.next();
|
||||
assertEquals("\t", attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
assertEquals("\t", attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
|
||||
}
|
||||
|
||||
@@ -439,7 +439,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTAttributeValue> attributes = jsp.getNodes(ASTAttributeValue.class, TEST_NO_QUOTE_ATTR_WITH_MALFORMED_EXPR);
|
||||
assertEquals(1, attributes.size(), "One attribute expected!");
|
||||
ASTAttributeValue attr = attributes.iterator().next();
|
||||
assertEquals("<%=something", attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
assertEquals("<%=something", attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,7 +453,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
assertEquals(1, attributes.size(), "One attribute expected!");
|
||||
|
||||
ASTAttributeValue attr = attributes.iterator().next();
|
||||
assertEquals("<% String a = \"1\";%>", attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
assertEquals("<% String a = \"1\";%>", attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -468,7 +468,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
assertEquals(1, attributes.size(), "One attribute expected!");
|
||||
|
||||
ASTAttributeValue attr = attributes.iterator().next();
|
||||
assertEquals("<% String a = \"1\";%>", attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
assertEquals("<% String a = \"1\";%>", attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -483,7 +483,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
assertEquals(1, attributes.size(), "One attribute expected!");
|
||||
|
||||
ASTAttributeValue attr = attributes.iterator().next();
|
||||
assertEquals("<% String a = \"1\";%>", attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
assertEquals("<% String a = \"1\";%>", attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -496,7 +496,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTAttributeValue> attributes = jsp.getNodes(ASTAttributeValue.class, TEST_NO_QUOTE_ATTR_WITH_DOLLAR);
|
||||
assertEquals(2, attributes.size(), "One attribute expected!");
|
||||
ASTAttributeValue attr = attributes.iterator().next();
|
||||
assertEquals("${something", attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
assertEquals("${something", attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -509,7 +509,7 @@ class JspDocStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTAttributeValue> attributes = jsp.getNodes(ASTAttributeValue.class, TEST_NO_QUOTE_ATTR_WITH_HASH);
|
||||
assertEquals(1, attributes.size(), "One attribute expected!");
|
||||
ASTAttributeValue attr = attributes.iterator().next();
|
||||
assertEquals("#{something", attr.getImage(), "Expected to detect proper value for attribute!");
|
||||
assertEquals("#{something", attr.getValue(), "Expected to detect proper value for attribute!");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -20,7 +20,7 @@ class JspPageStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTJspComment> comments = jsp.getNodes(ASTJspComment.class, JSP_COMMENT);
|
||||
assertEquals(1, comments.size(), "One comment expected!");
|
||||
ASTJspComment comment = comments.iterator().next();
|
||||
assertEquals("some comment", comment.getImage(), "Correct comment content expected!");
|
||||
assertEquals("some comment", comment.getContent(), "Correct comment content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ class JspPageStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTJspDeclaration> declarations = jsp.getNodes(ASTJspDeclaration.class, JSP_DECLARATION);
|
||||
assertEquals(1, declarations.size(), "One declaration expected!");
|
||||
ASTJspDeclaration declaration = declarations.iterator().next();
|
||||
assertEquals("String someString = \"s\";", declaration.getImage(), "Correct declaration content expected!");
|
||||
assertEquals("String someString = \"s\";", declaration.getContent(), "Correct declaration content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ class JspPageStyleTest extends AbstractJspNodesTst {
|
||||
assertEquals(1, scriptlets.size(), "One scriptlet expected!");
|
||||
ASTJspScriptlet scriptlet = scriptlets.iterator().next();
|
||||
assertEquals("someString = someString + \"suffix\";",
|
||||
scriptlet.getImage(), "Correct scriptlet content expected!");
|
||||
scriptlet.getContent(), "Correct scriptlet content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +79,7 @@ class JspPageStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTJspExpression> expressions = jsp.getNodes(ASTJspExpression.class, JSP_EXPRESSION);
|
||||
assertEquals(1, expressions.size(), "One expression expected!");
|
||||
ASTJspExpression expression = expressions.iterator().next();
|
||||
assertEquals("someString", expression.getImage(), "Correct expression content expected!");
|
||||
assertEquals("someString", expression.getContent(), "Correct expression content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ class JspPageStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTJspExpressionInAttribute> expressions = jsp.getNodes(ASTJspExpressionInAttribute.class, JSP_EXPRESSION_IN_ATTRIBUTE);
|
||||
assertEquals(1, expressions.size(), "One expression expected!");
|
||||
ASTJspExpressionInAttribute expression = expressions.iterator().next();
|
||||
assertEquals("style.getClass()", expression.getImage(), "Correct expression content expected!");
|
||||
assertEquals("style.getClass()", expression.getContent(), "Correct expression content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ class JspPageStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTElExpression> expressions = jsp.getNodes(ASTElExpression.class, JSP_EL_EXPRESSION);
|
||||
assertEquals(1, expressions.size(), "One expression expected!");
|
||||
ASTElExpression expression = expressions.iterator().next();
|
||||
assertEquals("myBean.get(\"${ World }\")", expression.getImage(), "Correct expression content expected!");
|
||||
assertEquals("myBean.get(\"${ World }\")", expression.getContent(), "Correct expression content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ class JspPageStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTElExpression> expressions = jsp.getNodes(ASTElExpression.class, JSP_EL_EXPRESSION_IN_ATTRIBUTE);
|
||||
assertEquals(1, expressions.size(), "One expression expected!");
|
||||
ASTElExpression expression = expressions.iterator().next();
|
||||
assertEquals("myValidator.find(\"'jsp'\")", expression.getImage(), "Correct expression content expected!");
|
||||
assertEquals("myValidator.find(\"'jsp'\")", expression.getContent(), "Correct expression content expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +123,7 @@ class JspPageStyleTest extends AbstractJspNodesTst {
|
||||
List<ASTValueBinding> valueBindings = jsp.getNodes(ASTValueBinding.class, JSF_VALUE_BINDING);
|
||||
assertEquals(1, valueBindings.size(), "One value binding expected!");
|
||||
ASTValueBinding valueBinding = valueBindings.iterator().next();
|
||||
assertEquals("myValidator.find(\"'jsf'\")", valueBinding.getImage(), "Correct expression content expected!");
|
||||
assertEquals("myValidator.find(\"'jsf'\")", valueBinding.getContent(), "Correct expression content expected!");
|
||||
}
|
||||
|
||||
private static final String JSP_COMMENT = "<html> <%-- some comment --%> </html>";
|
||||
|
||||
Reference in New Issue
Block a user