View | Details | Raw Unified | Return to bug 180683
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/ResolveTests.java (+44 lines)
Lines 1124-1129 Link Here
1124
		elements
1124
		elements
1125
	);
1125
	);
1126
}
1126
}
1127
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180683
1128
public void testUnicode2() throws JavaModelException {
1129
	this.workingCopies = new ICompilationUnit[1];
1130
	this.workingCopies[0] = getWorkingCopy(
1131
		"/Resolve/src/test/B.java",
1132
		"package test;\n"+
1133
		"public class \\u0042 {\n" + 
1134
		"  void foo() {\n" + 
1135
		"    \\u0042 var = null;\n" + 
1136
		"  }\n" + 
1137
		"}");
1138
1139
	String str = this.workingCopies[0].getSource();
1140
	int start = str.lastIndexOf("42");
1141
	int length = "".length();
1142
	IJavaElement[] elements =  this.workingCopies[0].codeSelect(start, length, this.wcOwner);
1143
	
1144
	assertElementsEqual(
1145
			"Unexpected elements",
1146
			"B [in [Working copy] B.java [in test [in src [in Resolve]]]]",
1147
			elements
1148
		);
1149
}
1150
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180683
1151
public void testUnicode3() throws JavaModelException {
1152
	this.workingCopies = new ICompilationUnit[1];
1153
	this.workingCopies[0] = getWorkingCopy(
1154
		"/Resolve/src/test/B.java",
1155
		"package test;\n"+
1156
		"public class \\u0042 {\n" + 
1157
		"  void foo() {\n" + 
1158
		"    \\u004");
1159
1160
	String str = this.workingCopies[0].getSource();
1161
	int start = str.lastIndexOf("4");
1162
	int length = "".length();
1163
	IJavaElement[] elements =  this.workingCopies[0].codeSelect(start, length, this.wcOwner);
1164
	
1165
	assertElementsEqual(
1166
			"Unexpected elements",
1167
			"",
1168
			elements
1169
		);
1170
}
1127
/**
1171
/**
1128
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47177
1172
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47177
1129
 */
1173
 */
(-)codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java (-1 / +13 lines)
Lines 341-346 Link Here
341
		int token;
341
		int token;
342
		
342
		
343
		if(selectionStart > selectionEnd){
343
		if(selectionStart > selectionEnd){
344
			// compute end position of the selection
345
			int end = selectionEnd + 1 == source.length ? selectionEnd : selectionEnd + 1;
344
			
346
			
345
			// compute start position of current line
347
			// compute start position of current line
346
			int currentPosition = selectionStart - 1;
348
			int currentPosition = selectionStart - 1;
Lines 355-360 Link Here
355
						while (source[pos] == 'u') {
357
						while (source[pos] == 'u') {
356
							pos++;
358
							pos++;
357
						}
359
						}
360
						
361
						int endOfUnicode = pos + 3;
362
						if (end < endOfUnicode) {
363
							if (endOfUnicode < source.length) {
364
								end = endOfUnicode;
365
							} else {
366
								return false; // not enough characters to decode an unicode
367
							}
368
						}
369
						
358
						if ((c1 = ScannerHelper.getNumericValue(source[pos++])) > 15
370
						if ((c1 = ScannerHelper.getNumericValue(source[pos++])) > 15
359
							|| c1 < 0
371
							|| c1 < 0
360
							|| (c2 = ScannerHelper.getNumericValue(source[pos++])) > 15
372
							|| (c2 = ScannerHelper.getNumericValue(source[pos++])) > 15
Lines 388-394 Link Here
388
			}
400
			}
389
			
401
			
390
			// compute start and end of the last token
402
			// compute start and end of the last token
391
			scanner.resetTo(nextCharacterPosition, selectionEnd + 1 == source.length ? selectionEnd : selectionEnd + 1);
403
			scanner.resetTo(nextCharacterPosition, end);
392
			do {
404
			do {
393
				try {
405
				try {
394
					token = scanner.getNextToken();
406
					token = scanner.getNextToken();

Return to bug 180683