NestedElement nestedElement = (NestedElement) i.next(); if (nestedElement.name == null) { throw new BuildException("scriptdef <element> elements " + "must specify an element name"); } if (nestedElementMap.containsKey(nestedElement.name)) { throw new BuildException("scriptdef <" + name + "> declares " + "the " + nestedElement.name + " nested element more " + "than once"); }
Attribute attribute = (Attribute) i.next(); if (attribute.name == null) { throw new BuildException("scriptdef <attribute> elements " + "must specify an attribute name"); } if (attributeSet.contains(attribute.name)) { throw new BuildException("scriptdef <" + name + "> declares " + "the " + attribute.name + " attribute more than once"); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/script/ScriptDef.java
Method name: void execute() Method name: void execute()
Number of AST nodes: 5 Number of AST nodes: 5
1
NestedElement nestedElement = (NestedElement) i.next();
1
Attribute attribute = (Attribute) i.next();
2
            if (nestedElement.name == null) {
2
            if (attribute.name == null) {
3
                throw new BuildException("scriptdef <element> elements "
3
                throw new BuildException("scriptdef <attribute> elements "
4
                    + "must specify an element name");
4
                    + "must specify an attribute name");
5
            }
5
            }
6
            if (nestedElementMap.containsKey(nestedElement.name)) {
6
            if (attributeSet.contains(attribute.name)) {
7
                throw new BuildException("scriptdef <" + name + "> declares "
7
                throw new BuildException("scriptdef <" + name + "> declares "
8
                    + "the " + nestedElement.name + " nested element more "
8
                    + "the " + 
9
                    + "than once");
9
attribute.name + " attribute more than once");
10
            }
10
            }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.7
Clones locationClones are in the same method
Number of node comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)2.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                            
    10
    Attribute attribute = (Attribute)i.next();
    Preondition Violations
    Unmatched statement Attribute attribute=(Attribute)i.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    Attribute attribute = (Attribute)i.next();
    18
    NestedElement nestedElement = (NestedElement)i.next();
    18
    NestedElement nestedElement = (NestedElement)i.next();
    Preondition Violations
    Unmatched statement NestedElement nestedElement=(NestedElement)i.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                    
    19
    if (nestedElement.name == null)
    19
    if (nestedElement.name == null)
    11
    if (attribute.name == null)
    Differences
    Expression1Expression2Difference
    nestedElementattributeVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.taskdefs.optional.script.ScriptDef.NestedElementorg.apache.tools.ant.taskdefs.optional.script.ScriptDef.AttributeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression nestedElement.name cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression attribute.name cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.lang.String of variable nestedElement.name does not match with type java.lang.String of variable attribute.name
    • Make classes org.apache.tools.ant.taskdefs.optional.script.ScriptDef.NestedElement and org.apache.tools.ant.taskdefs.optional.script.ScriptDef.Attribute extend a common superclass
    11
    if (attribute.name == null)
    20
    throw new BuildException("scriptdef <element> elements " + "must specify an element name");
    20
    throw new BuildException("scriptdef <element> elements " + "must specify an element name");
    12
    throw new BuildException("scriptdef <attribute> elements " + "must specify an attribute name");
    Differences
    Expression1Expression2Difference
    "scriptdef elements ""scriptdef elements "LITERAL_VALUE_MISMATCH
    "must specify an element name""must specify an attribute name"LITERAL_VALUE_MISMATCH
    12
    throw new BuildException("scriptdef <attribute> elements " + "must specify an attribute name");
    Precondition Violations (5)
    Row Violation
    1Unmatched statement Attribute attribute=(Attribute)i.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement NestedElement nestedElement=(NestedElement)i.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Expression nestedElement.name cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression attribute.name cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Type java.lang.String of variable nestedElement.name does not match with type java.lang.String of variable attribute.name