### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java,v retrieving revision 1.70 diff -u -r1.70 CompletionScanner.java --- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java 6 Oct 2009 01:00:37 -0000 1.70 +++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java 7 Apr 2010 19:40:13 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,6 +21,7 @@ * n means completion behind the n-th character */ import org.eclipse.jdt.core.compiler.*; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.parser.Scanner; import org.eclipse.jdt.internal.compiler.parser.ScannerHelper; @@ -791,7 +792,39 @@ throw new InvalidInputException("Ctrl-Z"); //$NON-NLS-1$ default : - if (ScannerHelper.isJavaIdentifierStart(this.currentCharacter)) + char c = this.currentCharacter; + if (c < ScannerHelper.MAX_OBVIOUS) { + if ((ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_IDENT_START) != 0) { + return scanIdentifierOrKeyword(); + } else if ((ScannerHelper.OBVIOUS_IDENT_CHAR_NATURES[c] & ScannerHelper.C_DIGIT) != 0) { + return scanNumber(false); + } else { + return TokenNameERROR; + } + } + boolean isJavaIdStart; + if (c >= HIGH_SURROGATE_MIN_VALUE && c <= HIGH_SURROGATE_MAX_VALUE) { + if (this.complianceLevel < ClassFileConstants.JDK1_5) { + throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + } + // Unicode 4 detection + char low = (char) getNextChar(); + if (low < LOW_SURROGATE_MIN_VALUE || low > LOW_SURROGATE_MAX_VALUE) { + // illegal low surrogate + throw new InvalidInputException(INVALID_LOW_SURROGATE); + } + isJavaIdStart = ScannerHelper.isJavaIdentifierStart(c, low); + } + else if (c >= LOW_SURROGATE_MIN_VALUE && c <= LOW_SURROGATE_MAX_VALUE) { + if (this.complianceLevel < ClassFileConstants.JDK1_5) { + throw new InvalidInputException(INVALID_UNICODE_ESCAPE); + } + throw new InvalidInputException(INVALID_HIGH_SURROGATE); + } else { + // optimized case already checked + isJavaIdStart = Character.isJavaIdentifierStart(c); + } + if (isJavaIdStart) return scanIdentifierOrKeyword(); if (ScannerHelper.isDigit(this.currentCharacter)) { return scanNumber(false); #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java,v retrieving revision 1.118 diff -u -r1.118 CompletionTests_1_5.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 9 Jul 2009 10:47:24 -0000 1.118 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 7 Apr 2010 19:40:16 -0000 @@ -13790,5 +13790,29 @@ (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}", requestor.getResults()); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=307486 +public void testLabel7() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/label/Test.java", + "package label;"+ + "public class Test {\n" + + " void foo() {\n" + + " \ud842\udf9fabc :\n" + + " while (true) {\n" + + " break \ud842\udf9fabc;\n" + + " }\n" + + " }\n" + + "}\n"); + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "break"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length() + 1; + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "\ud842\udf9fabc[LABEL_REF]{\ud842\udf9fabc, null, null, \ud842\udf9fabc, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + requestor.getResults()); +} }