Next step towards compile ;-)
This commit is contained in:
@@ -12,7 +12,7 @@ public abstract class AbstractApexNode<T extends AstNode> extends AbstractNode i
|
||||
protected final T node;
|
||||
|
||||
public AbstractApexNode(T node) {
|
||||
super(node.getType());
|
||||
super(node.getDefiningType().hashCode());
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@@ -41,17 +41,4 @@ public abstract class AbstractApexNode<T extends AstNode> extends AbstractNode i
|
||||
public T getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
public String getJsDoc() {
|
||||
return node.getJsDoc();
|
||||
}
|
||||
|
||||
public boolean hasSideEffects() {
|
||||
return node.hasSideEffects();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return node.shortName();
|
||||
}
|
||||
}
|
||||
|
@@ -23,14 +23,4 @@ public interface ApexNode<T extends AstNode> extends Node {
|
||||
* Get the underlying Rhino AST node.
|
||||
*/
|
||||
T getNode();
|
||||
|
||||
/**
|
||||
* Get the JsDoc associated with the given node. If there is no JsDoc on
|
||||
* this node, it may be associated with a parent node, on more representative
|
||||
* of the entire expression containing this node.
|
||||
* @return The JsDoc comment for the node, may be <code>null</code>.
|
||||
*/
|
||||
String getJsDoc();
|
||||
|
||||
boolean hasSideEffects();
|
||||
}
|
||||
|
@@ -5,13 +5,11 @@ package net.sourceforge.pmd.lang.apex.ast;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||
import net.sourceforge.pmd.lang.apex.ApexParserOptions;
|
||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
@@ -32,8 +30,7 @@ public class ApexParser {
|
||||
}
|
||||
|
||||
protected UserClass parseApex(final String sourceCode) throws ParseException {
|
||||
final Parser parser = null;
|
||||
UserClass astRoot = parser.parse(sourceCode);
|
||||
UserClass astRoot = null; // TODO How to use Jorje to get AST root nodes?
|
||||
return astRoot;
|
||||
}
|
||||
|
||||
@@ -41,10 +38,10 @@ public class ApexParser {
|
||||
try {
|
||||
final String sourceCode = IOUtils.toString(reader);
|
||||
final UserClass astRoot = parseApex(sourceCode);
|
||||
final ApexTreeBuilder treeBuilder = new ApexTreeBuilder(sourceCode);
|
||||
ApexNode<UserClass> tree = treeBuilder.build(astRoot);
|
||||
|
||||
final ApexTreeBuilder treeBuilder = new ApexTreeBuilder();
|
||||
suppressMap = new HashMap<>();
|
||||
|
||||
ApexNode<UserClass> tree = treeBuilder.build(astRoot);
|
||||
return tree;
|
||||
} catch (IOException e) {
|
||||
throw new ParseException(e);
|
||||
|
@@ -17,28 +17,28 @@ import net.sourceforge.pmd.lang.rule.XPathRule;
|
||||
|
||||
public class ApexRuleChainVisitor extends AbstractRuleChainVisitor {
|
||||
|
||||
protected void indexNodes(List<Node> nodes, RuleContext ctx) {
|
||||
// Visit Nodes in DFS order
|
||||
Stack<Node> stack = new Stack<>();
|
||||
stack.addAll(nodes);
|
||||
Collections.reverse(stack);
|
||||
while (!stack.isEmpty()) {
|
||||
Node node = stack.pop();
|
||||
indexNode(node);
|
||||
if (node.jjtGetNumChildren() > 0) {
|
||||
for (int i = node.jjtGetNumChildren() - 1; i >= 0; i--) {
|
||||
stack.push(node.jjtGetChild(i));
|
||||
protected void indexNodes(List<Node> nodes, RuleContext ctx) {
|
||||
// Visit Nodes in DFS order
|
||||
Stack<Node> stack = new Stack<>();
|
||||
stack.addAll(nodes);
|
||||
Collections.reverse(stack);
|
||||
while (!stack.isEmpty()) {
|
||||
Node node = stack.pop();
|
||||
indexNode(node);
|
||||
if (node.jjtGetNumChildren() > 0) {
|
||||
for (int i = node.jjtGetNumChildren() - 1; i >= 0; i--) {
|
||||
stack.push(node.jjtGetChild(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void visit(Rule rule, Node node, RuleContext ctx) {
|
||||
// Rule better either be a ApexParserVisitor, or a XPathRule
|
||||
if (rule instanceof XPathRule) {
|
||||
((XPathRule) rule).evaluate(node, ctx);
|
||||
} else {
|
||||
((ApexNode<?>) node).jjtAccept((ApexParserVisitor) rule, ctx);
|
||||
protected void visit(Rule rule, Node node, RuleContext ctx) {
|
||||
// Rule better either be a ApexParserVisitor, or a XPathRule
|
||||
if (rule instanceof XPathRule) {
|
||||
((XPathRule) rule).evaluate(node, ctx);
|
||||
} else {
|
||||
((ApexNode<?>) node).jjtAccept((ApexParserVisitor) rule, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user