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 95368 Details for
Bug 82712
[1.5] Code assist does not show method parameters from static imports
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
bug82712_001.txt (text/plain), 13.55 KB, created by
David Audel
on 2008-04-09 10:24:27 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
David Audel
Created:
2008-04-09 10:24:27 EDT
Size:
13.55 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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.98 >diff -u -r1.98 CompletionTests_1_5.java >--- src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 9 Apr 2008 13:28:58 -0000 1.98 >+++ src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 9 Apr 2008 14:22:50 -0000 >@@ -11629,6 +11629,66 @@ > "ZTest3[TYPE_REF]{ZTest3, test, Ltest.ZTest3;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_INTERFACE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", > requestor.getResults()); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=82712 >+public void test0362() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[2]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test.java", >+ "package test;\n"+ >+ "import static test.util.Math.*;\n"+ >+ "public class Test {\n"+ >+ " void foo() {\n"+ >+ " abs();\n"+ >+ " }\n"+ >+ "}\n"); >+ >+ this.workingCopies[1] = getWorkingCopy( >+ "/Completion/src/test/util/Math.java", >+ "package test.util;\n"+ >+ "public class Math {\n"+ >+ " public static int abs(int i) {return null;}\n"+ >+ "}n"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "abs("; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "abs[METHOD_REF]{, Ltest.util.Math;, (I)I, abs, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", >+ requestor.getResults()); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=82712 >+public void test0363() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[2]; >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test.java", >+ "package test;\n"+ >+ "import static test.util.Math.abs;\n"+ >+ "public class Test {\n"+ >+ " void foo() {\n"+ >+ " abs();\n"+ >+ " }\n"+ >+ "}\n"); >+ >+ this.workingCopies[1] = getWorkingCopy( >+ "/Completion/src/test/util/Math.java", >+ "package test.util;\n"+ >+ "public class Math {\n"+ >+ " public static int abs(int i) {return null;}\n"+ >+ "}n"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "abs("; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "abs[METHOD_REF]{, Ltest.util.Math;, (I)I, abs, (i), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", >+ requestor.getResults()); >+} > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130 > public void testEC001() throws JavaModelException { > this.workingCopies = new ICompilationUnit[1]; >#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.362 >diff -u -r1.362 CompletionEngine.java >--- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 9 Apr 2008 13:29:04 -0000 1.362 >+++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 9 Apr 2008 14:22:53 -0000 >@@ -1468,7 +1468,18 @@ > this.completionToken = messageSend.selector; > if (qualifiedBinding == null) { > if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) { >- findImplicitMessageSends(this.completionToken, argTypes, scope, messageSend, scope); >+ ObjectVector methodsFound = new ObjectVector(); >+ >+ findImplicitMessageSends(this.completionToken, argTypes, scope, messageSend, scope, methodsFound); >+ >+ findLocalMethodsFromStaticImports( >+ this.completionToken, >+ scope, >+ messageSend, >+ scope, >+ true, >+ methodsFound, >+ true); > } > } else if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) { > findMethods( >@@ -1952,7 +1963,7 @@ > > if (qualifiedBinding == null) { > if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) { >- findImplicitMessageSends(this.completionToken, argTypes, scope, messageSend, scope); >+ findImplicitMessageSends(this.completionToken, argTypes, scope, messageSend, scope, new ObjectVector()); > } > } else if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) { > findMethods( >@@ -5698,14 +5709,14 @@ > TypeBinding[] argTypes, > Scope scope, > InvocationSite invocationSite, >- Scope invocationScope) { >+ Scope invocationScope, >+ ObjectVector methodsFound) { > > if (token == null) > return; > > boolean staticsOnly = false; > // need to know if we're in a static context (or inside a constructor) >- ObjectVector methodsFound = new ObjectVector(); > > done : while (true) { // done when a COMPILATION_UNIT_SCOPE is found > >@@ -6427,10 +6438,11 @@ > } > > // Helper method for findMethods(char[], TypeBinding[], ReferenceBinding, Scope, ObjectVector, boolean, boolean, boolean) >- private void findLocalMethodsOfStaticImports( >+ private void findLocalMethodsFromStaticImports( > char[] methodName, > MethodBinding[] methods, > Scope scope, >+ boolean exactMatch, > ObjectVector methodsFound, > ReferenceBinding receiverType, > InvocationSite invocationSite) { >@@ -6492,13 +6504,17 @@ > int previousStartPosition = this.startPosition; > int previousTokenStart = this.tokenStart; > >- // nothing to insert - do not want to replace the existing selector & arguments >- if (this.source != null >- && this.source.length > this.endPosition >- && this.source[this.endPosition] == '(') { >- completion = method.selector; >+ if (!exactMatch) { >+ if (this.source != null >+ && this.source.length > this.endPosition >+ && this.source[this.endPosition] == '(') { >+ completion = method.selector; >+ } else { >+ completion = CharOperation.concat(method.selector, new char[] { '(', ')' }); >+ } > } else { >- completion = CharOperation.concat(method.selector, new char[] { '(', ')' }); >+ this.startPosition = this.endPosition; >+ this.tokenStart = this.tokenEnd; > } > > int relevance = computeBaseRelevance(); >@@ -8280,92 +8296,155 @@ > currentScope = currentScope.parent; > } > >- // search in static import >- ImportBinding[] importBindings = scope.compilationUnitScope().imports; >- for (int i = 0; i < importBindings.length; i++) { >- ImportBinding importBinding = importBindings[i]; >- if(importBinding.isValidBinding() && importBinding.isStatic()) { >- Binding binding = importBinding.resolvedImport; >- if(binding != null && binding.isValidBinding()) { >- if(importBinding.onDemand) { >- if((binding.kind() & Binding.TYPE) != 0) { >- if(proposeField) { >+ findFieldsAndMethodsFromStaticImports( >+ token, >+ scope, >+ invocationSite, >+ invocationScope, >+ false, >+ insideAnnotationAttribute, >+ localsFound, >+ fieldsFound, >+ methodsFound, >+ proposeField, >+ proposeMethod); >+ >+ if (this.assistNodeInJavadoc == 0) { >+ // search in favorites import >+ findFieldsAndMethodsFromFavorites( >+ token, >+ scope, >+ invocationSite, >+ invocationScope, >+ localsFound, >+ fieldsFound, >+ methodsFound); >+ } >+ } >+ } >+ >+ private void findLocalMethodsFromStaticImports( >+ char[] token, >+ Scope scope, >+ InvocationSite invocationSite, >+ Scope invocationScope, >+ boolean exactMatch, >+ ObjectVector methodsFound, >+ boolean proposeMethod) { >+ this.findFieldsAndMethodsFromStaticImports( >+ token, >+ scope, >+ invocationSite, >+ invocationScope, >+ exactMatch, >+ false, >+ new ObjectVector(), >+ new ObjectVector(), >+ methodsFound, >+ false, >+ proposeMethod); >+ } >+ >+ private void findFieldsAndMethodsFromStaticImports( >+ char[] token, >+ Scope scope, >+ InvocationSite invocationSite, >+ Scope invocationScope, >+ boolean exactMatch, >+ boolean insideAnnotationAttribute, >+ ObjectVector localsFound, >+ ObjectVector fieldsFound, >+ ObjectVector methodsFound, >+ boolean proposeField, >+ boolean proposeMethod) { >+ // search in static import >+ ImportBinding[] importBindings = scope.compilationUnitScope().imports; >+ for (int i = 0; i < importBindings.length; i++) { >+ ImportBinding importBinding = importBindings[i]; >+ if(importBinding.isValidBinding() && importBinding.isStatic()) { >+ Binding binding = importBinding.resolvedImport; >+ if(binding != null && binding.isValidBinding()) { >+ if(importBinding.onDemand) { >+ if((binding.kind() & Binding.TYPE) != 0) { >+ if(proposeField) { >+ findFields( >+ token, >+ (ReferenceBinding)binding, >+ scope, >+ fieldsFound, >+ localsFound, >+ true, >+ invocationSite, >+ invocationScope, >+ true, >+ false, >+ null, >+ null, >+ null, >+ false, >+ null, >+ -1, >+ -1); >+ } >+ if(proposeMethod && !insideAnnotationAttribute) { >+ findMethods( >+ token, >+ null, >+ null, >+ (ReferenceBinding)binding, >+ scope, >+ methodsFound, >+ true, >+ exactMatch, >+ false, >+ invocationSite, >+ invocationScope, >+ true, >+ false, >+ false, >+ null, >+ null, >+ null, >+ false, >+ null, >+ -1, >+ -1); >+ } >+ } >+ } else { >+ if ((binding.kind() & Binding.FIELD) != 0) { >+ if(proposeField) { > findFields( >- token, >- (ReferenceBinding)binding, >- scope, >- fieldsFound, >- localsFound, >- true, >- invocationSite, >- invocationScope, >- true, >- false, >- null, >- null, >- null, >- false, >- null, >- -1, >- -1); >- } >- if(proposeMethod && !insideAnnotationAttribute) { >- findMethods( >- token, >- null, >- null, >- (ReferenceBinding)binding, >- scope, >- methodsFound, >- true, >- false, >- false, >- invocationSite, >- invocationScope, >- true, >- false, >- false, >- null, >- null, >- null, >- false, >- null, >- -1, >- -1); >- } >+ token, >+ new FieldBinding[]{(FieldBinding)binding}, >+ scope, >+ fieldsFound, >+ localsFound, >+ true, >+ ((FieldBinding)binding).declaringClass, >+ invocationSite, >+ invocationScope, >+ true, >+ false, >+ null, >+ null, >+ null, >+ false, >+ null, >+ -1, >+ -1); > } >- } else { >- if ((binding.kind() & Binding.FIELD) != 0) { >- if(proposeField) { >- findFields( >- token, >- new FieldBinding[]{(FieldBinding)binding}, >- scope, >- fieldsFound, >- localsFound, >- true, >- ((FieldBinding)binding).declaringClass, >- invocationSite, >- invocationScope, >- true, >- false, >- null, >- null, >- null, >- false, >- null, >- -1, >- -1); >- } >- } else if ((binding.kind() & Binding.METHOD) != 0) { >- if(proposeMethod && !insideAnnotationAttribute) { >- MethodBinding methodBinding = (MethodBinding)binding; >- if(CharOperation.prefixEquals(token, methodBinding.selector)) >- >- findLocalMethodsOfStaticImports( >+ } else if ((binding.kind() & Binding.METHOD) != 0) { >+ if(proposeMethod && !insideAnnotationAttribute) { >+ MethodBinding methodBinding = (MethodBinding)binding; >+ if ((exactMatch && CharOperation.equals(token, methodBinding.selector)) || >+ !exactMatch && CharOperation.prefixEquals(token, methodBinding.selector)) { >+ >+ findLocalMethodsFromStaticImports( > methodBinding.selector, > methodBinding.declaringClass.methods(), > scope, >+ exactMatch, > methodsFound, > methodBinding.declaringClass, > invocationSite); >@@ -8375,18 +8454,6 @@ > } > } > } >- >- if (this.assistNodeInJavadoc == 0) { >- // search in favorites import >- findFieldsAndMethodsFromFavorites( >- token, >- scope, >- invocationSite, >- invocationScope, >- localsFound, >- fieldsFound, >- methodsFound); >- } > } > } > private char[][] findVariableFromUnresolvedReference(LocalDeclaration variable, BlockScope scope, final char[][] discouragedNames) {
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 82712
: 95368