### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/core/CompletionRequestor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CompletionRequestor.java,v retrieving revision 1.11 diff -u -r1.11 CompletionRequestor.java --- model/org/eclipse/jdt/core/CompletionRequestor.java 16 Oct 2006 17:21:09 -0000 1.11 +++ model/org/eclipse/jdt/core/CompletionRequestor.java 8 Dec 2006 14:44:25 -0000 @@ -60,6 +60,8 @@ */ private int ignoreSet = 0; + private String[] favoriteReferences; + /** * The set of CompletionProposal kinds that this requestor * allows for required proposals; 0 means the set is empty. @@ -194,6 +196,39 @@ } /** + * Returns the favorites references which are used to compute some completion proposals. + *

+ * A favorite reference is a qualified reference as it can be seen in an import statement.
+ * e.g. {"java.util.Arrays"}
+ * It can be an on demand reference.
+ * e.g. {"java.util.Arrays.*"} + * It can be a reference to a static method or field (as in a static import)
+ * e.g. {"java.util.Arrays.equals"} + *

+ * + * @return favorites imports + * + * @since 3.3 + */ + public String[] getFavoriteReferences() { + return this.favoriteReferences; + } + + /** + * Set the favorites references which will be used to compute some completion proposals. + * A favorite reference is a qualified reference as it can be seen in an import statement.
+ * + * @param favoriteImports + * + * @see #getFavoriteReferences() + * + * @since 3.3 + */ + public void setFavoriteReferences(String[] favoriteImports) { + this.favoriteReferences = favoriteImports; + } + + /** * Pro forma notification sent before reporting a batch of * completion proposals. *

Index: compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java,v retrieving revision 1.103 diff -u -r1.103 CompilationUnitScope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 17 Nov 2006 19:43:52 -0000 1.103 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 8 Dec 2006 14:44:25 -0000 @@ -428,6 +428,14 @@ for (int i = 0, length = topLevelTypes.length; i < length; i++) topLevelTypes[i].faultInTypesForFieldsAndMethods(); } +// this API is for code assist purpose +public Binding findImport(char[][] compoundName, boolean findStaticImports, boolean onDemand) { + if(onDemand) { + return findImport(compoundName, compoundName.length); + } else { + return findSingleImport(compoundName, findStaticImports); + } +} private Binding findImport(char[][] compoundName, int length) { recordQualifiedReference(compoundName); 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.312 diff -u -r1.312 CompletionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 6 Dec 2006 14:28:57 -0000 1.312 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 8 Dec 2006 14:44:25 -0000 @@ -230,6 +230,8 @@ int forbbidenBindingsPtr = -1; Binding[] forbbidenBindings = new Binding[1]; + ImportBinding[] favoriteReferenceBindings; + boolean assistNodeIsClass; boolean assistNodeIsEnum; boolean assistNodeIsException; @@ -3073,6 +3075,81 @@ } } + private void findFieldsAndMethodsFromFavorites( + char[] token, + Scope scope, + InvocationSite invocationSite, + Scope invocationScope, + ObjectVector localsFound, + ObjectVector fieldsFound, + ObjectVector methodsFound) { + + ImportBinding[] favoriteBindings = getFavoriteReferenceBindings(invocationScope); + + if (favoriteBindings != null && favoriteBindings.length > 0) { + for (int i = 0; i < favoriteBindings.length; i++) { + ImportBinding favoriteBinding = favoriteBindings[i]; + switch (favoriteBinding.resolvedImport.kind()) { + case Binding.FIELD: + FieldBinding fieldBinding = (FieldBinding) favoriteBinding.resolvedImport; + findFieldsFromFavorites( + token, + new FieldBinding[]{fieldBinding}, + scope, + fieldsFound, + localsFound, + fieldBinding.declaringClass, + invocationSite, + invocationScope); + break; + case Binding.METHOD: + MethodBinding methodBinding = (MethodBinding) favoriteBinding.resolvedImport; + MethodBinding[] methods = methodBinding.declaringClass.availableMethods(); + long range; + if ((range = ReferenceBinding.binarySearch(methodBinding.selector, methods)) >= 0) { + int start = (int) range, end = (int) (range >> 32); + int length = end - start + 1; + System.arraycopy(methods, start, methods = new MethodBinding[length], 0, length); + } else { + methods = Binding.NO_METHODS; + } + findLocalMethodsFromFavorites( + token, + methods, + scope, + methodsFound, + methodBinding.declaringClass, + invocationSite, + invocationScope); + break; + case Binding.TYPE: + ReferenceBinding referenceBinding = (ReferenceBinding) favoriteBinding.resolvedImport; + if(favoriteBinding.onDemand) { + findFieldsFromFavorites( + token, + referenceBinding.availableFields(), + scope, + fieldsFound, + localsFound, + referenceBinding, + invocationSite, + invocationScope); + + findLocalMethodsFromFavorites( + token, + referenceBinding.availableMethods(), + scope, + methodsFound, + referenceBinding, + invocationSite, + invocationScope); + } + break; + } + } + } + } + private void findFieldsAndMethodsFromMissingFieldType( char[] token, Scope scope, @@ -3240,6 +3317,81 @@ missingTypesConverter.guess(typeRef, scope, substitutionRequestor); } + private void findFieldsFromFavorites( + char[] fieldName, + FieldBinding[] fields, + Scope scope, + ObjectVector fieldsFound, + ObjectVector localsFound, + ReferenceBinding receiverType, + InvocationSite invocationSite, + Scope invocationScope) { + + char[] typeName = CharOperation.concatWith(receiverType.compoundName, '.'); + + int fieldLength = fieldName.length; + next : for (int f = fields.length; --f >= 0;) { + FieldBinding field = fields[f]; + + if (field.isSynthetic()) continue next; + + // only static fields must be proposed + if (!field.isStatic()) continue next; + + if (fieldLength > field.name.length) continue next; + + if (!CharOperation.prefixEquals(fieldName, field.name, false /* ignore case */) + && !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(fieldName, field.name))) continue next; + + if (this.options.checkDeprecation && + field.isViewedAsDeprecated() && + !scope.isDefinedInSameUnit(field.declaringClass)) + continue next; + + if (this.options.checkVisibility + && !field.canBeSeenBy(receiverType, invocationSite, scope)) continue next; + + for (int i = fieldsFound.size; --i >= 0;) { + Object[] other = (Object[])fieldsFound.elementAt(i); + FieldBinding otherField = (FieldBinding) other[0]; + + if (field == otherField) continue next; + } + + fieldsFound.add(new Object[]{field, receiverType}); + + char[] completion = CharOperation.concat(typeName, field.name, '.'); + + int relevance = computeBaseRelevance(); + relevance += computeRelevanceForInterestingProposal(field); + if (fieldName != null) relevance += computeRelevanceForCaseMatching(fieldName, field.name); + relevance += computeRelevanceForExpectingType(field.type); + relevance += computeRelevanceForStatic(true, true); + relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); + + this.noProposal = false; + + if (!this.isIgnored(CompletionProposal.FIELD_REF)) { + CompletionProposal proposal = this.createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); + proposal.setDeclarationSignature(getSignature(field.declaringClass)); + proposal.setSignature(getSignature(field.type)); + proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName()); + proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName()); + proposal.setPackageName(field.type.qualifiedPackageName()); + proposal.setTypeName(field.type.qualifiedSourceName()); + proposal.setName(field.name); + proposal.setCompletion(completion); + proposal.setFlags(field.modifiers); + proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); + proposal.setRelevance(relevance); + this.requestor.accept(proposal); + if(DEBUG) { + this.printDebug(proposal); + } + } + } + } + private void findImports(CompletionOnImportReference importReference, boolean findMembers) { char[][] tokens = importReference.tokens; @@ -4485,6 +4637,130 @@ methodsFound.addAll(newMethodsFound); } + private void findLocalMethodsFromFavorites( + char[] methodName, + MethodBinding[] methods, + Scope scope, + ObjectVector methodsFound, + ReferenceBinding receiverType, + InvocationSite invocationSite, + Scope invocationScope) { + + char[] typeName = CharOperation.concatWith(receiverType.compoundName, '.'); + + int methodLength = methodName.length; + + next : for (int f = methods.length; --f >= 0;) { + MethodBinding method = methods[f]; + + if (method.isSynthetic()) continue next; + + if (method.isDefaultAbstract()) continue next; + + if (method.isConstructor()) continue next; + + if (this.options.checkDeprecation && + method.isViewedAsDeprecated() && + !scope.isDefinedInSameUnit(method.declaringClass)) + continue next; + + if (!method.isStatic()) continue next; + + if (this.options.checkVisibility + && !method.canBeSeenBy(receiverType, invocationSite, scope)) continue next; + + if (methodLength > method.selector.length) continue next; + + if (!CharOperation.prefixEquals(methodName, method.selector, false /* ignore case */) + && !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(methodName, method.selector))) { + continue next; + } + + for (int i = methodsFound.size; --i >= 0;) { + Object[] other = (Object[]) methodsFound.elementAt(i); + MethodBinding otherMethod = (MethodBinding) other[0]; + + if (method == otherMethod) continue next; + } + + methodsFound.add(new Object[]{method, receiverType}); + + ReferenceBinding superTypeWithSameErasure = (ReferenceBinding)receiverType.findSuperTypeWithSameErasure(method.declaringClass); + if (method.declaringClass != superTypeWithSameErasure) { + MethodBinding[] otherMethods = superTypeWithSameErasure.getMethods(method.selector); + for (int i = 0; i < otherMethods.length; i++) { + if(otherMethods[i].original() == method.original()) { + method = otherMethods[i]; + } + } + } + + int length = method.parameters.length; + char[][] parameterPackageNames = new char[length][]; + char[][] parameterTypeNames = new char[length][]; + + for (int i = 0; i < length; i++) { + TypeBinding type = method.original().parameters[i]; + parameterPackageNames[i] = type.qualifiedPackageName(); + parameterTypeNames[i] = type.qualifiedSourceName(); + } + char[][] parameterNames = findMethodParameterNames(method,parameterTypeNames); + + char[] completion = CharOperation.NO_CHAR; + + int previousStartPosition = this.startPosition; + + if (this.source != null + && this.source.length > this.endPosition + && this.source[this.endPosition] == '(') { + completion = method.selector; + } else { + completion = CharOperation.concat(method.selector, new char[] { '(', ')' }); + } + + completion = CharOperation.concat(typeName, completion, '.'); + + int relevance = computeBaseRelevance(); + relevance += computeRelevanceForInterestingProposal(); + if (methodName != null) relevance += computeRelevanceForCaseMatching(methodName, method.selector); + relevance += computeRelevanceForExpectingType(method.returnType); + relevance += computeRelevanceForStatic(true, method.isStatic()); + relevance += computeRelevanceForQualification(true); + relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); + + + this.noProposal = false; + // Standard proposal + if(!this.isIgnored(CompletionProposal.METHOD_REF)) { + CompletionProposal proposal = this.createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); + proposal.setDeclarationSignature(getSignature(method.declaringClass)); + proposal.setSignature(getSignature(method)); + MethodBinding original = method.original(); + if(original != method) { + proposal.setOriginalSignature(getSignature(original)); + } + proposal.setDeclarationPackageName(method.declaringClass.qualifiedPackageName()); + proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName()); + proposal.setParameterPackageNames(parameterPackageNames); + proposal.setParameterTypeNames(parameterTypeNames); + proposal.setPackageName(method.returnType.qualifiedPackageName()); + proposal.setTypeName(method.returnType.qualifiedSourceName()); + proposal.setName(method.selector); + proposal.setCompletion(completion); + proposal.setFlags(method.modifiers); + proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); + proposal.setRelevance(relevance); + if(parameterNames != null) proposal.setParameterNames(parameterNames); + this.requestor.accept(proposal); + if(DEBUG) { + this.printDebug(proposal); + } + } + + this.startPosition = previousStartPosition; + } + } + private CompletionProposal createRequiredTypeProposal(Binding binding, int start, int end, int relevance) { CompletionProposal proposal = null; if (binding instanceof ReferenceBinding) { @@ -4525,8 +4801,11 @@ char[] methodName, MethodBinding[] methods, Scope scope, + ObjectVector methodsFound, ReferenceBinding receiverType, InvocationSite invocationSite) { + + ObjectVector newMethodsFound = new ObjectVector(); next : for (int f = methods.length; --f >= 0;) { MethodBinding method = methods[f]; @@ -4550,6 +4829,22 @@ if (!CharOperation.equals(methodName, method.selector, false /* ignore case */) && !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(methodName, method.selector))) continue next; + + for (int i = methodsFound.size; --i >= 0;) { + Object[] other = (Object[]) methodsFound.elementAt(i); + MethodBinding otherMethod = (MethodBinding) other[0]; + ReferenceBinding otherReceiverType = (ReferenceBinding) other[1]; + if (method == otherMethod && receiverType == otherReceiverType) + continue next; + + if (CharOperation.equals(method.selector, otherMethod.selector, true)) { + if (lookupEnvironment.methodVerifier().doesMethodOverride(otherMethod, method)) { + continue next; + } + } + } + + newMethodsFound.add(new Object[]{method, receiverType}); int length = method.parameters.length; char[][] parameterPackageNames = new char[length][]; @@ -4611,6 +4906,8 @@ } this.startPosition = previousStartPosition; } + + methodsFound.addAll(newMethodsFound); } int computeRelevanceForCaseMatching(char[] token, char[] proposalName){ if (this.options.camelCaseMatch) { @@ -5103,6 +5400,10 @@ (missingTypes && !this.requestor.isAllowingRequiredProposals(kind, CompletionProposal.TYPE_REF)); } + private boolean isIgnored(int kind) { + return this.requestor.isIgnored(kind); + } + private void findMethods( char[] selector, TypeBinding[] typeArgTypes, @@ -6173,6 +6474,7 @@ currentScope = currentScope.parent; } + // search in static import ImportBinding[] importBindings = scope.compilationUnitScope().imports; for (int i = 0; i < importBindings.length; i++) { ImportBinding importBinding = importBindings[i]; @@ -6249,6 +6551,7 @@ methodBinding.selector, methodBinding.declaringClass.methods(), scope, + methodsFound, methodBinding.declaringClass, invocationSite); } @@ -6257,6 +6560,18 @@ } } } + + 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) { @@ -6495,6 +6810,76 @@ }*/ } + private ImportBinding[] getFavoriteReferenceBindings(Scope scope) { + if (this.favoriteReferenceBindings != null) return this.favoriteReferenceBindings; + + String[] favoriteReferences = this.requestor.getFavoriteReferences(); + + if (favoriteReferences == null || favoriteReferences.length == 0) return null; + + ImportBinding[] resolvedImports = new ImportBinding[favoriteReferences.length]; + + int count = 0; + next : for (int i = 0; i < favoriteReferences.length; i++) { + String favoriteReference = favoriteReferences[i]; + + int length; + if (favoriteReference == null || (length = favoriteReference.length()) == 0) continue next; + + boolean onDemand = favoriteReference.charAt(length - 1) == '*'; + + char[][] compoundName = CharOperation.splitOn('.', favoriteReference.toCharArray()); + if (onDemand) { + compoundName = CharOperation.subarray(compoundName, 0, compoundName.length - 1); + } + + // remove duplicate and conflicting + for (int j = 0; j < count; j++) { + ImportReference f = resolvedImports[j].reference; + + if (CharOperation.equals(f.tokens, compoundName)) continue next; + + if (!onDemand && !f.onDemand) { + if (CharOperation.equals(f.tokens[f.tokens.length - 1], compoundName[compoundName.length - 1])) + continue next; + } + } + + boolean isStatic = this.compilerOptions.sourceLevel > ClassFileConstants.JDK1_4; + + ImportReference importReference = + new ImportReference( + compoundName, + new long[compoundName.length], + onDemand, + isStatic ? ClassFileConstants.AccStatic : ClassFileConstants.AccDefault); + + Binding importBinding = this.unitScope.findImport(compoundName, isStatic, onDemand); + + if (!importBinding.isValidBinding()) { + continue next; + } + + if (onDemand) { + if (importReference.isStatic() && importBinding instanceof PackageBinding) { + importReference.modifiers = importReference.modifiers & ~ClassFileConstants.AccStatic; + } + } else { + if (importBinding instanceof PackageBinding) { + continue next; + } + } + + resolvedImports[count++] = + new ImportBinding(compoundName, onDemand, importBinding, importReference); + } + + if (resolvedImports.length > count) + System.arraycopy(resolvedImports, 0, resolvedImports = new ImportBinding[count], 0, count); + + return this.favoriteReferenceBindings = resolvedImports; + } + public AssistParser getParser() { return this.parser; #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.137 diff -u -r1.137 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 24 Nov 2006 11:31:14 -0000 1.137 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 8 Dec 2006 14:44:35 -0000 @@ -13343,4 +13343,514 @@ "zzzzzz[FIELD_REF]{zzzzzz, Ltest.Test;, I, zzzzzz, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", requestor.getResults()); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports001() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo;\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[FIELD_REF]{test.p.ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports002() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports003() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo;\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports004() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports005() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo;\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports006() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports007() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "import test.p.ZZZ.*;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports009() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "import test.p.ZZZ.*;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports011() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "import test.p.ZZZ.foo;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports013() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "import test.p.ZZZ.foo;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports016() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public class foo {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" + + "Test.foo[TYPE_REF]{foo, test, Ltest.Test$foo;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports017() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void foo() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" + + "foo[METHOD_REF]{foo(), Ltest.Test;, ()V, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports018() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public int foo;\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" + + "foo[FIELD_REF]{foo, Ltest.Test;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports019() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " int foo = 0;\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" + + "foo[LOCAL_VARIABLE_REF]{foo, null, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports020() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + " public static int foo(int i){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" + + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, (I)I, foo, (i), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports022() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo();\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo("; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} } 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.78 diff -u -r1.78 CompletionTests_1_5.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 6 Dec 2006 14:28:43 -0000 1.78 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 8 Dec 2006 14:44:38 -0000 @@ -9425,4 +9425,713 @@ "Test[TYPE_REF]{, test, Ltest.Test;, null, null, ["+startOffset+", "+endOffset+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", requestor.getResults()); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports001() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo;\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[FIELD_REF]{test.p.ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports002() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports003() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo;\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports004() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports005() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo;\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[FIELD_REF]{test.p.ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports006() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports007() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "import test.p.ZZZ.*;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports008() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "import static test.p.ZZZ.*;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED +R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports009() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "import test.p.ZZZ.*;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports010() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "import static test.p.ZZZ.*;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports011() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "import test.p.ZZZ.foo;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports012() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "import static test.p.ZZZ.foo;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports013() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "import test.p.ZZZ.foo;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports014() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "import static test.p.ZZZ.foo;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports015() throws JavaModelException { + this.workingCopies = new ICompilationUnit[3]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "import static test.p.ZZZ.foo;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + this.workingCopies[2] = getWorkingCopy( + "/Completion/src3/test/q/ZZZ2.java", + "package test.q;\n" + + "public class ZZZ2 {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.q.ZZZ2.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.q.ZZZ2.foo(), Ltest.q.ZZZ2;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" + + "foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports016() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public class foo {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" + + "Test.foo[TYPE_REF]{foo, test, Ltest.Test$foo;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports017() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void foo() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" + + "foo[METHOD_REF]{foo(), Ltest.Test;, ()V, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports018() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public int foo;\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" + + "foo[FIELD_REF]{foo, Ltest.Test;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports019() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " int foo = 0;\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" + + "foo[LOCAL_VARIABLE_REF]{foo, null, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports020() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + " public static int foo(int i){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" + + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, (I)I, foo, (i), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports021() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}", + requestor.getResults()); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123 +public void testFavoriteImports022() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src3/test/Test.java", + "package test;\n" + + "public class Test {\n" + + " public void method() {\n" + + " foo();\n" + + " }\n" + + "}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/test/p/ZZZ.java", + "package test.p;\n" + + "public class ZZZ {\n" + + " public static int foo(){}\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"}); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "foo("; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} }