View | Details | Raw Unified | Return to bug 114116
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavadocTypeCompletionModelTest.java (+1 lines)
Lines 455-460 Link Here
455
		"}\n";
455
		"}\n";
456
	completeInJavadoc("/Completion/src/javadoc/types/tags/BasicTestTypes.java", source, true, "java.");
456
	completeInJavadoc("/Completion/src/javadoc/types/tags/BasicTestTypes.java", source, true, "java.");
457
	assertResults(
457
	assertResults(
458
		"java.util[PACKAGE_REF]{java.util, java.util, null, null, null, "+this.positions+R_DRICQNR+"}\n" +
458
		"java.lang.annotation[PACKAGE_REF]{java.lang.annotation, java.lang.annotation, null, null, null, "+this.positions+R_DRICQNR+"}\n" +
459
		"java.lang.annotation[PACKAGE_REF]{java.lang.annotation, java.lang.annotation, null, null, null, "+this.positions+R_DRICQNR+"}\n" +
459
		"java.lang[PACKAGE_REF]{java.lang, java.lang, null, null, null, "+this.positions+R_DRICQNR+"}\n" +
460
		"java.lang[PACKAGE_REF]{java.lang, java.lang, null, null, null, "+this.positions+R_DRICQNR+"}\n" +
460
		"java.io[PACKAGE_REF]{java.io, java.io, null, null, null, "+this.positions+R_DRICQNR+"}"
461
		"java.io[PACKAGE_REF]{java.io, java.io, null, null, null, "+this.positions+R_DRICQNR+"}"
(-)src/org/eclipse/jdt/core/tests/model/JavadocPackageCompletionModelTest.java (-1 / +2 lines)
Lines 301-307 Link Here
301
	completeInJavadoc("/Completion/src/javadoc/tags/package-info.java", source, true, "I");
301
	completeInJavadoc("/Completion/src/javadoc/tags/package-info.java", source, true, "I");
302
	assertSortedResults(
302
	assertSortedResults(
303
		"IllegalMonitorStateException[TYPE_REF]{IllegalMonitorStateException, java.lang, Ljava.lang.IllegalMonitorStateException;, null, null, "+this.positions+R_DRICUNR+"}\n" +
303
		"IllegalMonitorStateException[TYPE_REF]{IllegalMonitorStateException, java.lang, Ljava.lang.IllegalMonitorStateException;, null, null, "+this.positions+R_DRICUNR+"}\n" +
304
		"InterruptedException[TYPE_REF]{InterruptedException, java.lang, Ljava.lang.InterruptedException;, null, null, "+this.positions+R_DRICUNR+"}"
304
		"InterruptedException[TYPE_REF]{InterruptedException, java.lang, Ljava.lang.InterruptedException;, null, null, "+this.positions+R_DRICUNR+"}\n" +
305
		"Iterator[TYPE_REF]{java.util.Iterator, java.util, Ljava.util.Iterator;, null, null, "+this.positions+R_DRICNR+"}"
305
	);
306
	);
306
}
307
}
307
308
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (+1 lines)
Lines 8567-8572 Link Here
8567
		""+ getExternalJCLPathString("1.5") + " java.io\n" +
8567
		""+ getExternalJCLPathString("1.5") + " java.io\n" +
8568
		""+ getExternalJCLPathString("1.5") + " java.lang\n" +
8568
		""+ getExternalJCLPathString("1.5") + " java.lang\n" +
8569
		""+ getExternalJCLPathString("1.5") + " java.lang.annotation\n" +
8569
		""+ getExternalJCLPathString("1.5") + " java.lang.annotation\n" +
8570
		""+ getExternalJCLPathString("1.5") + " java.util\n" +
8570
		"lib \n" +
8571
		"lib \n" +
8571
		"lib/JavaSearch15.jar  [No source]\n" +
8572
		"lib/JavaSearch15.jar  [No source]\n" +
