if(importedPackages == null) importedPackages = new Vector(); // If it exists, remove it and add it at the end (avoid memory leak) if ( importedPackages.contains( name ) ) importedPackages.remove( name ); importedPackages.addElement(name); nameSpaceChanged();
if ( importedStatic == null ) importedStatic = new Vector(); // If it exists, remove it and add it at the end (avoid memory leak) if ( importedStatic.contains( clas ) ) importedStatic.remove( clas ); importedStatic.addElement( clas ); nameSpaceChanged();
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/bsh/NameSpace.java File path: /jEdit-4.2/src/bsh/NameSpace.java
Method name: void importPackage(String) Method name: void importStatic(Class)
Number of AST nodes: 6 Number of AST nodes: 6
1
if(importedPackages == null)
1
if ( importedStatic == null )
2
			importedPackages = new Vector();
2
			importedStatic = new Vector();
3
		// If it exists, remove it and add it at the end (avoid memory leak)
3
		// If it exists, remove it and add it at the end (avoid memory leak)
4
		if ( importedPackages.contains( name ) )
4
		if ( importedStatic.contains( clas ) )
5
			importedPackages.remove( name );
5
			importedStatic.remove( clas );
6
		importedPackages.addElement(name);
6
		importedStatic.addElement( clas );
7
		nameSpaceChanged();
7
		nameSpaceChanged();
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.5
Clones locationClones are declared in the same class
Number of node comparisons17
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)3.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (importedPackages == null)
    1
    if (importedPackages == null)
    1
    if (importedStatic == null)
    Differences
    Expression1Expression2Difference
    importedPackagesimportedStaticVARIABLE_NAME_MISMATCH
    1
    if (importedStatic == null)
    2
    importedPackages = new Vector();
    2
    importedPackages = new Vector();
    2
    importedStatic = new Vector();
    Differences
    Expression1Expression2Difference
    importedPackagesimportedStaticVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression importedPackages is a field being modified, and thus it cannot be parameterized
    Expression importedStatic is a field being modified, and thus it cannot be parameterized
    2
    importedStatic = new Vector();
    3
    if (importedPackages.contains(name))
    3
    if (importedPackages.contains(name))
    3
    if (importedStatic.contains(clas))
    Differences
    Expression1Expression2Difference
    nameclasVARIABLE_NAME_MISMATCH
    java.lang.Stringjava.lang.ClassVARIABLE_TYPE_MISMATCH
    importedPackagesimportedStaticVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type java.lang.String of variable name does not match with type java.lang.Class of variable clas
    • Make classes java.lang.String and java.lang.Class extend a common superclass
    Expression importedPackages cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression importedStatic cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    if (importedStatic.contains(clas))
    4
    importedPackages.remove(name);
    4
    importedPackages.remove(name);
    4
    importedStatic.remove(clas);
    Differences
    Expression1Expression2Difference
    nameclasVARIABLE_NAME_MISMATCH
    java.lang.Stringjava.lang.ClassVARIABLE_TYPE_MISMATCH
    importedPackagesimportedStaticVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type java.lang.String of variable name does not match with type java.lang.Class of variable clas
    • Make classes java.lang.String and java.lang.Class extend a common superclass
    Expression importedPackages cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression importedStatic cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    importedStatic.remove(clas);
    5
    importedPackages.addElement(name);
    5
    importedPackages.addElement(name);
    5
    importedStatic.addElement(clas);
    Differences
    Expression1Expression2Difference
    nameclasVARIABLE_NAME_MISMATCH
    java.lang.Stringjava.lang.ClassVARIABLE_TYPE_MISMATCH
    importedPackagesimportedStaticVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type java.lang.String of variable name does not match with type java.lang.Class of variable clas
    • Make classes java.lang.String and java.lang.Class extend a common superclass
    Expression importedPackages cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression importedStatic cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    importedStatic.addElement(clas);
    6
    nameSpaceChanged();
    6
    nameSpaceChanged();
    Precondition Violations (11)
    Row Violation
    1Expression importedPackages is a field being modified, and thus it cannot be parameterized
    2Expression importedStatic is a field being modified, and thus it cannot be parameterized
    3Type java.lang.String of variable name does not match with type java.lang.Class of variable clas
    4Expression importedPackages cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression importedStatic cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Type java.lang.String of variable name does not match with type java.lang.Class of variable clas
    7Expression importedPackages cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression importedStatic cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Type java.lang.String of variable name does not match with type java.lang.Class of variable clas
    10Expression importedPackages cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression importedStatic cannot be parameterized, because it has dependencies to/from statements that will be extracted