File tree Expand file tree Collapse file tree
cddiff/src/main/java/de/monticore/cddiff/ow2cw Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /* (c) https://github.com/MontiCore/monticore */
2+ package de .monticore .cddiff .ow2cw ;
3+
4+ import de .monticore .cdassociation ._ast .ASTCDAssociation ;
5+ import de .monticore .cdbasis ._ast .ASTCDCompilationUnit ;
6+ import de .monticore .cddiff .CDDiffUtil ;
7+
8+ import java .util .Set ;
9+ import java .util .stream .Collectors ;
10+
11+ public class MergeRedundantAssocsTrafo {
12+
13+ public void transform (ASTCDCompilationUnit cd ) {
14+ Set <ASTCDAssociation > assocs = CDDiffUtil .getAllAssocsFromCD (cd );
15+ for (ASTCDAssociation assoc : assocs ) {
16+ Set <ASTCDAssociation > duplicates = assocs .stream ().filter (duplicate -> isDuplicate (assoc ,
17+ duplicate )).collect (Collectors .toSet ());
18+ if (!duplicates .isEmpty ()) {
19+ duplicates .add (assoc );
20+ assocs .removeAll (duplicates );
21+ assocs .add (combineDuplicates (duplicates ));
22+ }
23+ }
24+ }
25+
26+ private ASTCDAssociation combineDuplicates (Set <ASTCDAssociation > duplicates ) {
27+ assert false ;
28+ return null ;
29+ }
30+
31+ private boolean isDuplicate (ASTCDAssociation assoc , ASTCDAssociation duplicate ) {
32+ assert false ;
33+ return false ;
34+ }
35+
36+ }
You can’t perform that action at this time.
0 commit comments