View | Details | Raw Unified | Return to bug 151500 | Differences between
and this patch

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java (-3 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
2
 * Copyright (c) 2004, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Andreas Magnusson <andreas.ch.magnusson@gmail.com>- contribution for bug 151500
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.codeassist;
12
package org.eclipse.jdt.internal.codeassist;
12
13
Lines 194-200 Link Here
194
			}
195
			}
195
		} else {
196
		} else {
196
			// TODO (david) shouldn't it be NameLookup.ACCEPT_ALL ?
197
			// TODO (david) shouldn't it be NameLookup.ACCEPT_ALL ?
197
			NameLookup.Answer answer = this.nameLookup.findType(new String(tName),
198
			NameLookup.Answer answer = this.nameLookup.findType(new String(declaringTypeName),
199
				new String(declaringTypePackageName),
198
				false,
200
				false,
199
				NameLookup.ACCEPT_CLASSES & NameLookup.ACCEPT_INTERFACES,
201
				NameLookup.ACCEPT_CLASSES & NameLookup.ACCEPT_INTERFACES,
200
				true/* consider secondary types */,
202
				true/* consider secondary types */,
Lines 249-254 Link Here
249
					char[][] argumentNames = info.getArgumentNames();
251
					char[][] argumentNames = info.getArgumentNames();
250
					if (argumentNames != null && argumentNames.length == length) {
252
					if (argumentNames != null && argumentNames.length == length) {
251
						parameters = argumentNames;
253
						parameters = argumentNames;
254
						return parameters;
252
					}
255
					}
253
				} catch(JavaModelException e){
256
				} catch(JavaModelException e){
254
					//parameters == null;
257
					//parameters == null;
Lines 290-296 Link Here
290
			}
293
			}
291
		} else {
294
		} else {
292
			// TODO (david) shouldn't it be NameLookup.ACCEPT_ALL ?
295
			// TODO (david) shouldn't it be NameLookup.ACCEPT_ALL ?
293
			NameLookup.Answer answer = this.nameLookup.findType(new String(tName),
296
			NameLookup.Answer answer = this.nameLookup.findType(new String(declaringTypeName),
297
				new String(declaringTypePackageName),
294
				false,
298
				false,
295
				NameLookup.ACCEPT_CLASSES & NameLookup.ACCEPT_INTERFACES,
299
				NameLookup.ACCEPT_CLASSES & NameLookup.ACCEPT_INTERFACES,
296
				true/* consider secondary types */,
300
				true/* consider secondary types */,
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests2.java (-3 / +181 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 18-23 Link Here
18
import java.util.Map;
18
import java.util.Map;
19
import java.util.StringTokenizer;
19
import java.util.StringTokenizer;
20
20
21
import junit.framework.ComparisonFailure;
22
import junit.framework.Test;
23
21
import org.eclipse.core.resources.IFile;
24
import org.eclipse.core.resources.IFile;
22
import org.eclipse.core.resources.IProject;
25
import org.eclipse.core.resources.IProject;
23
import org.eclipse.core.resources.IResource;
26
import org.eclipse.core.resources.IResource;
Lines 41-48 Link Here
41
import org.eclipse.jdt.internal.core.JavaModelManager;
44
import org.eclipse.jdt.internal.core.JavaModelManager;
42
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
45
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
43
46
44
import junit.framework.*;
45
46
public class CompletionTests2 extends ModifyingResourceTests implements RelevanceConstants {
47
public class CompletionTests2 extends ModifyingResourceTests implements RelevanceConstants {
47
48
48
	public static class CompletionContainerInitializer implements ContainerInitializer.ITestInitializer {
49
	public static class CompletionContainerInitializer implements ContainerInitializer.ITestInitializer {
Lines 5284-5287 Link Here
5284
		deleteProject("P");
5285
		deleteProject("P");
5285
	}
5286
	}
5286
}
5287
}
5288
5289
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=151500
5290
public void testBug151500a() throws Exception {
5291
	try {
5292
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib151500.jar"}, "bin", "1.4");
5293
		createJar(
5294
				new String[] {
5295
						"foo/Foo.java",
5296
						"package foo;\n" +
5297
						"public class Foo {\n"+
5298
						"  public Foo(int p1) {}\n"+
5299
						"  public Bar bar = new Bar(1,2);\n"+
5300
						"  public class Bar {\n" +
5301
						"    int param1;\n" +
5302
						"	 int param2;\n" +
5303
						"	 public Bar (int a, int b) {\n" +
5304
						"		param1 = a;\n" +
5305
						"		param2 = b;\n" +
5306
						"	 }\n" +
5307
						"	 public void someMethod(String paramName) {}\n"+
5308
						"  }\n"+
5309
						"}"
5310
				},
5311
				p.getProject().getLocation().append("lib151500.jar").toOSString(),
5312
				new String[]{getExternalJCLPathString("1.3")},
5313
				"1.3");
5314
		
5315
		refresh(p);
5316
		
5317
		waitUntilIndexesReady();
5318
		
5319
		this.workingCopies = new ICompilationUnit[1];
5320
		this.workingCopies[0] = getWorkingCopy(
5321
				"/P/src/test/Test.java",
5322
				"package test;\n"+
5323
				"public class Test {\n" +
5324
				"  void m() {\n" +
5325
				"    foo.Foo f = new Foo(1);\n" +
5326
				"	 f.bar.s\n" +
5327
				"  }\n" +
5328
				"}");
5329
5330
		// do completion
5331
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
5332
		requestor.allowAllRequiredProposals();
5333
		NullProgressMonitor monitor = new NullProgressMonitor();
5334
5335
	    String str = this.workingCopies[0].getSource();
5336
	    String completeBehind = "f.bar.s";
5337
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5338
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
5339
	    
5340
	    assertResults(
5341
			"someMethod[METHOD_REF]{someMethod(), Lfoo.Foo$Bar;, (Ljava.lang.String;)V, someMethod, (paramName), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_NON_STATIC)+ "}",
5342
			requestor.getResults());
5343
	} finally {
5344
		deleteProject("P");
5345
	}
5346
}
5347
5348
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=151500
5349
public void testBug151500b() throws Exception {	
5350
	try {
5351
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib151500.jar"}, "bin", "1.4");
5352
		createJar(
5353
				new String[] {
5354
						"foo/Foo.java",
5355
						"package foo;\n" +
5356
						"public class Foo {\n"+
5357
						"  public Foo(int p1) {}\n"+
5358
						"  public Bar bar = new Bar(1,2);\n"+
5359
						"  public class Bar {\n" +
5360
						"    int param1;\n" +
5361
						"	 int param2;\n" +
5362
						"	 public Bar (int a, int b) {\n" +
5363
						"		param1 = a;\n" +
5364
						"		param2 = b;\n" +
5365
						"	 }\n" +
5366
						"	 public void someMethod(String paramName) {}\n"+
5367
						"  }\n"+
5368
						"}"
5369
				},
5370
				p.getProject().getLocation().append("lib151500.jar").toOSString(),
5371
				new String[]{getExternalJCLPathString("1.3")},
5372
				"1.3");
5373
		
5374
		refresh(p);
5375
		
5376
		waitUntilIndexesReady();
5377
		
5378
		this.workingCopies = new ICompilationUnit[1];
5379
		this.workingCopies[0] = getWorkingCopy(
5380
				"/P/src/test/Test.java",
5381
				"package test;\n"+
5382
				"public class Test {\n" +
5383
				"  void m() {\n" +
5384
				"    new foo.Foo(1).new B;\n" +
5385
				"  }\n" +
5386
				"}");
5387
5388
		// do completion
5389
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
5390
		requestor.allowAllRequiredProposals();
5391
		NullProgressMonitor monitor = new NullProgressMonitor();
5392
5393
	    String str = this.workingCopies[0].getSource();
5394
	    String completeBehind = "new foo.Foo(1).new B";
5395
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5396
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
5397
	    
5398
	    assertResults(
5399
	    		"Bar[CONSTRUCTOR_INVOCATION]{(), Lfoo.Foo$Bar;, (II)V, Bar, (a, b), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}\n" +
5400
	    		"   Foo.Bar[TYPE_REF]{Bar, foo, Lfoo.Foo$Bar;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_UNQUALIFIED) + "}",
5401
			requestor.getResults());
5402
	} finally {
5403
		deleteProject("P");
5404
	}
5405
}
5406
5407
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=151500
5408
public void testBug151500c() throws Exception {	
5409
	try {
5410
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib151500.jar"}, "bin", "1.4");
5411
		createJar(
5412
				new String[] {
5413
						"foo/Foo.java",
5414
						"package foo;\n" +
5415
						"public class Foo {\n"+
5416
						"  public Foo(int p1) {}\n"+
5417
						"  public Bar bar = new Bar(1,2);\n"+
5418
						"  public class Bar {\n" +
5419
						"    int param1;\n" +
5420
						"	 int param2;\n" +
5421
						"	 public Bar (int a, int b) {\n" +
5422
						"		param1 = a;\n" +
5423
						"		param2 = b;\n" +
5424
						"	 }\n" +
5425
						"	 public void someMethod(String paramName) {}\n"+
5426
						"  }\n"+
5427
						"}"
5428
				},
5429
				p.getProject().getLocation().append("lib151500.jar").toOSString(),
5430
				new String[]{getExternalJCLPathString("1.3")},
5431
				"1.3");
5432
		
5433
		refresh(p);
5434
		
5435
		waitUntilIndexesReady();
5436
		
5437
		this.workingCopies = new ICompilationUnit[1];
5438
		this.workingCopies[0] = getWorkingCopy(
5439
				"/P/src/test/Test.java",
5440
				"package test;\n"+
5441
				"public class Test {\n" +
5442
				"  void m() {\n" +
5443
				"    new foo.Foo.B;\n" +
5444
				"  }\n" +
5445
				"}");
5446
5447
		// do completion
5448
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
5449
		requestor.allowAllRequiredProposals();
5450
		NullProgressMonitor monitor = new NullProgressMonitor();
5451
5452
	    String str = this.workingCopies[0].getSource();
5453
	    String completeBehind = "new foo.Foo.B";
5454
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5455
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
5456
	    
5457
	    assertResults(
5458
	    		"Bar[CONSTRUCTOR_INVOCATION]{(), Lfoo.Foo$Bar;, (II)V, Bar, (a, b), " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
5459
	    		"   Foo.Bar[TYPE_REF]{Bar, foo, Lfoo.Foo$Bar;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}",
5460
			requestor.getResults());
5461
	} finally {
5462
		deleteProject("P");
5463
	}
5464
}
5287
}
5465
}

Return to bug 151500