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 179057 Details for
Bug 325481
[assist] fields declared after a particular field are proposed in its initialization
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed fix v1.0 + regression tests
patch312603Related.txt (text/plain), 5.27 KB, created by
Ayushman Jain
on 2010-09-16 14:29:01 EDT
(
hide
)
Description:
proposed fix v1.0 + regression tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2010-09-16 14:29:01 EDT
Size:
5.27 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v >retrieving revision 1.418 >diff -u -r1.418 CompletionEngine.java >--- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 25 Aug 2010 10:53:58 -0000 1.418 >+++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 16 Sep 2010 18:10:14 -0000 >@@ -5975,13 +5975,33 @@ > int receiverEnd) { > > ObjectVector newFieldsFound = new ObjectVector(); >+ // if the proposal is being asked inside a field's initialization, we'll record its id >+ int fieldBeingCompletedId = -1; >+ for (int f = fields.length; --f >=0;) { >+ FieldBinding field = fields[f]; >+ FieldDeclaration fieldDeclaration = field.sourceField(); >+ if (fieldDeclaration != null && fieldDeclaration.initialization != null) { >+ // We're asking for a proposal inside this field's initialization. So record its id >+ fieldBeingCompletedId = field.id; >+ break; >+ } >+ } > // Inherited fields which are hidden by subclasses are filtered out > // No visibility checks can be performed without the scope & invocationSite > > int fieldLength = fieldName.length; > next : for (int f = fields.length; --f >= 0;) { > FieldBinding field = fields[f]; >- >+ >+ if (fieldBeingCompletedId >= 0) { >+ // Content assist invoked inside some field's initialization. >+ // bug 310427 and 325481 >+ if (field.id >= fieldBeingCompletedId) >+ // Don't propose field which is being declared currently >+ // Don't propose fields declared after the current field declaration statement >+ continue next; >+ } >+ > if (field.isSynthetic()) continue next; > > if (onlyStaticFields && !field.isStatic()) continue next; >@@ -6003,15 +6023,6 @@ > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346 > if (this.assistNodeIsInsideCase && field.type instanceof ArrayBinding) > continue next; >- >- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310427 >- // Don't propose field which is being declared currently >- // Don't propose fields declared after the current field declaration statement >- if (this.parser.assistNodeParent instanceof FieldDeclaration) { >- FieldDeclaration fieldDeclaration = (FieldDeclaration) this.parser.assistNodeParent; >- if (field.id >= fieldDeclaration.binding.id) >- continue next; >- } > > boolean prefixRequired = false; > >#P org.eclipse.jdt.core.tests.model >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.223 >diff -u -r1.223 CompletionTests.java >--- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 18 Aug 2010 14:13:45 -0000 1.223 >+++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 16 Sep 2010 18:10:18 -0000 >@@ -21696,4 +21696,35 @@ > "returnZero[METHOD_REF_WITH_CASTED_RECEIVER]{((CompletionAfterInstanceOf)a).returnZero(), Ltest.CompletionAfterInstanceOf;, ()I, Ltest.CompletionAfterInstanceOf;, returnZero, null, replace["+start2+", "+end2+"], token["+start1+", "+end1+"], receiver["+start3+", "+end3+"], " + (relevance1) + "}", > requestor.getResults()); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=325481 >+// To verify that when content assist is invoked inside a field initialization, >+// the field being declared and the ones declared after it are not proposed. >+public void test325481() 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 = \"\";\n" + >+ " String myString3 = (myString = String.format(String.format(my\n" + >+ " String myString4 = \"hello\";\n" + // should not be proposed >+ "}"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ final String completeBehind = "String.format(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, " + (R_NON_STATIC + R_UNQUALIFIED) + "}\n" + >+ "mypackage[PACKAGE_REF]{mypackage, mypackage, null, null, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE) + "}\n" + >+ "myString[FIELD_REF]{myString, Ltest.X;, Ljava.lang.String;, myString, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED) + "}\n" + >+ "myString2[FIELD_REF]{myString2, Ltest.X;, Ljava.lang.String;, myString2, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED) + "}", >+ requestor.getResults()); >+} > }
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 325481
:
179057
|
183654
|
183729
|
183833