forked from jasder/antlr
refine getChildren() method to narrow return type.
This commit is contained in:
parent
cbd6e17925
commit
76418c2b9b
|
@ -34,12 +34,11 @@ import org.antlr.v4.runtime.misc.Nullable;
|
|||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||
import org.antlr.v4.runtime.tree.RuleNode;
|
||||
import org.antlr.v4.runtime.tree.Tree;
|
||||
import org.antlr.v4.runtime.tree.Trees;
|
||||
import org.antlr.v4.runtime.tree.gui.TreeViewer;
|
||||
|
||||
import javax.print.PrintException;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -152,7 +151,7 @@ public class RuleContext implements RuleNode {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Tree> getChildren() {
|
||||
public List<? extends ParseTree> getChildren() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ import org.antlr.v4.runtime.Parser;
|
|||
import org.antlr.v4.runtime.RuleContext;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** An interface to access the tree of {@link RuleContext} objects created
|
||||
* during a parse that makes the data structure look like a simple parse tree.
|
||||
* This node represents both internal nodes, rule invocations,
|
||||
|
@ -48,6 +50,11 @@ public interface ParseTree extends SyntaxTree {
|
|||
@Override
|
||||
ParseTree getChild(int i);
|
||||
|
||||
/** Return ordered list of all children of this node; redefine to
|
||||
* refine type.
|
||||
*/
|
||||
List<? extends ParseTree> getChildren();
|
||||
|
||||
/** The {@link ParseTreeVisitor} needs a double dispatch method. */
|
||||
public <T> T accept(ParseTreeVisitor<? extends T> visitor);
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public class TerminalNodeImpl implements TerminalNode {
|
|||
public int getChildCount() { return 0; }
|
||||
|
||||
@Override
|
||||
public List<? extends Tree> getChildren() {
|
||||
public List<? extends ParseTree> getChildren() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue