private String items2Msg(String preface, Collection<T> items) { StringBuffer msg = new StringBuffer(preface); for (T item : items) { msg.append("\t"); msg.append(item.toString()); msg.append("\n"); } return msg.toString(); }
/** * Generates the association ends of the body of a class or interface. * @param cls * @param sb Where to put the result. */ private void generateClassifierBodyTypedefs(Object cls, StringBuffer sb) { if (generatorPass == HEADER_PASS) { Collection publicTypedefStatements = findTagValues(cls, TV_NAME_TYPEDEF_PUBLIC); Collection protectedTypedefStatements = findTagValues(cls, TV_NAME_TYPEDEF_PROTECTED); Collection privateTypedefStatements = findTagValues(cls, TV_NAME_TYPEDEF_PRIVATE); if (!publicTypedefStatements.isEmpty()) { sb.append(LINE_SEPARATOR).append(" public:") .append(LINE_SEPARATOR).append(indent); sb.append("// public type definitions for header defined " + "by Tag entries in ArgoUML").append(LINE_SEPARATOR); sb.append(indent); sb.append("// Result: typedef <typedef_public> " + "<tag_value>;").append(LINE_SEPARATOR); Iterator typedefEnum = publicTypedefStatements.iterator(); while (typedefEnum.hasNext()) { sb.append(indent).append("typedef "); sb.append(typedefEnum.next()) .append(";").append(LINE_SEPARATOR); } } if (!protectedTypedefStatements.isEmpty()) { sb.append(LINE_SEPARATOR).append(" protected:") .append(LINE_SEPARATOR).append(indent); sb.append("// protected type definitions for header defined " + "by Tag entries in ArgoUML").append(LINE_SEPARATOR); sb.append(indent); sb.append("// Result: typedef <typedef_protected> " + "<tag_value>;").append(LINE_SEPARATOR); Iterator typedefEnum = protectedTypedefStatements.iterator(); while (typedefEnum.hasNext()) { sb.append(indent).append("typedef "); sb.append(typedefEnum.next()) .append(";").append(LINE_SEPARATOR); } } if (!privateTypedefStatements.isEmpty()) { sb.append(LINE_SEPARATOR).append(" private:") .append(LINE_SEPARATOR).append(indent); sb.append("// private type definitions for header defined " + "by Tag entries in ArgoUML").append(LINE_SEPARATOR); sb.append(indent); sb.append("// Result: typedef <typedef_private> " + "<tag_value>;").append(LINE_SEPARATOR); Iterator typedefEnum = privateTypedefStatements.iterator(); while (typedefEnum.hasNext()) { sb.append(indent).append("typedef "); sb.append(typedefEnum.next()).append(";") .append(LINE_SEPARATOR); } } } }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/profile/internal/DependencyResolver.java File path: /ArgoUML-0.34-src/argouml-cpp/src/org/argouml/language/cpp/generator/GeneratorCpp.java
Method name: String items2Msg(String, Collection) Method name: void generateClassifierBodyTypedefs(Object, StringBuffer)
Number of AST nodes: 4 Number of AST nodes: 3
1
private String items2Msg(String preface, Collection<T> items) {
1
/**
2
        StringBuffer msg = new StringBuffer(preface);
2
     * Generates the association ends of the body of a class or interface.
3
        for (T item : items) {
3
     * @param cls
4
            msg.append("\t");
4
     * @param sb Where to put the result.
5
            msg.append(item.toString());
5
     */
6
            msg.append("\n");
6
    private void generateClassifierBodyTypedefs(Object cls, StringBuffer sb) {
7
        }
7
        if (generatorPass == HEADER_PASS) {
8
        return msg.toString();
8
            Collection publicTypedefStatements =
9
    }
9
                findTagValues(cls, TV_NAME_TYPEDEF_PUBLIC);
10
            Collection protectedTypedefStatements =
11
                findTagValues(cls, TV_NAME_TYPEDEF_PROTECTED);
12
            Collection privateTypedefStatements =
13
                findTagValues(cls, TV_NAME_TYPEDEF_PRIVATE);
14
            if (!publicTypedefStatements.isEmpty()) {
15
                sb.append(LINE_SEPARATOR).append(" public:")
16
                    .append(LINE_SEPARATOR).append(indent);
17
                sb.append("// public type definitions for header defined "
18
                      + "by Tag entries in ArgoUML").append(LINE_SEPARATOR);
19
                sb.append(indent);
20
                sb.append("// Result: typedef <typedef_public> "
21
                      + "<tag_value>;").append(LINE_SEPARATOR);
22
                Iterator typedefEnum = publicTypedefStatements.iterator();
23
24
                while (typedefEnum.hasNext()) {
25
                    sb.append(indent).append("typedef ");
26
                    sb.append(typedefEnum.next())
27
                        .append(";").append(LINE_SEPARATOR);
28
                }
29
            }
30
            if (!protectedTypedefStatements.isEmpty()) {
31
                sb.append(LINE_SEPARATOR).append(" protected:")
32
                    .append(LINE_SEPARATOR).append(indent);
33
                sb.append("// protected type definitions for header defined "
34
                      + "by Tag entries in ArgoUML").append(LINE_SEPARATOR);
35
                sb.append(indent);
36
                sb.append("// Result: typedef <typedef_protected> "
37
                      + "<tag_value>;").append(LINE_SEPARATOR);
38
                Iterator typedefEnum = protectedTypedefStatements.iterator();
39
40
                while (typedefEnum.hasNext()) {
41
                    sb.append(indent).append("typedef ");
42
                    sb.append(typedefEnum.next())
43
                        .append(";").append(LINE_SEPARATOR);
44
                }
45
            }
46
            if (!privateTypedefStatements.isEmpty()) {
47
                sb.append(LINE_SEPARATOR).append(" private:")
48
                    .append(LINE_SEPARATOR).append(indent);
49
                sb.append("// private type definitions for header defined "
50
                      + "by Tag entries in ArgoUML").append(LINE_SEPARATOR);
51
                sb.append(indent);
52
                sb.append("// Result: typedef <typedef_private> "
53
                      + "<tag_value>;").append(LINE_SEPARATOR);
54
                Iterator typedefEnum = privateTypedefStatements.iterator();
55
56
                while (typedefEnum.hasNext()) {
57
                    sb.append(indent).append("typedef ");
58
                    sb.append(typedefEnum.next()).append(";")
59
                        .append(LINE_SEPARATOR);
60
                }
61
            }
62
        }
