@Override public void setEnclosingFig(Fig encloser) { Object comp = getOwner(); if (encloser != null && (Model.getFacade().isANode(encloser.getOwner()) || Model.getFacade().isAComponent(encloser.getOwner())) && getOwner() != null) { if (Model.getFacade().isANode(encloser.getOwner())) { Object node = encloser.getOwner(); if (!Model.getFacade().getDeploymentLocations(comp).contains( node)) { Model.getCoreHelper().addDeploymentLocation(comp, node); } } 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 (encloser == null && getEnclosingFig() != null) { Object encloserOwner = getEnclosingFig().getOwner(); if (Model.getFacade().isANode(encloserOwner) && (Model.getFacade().getDeploymentLocations(comp) .contains(encloserOwner))) { Model.getCoreHelper().removeDeploymentLocation(comp, encloserOwner); } super.setEnclosingFig(encloser); } }
@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); } } } }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/deployment/ui/FigComponent.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/deployment/ui/FigNodeInstance.java
Method name: void setEnclosingFig(Fig) Method name: void setEnclosingFig(Fig)
Number of AST nodes: 5 Number of AST nodes: 4
1
@Override
1
@Override
2
    public void setEnclosingFig(Fig encloser) {
2
    public void setEnclosingFig(Fig encloser) {
3
3
        if (getOwner() != null) {
4
        Object comp = getOwner();
4
            Object nod = getOwner();
5
        if (encloser != null
5
            if (encloser != null) {
6
                && (Model.getFacade().isANode(encloser.getOwner()) 
6
                Object comp = encloser.getOwner();
7
                        || Model.getFacade().isAComponent(encloser.getOwner()))
7
                if (Model.getFacade().isAComponentInstance(comp)) {
8
                && getOwner() != null) {
8
                    if (Model.getFacade().getComponentInstance(nod) != comp) {
9
            if (Model.getFacade().isANode(encloser.getOwner())) {
9
                        Model.getCommonBehaviorHelper()
10
                Object node = encloser.getOwner();
10
                                .setComponentInstance(nod, comp);
11
                if (!Model.getFacade().getDeploymentLocations(comp).contains(
11
                        super.setEnclosingFig(encloser);
12
                        node)) {
12
                    }
13
                    Model.getCoreHelper().addDeploymentLocation(comp, node);
13
                } else if (Model.getFacade().isANode(comp)) {
14
                }
14
                    super.setEnclosingFig(encloser);
15
            }
15
                }
16
            super.setEnclosingFig(encloser);
16
            } else if (encloser == null) {
17
17
                if (isVisible()
18
            if (getLayer() != null) {
18
                        // If we are not visible most likely
19
                // elementOrdering(figures);
19
                        // we're being deleted.
20
                List contents = new ArrayList(getLayer().getContents());
20
                        // TODO: This indicates a more fundamental problem that
21
                Iterator it = contents.iterator();
21
                        // should be investigated - tfm - 20061230
22
                while (it.hasNext()) {
22
                        && Model.getFacade().getComponentInstance(nod) != null) {
23
                    Object o = it.next();
23
                    Model.getCommonBehaviorHelper()
24
                    if (o instanceof FigEdgeModelElement) {
24
                            .setComponentInstance(nod, null);
25
                        FigEdgeModelElement figedge = (FigEdgeModelElement) o;
25
                    super.setEnclosingFig(encloser);
26
                        figedge.getLayer().bringToFront(figedge);
26
                }
27
                    }
27
            }
28
                }
28
        }
29
            }
29
30
        } else if (encloser == null && getEnclosingFig() != null) {
30
        if (getLayer() != null) {
31
            Object encloserOwner = getEnclosingFig().getOwner();
31
            // elementOrdering(figures);
32
            if (Model.getFacade().isANode(encloserOwner)
32
            Collection contents = new ArrayList(getLayer().getContents());
33
                    && (Model.getFacade().getDeploymentLocations(comp)
33
            for (Object o : contents) {
34
                            .contains(encloserOwner))) {
34
                if (o instanceof FigEdgeModelElement) {
35
                Model.getCoreHelper().removeDeploymentLocation(comp,
35
                    FigEdgeModelElement figedge = (FigEdgeModelElement) o;
36
                        encloserOwner);
36
                    figedge.getLayer().bringToFront(figedge);
37
            }
37
                }
38
            super.setEnclosingFig(encloser);
38
            }
39
        }
39
        }
40
    }
40
    }
  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
    11
    while (it.hasNext())
    11
    while (it.hasNext())
    17
    for (Object o : contents)
    Differences
    Expression1Expression2Difference
    java.util.Listjava.util.CollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.List of variable contents does not match with type java.util.Collection of variable contents
    • Make classes java.util.List and java.util.Collection extend a common superclass
    17
    for (Object o : contents)
    12
    Object o = it.next();
                                                  
    13
    if (o instanceof FigEdgeModelElement)
    18
    if (o instanceof FigEdgeModelElement)
    14
    FigEdgeModelElement figedge = (FigEdgeModelElement)o;
    19
    FigEdgeModelElement figedge = (FigEdgeModelElement)o;
    15
    figedge.getLayer().bringToFront(figedge);
    20
    figedge.getLayer().bringToFront(figedge);
    Precondition Violations (1)
    Row Violation
    1Type java.util.List of variable contents does not match with type java.util.Collection of variable contents