@Override public void initialiseListener(Object modelElement) { addElementListener(modelElement, new String[] {"name", "classifier", "remove"}); Collection<Object> c = Model.getFacade().getClassifiers(modelElement); for (Object classifier : c) { addElementListener(classifier, new String[] {"name", "remove"}); } }
private static void addListenersForEvent(NotationProvider np, Object event) { if (event != null) { if (Model.getFacade().isAEvent(event)) { np.addElementListener(event, new String[] { "parameter", "name"}); } if (Model.getFacade().isATimeEvent(event)) { np.addElementListener(event, new String[] {"when"}); } if (Model.getFacade().isAChangeEvent(event)) { np.addElementListener(event, new String[] {"changeExpression"}); } /* And the parameter names and values: */ Collection prms = Model.getFacade().getParameters(event); Iterator i = prms.iterator(); while (i.hasNext()) { Object parameter = i.next(); np.addElementListener(parameter, new String[] {"defaultValue", "name", "type", "kind"}); } } }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/notation/providers/NodeInstanceNotation.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/notation/providers/NotationUtilityProviders.java
Method name: void initialiseListener(Object) Method name: void addListenersForEvent(NotationProvider, Object)
Number of AST nodes: 2 Number of AST nodes: 3
1
@Override
1
private static void addListenersForEvent(NotationProvider np, 
2
    public void initialiseListener(Object modelElement) {
2
            Object event) {
3
        addElementListener(modelElement,
3
        if (event != null) {
4
                new String[] {"name", "classifier", "remove"});
4
            if (Model.getFacade().isAEvent(event)) {
5
        Collection<Object> c = Model.getFacade().getClassifiers(modelElement);
5
                np.addElementListener(event,
6
        for (Object classifier : c) {
6
                        new String[] {
7
            addElementListener(classifier,
7
                            "parameter", "name"});
8
                    new String[] {"name", "remove"});
8
            }
9
        }
9
            if (Model.getFacade().isATimeEvent(event)) {
10
    }
10
                np.addElementListener(event, new String[] {"when"});
11
            }
12
            if (Model.getFacade().isAChangeEvent(event)) {
13
                np.addElementListener(event,
14
                        new String[] {"changeExpression"});
15
            }
16
            /* And the parameter names and values: */
17
            Collection prms = Model.getFacade().getParameters(event);
18
            Iterator i = prms.iterator();
19
            while (i.hasNext()) {
20
                Object parameter = i.next();
21
                np.addElementListener(parameter, 
22
                      new String[] {"defaultValue", "name", "type", "kind"});
23
            }
24
        }
25
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    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 Score0.750
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    for (Object classifier : c)
    3
    for (Object classifier : c)
    10
    while (i.hasNext())
    Differences
    Expression1Expression2Difference
    classifierparameterVARIABLE_NAME_MISMATCH
    java.util.Collectionjava.util.CollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection<java.lang.Object> of variable c does not match with type java.util.Collection of variable prms
    • Make classes java.util.Collection and java.util.Collection extend a common superclass
    10
    while (i.hasNext())
                                                                
    11
    Object parameter = i.next();
    Differences
    Expression1Expression2Difference
    classifierparameterVARIABLE_NAME_MISMATCH
    11
    Object parameter = i.next();
    4
    addElementListener(classifier, new String[] {"name", "remove"});
    4
    addElementListener(classifier, new String[] {"name", "remove"});
    12
    np.addElementListener(parameter, new String[] {"defaultValue", "name", "type", "kind"});
    Differences
    Expression1Expression2Difference
    classifierparameterVARIABLE_NAME_MISMATCH
    {"name","remove"}{"defaultValue","name","type","kind"}ARRAY_INITIALIZER_EXPRESSION_NUMBER_MISMATCH
    npMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression addElementListener(classifier,new String[]{"name","remove"}) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression addElementListener(classifier,new String[]{"name","remove"}) is a void method call, and thus it cannot be parameterized
    Expression np.addElementListener(parameter,new String[]{"defaultValue","name","type","kind"}) is a void method call, and thus it cannot be parameterized
    12
    np.addElementListener(parameter, new String[] {"defaultValue", "name", "type", "kind"});
    Precondition Violations (4)
    Row Violation
    1Type java.util.Collection<java.lang.Object> of variable c does not match with type java.util.Collection of variable prms
    2Expression addElementListener(classifier,new String[]{"name","remove"}) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression addElementListener(classifier,new String[]{"name","remove"}) is a void method call, and thus it cannot be parameterized
    4Expression np.addElementListener(parameter,new String[]{"defaultValue","name","type","kind"}) is a void method call, and thus it cannot be parameterized