Code style cleanup
This commit is contained in:
@@ -12,8 +12,8 @@ import org.apache.commons.io.IOUtils;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.LanguageVersionHandler;
|
||||
import net.sourceforge.pmd.lang.TokenManager;
|
||||
import net.sourceforge.pmd.lang.vf.ast.Token;
|
||||
import net.sourceforge.pmd.lang.vf.VfLanguageModule;
|
||||
import net.sourceforge.pmd.lang.vf.ast.Token;
|
||||
import net.sourceforge.pmd.util.IOUtil;
|
||||
|
||||
/**
|
||||
|
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class ASTAttribute extends AbstractVFNode {
|
||||
|
||||
private String name;
|
||||
|
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class ASTAttributeValue extends AbstractVFNode {
|
||||
public ASTAttributeValue(int id) {
|
||||
super(id);
|
||||
|
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class ASTCData extends AbstractVFNode {
|
||||
public ASTCData(int id) {
|
||||
super(id);
|
||||
|
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class ASTCommentTag extends AbstractVFNode {
|
||||
public ASTCommentTag(int id) {
|
||||
super(id);
|
||||
|
@@ -6,8 +6,6 @@
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.RootNode;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class ASTCompilationUnit extends AbstractVFNode implements RootNode {
|
||||
public ASTCompilationUnit(int id) {
|
||||
|
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class ASTDeclaration extends AbstractVFNode {
|
||||
|
||||
private String name;
|
||||
|
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class ASTDoctypeDeclaration extends AbstractVFNode {
|
||||
|
||||
/**
|
||||
|
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class ASTDoctypeExternalId extends AbstractVFNode {
|
||||
|
||||
/**
|
||||
|
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class ASTElExpression extends AbstractVFNode {
|
||||
public ASTElExpression(int id) {
|
||||
super(id);
|
||||
|
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class ASTElement extends AbstractVFNode {
|
||||
|
||||
/**
|
||||
|
@@ -6,9 +6,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class ASTHtmlScript extends AbstractVFNode {
|
||||
public ASTHtmlScript(int id) {
|
||||
super(id);
|
||||
|
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class ASTText extends AbstractVFNode {
|
||||
public ASTText(int id) {
|
||||
super(id);
|
||||
|
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class ASTUnparsedText extends AbstractVFNode {
|
||||
public ASTUnparsedText(int id) {
|
||||
super(id);
|
||||
|
@@ -5,9 +5,6 @@
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.AbstractNode;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserTreeConstants;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class AbstractVFNode extends AbstractNode implements VfNode {
|
||||
|
||||
|
@@ -4,8 +4,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.ParseException;
|
||||
|
||||
/**
|
||||
* Exception indicating that a syntactic error has been found.
|
||||
*
|
||||
|
@@ -5,7 +5,6 @@
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public interface VfNode extends Node {
|
||||
/**
|
||||
|
@@ -4,8 +4,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public class VfParserVisitorAdapter implements VfParserVisitor {
|
||||
|
||||
public Object visit(VfNode node, Object data) {
|
||||
|
@@ -9,7 +9,6 @@ import java.util.List;
|
||||
import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRule;
|
||||
import net.sourceforge.pmd.lang.rule.ImmutableLanguage;
|
||||
import net.sourceforge.pmd.lang.vf.VfLanguageModule;
|
||||
@@ -27,6 +26,7 @@ import net.sourceforge.pmd.lang.vf.ast.ASTHtmlScript;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTText;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTUnparsedText;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfNode;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
|
||||
public abstract class AbstractVfRule extends AbstractRule implements VfParserVisitor, ImmutableLanguage {
|
||||
|
||||
|
@@ -9,11 +9,11 @@ import java.util.List;
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRuleChainVisitor;
|
||||
import net.sourceforge.pmd.lang.rule.XPathRule;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfNode;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParserVisitorAdapter;
|
||||
|
||||
public class VfRuleChainVisitor extends AbstractRuleChainVisitor {
|
||||
|
@@ -20,9 +20,15 @@ import net.sourceforge.pmd.lang.vf.rule.AbstractVfRule;
|
||||
*/
|
||||
public class VfUnescapeElRule extends AbstractVfRule {
|
||||
|
||||
private static final String APEX_PARAM = "apex:param";
|
||||
private static final String VALUE = "value";
|
||||
private static final String ITEM_VALUE = "itemValue";
|
||||
private static final String ESCAPE = "escape";
|
||||
private static final String APEX_OUTPUT_TEXT = "apex:outputText";
|
||||
private static final String ITEM_ESCAPED = "itemEscaped";
|
||||
private static final String APEX_OUTPUT_TEXT = "apex:outputtext";
|
||||
private static final String APEX_PAGE_MESSAGE = "apex:pagemessage";
|
||||
private static final String APEX_PAGE_MESSAGES = "apex:pagemessages";
|
||||
private static final String APEX_SELECT_OPTION = "apex:selectoption ";
|
||||
private static final String FALSE = "false";
|
||||
|
||||
@Override
|
||||
@@ -33,7 +39,7 @@ public class VfUnescapeElRule extends AbstractVfRule {
|
||||
|
||||
@Override
|
||||
public Object visit(ASTElement node, Object data) {
|
||||
if (node.getName().equalsIgnoreCase(APEX_OUTPUT_TEXT)) {
|
||||
if (doesTagSupportEscaping(node)) {
|
||||
final List<ASTAttribute> attributes = node.findChildrenOfType(ASTAttribute.class);
|
||||
boolean isUnescaped = false;
|
||||
boolean isEL = false;
|
||||
@@ -44,6 +50,7 @@ public class VfUnescapeElRule extends AbstractVfRule {
|
||||
String name = attr.getName();
|
||||
switch (name) {
|
||||
case ESCAPE:
|
||||
case ITEM_ESCAPED:
|
||||
final ASTUnparsedText text = attr.getFirstDescendantOfType(ASTUnparsedText.class);
|
||||
if (text != null) {
|
||||
if (text.getImage().equalsIgnoreCase(FALSE)) {
|
||||
@@ -52,6 +59,7 @@ public class VfUnescapeElRule extends AbstractVfRule {
|
||||
}
|
||||
break;
|
||||
case VALUE:
|
||||
case ITEM_VALUE:
|
||||
final ASTElExpression elInVal = attr.getFirstDescendantOfType(ASTElExpression.class);
|
||||
if (elInVal != null) {
|
||||
isEL = true;
|
||||
@@ -86,10 +94,27 @@ public class VfUnescapeElRule extends AbstractVfRule {
|
||||
return super.visit(node, data);
|
||||
}
|
||||
|
||||
private boolean doesTagSupportEscaping(ASTElement node) {
|
||||
if (node.getName() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (node.getName().toLowerCase()) { // vf is case insensitive?
|
||||
case APEX_OUTPUT_TEXT:
|
||||
case APEX_PAGE_MESSAGE:
|
||||
case APEX_PAGE_MESSAGES:
|
||||
case APEX_SELECT_OPTION:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean hasAnyEL(ASTElement node) {
|
||||
final List<ASTElement> innerElements = node.findChildrenOfType(ASTElement.class);
|
||||
for (ASTElement element : innerElements) {
|
||||
if (element.getName().equalsIgnoreCase("apex:param")) {
|
||||
if (element.getName().equalsIgnoreCase(APEX_PARAM)) {
|
||||
final List<ASTAttribute> innerAttributes = element.findChildrenOfType(ASTAttribute.class);
|
||||
for (ASTAttribute attrib : innerAttributes) {
|
||||
final ASTElExpression elInVal = attrib.getFirstDescendantOfType(ASTElExpression.class);
|
||||
|
@@ -13,7 +13,6 @@ import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.LanguageVersionHandler;
|
||||
import net.sourceforge.pmd.lang.Parser;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.vf.VfLanguageModule;
|
||||
|
||||
/**
|
||||
* @author sergey.gorbaty
|
||||
@@ -23,19 +22,16 @@ public class VfParserTest {
|
||||
|
||||
@Test
|
||||
public void testSingleDoubleQuoteAndEL() {
|
||||
Node node = parse(
|
||||
"<span escape='false' attrib=\"{!call}\">${!yes}</span>");
|
||||
Node node = parse("<span escape='false' attrib=\"{!call}\">${!yes}</span>");
|
||||
Assert.assertNotNull(node);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSingleDoubleQuote() {
|
||||
Node node = parse(
|
||||
"<span escape='false' attrib=\"{!call}\">${yes}</span>");
|
||||
Node node = parse("<span escape='false' attrib=\"{!call}\">${yes}</span>");
|
||||
Assert.assertNotNull(node);
|
||||
}
|
||||
|
||||
|
||||
private Node parse(String code) {
|
||||
LanguageVersionHandler jspLang = LanguageRegistry.getLanguage(VfLanguageModule.NAME).getDefaultVersion()
|
||||
.getLanguageVersionHandler();
|
||||
|
@@ -12,8 +12,6 @@ import java.util.Set;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.JavaCharStream;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfNode;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfParser;
|
||||
|
||||
public abstract class AbstractVfNodesTest {
|
||||
|
||||
|
@@ -10,9 +10,6 @@ import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTElement;
|
||||
import net.sourceforge.pmd.lang.vf.ast.OpenTagRegister;
|
||||
|
||||
public class OpenTagRegisterTest {
|
||||
|
||||
private OpenTagRegister tagList;
|
||||
@@ -112,7 +109,8 @@ public class OpenTagRegisterTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* <a> <x> <a> <b> <b> </z> </a> </x>
|
||||
* <a> <x> <a> <b> <b> </z> </a>
|
||||
* </x>
|
||||
*/
|
||||
@Test
|
||||
public void openedIsolatedTag() {
|
||||
|
@@ -19,17 +19,6 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
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.ASTCommentTag;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTDoctypeDeclaration;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTDoctypeExternalId;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTElExpression;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTElement;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTHtmlScript;
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTText;
|
||||
import net.sourceforge.pmd.lang.vf.ast.VfNode;
|
||||
|
||||
/**
|
||||
* Test parsing of a VF in document style, by checking the generated AST.
|
||||
|
@@ -5,10 +5,10 @@
|
||||
package net.sourceforge.pmd.lang.vf.ast;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import java.util.Set;
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.vf.ast.ASTElExpression;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class VfPageStyleTest extends AbstractVfNodesTest {
|
||||
|
||||
|
Reference in New Issue
Block a user