if ( operand instanceof Integer ) { int result = Primitive.intUnaryOperation((Integer)operand, kind); // ++ and -- must be cast back the original type if(kind == INCR || kind == DECR) { if(operandType == Byte.TYPE) return new Byte((byte)result); if(operandType == Short.TYPE) return new Short((short)result); if(operandType == Character.TYPE) return new Character((char)result); } return new Integer(result); } else if(operand instanceof Long) return new Long(Primitive.longUnaryOperation((Long)operand, kind)); else if(operand instanceof Float) return new Float(Primitive.floatUnaryOperation((Float)operand, kind)); else if(operand instanceof Double) return new Double(Primitive.doubleUnaryOperation((Double)operand, kind)); else throw new InterpreterError("An error occurred. Please call technical support.");
if(operand instanceof Integer) { int result = intUnaryOperation((Integer)operand, kind); // ++ and -- must be cast back the original type if(kind == INCR || kind == DECR) { if(operandType == Byte.TYPE) return new Primitive((byte)result); if(operandType == Short.TYPE) return new Primitive((short)result); if(operandType == Character.TYPE) return new Primitive((char)result); } return new Primitive(result); } else if(operand instanceof Long) return new Primitive(longUnaryOperation((Long)operand, kind)); else if(operand instanceof Float) return new Primitive(floatUnaryOperation((Float)operand, kind)); else if(operand instanceof Double) return new Primitive(doubleUnaryOperation((Double)operand, kind)); else throw new InterpreterError( "An error occurred. Please call technical support.");
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/bsh/BSHUnaryExpression.java File path: /jEdit-4.2/src/bsh/Primitive.java
Method name: Object primitiveWrapperUnaryOperation(Object, int) Method name: Primitive unaryOperation(Primitive, int)
Number of AST nodes: 17 Number of AST nodes: 17
1
if ( operand instanceof Integer )
1
if(operand instanceof Integer)
2
        {
2
        {
3
            int result = Primitive.intUnaryOperation((Integer)operand, kind);
3
            int result = intUnaryOperation((Integer)operand, kind);
4
            // ++ and -- must be cast back the original type
4
            // ++ and -- must be cast back the original type
5
            if(kind == INCR || kind == DECR)
5
            if(kind == INCR || kind == DECR)
6
            {
6
            {
7
                if(operandType == Byte.TYPE)
7
                if(operandType == Byte.TYPE)
8
                    return new Byte((byte)result);
8
                    return new Primitive((byte)result);
9
                if(operandType == Short.TYPE)
9
                if(operandType == Short.TYPE)
10
                    return new Short((short)result);
10
                    return new Primitive((short)result);
11
                if(operandType == Character.TYPE)
11
                if(operandType == Character.TYPE)
12
                    return new Character((char)result);
12
                    return new Primitive((char)result);
13
            }
13
            }
14
            return new Integer(result);
14
            return new Primitive(result);
15
        }
15
        }
16
        else if(operand instanceof Long)
16
        else if(operand instanceof Long)
17
            return new Long(Primitive.longUnaryOperation((Long)operand, kind));
17
            return new Primitive(longUnaryOperation((Long)operand, kind));
18
        else if(operand instanceof Float)
18
        else if(operand instanceof Float)
19
            return new Float(Primitive.floatUnaryOperation((Float)operand, kind));
19
            return new Primitive(floatUnaryOperation((Float)operand, kind));
20
        else if(operand instanceof Double)
20
        else if(operand instanceof Double)
21
            return new Double(Primitive.doubleUnaryOperation((Double)operand, kind));
21
            return new Primitive(doubleUnaryOperation((Double)operand, kind));
22
        else
22
        else
23
            throw new InterpreterError(
23
            throw new InterpreterError(
24
"An error occurred.  Please call technical support.");
24
				"An error occurred.  Please call technical support.");
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)2.2
Clones locationClones are in different classes
Number of node comparisons73
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment7
    Number of unmapped statements in the second code fragment7
    Time elapsed for statement mapping (ms)4.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    else if (operand instanceof Integer)
    9
    else if (operand instanceof Integer)
    6
    int result = Primitive.intUnaryOperation((Integer)operand, kind);
    6
    int result = Primitive.intUnaryOperation((Integer)operand, kind);
    10
    int result = intUnaryOperation((Integer)operand, kind);
    Differences
    Expression1Expression2Difference
    PrimitiveMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression Primitive.intUnaryOperation((Integer)operand,kind) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression intUnaryOperation((Integer)operand,kind) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    int result = intUnaryOperation((Integer)operand, kind);
    7
    if (kind == INCR || kind == DECR)
    11
    if (kind == INCR || kind == DECR)
    8
    if (operandType == Byte.TYPE)
    12
    if (operandType == Byte.TYPE)
    9
    return new Byte((byte)result);
                                                                      
                                                                                  
    13
    return new Primitive((byte)result);
    10
    if (operandType == Short.TYPE)
    14
    if (operandType == Short.TYPE)
    11
    return new Short((short)result);
                                                                            
                                                                                    
    15
    return new Primitive((short)result);
    12
    if (operandType == Character.TYPE)
    16
    if (operandType == Character.TYPE)
    13
    return new Character((char)result);
                                                                                  
                                                                                  
    17
    return new Primitive((char)result);
    14
    return new Integer(result);
                                                                  
                                                                      
    18
    return new Primitive(result);
    15
    else if (operand instanceof Long)
    19
    else if (operand instanceof Long)
    16
    return new Long(Primitive.longUnaryOperation((Long)operand, kind));
    16
    return new Long(Primitive.longUnaryOperation((Long)operand, kind));
    Preondition Violations
    Unmatched statement return new Long(Primitive.longUnaryOperation((Long)operand,kind)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return new Long(Primitive.longUnaryOperation((Long)operand,kind));
                                                                                                                                                
                                                                                                                                      
    20
    return new Primitive(longUnaryOperation((Long)operand, kind));
    Preondition Violations
    Unmatched statement return new Primitive(longUnaryOperation((Long)operand,kind)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return new Primitive(longUnaryOperation((Long)operand,kind));
    20
    return new Primitive(longUnaryOperation((Long)operand, kind));
    17
    else if (operand instanceof Float)
    21
    else if (operand instanceof Float)
    18
    return new Float(Primitive.floatUnaryOperation((Float)operand, kind));
    18
    return new Float(Primitive.floatUnaryOperation((Float)operand, kind));
    Preondition Violations
    Unmatched statement return new Float(Primitive.floatUnaryOperation((Float)operand,kind)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return new Float(Primitive.floatUnaryOperation((Float)operand,kind));
                                                                                                                                                      
                                                                                                                                          
    22
    return new Primitive(floatUnaryOperation((Float)operand, kind));
    Preondition Violations
    Unmatched statement return new Primitive(floatUnaryOperation((Float)operand,kind)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return new Primitive(floatUnaryOperation((Float)operand,kind));
    22
    return new Primitive(floatUnaryOperation((Float)operand, kind));
    19
    else if (operand instanceof Double)
    23
    else if (operand instanceof Double)
    20
    return new Double(Primitive.doubleUnaryOperation((Double)operand, kind));
    20
    return new Double(Primitive.doubleUnaryOperation((Double)operand, kind));
    Preondition Violations
    Unmatched statement return new Double(Primitive.doubleUnaryOperation((Double)operand,kind)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return new Double(Primitive.doubleUnaryOperation((Double)operand,kind));
                                                                                                                                                            
                                                                                                                                              
    24
    return new Primitive(doubleUnaryOperation((Double)operand, kind));
    Preondition Violations
    Unmatched statement return new Primitive(doubleUnaryOperation((Double)operand,kind)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched return new Primitive(doubleUnaryOperation((Double)operand,kind));
    24
    return new Primitive(doubleUnaryOperation((Double)operand, kind));
    else
    else
    21
    throw new InterpreterError("An error occurred.  Please call technical support.");
    25
    throw new InterpreterError("An error occurred.  Please call technical support.");
    Precondition Violations (14)
    Row Violation
    1Expression Primitive.intUnaryOperation((Integer)operand,kind) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression intUnaryOperation((Integer)operand,kind) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement return new Long(Primitive.longUnaryOperation((Long)operand,kind)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched return new Long(Primitive.longUnaryOperation((Long)operand,kind));
    5Unmatched statement return new Primitive(longUnaryOperation((Long)operand,kind)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched return new Primitive(longUnaryOperation((Long)operand,kind));
    7Unmatched statement return new Float(Primitive.floatUnaryOperation((Float)operand,kind)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8Unmatched return new Float(Primitive.floatUnaryOperation((Float)operand,kind));
    9Unmatched statement return new Primitive(floatUnaryOperation((Float)operand,kind)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10Unmatched return new Primitive(floatUnaryOperation((Float)operand,kind));
    11Unmatched statement return new Double(Primitive.doubleUnaryOperation((Double)operand,kind)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    12Unmatched return new Double(Primitive.doubleUnaryOperation((Double)operand,kind));
    13Unmatched statement return new Primitive(doubleUnaryOperation((Double)operand,kind)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    14Unmatched return new Primitive(doubleUnaryOperation((Double)operand,kind));