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

(-)src/org/eclipse/jdt/core/tests/compiler/regression/UtilTest.java (-2 / +48 lines)
Lines 44-50 Link Here
44
		if (!match) line.append(" NOT");
44
		if (!match) line.append(" NOT");
45
		line.append(" match pattern '");
45
		line.append(" match pattern '");
46
		line.append(pattern);
46
		line.append(pattern);
47
		line.append("'");
47
		line.append("', but it DOES");
48
		if (!camelCase) line.append(" NOT");
48
		if (this.camelCaseErrors.length() == 0) {
49
		if (this.camelCaseErrors.length() == 0) {
49
			System.out.println("Invalid results in test "+getName()+":");
50
			System.out.println("Invalid results in test "+getName()+":");
50
		}
51
		}
Lines 513-519 Link Here
513
/**
514
/**
514
 * Bug 130390: CamelCase algorithm cleanup and improvement
515
 * Bug 130390: CamelCase algorithm cleanup and improvement
515
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=130390"
516
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=130390"
516
 *
517
 */
517
 */
518
public void test66() {
518
public void test66() {
519
    String[][] MATCHES = {
519
    String[][] MATCHES = {
Lines 562-567 Link Here
562
	// Verify that there were no unexpected results
562
	// Verify that there were no unexpected results
563
    assertTrue(this.camelCaseErrors.toString(), this.camelCaseErrors.length()==0);
563
    assertTrue(this.camelCaseErrors.toString(), this.camelCaseErrors.length()==0);
564
}
564
}
565
566
/**
567
 * Bug 137087: Open Type - missing matches when using mixed case pattern
568
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=137087"
569
 */
570
public void test67() {
571
	assertCamelCase("runtimeEx", "RuntimeException", false/* should not match */);
572
	assertCamelCase("Runtimeex", "RuntimeException", false/* should not match */);
573
	assertCamelCase("runtimeexception", "RuntimeException", false/* should not match */);
574
	assertCamelCase("Runtimexception", "RuntimeException", false/* should not match */);
575
	assertCamelCase("illegalMSException", "IllegalMonitorStateException", false/* should not match */);
576
	assertCamelCase("illegalMsException", "IllegalMonitorStateException", false /* should not match */);
577
	assertCamelCase("IllegalMSException", "IllegalMonitorStateException", true/* should match */);
578
	assertCamelCase("IllegalMsException", "IllegalMonitorStateException", false /* should not match */);
579
	assertCamelCase("clonenotsupportedex", "CloneNotSupportedException", false/* should not match */);
580
	assertCamelCase("CloneNotSupportedEx", "CloneNotSupportedException", true/* should match */);
581
	assertCamelCase("cloneNotsupportedEx", "CloneNotSupportedException", false/* should not match */);
582
	assertCamelCase("ClonenotSupportedexc", "CloneNotSupportedException", false/* should not match */);
583
	assertCamelCase("cloneNotSupportedExcep", "CloneNotSupportedException", false/* should not match */);
584
	assertCamelCase("Clonenotsupportedexception", "CloneNotSupportedException", false/* should not match */);
585
	assertCamelCase("CloneNotSupportedException", "CloneNotSupportedException", true /* should match */);
586
	// Verify that there were no unexpected results
587
    assertTrue(this.camelCaseErrors.toString(), this.camelCaseErrors.length()==0);
588
}
589
// lower CamelCase
590
public void test68() {
591
	assertCamelCase("aMe", "aMethod", true/* should match */);
592
	assertCamelCase("ame", "aMethod", false/* should not match */);
593
	assertCamelCase("longNOM", "longNameOfMethod", true/* should match */);
594
	assertCamelCase("longNOMeth", "longNameOfMethod", true/* should match */);
595
	assertCamelCase("longNOMethod", "longNameOfMethod", true/* should match */);
596
	assertCamelCase("longNoMethod", "longNameOfMethod", false/* should not match */);
597
	// Verify that there were no unexpected results
598
    assertTrue(this.camelCaseErrors.toString(), this.camelCaseErrors.length()==0);
599
}
600
// search tests
601
public void test69() {
602
	assertCamelCase("aa", "AxxAyy", false /* should not match */);
603
	assertCamelCase("Aa", "AxxAyy", false /* should not match */);
604
	assertCamelCase("aA", "AxxAyy", false /* should not match */);
605
	assertCamelCase("AA", "AxxAyy", true /* should match */);
606
	assertCamelCase("aa", "AbcdAbcdefAbcAbcdefghAbAAzzzzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnAbcAbcdefghijklm", false /* should not match */);
607
	assertCamelCase("AA", "AbcdAbcdefAbcAbcdefghAbAAzzzzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnAbcAbcdefghijklm", true /* should match */);
608
	// Verify that there were no unexpected results
609
    assertTrue(this.camelCaseErrors.toString(), this.camelCaseErrors.length()==0);
610
}
565
public static Class testClass() {
611
public static Class testClass() {
566
	return UtilTest.class;
612
	return UtilTest.class;
567
}
613
}
(-)src/org/eclipse/jdt/core/tests/model/SearchTests.java (+4 lines)
Lines 1022-1025 Link Here
1022
		SearchPattern.R_CAMELCASE_MATCH|SearchPattern.R_PREFIX_MATCH,
1022
		SearchPattern.R_CAMELCASE_MATCH|SearchPattern.R_PREFIX_MATCH,
1023
		SearchPattern.R_PREFIX_MATCH);
1023
		SearchPattern.R_PREFIX_MATCH);
