private StringBuffer generateIncludes(StringBuffer sb) { for (Iterator it = systemInc.iterator(); it.hasNext(); ) { String inc = (String) it.next(); sb.append("#include <"); sb.append(inc).append('>').append(LINE_SEPARATOR); } // separate system from external headers if (systemInc.size() > 0) sb.append(LINE_SEPARATOR); for (Iterator it = extInc.iterator(); it.hasNext(); ) { String inc = (String) it.next(); sb.append("#include <"); sb.append(inc).append('>').append(LINE_SEPARATOR); } // separate external from local headers if (extInc.size() > 0) sb.append(LINE_SEPARATOR); for (Iterator it = localInc.iterator(); it.hasNext(); ) { String inc = (String) it.next(); sb.append("#include \"").append(inc).append("\"" + LINE_SEPARATOR); } return sb; }
/** * 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-cpp/src/org/argouml/language/cpp/generator/GeneratorCpp.java File path: /ArgoUML-0.34-src/argouml-cpp/src/org/argouml/language/cpp/generator/GeneratorCpp.java
Method name: StringBuffer generateIncludes(StringBuffer) Method name: void generateClassifierBodyTypedefs(Object, StringBuffer)
Number of AST nodes: 4 Number of AST nodes: 3
1
private StringBuffer generateIncludes(StringBuffer sb) {
1
/**
2
        for (Iterator it = systemInc.iterator(); it.hasNext(); ) {
2
     * Generates the association ends of the body of a class or interface.
3
            String inc = (String) it.next();
3
     * @param cls
4
            sb.append("#include <");
4
     * @param sb Where to put the result.
5
            sb.append(inc).append('>').append(LINE_SEPARATOR);
5
     */
6
        }
6
    private void generateClassifierBodyTypedefs(Object cls, StringBuffer sb) {
7
        // separate system from external headers
7
        if (generatorPass == HEADER_PASS) {
8
        if (systemInc.size() > 0) sb.append(LINE_SEPARATOR);
8
            Collection publicTypedefStatements =
9
        for (Iterator it = extInc.iterator(); it.hasNext(); ) {
9
                findTagValues(cls, TV_NAME_TYPEDEF_PUBLIC);
10
            String inc = (String) it.next();
10
            Collection protectedTypedefStatements =
11
            sb.append("#include <");
11
                findTagValues(cls, TV_NAME_TYPEDEF_PROTECTED);
12
            sb.append(inc).append('>').append(LINE_SEPARATOR);
12
            Collection privateTypedefStatements =
13
        }
13
                findTagValues(cls, TV_NAME_TYPEDEF_PRIVATE);
14
        // separate external from local headers
14
            if (!publicTypedefStatements.isEmpty()) {
15
        if (extInc.size() > 0) sb.append(LINE_SEPARATOR);
15
                sb.append(LINE_SEPARATOR).append(" public:")
16
        for (Iterator it = localInc.iterator(); it.hasNext(); ) {
16
                    .append(LINE_SEPARATOR).append(indent);
17
            String inc = (String) it.next();
17
                sb.append("// public type definitions for header defined "
18
            sb.append("#include \"").append(inc).append("\"" + LINE_SEPARATOR);
18
                      + "by Tag entries in ArgoUML").append(LINE_SEPARATOR);
19
        }
19
                sb.append(indent);
20
        return sb;
20
                sb.append("// Result: typedef <typedef_public> "
21
    }
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 fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.500
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    for (Iterator it = systemInc.iterator(); it.hasNext(); )
    1
    for (Iterator it = systemInc.iterator(); it.hasNext(); )
    11
    while (typedefEnum.hasNext())
    Differences
    Expression1Expression2Difference
    ittypedefEnumVARIABLE_NAME_MISMATCH
    java.util.Setjava.util.CollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Set of variable systemInc does not match with type java.util.Collection of variable publicTypedefStatements
    • Make classes java.util.Set and java.util.Collection extend a common superclass
    11
    while (typedefEnum.hasNext())
    2
    String inc = (String)it.next();
                                                                    
    3
    sb.append("#include <");
    3
    sb.append("#include <");
    12
    sb.append(indent).append("typedef ");
    Differences
    Expression1Expression2Difference
    "#include <""typedef "LITERAL_VALUE_MISMATCH
    sbsb.append(indent)TYPE_COMPATIBLE_REPLACEMENT
    12
    sb.append(indent).append("typedef ");
    4
    sb.append(inc).append('>').append(LINE_SEPARATOR);
    4
    sb.append(inc).append('>').append(LINE_SEPARATOR);
    Preondition Violations
    Unmatched statement sb.append(inc).append('>').append(LINE_SEPARATOR); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                              
                                                                                                                                              
    13
    sb.append(typedefEnum.next()).append(";").append(LINE_SEPARATOR);
    Precondition Violations (3)
    Row Violation
    1Type java.util.Set of variable systemInc does not match with type java.util.Collection of variable publicTypedefStatements
    2Unmatched statement sb.append(inc).append('>').append(LINE_SEPARATOR); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Clone fragment #1 returns variables inc , while Clone fragment #2 returns variables