Removing comment AST nodes for cleaner tree
This commit is contained in:
parent
ee0558a07c
commit
5c8d324230
@ -512,31 +512,22 @@ void PrimaryExpression() #void :
|
||||
PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*
|
||||
}
|
||||
|
||||
void ELSQCommentExpression() #CommentExpression :
|
||||
{
|
||||
StringBuffer content = new StringBuffer();
|
||||
Token t;
|
||||
}
|
||||
void ELSQCommentExpression() #void :
|
||||
{}
|
||||
{
|
||||
<COMMENT_OPEN_SQ> ( t = <COMMENT_INNER_TEXT_SQ> { content.append(t.image); })* <COMMENT_CLOSE_SQ> { jjtThis.setImage(content.toString()); }
|
||||
<COMMENT_OPEN_SQ> ( <COMMENT_INNER_TEXT_SQ> )* <COMMENT_CLOSE_SQ>
|
||||
}
|
||||
|
||||
void ELDQCommentExpression() #CommentExpression :
|
||||
{
|
||||
StringBuffer content = new StringBuffer();
|
||||
Token t;
|
||||
}
|
||||
void ELDQCommentExpression() #void :
|
||||
{}
|
||||
{
|
||||
<COMMENT_OPEN_DQ> ( t = <COMMENT_INNER_TEXT_DQ> { content.append(t.image); })* <COMMENT_CLOSE_DQ> { jjtThis.setImage(content.toString()); }
|
||||
<COMMENT_OPEN_DQ> ( <COMMENT_INNER_TEXT_DQ> )* <COMMENT_CLOSE_DQ>
|
||||
}
|
||||
|
||||
void CommentExpression() :
|
||||
{
|
||||
StringBuffer content = new StringBuffer();
|
||||
Token t;
|
||||
}
|
||||
void CommentExpression() #void :
|
||||
{}
|
||||
{
|
||||
<COMMENT_OPEN_SCRIPT> ( t = <COMMENT_INNER_TEXT_SCRIPT> { content.append(t.image); })* <COMMENT_CLOSE_SCRIPT> { jjtThis.setImage(content.toString()); }
|
||||
<COMMENT_OPEN_SCRIPT> ( <COMMENT_INNER_TEXT_SCRIPT> )* <COMMENT_CLOSE_SCRIPT>
|
||||
}
|
||||
|
||||
void PrimaryPrefix() #void :
|
||||
@ -706,18 +697,10 @@ void Attribute() :
|
||||
)
|
||||
}
|
||||
|
||||
void CommentTag() :
|
||||
void CommentTag() #void :
|
||||
{}
|
||||
{
|
||||
StringBuffer content = new StringBuffer();
|
||||
Token t;
|
||||
}
|
||||
{
|
||||
<COMMENT_START>
|
||||
( t = <COMMENT_TEXT> { content.append(t.image); } )*
|
||||
<COMMENT_END>
|
||||
{
|
||||
jjtThis.setImage(content.toString().trim());
|
||||
}
|
||||
<COMMENT_START> ( <COMMENT_TEXT> )* <COMMENT_END>
|
||||
}
|
||||
|
||||
void Declaration() :
|
||||
|
@ -1,22 +0,0 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
public class ASTCommentExpression extends AbstractVFNode {
|
||||
|
||||
public ASTCommentExpression(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public ASTCommentExpression(VfParser p, int id) {
|
||||
super(p, id);
|
||||
}
|
||||
|
||||
/** Accept the visitor. **/
|
||||
public Object jjtAccept(VfParserVisitor visitor, Object data) {
|
||||
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
/* Generated By:JJTree: Do not edit this line. ASTCommentTag.java */
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
public class ASTCommentTag extends AbstractVFNode {
|
||||
public ASTCommentTag(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public ASTCommentTag(VfParser p, int id) {
|
||||
super(p, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept the visitor. *
|
||||
*/
|
||||
public Object jjtAccept(VfParserVisitor visitor, Object data) {
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
}
|
@ -39,10 +39,6 @@ public class VfParserVisitorAdapter implements VfParserVisitor {
|
||||
return visit((VfNode) node, data);
|
||||
}
|
||||
|
||||
public Object visit(ASTCommentTag node, Object data) {
|
||||
return visit((VfNode) node, data);
|
||||
}
|
||||
|
||||
public Object visit(ASTDeclaration node, Object data) {
|
||||
return visit((VfNode) node, data);
|
||||
}
|
||||
@ -89,8 +85,4 @@ public class VfParserVisitorAdapter implements VfParserVisitor {
|
||||
return visit((VfNode) node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTCommentExpression node, Object data) {
|
||||
return visit((VfNode) node, data);
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,6 @@ import net.sourceforge.pmd.lang.vf.ast.ASTArguments;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTAttribute;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTAttributeValue;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTCData;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTCommentExpression;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTCommentTag;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTContent;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTDeclaration;
|
||||
@ -89,10 +87,6 @@ public abstract class AbstractVfRule extends AbstractRule implements VfParserVis
|
||||
return visit((VfNode) node, data);
|
||||
}
|
||||
|
||||
public Object visit(ASTCommentTag node, Object data) {
|
||||
return visit((VfNode) node, data);
|
||||
}
|
||||
|
||||
public Object visit(ASTDeclaration node, Object data) {
|
||||
return visit((VfNode) node, data);
|
||||
}
|
||||
@ -133,7 +127,4 @@ public abstract class AbstractVfRule extends AbstractRule implements VfParserVis
|
||||
return visit((VfNode) node, data);
|
||||
}
|
||||
|
||||
public Object visit(ASTCommentExpression node, Object data) {
|
||||
return visit((VfNode) node, data);
|
||||
}
|
||||
}
|
||||
|
@ -128,18 +128,6 @@ public class VfDocStyleTest extends AbstractVfNodesTest {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test parsing of a XML comment.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testComment() {
|
||||
Set<ASTCommentTag> comments = getNodes(ASTCommentTag.class, TEST_COMMENT);
|
||||
assertEquals("One comment expected!", 1, comments.size());
|
||||
ASTCommentTag comment = comments.iterator().next();
|
||||
assertEquals("Correct comment content expected!", "comment", comment.getImage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test parsing of HTML <script> element.
|
||||
*/
|
||||
@ -177,12 +165,8 @@ public class VfDocStyleTest extends AbstractVfNodesTest {
|
||||
ASTElExpression elExpr = element.getFirstDescendantOfType(ASTElExpression.class);
|
||||
ASTIdentifier id = elExpr.getFirstDescendantOfType(ASTIdentifier.class);
|
||||
assertEquals("Correct identifier expected", "init", id.getImage());
|
||||
ASTCommentExpression comment = elExpr.getFirstDescendantOfType(ASTCommentExpression.class);
|
||||
assertEquals("Correct comment expected!", "comment here", comment.getImage());
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test parsing of EL in attribute of an element that also has a comment.
|
||||
*/
|
||||
@ -194,12 +178,9 @@ public class VfDocStyleTest extends AbstractVfNodesTest {
|
||||
ASTElExpression elExpr = element.getFirstDescendantOfType(ASTElExpression.class);
|
||||
ASTIdentifier id = elExpr.getFirstDescendantOfType(ASTIdentifier.class);
|
||||
assertEquals("Correct identifier expected", "init", id.getImage());
|
||||
ASTCommentExpression comment = elExpr.getFirstDescendantOfType(ASTCommentExpression.class);
|
||||
assertEquals("Correct comment expected!", "comment here", comment.getImage());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test parsing of EL in HTML <script> element.
|
||||
*/
|
||||
@ -226,8 +207,6 @@ public class VfDocStyleTest extends AbstractVfNodesTest {
|
||||
ASTText text = script.getFirstChildOfType(ASTText.class);
|
||||
assertEquals("Correct script content expected!", "vartext=", text.getImage());
|
||||
ASTElExpression el = script.getFirstChildOfType(ASTElExpression.class);
|
||||
List<ASTCommentExpression> comments = el.findDescendantsOfType(ASTCommentExpression.class);
|
||||
assertEquals("Correct comment size expected!", 2, comments.size());
|
||||
ASTIdentifier id = el.getFirstDescendantOfType(ASTIdentifier.class);
|
||||
assertEquals("Correct EL content expected!", "elInScript", id.getImage());
|
||||
}
|
||||
@ -288,8 +267,7 @@ public class VfDocStyleTest extends AbstractVfNodesTest {
|
||||
ASTHtmlScript next = script.iterator().next();
|
||||
ASTText text = next.getFirstChildOfType(ASTText.class);
|
||||
assertTrue(text.getImage().contains("<!--"));
|
||||
Set<ASTCommentTag> comments = getNodes(ASTCommentTag.class, TEST_COMPLEX_SCRIPT);
|
||||
assertEquals("One comment expected!", 1, comments.size());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -712,8 +690,6 @@ public class VfDocStyleTest extends AbstractVfNodesTest {
|
||||
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" "
|
||||
+ "\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n" + "<greeting>Hello, world!</greeting>";
|
||||
|
||||
private static final String TEST_COMMENT = "<html><!-- comment --></html>";
|
||||
|
||||
private static final String TEST_ATTRIBUTE_VALUE_CONTAINING_HASH = "<tag:if something=\"#yes#\" foo=\"CREATE\"> <a href=\"#\">foo</a> </tag:if>";
|
||||
|
||||
private static final String TEST_HTML_SCRIPT = "<html><head><script>Script!</script></head></html>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user