View | Details | Raw Unified | Return to bug 261973
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/CompletionTests2.java (-1 / +130 lines)
Lines 36-41 Link Here
36
import org.eclipse.jdt.core.JavaCore;
36
import org.eclipse.jdt.core.JavaCore;
37
import org.eclipse.jdt.core.tests.util.Util;
37
import org.eclipse.jdt.core.tests.util.Util;
38
import org.eclipse.jdt.internal.codeassist.RelevanceConstants;
38
import org.eclipse.jdt.internal.codeassist.RelevanceConstants;
39
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
39
import org.eclipse.jdt.internal.core.JavaModelManager;
40
import org.eclipse.jdt.internal.core.JavaModelManager;
40
41
41
import junit.framework.*;
42
import junit.framework.*;
Lines 2614-2620 Link Here
2614
	    assertResults(
2615
	    assertResults(
2615
			"AllConstructors33[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors33;, (Lp6930_1.ParamType;Lp6930_2.ParamType;)V, AllConstructors33, (p21, p22), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2616
			"AllConstructors33[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors33;, (Lp6930_1.ParamType;Lp6930_2.ParamType;)V, AllConstructors33, (p21, p22), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2616
			"   AllConstructors33[TYPE_REF]{p6930.AllConstructors33, p6930, Lp6930.AllConstructors33;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2617
			"   AllConstructors33[TYPE_REF]{p6930.AllConstructors33, p6930, Lp6930.AllConstructors33;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2617
			"AllConstructors33[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors33;, (Lp6930_1.ParamType;Lp6930_2.ParamType;)V, AllConstructors33, (p11, p12), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2618
			"AllConstructors33[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors33;, (Lp6930_2.ParamType;Lp6930_2.ParamType;)V, AllConstructors33, (p11, p12), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2618
			"   AllConstructors33[TYPE_REF]{p6930.AllConstructors33, p6930, Lp6930.AllConstructors33;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
2619
			"   AllConstructors33[TYPE_REF]{p6930.AllConstructors33, p6930, Lp6930.AllConstructors33;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
2619
			requestor.getResults());
2620
			requestor.getResults());
2620
	} finally {
2621
	} finally {
Lines 2623-2628 Link Here
2623
		JavaCore.setOptions(oldOptions);
2624
		JavaCore.setOptions(oldOptions);
2624
	}
2625
	}
2625
}
2626
}
2627
public void testBug6930_34() throws Exception {
2628
	Hashtable oldOptions = JavaCore.getOptions();
2629
	
2630
	try {
2631
		Hashtable options = new Hashtable(oldOptions);
2632
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
2633
		JavaCore.setOptions(options);
2634
		
2635
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
2636
		
2637
		Map compileOptions = new HashMap();
2638
		compileOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
2639
	    
2640
		String[] pathsAndContents =
2641
			new String[] {
2642
				"p6930/AllConstructors34.java",
2643
				"package p6930;\n" +
2644
				"public class AllConstructors34 {\n" +
2645
				"  public AllConstructors34(Object o) {}\n" +
2646
				"}"
2647
			};
2648
		createJar(
2649
				pathsAndContents,
2650
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
2651
				compileOptions);
2652
		
2653
		addLibraryEntry(p, "/P/lib6930.jar", null);
2654
		
2655
		refresh(p);
2656
		
2657
		waitUntilIndexesReady();
2658
		
2659
		this.workingCopies = new ICompilationUnit[1];
2660
		this.workingCopies[0] = getWorkingCopy(
2661
				"/P/src/test/Test.java",
2662
				"package test;"+
2663
				"public class Test {\n" +
2664
				"  void foo() {\n" +
2665
				"    new AllConstructors\n" +
2666
				"  }\n" +
2667
				"}");
2668
2669
		// do completion
2670
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2671
		requestor.allowAllRequiredProposals();
2672
		NullProgressMonitor monitor = new NullProgressMonitor();
2673
2674
	    String str = this.workingCopies[0].getSource();
2675
	    String completeBehind = "AllConstructors";
2676
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2677
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2678
	    
2679
	    assertResults(
2680
			"AllConstructors34[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors34;, (Ljava.lang.Object;)V, AllConstructors34, (arg0), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2681
			"   AllConstructors34[TYPE_REF]{p6930.AllConstructors34, p6930, Lp6930.AllConstructors34;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
2682
			requestor.getResults());
2683
	} finally {
2684
		deleteProject("P");
2685
		
2686
		JavaCore.setOptions(oldOptions);
2687
	}
2688
}
2689
public void testBug6930_35() throws Exception {
2690
	Hashtable oldOptions = JavaCore.getOptions();
2691
	
2692
	try {
2693
		Hashtable options = new Hashtable(oldOptions);
2694
		options.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED);
2695
		JavaCore.setOptions(options);
2696
		
2697
		IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[]{"JCL_LIB"}, "bin");
