From 12586dc1f9cfada0ba4b3140439a77e65b78b29c Mon Sep 17 00:00:00 2001 From: tsantalis Date: Sun, 22 Sep 2024 12:43:52 -0400 Subject: [PATCH] Restore mappings in commit https://github.com/apache/flink/commit/7407076d3990752eb5fa4072cd036efd2f656cbc flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/PojoSerializer.java --- .../decomposition/UMLOperationBodyMapper.java | 6 ++ .../uom/java/xmi/diff/MappingOptimizer.java | 60 ++++++++++++++----- 2 files changed, 51 insertions(+), 15 deletions(-) diff --git a/src/main/java/gr/uom/java/xmi/decomposition/UMLOperationBodyMapper.java b/src/main/java/gr/uom/java/xmi/decomposition/UMLOperationBodyMapper.java index 8ea5c2701a..cede6fdf6c 100644 --- a/src/main/java/gr/uom/java/xmi/decomposition/UMLOperationBodyMapper.java +++ b/src/main/java/gr/uom/java/xmi/decomposition/UMLOperationBodyMapper.java @@ -2555,6 +2555,9 @@ else if(streamAPIStatements1.size() > 0 && streamAPIStatements2.size() == 0) { mapping.getFragment1().getVariableDeclarations().toString().equals(mapping.getFragment2().getVariableDeclarations().toString())) { continue; } + if(expression.getLocationInfo().getCodeElementType().equals(CodeElementType.CATCH_CLAUSE_EXCEPTION_NAME)) { + continue; + } expression.replaceParametersWithArguments(parameterToArgumentMap1); expressionsT1.add(expression); } @@ -2961,6 +2964,9 @@ else if(streamAPIStatements1.size() > 0 && streamAPIStatements2.size() == 0) { mapping.getFragment1().getVariableDeclarations().toString().equals(mapping.getFragment2().getVariableDeclarations().toString())) { continue; } + if(expression.getLocationInfo().getCodeElementType().equals(CodeElementType.CATCH_CLAUSE_EXCEPTION_NAME)) { + continue; + } expression.replaceParametersWithArguments(parameterToArgumentMap2); expressionsT2.add(expression); } diff --git a/src/main/java/gr/uom/java/xmi/diff/MappingOptimizer.java b/src/main/java/gr/uom/java/xmi/diff/MappingOptimizer.java index fd5b13dddf..6331a74e38 100644 --- a/src/main/java/gr/uom/java/xmi/diff/MappingOptimizer.java +++ b/src/main/java/gr/uom/java/xmi/diff/MappingOptimizer.java @@ -26,6 +26,7 @@ import gr.uom.java.xmi.decomposition.VariableDeclaration; import gr.uom.java.xmi.decomposition.AbstractCall.StatementCoverageType; import gr.uom.java.xmi.decomposition.replacement.Replacement; +import gr.uom.java.xmi.decomposition.replacement.Replacement.ReplacementType; public class MappingOptimizer { private UMLAbstractClassDiff classDiff; @@ -251,6 +252,20 @@ private void optimizeDuplicateMappings(Map 0) { + //tolerate variable renames + int editDistance = StringDistance.editDistance(stringRepresentation1.get(i), stringRepresentation2.get(i)); + for(Replacement r : mapping.getReplacements()) { + if(r.getType().equals(ReplacementType.VARIABLE_NAME)) { + if(editDistance == r.getBefore().length() && editDistance == r.getAfter().length()) { + identicalStatements++; + break; + } + } + } + } } identicalStatementsForCompositeMappings.add(identicalStatements); exactMappingsNestedUnderCompositeExcludingBlocks.add(mapper.exactMappingsNestedUnderCompositeExcludingBlocks((CompositeStatementObjectMapping)mapping)); @@ -684,27 +699,42 @@ private void determineIndicesToBeRemoved(List nestedMapper, List minimum && !extractInlineOverlappingRefactoring.get(i) == true) { - indicesToBeRemoved.add(i); + else { + allReplacementsCoverEntireStatement = true; + } + if(!allReplacementsCoverEntireStatement) { + int minimum = replacementTypeCount.get(0); + for(int i=1; i minimum && !extractInlineOverlappingRefactoring.get(i) == true) { + indicesToBeRemoved.add(i); + } } } }