Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 168752 Details for
Bug 312603
[content assist] field being declared is proposed as a method argument inside initialization
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Another proposal to fix the issue
v01.txt (text/plain), 13.89 KB, created by
Frederic Fusier
on 2010-05-17 11:40:13 EDT
(
hide
)
Description:
Another proposal to fix the issue
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2010-05-17 11:40:13 EDT
Size:
13.89 KB
patch
obsolete
>### 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.17 >diff -u -r1.17 InternalExtendedCompletionContext.java >--- codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java 16 Apr 2010 13:25:08 -0000 1.17 >+++ codeassist/org/eclipse/jdt/internal/codeassist/InternalExtendedCompletionContext.java 17 May 2010 15:32:28 -0000 >@@ -19,7 +19,6 @@ > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.WorkingCopyOwner; > import org.eclipse.jdt.core.compiler.CharOperation; >-import org.eclipse.jdt.internal.codeassist.complete.CompletionNodeDetector; > import org.eclipse.jdt.internal.codeassist.complete.CompletionParser; > import org.eclipse.jdt.internal.codeassist.impl.AssistCompilationUnit; > import org.eclipse.jdt.internal.compiler.ast.ASTNode; >@@ -187,11 +186,14 @@ > } > } else { > FieldDeclaration fieldDeclaration = fields[i]; >- if (fieldDeclaration.initialization != null && >- fieldDeclaration.initialization.sourceStart <= astNode.sourceStart && >- astNode.sourceEnd <= fieldDeclaration.initialization.sourceEnd) { >+ if (fieldDeclaration.initialization != null) { > // completion is inside a field initializer > searchVisibleVariablesAndMethods(scope, this.visibleLocalVariables, this.visibleFields, this.visibleMethods, notInJavadoc); >+ // remove this field from visibleFields list because completion is being asked in its >+ // intialization and so this has not yet been declared successfully. >+ if (this.visibleFields.size > 0 && this.visibleFields.contains(fieldDeclaration.binding)) { >+ this.visibleFields.remove(fieldDeclaration.binding); >+ } > break done; > } > } >@@ -721,19 +723,7 @@ > // If the local variable declaration's initialization statement itself has the completion, > // then don't propose the local variable > if (local.declaration.initialization != null) { >- if(local.declaration.initialization.sourceEnd > 0) { >- if (this.assistNode.sourceEnd <= local.declaration.initialization.sourceEnd >- && this.assistNode.sourceStart >= local.declaration.initialization.sourceStart) { >- continue next; >- } >- } else { >- CompletionNodeDetector detector = new CompletionNodeDetector( >- this.assistNode, >- local.declaration.initialization); >- if (detector.containsCompletionNode()) { >- continue next; >- } >- } >+ continue next; > } > for (int f = 0; f < localsFound.size; f++) { > LocalVariableBinding otherLocal = >#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.18 >diff -u -r1.18 CompletionContextTests.java >--- src/org/eclipse/jdt/core/tests/model/CompletionContextTests.java 16 Apr 2010 13:25:08 -0000 1.18 >+++ src/org/eclipse/jdt/core/tests/model/CompletionContextTests.java 17 May 2010 15:32:34 -0000 >@@ -4002,7 +4002,6 @@ > "expectedTypesKeys={I}\n" + > "completion token location=UNKNOWN\n" + > "visibleElements={\n" + >- " field1 {key=Ltest/X;.field1)I} [in X [in [Working copy] X.java [in test [in src3 [in Completion]]]]],\n" + > " field0 {key=Ltest/X;.field0)I} [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" + >@@ -5291,4 +5290,139 @@ > "}", > result.context); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=312603 >+public void test0174() 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 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); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=312603 >+public void test0175() 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= new String(String.format;\n" + >+ "}"); >+ >+ 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=null\n" + >+ "expectedTypesKeys=null\n" + >+ "completion token location=UNKNOWN\n" + >+ "enclosingElement=X {key=Ltest/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); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=312603 >+public void test0176() 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= (fooBar = new String(String.format;\n" + >+ "}"); >+ >+ 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=null\n" + >+ "expectedTypesKeys=null\n" + >+ "completion token location=UNKNOWN\n" + >+ "enclosingElement=X {key=Ltest/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); >+} > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 312603
:
168330
|
168752
|
178587
|
179038
|
179380