8572
		"lib/JavaSearch15.jar g1 [No source]\n" +
8573
		"lib/JavaSearch15.jar g1 [No source]\n" +
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (+85 lines)
Lines 12015-12020 Link Here
12015
			"foo2[METHOD_REF]{foo2(), Ltest.Test;, ()V, foo2, null, public deprecated, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12015
			"foo2[METHOD_REF]{foo2(), Ltest.Test;, ()V, foo2, null, public deprecated, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
12016
			requestor.getResults());
12016
			requestor.getResults());
12017
}
12017
}
12018
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114116
12019
public void test0376() throws JavaModelException {
12020
	this.workingCopies = new ICompilationUnit[2];
12021
	
12022
	this.workingCopies[0] = getWorkingCopy(
12023
		"/Completion/src/test/Test.java",
12024
		"package test;\n"+
12025
		"public class Test {\n"+
12026
		"        MyCollection<String> \n"+
12027
		"}");
12028
	
12029
	this.workingCopies[1] = getWorkingCopy(
12030
		"/Completion/src/test/MyCollection.java",
12031
		"package test;\n"+
12032
		"public abstract class MyCollection<T> implements java.util.Collection<T> {\n"+
12033
		"}");
12034
	
12035
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12036
	String str = this.workingCopies[0].getSource();
12037
	String completeBehind = "MyCollection<String> ";
12038
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12039
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12040
12041
	assertResults(
12042
			"collection[VARIABLE_DECLARATION]{collection, null, Ltest.MyCollection<Ljava.lang.String;>;, collection, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12043
			"myCollection[VARIABLE_DECLARATION]{myCollection, null, Ltest.MyCollection<Ljava.lang.String;>;, myCollection, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12044
			"strings[VARIABLE_DECLARATION]{strings, null, Ltest.MyCollection<Ljava.lang.String;>;, strings, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
12045
			requestor.getResults());
12046
}
12047
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114116
12048
public void test0377() throws JavaModelException {
12049
	this.workingCopies = new ICompilationUnit[2];
12050
	
12051
	this.workingCopies[0] = getWorkingCopy(
12052
		"/Completion/src/test/Test.java",
12053
		"package test;\n"+
12054
		"public class Test {\n"+
12055
		"        MyCollection \n"+
12056
		"}");
12057
	
12058
	this.workingCopies[1] = getWorkingCopy(
12059
		"/Completion/src/test/MyCollection.java",
12060
		"package test;\n"+
12061
		"public abstract class MyCollection<T> implements java.util.Collection<T> {\n"+
12062
		"}");
12063
	
12064
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12065
	String str = this.workingCopies[0].getSource();
12066
	String completeBehind = "MyCollection ";
12067
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12068
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12069
12070
	assertResults(
12071
			"collection[VARIABLE_DECLARATION]{collection, null, Ltest.MyCollection;, collection, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
12072
			"myCollection[VARIABLE_DECLARATION]{myCollection, null, Ltest.MyCollection;, myCollection, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
12073
			requestor.getResults());
12074
}
12075
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114116
12076
public void test0378() throws JavaModelException {
12077
	this.workingCopies = new ICompilationUnit[2];
12078
	
12079
	this.workingCopies[0] = getWorkingCopy(
12080
		"/Completion/src/test/Test.java",
12081
		"package test;\n"+
12082
		"public class Test {\n"+
12083
		"        MyCollection<String, String> \n"+
12084
		"}");
12085
	
12086
	this.workingCopies[1] = getWorkingCopy(
12087
		"/Completion/src/test/MyCollection.java",
12088
		"package test;\n"+
12089
		"public abstract class MyCollection<T, U> implements java.util.Collection<T> {\n"+
12090
		"}");
12091
	
12092
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
12093
	String str = this.workingCopies[0].getSource();
12094
	String completeBehind = "MyCollection<String, String> ";
12095
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
12096
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
12097
12098
	assertResults(
12099
			"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" +
12100
			"myCollection[VARIABLE_DECLARATION]{myCollection, null, Ltest.MyCollection<Ljava.lang.String;Ljava.lang.String;>;, myCollection, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
12101
			requestor.getResults());
12102
}
12018
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130
12103
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=153130
12019
public void testEC001() throws JavaModelException {
12104
public void testEC001() throws JavaModelException {
12020
	this.workingCopies = new ICompilationUnit[1];
12105
	this.workingCopies = new ICompilationUnit[1];
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java (+2 lines)
Lines 86-91 Link Here
86
	final int T_JavaIoExternalizable = 56;
86
	final int T_JavaIoExternalizable = 56;
87
	final int T_JavaIoObjectStreamException = 57;
87
	final int T_JavaIoObjectStreamException = 57;
88
	final int T_JavaIoException = 58;
88
	final int T_JavaIoException = 58;
89
	
90
	final int T_JavaUtilCollection = 59;
89
91
90
	final int NoId = Integer.MAX_VALUE;
92
	final int NoId = Integer.MAX_VALUE;
91
93
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java (+1 lines)
Lines 107-112 Link Here
107
	char[][] JAVA_LANG_DOUBLE = {JAVA, LANG, "Double".toCharArray()}; //$NON-NLS-1$
107
	char[][] JAVA_LANG_DOUBLE = {JAVA, LANG, "Double".toCharArray()}; //$NON-NLS-1$
108
	char[][] JAVA_LANG_BOOLEAN = {JAVA, LANG, "Boolean".toCharArray()}; //$NON-NLS-1$
108
	char[][] JAVA_LANG_BOOLEAN = {JAVA, LANG, "Boolean".toCharArray()}; //$NON-NLS-1$
109
	char[][] JAVA_LANG_VOID = {JAVA, LANG, "Void".toCharArray()}; //$NON-NLS-1$
109
	char[][] JAVA_LANG_VOID = {JAVA, LANG, "Void".toCharArray()}; //$NON-NLS-1$
110
	char[][] JAVA_UTIL_COLLECTION = {JAVA, UTIL, "Collection".toCharArray()}; //$NON-NLS-1$
110
	char[][] JAVA_UTIL_ITERATOR = {JAVA, UTIL, "Iterator".toCharArray()}; //$NON-NLS-1$
111
	char[][] JAVA_UTIL_ITERATOR = {JAVA, UTIL, "Iterator".toCharArray()}; //$NON-NLS-1$
111
	char[][] JAVA_LANG_DEPRECATED = {JAVA, LANG, "Deprecated".toCharArray()}; //$NON-NLS-1$
112
	char[][] JAVA_LANG_DEPRECATED = {JAVA, LANG, "Deprecated".toCharArray()}; //$NON-NLS-1$
112
	char[][] JAVA_LANG_ANNOTATION_DOCUMENTED = {JAVA, LANG, ANNOTATION, "Documented".toCharArray()}; //$NON-NLS-1$
113
	char[][] JAVA_LANG_ANNOTATION_DOCUMENTED = {JAVA, LANG, ANNOTATION, "Documented".toCharArray()}; //$NON-NLS-1$
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java (-3 / +5 lines)
Lines 377-385 Link Here
377
						this.id = TypeIds.T_JavaIoObjectStreamException;
377
						this.id = TypeIds.T_JavaIoObjectStreamException;
378
					else if (CharOperation.equals(TypeConstants.JAVA_IO_IOEXCEPTION[2], this.compoundName[2]))
378
					else if (CharOperation.equals(TypeConstants.JAVA_IO_IOEXCEPTION[2], this.compoundName[2]))
379
						this.id = TypeIds.T_JavaIoException;
379
						this.id = TypeIds.T_JavaIoException;
380
				} else if (CharOperation.equals(TypeConstants.UTIL, this.compoundName[1])
380
				} else if (CharOperation.equals(TypeConstants.UTIL, this.compoundName[1])){
381
						&& CharOperation.equals(TypeConstants.JAVA_UTIL_ITERATOR[2], this.compoundName[2])) {
381
					if (CharOperation.equals(TypeConstants.JAVA_UTIL_ITERATOR[2], this.compoundName[2]))
382
					this.id = TypeIds.T_JavaUtilIterator;
382
						this.id = TypeIds.T_JavaUtilIterator;
383
					else if (CharOperation.equals(TypeConstants.JAVA_UTIL_COLLECTION[2], this.compoundName[2]))
384
						this.id = TypeIds.T_JavaUtilCollection;
383
				}
385
				}
