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 / +190 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
		
5294
		createFolder("/P/src/p151500");
5295
		
5296
		createJar(
5297
				new String[] {
5298
						"foo/Foo.java",
5299
						"package foo;\n" +
5300
						"public class Foo {\n"+
5301
						"  public Foo(int p1) {}\n"+
5302
						"  public Bar bar = new Bar(1,2);\n"+
5303
						"  public class Bar {\n" +
5304
						"    int param1;\n" +
5305
						"	 int param2;\n" +
5306
						"	 public Bar (int a, int b) {\n" +
5307
						"		param1 = a;\n" +
5308
						"		param2 = b;\n" +
5309
						"	 }\n" +
5310
						"	 public void someMethod(String paramName) {}\n"+
5311
						"  }\n"+
5312
						"}"
5313
				},
5314
				p.getProject().getLocation().append("lib151500.jar").toOSString(),
5315
				new String[]{getExternalJCLPathString("1.3")},
5316
				"1.3");
5317
		
5318
		refresh(p);
5319
		
5320
		waitUntilIndexesReady();
5321
		
5322
		this.workingCopies = new ICompilationUnit[1];
5323
		this.workingCopies[0] = getWorkingCopy(
5324
				"/P/src/test/Test.java",
5325
				"package test;\n"+
5326
				"public class Test {\n" +
5327
				"  void m() {\n" +
5328
				"    foo.Foo f = new Foo(1);\n" +
5329
				"	 f.bar.s\n" +
5330
				"  }\n" +
5331
				"}");
5332
5333
		// do completion
5334
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
5335
		requestor.allowAllRequiredProposals();
5336
		NullProgressMonitor monitor = new NullProgressMonitor();
5337
5338
	    String str = this.workingCopies[0].getSource();
5339
	    String completeBehind = "f.bar.s";
5340
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5341
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
5342
	    
5343
	    assertResults(
5344
			"someMethod[METHOD_REF]{someMethod(), Lfoo.Foo$Bar;, (Ljava.lang.String;)V, someMethod, (paramName), 35}",
5345
			requestor.getResults());
5346
	} finally {
5347
		deleteProject("P");
5348
	}
5349
}
5350
5351
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=151500
5352
public void testBug151500b() throws Exception {	
5353
	try {
5354
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib151500.jar"}, "bin", "1.4");
5355
		
5356
		createFolder("/P/src/p151500");
5357
		
5358
		createJar(
5359
				new String[] {
5360
						"foo/Foo.java",
5361
						"package foo;\n" +
5362
						"public class Foo {\n"+
5363
						"  public Foo(int p1) {}\n"+
5364
						"  public Bar bar = new Bar(1,2);\n"+
5365
						"  public class Bar {\n" +
5366
						"    int param1;\n" +
5367
						"	 int param2;\n" +
5368
						"	 public Bar (int a, int b) {\n" +
5369
						"		param1 = a;\n" +
5370
						"		param2 = b;\n" +
5371
						"	 }\n" +
5372
						"	 public void someMethod(String paramName) {}\n"+
5373
						"  }\n"+
5374
						"}"
5375
				},
5376
				p.getProject().getLocation().append("lib151500.jar").toOSString(),
5377
				new String[]{getExternalJCLPathString("1.3")},
5378
				"1.3");
5379
		
5380
		refresh(p);
5381
		
5382
		waitUntilIndexesReady();
5383
		
5384
		this.workingCopies = new ICompilationUnit[1];
5385
		this.workingCopies[0] = getWorkingCopy(
5386
				"/P/src/test/Test.java",
5387
				"package test;\n"+
5388
				"public class Test {\n" +
5389
				"  void m() {\n" +
5390
				"    new foo.Foo(1).new B;\n" +
5391
				"  }\n" +
5392
				"}");
5393
5394
		// do completion
5395
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
5396
		requestor.allowAllRequiredProposals();
5397
		NullProgressMonitor monitor = new NullProgressMonitor();
5398
5399
	    String str = this.workingCopies[0].getSource();
5400
	    String completeBehind = "new foo.Foo(1).new B";
5401
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5402
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
5403
	    
5404
	    assertResults(
5405
	    		"Bar[CONSTRUCTOR_INVOCATION]{(), Lfoo.Foo$Bar;, (II)V, Bar, (a, b), 27}\n" +
5406
	    		"   Foo.Bar[TYPE_REF]{Bar, foo, Lfoo.Foo$Bar;, null, null, 27}",
5407
			requestor.getResults());
5408
	} finally {
5409
		deleteProject("P");
5410
	}
5411
}
5412
5413
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=151500
5414
public void testBug151500c() throws Exception {	
5415
	try {
5416
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL15_LIB", "/P/lib151500.jar"}, "bin", "1.4");
5417
		
5418
		createFolder("/P/src/p151500");
5419
		
5420
		createJar(
5421
				new String[] {
5422
						"foo/Foo.java",
5423
						"package foo;\n" +
5424
						"public class Foo {\n"+
5425
						"  public Foo(int p1) {}\n"+
5426
						"  public Bar bar = new Bar(1,2);\n"+
5427
						"  public class Bar {\n" +
5428
						"    int param1;\n" +
5429
						"	 int param2;\n" +
5430
						"	 public Bar (int a, int b) {\n" +
5431
						"		param1 = a;\n" +
5432
						"		param2 = b;\n" +
5433
						"	 }\n" +
5434
						"	 public void someMethod(String paramName) {}\n"+
5435
						"  }\n"+
5436
						"}"
5437
				},
5438
				p.getProject().getLocation().append("lib151500.jar").toOSString(),
5439
				new String[]{getExternalJCLPathString("1.3")},
5440
				"1.3");
5441
		
5442
		refresh(p);
5443
		
5444
		waitUntilIndexesReady();
5445
		
5446
		this.workingCopies = new ICompilationUnit[1];
5447
		this.workingCopies[0] = getWorkingCopy(
5448
				"/P/src/test/Test.java",
5449
				"package test;\n"+
5450
				"public class Test {\n" +
5451
				"  void m() {\n" +
5452
				"    new foo.Foo.B;\n" +
5453
				"  }\n" +
5454
				"}");
5455
5456
		// do completion
5457
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
5458
		requestor.allowAllRequiredProposals();
5459
		NullProgressMonitor monitor = new NullProgressMonitor();
5460
5461
	    String str = this.workingCopies[0].getSource();
5462
	    String completeBehind = "new foo.Foo.B";
5463
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5464
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
5465
	    
5466
	    assertResults(
5467
	    		"Bar[CONSTRUCTOR_INVOCATION]{(), Lfoo.Foo$Bar;, (II)V, Bar, (a, b), 24}\n" +
5468
	    		"   Foo.Bar[TYPE_REF]{Bar, foo, Lfoo.Foo$Bar;, null, null, 24}",
5469
			requestor.getResults());
5470
	} finally {
5471
		deleteProject("P");
5472
	}
5473
}
5287
}
5474
}

Return to bug 151500