From 18287ad7307950faaddd5ed9337a1ddfa7c0f256 Mon Sep 17 00:00:00 2001 From: tsantalis Date: Sun, 22 Dec 2024 11:43:53 -0500 Subject: [PATCH] Fix one more failing test --- .../java/xmi/decomposition/AbstractCodeMapping.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 79492a4900..85ae63cb08 100644 --- a/src/main/java/gr/uom/java/xmi/decomposition/AbstractCodeMapping.java +++ b/src/main/java/gr/uom/java/xmi/decomposition/AbstractCodeMapping.java @@ -707,7 +707,8 @@ else if(stringConcatMatch(initializer, before)) { } } } - if(!fragment1.getString().equals(fragment2.getString()) && initializer != null && fragment1.getVariableDeclaration(variableName) == null && !isDefaultValue(initializer.toString())) { + if(!fragment1.getString().equals(fragment2.getString()) && initializer != null && fragment1.getVariableDeclaration(variableName) == null && + !isDefaultValue(initializer.toString()) && !isVariableReference(initializer.toString(), fragment2.getVariables())) { if(getFragment1().getString().contains(initializer.getString()) && getFragment2().findExpression(variableName).size() > 0 && !getFragment2().getString().equals(JAVA.RETURN_SPACE + variableName + JAVA.STATEMENT_TERMINATION)) { boolean mappingFound = false; @@ -875,6 +876,15 @@ private boolean anonymousWithMethodSignatureChange(AbstractExpression initialize return false; } + private boolean isVariableReference(String argument, List variables) { + for(LeafExpression expr : variables) { + if(expr.getString().equals(argument)) { + return true; + } + } + return false; + } + private boolean isDefaultValue(String argument) { return argument.equals("null") || argument.equals("0") || argument.equals("1") || argument.equals("false") || argument.equals("true"); }