List<String> result = new ArrayList<String>(); StringBuffer currentWord = new StringBuffer(); int length = sourceName.length(); boolean lastIsLower = false; for (int index = 0; index < length; index++) { char curChar = sourceName.charAt(index); if (Character.isUpperCase(curChar) || (!lastIsLower && Character.isDigit(curChar)) || curChar == sourceSeparator) { if (lastIsLower || curChar == sourceSeparator) { result.add(currentWord.toString()); currentWord = new StringBuffer(); } lastIsLower = false; } else { if (!lastIsLower) { int currentWordLength = currentWord.length(); if (currentWordLength > 1) { char lastChar = currentWord.charAt(--currentWordLength); currentWord.setLength(currentWordLength); result.add(currentWord.toString()); currentWord = new StringBuffer(); currentWord.append(lastChar); } } lastIsLower = true; } if (curChar != sourceSeparator) { currentWord.append(curChar); } } result.add(currentWord.toString()); return result;
List<String> result = new ArrayList<String>(); StringBuffer currentWord = new StringBuffer(); int length = sourceName.length(); boolean lastIsLower = false; for (int index=0; index<length; index++) { char curChar = sourceName.charAt(index); if (Character.isUpperCase(curChar) || curChar == sourceSeparator) { if (lastIsLower || curChar == sourceSeparator) { result.add(currentWord.toString()); currentWord = new StringBuffer(); } lastIsLower = false; } else { if (!lastIsLower) { int currentWordLength = currentWord.length(); if (currentWordLength > 1) { char lastChar = currentWord.charAt(--currentWordLength); currentWord.setLength(currentWordLength); result.add(currentWord.toString()); currentWord = new StringBuffer(); currentWord.append(lastChar); } } lastIsLower = true; } if (curChar != sourceSeparator) { currentWord.append(curChar); } } result.add(currentWord.toString()); return result;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/edit/provider/ReflectiveItemProvider.java File path: /emf-2.4.1/src/org/eclipse/emf/mapping/domain/AdapterFactoryMappingDomain.java
Method name: List parseName(String, char) Method name: List parseName(String, char)
Number of AST nodes: 24 Number of AST nodes: 24
1
List<String> result = new ArrayList<String>();
1
List<String> result = new ArrayList<String>();
2
    StringBuffer currentWord = new StringBuffer();
2
    StringBuffer currentWord = new StringBuffer();
3
    int length = sourceName.length();
3
    int length = sourceName.length();
4
    boolean lastIsLower = false;
4
    boolean lastIsLower = false;
5
    for (int index = 0; index < length; index++)
5
    for (int index=0; index<length; index++)
6
    {
6
    {
7
      char curChar = sourceName.charAt(index);
7
      char curChar = sourceName.charAt(index);
8
      if (Character.isUpperCase(curChar) || (!lastIsLower && Character.isDigit(curChar)) || curChar == sourceSeparator)
8
      if (Character.isUpperCase(curChar) || curChar == sourceSeparator)
9
      {
9
      {
10
        if (lastIsLower || curChar == sourceSeparator)
10
        if (lastIsLower || curChar == sourceSeparator)
11
        {
11
        {
12
          result.add(currentWord.toString());
12
          result.add(currentWord.toString());
13
          currentWord = new StringBuffer();
13
          currentWord = new StringBuffer();
14
        }
14
        }
15
        lastIsLower = false;
15
        lastIsLower = false;
16
      }
16
      }
17
      else
17
      else
18
      {
18
      {
19
        if (!lastIsLower)
19
        if (!lastIsLower)
20
        {
20
        {
21
          int currentWordLength = currentWord.length();
21
          int currentWordLength = currentWord.length();
22
          if (currentWordLength > 1)
22
          if (currentWordLength > 1)
23
          {
23
          {
24
            char lastChar = currentWord.charAt(--currentWordLength);
24
            char lastChar = currentWord.charAt(--currentWordLength);
25
            currentWord.setLength(currentWordLength);
25
            currentWord.setLength(currentWordLength);
26
            result.add(currentWord.toString());
26
            result.add(currentWord.toString());
27
            currentWord = new StringBuffer();
27
            currentWord = new StringBuffer();
28
            currentWord.append(lastChar);
28
            currentWord.append(lastChar);
29
          }
29
          }
30
        }
30
        }
31
        lastIsLower = true;
31
        lastIsLower = true;
32
      }
32
      }
33
      if (curChar != sourceSeparator)
33
      if (curChar != sourceSeparator)
34
      {
34
      {
35
        currentWord.append(curChar);
35
        currentWord.append(curChar);
36
      }
36
      }
37
    }
37
    }