384
				return;
386
				return;
385
			}
387
			}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (+5 lines)
Lines 2069-2074 Link Here
2069
		unitScope.recordQualifiedReference(JAVA_LANG_THROWABLE);
2069
		unitScope.recordQualifiedReference(JAVA_LANG_THROWABLE);
2070
		return unitScope.environment.getResolvedType(JAVA_LANG_THROWABLE, this);
2070
		return unitScope.environment.getResolvedType(JAVA_LANG_THROWABLE, this);
2071
	}
2071
	}
2072
	public final ReferenceBinding getJavaUtilCollection() {
2073
		CompilationUnitScope unitScope = compilationUnitScope();
2074
		unitScope.recordQualifiedReference(JAVA_UTIL_COLLECTION);
2075
		return unitScope.environment.getResolvedType(JAVA_UTIL_COLLECTION, this);
2076
	}
2072
	public final ReferenceBinding getJavaUtilIterator() {
2077
	public final ReferenceBinding getJavaUtilIterator() {
2073
		CompilationUnitScope unitScope = compilationUnitScope();
2078
		CompilationUnitScope unitScope = compilationUnitScope();
2074
		unitScope.recordQualifiedReference(JAVA_UTIL_ITERATOR);
2079
		unitScope.recordQualifiedReference(JAVA_UTIL_ITERATOR);
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-18 / +91 lines)
Lines 8895-8926 Link Here
8895
	}
