/** * Remove entire composite Fig from Diagram. Discover the attached * FigEdgeAssociationClass and the FigClassAssociationClass attached to * that. Remove them from the diagram before removing this. */ @Override protected void removeFromDiagramImpl() { FigEdgeAssociationClass figEdgeLink = null; List edges = null; FigEdgePort figEdgePort = getEdgePort(); if (figEdgePort != null) { edges = figEdgePort.getFigEdges(); } if (edges != null) { for (Iterator it = edges.iterator(); it.hasNext() && figEdgeLink == null;) { Object o = it.next(); if (o instanceof FigEdgeAssociationClass) { figEdgeLink = (FigEdgeAssociationClass) o; } } } if (figEdgeLink != null) { FigNode figClassBox = figEdgeLink.getDestFigNode(); if (!(figClassBox instanceof FigClassAssociationClass)) { figClassBox = figEdgeLink.getSourceFigNode(); } figEdgeLink.removeFromDiagramImpl(); ((FigClassAssociationClass) figClassBox).removeFromDiagramImpl(); } super.removeFromDiagramImpl(); }
protected Fig getRemoveDelegate() { // Look for the dashed edge for (Object fig : getFigEdges()) { if (fig instanceof FigEdgeAssociationClass) { // We have the dashed edge now find the opposite FigNode FigEdgeAssociationClass dashedEdge = (FigEdgeAssociationClass) fig; return dashedEdge.getRemoveDelegate(); } } return null; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociationClass.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/ui/FigClassAssociationClass.java
Method name: void removeFromDiagramImpl() Method name: Fig getRemoveDelegate()
Number of AST nodes: 4 Number of AST nodes: 4
1
/**
1
protected Fig getRemoveDelegate() {
2
     * Remove entire composite Fig from Diagram. Discover the attached
2
        // Look for the dashed edge
3
     * FigEdgeAssociationClass and the FigClassAssociationClass attached to
3
        for (Object fig : getFigEdges()) {
4
     * that. Remove them from the diagram before removing this.
4
            if (fig instanceof FigEdgeAssociationClass) {
5
     */
5
                // We have the dashed edge now find the opposite FigNode
6
    @Override
6
                FigEdgeAssociationClass dashedEdge =
7
    protected void removeFromDiagramImpl() {
7
                    (FigEdgeAssociationClass) fig;
8
        FigEdgeAssociationClass figEdgeLink = null;
8
                return dashedEdge.getRemoveDelegate();
9
        List edges = null;
9
            }
10
10
        }
11
        FigEdgePort figEdgePort = getEdgePort();
11
        return null;
12
        if (figEdgePort != null) {
12
    }
13
            edges = figEdgePort.getFigEdges();
14
        }
15
16
        if (edges != null) {
17
            for (Iterator it = edges.iterator(); it.hasNext()
18
                    && figEdgeLink == null;) {
19
                Object o = it.next();
20
                if (o instanceof FigEdgeAssociationClass) {
21
                    figEdgeLink = (FigEdgeAssociationClass) o;
22
                }
23
            }
24
        }
25
26
        if (figEdgeLink != null) {
27
            FigNode figClassBox = figEdgeLink.getDestFigNode();
28
            if (!(figClassBox instanceof FigClassAssociationClass)) {
29
                figClassBox = figEdgeLink.getSourceFigNode();
30
            }
31
            figEdgeLink.removeFromDiagramImpl();
32
            ((FigClassAssociationClass) figClassBox).removeFromDiagramImpl();
33
        }
34
35
        super.removeFromDiagramImpl();
36
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.667
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    7
    for (Iterator it = edges.iterator(); it.hasNext() && figEdgeLink == null; )
    7
    for (Iterator it = edges.iterator(); it.hasNext() && figEdgeLink == null; )
    1
    for (Object fig : getFigEdges())
    Differences
    Expression1Expression2Difference
    ofigVARIABLE_NAME_MISMATCH
    java.util.Listjava.util.ListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.List of variable edges does not match with type java.util.List<org.tigris.gef.presentation.FigEdge> of variable getFigEdges()
    • Make classes java.util.List and java.util.List extend a common superclass
    1
    for (Object fig : getFigEdges())
    8
    Object o = it.next();
    8
    Object o = it.next();
    Differences
    Expression1Expression2Difference
    ofigVARIABLE_NAME_MISMATCH
                                                
    9
    if (o instanceof FigEdgeAssociationClass)
    9
    if (o instanceof FigEdgeAssociationClass)
    2
    if (fig instanceof FigEdgeAssociationClass)
    Differences
    Expression1Expression2Difference
    ofigVARIABLE_NAME_MISMATCH
    2
    if (fig instanceof FigEdgeAssociationClass)
    10
    figEdgeLink = (FigEdgeAssociationClass)o;
    10
    figEdgeLink = (FigEdgeAssociationClass)o;
    3
    FigEdgeAssociationClass dashedEdge = (FigEdgeAssociationClass)fig;
    Differences
    Expression1Expression2Difference
    figEdgeLinkdashedEdgeVARIABLE_NAME_MISMATCH
    ofigVARIABLE_NAME_MISMATCH
    figEdgeLinkdashedEdgeVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression figEdgeLink cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression dashedEdge cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression figEdgeLink cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression dashedEdge cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    FigEdgeAssociationClass dashedEdge = (FigEdgeAssociationClass)fig;
                                                                                      
    4
    return dashedEdge.getRemoveDelegate();
    Preondition Violations
    Unmatched statement return dashedEdge.getRemoveDelegate(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return dashedEdge.getRemoveDelegate();
    4
    return dashedEdge.getRemoveDelegate();
    Precondition Violations (7)
    Row Violation
    1Type java.util.List of variable edges does not match with type java.util.List<org.tigris.gef.presentation.FigEdge> of variable getFigEdges()
    2Expression figEdgeLink cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression dashedEdge cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression figEdgeLink cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression dashedEdge cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Unmatched statement return dashedEdge.getRemoveDelegate(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched return dashedEdge.getRemoveDelegate();