1024
}
1024
}
1025
public void testSearchPatternValidMatchRule05() {
1026
	assertValidMatchRule("hashMap", SearchPattern.R_CAMELCASE_MATCH);
1027
	assertValidMatchRule("Hashmap", SearchPattern.R_CAMELCASE_MATCH);
1028
}
1025
}
1029
}
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-3 / +257 lines)
Lines 4574-4580 Link Here
4574
	assertEquals("Invalid number of working copies kept between tests!", 5, workingCopies.length);
4574
	assertEquals("Invalid number of working copies kept between tests!", 5, workingCopies.length);
4575
	search("AxXA", TYPE, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH);
4575
	search("AxXA", TYPE, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH);
4576
	this.discard = false;
4576
	this.discard = false;
4577
	assertSearchResults("");
4577
	assertSearchResults(
4578
		"src/b110060/AxxAyy.java b110060.AxxAyy [AxxAyy] EXACT_MATCH\n" + 
4579
		"src/b110060/Test.java b110060.Test.axxayy [AxxAyy] EXACT_MATCH"
4580
	);
4578
}
4581
}
4579
4582
4580
public void testBug110060_AllTypeNames01() throws CoreException {
4583
public void testBug110060_AllTypeNames01() throws CoreException {
Lines 4755-4761 Link Here
4755
	this.discard = false;
4758
	this.discard = false;
4756
	assertSearchResults(
4759
	assertSearchResults(
4757
		"Unexpected all type names",
4760
		"Unexpected all type names",
4758
		"",
4761
		"b110060.AA\n" + 
4762
		"b110060.AAxx",
4759
		requestor);
4763
		requestor);
4760
}
4764
}
4761
4765
Lines 5994-6000 Link Here
5994
	);
5998
	);
5995
}
5999
}
5996
6000
5997
5998
/**
6001
/**
5999
 * To get these tests search matches in a workspace, do NOT forget to modify files
6002
 * To get these tests search matches in a workspace, do NOT forget to modify files
6000
 * to set them as working copies.
6003
 * to set them as working copies.
Lines 6036-6041 Link Here
6036
	search("NPE", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH);
6039
	search("NPE", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH);
6037
	this.discard = false;
6040
	this.discard = false;
6038
	assertSearchResults(
6041
	assertSearchResults(
6042
		"src/b130390/Npe.java b130390.Npe [Npe] EXACT_MATCH\n" + 
6039
		"src/b130390/NullPointerException.java b130390.NullPointerException [NullPointerException] EXACT_MATCH"
6043
		"src/b130390/NullPointerException.java b130390.NullPointerException [NullPointerException] EXACT_MATCH"
6040
	);
6044
	);
6041
}
6045
}
Lines 6094-6097 Link Here
6094
		"src/b130390/TimeZone.java b130390.TimeZone [TimeZone] EXACT_MATCH"
6098
		"src/b130390/TimeZone.java b130390.TimeZone [TimeZone] EXACT_MATCH"
6095
	);
6099
	);
6096
}
6100
}
6101
/**
6102
 * To get these tests search matches in a workspace, do NOT forget to modify files
6103
 * to set them as working copies.
6104
 *
6105
 * @test Bug 137087: Open Type - missing matches when using mixed case pattern
6106
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=137087"
6107
 */
