diff --git a/src/main/java/org/refactoringminer/astDiff/matchers/ProjectASTDiffer.java b/src/main/java/org/refactoringminer/astDiff/matchers/ProjectASTDiffer.java index 9dd5617241..aba7b4a3f9 100644 --- a/src/main/java/org/refactoringminer/astDiff/matchers/ProjectASTDiffer.java +++ b/src/main/java/org/refactoringminer/astDiff/matchers/ProjectASTDiffer.java @@ -85,6 +85,7 @@ private void createASTDiffsForMovedDeclarations() { for(ASTDiff diff : projectASTDiff.getDiffSet()) { Map> methodDeclarationMappings = new LinkedHashMap>(); Map> fieldDeclarationMappings = new LinkedHashMap>(); + Map> typeDeclarationMappings = new LinkedHashMap>(); Map actionMap = new LinkedHashMap(); ExtendedOnlyRootsClassifier classifier = (ExtendedOnlyRootsClassifier) diff.createRootNodesClassifier(); Map map = classifier.getSrcMoveOutTreeMap(); @@ -117,6 +118,14 @@ private void createASTDiffsForMovedDeclarations() { } } } + if(src.getType().name.equals(Constants.TYPE_DECLARATION) || + src.getType().name.equals(Constants.ENUM_DECLARATION) || + src.getType().name.equals(Constants.RECORD_DECLARATION)) { + actionMap.put(src, map.get(src)); + List mappings = new ArrayList(); + mappings.addAll(getMappingForLeft(diff, src)); + typeDeclarationMappings.put(src, mappings); + } } //group the mappings based on the pair of src and dst files. String srcPath = diff.getSrcPath(); @@ -156,6 +165,24 @@ private void createASTDiffsForMovedDeclarations() { } } } + for(Tree key : typeDeclarationMappings.keySet()) { + if(actionMap.containsKey(key)) { + Action action = actionMap.get(key); + if(action instanceof MoveOut) { + MoveOut moveOut = (MoveOut)action; + String dstPath = moveOut.getDstFile(); + Pair pair = new Pair(srcPath, dstPath); + if(filePairMappings.containsKey(pair)) { + filePairMappings.get(pair).addAll(typeDeclarationMappings.get(key)); + } + else { + List mappings = new ArrayList(); + mappings.addAll(typeDeclarationMappings.get(key)); + filePairMappings.put(pair, mappings); + } + } + } + } } for(Pair pair : filePairMappings.keySet()) { Pair treeContextPairs = findTreeContexts(pair.first, pair.second);