From 2cb13f87b5016f64778b9154367f06727cc12ce5 Mon Sep 17 00:00:00 2001 From: tsantalis Date: Sun, 20 Nov 2022 07:27:00 -0500 Subject: [PATCH] TryStatement.RESOURCES_PROPERTY has been deprecated breadthFirstEnumeration() returns Enumeration instead of Enumeration --- .../java/ast/IfStatementExpressionAnalyzer.java | 13 +++++++------ src/gr/uom/java/ast/delegation/DelegationTree.java | 6 ++++-- .../uom/java/ast/inheritance/InheritanceTree.java | 14 ++++++++------ .../manipulators/ExtractCloneRefactoring.java | 2 +- .../ExtractMethodFragmentRefactoring.java | 2 +- .../ReplaceConditionalWithPolymorphism.java | 5 +++-- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/gr/uom/java/ast/IfStatementExpressionAnalyzer.java b/src/gr/uom/java/ast/IfStatementExpressionAnalyzer.java index f191d7548..42fc044f1 100644 --- a/src/gr/uom/java/ast/IfStatementExpressionAnalyzer.java +++ b/src/gr/uom/java/ast/IfStatementExpressionAnalyzer.java @@ -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; @@ -268,9 +269,9 @@ else if(leaf.getPreviousSibling() != null) { } public boolean allParentNodesAreConditionalAndOperators() { - Enumeration enumeration = root.breadthFirstEnumeration(); + Enumeration 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)) @@ -281,9 +282,9 @@ public boolean allParentNodesAreConditionalAndOperators() { } public boolean allParentNodesAreConditionalOrOperators() { - Enumeration enumeration = root.breadthFirstEnumeration(); + Enumeration 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)) @@ -295,9 +296,9 @@ public boolean allParentNodesAreConditionalOrOperators() { public int getNumberOfConditionalOperatorNodes() { int counter = 0; - Enumeration enumeration = root.breadthFirstEnumeration(); + Enumeration enumeration = root.breadthFirstEnumeration(); while(enumeration.hasMoreElements()) { - DefaultMutableTreeNode node = enumeration.nextElement(); + DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumeration.nextElement(); if(!node.isLeaf()) { counter++; } diff --git a/src/gr/uom/java/ast/delegation/DelegationTree.java b/src/gr/uom/java/ast/delegation/DelegationTree.java index c91809556..4b260aad8 100644 --- a/src/gr/uom/java/ast/delegation/DelegationTree.java +++ b/src/gr/uom/java/ast/delegation/DelegationTree.java @@ -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; @@ -48,9 +50,9 @@ private boolean existsNode(Object[] path, MethodObject mo) { return false; } - private boolean existsNode(Enumeration children, MethodObject mo) { + private boolean existsNode(Enumeration 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; diff --git a/src/gr/uom/java/ast/inheritance/InheritanceTree.java b/src/gr/uom/java/ast/inheritance/InheritanceTree.java index c105e21fb..48e1a9fe0 100644 --- a/src/gr/uom/java/ast/inheritance/InheritanceTree.java +++ b/src/gr/uom/java/ast/inheritance/InheritanceTree.java @@ -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; @@ -23,9 +25,9 @@ public DefaultMutableTreeNode getRootNode() { } public boolean contains(String nodeName) { - Enumeration e = rootNode.breadthFirstEnumeration(); + Enumeration e = rootNode.breadthFirstEnumeration(); while(e.hasMoreElements()) { - DefaultMutableTreeNode node = e.nextElement(); + DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement(); if(node.getUserObject().equals(nodeName)) { return true; } @@ -35,9 +37,9 @@ public boolean contains(String nodeName) { public DefaultMutableTreeNode getNode(String nodeName) { if(rootNode != null) { - Enumeration e = rootNode.breadthFirstEnumeration(); + Enumeration e = rootNode.breadthFirstEnumeration(); while(e.hasMoreElements()) { - DefaultMutableTreeNode node = e.nextElement(); + DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement(); if(node.getUserObject().equals(nodeName)) { return node; } @@ -70,9 +72,9 @@ public void addChildRootNodeToParent(DefaultMutableTreeNode childRootNode, Strin public TreeMap> getLeavesByLevel() { TreeMap> levelMap = new TreeMap>(); - Enumeration e = rootNode.breadthFirstEnumeration(); + Enumeration 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)) { diff --git a/src/gr/uom/java/jdeodorant/refactoring/manipulators/ExtractCloneRefactoring.java b/src/gr/uom/java/jdeodorant/refactoring/manipulators/ExtractCloneRefactoring.java index 3233d22c9..1bb40d77a 100644 --- a/src/gr/uom/java/jdeodorant/refactoring/manipulators/ExtractCloneRefactoring.java +++ b/src/gr/uom/java/jdeodorant/refactoring/manipulators/ExtractCloneRefactoring.java @@ -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 resources = oldTryStatement.resources(); for(VariableDeclarationExpression expression : resources) { Expression newResourceExpression = (Expression)processASTNodeWithDifferences(ast, sourceRewriter, expression, nodeMapping); diff --git a/src/gr/uom/java/jdeodorant/refactoring/manipulators/ExtractMethodFragmentRefactoring.java b/src/gr/uom/java/jdeodorant/refactoring/manipulators/ExtractMethodFragmentRefactoring.java index afc7498aa..6baf58989 100644 --- a/src/gr/uom/java/jdeodorant/refactoring/manipulators/ExtractMethodFragmentRefactoring.java +++ b/src/gr/uom/java/jdeodorant/refactoring/manipulators/ExtractMethodFragmentRefactoring.java @@ -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 resources = tryStatementParent.resources(); for(VariableDeclarationExpression expression : resources) { resourceRewrite.insertLast(expression, null); diff --git a/src/gr/uom/java/jdeodorant/refactoring/manipulators/ReplaceConditionalWithPolymorphism.java b/src/gr/uom/java/jdeodorant/refactoring/manipulators/ReplaceConditionalWithPolymorphism.java index 6e4e2698a..477f8f41a 100644 --- a/src/gr/uom/java/jdeodorant/refactoring/manipulators/ReplaceConditionalWithPolymorphism.java +++ b/src/gr/uom/java/jdeodorant/refactoring/manipulators/ReplaceConditionalWithPolymorphism.java @@ -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; @@ -477,9 +478,9 @@ else if(variableDeclarationFragment.getParent() instanceof FieldDeclaration) { List> typeCheckStatements = typeCheckElimination.getTypeCheckStatements(); List subclassNames = typeCheckElimination.getSubclassNames(); DefaultMutableTreeNode root = typeCheckElimination.getExistingInheritanceTree().getRootNode(); - Enumeration enumeration = root.children(); + Enumeration 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);