8895
	}
8896
		// Helper method for private void findVariableNames(char[] name, TypeReference type )
8896
		// Helper method for private void findVariableNames(char[] name, TypeReference type )
8897
	private void findVariableName(
8897
	private void findVariableName(
8898
		char[] token,
8898
			char[] token,
8899
		char[] qualifiedPackageName,
8899
			char[] qualifiedPackageName,
8900
		char[] qualifiedSourceName,
8900
			char[] qualifiedSourceName,
8901
		char[] sourceName,
8901
			char[] sourceName,
8902
		final TypeBinding typeBinding,
8902
			final TypeBinding typeBinding,
8903
		char[][] discouragedNames,
8903
			char[][] discouragedNames,
8904
		final char[][] forbiddenNames,
8904
			final char[][] forbiddenNames,
8905
		int dim,
8905
			int dim,
8906
		int kind,
8906
			int kind,
8907
		int modifiers){
8907
			int modifiers){
8908
		findVariableName(
8909
				token,
8910
				qualifiedPackageName,
8911
				qualifiedSourceName,
8912
				sourceName,
8913
				typeBinding,
8914
				discouragedNames,
8915
				forbiddenNames,
8916
				false,
8917
				dim,
8918
				kind,
8919
				modifiers);
8920
	}
8921
	private void findVariableName(
8922
			char[] token,
8923
			char[] qualifiedPackageName,
8924
			char[] qualifiedSourceName,
8925
			char[] sourceName,
8926
			final TypeBinding typeBinding,
8927
			char[][] discouragedNames,
8928
			final char[][] forbiddenNames,
8929
			boolean forCollection,
8930
			int dim,
8931
			int kind,
8932
			int modifiers){
8908
8933
8909
		if(sourceName == null || sourceName.length == 0)
8934
		if(sourceName == null || sourceName.length == 0)
8910
			return;
8935
			return;
8911
8936
8912
		// compute variable name for non base type
8937
		// compute variable name for non base type
8913
		final char[] displayName;
8938
		final char[] displayName;
8914
		if (dim > 0){
8939
		if (!forCollection) {
8915
			int l = qualifiedSourceName.length;
8940
			if (dim > 0){
8916
			displayName = new char[l+(2*dim)];
8941
				int l = qualifiedSourceName.length;
8917
			System.arraycopy(qualifiedSourceName, 0, displayName, 0, l);
8942
				displayName = new char[l+(2*dim)];
8918
			for(int i = 0; i < dim; i++){
8943
				System.arraycopy(qualifiedSourceName, 0, displayName, 0, l);
8919
				displayName[l+(i*2)] = '[';
8944
				for(int i = 0; i < dim; i++){
8920
				displayName[l+(i*2)+1] = ']';
8945
					displayName[l+(i*2)] = '[';
8946
					displayName[l+(i*2)+1] = ']';
8947
				}
8948
			} else {
8949
				displayName = qualifiedSourceName;
8921
			}
8950
			}
8922
		} else {
8951
		} else {
8923
			displayName = qualifiedSourceName;
8952
			displayName = typeBinding.qualifiedSourceName();
8924
		}
8953
		}
8925
8954
8926
		final char[] t = token;
8955
		final char[] t = token;
Lines 9014-9019 Link Here
9014
				break;
9043
				break;
9015
		}
9044
		}