63
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.500
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    2
    for (T item : items)
    2
    for (T item : items)
    11
    while (typedefEnum.hasNext())
    Differences
    Expression1Expression2Difference
    java.util.Collectionjava.util.CollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection<T> of variable items does not match with type java.util.Collection of variable publicTypedefStatements
    • Make classes java.util.Collection and java.util.Collection extend a common superclass
    11
    while (typedefEnum.hasNext())
    3
    msg.append("\t");
                                            
    4
    msg.append(item.toString());
    4
    msg.append(item.toString());
    12
    sb.append(indent).append("typedef ");
    Differences
    Expression1Expression2Difference
    item.toString()"typedef "TYPE_COMPATIBLE_REPLACEMENT
    msgsb.append(indent)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression item.toString() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12
    sb.append(indent).append("typedef ");
    5
    msg.append("\n");
    5
    msg.append("\n");
    13
    sb.append(typedefEnum.next()).append(";").append(LINE_SEPARATOR);
    Differences
    Expression1Expression2Difference
    "\n"LINE_SEPARATORTYPE_COMPATIBLE_REPLACEMENT
    msgsb.append(typedefEnum.next()).append(";")TYPE_COMPATIBLE_REPLACEMENT
    13
    sb.append(typedefEnum.next()).append(";").append(LINE_SEPARATOR);
    Precondition Violations (2)
    Row Violation
    1Type java.util.Collection<T> of variable items does not match with type java.util.Collection of variable publicTypedefStatements
    2Expression item.toString() cannot be parameterized, because it has dependencies to/from statements that will be extracted