38
    result.add(currentWord.toString());
38
    result.add(currentWord.toString());
39
    return result;
39
    return result;
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)1.0
Clones locationClones are in different classes
Number of node comparisons86
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements24
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)16.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    List<String> result = new ArrayList<String>();
    1
    List<String> result = new ArrayList<String>();
    2
    StringBuffer currentWord = new StringBuffer();
    2
    StringBuffer currentWord = new StringBuffer();
    3
    int length = sourceName.length();
    3
    int length = sourceName.length();
    4
    boolean lastIsLower = false;
    4
    boolean lastIsLower = false;
    5
    for (int index = 0; index < length; index++)
    5
    for (int index = 0; index < length; index++)
    6
    char curChar = sourceName.charAt(index);
    6
    char curChar = sourceName.charAt(index);
    7
    if (Character.isUpperCase(curChar) || (!lastIsLower && Character.isDigit(curChar)) || curChar == sourceSeparator)
    7
    if (Character.isUpperCase(curChar) || (!lastIsLower && Character.isDigit(curChar)) || curChar == sourceSeparator)
    7
    if (Character.isUpperCase(curChar) || curChar == sourceSeparator)
    Differences
    Expression1Expression2Difference
    (!lastIsLower && Character.isDigit(curChar))curChar == sourceSeparatorINFIX_RIGHT_OPERAND_MISMATCH
    Character.isUpperCase(curChar) || (!lastIsLower && Character.isDigit(curChar)) || curChar == sourceSeparatorCharacter.isUpperCase(curChar) || curChar == sourceSeparatorINFIX_EXTENDED_OPERAND_NUMBER_MISMATCH
    Preondition Violations
    Expression (!lastIsLower && Character.isDigit(curChar)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression curChar == sourceSeparator cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Character.isUpperCase(curChar) || (!lastIsLower && Character.isDigit(curChar)) || curChar == sourceSeparator cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Character.isUpperCase(curChar) || curChar == sourceSeparator cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    if (Character.isUpperCase(curChar) || curChar == sourceSeparator)
    8
    if (lastIsLower || curChar == sourceSeparator)
    8
    if (lastIsLower || curChar == sourceSeparator)
    9
    result.add(currentWord.toString());
    9
    result.add(currentWord.toString());
    10
    currentWord = new StringBuffer();
    10
    currentWord = new StringBuffer();
    11
    lastIsLower = false;
    11
    lastIsLower = false;
    else
    else
    12
    if (!lastIsLower)
    12
    if (!lastIsLower)
    13
    int currentWordLength = currentWord.length();
    13
    int currentWordLength = currentWord.length();
    14
    if (currentWordLength > 1)
    14
    if (currentWordLength > 1)
    15
    char lastChar = currentWord.charAt(--currentWordLength);
    15
    char lastChar = currentWord.charAt(--currentWordLength);
    16
    currentWord.setLength(currentWordLength);
    16
    currentWord.setLength(currentWordLength);
    17
    result.add(currentWord.toString());
    17
    result.add(currentWord.toString());
    18
    currentWord = new StringBuffer();
    18
    currentWord = new StringBuffer();
    19
    currentWord.append(lastChar);
    19
    currentWord.append(lastChar);
    20
    lastIsLower = true;
    20
    lastIsLower = true;
    21
    if (curChar != sourceSeparator)
    21
    if (curChar != sourceSeparator)
    22
    currentWord.append(curChar);
    22
    currentWord.append(curChar);
    23
    result.add(currentWord.toString());
    23
    result.add(currentWord.toString());
    24
    return result;
    24
    return result;
    Precondition Violations (4)
    Row Violation
    1Expression (!lastIsLower && Character.isDigit(curChar)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression curChar == sourceSeparator cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression Character.isUpperCase(curChar) || (!lastIsLower && Character.isDigit(curChar)) || curChar == sourceSeparator cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression Character.isUpperCase(curChar) || curChar == sourceSeparator cannot be parameterized, because it has dependencies to/from statements that will be extracted