@Override public void initialiseListener(Object modelElement) { addElementListener(modelElement, new String[] {"name", "remove", "stereotype"} ); Collection c = Model.getFacade().getStereotypes(modelElement); for (Object st : c) { addElementListener(st, 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/EnumerationLiteralNotation.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", "remove", "stereotype"} );
4
            if (Model.getFacade().isAEvent(event)) {
5
        Collection c = Model.getFacade().getStereotypes(modelElement);
5
                np.addElementListener(event,
6
        for (Object st : c) {
6
                        new String[] {
7
            addElementListener(st, new String[] {"name", "remove"});
7
                            "parameter", "name"});
8
        }
8
            }
9
    }
9
            if (Model.getFacade().isATimeEvent(event)) {
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 st : c)
    3
    for (Object st : c)
    10
    while (i.hasNext())
    Differences
    Expression1Expression2Difference
    stparameterVARIABLE_NAME_MISMATCH
    10
    while (i.hasNext())
                                                                
    11
    Object parameter = i.next();
    Differences
    Expression1Expression2Difference
    stparameterVARIABLE_NAME_MISMATCH
    11
    Object parameter = i.next();
    4
    addElementListener(st, new String[] {"name", "remove"});
    4
    addElementListener(st, new String[] {"name", "remove"});
    12
    np.addElementListener(parameter, new String[] {"defaultValue", "name", "type", "kind"});
    Differences
    Expression1Expression2Difference
    stparameterVARIABLE_NAME_MISMATCH
    {"name","remove"}{"defaultValue","name","type","kind"}ARRAY_INITIALIZER_EXPRESSION_NUMBER_MISMATCH
    npMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression addElementListener(st,new String[]{"name","remove"}) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression addElementListener(st,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 (3)
    Row Violation
    1Expression addElementListener(st,new String[]{"name","remove"}) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression addElementListener(st,new String[]{"name","remove"}) is a void method call, and thus it cannot be parameterized
    3Expression np.addElementListener(parameter,new String[]{"defaultValue","name","type","kind"}) is a void method call, and thus it cannot be parameterized