forked from jasder/antlr
v4: remove unnecessary casts
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9362]
This commit is contained in:
parent
d01c583e36
commit
1da1fe8002
|
@ -95,7 +95,7 @@ public abstract class BaseAST implements AST {
|
||||||
if ( t==null ) {
|
if ( t==null ) {
|
||||||
return; // do nothing upon addChild(null)
|
return; // do nothing upon addChild(null)
|
||||||
}
|
}
|
||||||
BaseAST childTree = (BaseAST)t;
|
BaseAST childTree = t;
|
||||||
if ( childTree.isNil() ) { // t is an empty node possibly with children
|
if ( childTree.isNil() ) { // t is an empty node possibly with children
|
||||||
if ( this.children!=null && this.children == childTree.children ) {
|
if ( this.children!=null && this.children == childTree.children ) {
|
||||||
throw new RuntimeException("attempt to add child list to itself");
|
throw new RuntimeException("attempt to add child list to itself");
|
||||||
|
@ -240,7 +240,7 @@ public abstract class BaseAST implements AST {
|
||||||
public void freshenParentAndChildIndexesDeeply(int offset) {
|
public void freshenParentAndChildIndexesDeeply(int offset) {
|
||||||
int n = getChildCount();
|
int n = getChildCount();
|
||||||
for (int c = offset; c < n; c++) {
|
for (int c = offset; c < n; c++) {
|
||||||
BaseAST child = (BaseAST)getChild(c);
|
BaseAST child = getChild(c);
|
||||||
child.setChildIndex(c);
|
child.setChildIndex(c);
|
||||||
child.setParent(this);
|
child.setParent(this);
|
||||||
child.freshenParentAndChildIndexesDeeply();
|
child.freshenParentAndChildIndexesDeeply();
|
||||||
|
|
|
@ -57,7 +57,7 @@ public abstract class BaseASTAdaptor<T extends BaseAST> implements ASTAdaptor<T>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isNil(T tree) {
|
public boolean isNil(T tree) {
|
||||||
return ((AST)tree).isNil();
|
return tree.isNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -96,7 +96,7 @@ public abstract class BaseASTAdaptor<T extends BaseAST> implements ASTAdaptor<T>
|
||||||
@Override
|
@Override
|
||||||
public void addChild(T t, T child) {
|
public void addChild(T t, T child) {
|
||||||
if ( t!=null && child!=null ) {
|
if ( t!=null && child!=null ) {
|
||||||
((BaseAST)t).addChild((BaseAST) child);
|
t.addChild(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,20 +231,20 @@ public abstract class BaseASTAdaptor<T extends BaseAST> implements ASTAdaptor<T>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getChildCount(T t) {
|
public int getChildCount(T t) {
|
||||||
return ((BaseAST)t).getChildCount();
|
return t.getChildCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getUniqueID(T node) {
|
public int getUniqueID(T node) {
|
||||||
if ( treeToUniqueIDMap==null ) {
|
if ( treeToUniqueIDMap==null ) {
|
||||||
treeToUniqueIDMap = new HashMap();
|
treeToUniqueIDMap = new HashMap<BaseAST, Integer>();
|
||||||
}
|
}
|
||||||
Integer prevID = (Integer)treeToUniqueIDMap.get(node);
|
Integer prevID = treeToUniqueIDMap.get(node);
|
||||||
if ( prevID!=null ) {
|
if ( prevID!=null ) {
|
||||||
return prevID;
|
return prevID;
|
||||||
}
|
}
|
||||||
int ID = uniqueNodeID;
|
int ID = uniqueNodeID;
|
||||||
treeToUniqueIDMap.put((BaseAST)node, ID);
|
treeToUniqueIDMap.put(node, ID);
|
||||||
uniqueNodeID++;
|
uniqueNodeID++;
|
||||||
return ID;
|
return ID;
|
||||||
// GC makes these nonunique:
|
// GC makes these nonunique:
|
||||||
|
|
Loading…
Reference in New Issue