2698
		
2699
		Map compileOptions = new HashMap();
2700
		compileOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
2701
	    
2702
		String[] pathsAndContents =
2703
			new String[] {
2704
				"p6930/AllConstructors35.java",
2705
				"package p6930;\n" +
2706
				"public class AllConstructors35 {\n" +
2707
				"  public AllConstructors35(Object o) {}\n" +
2708
				"}"
2709
			};
2710
		createJar(
2711
				pathsAndContents,
2712
				p.getProject().getLocation().append("lib6930.jar").toOSString(),
2713
				compileOptions);
2714
		
2715
		createSourceZip(
2716
				pathsAndContents,
2717
				p.getProject().getLocation().append("lib6930src.zip").toOSString());
2718
		
2719
		addLibraryEntry(p, "/P/lib6930.jar", "/P/lib6930src.zip");
2720
		
2721
		refresh(p);
2722
		
2723
		waitUntilIndexesReady();
2724
		
2725
		this.workingCopies = new ICompilationUnit[1];
2726
		this.workingCopies[0] = getWorkingCopy(
2727
				"/P/src/test/Test.java",
2728
				"package test;"+
2729
				"public class Test {\n" +
2730
				"  void foo() {\n" +
2731
				"    new AllConstructors\n" +
2732
				"  }\n" +
2733
				"}");
2734
2735
		// do completion
2736
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, true, true);
2737
		requestor.allowAllRequiredProposals();
2738
		NullProgressMonitor monitor = new NullProgressMonitor();
2739
2740
	    String str = this.workingCopies[0].getSource();
2741
	    String completeBehind = "AllConstructors";
2742
	    int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
2743
	    this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
2744
	    
2745
	    assertResults(
2746
			"AllConstructors35[CONSTRUCTOR_INVOCATION]{(), Lp6930.AllConstructors35;, (Ljava.lang.Object;)V, AllConstructors35, (o), "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}\n" +
2747
			"   AllConstructors35[TYPE_REF]{p6930.AllConstructors35, p6930, Lp6930.AllConstructors35;, null, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"}",
2748
			requestor.getResults());
2749
	} finally {
2750
		deleteProject("P");
2751
		
2752
		JavaCore.setOptions(oldOptions);
2753
	}
2754
}
2626
public void testBug79288() throws Exception {
2755
public void testBug79288() throws Exception {
2627
	try {
2756
	try {
2628
		// create variable
2757
		// create variable
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (-1 / +1 lines)
Lines 107-113 Link Here
107
		IProgressMonitor monitor = new NullProgressMonitor();
107
		IProgressMonitor monitor = new NullProgressMonitor();
108
		monitor.setCanceled(true); /*force completion to abort*/
108
		monitor.setCanceled(true); /*force completion to abort*/
109
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
109
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner, monitor);
110
		assertTrue("Should not be cancelled", false);
110
		assertTrue("Should be cancelled", false);
111
	} catch (OperationCanceledException e) {
111
	} catch (OperationCanceledException e) {
112
		assertResults(
112
		assertResults(
113
				"",
113
				"",
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java (+7 lines)
Lines 1129-1134 Link Here
1129
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, jarPath, "1.4");
1129
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, jarPath, "1.4");
1130
	}
1130
	}
1131
	
1131
	
1132
	protected void createJar(String[] javaPathsAndContents, String jarPath, Map options) throws IOException {
1133
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, null, jarPath, null, "1.4", options);
1134
	}
1135
	
1132
	protected void createJar(String[] javaPathsAndContents, String jarPath, String[] classpath, String compliance) throws IOException {
1136
	protected void createJar(String[] javaPathsAndContents, String jarPath, String[] classpath, String compliance) throws IOException {
1133
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, null,jarPath, classpath, compliance);
1137
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, null,jarPath, classpath, compliance);
1134
	}