6108
public void testBug137087() throws CoreException {
6109
	// Search CamelCase
6110
	int matchRule = SearchPattern.R_CAMELCASE_MATCH;
6111
	String pattern = "runtimeEx";
6112
	search(pattern, TYPE, DECLARATIONS, matchRule);
6113
	assertSearchResults(
6114
		""+ getExternalJCLPathString("1.5") + " java.lang.RuntimeException EXACT_MATCH"
6115
	);
6116
	// Search like UI does (ie. replace it with prefix if it's not a valid CamelCase)
6117
	int validatedRule = SearchPattern.validateMatchRule(pattern, matchRule);
6118
	if (validatedRule != matchRule) {
6119
		matchRule = SearchPattern.R_PREFIX_MATCH;
6120
	}
6121
	search(pattern, TYPE, DECLARATIONS, matchRule);
6122
	assertSearchResults(
6123
		""+ getExternalJCLPathString("1.5") + " java.lang.RuntimeException EXACT_MATCH\n" +
6124
		""+ getExternalJCLPathString("1.5") + " java.lang.RuntimeException EXACT_MATCH"
6125
	);
6126
}
6127
public void testBug137087b() throws CoreException {
6128
	// Search CamelCase
6129
	int matchRule = SearchPattern.R_CAMELCASE_MATCH;
6130
	String pattern = "Runtimeex";
6131
	search(pattern, TYPE, DECLARATIONS, matchRule);
6132
	assertSearchResults(
6133
		""+ getExternalJCLPathString("1.5") + " java.lang.RuntimeException EXACT_MATCH"
6134
	);
6135
	// Search like UI does (ie. replace it with prefix if it's not a valid CamelCase)
6136
	int validatedRule = SearchPattern.validateMatchRule(pattern, matchRule);
6137
	if (validatedRule != matchRule) {
6138
		matchRule = SearchPattern.R_PREFIX_MATCH;
6139
	}
6140
	search(pattern, TYPE, DECLARATIONS, matchRule);
6141
	assertSearchResults(
6142
		""+ getExternalJCLPathString("1.5") + " java.lang.RuntimeException EXACT_MATCH\n" +
6143
		""+ getExternalJCLPathString("1.5") + " java.lang.RuntimeException EXACT_MATCH"
6144
	);
6145
}
6146
public void testBug137087c() throws CoreException {
6147
	// Search CamelCase
6148
	int matchRule = SearchPattern.R_CAMELCASE_MATCH;
6149
	String pattern = "runtimeexception";
6150
	search(pattern, TYPE, DECLARATIONS, matchRule);
6151
	assertSearchResults(
6152
		"" // no match expected as this is not a valid camel case
6153
	);
6154
	// Search like UI does (ie. replace it with prefix if it's not a valid CamelCase)
6155
	int validatedRule = SearchPattern.validateMatchRule(pattern, matchRule);
6156
	if (validatedRule != matchRule) {
6157
		matchRule = SearchPattern.R_PREFIX_MATCH;
6158
	}
6159
	search(pattern, TYPE, DECLARATIONS, matchRule);
6160
	assertSearchResults(
6161
		""+ getExternalJCLPathString("1.5") + " java.lang.RuntimeException EXACT_MATCH"
6162
	);
6163
}
6164
public void testBug137087d() throws CoreException {
6165
	// Search CamelCase
6166
	int matchRule = SearchPattern.R_CAMELCASE_MATCH;
6167
	String pattern = "Runtimexception";
6168
	search(pattern, TYPE, DECLARATIONS, matchRule);
6169
	assertSearchResults(
6170
		"" // no match expected as pattern is missing a 'e'
6171
	);
6172
	// Search like UI does (ie. replace it with prefix if it's not a valid CamelCase)
6173
	int validatedRule = SearchPattern.validateMatchRule(pattern, matchRule);
6174
	if (validatedRule != matchRule) {
6175
		matchRule = SearchPattern.R_PREFIX_MATCH;
6176
	}
6177
	search(pattern, TYPE, DECLARATIONS, matchRule);
6178
	assertSearchResults(
6179
		"" // no match expected as pattern is missing a 'e'
6180
	);
6181
}
6182
public void testBug137087e() throws CoreException {
6183
	// Search CamelCase
6184
	int matchRule = SearchPattern.R_CAMELCASE_MATCH;
6185
	String pattern = "IllegalMSException";
6186
	search(pattern, TYPE, DECLARATIONS, matchRule);
6187
	assertSearchResults(
6188
		""+ getExternalJCLPathString("1.5") + " java.lang.IllegalMonitorStateException EXACT_MATCH"
6189
	);
6190
	// Search like UI does (ie. replace it with prefix if it's not a valid CamelCase)
6191
	int validatedRule = SearchPattern.validateMatchRule(pattern, matchRule);
6192
	if (validatedRule != matchRule) {
6193
		matchRule = SearchPattern.R_PREFIX_MATCH;
6194
	}
6195
	search(pattern, TYPE, DECLARATIONS, matchRule);
6196
	assertSearchResults(
6197
		""+ getExternalJCLPathString("1.5") + " java.lang.IllegalMonitorStateException EXACT_MATCH\n" +
6198
		""+ getExternalJCLPathString("1.5") + " java.lang.IllegalMonitorStateException EXACT_MATCH"
6199
	);
6200
}
6201
public void testBug137087f() throws CoreException {
6202
	// Search CamelCase
6203
	int matchRule = SearchPattern.R_CAMELCASE_MATCH;
6204
	String pattern = "illegalMsExceptionSException";
6205
	search(pattern, TYPE, DECLARATIONS, matchRule);
6206
	assertSearchResults(
6207
		"" // expected no result as uppercase characters in pattern do not match any camelcase ones in existing types
6208
	);
6209
	// Search like UI does (ie. replace it with prefix if it's not a valid CamelCase)
6210
	int validatedRule = SearchPattern.validateMatchRule(pattern, matchRule);
6211
	if (validatedRule != matchRule) {
6212
		matchRule = SearchPattern.R_PREFIX_MATCH;
6213
	}
6214
	search(pattern, TYPE, DECLARATIONS, matchRule);
6215
	assertSearchResults(
6216
		"" // expected no result as uppercase characters in pattern do not match any camelcase ones in existing types
6217
	);
6218
}
6219
public void testBug137087g() throws CoreException {
6220
	// Search CamelCase
6221
	int matchRule = SearchPattern.R_CAMELCASE_MATCH;
6222
	String pattern = "clonenotsupportedex";
6223
	search(pattern, TYPE, DECLARATIONS, matchRule);
6224
	assertSearchResults(
6225
		"" // no match expected as this is not a valid camel case
6226
	);
6227
	// Search like UI does (ie. replace it with prefix if it's not a valid CamelCase)
6228
	int validatedRule = SearchPattern.validateMatchRule(pattern, matchRule);
6229
	if (validatedRule != matchRule) {
6230
		matchRule = SearchPattern.R_PREFIX_MATCH;
6231
	}
6232
	search(pattern, TYPE, DECLARATIONS, matchRule);
6233
	assertSearchResults(
6234
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH"
6235
	);
6236
}
6237
public void testBug137087h() throws CoreException {
6238
	// Search CamelCase
6239
	int matchRule = SearchPattern.R_CAMELCASE_MATCH;
6240
	String pattern = "CloneNotSupportedEx";
6241
	search(pattern, TYPE, DECLARATIONS, matchRule);
6242
	assertSearchResults(
6243
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH"
6244
	);
6245
	// Search like UI does (ie. replace it with prefix if it's not a valid CamelCase)
6246
	int validatedRule = SearchPattern.validateMatchRule(pattern, matchRule);
6247
	if (validatedRule != matchRule) {
6248
		matchRule = SearchPattern.R_PREFIX_MATCH;
6249
	}
6250
	search(pattern, TYPE, DECLARATIONS, matchRule);
6251
	assertSearchResults(
6252
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH\n" +
6253
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH"
6254
	);
6255
}
6256
public void testBug137087i() throws CoreException {
6257
	// Search CamelCase
6258
	int matchRule = SearchPattern.R_CAMELCASE_MATCH;
6259
	String pattern = "cloneNotsupportedEx";
6260
	search(pattern, TYPE, DECLARATIONS, matchRule);
6261
	assertSearchResults(
6262
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH"
6263
	);
6264
	// Search like UI does (ie. replace it with prefix if it's not a valid CamelCase)
6265
	int validatedRule = SearchPattern.validateMatchRule(pattern, matchRule);
6266
	if (validatedRule != matchRule) {
6267
		matchRule = SearchPattern.R_PREFIX_MATCH;
6268
	}
6269
	search(pattern, TYPE, DECLARATIONS, matchRule);
6270
	assertSearchResults(
6271
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH\n" +
6272
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH"
6273
	);
6274
}
6275
public void testBug137087j() throws CoreException {
6276
	// Search CamelCase
6277
	int matchRule = SearchPattern.R_CAMELCASE_MATCH;
6278
	String pattern = "ClonenotSupportedexc";
6279
	search(pattern, TYPE, DECLARATIONS, matchRule);
6280
	assertSearchResults(
6281
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH"
6282
	);
6283
	// Search like UI does (ie. replace it with prefix if it's not a valid CamelCase)
6284
	int validatedRule = SearchPattern.validateMatchRule(pattern, matchRule);
6285
	if (validatedRule != matchRule) {
6286
		matchRule = SearchPattern.R_PREFIX_MATCH;
6287
	}
6288
	search(pattern, TYPE, DECLARATIONS, matchRule);
6289
	assertSearchResults(
6290
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH\n" +
6291
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH"
6292
	);
6293
}
6294
public void testBug137087k() throws CoreException {
6295
	// Search CamelCase
6296
	int matchRule = SearchPattern.R_CAMELCASE_MATCH;
6297
	String pattern = "cloneNotSupportedExcep";
6298
	search(pattern, TYPE, DECLARATIONS, matchRule);
6299
	assertSearchResults(
6300
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH"
6301
	);
6302
	// Search like UI does (ie. replace it with prefix if it's not a valid CamelCase)
6303
	int validatedRule = SearchPattern.validateMatchRule(pattern, matchRule);
6304
	if (validatedRule != matchRule) {
6305
		matchRule = SearchPattern.R_PREFIX_MATCH;
6306
	}
6307
	search(pattern, TYPE, DECLARATIONS, matchRule);
6308
	assertSearchResults(
6309
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH\n" +
6310
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH"
6311
	);
6312
}
6313
public void testBug137087l() throws CoreException {
6314
	// Search CamelCase
6315
	int matchRule = SearchPattern.R_CAMELCASE_MATCH;
6316
	String pattern = "Clonenotsupportedexception";
6317
	search(pattern, TYPE, DECLARATIONS, matchRule);
6318
	assertSearchResults(
6319
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH"
6320
	);
6321
	// Search like UI does (ie. replace it with prefix if it's not a valid CamelCase)
6322
	int validatedRule = SearchPattern.validateMatchRule(pattern, matchRule);
6323
	if (validatedRule != matchRule) {
6324
		matchRule = SearchPattern.R_PREFIX_MATCH;
6325
	}
6326
	search(pattern, TYPE, DECLARATIONS, matchRule);
6327
	assertSearchResults(
6328
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH\n" +
6329
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH"
6330
	);
6331
}
6332
public void testBug137087m() throws CoreException {
6333
	// Search CamelCase
6334
	int matchRule = SearchPattern.R_CAMELCASE_MATCH;
6335
	String pattern = "CloneNotSupportedException";
6336
	search(pattern, TYPE, DECLARATIONS, matchRule);
6337
	assertSearchResults(
6338
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH"
6339
	);
6340
	// Search like UI does (ie. replace it with prefix if it's not a valid CamelCase)
6341
	int validatedRule = SearchPattern.validateMatchRule(pattern, matchRule);
6342
	if (validatedRule != matchRule) {
6343
		matchRule = SearchPattern.R_PREFIX_MATCH;
6344
	}
6345
	search(pattern, TYPE, DECLARATIONS, matchRule);
6346
	assertSearchResults(
6347
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH\n" +
6348
		""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH"
6349
	);
6350
}
6097
}
6351
}
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java (-2 / +8 lines)
Lines 3574-3579 Link Here
3574
public void testCamelCaseTypePattern01() throws CoreException {
3574
public void testCamelCaseTypePattern01() throws CoreException {
3575
	search("RE", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH, getJavaSearchScope());
3575
	search("RE", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH, getJavaSearchScope());
3576
	assertSearchResults(
3576
	assertSearchResults(
3577
		"src/a3/References.java a3.References [References]\n" + 
3577
		""+ getExternalJCLPathString() + " java.lang.RuntimeException"
3578
		""+ getExternalJCLPathString() + " java.lang.RuntimeException"
3578
	);
3579
	);
3579
}
3580
}
Lines 3594-3600 Link Here
3594
3595
3595
public void testCamelCaseTypePattern04() throws CoreException {
3596
public void testCamelCaseTypePattern04() throws CoreException {
3596
	search("RUNTIMEEXCEPTION", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH, getJavaSearchScope());
3597
	search("RUNTIMEEXCEPTION", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH, getJavaSearchScope());
3597
	assertSearchResults("");
3598
	assertSearchResults(
3599
		""+ getExternalJCLPathString() + " java.lang.RuntimeException"
3600
	);
3598
}
3601
}
3599
3602
3600
public void testCamelCaseTypePattern05() throws CoreException {
3603
public void testCamelCaseTypePattern05() throws CoreException {
Lines 3659-3665 Link Here
3659
	);
3662
	);
