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 111807 Details for
Bug 114116
[assist] name suggestion for collections
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
bug114116_003.txt (text/plain), 17.42 KB, created by
David Audel
on 2008-09-05 07:16:37 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
David Audel
Created:
2008-09-05 07:16:37 EDT
Size:
17.42 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/JavadocTypeCompletionModelTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocTypeCompletionModelTest.java,v >retrieving revision 1.17 >diff -u -r1.17 JavadocTypeCompletionModelTest.java >--- src/org/eclipse/jdt/core/tests/model/JavadocTypeCompletionModelTest.java 8 Jul 2008 13:29:10 -0000 1.17 >+++ src/org/eclipse/jdt/core/tests/model/JavadocTypeCompletionModelTest.java 5 Sep 2008 10:02:20 -0000 >@@ -455,6 +455,7 @@ > "}\n"; > completeInJavadoc("/Completion/src/javadoc/types/tags/BasicTestTypes.java", source, true, "java."); > assertResults( >+ "java.util[PACKAGE_REF]{java.util, java.util, null, null, null, "+this.positions+R_DRICQNR+"}\n" + > "java.lang.annotation[PACKAGE_REF]{java.lang.annotation, java.lang.annotation, null, null, null, "+this.positions+R_DRICQNR+"}\n" + > "java.lang[PACKAGE_REF]{java.lang, java.lang, null, null, null, "+this.positions+R_DRICQNR+"}\n" + > "java.io[PACKAGE_REF]{java.io, java.io, null, null, null, "+this.positions+R_DRICQNR+"}" >Index: src/org/eclipse/jdt/core/tests/model/JavadocPackageCompletionModelTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavadocPackageCompletionModelTest.java,v >retrieving revision 1.15 >diff -u -r1.15 JavadocPackageCompletionModelTest.java >--- src/org/eclipse/jdt/core/tests/model/JavadocPackageCompletionModelTest.java 8 Jul 2008 13:29:10 -0000 1.15 >+++ src/org/eclipse/jdt/core/tests/model/JavadocPackageCompletionModelTest.java 5 Sep 2008 10:02:20 -0000 >@@ -301,7 +301,8 @@ > completeInJavadoc("/Completion/src/javadoc/tags/package-info.java", source, true, "I"); > assertSortedResults( > "IllegalMonitorStateException[TYPE_REF]{IllegalMonitorStateException, java.lang, Ljava.lang.IllegalMonitorStateException;, null, null, "+this.positions+R_DRICUNR+"}\n" + >- "InterruptedException[TYPE_REF]{InterruptedException, java.lang, Ljava.lang.InterruptedException;, null, null, "+this.positions+R_DRICUNR+"}" >+ "InterruptedException[TYPE_REF]{InterruptedException, java.lang, Ljava.lang.InterruptedException;, null, null, "+this.positions+R_DRICUNR+"}\n" + >+ "Iterator[TYPE_REF]{java.util.Iterator, java.util, Ljava.util.Iterator;, null, null, "+this.positions+R_DRICNR+"}" > ); > } > >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v >retrieving revision 1.154 >diff -u -r1.154 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 4 Sep 2008 16:37:12 -0000 1.154 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 5 Sep 2008 10:02:20 -0000 >@@ -8567,6 +8567,7 @@ > ""+ getExternalJCLPathString("1.5") + " java.io\n" + > ""+ getExternalJCLPathString("1.5") + " java.lang\n" + > ""+ getExternalJCLPathString("1.5") + " java.lang.annotation\n" + >+ ""+ getExternalJCLPathString("1.5") + " java.util\n" + > "lib \n" + > "lib/JavaSearch15.jar [No source]\n" + > "lib/JavaSearch15.jar g1 [No source]\n" + >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.107 >diff -u -r1.107 CompletionTests_1_5.java >--- src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 23 Jul 2008 13:25:31 -0000 1.107 >+++ src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 5 Sep 2008 10:02:18 -0000 >@@ -12015,6 +12015,91 @@ > "foo2[METHOD_REF]{foo2(), Ltest.Test;, ()V, foo2, null, public deprecated, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", > requestor.getResults()); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114116 >+public void test0376() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[2]; >+ >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test.java", >+ "package test;\n"+ >+ "public class Test {\n"+ >+ " MyCollection<String> \n"+ >+ "}"); >+ >+ this.workingCopies[1] = getWorkingCopy( >+ "/Completion/src/test/MyCollection.java", >+ "package test;\n"+ >+ "public abstract class MyCollection<T> implements java.util.Collection<T> {\n"+ >+ "}"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "MyCollection<String> "; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "collection[VARIABLE_DECLARATION]{collection, null, Ltest.MyCollection<Ljava.lang.String;>;, collection, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + >+ "myCollection[VARIABLE_DECLARATION]{myCollection, null, Ltest.MyCollection<Ljava.lang.String;>;, myCollection, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + >+ "strings[VARIABLE_DECLARATION]{strings, null, Ltest.MyCollection<Ljava.lang.String;>;, strings, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", >+ requestor.getResults()); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114116 >+public void test0377() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[2]; >+ >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test.java", >+ "package test;\n"+ >+ "public class Test {\n"+ >+ " MyCollection \n"+ >+ "}"); >+ >+ this.workingCopies[1] = getWorkingCopy( >+ "/Completion/src/test/MyCollection.java", >+ "package test;\n"+ >+ "public abstract class MyCollection<T> implements java.util.Collection<T> {\n"+ >+ "}"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "MyCollection "; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "collection[VARIABLE_DECLARATION]{collection, null, Ltest.MyCollection;, collection, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + >+ "myCollection[VARIABLE_DECLARATION]{myCollection, null, Ltest.MyCollection;, myCollection, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", >+ requestor.getResults()); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114116 >+public void test0378() throws JavaModelException { >+ this.workingCopies = new ICompilationUnit[2]; >+ >+ this.workingCopies[0] = getWorkingCopy( >+ "/Completion/src/test/Test.java", >+ "package test;\n"+ >+ "public class Test {\n"+ >+ " MyCollection<String, String> \n"+ >+ "}"); >+ >+ this.workingCopies[1] = getWorkingCopy( >+ "/Completion/src/test/MyCollection.java", >+ "package test;\n"+ >+ "public abstract class MyCollection<T, U> implements java.util.Collection<T> {\n"+ >+ "}"); >+ >+ CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); >+ String str = this.workingCopies[0].getSource(); >+ String completeBehind = "MyCollection<String, String> "; >+ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); >+ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); >+ >+ assertResults( >+ "collection[VARIABLE_DECLARATION]{collection, null, Ltest.MyCollection<Ljava.lang.String;Ljava.lang.String;>;, collection, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + >+ "myCollection[VARIABLE_DECLARATION]{myCollection, null, Ltest.MyCollection<Ljava.lang.String;Ljava.lang.String;>;, myCollection, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + 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]; >Index: JCL/jclMin1.5src.zip >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/JCL/jclMin1.5src.zip,v >retrieving revision 1.10 >diff -u -r1.10 jclMin1.5src.zip >Binary files /tmp/cvsGwfwZG and jclMin1.5src.zip differ >Index: JCL/jclMin1.5.jar >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/JCL/jclMin1.5.jar,v >retrieving revision 1.10 >diff -u -r1.10 jclMin1.5.jar >Binary files /tmp/cvsHU7EfF and jclMin1.5.jar differ >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java,v >retrieving revision 1.30 >diff -u -r1.30 TypeIds.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java 27 Jun 2008 16:04:02 -0000 1.30 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java 5 Sep 2008 10:02:24 -0000 >@@ -86,6 +86,8 @@ > final int T_JavaIoExternalizable = 56; > final int T_JavaIoObjectStreamException = 57; > final int T_JavaIoException = 58; >+ >+ final int T_JavaUtilCollection = 59; > > final int NoId = Integer.MAX_VALUE; > >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java,v >retrieving revision 1.45 >diff -u -r1.45 TypeConstants.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java 27 Jun 2008 16:04:02 -0000 1.45 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java 5 Sep 2008 10:02:24 -0000 >@@ -107,6 +107,7 @@ > char[][] JAVA_LANG_DOUBLE = {JAVA, LANG, "Double".toCharArray()}; //$NON-NLS-1$ > char[][] JAVA_LANG_BOOLEAN = {JAVA, LANG, "Boolean".toCharArray()}; //$NON-NLS-1$ > char[][] JAVA_LANG_VOID = {JAVA, LANG, "Void".toCharArray()}; //$NON-NLS-1$ >+ char[][] JAVA_UTIL_COLLECTION = {JAVA, UTIL, "Collection".toCharArray()}; //$NON-NLS-1$ > char[][] JAVA_UTIL_ITERATOR = {JAVA, UTIL, "Iterator".toCharArray()}; //$NON-NLS-1$ > char[][] JAVA_LANG_DEPRECATED = {JAVA, LANG, "Deprecated".toCharArray()}; //$NON-NLS-1$ > char[][] JAVA_LANG_ANNOTATION_DOCUMENTED = {JAVA, LANG, ANNOTATION, "Documented".toCharArray()}; //$NON-NLS-1$ >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java,v >retrieving revision 1.121 >diff -u -r1.121 ReferenceBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 3 Sep 2008 12:00:07 -0000 1.121 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 5 Sep 2008 10:02:23 -0000 >@@ -377,9 +377,11 @@ > this.id = TypeIds.T_JavaIoObjectStreamException; > else if (CharOperation.equals(TypeConstants.JAVA_IO_IOEXCEPTION[2], this.compoundName[2])) > this.id = TypeIds.T_JavaIoException; >- } else if (CharOperation.equals(TypeConstants.UTIL, this.compoundName[1]) >- && CharOperation.equals(TypeConstants.JAVA_UTIL_ITERATOR[2], this.compoundName[2])) { >- this.id = TypeIds.T_JavaUtilIterator; >+ } else if (CharOperation.equals(TypeConstants.UTIL, this.compoundName[1])){ >+ if (CharOperation.equals(TypeConstants.JAVA_UTIL_ITERATOR[2], this.compoundName[2])) >+ this.id = TypeIds.T_JavaUtilIterator; >+ else if (CharOperation.equals(TypeConstants.JAVA_UTIL_COLLECTION[2], this.compoundName[2])) >+ this.id = TypeIds.T_JavaUtilCollection; > } > return; > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v >retrieving revision 1.339 >diff -u -r1.339 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 3 Sep 2008 12:00:30 -0000 1.339 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 5 Sep 2008 10:02:24 -0000 >@@ -2069,6 +2069,11 @@ > unitScope.recordQualifiedReference(JAVA_LANG_THROWABLE); > return unitScope.environment.getResolvedType(JAVA_LANG_THROWABLE, this); > } >+ public final ReferenceBinding getJavaUtilCollection() { >+ CompilationUnitScope unitScope = compilationUnitScope(); >+ unitScope.recordQualifiedReference(JAVA_UTIL_COLLECTION); >+ return unitScope.environment.getResolvedType(JAVA_UTIL_COLLECTION, this); >+ } > public final ReferenceBinding getJavaUtilIterator() { > CompilationUnitScope unitScope = compilationUnitScope(); > unitScope.recordQualifiedReference(JAVA_UTIL_ITERATOR); >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.372 >diff -u -r1.372 CompletionEngine.java >--- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 4 Sep 2008 13:12:28 -0000 1.372 >+++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 5 Sep 2008 10:02:23 -0000 >@@ -8895,32 +8895,61 @@ > } > // Helper method for private void findVariableNames(char[] name, TypeReference type ) > private void findVariableName( >- char[] token, >- char[] qualifiedPackageName, >- char[] qualifiedSourceName, >- char[] sourceName, >- final TypeBinding typeBinding, >- char[][] discouragedNames, >- final char[][] forbiddenNames, >- int dim, >- int kind, >- int modifiers){ >+ char[] token, >+ char[] qualifiedPackageName, >+ char[] qualifiedSourceName, >+ char[] sourceName, >+ final TypeBinding typeBinding, >+ char[][] discouragedNames, >+ final char[][] forbiddenNames, >+ int dim, >+ int kind, >+ int modifiers){ >+ findVariableName( >+ token, >+ qualifiedPackageName, >+ qualifiedSourceName, >+ sourceName, >+ typeBinding, >+ discouragedNames, >+ forbiddenNames, >+ false, >+ dim, >+ kind, >+ modifiers); >+ } >+ private void findVariableName( >+ char[] token, >+ char[] qualifiedPackageName, >+ char[] qualifiedSourceName, >+ char[] sourceName, >+ final TypeBinding typeBinding, >+ char[][] discouragedNames, >+ final char[][] forbiddenNames, >+ boolean forCollection, >+ int dim, >+ int kind, >+ int modifiers){ > > if(sourceName == null || sourceName.length == 0) > return; > > // compute variable name for non base type > final char[] displayName; >- if (dim > 0){ >- int l = qualifiedSourceName.length; >- displayName = new char[l+(2*dim)]; >- System.arraycopy(qualifiedSourceName, 0, displayName, 0, l); >- for(int i = 0; i < dim; i++){ >- displayName[l+(i*2)] = '['; >- displayName[l+(i*2)+1] = ']'; >+ if (!forCollection) { >+ if (dim > 0){ >+ int l = qualifiedSourceName.length; >+ displayName = new char[l+(2*dim)]; >+ System.arraycopy(qualifiedSourceName, 0, displayName, 0, l); >+ for(int i = 0; i < dim; i++){ >+ displayName[l+(i*2)] = '['; >+ displayName[l+(i*2)+1] = ']'; >+ } >+ } else { >+ displayName = qualifiedSourceName; > } > } else { >- displayName = qualifiedSourceName; >+ displayName = typeBinding.qualifiedSourceName(); > } > > final char[] t = token; >@@ -9014,6 +9043,31 @@ > break; > } > } >+ >+ private void findVariableNameForCollection( >+ char[] token, >+ char[] qualifiedPackageName, >+ char[] qualifiedSourceName, >+ char[] sourceName, >+ final TypeBinding typeBinding, >+ char[][] discouragedNames, >+ final char[][] forbiddenNames, >+ int kind, >+ int modifiers){ >+ >+ findVariableName( >+ token, >+ qualifiedPackageName, >+ qualifiedSourceName, >+ sourceName, >+ typeBinding, >+ discouragedNames, >+ forbiddenNames, >+ false, >+ 1, >+ kind, >+ modifiers); >+ } > > private void findVariableNames(char[] name, TypeReference type , char[][] discouragedNames, char[][] forbiddenNames, int kind, int modifiers){ > if(type != null && >@@ -9033,6 +9087,25 @@ > type.dimensions(), > kind, > modifiers); >+ >+ if (tb.isParameterizedType() && >+ tb.findSuperTypeOriginatingFrom(TypeIds.T_JavaUtilCollection, false) != null) { >+ ParameterizedTypeBinding ptb = ((ParameterizedTypeBinding) tb); >+ TypeBinding[] arguments = ptb.arguments; >+ if (arguments != null && arguments.length == 1) { >+ TypeBinding argument = arguments[0]; >+ findVariableNameForCollection( >+ name, >+ argument.leafComponentType().qualifiedPackageName(), >+ argument.leafComponentType().qualifiedSourceName(), >+ argument.leafComponentType().sourceName(), >+ tb, >+ discouragedNames, >+ forbiddenNames, >+ kind, >+ modifiers); >+ } >+ } > } > } >
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 114116
: 111807