### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java,v retrieving revision 1.19 diff -u -r1.19 InternalExtendedCompletionContext.java --- codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java 10 Sep 2010 07:24:55 -0000 1.19 +++ codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java 22 Sep 2010 14:01:19 -0000 @@ -195,6 +195,15 @@ if (this.visibleFields.size > 0 && this.visibleFields.contains(fieldDeclaration.binding)) { this.visibleFields.remove(fieldDeclaration.binding); } + int count = 0; + while (count < this.visibleFields.size) { + FieldBinding visibleField = (FieldBinding)this.visibleFields.elementAt(count); + if (visibleField.id > fieldDeclaration.binding.id) { + this.visibleFields.remove(visibleField); + continue; + } + count++; + } break done; } /*(Incase fieldDeclaration != null is not sufficient to infer that #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/CompletionContextTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionContextTests.java,v retrieving revision 1.19 diff -u -r1.19 CompletionContextTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionContextTests.java 10 Sep 2010 07:24:58 -0000 1.19 +++ src/org/eclipse/jdt/core/tests/model/CompletionContextTests.java 22 Sep 2010 14:01:19 -0000 @@ -5425,4 +5425,53 @@ "}", result.context); } + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=312603 +public void test0177() throws JavaModelException { + this.workingCopies = new ICompilationUnit[3]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/X.java", + "package test;\n" + + "import java.text.MessageFormat;\n" + + "public class X {\n" + + " String fooBar = \"Hi\";" + + " String furchtbar= MessageFormat.format\n" + + " String abc1 = \"Hi\";" + + " String abc2 = \"Hi\";" + + " String abc3 = \"Hi\";" + + " String abc4 = \"Hi\";" + + "}"); + + String str = this.workingCopies[0].getSource(); + int tokenStart = str.lastIndexOf("format"); + int tokenEnd = tokenStart + "format".length() - 1; + int cursorLocation = str.lastIndexOf("format") + "format".length(); + + CompletionResult result = contextComplete(this.workingCopies[0], cursorLocation, true, true); + String jclPath = getExternalJCLPathString(); + assertResults( + "completion offset="+(cursorLocation)+"\n" + + "completion range=["+(tokenStart)+", "+(tokenEnd)+"]\n" + + "completion token=\"format\"\n" + + "completion token kind=TOKEN_KIND_NAME\n" + + "expectedTypesSignatures={Ljava.lang.String;}\n" + + "expectedTypesKeys={Ljava/lang/String;}\n" + + "completion token location=UNKNOWN\n" + + "enclosingElement=furchtbar {key=Ltest/X;.furchtbar)Ljava/lang/String;} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]]\n" + + "visibleElements={\n" + + " fooBar {key=Ltest/X;.fooBar)Ljava/lang/String;} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]],\n" + + " wait(long, int) {key=Ljava/lang/Object;.wait(JI)V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + + " wait(long) {key=Ljava/lang/Object;.wait(J)V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + + " wait() {key=Ljava/lang/Object;.wait()V|Ljava/lang/IllegalMonitorStateException;|Ljava/lang/InterruptedException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + + " toString() {key=Ljava/lang/Object;.toString()Ljava/lang/String;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + + " notifyAll() {key=Ljava/lang/Object;.notifyAll()V|Ljava/lang/IllegalMonitorStateException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + + " notify() {key=Ljava/lang/Object;.notify()V|Ljava/lang/IllegalMonitorStateException;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + + " hashCode() {key=Ljava/lang/Object;.hashCode()I} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + + " getClass() {key=Ljava/lang/Object;.getClass()Ljava/lang/Class;} [in Object [in Object.class [in java.lang [in " + jclPath +"]]]],\n" + + " finalize() {key=Ljava/lang/Object;.finalize()V|Ljava/lang/Throwable;} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + + " equals(java.lang.Object) {key=Ljava/lang/Object;.equals(Ljava/lang/Object;)Z} [in Object [in Object.class [in java.lang [in " + jclPath + "]]]],\n" + + " clone() {key=Ljava/lang/Object;.clone()Ljava/lang/Object;|Ljava/lang/CloneNotSupportedException;} [in Object [in Object.class [in java.lang [in " + jclPath +"]]]],\n" + + "}", + result.context); +} } Index: src/org/eclipse/jdt/core/tests/model/CompletionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java,v retrieving revision 1.226 diff -u -r1.226 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 22 Sep 2010 06:32:08 -0000 1.226 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 22 Sep 2010 14:01:20 -0000 @@ -21764,4 +21764,30 @@ "myString2[FIELD_REF]{myString2, Ltest.X;, Ljava.lang.String;, myString2, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED) + "}", requestor.getResults()); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=312603 +public void test312603() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/X.java", + "package test;\n" + + "public class X {\n" + + " void foo(String s) {}\n" + + " String myString = \"\";\n" + + " String myString2 = foo(my\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + final String completeBehind = "String myString2 = foo(my"; + int cursorLocation = str.lastIndexOf(completeBehind) + + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, + this.wcOwner); + + assertResults( + "MyClass[TYPE_REF]{mypackage.MyClass, mypackage, Lmypackage.MyClass;, null, null, 14}\n" + + "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, 24}\n" + + "myString[FIELD_REF]{myString, Ltest.X;, Ljava.lang.String;, myString, null, 57}", + requestor.getResults()); +} }