### Eclipse Workspace Patch 1.0 #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.164 diff -u -r1.164 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 4 Jul 2007 08:08:48 -0000 1.164 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 11 Jul 2007 08:40:51 -0000 @@ -3738,7 +3738,7 @@ assertResults( "pack1.pack3[PACKAGE_REF]{pack1.pack3.*;, pack1.pack3, null, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_NON_RESTRICTED)+"}\n"+ - "PX[TYPE_REF]{pack1.PX;, pack1, Lpack1.PX;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}", + "PX[TYPE_REF]{PX;, pack1, Lpack1.PX;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}", 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.91 diff -u -r1.91 CompletionTests_1_5.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 4 Jul 2007 08:08:48 -0000 1.91 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 11 Jul 2007 08:40:53 -0000 @@ -1973,7 +1973,7 @@ result.context); assertResults( - "ImportedClass[TYPE_REF]{test0071.p.ImportedClass., test0071.p, Ltest0071.p.ImportedClass;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + "ImportedClass[TYPE_REF]{ImportedClass., test0071.p, Ltest0071.p.ImportedClass;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", result.proposals); } finally { if(importedClass != null) { @@ -2005,16 +2005,13 @@ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); cu.codeComplete(cursorLocation, requestor, this.wcOwner); - int end1 = cursorLocation; - int start1 = end1 - "ZZ".length(); - - int end2 = cursorLocation; - int start2 = end2 - "test0072.p.ImportedClass.ZZ".length(); + int end = cursorLocation; + int start = end - "ZZ".length(); assertResults( - "ZZZ1[FIELD_REF]{ZZZ1;, Ltest0072.p.ImportedClass;, I, ZZZ1, null, ["+start1+", "+end1+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + - "ZZZ2[METHOD_IMPORT]{test0072.p.ImportedClass.ZZZ2;, Ltest0072.p.ImportedClass;, ()V, ZZZ2, null, ["+start2+", "+end2+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + - "ZZZ2[METHOD_IMPORT]{test0072.p.ImportedClass.ZZZ2;, Ltest0072.p.ImportedClass;, (I)V, ZZZ2, (i), ["+start2+", "+end2+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + "ZZZ1[FIELD_REF]{ZZZ1;, Ltest0072.p.ImportedClass;, I, ZZZ1, null, ["+start+", "+end+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + + "ZZZ2[METHOD_IMPORT]{ZZZ2;, Ltest0072.p.ImportedClass;, ()V, ZZZ2, null, ["+start+", "+end+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + + "ZZZ2[METHOD_IMPORT]{ZZZ2;, Ltest0072.p.ImportedClass;, (I)V, ZZZ2, (i), ["+start+", "+end+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", requestor.getResults()); } finally { if(importedClass != null) { @@ -2048,16 +2045,13 @@ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); cu.codeComplete(cursorLocation, requestor, this.wcOwner); - int end1 = cursorLocation; - int start1 = end1 - "ZZ".length(); - - int end2 = cursorLocation; - int start2 = end2 - "test0073.p.ImportedClass.Inner.ZZ".length(); + int end = cursorLocation; + int start = end - "ZZ".length(); assertResults( - "ZZZ1[FIELD_REF]{ZZZ1;, Ltest0073.p.ImportedClass$Inner;, I, ZZZ1, null, ["+start1+", "+end1+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + - "ZZZ2[METHOD_IMPORT]{test0073.p.ImportedClass.Inner.ZZZ2;, Ltest0073.p.ImportedClass$Inner;, ()V, ZZZ2, null, ["+start2+", "+end2+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + - "ZZZ2[METHOD_IMPORT]{test0073.p.ImportedClass.Inner.ZZZ2;, Ltest0073.p.ImportedClass$Inner;, (I)V, ZZZ2, (i), ["+start2+", "+end2+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + "ZZZ1[FIELD_REF]{ZZZ1;, Ltest0073.p.ImportedClass$Inner;, I, ZZZ1, null, ["+start+", "+end+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + + "ZZZ2[METHOD_IMPORT]{ZZZ2;, Ltest0073.p.ImportedClass$Inner;, ()V, ZZZ2, null, ["+start+", "+end+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + + "ZZZ2[METHOD_IMPORT]{ZZZ2;, Ltest0073.p.ImportedClass$Inner;, (I)V, ZZZ2, (i), ["+start+", "+end+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", requestor.getResults()); } finally { if(importedClass != null) { @@ -2091,16 +2085,13 @@ int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); cu.codeComplete(cursorLocation, requestor, this.wcOwner); - int end1 = cursorLocation; - int start1 = end1 - "ZZ".length(); - - int end2 = cursorLocation; - int start2 = end2 - "test0074.p.ImportedClass.Inner.ZZ".length(); + int end = cursorLocation; + int start = end - "ZZ".length(); assertResults( - "ZZZ1[FIELD_REF]{ZZZ1;, Ltest0074.p.ImportedClass$Inner;, I, ZZZ1, null, ["+start1+", "+end1+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + - "ZZZ2[METHOD_IMPORT]{test0074.p.ImportedClass.Inner.ZZZ2;, Ltest0074.p.ImportedClass$Inner;, ()V, ZZZ2, null, ["+start2+", "+end2+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + - "ZZZ2[METHOD_IMPORT]{test0074.p.ImportedClass.Inner.ZZZ2;, Ltest0074.p.ImportedClass$Inner;, (I)V, ZZZ2, (i), ["+start2+", "+end2+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + "ZZZ1[FIELD_REF]{ZZZ1;, Ltest0074.p.ImportedClass$Inner;, I, ZZZ1, null, ["+start+", "+end+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + + "ZZZ2[METHOD_IMPORT]{ZZZ2;, Ltest0074.p.ImportedClass$Inner;, ()V, ZZZ2, null, ["+start+", "+end+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + + "ZZZ2[METHOD_IMPORT]{ZZZ2;, Ltest0074.p.ImportedClass$Inner;, (I)V, ZZZ2, (i), ["+start+", "+end+"], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", requestor.getResults()); } finally { if(importedClass != null) { @@ -6847,7 +6838,7 @@ result.context); assertResults( - "ImportedClass.ImportedMember[TYPE_REF]{test0211.p.ImportedClass.ImportedMember;, test0211.p, Ltest0211.p.ImportedClass$ImportedMember;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + "ImportedClass.ImportedMember[TYPE_REF]{ImportedMember;, test0211.p, Ltest0211.p.ImportedClass$ImportedMember;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", result.proposals); } finally { if(importedClass != null) { @@ -6888,7 +6879,7 @@ result.context); assertResults( - "ImportedClass[TYPE_REF]{test0212.p.ImportedClass;, test0212.p, Ltest0212.p.ImportedClass;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + "ImportedClass[TYPE_REF]{ImportedClass;, test0212.p, Ltest0212.p.ImportedClass;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", result.proposals); } finally { if(importedClass != null) { @@ -6927,7 +6918,7 @@ result.context); assertResults( - "ImportedClass[TYPE_REF]{test0213.p.ImportedClass;, test0213.p, Ltest0213.p.ImportedClass;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + "ImportedClass[TYPE_REF]{ImportedClass;, test0213.p, Ltest0213.p.ImportedClass;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", result.proposals); } finally { if(importedClass != null) { @@ -8044,8 +8035,8 @@ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "oneTwoThree[METHOD_IMPORT]{camelcase.ImportedType.oneTwoThree;, Lcamelcase.ImportedType;, ()V, oneTwoThree, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CAMEL_CASE + R_NON_RESTRICTED) + "}\n" + - "oTTMethod[METHOD_IMPORT]{camelcase.ImportedType.oTTMethod;, Lcamelcase.ImportedType;, ()V, oTTMethod, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + "oneTwoThree[METHOD_IMPORT]{oneTwoThree;, Lcamelcase.ImportedType;, ()V, oneTwoThree, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CAMEL_CASE + R_NON_RESTRICTED) + "}\n" + + "oTTMethod[METHOD_IMPORT]{oTTMethod;, Lcamelcase.ImportedType;, ()V, oTTMethod, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", requestor.getResults()); } finally { JavaCore.setOptions(oldOptions); @@ -10655,8 +10646,8 @@ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "foo1[METHOD_IMPORT]{test0330.q.Y.foo1;, Ltest0330.q.Y;, ()Ltest0330.p.X;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + - "foo2[METHOD_IMPORT]{test0330.q.Y.foo2;, Ltest0330.q.Y;, ()V, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + "foo1[METHOD_IMPORT]{foo1;, Ltest0330.q.Y;, ()Ltest0330.p.X;, foo1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + + "foo2[METHOD_IMPORT]{foo2;, Ltest0330.q.Y;, ()V, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", requestor.getResults()); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=185318 @@ -10676,7 +10667,7 @@ this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "foo2[METHOD_IMPORT]{test0331.q.Y.foo2;, Ltest0331.q.Y;, ()V, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + "foo2[METHOD_IMPORT]{foo2;, Ltest0331.q.Y;, ()V, foo2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", requestor.getResults()); } //https://bugs.eclipse.org/bugs/show_bug.cgi?id=185318 #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v retrieving revision 1.339 diff -u -r1.339 CompletionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 9 Jul 2007 11:03:54 -0000 1.339 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 11 Jul 2007 08:40:57 -0000 @@ -480,29 +480,25 @@ continue next; // import of default package is forbidden when compliance is 1.4 or higher } - char[] completionName; + char[] completionName = this.insideQualifiedReference ? simpleTypeName : fullyQualifiedName; if(this.resolvingStaticImports) { if(enclosingTypeNames == null || enclosingTypeNames.length == 0) { - completionName = CharOperation.concat(fullyQualifiedName, new char[] { '.' }); + completionName = CharOperation.concat(completionName, new char[] { '.' }); } else if ((modifiers & ClassFileConstants.AccStatic) == 0) { continue next; } else { - completionName = CharOperation.concat(fullyQualifiedName, new char[] { ';' }); + completionName = CharOperation.concat(completionName, new char[] { ';' }); } } else { - completionName = CharOperation.concat(fullyQualifiedName, new char[] { ';' }); + completionName = CharOperation.concat(completionName, new char[] { ';' }); } int relevance = computeBaseRelevance(); relevance += computeRelevanceForResolution(); relevance += computeRelevanceForInterestingProposal(); relevance += computeRelevanceForRestrictions(accessibility); - if(insideQualifiedReference) { - relevance += computeRelevanceForCaseMatching(this.completionToken, fullyQualifiedName); - } else { - relevance += computeRelevanceForCaseMatching(this.completionToken, simpleTypeName); - } + relevance += computeRelevanceForCaseMatching(this.completionToken, simpleTypeName); this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { @@ -2017,9 +2013,8 @@ contextAccepted = true; this.buildContext(importReference, null, null, null); - setSourceRange( - importReference.sourceStart, - importReference.declarationSourceEnd); + long positions = importReference.sourcePositions[importReference.sourcePositions.length - 1]; + setSourceRange((int) (positions >>> 32), (int) positions); char[][] oldTokens = importReference.tokens; int tokenCount = oldTokens.length; @@ -2037,15 +2032,14 @@ findImports((CompletionOnImportReference)importReference, false); } else { ReferenceBinding ref = (ReferenceBinding) binding; + if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { this.findImportsOfMemberTypes(lastToken, ref, importReference.isStatic()); } if(importReference.isStatic()) { + if(!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) { - long positions = importReference.sourcePositions[importReference.sourcePositions.length - 1]; - setSourceRange((int) (positions >>> 32), (int) positions); this.findImportsOfStaticFields(lastToken, ref); - setSourceRange(importReference.sourceStart, importReference.declarationSourceEnd); } if(!this.requestor.isIgnored(CompletionProposal.METHOD_NAME_REFERENCE)) { this.findImportsOfStaticMethods(lastToken, ref); @@ -3862,10 +3856,21 @@ this.resolvingImports = true; this.resolvingStaticImports = importReference.isStatic(); - this.completionToken = importName; + this.completionToken = lastToken; + this.qualifiedCompletionToken = importName; + // want to replace the existing .*; if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) { + int oldStart = this.startPosition; + int oldEnd = this.endPosition; + setSourceRange( + importReference.sourceStart, + importReference.declarationSourceEnd); this.nameEnvironment.findPackages(importName, this); + setSourceRange( + oldStart, + oldEnd - 1, + false); } if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { this.nameEnvironment.findTypes( @@ -3903,12 +3908,7 @@ && !memberType.canBeSeenBy(this.unitScope.fPackage)) continue next; - char[] completionName = CharOperation.concat( - memberType.qualifiedPackageName(), - memberType.qualifiedSourceName(), - '.'); - - completionName = CharOperation.concat(completionName, SEMICOLON); + char[] completionName = CharOperation.concat(memberType.sourceName, SEMICOLON); int relevance = computeBaseRelevance(); relevance += computeRelevanceForResolution(); @@ -4023,16 +4023,8 @@ parameterTypeNames[i] = type.qualifiedSourceName(); } char[][] parameterNames = findMethodParameterNames(method,parameterTypeNames); - - - char[] completionName = CharOperation.concat( - method.declaringClass.qualifiedPackageName(), - '.', - method.declaringClass.qualifiedSourceName(), - '.', - method.selector); - completionName = CharOperation.concat(completionName, SEMICOLON); + char[] completionName = CharOperation.concat(method.selector, SEMICOLON); int relevance = computeBaseRelevance(); relevance += computeRelevanceForResolution();