3660
	assertSearchResults(
3663
	assertSearchResults(
3661
		"Unexpected all type names",
3664
		"Unexpected all type names",
3662
		"",
3665
		"AA\n" + 
3666
		"d8.AA\n" + 
3667
		"p6.AA\n" + 
3668
		"q1.AA",
3663
		requestor);
3669
		requestor);
3664
}
3670
}
3665
3671
(-)search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java (-2 / +4 lines)
Lines 471-478 Link Here
471
			}
471
			}
472
			switch(matchMode) {
472
			switch(matchMode) {
473
				case SearchPattern.R_EXACT_MATCH :
473
				case SearchPattern.R_EXACT_MATCH :
474
					if (isCamelCase) return false;
474
					if (!isCamelCase) {
475
					return matchFirstChar && CharOperation.equals(patternTypeName, typeName, isCaseSensitive);
475
						return matchFirstChar && CharOperation.equals(patternTypeName, typeName, isCaseSensitive);
476
					}
477
					// fall through next case to match as prefix if camel case failed
476
				case SearchPattern.R_PREFIX_MATCH :
478
				case SearchPattern.R_PREFIX_MATCH :
477
					return matchFirstChar && CharOperation.prefixEquals(patternTypeName, typeName, isCaseSensitive);
479
					return matchFirstChar && CharOperation.prefixEquals(patternTypeName, typeName, isCaseSensitive);
478
				case SearchPattern.R_PATTERN_MATCH :
480
				case SearchPattern.R_PATTERN_MATCH :
(-)search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java (-4 / +8 lines)
Lines 276-285 Link Here
276
	}
276
	}
