public List getInEdges(Object port) { List res = new ArrayList(); if (Model.getFacade().isANode(port)) { Collection ends = Model.getFacade().getAssociationEnds(port); if (ends == null) { return Collections.EMPTY_LIST; } for (Object end : ends) { res.add(Model.getFacade().getAssociation(end)); } } if (Model.getFacade().isANodeInstance(port)) { Object noi = port; Collection ends = Model.getFacade().getLinkEnds(noi); res.addAll(ends); } if (Model.getFacade().isAComponent(port)) { Collection ends = Model.getFacade().getAssociationEnds(port); if (ends == null) { return Collections.EMPTY_LIST; } for (Object end : ends) { res.add(Model.getFacade().getAssociation(end)); } } if (Model.getFacade().isAComponentInstance(port)) { Object coi = port; Collection ends = Model.getFacade().getLinkEnds(coi); res.addAll(ends); } if (Model.getFacade().isAClass(port)) { Collection ends = Model.getFacade().getAssociationEnds(port); if (ends == null) { return Collections.EMPTY_LIST; } for (Object end : ends) { res.add(Model.getFacade().getAssociation(end)); } } if (Model.getFacade().isAInterface(port)) { Collection ends = Model.getFacade().getAssociationEnds(port); if (ends == null) { return Collections.EMPTY_LIST; } for (Object end : ends) { res.add(Model.getFacade().getAssociation(end)); } } if (Model.getFacade().isAObject(port)) { Object clo = port; Collection ends = Model.getFacade().getLinkEnds(clo); res.addAll(ends); } return res; }
/** * To simplify implementation, we list all associations * found with any of the Classifiers * represented by the linked Instances. <p> * * TODO: Make a foolproof algorithm that only allows selecting associations * that create a correct model. Also take into account n-ary associations * and associationclasses. This algo best goes in the model subsystem, e.g. * in a method getAllPossibleAssociationsForALink(). * * @see org.argouml.uml.ui.UMLComboBoxModel#buildModelList() */ protected void buildModelList() { Collection linkEnds; Collection associations = new HashSet(); Object t = getTarget(); if (Model.getFacade().isALink(t)) { linkEnds = Model.getFacade().getConnections(t); Iterator ile = linkEnds.iterator(); while (ile.hasNext()) { Object instance = Model.getFacade().getInstance(ile.next()); Collection c = Model.getFacade().getClassifiers(instance); Iterator ic = c.iterator(); while (ic.hasNext()) { Object classifier = ic.next(); Collection ae = Model.getFacade().getAssociationEnds(classifier); Iterator iae = ae.iterator(); while (iae.hasNext()) { Object associationEnd = iae.next(); Object association = Model.getFacade().getAssociation(associationEnd); associations.add(association); } } } } setElements(associations); }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/deployment/DeploymentDiagramGraphModel.java File path: /ArgoUML-0.34-src/argouml/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLLinkAssociationComboBoxModel.java
Method name: List getInEdges(Object) Method name: void buildModelList()
Number of AST nodes: 2 Number of AST nodes: 4
1
public List getInEdges(Object port) {
1
/**
2
        List res = new ArrayList();
2
     * To simplify implementation, we list all associations
3
        if (Model.getFacade().isANode(port)) {
3
     * found with any of the Classifiers
4
            Collection ends = Model.getFacade().getAssociationEnds(port);
4
     * represented by the linked Instances. <p>
5
            if (ends == null) {
5
     *
6
                return Collections.EMPTY_LIST;
6
     * TODO: Make a foolproof algorithm that only allows selecting associations
7
            }
7
     * that create a correct model. Also take into account n-ary associations
8
            for (Object end : ends) {
8
     * and associationclasses. This algo best goes in the model subsystem, e.g.
9
                res.add(Model.getFacade().getAssociation(end));
9
     * in a method getAllPossibleAssociationsForALink().
10
            }
10
     *
11
        }
11
     * @see org.argouml.uml.ui.UMLComboBoxModel#buildModelList()
12
        if (Model.getFacade().isANodeInstance(port)) {
12
     */
13
            Object noi = port;
13
    protected void buildModelList() {
14
            Collection ends = Model.getFacade().getLinkEnds(noi);
14
        Collection linkEnds;
15
            res.addAll(ends);
15
        Collection associations = new HashSet();
16
        }
16
        Object t = getTarget();
17
        if (Model.getFacade().isAComponent(port)) {
17
        if (Model.getFacade().isALink(t)) {
18
            Collection ends = Model.getFacade().getAssociationEnds(port);
18
            linkEnds = Model.getFacade().getConnections(t);
19
            if (ends == null) {
19
            Iterator ile = linkEnds.iterator();
20
                return Collections.EMPTY_LIST;
20
            while (ile.hasNext()) {
21
            }
21
                Object instance = Model.getFacade().getInstance(ile.next());
22
            for (Object end : ends) {
22
                Collection c = Model.getFacade().getClassifiers(instance);
23
                res.add(Model.getFacade().getAssociation(end));
23
                Iterator ic = c.iterator();
24
            }
24
                while (ic.hasNext()) {
25
        }
25
                    Object classifier = ic.next();
26
        if (Model.getFacade().isAComponentInstance(port)) {
26
                    Collection ae =
27
            Object coi = port;
27
                        Model.getFacade().getAssociationEnds(classifier);
28
            Collection ends = Model.getFacade().getLinkEnds(coi);
28
                    Iterator iae = ae.iterator();
29
            res.addAll(ends);
29
                    while (iae.hasNext()) {
30
        }
30
                        Object associationEnd = iae.next();
31
        if (Model.getFacade().isAClass(port)) {
31
                        Object association =
32
            Collection ends = Model.getFacade().getAssociationEnds(port);
32
                            Model.getFacade().getAssociation(associationEnd);
33
            if (ends == null) {
33
                        associations.add(association);
34
                return Collections.EMPTY_LIST;
34
                    }
35
            }
35
                }
36
            for (Object end : ends) {
36
            }
37
                res.add(Model.getFacade().getAssociation(end));
37
        }
38
            }
38
        setElements(associations);
39
        }
39
    }
