/** * Find a class within the given namespace that has the given identifier. * * @param identifier the class identifier * @param ns namespace to look in * @return the class if found, null otherwise */ private static Object findClass(String identifier, Object ns) { Collection classes = getCoreHelper().getAllClasses(ns); Iterator it = classes.iterator(); while (it.hasNext()) { Object candidateClass = it.next(); if (Model.getFacade().getName(candidateClass).equals(identifier)) { return candidateClass; } } return null; }
private Object buildImport(Object element, Object srcFile) { // TODO: add <<javaImport>> stereotype to Java profile - thn Collection dependencies = Model.getCoreHelper().getDependencies( element, srcFile); for (Object dep : dependencies) { for (Object stereotype : Model.getFacade().getStereotypes(dep)) { if ("javaImport".equals( Model.getFacade().getName(stereotype))) { return dep; } } } // Didn't find it. Let's create one. Object pkgImport = Model.getCoreFactory().buildDependency(srcFile, element); if (Model.getFacade().getUmlVersion().charAt(0) == '1') { // TODO: support for stereotypes in eUML Model.getCoreHelper().addStereotype(pkgImport, getUML1Stereotype("javaImport")); ProjectManager.getManager().updateRoots(); } String newName = makeDependencyName(srcFile, element); Model.getCoreHelper().setName(pkgImport, newName); newElements.add(pkgImport); return pkgImport; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml-cpp/src/org/argouml/language/cpp/reveng/ModelerImpl.java File path: /ArgoUML-0.34-src/argouml-java/src/org/argouml/language/java/reveng/Modeller.java
Method name: Object findClass(String, Object) Method name: Object buildImport(Object, Object)
Number of AST nodes: 4 Number of AST nodes: 3
1
/**
1
private Object buildImport(Object element, Object srcFile) {
2
     * Find a class within the given namespace that has the given identifier.
2
        // TODO: add <<javaImport>> stereotype to Java profile - thn
3
     *
3
        Collection dependencies = Model.getCoreHelper().getDependencies(
4
     * @param identifier the class identifier
4
                element, srcFile);
5
     * @param ns namespace to look in
5
        for (Object dep : dependencies) {
6
     * @return the class if found, null otherwise
6
            for (Object stereotype : Model.getFacade().getStereotypes(dep)) {
7
     */
7
                if ("javaImport".equals(
8
    private static Object findClass(String identifier, Object ns) {
8
                        Model.getFacade().getName(stereotype))) {
9
        Collection classes = getCoreHelper().getAllClasses(ns);
9
                    return dep;
10
        Iterator it = classes.iterator();
10
                }
11
        while (it.hasNext()) {
11
            }
12
            Object candidateClass = it.next();
12
        }
13
            if (Model.getFacade().getName(candidateClass).equals(identifier)) {
13
14
                return candidateClass;
14
        // Didn't find it. Let's create one.
15
            }
15
        Object pkgImport = Model.getCoreFactory().buildDependency(srcFile,
16
        }
16
                element);
17
        return null;
17
        if (Model.getFacade().getUmlVersion().charAt(0) == '1') {
18
    }
18
            // TODO: support for stereotypes in eUML
19
            Model.getCoreHelper().addStereotype(pkgImport,
20
                    getUML1Stereotype("javaImport"));
21
            ProjectManager.getManager().updateRoots();
22
        }
23
        String newName = makeDependencyName(srcFile, element);
24
        Model.getCoreHelper().setName(pkgImport, newName);
25
        newElements.add(pkgImport);
26
        return pkgImport;
27
    }
  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 fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score1.000
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    while (it.hasNext())
    3
    while (it.hasNext())
    3
    for (Object stereotype : Model.getFacade().getStereotypes(dep))
    Differences
    Expression1Expression2Difference
    candidateClassstereotypeVARIABLE_NAME_MISMATCH
    classesModel.getFacade().getStereotypes(dep)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression candidateClass cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    for (Object stereotype : Model.getFacade().getStereotypes(dep))
    4
    Object candidateClass = it.next();
    4
    Object candidateClass = it.next();
    Differences
    Expression1Expression2Difference
    candidateClassstereotypeVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression candidateClass cannot be parameterized, because it has dependencies to/from statements that will be extracted
                                                                          
    5
    if (Model.getFacade().getName(candidateClass).equals(identifier))
    5
    if (Model.getFacade().getName(candidateClass).equals(identifier))
    4
    if ("javaImport".equals(Model.getFacade().getName(stereotype)))
    Differences
    Expression1Expression2Difference
    identifierModel.getFacade().getName(stereotype)TYPE_COMPATIBLE_REPLACEMENT
    Model.getFacade().getName(candidateClass)"javaImport"TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression Model.getFacade().getName(stereotype) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    if ("javaImport".equals(Model.getFacade().getName(stereotype)))
    6
    return candidateClass;
    6
    return candidateClass;
    5
    return dep;
    Differences
    Expression1Expression2Difference
    candidateClassdepVARIABLE_NAME_MISMATCH
    5
    return dep;
    Precondition Violations (3)
    Row Violation
    1Expression candidateClass cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression candidateClass cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression Model.getFacade().getName(stereotype) cannot be parameterized, because it has dependencies to/from statements that will be extracted