277
	switch (this.matchMode) {
277
	switch (this.matchMode) {
278
		case SearchPattern.R_EXACT_MATCH:
278
		case SearchPattern.R_EXACT_MATCH:
279
			if (!this.isCamelCase && sameLength && matchFirstChar && CharOperation.equals(pattern, name, this.isCaseSensitive)) {
279
			if (!this.isCamelCase) {
280
				return POSSIBLE_FULL_MATCH;
280
				if (sameLength && matchFirstChar && CharOperation.equals(pattern, name, this.isCaseSensitive)) {
281
					return POSSIBLE_FULL_MATCH;
282
				}
283
				break;
281
			}
284
			}
282
			break;
285
			// fall through next case to match as prefix if camel case failed
283
		case SearchPattern.R_PREFIX_MATCH:
286
		case SearchPattern.R_PREFIX_MATCH:
284
			if (canBePrefix && matchFirstChar && CharOperation.prefixEquals(pattern, name, this.isCaseSensitive)) {
287
			if (canBePrefix && matchFirstChar && CharOperation.prefixEquals(pattern, name, this.isCaseSensitive)) {
285
				return POSSIBLE_PREFIX_MATCH;
288
				return POSSIBLE_PREFIX_MATCH;
Lines 692-698 Link Here
692
			}
695
			}
693
		}
696
		}