40
        if (Model.getFacade().isAInterface(port)) {
41
            Collection ends = Model.getFacade().getAssociationEnds(port);
42
            if (ends == null) {
43
                return Collections.EMPTY_LIST;
44
            }
45
            for (Object end : ends) {
46
                res.add(Model.getFacade().getAssociation(end));
47
            }
48
        }
49
        if (Model.getFacade().isAObject(port)) {
50
            Object clo = port;
51
            Collection ends = Model.getFacade().getLinkEnds(clo);
52
            res.addAll(ends);
53
        }
54
55
56
        return res;
57
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)0.0
    Similarity Score1.000
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    32
    for (Object end : ends)
    32
    for (Object end : ends)
    15
    while (iae.hasNext())
    Differences
    Expression1Expression2Difference
    endassociationEndVARIABLE_NAME_MISMATCH
    15
    while (iae.hasNext())
                                                                              
    16
    Object associationEnd = iae.next();
    Differences
    Expression1Expression2Difference
    endassociationEndVARIABLE_NAME_MISMATCH
    16
    Object associationEnd = iae.next();
                                                                                                                                                    
    17
    Object association = Model.getFacade().getAssociation(associationEnd);
    Preondition Violations
    Unmatched statement Object association=Model.getFacade().getAssociation(associationEnd); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17
    Object association = Model.getFacade().getAssociation(associationEnd);
                                                                        
    18
    associations.add(association);
    33
    res.add(Model.getFacade().getAssociation(end));
    33
    res.add(Model.getFacade().getAssociation(end));
    Preondition Violations
    Unmatched statement res.add(Model.getFacade().getAssociation(end)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                          
    Precondition Violations (2)
    Row Violation
    1Unmatched statement Object association=Model.getFacade().getAssociation(associationEnd); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement res.add(Model.getFacade().getAssociation(end)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted