File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xmi/impl/XMLSaveImpl.java | File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xmi/impl/XMLSaveImpl.java | |||
Method name: String convertText(String)
|
Method name: String convert(String)
|
|||
Number of AST nodes: 82 | Number of AST nodes: 80 | |||
1 | ch = input.charAt(inputPos++); // value[outputPos];↵ | 1 | ch = input.charAt(inputPos++); // value[outputPos];↵ | |
2 | switch (ch)↵ | 2 | switch (ch)↵ | |
3 | {↵ | 3 | {↵ | |
4 | case 0x1:↵ | 4 | case 0x1:↵ | |
5 | case 0x2:↵ | 5 | case 0x2:↵ | |
6 | case 0x3:↵ | 6 | case 0x3:↵ | |
7 | case 0x4:↵ | 7 | case 0x4:↵ | |
8 | case 0x5:↵ | 8 | case 0x5:↵ | |
9 | case 0x6:↵ | 9 | case 0x6:↵ | |
10 | case 0x7:↵ | 10 | case 0x7:↵ | |
11 | case 0x8:↵ | 11 | case 0x8:↵ | |
12 | case 0xB:↵ | 12 | case 0xB:↵ | |
13 | case 0xC:↵ | 13 | case 0xC:↵ | |
14 | case 0xE:↵ | 14 | case 0xE:↵ | |
15 | case 0xF:↵ | 15 | case 0xF:↵ | |
16 | case 0x10:↵ | 16 | case 0x10:↵ | |
17 | case 0x11:↵ | 17 | case 0x11:↵ | |
18 | case 0x12:↵ | 18 | case 0x12:↵ | |
19 | case 0x13:↵ | 19 | case 0x13:↵ | |
20 | case 0x14:↵ | 20 | case 0x14:↵ | |
21 | case 0x15:↵ | 21 | case 0x15:↵ | |
22 | case 0x16:↵ | 22 | case 0x16:↵ | |
23 | case 0x17:↵ | 23 | case 0x17:↵ | |
24 | case 0x18:↵ | 24 | case 0x18:↵ | |
25 | case 0x19:↵ | 25 | case 0x19:↵ | |
26 | case 0x1A:↵ | 26 | case 0x1A:↵ | |
27 | case 0x1B:↵ | 27 | case 0x1B:↵ | |
28 | case 0x1C:↵ | 28 | case 0x1C:↵ | |
29 | case 0x1D:↵ | 29 | case 0x1D:↵ | |
30 | case 0x1E:↵ | 30 | case 0x1E:↵ | |
31 | case 0x1F:↵ | 31 | case 0x1F:↵ | |
32 | {↵ | 32 | {↵ | |
33 | if (allowControlCharacters)↵ | 33 | if (allowControlCharacters)↵ | |
34 | {↵ | 34 | {↵ | |
35 | outputPos = replaceChars(outputPos, CONTROL_CHARACTERS[ch], inputLength);↵ | 35 | outputPos = replaceChars(outputPos, CONTROL_CHARACTERS[ch], inputLength);↵ | |
36 | changed = true;↵ | 36 | changed = true;↵ | |
37 | }↵ | 37 | }↵ | |
38 | else↵ | 38 | else↵ | |
39 | {↵ | 39 | {↵ | |
40 | throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵ | 40 | throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵ | |
41 | }↵ | 41 | }↵ | |
42 | break;↵ | 42 | break;↵ | |
43 | }↵ | 43 | }↵ | |
44 | case '&':↵ | 44 | case '&':↵ | |
45 | {↵ | 45 | {↵ | |
46 | outputPos = replaceChars(outputPos, AMP, inputLength);↵ | 46 | outputPos = replaceChars(outputPos, AMP, inputLength);↵ | |
47 | changed = true;↵ | 47 | changed = true;↵ | |
48 | break;↵ | 48 | break;↵ | |
49 | }↵ | 49 | }↵ | |
50 | case '<':↵ | 50 | case '<':↵ | |
51 | {↵ | 51 | {↵ | |
52 | outputPos = replaceChars(outputPos, LESS, inputLength);↵ | 52 | outputPos = replaceChars(outputPos, LESS, inputLength);↵ | |
53 | changed = true;↵ | 53 | changed = true;↵ | |
54 | break;↵ | 54 | break;↵ | |
55 | }↵ | 55 | }↵ | |
56 | case '"':↵ | 56 | case '"':↵ | |
57 | {↵ | 57 | {↵ | |
58 | outputPos = replaceChars(outputPos, QUOTE, inputLength);↵ | 58 | outputPos = replaceChars(outputPos, QUOTE, inputLength);↵ | |
59 | changed = true;↵ | 59 | changed = true;↵ | |
60 | break;↵ | 60 | break;↵ | |
61 | }↵ | 61 | }↵ | |
62 | case '\n':↵ | 62 | case '\n':↵ | |
63 | {↵ | 63 | {↵ | |
64 | outputPos = replaceChars(outputPos, LINE_FEED, inputLength);↵ | 64 | outputPos = replaceChars(outputPos, LF, inputLength);↵ | |
65 | changed = true;↵ | 65 | changed = true;↵ | |
66 | break;↵ | 66 | break;↵ | |
67 | }↵ | 67 | }↵ | |
68 | case '\r':↵ | 68 | case '\r':↵ | |
69 | {↵ | 69 | {↵ | |
70 | outputPos = replaceChars(outputPos, CR, inputLength);↵ | 70 | outputPos = replaceChars(outputPos, CR, inputLength);↵ | |
71 | changed = true;↵ | 71 | changed = true;↵ | |
72 | break;↵ | 72 | break;↵ | |
73 | }↵ | 73 | }↵ | |
74 | case '>':↵ | 74 | case '\t':↵ | |
75 | {↵ | 75 | {↵ | |
76 | if (inputPos >= 3 && input.charAt(inputPos - 2) == ']' && input.charAt(inputPos - 3) == ']')↵ | |||
77 | {↵ | |||
78 | outputPos = replaceChars(outputPos, GREATER, inputLength);↵ | 76 | outputPos = replaceChars(outputPos, TAB, inputLength);↵ | |
79 | cdataCloseBracket = true;↵ | |||
80 | changed = true;↵ | 77 | changed = true;↵ | |
81 | break;↵ | 78 | break;↵ | |
82 | }↵ | |||
83 | // continue with default processing↵ | |||
84 | }↵ | 79 | }↵ | |
85 | default:↵ | 80 | default:↵ | |
86 | {↵ | 81 | {↵ | |
87 | if (!XMLChar.isValid(ch))↵ | 82 | if (!XMLChar.isValid(ch))↵ | |
88 | {↵ | 83 | {↵ | |
89 | if (XMLChar.isHighSurrogate(ch))↵ | 84 | if (XMLChar.isHighSurrogate(ch))↵ | |
90 | {↵ | 85 | {↵ | |
91 | char high = ch;↵ | 86 | char high = ch;↵ | |
92 | if (inputLength-- > 0)↵ | 87 | if (inputLength-- > 0)↵ | |
93 | {↵ | 88 | {↵ | |
94 | ch = input.charAt(inputPos++); ↵ | 89 | ch = input.charAt(inputPos++); ↵ | |
95 | if (XMLChar.isLowSurrogate(ch))↵ | 90 | if (XMLChar.isLowSurrogate(ch))↵ | |
96 | {↵ | 91 | {↵ | |
97 | if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT)↵ | 92 | if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT)↵ | |
98 | {↵ | 93 | {↵ | |
99 | // Every codepoint is supported! ↵ | 94 | // Every codepoint is supported! ↵ | |
100 | value[outputPos++] = high;↵ | 95 | value[outputPos++] = high;↵ | |
101 | value[outputPos++] = ch;↵ | 96 | value[outputPos++] = ch;↵ | |
102 | }↵ | 97 | }↵ | |
103 | else↵ | 98 | else↵ | |
104 | {↵ | 99 | {↵ | |
105 | // Produce the supplemental character as an entity↵ | 100 | // Produce the supplemental character as an entity↵ | |
106 | outputPos = replaceChars(outputPos, ("" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength);↵ | 101 | outputPos = replaceChars(outputPos, ("" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength);↵ | |
107 | changed = true;↵ | 102 | changed = true;↵ | |
108 | }↵ | 103 | }↵ | |
109 | break;↵ | 104 | break;↵ | |
110 | }↵ | 105 | }↵ | |
111 | throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵ | 106 | throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵ | |
112 | }↵ | 107 | }↵ | |
113 | else↵ | 108 | else↵ | |
114 | {↵ | 109 | {↵ | |
115 | throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵ | 110 | throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵ | |
116 | }↵ | 111 | }↵ | |
117 | }↵ | 112 | }↵ | |
118 | else↵ | 113 | else↵ | |
119 | {↵ | 114 | {↵ | |
120 | throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵ | 115 | throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input);↵ | |
121 | }↵ | 116 | }↵ | |
122 | }↵ | 117 | }↵ | |
123 | else↵ | 118 | else↵ | |
124 | {↵ | 119 | {↵ | |
125 | // Normal (BMP) unicode code point. See if we know for a fact that the encoding supports it:↵ | 120 | // Normal (BMP) unicode code point. See if we know for a fact that the encoding supports it:↵ | |
126 | if (ch <= mappableLimit)↵ | 121 | if (ch <= mappableLimit)↵ | |
127 | {↵ | 122 | {↵ | |
128 | value[outputPos++] = ch;↵ | 123 | value[outputPos++] = ch;↵ | |
129 | }↵ | 124 | }↵ | |
130 | else↵ | 125 | else↵ | |
131 | {↵ | 126 | {↵ | |
132 | // We not sure the encoding supports this code point, so we write it as a character entity reference.↵ | 127 | // We not sure the encoding supports this code point, so we write it as a character entity reference.↵ | |
133 | outputPos = replaceChars(outputPos, ("" + Integer.toHexString(ch) + ";").toCharArray(), inputLength);↵ | 128 | outputPos = replaceChars(outputPos, ("" + Integer.toHexString(ch) + ";").toCharArray(), inputLength);↵ | |
134 | changed = true;↵ | 129 | changed = true;↵ | |
135 | }↵ | 130 | }↵ | |
136 | }↵ | 131 | }↵ | |
137 | break;↵ | 132 | break;↵ | |
138 | }↵ | 133 | }↵ | |
139 | } | 134 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 1.7 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 1655 |
Number of mapped statements | 77 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 72.1 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9 | ch = input.charAt(inputPos++); | 8 | ch = input.charAt(inputPos++); | |||||||||||
10 | switch (ch) | 9 | switch (ch) | |||||||||||
11 | case 0x1: | 10 | case 0x1: | |||||||||||
12 | case 0x2: | 11 | case 0x2: | |||||||||||
13 | case 0x3: | 12 | case 0x3: | |||||||||||
14 | case 0x4: | 13 | case 0x4: | |||||||||||
15 | case 0x5: | 14 | case 0x5: | |||||||||||
16 | case 0x6: | 15 | case 0x6: | |||||||||||
17 | case 0x7: | 16 | case 0x7: | |||||||||||
18 | case 0x8: | 17 | case 0x8: | |||||||||||
19 | case 0xB: | 18 | case 0xB: | |||||||||||
20 | case 0xC: | 19 | case 0xC: | |||||||||||
21 | case 0xE: | 20 | case 0xE: | |||||||||||
22 | case 0xF: | 21 | case 0xF: | |||||||||||
23 | case 0x10: | 22 | case 0x10: | |||||||||||
24 | case 0x11: | 23 | case 0x11: | |||||||||||
25 | case 0x12: | 24 | case 0x12: | |||||||||||
26 | case 0x13: | 25 | case 0x13: | |||||||||||
27 | case 0x14: | 26 | case 0x14: | |||||||||||
28 | case 0x15: | 27 | case 0x15: | |||||||||||
29 | case 0x16: | 28 | case 0x16: | |||||||||||
30 | case 0x17: | 29 | case 0x17: | |||||||||||
31 | case 0x18: | 30 | case 0x18: | |||||||||||
32 | case 0x19: | 31 | case 0x19: | |||||||||||
33 | case 0x1A: | 32 | case 0x1A: | |||||||||||
34 | case 0x1B: | 33 | case 0x1B: | |||||||||||
35 | case 0x1C: | 34 | case 0x1C: | |||||||||||
36 | case 0x1D: | 35 | case 0x1D: | |||||||||||
37 | case 0x1E: | 36 | case 0x1E: | |||||||||||
38 | case 0x1F: | 37 | case 0x1F: | |||||||||||
39 | if (allowControlCharacters) | 38 | if (allowControlCharacters) | |||||||||||
40 | outputPos = replaceChars(outputPos, CONTROL_CHARACTERS[ch], inputLength); | 39 | outputPos = replaceChars(outputPos, CONTROL_CHARACTERS[ch], inputLength); | |||||||||||
41 | changed = true; | 40 | changed = true; | |||||||||||
else | else | |||||||||||||
42 | throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); | 41 | throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); | |||||||||||
43 | break; | 42 | break; | |||||||||||
44 | case '&': | 43 | case '&': | |||||||||||
45 | outputPos = replaceChars(outputPos, AMP, inputLength); | 44 | outputPos = replaceChars(outputPos, AMP, inputLength); | |||||||||||
46 | changed = true; | 45 | changed = true; | |||||||||||
47 | break; | 46 | break; | |||||||||||
48 | case '<': | 47 | case '<': | |||||||||||
49 | outputPos = replaceChars(outputPos, LESS, inputLength); | 48 | outputPos = replaceChars(outputPos, LESS, inputLength); | |||||||||||
50 | changed = true; | 49 | changed = true; | |||||||||||
51 | break; | 50 | break; | |||||||||||
52 | case '"': | 51 | case '"': | |||||||||||
53 | outputPos = replaceChars(outputPos, QUOTE, inputLength); | 52 | outputPos = replaceChars(outputPos, QUOTE, inputLength); | |||||||||||
54 | changed = true; | 53 | changed = true; | |||||||||||
55 | break; | 54 | break; | |||||||||||
56 | case '\n': | 55 | case '\n': | |||||||||||
57 | outputPos = replaceChars(outputPos, LINE_FEED, inputLength); |
| 56 | outputPos = replaceChars(outputPos, LF, inputLength); | ||||||||||
58 | changed = true; | 57 | changed = true; | |||||||||||
59 | break; | 58 | break; | |||||||||||
60 | case '\r': | 59 | case '\r': | |||||||||||
61 | outputPos = replaceChars(outputPos, CR, inputLength); | 60 | outputPos = replaceChars(outputPos, CR, inputLength); | |||||||||||
62 | changed = true; | 61 | changed = true; | |||||||||||
63 | break; | 62 | break; | |||||||||||
64 | case '>': |
| 63 | case '\t': | ||||||||||
| 64 | outputPos = replaceChars(outputPos, TAB, inputLength); | ||||||||||||
| 65 | changed = true; | ||||||||||||
65 | if (inputPos >= 3 && input.charAt(inputPos - 2) == ']' && input.charAt(inputPos - 3) == ']') |
| | |||||||||||
66 | outputPos = replaceChars(outputPos, GREATER, inputLength); |
| | |||||||||||
67 | cdataCloseBracket = true; | | ||||||||||||
68 | changed = true; |
| | |||||||||||
69 | break; |
| | |||||||||||
|
| 66 | break; | |||||||||||
70 | default: | 67 | default: | |||||||||||
71 | if (!XMLChar.isValid(ch)) | 68 | if (!XMLChar.isValid(ch)) | |||||||||||
72 | if (XMLChar.isHighSurrogate(ch)) | 69 | if (XMLChar.isHighSurrogate(ch)) | |||||||||||
73 | char high = ch; | 70 | char high = ch; | |||||||||||
74 | if (inputLength-- > 0) | 71 | if (inputLength-- > 0) | |||||||||||
75 | ch = input.charAt(inputPos++); | 72 | ch = input.charAt(inputPos++); | |||||||||||
76 | if (XMLChar.isLowSurrogate(ch)) | 73 | if (XMLChar.isLowSurrogate(ch)) | |||||||||||
77 | if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT) | 74 | if (mappableLimit == MAX_UTF_MAPPABLE_CODEPOINT) | |||||||||||
78 | value[outputPos++] = high; | 75 | value[outputPos++] = high; | |||||||||||
79 | value[outputPos++] = ch; | 76 | value[outputPos++] = ch; | |||||||||||
else | else | |||||||||||||
80 | outputPos = replaceChars(outputPos, ("" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength); | 77 | outputPos = replaceChars(outputPos, ("" + Integer.toHexString(XMLChar.supplemental(high, ch)) + ";").toCharArray(), inputLength); | |||||||||||
81 | changed = true; | 78 | changed = true; | |||||||||||
82 | break; | 79 | break; | |||||||||||
83 | throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); | 80 | throw new RuntimeException("An invalid low surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); | |||||||||||
else | else | |||||||||||||
84 | throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); | 81 | throw new RuntimeException("An unpaired high surrogate character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); | |||||||||||
else | else | |||||||||||||
85 | throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); | 82 | throw new RuntimeException("An invalid XML character (Unicode: 0x" + Integer.toHexString(ch) + ") was found in the element content:" + input); | |||||||||||
else | else | |||||||||||||
86 | if (ch <= mappableLimit) | 83 | if (ch <= mappableLimit) | |||||||||||
87 | value[outputPos++] = ch; | 84 | value[outputPos++] = ch; | |||||||||||
else | else | |||||||||||||
88 | outputPos = replaceChars(outputPos, ("" + Integer.toHexString(ch) + ";").toCharArray(), inputLength); | 85 | outputPos = replaceChars(outputPos, ("" + Integer.toHexString(ch) + ";").toCharArray(), inputLength); | |||||||||||
89 | changed = true; | 86 | changed = true; | |||||||||||
90 | break; | 87 | break; |
Row | Violation |
---|---|
1 | Unmatched statement if(inputPos >= 3 && input.charAt(inputPos - 2) == ']' && input.charAt(inputPos - 3) == ']') cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement outputPos=replaceChars(outputPos,GREATER,inputLength); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement changed=true; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Unmatched break; |
5 | Unmatched break; |
6 | Clone fragment #1 returns variables inputLength, inputPos, outputPos, changed , while Clone fragment #2 returns variables inputLength, outputPos, changed, inputPos |