694
		if (this.matchMode == SearchPattern.R_EXACT_MATCH) {
697
		if (this.matchMode == SearchPattern.R_EXACT_MATCH) {
695
			return IMPOSSIBLE_MATCH;
698
			boolean matchPattern = CharOperation.prefixEquals(qualifiedPattern, sourceName, this.isCaseSensitive);
699
			return matchPattern ? ACCURATE_MATCH : IMPOSSIBLE_MATCH;
696
		}
700
		}
697
	}
701
	}
698
	boolean matchPattern = CharOperation.match(qualifiedPattern, sourceName, this.isCaseSensitive);
702
	boolean matchPattern = CharOperation.match(qualifiedPattern, sourceName, this.isCaseSensitive);
(-)search/org/eclipse/jdt/internal/core/search/matching/PackageReferenceLocator.java (-1 lines)
Lines 104-110 Link Here
104
	}
104
	}
105
	switch (this.matchMode) {
105
	switch (this.matchMode) {
106
		case SearchPattern.R_EXACT_MATCH:
106
		case SearchPattern.R_EXACT_MATCH:
107
			if (this.isCamelCase) break;
108
		case SearchPattern.R_PREFIX_MATCH:
107
		case SearchPattern.R_PREFIX_MATCH:
109
			if (packageName==null) packageName = CharOperation.concatWith(tokens, '.');
108
			if (packageName==null) packageName = CharOperation.concatWith(tokens, '.');
110
			if (CharOperation.prefixEquals(this.pattern.pkgName, packageName, this.isCaseSensitive)) {
109
			if (CharOperation.prefixEquals(this.pattern.pkgName, packageName, this.isCaseSensitive)) {
(-)search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java (-1 lines)
Lines 117-123 Link Here
117
		}
117
		}
118
		switch (this.matchMode) {
118
		switch (this.matchMode) {
119
			case SearchPattern.R_EXACT_MATCH:
119
			case SearchPattern.R_EXACT_MATCH:
120
				if (this.isCamelCase) break;
121
			case SearchPattern.R_PREFIX_MATCH:
120
			case SearchPattern.R_PREFIX_MATCH:
122
				if (CharOperation.prefixEquals(qualifiedPattern, qualifiedTypeName, this.isCaseSensitive)) {
121
				if (CharOperation.prefixEquals(qualifiedPattern, qualifiedTypeName, this.isCaseSensitive)) {
123
					return POSSIBLE_PREFIX_MATCH;
122
					return POSSIBLE_PREFIX_MATCH;
(-)search/org/eclipse/jdt/core/search/SearchPattern.java (-4 / +6 lines)
Lines 1786-1796 Link Here
1786
		switch (matchMode) {
1786
		switch (matchMode) {
1787
			case R_EXACT_MATCH :
1787
			case R_EXACT_MATCH :
1788
			case R_FULL_MATCH :
1788
			case R_FULL_MATCH :
1789
				if (!isCamelCase && sameLength && matchFirstChar) {
1789
				if (!isCamelCase) {
1790
					return CharOperation.equals(pattern, name, isCaseSensitive);
1790
					if (sameLength && matchFirstChar) {
1791
						return CharOperation.equals(pattern, name, isCaseSensitive);
1792
					}
1793
					break;
1791
				}
1794
				}
1792
				break;
1795
				// fall through next case to match as prefix if camel case failed
1793
1794
			case R_PREFIX_MATCH :
1796
			case R_PREFIX_MATCH :
1795
				if (canBePrefix && matchFirstChar) {
1797
				if (canBePrefix && matchFirstChar) {
1796
					return CharOperation.prefixEquals(pattern, name, isCaseSensitive);
1798
					return CharOperation.prefixEquals(pattern, name, isCaseSensitive);
(-)search/org/eclipse/jdt/internal/core/index/Index.java (-9 / +15 lines)
Lines 47-58 Link Here
47
47
48
public static boolean isMatch(char[] pattern, char[] word, int matchRule) {
48
public static boolean isMatch(char[] pattern, char[] word, int matchRule) {
49
	if (pattern == null) return true;
49
	if (pattern == null) return true;
50
	if (pattern.length == 0) return matchRule != SearchPattern.R_EXACT_MATCH;
50
	int patternLength = pattern.length;
51
	if (word.length == 0) return (matchRule & SearchPattern.R_PATTERN_MATCH) != 0 && pattern.length == 1 && pattern[0] == '*';
51
	int wordLength = word.length;
52
	if (patternLength == 0) return matchRule != SearchPattern.R_EXACT_MATCH;
53
	if (wordLength == 0) return (matchRule & SearchPattern.R_PATTERN_MATCH) != 0 && patternLength == 1 && pattern[0] == '*';
52
54
53
	// First test camel case if necessary
55
	// First test camel case if necessary
54
	boolean isCamelCase = (matchRule & SearchPattern.R_CAMELCASE_MATCH) != 0;
56
	boolean isCamelCase = (matchRule & SearchPattern.R_CAMELCASE_MATCH) != 0;
55
	if (isCamelCase && pattern[0] == word[0] && CharOperation.camelCaseMatch(pattern, word)) {
57
	if (isCamelCase &&  pattern[0] == word[0] && CharOperation.camelCaseMatch(pattern, word)) {
56
		return true;
58
		return true;
57
	}
59
	}
58
60
Lines 60-76 Link Here
60
	matchRule &= ~SearchPattern.R_CAMELCASE_MATCH;
62
	matchRule &= ~SearchPattern.R_CAMELCASE_MATCH;
61
	switch(matchRule & MATCH_RULE_INDEX_MASK) {
63
	switch(matchRule & MATCH_RULE_INDEX_MASK) {
62
		case SearchPattern.R_EXACT_MATCH :
64
		case SearchPattern.R_EXACT_MATCH :
63
			if (isCamelCase) return false;
65
			if (!isCamelCase) {
64
			return CharOperation.equals(pattern, word, false);
66
				return patternLength == wordLength && CharOperation.equals(pattern, word, false);
67
			}
68
			// fall through prefix match if camel case failed
65
		case SearchPattern.R_PREFIX_MATCH :
69
		case SearchPattern.R_PREFIX_MATCH :
66
			return CharOperation.prefixEquals(pattern, word, false);
70
			return patternLength <= wordLength && CharOperation.prefixEquals(pattern, word, false);
67
		case SearchPattern.R_PATTERN_MATCH :
71
		case SearchPattern.R_PATTERN_MATCH :
68
			return CharOperation.match(pattern, word, false);
72
			return CharOperation.match(pattern, word, false);
69
		case SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE :
73
		case SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE :
70
			if (isCamelCase) return false;
74
			if (!isCamelCase) {
71
			return pattern[0] == word[0] && CharOperation.equals(pattern, word);
75
				return pattern[0] == word[0] && patternLength == wordLength && CharOperation.equals(pattern, word);
76
			}
77
			// fall through prefix match if camel case failed
72
		case SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE :
78
		case SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE :
73
			return pattern[0] == word[0] && CharOperation.prefixEquals(pattern, word);
79
			return pattern[0] == word[0] && patternLength <= wordLength && CharOperation.prefixEquals(pattern, word);
74
		case SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE :
80
		case SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE :
75
			return CharOperation.match(pattern, word, true);
81
			return CharOperation.match(pattern, word, true);
76
	}
82
	}

Return to bug 137087