Skip to content

Commit

Permalink
TryStatement.RESOURCES_PROPERTY has been deprecated
Browse files Browse the repository at this point in the history
breadthFirstEnumeration() returns Enumeration<TreeNode> instead of Enumeration<DefaultMutableTreeNode>
  • Loading branch information
tsantalis committed Nov 20, 2022
1 parent b104d0e commit 2cb13f8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
13 changes: 7 additions & 6 deletions src/gr/uom/java/ast/IfStatementExpressionAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Set;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;

import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jdt.core.dom.InfixExpression;
Expand Down Expand Up @@ -268,9 +269,9 @@ else if(leaf.getPreviousSibling() != null) {
}

public boolean allParentNodesAreConditionalAndOperators() {
Enumeration<DefaultMutableTreeNode> enumeration = root.breadthFirstEnumeration();
Enumeration<TreeNode> enumeration = root.breadthFirstEnumeration();
while(enumeration.hasMoreElements()) {
DefaultMutableTreeNode node = enumeration.nextElement();
DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumeration.nextElement();
if(!node.isLeaf()) {
InfixExpression.Operator operator = (InfixExpression.Operator)node.getUserObject();
if(!operator.equals(InfixExpression.Operator.CONDITIONAL_AND))
Expand All @@ -281,9 +282,9 @@ public boolean allParentNodesAreConditionalAndOperators() {
}

public boolean allParentNodesAreConditionalOrOperators() {
Enumeration<DefaultMutableTreeNode> enumeration = root.breadthFirstEnumeration();
Enumeration<TreeNode> enumeration = root.breadthFirstEnumeration();
while(enumeration.hasMoreElements()) {
DefaultMutableTreeNode node = enumeration.nextElement();
DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumeration.nextElement();
if(!node.isLeaf()) {
InfixExpression.Operator operator = (InfixExpression.Operator)node.getUserObject();
if(!operator.equals(InfixExpression.Operator.CONDITIONAL_OR))
Expand All @@ -295,9 +296,9 @@ public boolean allParentNodesAreConditionalOrOperators() {

public int getNumberOfConditionalOperatorNodes() {
int counter = 0;
Enumeration<DefaultMutableTreeNode> enumeration = root.breadthFirstEnumeration();
Enumeration<TreeNode> enumeration = root.breadthFirstEnumeration();
while(enumeration.hasMoreElements()) {
DefaultMutableTreeNode node = enumeration.nextElement();
DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumeration.nextElement();
if(!node.isLeaf()) {
counter++;
}
Expand Down
6 changes: 4 additions & 2 deletions src/gr/uom/java/ast/delegation/DelegationTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import gr.uom.java.ast.*;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;

import java.util.Enumeration;
import java.util.List;
import java.util.ArrayList;
Expand Down Expand Up @@ -48,9 +50,9 @@ private boolean existsNode(Object[] path, MethodObject mo) {
return false;
}

private boolean existsNode(Enumeration<DefaultMutableTreeNode> children, MethodObject mo) {
private boolean existsNode(Enumeration<TreeNode> children, MethodObject mo) {
while(children.hasMoreElements()) {
DefaultMutableTreeNode child = children.nextElement();
DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement();
MethodObject childMethodObject = (MethodObject)child.getUserObject();
if(childMethodObject.equals(mo))
return true;
Expand Down
14 changes: 8 additions & 6 deletions src/gr/uom/java/ast/inheritance/InheritanceTree.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gr.uom.java.ast.inheritance;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;

import java.util.Enumeration;
import java.util.LinkedHashSet;
import java.util.Set;
Expand All @@ -23,9 +25,9 @@ public DefaultMutableTreeNode getRootNode() {
}

public boolean contains(String nodeName) {
Enumeration<DefaultMutableTreeNode> e = rootNode.breadthFirstEnumeration();
Enumeration<TreeNode> e = rootNode.breadthFirstEnumeration();
while(e.hasMoreElements()) {
DefaultMutableTreeNode node = e.nextElement();
DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
if(node.getUserObject().equals(nodeName)) {
return true;
}
Expand All @@ -35,9 +37,9 @@ public boolean contains(String nodeName) {

public DefaultMutableTreeNode getNode(String nodeName) {
if(rootNode != null) {
Enumeration<DefaultMutableTreeNode> e = rootNode.breadthFirstEnumeration();
Enumeration<TreeNode> e = rootNode.breadthFirstEnumeration();
while(e.hasMoreElements()) {
DefaultMutableTreeNode node = e.nextElement();
DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
if(node.getUserObject().equals(nodeName)) {
return node;
}
Expand Down Expand Up @@ -70,9 +72,9 @@ public void addChildRootNodeToParent(DefaultMutableTreeNode childRootNode, Strin

public TreeMap<Integer, Set<String>> getLeavesByLevel() {
TreeMap<Integer, Set<String>> levelMap = new TreeMap<Integer, Set<String>>();
Enumeration<DefaultMutableTreeNode> e = rootNode.breadthFirstEnumeration();
Enumeration<TreeNode> e = rootNode.breadthFirstEnumeration();
while(e.hasMoreElements()) {
DefaultMutableTreeNode node = e.nextElement();
DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
if(node.isLeaf()) {
int level = node.getLevel();
if(levelMap.containsKey(level)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2770,7 +2770,7 @@ else if(oldStatement instanceof SynchronizedStatement) {
else if(oldStatement instanceof TryStatement) {
TryStatement oldTryStatement = (TryStatement)oldStatement;
TryStatement newTryStatement = ast.newTryStatement();
ListRewrite resourceRewrite = sourceRewriter.getListRewrite(newTryStatement, TryStatement.RESOURCES_PROPERTY);
ListRewrite resourceRewrite = sourceRewriter.getListRewrite(newTryStatement, TryStatement.RESOURCES2_PROPERTY);
List<VariableDeclarationExpression> resources = oldTryStatement.resources();
for(VariableDeclarationExpression expression : resources) {
Expression newResourceExpression = (Expression)processASTNodeWithDifferences(ast, sourceRewriter, expression, nodeMapping);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ protected ListRewrite createTryStatementIfNeeded(ASTRewrite sourceRewriter, AST

protected TryStatement copyTryStatement(ASTRewrite sourceRewriter, AST ast, TryStatement tryStatementParent) {
TryStatement newTryStatement = ast.newTryStatement();
ListRewrite resourceRewrite = sourceRewriter.getListRewrite(newTryStatement, TryStatement.RESOURCES_PROPERTY);
ListRewrite resourceRewrite = sourceRewriter.getListRewrite(newTryStatement, TryStatement.RESOURCES2_PROPERTY);
List<VariableDeclarationExpression> resources = tryStatementParent.resources();
for(VariableDeclarationExpression expression : resources) {
resourceRewrite.insertLast(expression, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.Set;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
Expand Down Expand Up @@ -477,9 +478,9 @@ else if(variableDeclarationFragment.getParent() instanceof FieldDeclaration) {
List<ArrayList<Statement>> typeCheckStatements = typeCheckElimination.getTypeCheckStatements();
List<String> subclassNames = typeCheckElimination.getSubclassNames();
DefaultMutableTreeNode root = typeCheckElimination.getExistingInheritanceTree().getRootNode();
Enumeration<DefaultMutableTreeNode> enumeration = root.children();
Enumeration<TreeNode> enumeration = root.children();
while(enumeration.hasMoreElements()) {
DefaultMutableTreeNode child = enumeration.nextElement();
DefaultMutableTreeNode child = (DefaultMutableTreeNode) enumeration.nextElement();
String childClassName = (String)child.getUserObject();
if(!subclassNames.contains(childClassName))
subclassNames.add(childClassName);
Expand Down

0 comments on commit 2cb13f8

Please sign in to comment.