if (position < document.getLength()) { int length = len; if (position + length >= document.getLength()) { length = document.getLength() - (int) position; } if (off + length >= cbuf.length) { length = cbuf.length - off; } try { String s = document.getText((int) position, length); position += length; for (int i = 0; i < length; i++) { // The Ostermiller SQLLexer crashes with an ArrayIndexOutOfBoundsException // if the char is greater then 255. So we prevent the char from being greater. // This is surely not a proper Unicode treatment but it doesn't seem // to do no harm and it keeps the SQLLexer working. cbuf[off + i] = (char)((s.charAt(i)) % 256); } return length; } catch (BadLocationException x) { return -1; } } else { return -1; }
if (position < document.getLength()) { int length = len; if (position + length >= document.getLength()) { length = document.getLength() - (int) position; } if (off + length >= cbuf.length) { length = cbuf.length - off; } try { String s = document.getText((int) position, length); position += length; for (int i = 0; i < length; i++) { cbuf[off + i] = s.charAt(i); } return length; } catch (BadLocationException x) { return -1; } } else { return -1; }
Clone fragments detected by clone detection tool
File path: /sql12/plugins/syntax/src/net/sourceforge/squirrel_sql/plugins/syntax/oster/OsterTextControl.java File path: /sql12/plugins/syntax/src/net/sourceforge/squirrel_sql/plugins/syntax/oster/DocReader.java
Method name: int read(char[], int, int) Method name: int read(char[], int, int)
Number of AST nodes: 13 Number of AST nodes: 13
1
if (position < document.getLength())
1
if (position < document.getLength())
2
			{
2
		{
3
				int length = len;
3
			int length = len;
4
				if (position + length >= document.getLength())
4
			if (position + length >= document.getLength())
5
				{
5
			
6
	
6
{
7
				length = document.getLength() - (int) position;
7
				length = document.getLength() - (int) position;
8
				}
8
			}
9
				if (off + length >= cbuf.length)
9
			if (off + length >= cbuf.length)
10
				{
10
			{
11
					length = cbuf.length - off;
11
				length = cbuf.length - off;
12
				}
12
			}
13
				try
13
			try
14
				{
14
			{
15
					String s = document.getText((int) position, length);
15
				String s = document.getText((int) position, length);
16
					position += length;
16
				position += length;
17
					for (int i = 0; i < length; i++)
17
				for (int i = 0; i < length; i++)
18
					{
18
				{
19
                  // The Ostermiller SQLLexer crashes with an ArrayIndexOutOfBoundsException
20
                  // if the char is greater then 255. So we prevent the char from being greater.
21
                  // This is surely not a proper Unicode treatment but it doesn't seem
22
                  // to do no harm and it keeps the SQLLexer working.
23
						cbuf[off + i] = (char)((s.charAt(i)) % 256);
19
					cbuf[off + i] = s.charAt(i);
24
					}
20
				
25
	
21
}
26
				return length;
22
				return length;
27
				}
23
			
28
	
24
}
29
			catch (BadLocationException x)
25
			catch (BadLocationException x)
30
				{
26
			{
31
					return -1;
27
				return -1;
32
				}
28
			}
33
			}
29
		
34
	
30
}
35
		else
31
		else
36
			{
32
		{
37
				return -1;
33
			return -1;
38
			}
34
		}
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.1
Clones locationClones are in different classes having the same super class
Number of node comparisons39
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements13
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)9.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (position < document.getLength())
    1
    if (position < document.getLength())
    2
    int length = len;
    2
    int length = len;
    3
    if (position + length >= document.getLength())
    3
    if (position + length >= document.getLength())
    4
    length = document.getLength() - (int)position;
    4
    length = document.getLength() - (int)position;
    5
    if (off + length >= cbuf.length)
    5
    if (off + length >= cbuf.length)
    6
    length = cbuf.length - off;
    6
    length = cbuf.length - off;
    7
    try
    7
    try
    8
    String s = document.getText((int)position, length);
    8
    String s = document.getText((int)position, length);
    9
    position += length;
    9
    position += length;
    10
    for (int i = 0; i < length; i++)
    10
    for (int i = 0; i < length; i++)
    11
    cbuf[off + i] = (char)((s.charAt(i)) % 256);
    11
    cbuf[off + i] = (char)((s.charAt(i)) % 256);
    11
    cbuf[off + i] = s.charAt(i);
    Differences
    Expression1Expression2Difference
    (char)((s.charAt(i)) % 256)s.charAt(i)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression (char)((s.charAt(i)) % 256) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression s.charAt(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11
    cbuf[off + i] = s.charAt(i);
    12
    return length;
    12
    return length;
    else
    else
    13
    return -1;
    13
    return -1;
    Precondition Violations (3)
    Row Violation
    1Expression (char)((s.charAt(i)) % 256) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression s.charAt(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Not all possible execution flows end in a return statement