9016
	}
9045
	}
9046
	
9047
	private void findVariableNameForCollection(
9048
			char[] token,
9049
			char[] qualifiedPackageName,
9050
			char[] qualifiedSourceName,
9051
			char[] sourceName,
9052
			final TypeBinding typeBinding,
9053
			char[][] discouragedNames,
9054
			final char[][] forbiddenNames,
9055
			int kind,
9056
			int modifiers){
9057
9058
		findVariableName(
9059
				token,
9060
				qualifiedPackageName,
9061
				qualifiedSourceName,
9062
				sourceName,
9063
				typeBinding,
9064
				discouragedNames,
9065
				forbiddenNames,
9066
				false,
9067
				1,
9068
				kind,
9069
				modifiers);
9070
	}
9017
9071
9018
	private void findVariableNames(char[] name, TypeReference type , char[][] discouragedNames, char[][] forbiddenNames, int kind, int modifiers){
9072
	private void findVariableNames(char[] name, TypeReference type , char[][] discouragedNames, char[][] forbiddenNames, int kind, int modifiers){
9019
		if(type != null &&
9073
		if(type != null &&
Lines 9033-9038 Link Here
9033
					type.dimensions(),
9087
					type.dimensions(),
9034
					kind,
9088
					kind,
9035
					modifiers);
9089
					modifiers);
9090
				
9091
				if (tb.isParameterizedType() &&
9092
						tb.findSuperTypeOriginatingFrom(TypeIds.T_JavaUtilCollection, false) != null) {
9093
					ParameterizedTypeBinding ptb = ((ParameterizedTypeBinding) tb);
9094
					TypeBinding[] arguments = ptb.arguments;
9095
					if (arguments != null && arguments.length == 1) {
9096
						TypeBinding argument = arguments[0];
9097
						findVariableNameForCollection(
9098
							name,
9099
							argument.leafComponentType().qualifiedPackageName(),
9100
							argument.leafComponentType().qualifiedSourceName(),
9101
							argument.leafComponentType().sourceName(),
9102
							tb,
9103
							discouragedNames,
9104
							forbiddenNames,
9105
							kind,
9106
							modifiers);
9107
					}
9108
				}
9036
			}
9109
			}
9037
		}
9110
		}
9038
9111

Return to bug 114116