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

(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java (-2 / +35 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 21-26 Link Here
21
 *  n  means completion behind the n-th character
21
 *  n  means completion behind the n-th character
22
 */
22
 */
23
import org.eclipse.jdt.core.compiler.*;
23
import org.eclipse.jdt.core.compiler.*;
24
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
24
import org.eclipse.jdt.internal.compiler.parser.Scanner;
25
import org.eclipse.jdt.internal.compiler.parser.Scanner;
25
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
26
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
26
27
Lines 791-797 Link Here
791
					throw new InvalidInputException("Ctrl-Z"); //$NON-NLS-1$
792
					throw new InvalidInputException("Ctrl-Z"); //$NON-NLS-1$
792
793
793
				default :
794
				default :
794
					if (ScannerHelper.isJavaIdentifierStart(this.currentCharacter))
795
					char c = this.currentCharacter;
796
					if (c < ScannerHelper.MAX_OBVIOUS) {
797
						if ((ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_IDENT_START) != 0) {
798
							return scanIdentifierOrKeyword();
799
						} else if ((ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_DIGIT) != 0) {
800
								return scanNumber(false);
801
						} else {
802
							return TokenNameERROR;
803
						}
804
					}
805
					boolean isJavaIdStart;
806
					if (c >= HIGH_SURROGATE_MIN_VALUE && c <= HIGH_SURROGATE_MAX_VALUE) {
807
						if (this.complianceLevel < ClassFileConstants.JDK1_5) {
808
							throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
809
						}
810
						// Unicode 4 detection
811
						char low = (char) getNextChar();
812
						if (low < LOW_SURROGATE_MIN_VALUE || low > LOW_SURROGATE_MAX_VALUE) {
813
							// illegal low surrogate
814
							throw new InvalidInputException(INVALID_LOW_SURROGATE);
815
						}
816
						isJavaIdStart = ScannerHelper.isJavaIdentifierStart(c, low);
817
					}
818
					else if (c >= LOW_SURROGATE_MIN_VALUE && c <= LOW_SURROGATE_MAX_VALUE) {
819
						if (this.complianceLevel < ClassFileConstants.JDK1_5) {
820
							throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
821
						}
822
						throw new InvalidInputException(INVALID_HIGH_SURROGATE);
823
					} else {
824
						// optimized case already checked
825
						isJavaIdStart = Character.isJavaIdentifierStart(c);
826
					}
827
					if (isJavaIdStart)
795
						return scanIdentifierOrKeyword();
828
						return scanIdentifierOrKeyword();
796
					if (ScannerHelper.isDigit(this.currentCharacter)) {
829
					if (ScannerHelper.isDigit(this.currentCharacter)) {
797
						return scanNumber(false);
830
						return scanNumber(false);
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (+24 lines)
Lines 13790-13794 Link Here
13790
					(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
13790
					(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
13791
			requestor.getResults());	
13791
			requestor.getResults());	
13792
}
13792
}
13793
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=307486
13794
public void testLabel7() throws JavaModelException {
13795
	this.workingCopies = new ICompilationUnit[1];
13796
	this.workingCopies[0] = getWorkingCopy(
13797
		"/Completion/src/label/Test.java",
13798
		"package label;"+
13799
		"public class Test {\n" +
13800
		"  void foo() {\n" +
13801
		"    \ud842\udf9fabc :\n" +
13802
		"    while (true) {\n" + 
13803
		"        break \ud842\udf9fabc;\n" + 
13804
		"    }\n" + 
13805
		"  }\n" +
13806
		"}\n");
13793
13807
13808
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13809
	String str = this.workingCopies[0].getSource();
13810
	String completeBehind = "break";
13811
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length() + 1;
13812
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13813
13814
	assertResults(
13815
			"\ud842\udf9fabc[LABEL_REF]{\ud842\udf9fabc, null, null, \ud842\udf9fabc, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
13816
			requestor.getResults());
13817
}
13794
}
13818
}

Return to bug 307486