### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java,v retrieving revision 1.15 diff -u -r1.15 InternalCompletionProposal.java --- codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java 28 Jun 2010 13:07:11 -0000 1.15 +++ codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java 5 Jul 2010 07:48:51 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Andreas Magnusson - contribution for bug 151500 *******************************************************************************/ package org.eclipse.jdt.internal.codeassist; @@ -194,7 +195,8 @@ } } else { // TODO (david) shouldn't it be NameLookup.ACCEPT_ALL ? - NameLookup.Answer answer = this.nameLookup.findType(new String(tName), + NameLookup.Answer answer = this.nameLookup.findType(new String(declaringTypeName), + new String(declaringTypePackageName), false, NameLookup.ACCEPT_CLASSES & NameLookup.ACCEPT_INTERFACES, true/* consider secondary types */, @@ -249,6 +251,7 @@ char[][] argumentNames = info.getArgumentNames(); if (argumentNames != null && argumentNames.length == length) { parameters = argumentNames; + return parameters; } } catch(JavaModelException e){ //parameters == null; @@ -290,7 +293,8 @@ } } else { // TODO (david) shouldn't it be NameLookup.ACCEPT_ALL ? - NameLookup.Answer answer = this.nameLookup.findType(new String(tName), + NameLookup.Answer answer = this.nameLookup.findType(new String(declaringTypeName), + new String(declaringTypePackageName), false, NameLookup.ACCEPT_CLASSES & NameLookup.ACCEPT_INTERFACES, true/* consider secondary types */, #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/CompletionTests2.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests2.java,v retrieving revision 1.48 diff -u -r1.48 CompletionTests2.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests2.java 9 Jul 2009 10:31:22 -0000 1.48 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests2.java 5 Jul 2010 07:49:10 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,6 +18,9 @@ import java.util.Map; import java.util.StringTokenizer; +import junit.framework.ComparisonFailure; +import junit.framework.Test; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -41,8 +44,6 @@ import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.internal.core.search.indexing.IndexManager; -import junit.framework.*; - public class CompletionTests2 extends ModifyingResourceTests implements RelevanceConstants { public static class CompletionContainerInitializer implements ContainerInitializer.ITestInitializer { @@ -5284,4 +5285,190 @@ deleteProject("P"); } } + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=151500 +public void testBug151500a() throws Exception { + try { + IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib151500.jar"}, "bin", "1.4"); + + createFolder("/P/src/p151500"); + + createJar( + new String[] { + "foo/Foo.java", + "package foo;\n" + + "public class Foo {\n"+ + " public Foo(int p1) {}\n"+ + " public Bar bar = new Bar(1,2);\n"+ + " public class Bar {\n" + + " int param1;\n" + + " int param2;\n" + + " public Bar (int a, int b) {\n" + + " param1 = a;\n" + + " param2 = b;\n" + + " }\n" + + " public void someMethod(String paramName) {}\n"+ + " }\n"+ + "}" + }, + p.getProject().getLocation().append("lib151500.jar").toOSString(), + new String[]{getExternalJCLPathString("1.3")}, + "1.3"); + + refresh(p); + + waitUntilIndexesReady(); + + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/P/src/test/Test.java", + "package test;\n"+ + "public class Test {\n" + + " void m() {\n" + + " foo.Foo f = new Foo(1);\n" + + " f.bar.s\n" + + " }\n" + + "}"); + + // do completion + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true); + requestor.allowAllRequiredProposals(); + NullProgressMonitor monitor = new NullProgressMonitor(); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "f.bar.s"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); + + assertResults( + "someMethod[METHOD_REF]{someMethod(), Lfoo.Foo$Bar;, (Ljava.lang.String;)V, someMethod, (paramName), 35}", + requestor.getResults()); + } finally { + deleteProject("P"); + } +} + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=151500 +public void testBug151500b() throws Exception { + try { + IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib151500.jar"}, "bin", "1.4"); + + createFolder("/P/src/p151500"); + + createJar( + new String[] { + "foo/Foo.java", + "package foo;\n" + + "public class Foo {\n"+ + " public Foo(int p1) {}\n"+ + " public Bar bar = new Bar(1,2);\n"+ + " public class Bar {\n" + + " int param1;\n" + + " int param2;\n" + + " public Bar (int a, int b) {\n" + + " param1 = a;\n" + + " param2 = b;\n" + + " }\n" + + " public void someMethod(String paramName) {}\n"+ + " }\n"+ + "}" + }, + p.getProject().getLocation().append("lib151500.jar").toOSString(), + new String[]{getExternalJCLPathString("1.3")}, + "1.3"); + + refresh(p); + + waitUntilIndexesReady(); + + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/P/src/test/Test.java", + "package test;\n"+ + "public class Test {\n" + + " void m() {\n" + + " new foo.Foo(1).new B;\n" + + " }\n" + + "}"); + + // do completion + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true); + requestor.allowAllRequiredProposals(); + NullProgressMonitor monitor = new NullProgressMonitor(); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "new foo.Foo(1).new B"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); + + assertResults( + "Bar[CONSTRUCTOR_INVOCATION]{(), Lfoo.Foo$Bar;, (II)V, Bar, (a, b), 27}\n" + + " Foo.Bar[TYPE_REF]{Bar, foo, Lfoo.Foo$Bar;, null, null, 27}", + requestor.getResults()); + } finally { + deleteProject("P"); + } +} + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=151500 +public void testBug151500c() throws Exception { + try { + IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib151500.jar"}, "bin", "1.4"); + + createFolder("/P/src/p151500"); + + createJar( + new String[] { + "foo/Foo.java", + "package foo;\n" + + "public class Foo {\n"+ + " public Foo(int p1) {}\n"+ + " public Bar bar = new Bar(1,2);\n"+ + " public class Bar {\n" + + " int param1;\n" + + " int param2;\n" + + " public Bar (int a, int b) {\n" + + " param1 = a;\n" + + " param2 = b;\n" + + " }\n" + + " public void someMethod(String paramName) {}\n"+ + " }\n"+ + "}" + }, + p.getProject().getLocation().append("lib151500.jar").toOSString(), + new String[]{getExternalJCLPathString("1.3")}, + "1.3"); + + refresh(p); + + waitUntilIndexesReady(); + + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/P/src/test/Test.java", + "package test;\n"+ + "public class Test {\n" + + " void m() {\n" + + " new foo.Foo.B;\n" + + " }\n" + + "}"); + + // do completion + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true); + requestor.allowAllRequiredProposals(); + NullProgressMonitor monitor = new NullProgressMonitor(); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "new foo.Foo.B"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor); + + assertResults( + "Bar[CONSTRUCTOR_INVOCATION]{(), Lfoo.Foo$Bar;, (II)V, Bar, (a, b), 24}\n" + + " Foo.Bar[TYPE_REF]{Bar, foo, Lfoo.Foo$Bar;, null, null, 24}", + requestor.getResults()); + } finally { + deleteProject("P"); + } +} }