From 96c64ee10d0507e621028a4f12b7a603dfbc9516 Mon Sep 17 00:00:00 2001 From: tsantalis Date: Mon, 20 Jan 2025 19:57:35 -0500 Subject: [PATCH] Enable the detection of nested Extract Variable in commit ttps://github.com/spring-projects/spring-boot/commit/8d64e9971450bc54f4447930eec741bc2bd48e31 buildSrc/src/main/java/org/springframework/boot/build/constraints/ExtractVersionConstraints.java --- .../xmi/decomposition/AbstractCodeMapping.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/gr/uom/java/xmi/decomposition/AbstractCodeMapping.java b/src/main/java/gr/uom/java/xmi/decomposition/AbstractCodeMapping.java index 9fa9299c5..26c71a144 100644 --- a/src/main/java/gr/uom/java/xmi/decomposition/AbstractCodeMapping.java +++ b/src/main/java/gr/uom/java/xmi/decomposition/AbstractCodeMapping.java @@ -1218,6 +1218,9 @@ else if(stringConcatMatch(initializer, after)) { } private boolean identical() { + if(refactorings.size() > 1) { + return true; + } if(getReplacements().size() == 1 && fragment1.getVariableDeclarations().size() == fragment2.getVariableDeclarations().size()) { return true; } @@ -1415,6 +1418,18 @@ private boolean diamondClassInstanceCreationMatch(AbstractExpression initializer } } } + if(initializer.getString().contains("Map.of(") && replacedExpression.contains("Collections.singletonMap(")) { + String tmp = initializer.getString().replace("Map.of(", "Collections.singletonMap("); + if(tmp.equals(replacedExpression)) { + return true; + } + } + else if(initializer.getString().contains("Collections.singletonMap(") && replacedExpression.contains("Map.of(")) { + String tmp = initializer.getString().replace("Collections.singletonMap(", "Map.of("); + if(tmp.equals(replacedExpression)) { + return true; + } + } return false; }