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 233551 Details for
Bug 405141
[assist] Completion engine should disambiguate ambiguous field access through multiply inherited interfaces
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for the fix
Bug-405141new.patch (text/plain), 13.63 KB, created by
ANIRBAN CHAKRABORTY
on 2013-07-17 08:55:25 EDT
(
hide
)
Description:
Patch for the fix
Filename:
MIME Type:
Creator:
ANIRBAN CHAKRABORTY
Created:
2013-07-17 08:55:25 EDT
Size:
13.63 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java >index c0f3c2e..bdfbea0 100644 >--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java >+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java >@@ -1064,10 +1064,12 @@ > suite.addTest(new CompletionTests("testBug406468b")); > suite.addTest(new CompletionTests("testBug405250a")); > suite.addTest(new CompletionTests("testBug405250b")); > suite.addTest(new CompletionTests("testBug405250c")); > suite.addTest(new CompletionTests("testBug405250d")); >+ suite.addTest(new CompletionTests("testBug405141a")); >+ suite.addTest(new CompletionTests("testBug405141b")); > return suite; > } > public CompletionTests(String name) { > super(name); > } >@@ -26576,6 +26578,86 @@ > options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); > options.put(CompilerOptions.OPTION_Source, savedOptionSource); > COMPLETION_PROJECT.setOptions(options); > } > } >+// Bug 405141 - [1.8][code assist] Improper completion in lambda body for multiply inherited interface >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=405141 >+public void testBug405141a() throws JavaModelException { >+ Map options = COMPLETION_PROJECT.getOptions(true); >+ Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); >+ Object savedOptionSource = options.get(CompilerOptions.OPTION_Source); >+ try { >+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_8); >+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_8); >+ COMPLETION_PROJECT.setOptions(options); >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/X.java", >+ "public interface Foo {\n" + >+ " int run1(int s1, int s2);\n" + >+ " static int intVal = 0;\n" + >+ "}\n" + >+ "interface AnotherFoo {\n" + >+ " int run1(int s1, int s2);\n" + >+ " static int intVal = 0;\n" + >+ "}\n" + >+ "interface X extends Foo, AnotherFoo{\n" + >+ " static Foo f = (intV1, intV2) -> intV;\n" + >+ "}\n"); >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "static Foo f = (intV1, intV2) -> intV"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ assertResults( >+ "intVal[FIELD_REF]{AnotherFoo.intVal, Ltest.AnotherFoo;, I, intVal, null, 24}\n" + >+ "intV1[LOCAL_VARIABLE_REF]{intV1, null, I, intV1, null, 27}\n" + >+ "intV2[LOCAL_VARIABLE_REF]{intV2, null, I, intV2, null, 27}\n" + >+ "intVal[FIELD_REF]{Foo.intVal, Ltest.Foo;, I, intVal, null, 27}", >+ requestor.getResults()); >+ } finally { >+ // Restore compliance settings. >+ options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); >+ options.put(CompilerOptions.OPTION_Source, savedOptionSource); >+ COMPLETION_PROJECT.setOptions(options); >+ } >+} >+public void testBug405141b() throws JavaModelException { >+ Map options = COMPLETION_PROJECT.getOptions(true); >+ Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); >+ Object savedOptionSource = options.get(CompilerOptions.OPTION_Source); >+ try { >+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_8); >+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_8); >+ COMPLETION_PROJECT.setOptions(options); >+ this.workingCopies = new ICompilationUnit[1]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/X.java", >+ "public interface Foo {\n" + >+ " static int intVar = 0;\n" + >+ "}\n" + >+ "interface AnotherFoo {\n" + >+ " static int intVar = 0;\n" + >+ "}\n" + >+ "interface X extends Foo, AnotherFoo{}\n" + >+ "class XClass implements X{\n" + >+ " void method () {\n" + >+ " int v = intV\n" + >+ "}\n"); >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "int v = intV"; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ assertResults( >+ "intVar[FIELD_REF]{AnotherFoo.intVar, Ltest.AnotherFoo;, I, intVar, null, 54}\n" + >+ "intVar[FIELD_REF]{Foo.intVar, Ltest.Foo;, I, intVar, null, 57}", >+ requestor.getResults()); >+ } finally { >+ // Restore compliance settings. >+ options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); >+ options.put(CompilerOptions.OPTION_Source, savedOptionSource); >+ COMPLETION_PROJECT.setOptions(options); >+ } >+} > } >diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java >index 96a93bc..2fa241e 100644 >--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java >+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java >@@ -2254,10 +2254,11 @@ > || !this.requestor.isIgnored(CompletionProposal.JAVADOC_FIELD_REF)) { > findFields(this.completionToken, > receiverType, > scope, > new ObjectVector(), >+ null, > new ObjectVector(), > false, /*not only static */ > fieldRef, > scope, > false, >@@ -6139,10 +6140,11 @@ > private void findFields( > char[] fieldName, > FieldBinding[] fields, > Scope scope, > ObjectVector fieldsFound, >+ ObjectVector fieldProposals, > ObjectVector localsFound, > boolean onlyStaticFields, > ReferenceBinding receiverType, > InvocationSite invocationSite, > Scope invocationScope, >@@ -6155,10 +6157,11 @@ > char[] castedReceiver, > int receiverStart, > int receiverEnd) { > > ObjectVector newFieldsFound = new ObjectVector(); >+ ObjectVector newFieldProposals = new ObjectVector(); > // if the proposal is being asked inside a field's initialization, we'll record its id > int fieldBeingCompletedId = -1; > boolean isFieldBeingCompletedStatic = false; > for (int f = fields.length; --f >=0;) { > FieldBinding field = fields[f]; >@@ -6237,10 +6240,11 @@ > continue next; // non-constants not allowed in case. > } > } > > boolean prefixRequired = false; >+ boolean rootNameCompletion = false; > > for (int i = fieldsFound.size; --i >= 0;) { > Object[] other = (Object[])fieldsFound.elementAt(i); > FieldBinding otherField = (FieldBinding) other[0]; > ReferenceBinding otherReceiverType = (ReferenceBinding) other[1]; >@@ -6258,10 +6262,17 @@ > if (field.declaringClass.isInterface()) > if (otherField.declaringClass.implementsInterface(field.declaringClass, true)) > continue next; > if(canBePrefixed) { > prefixRequired = true; >+ if (fieldProposals != null) { >+ InternalCompletionProposal oldProposal = (InternalCompletionProposal)fieldProposals.elementAt(i); >+ if (oldProposal.getKind() == CompletionProposal.FIELD_REF && CharOperation.equals(field.name, oldProposal.getName())) { >+ rootNameCompletion = true; >+ oldProposal.setCompletion(CharOperation.concat(oldProposal.declarationTypeName, oldProposal.getName(), '.')); >+ } >+ } > } else { > continue next; > } > } > } >@@ -6356,16 +6367,21 @@ > missingElementsEnds[i], > relevance); > } > proposal.setRequiredProposals(subProposals); > } >- proposal.setCompletion(completion); >+ proposal.setCompletion(rootNameCompletion ? CharOperation.concat(field.declaringClass.qualifiedSourceName(), field.name, '.') : completion); > proposal.setFlags(field.modifiers); > proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); > proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); > proposal.setRelevance(relevance); >- this.requestor.accept(proposal); >+ if (fieldProposals != null) { >+ newFieldProposals.add(proposal); >+ } >+ else { >+ this.requestor.accept(proposal); >+ } > if(DEBUG) { > this.printDebug(proposal); > } > } > >@@ -6384,11 +6400,16 @@ > proposal.setFlags(field.modifiers); > int start = (this.assistNodeInJavadoc & CompletionOnJavadoc.REPLACE_TAG) != 0 ? this.javadocTagPosition : this.startPosition; > proposal.setReplaceRange(start - this.offset, this.endPosition - this.offset); > proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); > proposal.setRelevance(relevance+R_INLINE_TAG); >- this.requestor.accept(proposal); >+ if (fieldProposals != null) { >+ newFieldProposals.add(proposal); >+ } >+ else { >+ this.requestor.accept(proposal); >+ } > if(DEBUG) { > this.printDebug(proposal); > } > // Javadoc value completion for static fields > if (field.isStatic() && !this.requestor.isIgnored(CompletionProposal.JAVADOC_VALUE_REF)) { >@@ -6404,11 +6425,16 @@ > valueProposal.setCompletion(javadocCompletion); > valueProposal.setFlags(field.modifiers); > valueProposal.setReplaceRange(start - this.offset, this.endPosition - this.offset); > valueProposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); > valueProposal.setRelevance(relevance+R_VALUE_TAG); >- this.requestor.accept(valueProposal); >+ if (fieldProposals != null) { >+ newFieldProposals.add(valueProposal); >+ } >+ else { >+ this.requestor.accept(valueProposal); >+ } > if(DEBUG) { > this.printDebug(valueProposal); > } > } > } >@@ -6433,31 +6459,40 @@ > missingElementsEnds[i], > relevance); > } > proposal.setRequiredProposals(subProposals); > } >- proposal.setCompletion(completion); >+ proposal.setCompletion(rootNameCompletion ? CharOperation.concat(field.declaringClass.qualifiedSourceName(), field.name, '.') : completion); > proposal.setFlags(field.modifiers); > proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); > proposal.setReceiverRange(receiverStart - this.offset, receiverEnd - this.offset); > proposal.setTokenRange(this.tokenStart - this.offset, this.tokenEnd - this.offset); > proposal.setRelevance(relevance); >- this.requestor.accept(proposal); >+ if (fieldProposals != null) { >+ newFieldProposals.add(proposal); >+ } >+ else { >+ this.requestor.accept(proposal); >+ } > if(DEBUG) { > this.printDebug(proposal); > } > } > } > } > > fieldsFound.addAll(newFieldsFound); >+ if (fieldProposals != null) { >+ fieldProposals.addAll(newFieldProposals); >+ } > } > private void findFields( > char[] fieldName, > ReferenceBinding receiverType, > Scope scope, > ObjectVector fieldsFound, >+ ObjectVector fieldProposals, > ObjectVector localsFound, > boolean onlyStaticFields, > InvocationSite invocationSite, > Scope invocationScope, > boolean implicitCall, >@@ -6501,10 +6536,11 @@ > findFields( > fieldName, > fields, > scope, > fieldsFound, >+ null, > localsFound, > onlyStaticFields, > receiverType, > invocationSite, > invocationScope, >@@ -6529,10 +6565,11 @@ > findFields( > fieldName, > fields, > scope, > fieldsFound, >+ fieldProposals, > localsFound, > onlyStaticFields, > receiverType, > invocationSite, > invocationScope, >@@ -6557,10 +6594,16 @@ > for (int b = 0; b < nextPosition; b++) > if (next == interfacesToVisit[b]) continue nextInterface; > interfacesToVisit[nextPosition++] = next; > } > } >+ } >+ if (fieldProposals != null) { >+ for (int indx = 0; indx < fieldProposals.size; indx++) { >+ this.requestor.accept((InternalCompletionProposal)fieldProposals.elementAt(indx)); >+ } >+ fieldProposals.removeAll(); > } > } > } > > protected void findFieldsAndMethods( >@@ -6807,10 +6850,11 @@ > findFields( > token, > (ReferenceBinding) receiverType, > scope, > fieldsFound, >+ null, > new ObjectVector(), > false, > invocationSite, > invocationScope, > implicitCall, >@@ -7343,10 +7387,11 @@ > findFields( > token, > (ReferenceBinding)binding, > scope, > fieldsFound, >+ null, > localsFound, > true, > invocationSite, > invocationScope, > true, >@@ -7389,10 +7434,11 @@ > findFields( > token, > new FieldBinding[]{(FieldBinding)binding}, > scope, > fieldsFound, >+ null, > localsFound, > true, > ((FieldBinding)binding).declaringClass, > invocationSite, > invocationScope, >@@ -9250,10 +9296,11 @@ > findFields( > token, > receiverType, > scope, > new ObjectVector(), >+ null, > new ObjectVector(), > true, > invocationSite, > scope, > false, >@@ -11591,10 +11638,12 @@ > > ObjectVector localsFound = new ObjectVector(); > ObjectVector fieldsFound = new ObjectVector(); > ObjectVector methodsFound = new ObjectVector(); > >+ ObjectVector fieldProposals = new ObjectVector(); >+ > Scope currentScope = scope; > > if (!this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) { > done1 : while (true) { // done when a COMPILATION_UNIT_SCOPE is found > >@@ -11740,10 +11789,11 @@ > findFields( > token, > enclosingType, > classScope, > fieldsFound, >+ fieldProposals, > localsFound, > staticsOnly, > invocationSite, > invocationScope, > true,
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
Flags:
anchakrk
:
review?
Actions:
View
|
Diff
Attachments on
bug 405141
: 233551