1138
	}
Lines 1610-1615 Link Here
1610
		getWorkspace().run(create, null);
1614
		getWorkspace().run(create, null);
1611
		return project;
1615
		return project;
1612
	}
1616
	}
1617
	public void createSourceZip(String[] pathsAndContents, String zipPath) throws IOException {
1618
		org.eclipse.jdt.core.tests.util.Util.createSourceZip(pathsAndContents, zipPath);
1619
	}
1613
	public void deleteResource(File resource) {
1620
	public void deleteResource(File resource) {
1614
		int retryCount = 0;
1621
		int retryCount = 0;
1615
		while (++retryCount <= 60) { // wait 1 minute at most
1622
		while (++retryCount <= 60) { // wait 1 minute at most
(-)src/org/eclipse/jdt/core/tests/util/Util.java (+5 lines)
Lines 360-365 Link Here
360
public static void createJar(String[] javaPathsAndContents, String[] extraPathsAndContents, String jarPath, String[] classpath, String compliance) throws IOException {
360
public static void createJar(String[] javaPathsAndContents, String[] extraPathsAndContents, String jarPath, String[] classpath, String compliance) throws IOException {
361
	createJar(javaPathsAndContents, extraPathsAndContents, getCompileOptions(compliance), classpath, jarPath);
361
	createJar(javaPathsAndContents, extraPathsAndContents, getCompileOptions(compliance), classpath, jarPath);
362
}
362
}
363
public static void createJar(String[] javaPathsAndContents, String[] extraPathsAndContents, String jarPath, String[] classpath, String compliance, Map options) throws IOException {
364
	Map compileOptions = getCompileOptions(compliance);
365
	compileOptions.putAll(options);
366
	createJar(javaPathsAndContents, extraPathsAndContents, compileOptions, classpath, jarPath);
367
}
363
public static void createSourceZip(String[] pathsAndContents, String zipPath) throws IOException {
368
public static void createSourceZip(String[] pathsAndContents, String zipPath) throws IOException {
364
    String sourcesPath = getOutputDirectory() + File.separator + "sources";
369
    String sourcesPath = getOutputDirectory() + File.separator + "sources";
365
    createSourceDir(pathsAndContents, sourcesPath);
370
    createSourceDir(pathsAndContents, sourcesPath);
(-)codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java (-4 / +7 lines)
Lines 29-34 Link Here
29
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
29
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
30
import org.eclipse.jdt.internal.core.BinaryType;
30
import org.eclipse.jdt.internal.core.BinaryType;
31
import org.eclipse.jdt.internal.core.JavaElement;
31
import org.eclipse.jdt.internal.core.JavaElement;
32
import org.eclipse.jdt.internal.core.JavaModelManager;
32
import org.eclipse.jdt.internal.core.NameLookup;
33
import org.eclipse.jdt.internal.core.NameLookup;
33
import org.eclipse.jdt.internal.core.SourceMapper;
34
import org.eclipse.jdt.internal.core.SourceMapper;
34
35
Lines 38-46 Link Here
38
 */
39
 */
39
public class InternalCompletionProposal extends CompletionProposal {
40
public class InternalCompletionProposal extends CompletionProposal {
40
	private static Object NO_ATTACHED_SOURCE = new Object();
41
	private static Object NO_ATTACHED_SOURCE = new Object();
41
	private static final int OPENED_BYNARY_TYPES_THRESHOLD = 100; // threshold of opened binary to avoid to harm java model cache
42
	
42
43
44
	protected CompletionEngine completionEngine;
43
	protected CompletionEngine completionEngine;
45
	protected NameLookup nameLookup;
44
	protected NameLookup nameLookup;
46
45
Lines 220-226 Link Here
220
			if (this.hasNoParameterNamesFromIndex) {
219
			if (this.hasNoParameterNamesFromIndex) {
221
				IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot)type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
220
				IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot)type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
222
				if (packageFragmentRoot.isArchive() ||
221
				if (packageFragmentRoot.isArchive() ||
223
						this.completionEngine.openedBinaryTypes < OPENED_BYNARY_TYPES_THRESHOLD) {
222
						this.completionEngine.openedBinaryTypes < getOpenedBinaryTypesThreshold()) {
224
					SourceMapper mapper = ((JavaElement)method).getSourceMapper();
223
					SourceMapper mapper = ((JavaElement)method).getSourceMapper();
225
					if (mapper != null) {
224
					if (mapper != null) {
226
						try {
225
						try {
Lines 339-344 Link Here
339
	protected char[] getDeclarationTypeName() {
338
	protected char[] getDeclarationTypeName() {
340
		return this.declarationTypeName;
339
		return this.declarationTypeName;
341
	}
340
	}
341
	
342
	private int getOpenedBinaryTypesThreshold() {
343
		return JavaModelManager.getJavaModelManager().getOpenableCacheSize() / 10;
344
	}
342
345
343
	protected char[] getPackageName() {
346
	protected char[] getPackageName() {
344
		return this.packageName;
347
		return this.packageName;
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-40 / +14 lines)
Lines 5214-5269 Link Here
5214
		}
5214
		}
5215
5215
5216
		if (guessedType != null && guessedType.isValidBinding()) {
5216
		if (guessedType != null && guessedType.isValidBinding()) {
5217
			if (guessedType instanceof ReferenceBinding) {
5217
			if (guessedType instanceof SourceTypeBinding) {
5218
				ReferenceBinding refBinding = (ReferenceBinding) guessedType;
5218
				SourceTypeBinding refBinding = (SourceTypeBinding) guessedType;
5219
				
5219
				
5220
				MethodBinding bestConstructor = null;
5220
				refBinding.methods(); // force resolution
5221
				int[] bestMatchingLengths = null;
5221
				if (refBinding.scope == null || refBinding.scope.referenceContext == null) return null;
5222
				
5222
				TypeDeclaration typeDeclaration = refBinding.scope.referenceContext;
5223
				MethodBinding[] methods = refBinding.methods();
5223
				AbstractMethodDeclaration[] methods = typeDeclaration.methods;
5224
				next : for (int i = 0; i < methods.length; i++) {
5224
				next : for (int i = 0; i < methods.length; i++) {
5225
					MethodBinding method = methods[i];
5225
					AbstractMethodDeclaration method = methods[i];
5226
					
5226
					
5227
					if (!method.isConstructor()) break next;
5227
					if (method.binding == null || !method.isConstructor()) continue next;
5228
					
5228
					
5229
					TypeBinding[] parameters = method.parameters;
5229
					Argument[] arguments = method.arguments;
5230
					//TODO take careful of member types
5230
					int argumentsLength = arguments == null ? 0 : arguments.length;
5231
					int parametersLength = parameters == null ? 0 : parameters.length;
5231
					if (parameterCount != argumentsLength) continue next;
5232
					if (parameterCount != parametersLength) continue next;
5233
					
5232
					
5234
					int[] matchingLengths = new int[parameterCount];
5233
					for (int j = 0; j < argumentsLength; j++) {
5235
					for (int j = 0; j < parametersLength; j++) {
5234
						if (!CharOperation.equals(CharOperation.concatWith(arguments[j].type.getTypeName(), '.'), parameterTypes[j])) {
5236
						TypeBinding parameter = parameters[j];
5237
						
5238
						char[] parameterTypeName;
5239
						if (parameter instanceof ReferenceBinding) {
5240
							parameterTypeName = CharOperation.concatWith(((ReferenceBinding)parameter).compoundName, '.');
5241
						} else {
5242
							parameterTypeName = parameter.sourceName();
5243
						}
5244
						
5245
						if (!CharOperation.endsWith(parameterTypeName, parameterTypes[j])) {
5246
							continue next;
5235
							continue next;
5247
						}
5236
						}
5248
						
5249
						int matchingLength = parameterTypes[j].length;
5250
						
5251
						if (bestMatchingLengths != null) {
5252
							if (bestMatchingLengths[j] > matchingLength) {
5253
								continue next;
5254
							}
5255
						}
5256
						
5257
						matchingLengths[j] = matchingLength;
5258
					}
5237
					}
5259
					
5238
					
5260
					
5239
					return getSignature(method.binding);
5261
					bestConstructor = method;
5262
					bestMatchingLengths = matchingLengths;
5263
				}
5240
				}
5264
				
5265
				if (bestConstructor == null) return null;
5266
				return getSignature(bestConstructor);
5267
			}
5241
			}
5268
		}
5242
		}
5269
		
5243
		
(-)search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java (-47 / +16 lines)
Lines 430-472 Link Here
430
		}
430
		}
431
		return true;
431
		return true;
432
	}
432
	}
433
	
434
	boolean match(char[] patternPkg, char[] patternTypeName, int matchRule, char[] pkg, char[] typeName) {
435
		
436
		boolean isCaseSensitive = (matchRule & SearchPattern.R_CASE_SENSITIVE) != 0;
437
		
438
		if (patternPkg != null && !CharOperation.equals(patternPkg, pkg, true))
439
			return false;
440
		
441
		if (patternTypeName != null) {
442
			boolean isCamelCase = (matchRule & (SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH)) != 0;
443
			int matchMode = matchRule & JavaSearchPattern.MATCH_MODE_MASK;
444
			if (!isCaseSensitive && !isCamelCase) {
445
				patternTypeName = CharOperation.toLowerCase(patternTypeName);
446
			}
447
			boolean matchFirstChar = !isCaseSensitive || patternTypeName[0] == typeName[0];
448
			switch(matchMode) {
449
				case SearchPattern.R_EXACT_MATCH :
450
					return matchFirstChar && CharOperation.equals(patternTypeName, typeName, isCaseSensitive);
451
				case SearchPattern.R_PREFIX_MATCH :
452
					return matchFirstChar && CharOperation.prefixEquals(patternTypeName, typeName, isCaseSensitive);
453
				case SearchPattern.R_PATTERN_MATCH :
454
					return CharOperation.match(patternTypeName, typeName, isCaseSensitive);
455
				case SearchPattern.R_REGEXP_MATCH :
456
					// TODO (frederic) implement regular expression match
457
					break;
458
				case SearchPattern.R_CAMELCASE_MATCH:
459
					if (matchFirstChar && CharOperation.camelCaseMatch(patternTypeName, typeName, false)) {
460
						return true;
461
					}
462
					return !isCaseSensitive && matchFirstChar && CharOperation.prefixEquals(patternTypeName, typeName, false);
463
				case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH:
464
					return matchFirstChar && CharOperation.camelCaseMatch(patternTypeName, typeName, true);
465
			}
466
		}
467
		return true;
468
469
	}
470
433
471
	boolean match(char patternTypeSuffix, char[] patternPkg, char[] patternTypeName, int matchRule, int typeKind, char[] pkg, char[] typeName) {
434
	boolean match(char patternTypeSuffix, char[] patternPkg, char[] patternTypeName, int matchRule, int typeKind, char[] pkg, char[] typeName) {
472
		switch(patternTypeSuffix) {
435
		switch(patternTypeSuffix) {
Lines 493-506 Link Here
493
				break;
456
				break;
494
			case IIndexConstants.TYPE_SUFFIX : // nothing
457
			case IIndexConstants.TYPE_SUFFIX : // nothing
495
		}
458
		}
496
459
		return match(patternPkg, matchRule, patternTypeName, matchRule, pkg, typeName);
497
		boolean isCaseSensitive = (matchRule & SearchPattern.R_CASE_SENSITIVE) != 0;
460
	}
498
		if (patternPkg != null && !CharOperation.equals(patternPkg, pkg, isCaseSensitive))
461
	
499
				return false;
462
	boolean match(char[] patternPkg, int matchRulePkg, char[] patternTypeName, int matchRuleTypeName, char[] pkg, char[] typeName) {
500
463
		boolean isPkgCaseSensitive = (matchRulePkg & SearchPattern.R_CASE_SENSITIVE) != 0;
464
		if (patternPkg != null && !CharOperation.equals(patternPkg, pkg, isPkgCaseSensitive))
465
			return false;
466
		
467
		boolean isCaseSensitive = (matchRuleTypeName & SearchPattern.R_CASE_SENSITIVE) != 0;
501
		if (patternTypeName != null) {
468
		if (patternTypeName != null) {
502
			boolean isCamelCase = (matchRule & (SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH)) != 0;
469
			boolean isCamelCase = (matchRuleTypeName & (SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH)) != 0;
503
			int matchMode = matchRule & JavaSearchPattern.MATCH_MODE_MASK;
470
			int matchMode = matchRuleTypeName & JavaSearchPattern.MATCH_MODE_MASK;
504
			if (!isCaseSensitive && !isCamelCase) {
471
			if (!isCaseSensitive && !isCamelCase) {
505
				patternTypeName = CharOperation.toLowerCase(patternTypeName);
472
				patternTypeName = CharOperation.toLowerCase(patternTypeName);
506
			}
473
			}
Lines 554-559 Link Here
554
521
555
		// Validate match rule first
522
		// Validate match rule first
556
		final int validatedTypeMatchRule = SearchPattern.validateMatchRule(typeName == null ? null : new String (typeName), typeMatchRule);
523
		final int validatedTypeMatchRule = SearchPattern.validateMatchRule(typeName == null ? null : new String (typeName), typeMatchRule);
524
		
525
		final int pkgMatchRule = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
557
526
558
		// Debug
527
		// Debug
559
		if (VERBOSE) {
528
		if (VERBOSE) {
Lines 685-691 Link Here
685
						for (int j = 0, allTypesLength = allTypes.length; j < allTypesLength; j++) {
654
						for (int j = 0, allTypesLength = allTypes.length; j < allTypesLength; j++) {
686
							IType type = allTypes[j];
655
							IType type = allTypes[j];
687
							char[] simpleName = type.getElementName().toCharArray();
656
							char[] simpleName = type.getElementName().toCharArray();
688
							if (match(packageName, typeName, validatedTypeMatchRule, packageDeclaration, simpleName) && !type.isMember()) {
657
							if (match(packageName, pkgMatchRule, typeName, validatedTypeMatchRule, packageDeclaration, simpleName) && !type.isMember()) {
689
								
658
								
690
								int extraFlags = ExtraFlags.getExtraFlags(type);
659
								int extraFlags = ExtraFlags.getExtraFlags(type);
691
								
660
								
Lines 752-758 Link Here
752
								private void endVisit(TypeDeclaration typeDeclaration) {
721
								private void endVisit(TypeDeclaration typeDeclaration) {
753
									if (!hasConstructor(typeDeclaration) && typeDeclaration.enclosingType == null) {
722
									if (!hasConstructor(typeDeclaration) && typeDeclaration.enclosingType == null) {
754
									
723
									
755
										if (match(packageName, typeName, validatedTypeMatchRule, packageDeclaration, typeDeclaration.name)) {
724
										if (match(packageName, pkgMatchRule, typeName, validatedTypeMatchRule, packageDeclaration, typeDeclaration.name)) {
756
											nameRequestor.acceptConstructor(
725
											nameRequestor.acceptConstructor(
757
													Flags.AccPublic,
726
													Flags.AccPublic,
758
													typeName,
727
													typeName,
Lines 793-799 Link Here
793
								}
762
								}
794
								public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope classScope) {
763
								public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope classScope) {
795
									TypeDeclaration typeDeclaration = this.declaringTypes[this.declaringTypesPtr];
764
									TypeDeclaration typeDeclaration = this.declaringTypes[this.declaringTypesPtr];
796
									if (match(packageName, typeName, validatedTypeMatchRule, packageDeclaration, typeDeclaration.name)) {
765
									if (match(packageName, pkgMatchRule, typeName, validatedTypeMatchRule, packageDeclaration, typeDeclaration.name)) {
797
										Argument[] arguments = constructorDeclaration.arguments;
766
										Argument[] arguments = constructorDeclaration.arguments;
798
										int length = arguments == null ? 0 : arguments.length;
767
										int length = arguments == null ? 0 : arguments.length;
799
										char[][] parameterNames = new char[length][];
768
										char[][] parameterNames = new char[length][];
(-)search/org/eclipse/jdt/internal/core/search/matching/ConstructorDeclarationPattern.java (-38 lines)
Lines 10-23 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.search.matching;
11
package org.eclipse.jdt.internal.core.search.matching;
12
12
13
import java.io.IOException;
14
15
import org.eclipse.jdt.core.compiler.CharOperation;
13
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.core.search.SearchPattern;
14
import org.eclipse.jdt.core.search.SearchPattern;
17
import org.eclipse.jdt.internal.compiler.ExtraFlags;
15
import org.eclipse.jdt.internal.compiler.ExtraFlags;
18
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
16
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
19
import org.eclipse.jdt.internal.core.index.EntryResult;
20
import org.eclipse.jdt.internal.core.index.Index;
21
17
22
public class ConstructorDeclarationPattern extends ConstructorPattern {
18
public class ConstructorDeclarationPattern extends ConstructorPattern {
23
	public int extraFlags;
19
	public int extraFlags;
Lines 152-191 Link Here
152
	return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
148
	return (this.parameterCount == pattern.parameterCount || this.parameterCount == -1 || this.varargs)
153
		&& matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
149
		&& matchesName(this.declaringSimpleName, pattern.declaringSimpleName);
154
}
150
}
155
public EntryResult[] queryIn(Index index) throws IOException {
156
	char[] key = this.declaringSimpleName; // can be null
157
	int matchRule = getMatchRule();
158
159
	switch(getMatchMode()) {
160
		case R_EXACT_MATCH :
161
			if (this.declaringSimpleName != null && this.parameterCount >= 0 && !this.varargs) {
162
				key = createIndexKey(this.declaringSimpleName, this.parameterCount);
163
			} 
164
			matchRule &= ~R_EXACT_MATCH;
165
			matchRule |= R_PREFIX_MATCH;
166
			break;
167
		case R_PREFIX_MATCH :
168
			// do a prefix query with the declaringSimpleName
169
			break;
170
		case R_PATTERN_MATCH :
171
			if (this.parameterCount >= 0 && !this.varargs)
172
				key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount);
173
			else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*')
174
				key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
175
			key = CharOperation.concat(key, ONE_STAR);
176
			// else do a pattern query with just the declaringSimpleName
177
			break;
178
		case R_REGEXP_MATCH :
179
			// TODO (frederic) implement regular expression match
180
			break;
181
		case R_CAMELCASE_MATCH:
182
		case R_CAMELCASE_SAME_PART_COUNT_MATCH:
183
			// do a prefix query with the declaringSimpleName
184
			break;
185
	}
186
187
	return index.query(getIndexCategories(), key, matchRule); // match rule is irrelevant when the key is null
188
}
189
private void removeInternalFlags() {
151
private void removeInternalFlags() {
190
	this.extraFlags = this.extraFlags & ~ExtraFlags.ParameterTypesStoredAsSignature; // ParameterTypesStoredAsSignature is an internal flags only used to decode key
152
	this.extraFlags = this.extraFlags & ~ExtraFlags.ParameterTypesStoredAsSignature; // ParameterTypesStoredAsSignature is an internal flags only used to decode key
191
}
153
}
(-)search/org/eclipse/jdt/internal/core/search/matching/ConstructorPattern.java (-4 / +6 lines)
Lines 528-538 Link Here
528
			// do a prefix query with the declaringSimpleName
528
			// do a prefix query with the declaringSimpleName
529
			break;
529
			break;
530
		case R_PATTERN_MATCH :
530
		case R_PATTERN_MATCH :
531
			if (this.parameterCount >= 0 && !this.varargs)
531
			if (this.parameterCount >= 0 && !this.varargs) {
532
				key = createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount);
532
				key = CharOperation.concat(createIndexKey(this.declaringSimpleName == null ? ONE_STAR : this.declaringSimpleName, this.parameterCount), ONE_STAR);
533
			else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*')
533
			} else if (this.declaringSimpleName != null && this.declaringSimpleName[this.declaringSimpleName.length - 1] != '*') {
534
				key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
534
				key = CharOperation.concat(this.declaringSimpleName, ONE_STAR, SEPARATOR);
535
			key = CharOperation.concat(key, ONE_STAR);
535
			} else if (key != null){
536
				key = CharOperation.concat(key, ONE_STAR);
537
			}
536
			// else do a pattern query with just the declaringSimpleName
538
			// else do a pattern query with just the declaringSimpleName
537
			break;
539
			break;
538
		case R_REGEXP_MATCH :
540
		case R_REGEXP_MATCH :
(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (+4 lines)
Lines 4683-4686 Link Here
4683
	public Stats debugNewOpenableCacheStats() {
4683
	public Stats debugNewOpenableCacheStats() {
4684
		return this.cache.openableCache.new Stats();
4684
		return this.cache.openableCache.new Stats();
4685
	}
4685
	}
4686
	
4687
	public int getOpenableCacheSize() {
4688
		return this.cache.openableCache.getSpaceLimit();
4689
	}
4686
}
4690
}

Return to bug 261973