@Override public void setEnclosingFig(Fig encloser) { if (getOwner() != null) { Object nod = getOwner(); if (encloser != null) { Object comp = encloser.getOwner(); if (Model.getFacade().isAComponentInstance(comp)) { if (Model.getFacade().getComponentInstance(nod) != comp) { Model.getCommonBehaviorHelper() .setComponentInstance(nod, comp); super.setEnclosingFig(encloser); } } else if (Model.getFacade().isANode(comp)) { super.setEnclosingFig(encloser); } } else if (encloser == null) { if (isVisible() // If we are not visible most likely // we're being deleted. // TODO: This indicates a more fundamental problem that // should be investigated - tfm - 20061230 && Model.getFacade().getComponentInstance(nod) != null) { Model.getCommonBehaviorHelper() .setComponentInstance(nod, null); super.setEnclosingFig(encloser); } } } if (getLayer() != null) { // elementOrdering(figures); Collection contents = new ArrayList(getLayer().getContents()); for (Object o : contents) { if (o instanceof FigEdgeModelElement) { FigEdgeModelElement figedge = (FigEdgeModelElement) o; figedge.getLayer().bringToFront(figedge); } } } }
@Override public void setEnclosingFig(Fig encloser) { if (getOwner() != null) { Object comp = getOwner(); if (encloser != null) { Object nodeOrComp = encloser.getOwner(); if (Model.getFacade().isANodeInstance(nodeOrComp)) { if (Model.getFacade() .getNodeInstance(comp) != nodeOrComp) { Model.getCommonBehaviorHelper() .setNodeInstance(comp, nodeOrComp); super.setEnclosingFig(encloser); } } else if (Model.getFacade().isAComponentInstance(nodeOrComp)) { if (Model.getFacade() .getComponentInstance(comp) != nodeOrComp) { Model.getCommonBehaviorHelper() .setComponentInstance(comp, nodeOrComp); super.setEnclosingFig(encloser); } } else if (Model.getFacade().isANode(nodeOrComp)) { super.setEnclosingFig(encloser); } if (getLayer() != null) { // elementOrdering(figures); List contents = new ArrayList(getLayer().getContents()); Iterator it = contents.iterator(); while (it.hasNext()) { Object o = it.next(); if (o instanceof FigEdgeModelElement) { FigEdgeModelElement figedge = (FigEdgeModelElement) o; figedge.getLayer().bringToFront(figedge); } } } } else if (isVisible() // If we are not visible most likely we're being deleted. // TODO: This indicates a more fundamental problem that // should be investigated - tfm - 20061230 && encloser == null && getEnclosingFig() != null) { if (Model.getFacade().getNodeInstance(comp) != null) { Model.getCommonBehaviorHelper() .setNodeInstance(comp, null); } if (Model.getFacade().getComponentInstance(comp) != null) { Model.getCommonBehaviorHelper() .setComponentInstance(comp, null); } super.setEnclosingFig(encloser); } } }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/deployment/ui/FigNodeInstance.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/deployment/ui/FigComponentInstance.java
Method name: void setEnclosingFig(Fig) Method name: void setEnclosingFig(Fig)
Number of AST nodes: 4 Number of AST nodes: 5
1
@Override
1
@Override
2
    public void setEnclosingFig(Fig encloser) {
2
    public void setEnclosingFig(Fig encloser) {
3
        if (getOwner() != null) {
3
4
            Object nod = getOwner();
4
        if (getOwner() != null) {
5
            if (encloser != null) {
5
            Object comp = getOwner();
6
                Object comp = encloser.getOwner();
6
            if (encloser != null) {
7
                if (Model.getFacade().isAComponentInstance(comp)) {
7
                Object nodeOrComp = encloser.getOwner();
8
                    if (Model.getFacade().getComponentInstance(nod) != comp) {
8
                if (Model.getFacade().isANodeInstance(nodeOrComp)) {
9
                        Model.getCommonBehaviorHelper()
9
                    if (Model.getFacade()
10
                                .setComponentInstance(nod, comp);
10
                            .getNodeInstance(comp) != nodeOrComp) {
11
                        super.setEnclosingFig(encloser);
11
                        Model.getCommonBehaviorHelper()
12
                    }
12
                                .setNodeInstance(comp, nodeOrComp);
13
                } else if (Model.getFacade().isANode(comp)) {
13
                        super.setEnclosingFig(encloser);
14
                    super.setEnclosingFig(encloser);
14
                    }
15
                }
15
                } else if (Model.getFacade().isAComponentInstance(nodeOrComp)) {
16
            } else if (encloser == null) {
16
                    if (Model.getFacade()
17
                if (isVisible()
17
                            .getComponentInstance(comp) != nodeOrComp) {
18
                        // If we are not visible most likely
18
                        Model.getCommonBehaviorHelper()
19
                        // we're being deleted.
19
                                .setComponentInstance(comp, nodeOrComp);
20
                        // TODO: This indicates a more fundamental problem that
20
                        super.setEnclosingFig(encloser);
21
                        // should be investigated - tfm - 20061230
21
                    }
22
                        && Model.getFacade().getComponentInstance(nod) != null) {
22
                } else if (Model.getFacade().isANode(nodeOrComp)) {
23
                    Model.getCommonBehaviorHelper()
23
                    super.setEnclosingFig(encloser);
24
                            .setComponentInstance(nod, null);
24
                }
25
                    super.setEnclosingFig(encloser);
25
26
                }
26
                if (getLayer() != null) {
27
            }
27
                    // elementOrdering(figures);
28
        }
28
                    List contents = new ArrayList(getLayer().getContents());
29
29
                    Iterator it = contents.iterator();
30
        if (getLayer() != null) {
30
                    while (it.hasNext()) {
31
            // elementOrdering(figures);
31
                        Object o = it.next();
32
            Collection contents = new ArrayList(getLayer().getContents());
32
                        if (o instanceof FigEdgeModelElement) {
33
            for (Object o : contents) {
33
                            FigEdgeModelElement figedge =
34
                if (o instanceof FigEdgeModelElement) {
34
                                    (FigEdgeModelElement) o;
35
                    FigEdgeModelElement figedge = (FigEdgeModelElement) o;
35
                            figedge.getLayer().bringToFront(figedge);
36
                    figedge.getLayer().bringToFront(figedge);
36
                        }
37
                }
37
                    }
38
            }
38
                }
39
        }
39
            } else if (isVisible()
40
    }
40
                    // If we are not visible most likely we're being deleted.
41
                    // TODO: This indicates a more fundamental problem that 
42
                    // should be investigated - tfm - 20061230
43
                    && encloser == null && getEnclosingFig() != null) {
44
                if (Model.getFacade().getNodeInstance(comp) != null) {
45
                    Model.getCommonBehaviorHelper()
46
                            .setNodeInstance(comp, null);
47
                }
48
                if (Model.getFacade().getComponentInstance(comp) != null) {
49
                    Model.getCommonBehaviorHelper()
50
                            .setComponentInstance(comp, null);
51
                }
52
                super.setEnclosingFig(encloser);
53
            }
54
        }
55
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score1.000
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    17
    for (Object o : contents)
    17
    for (Object o : contents)
    18
    while (it.hasNext())
    Differences
    Expression1Expression2Difference
    java.util.Collectionjava.util.ListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection of variable contents does not match with type java.util.List of variable contents
    • Make classes java.util.Collection and java.util.List extend a common superclass
    18
    while (it.hasNext())
                                                  
    19
    Object o = it.next();
    18
    if (o instanceof FigEdgeModelElement)
    20
    if (o instanceof FigEdgeModelElement)
    19
    FigEdgeModelElement figedge = (FigEdgeModelElement)o;
    21
    FigEdgeModelElement figedge = (FigEdgeModelElement)o;
    20
    figedge.getLayer().bringToFront(figedge);
    22
    figedge.getLayer().bringToFront(figedge);
    Precondition Violations (1)
    Row Violation
    1Type java.util.Collection of variable contents does not match with type java.util.List of variable contents