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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/InternalNamingConventions.java (-246 / +582 lines)
Lines 12-19 Link Here
12
12
13
import java.util.Map;
13
import java.util.Map;
14
14
15
import org.eclipse.jdt.core.Flags;
16
import org.eclipse.jdt.core.IJavaProject;
15
import org.eclipse.jdt.core.IJavaProject;
16
import org.eclipse.jdt.core.JavaCore;
17
import org.eclipse.jdt.core.compiler.CharOperation;
17
import org.eclipse.jdt.core.compiler.CharOperation;
18
import org.eclipse.jdt.core.compiler.InvalidInputException;
18
import org.eclipse.jdt.core.compiler.InvalidInputException;
19
import org.eclipse.jdt.internal.codeassist.impl.AssistOptions;
19
import org.eclipse.jdt.internal.codeassist.impl.AssistOptions;
Lines 37-263 Link Here
37
				null/*taskPriorities*/,
37
				null/*taskPriorities*/,
38
				true/*taskCaseSensitive*/);
38
				true/*taskCaseSensitive*/);
39
	}
39
	}
40
	public static void suggestArgumentNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[] internalPrefix, char[][] excludedNames, INamingRequestor requestor) {
41
		Map options = javaProject.getOptions(true);
42
		CompilerOptions compilerOptions = new CompilerOptions(options);
43
		AssistOptions assistOptions = new AssistOptions(options);
44
45
		suggestNames(
46
			packageName,
47
			qualifiedTypeName,
48
			dim,
49
			internalPrefix,
50
			assistOptions.argumentPrefixes,
51
			assistOptions.argumentSuffixes,
52
			excludedNames,
53
			getNameScanner(compilerOptions),
54
			requestor);
55
	}
56
	public static void suggestFieldNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, int modifiers, char[] internalPrefix, char[][] excludedNames, INamingRequestor requestor) {
57
		boolean isStatic = Flags.isStatic(modifiers);
58
59
		Map options = javaProject.getOptions(true);
60
		CompilerOptions compilerOptions = new CompilerOptions(options);
61
		AssistOptions assistOptions = new AssistOptions(options);
62
63
		suggestNames(
64
			packageName,
65
			qualifiedTypeName,
66
			dim,
67
			internalPrefix,
68
			isStatic ? assistOptions.staticFieldPrefixes : assistOptions.fieldPrefixes,
69
			isStatic ? assistOptions.staticFieldSuffixes : assistOptions.fieldSuffixes,
70
			excludedNames,
71
			getNameScanner(compilerOptions),
72
			requestor);
73
	}
74
	public static void suggestLocalVariableNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[] internalPrefix, char[][] excludedNames, INamingRequestor requestor) {
75
		Map options = javaProject.getOptions(true);
76
		CompilerOptions compilerOptions = new CompilerOptions(options);
77
		AssistOptions assistOptions = new AssistOptions(options);
78
79
		suggestNames(
80
			packageName,
81
			qualifiedTypeName,
82
			dim,
83
			internalPrefix,
84
			assistOptions.localPrefixes,
85
			assistOptions.localSuffixes,
86
			excludedNames,
87
			getNameScanner(compilerOptions),
88
			requestor);
89
	}
90
91
	private static void suggestNames(
92
		char[] packageName,
93
		char[] qualifiedTypeName,
94
		int dim,
95
		char[] internalPrefix,
96
		char[][] prefixes,
97
		char[][] suffixes,
98
		char[][] excludedNames,
99
		Scanner nameScanner,
100
		INamingRequestor requestor){
101
102
		if(qualifiedTypeName == null || qualifiedTypeName.length == 0)
103
			return;
104
105
		if(internalPrefix == null) {
106
			internalPrefix = CharOperation.NO_CHAR;
107
		} else {
108
			internalPrefix = removePrefix(internalPrefix, prefixes);
109
		}
110
111
		char[] typeName = CharOperation.lastSegment(qualifiedTypeName, '.');
112
113
		if(prefixes == null || prefixes.length == 0) {
114
			prefixes = new char[1][0];
115
		} else {
116
			int length = prefixes.length;
117
			System.arraycopy(prefixes, 0, prefixes = new char[length+1][], 0, length);
118
			prefixes[length] = CharOperation.NO_CHAR;
119
		}
120
121
		if(suffixes == null || suffixes.length == 0) {
122
			suffixes = new char[1][0];
123
		} else {
124
			int length = suffixes.length;
125
			System.arraycopy(suffixes, 0, suffixes = new char[length+1][], 0, length);
126
			suffixes[length] = CharOperation.NO_CHAR;
127
		}
128
129
		char[][] tempNames = null;
130
131
		// compute variable name for base type
132
		try{
133
			nameScanner.setSource(typeName);
134
			switch (nameScanner.getNextToken()) {
135
				case TerminalTokens.TokenNameint :
136
				case TerminalTokens.TokenNamebyte :
137
				case TerminalTokens.TokenNameshort :
138
				case TerminalTokens.TokenNamechar :
139
				case TerminalTokens.TokenNamelong :
140
				case TerminalTokens.TokenNamefloat :
141
				case TerminalTokens.TokenNamedouble :
142
				case TerminalTokens.TokenNameboolean :
143
144
					if (internalPrefix != null && internalPrefix.length > 0) return;
145
146
					char[] name = computeBaseTypeNames(typeName[0], excludedNames);
147
					if(name != null) {
148
						tempNames =  new char[][]{name};
149
					}
150
					break;
151
			}
152
		} catch(InvalidInputException e){
153
			// ignore
154
		}
155
156
		// compute variable name for non base type
157
		if(tempNames == null) {
158
			tempNames = computeNames(typeName);
159
		}
160
161
		boolean acceptDefaultName = true;
162
		SimpleSetOfCharArray foundNames = new SimpleSetOfCharArray();
163
164
		next : for (int i = 0; i < tempNames.length; i++) {
165
			char[] tempName = tempNames[i];
166
			if(dim > 0) {
167
				int length = tempName.length;
168
				if (tempName[length-1] == 's'){
169
					if(tempName.length > 1 && tempName[length-2] == 's') {
170
						System.arraycopy(tempName, 0, tempName = new char[length + 2], 0, length);
171
						tempName[length] = 'e';
172
						tempName[length+1] = 's';
173
					}
174
				} else if(tempName[length-1] == 'y') {
175
					System.arraycopy(tempName, 0, tempName = new char[length + 2], 0, length);
176
					tempName[length-1] = 'i';
177
					tempName[length] = 'e';
178
					tempName[length+1] = 's';
179
				} else {
180
					System.arraycopy(tempName, 0, tempName = new char[length + 1], 0, length);
181
					tempName[length] = 's';
182
				}
183
			}
184
185
			char[] unprefixedName = tempName;
186
			unprefixedName[0] = ScannerHelper.toUpperCase(unprefixedName[0]);
187
			for (int j = 0; j <= internalPrefix.length; j++) {
188
				if(j == internalPrefix.length ||
189
						CharOperation.prefixEquals(CharOperation.subarray(internalPrefix, j, -1), unprefixedName, j != 0 /*do not check case when there is no prefix*/)) {
190
					tempName = CharOperation.concat(CharOperation.subarray(internalPrefix, 0, j), unprefixedName);
191
					if(j == 0) tempName[0] = ScannerHelper.toLowerCase(tempName[0]);
192
					for (int k = 0; k < prefixes.length; k++) {
193
						if(prefixes[k].length > 0
194
							&& ScannerHelper.isLetterOrDigit(prefixes[k][prefixes[k].length - 1])) {
195
							tempName[0] = ScannerHelper.toUpperCase(tempName[0]);
196
						} else {
197
							tempName[0] = ScannerHelper.toLowerCase(tempName[0]);
198
						}
199
						char[] prefixName = CharOperation.concat(prefixes[k], tempName);
200
						for (int l = 0; l < suffixes.length; l++) {
201
							char[] suffixName = CharOperation.concat(prefixName, suffixes[l]);
202
							suffixName =
203
								excludeNames(
204
									suffixName,
205
									prefixName,
206
									suffixes[l],
207
									excludedNames);
208
							try{
209
								nameScanner.setSource(suffixName);
210
								switch (nameScanner.getNextToken()) {
211
									case TerminalTokens.TokenNameIdentifier :
212
										int token = nameScanner.getNextToken();
213
										if (token == TerminalTokens.TokenNameEOF && nameScanner.startPosition == suffixName.length) {
214
											if (!foundNames.includes(suffixName)) {
215
												acceptName(suffixName, prefixes[k], suffixes[l],  k == 0, l == 0, internalPrefix.length - j, requestor);
216
												foundNames.add(suffixName);
217
												acceptDefaultName = false;
218
											}
219
										}
220
										break;
221
									default:
222
										suffixName = CharOperation.concat(
223
											prefixName,
224
											String.valueOf(1).toCharArray(),
225
											suffixes[l]
226
										);
227
										suffixName =
228
											excludeNames(
229
												suffixName,
230
												prefixName,
231
												suffixes[l],
232
												excludedNames);
233
										nameScanner.setSource(suffixName);
234
										switch (nameScanner.getNextToken()) {
235
											case TerminalTokens.TokenNameIdentifier :
236
												token = nameScanner.getNextToken();
237
												if (token == TerminalTokens.TokenNameEOF && nameScanner.startPosition == suffixName.length) {
238
													if (!foundNames.includes(suffixName)) {
239
														acceptName(suffixName, prefixes[k], suffixes[l], k == 0, l == 0, internalPrefix.length - j, requestor);
240
														foundNames.add(suffixName);
241
														acceptDefaultName = false;
242
													}
243
												}
244
										}
245
								}
246
							} catch(InvalidInputException e){
247
								// ignore
248
							}
249
						}
250
					}
251
					continue next;
252
				}
253
			}
254
		}
255
		// if no names were found
256
		if(acceptDefaultName) {
257
			char[] name = excludeNames(DEFAULT_NAME, DEFAULT_NAME, CharOperation.NO_CHAR, excludedNames);
258
			requestor.acceptNameWithoutPrefixAndSuffix(name, 0);
259
		}
260
	}
261
40
262
	private static void acceptName(
41
	private static void acceptName(
263
		char[] name,
42
		char[] name,
Lines 278-283 Link Here
278
		}
57
		}
279
	}
58
	}
280
59
60
	private static char[][] computeBaseTypeNames(char[] typeName, boolean isConstantField, char[][] excludedNames){
61
		char[] name = computeBaseTypeNames(typeName[0], excludedNames);
62
		if(name != null) {
63
			return new char[][]{name};
64
		} else {
65
			// compute variable name like from non base type
66
			return  computeNonBaseTypeNames(typeName, isConstantField);
67
		}
68
	}
281
	private static char[] computeBaseTypeNames(char firstName, char[][] excludedNames){
69
	private static char[] computeBaseTypeNames(char firstName, char[][] excludedNames){
282
		char[] name = new char[]{firstName};
70
		char[] name = new char[]{firstName};
283
71
Lines 294-327 Link Here
294
82
295
		return name;
83
		return name;
296
	}
84
	}
297
85
	
298
	private static char[][] computeNames(char[] sourceName){
86
	private static char[][] computeNonBaseTypeNames(char[] sourceName, boolean isConstantField){
299
		char[][] names = new char[5][];
87
		int length = sourceName.length;
300
		int nameCount = 0;
88
		
301
		boolean previousIsUpperCase = false;
89
		if (length == 0) {
302
		boolean previousIsLetter = true;
90
			return CharOperation.NO_CHAR_CHAR;
303
		for(int i = sourceName.length - 1 ; i >= 0 ; i--){
91
		}
304
			boolean isUpperCase = ScannerHelper.isUpperCase(sourceName[i]);
92
		
305
			boolean isLetter = ScannerHelper.isLetter(sourceName[i]);
93
		if (length == 1) {
306
			if(isUpperCase && !previousIsUpperCase && previousIsLetter){
94
			return new char[][]{CharOperation.toLowerCase(sourceName)};
307
				char[] name = CharOperation.subarray(sourceName,i,sourceName.length);
95
		}
308
				if(name.length > 1){
96
		
309
					if(nameCount == names.length) {
97
		char[][] nameParts = new char[length][];
310
						System.arraycopy(names, 0, names = new char[nameCount * 2][], 0, nameCount);
98
		int namePartsPtr = -1;
311
					}
99
		
312
					name[0] = ScannerHelper.toLowerCase(name[0]);
100
		int endIndex = length;
313
					names[nameCount++] = name;
101
		char c = sourceName[length - 1];
314
				}
102
		
103
		final int IS_LOWER_CASE = 1;
104
		final int IS_UPPER_CASE = 2;
105
		final int IS_UNDERSCORE = 3;
106
		final int IS_OTHER = 4;
107
		
108
		int previousCharKind =
109
			ScannerHelper.isLowerCase(c) ? IS_LOWER_CASE :
110
				ScannerHelper.isUpperCase(c) ? IS_UPPER_CASE :
111
					c == '_' ? IS_UNDERSCORE : IS_OTHER;
112
		
113
		for(int i = length - 1 ; i >= 0 ; i--){
114
			c = sourceName[i];
115
			
116
			int charKind =
117
				ScannerHelper.isLowerCase(c) ? IS_LOWER_CASE :
118
					ScannerHelper.isUpperCase(c) ? IS_UPPER_CASE :
119
						c == '_' ? IS_UNDERSCORE : IS_OTHER;
120
			
121
			switch (charKind) {
122
				case IS_LOWER_CASE:
123
					if (previousCharKind == IS_UPPER_CASE) {
124
						nameParts[++namePartsPtr] = CharOperation.subarray(sourceName, i + 1, endIndex);
125
						endIndex = i + 1;
126
					}
127
					previousCharKind = IS_LOWER_CASE;
128
					break;
129
				case IS_UPPER_CASE:
130
					if (previousCharKind == IS_LOWER_CASE) {
131
						nameParts[++namePartsPtr] = CharOperation.subarray(sourceName, i, endIndex);
132
						if (i > 0) {
133
							char pc = sourceName[i - 1];
134
							previousCharKind =
135
								ScannerHelper.isLowerCase(pc) ? IS_LOWER_CASE :
136
									ScannerHelper.isUpperCase(pc) ? IS_UPPER_CASE :
137
										pc == '_' ? IS_UNDERSCORE : IS_OTHER;
138
						}
139
						endIndex = i;
140
					} else {
141
						previousCharKind = IS_UPPER_CASE;
142
					}
143
					break;
144
				case IS_UNDERSCORE:
145
					switch (previousCharKind) {
146
						case IS_UNDERSCORE:
147
							if (i > 0) {
148
								char pc = sourceName[i - 1];
149
								previousCharKind =
150
									ScannerHelper.isLowerCase(pc) ? IS_LOWER_CASE :
151
										ScannerHelper.isUpperCase(pc) ? IS_UPPER_CASE :
152
											pc == '_' ? IS_UNDERSCORE : IS_OTHER;
153
							}
154
							endIndex = i;
155
							break;
156
						case IS_LOWER_CASE:
157
						case IS_UPPER_CASE:
158
							nameParts[++namePartsPtr] = CharOperation.subarray(sourceName, i + 1, endIndex);
159
							if (i > 0) {
160
								char pc = sourceName[i - 1];
161
								previousCharKind =
162
									ScannerHelper.isLowerCase(pc) ? IS_LOWER_CASE :
163
										ScannerHelper.isUpperCase(pc) ? IS_UPPER_CASE :
164
											pc == '_' ? IS_UNDERSCORE : IS_OTHER;
165
							}
166
							endIndex = i;
167
							break;
168
						default:
169
							previousCharKind = IS_UNDERSCORE;
170
							break;
171
					}
172
					break;
173
				default:
174
					previousCharKind = IS_OTHER;
175
					break;
315
			}
176
			}
316
			previousIsUpperCase = isUpperCase;
317
			previousIsLetter = isLetter;
318
		}
177
		}
319
		if(nameCount == 0){
178
		if (endIndex > 0) {
320
			names[nameCount++] = CharOperation.toLowerCase(sourceName);
179
			nameParts[++namePartsPtr] = CharOperation.subarray(sourceName, 0, endIndex);
180
		}
181
		
182
		if (isConstantField) {
183
			return generateConstantName(nameParts, namePartsPtr);
184
		} else {
185
			return generateNonConstantName(nameParts, namePartsPtr);
321
		}
186
		}
322
		System.arraycopy(names, 0, names = new char[nameCount][], 0, nameCount);
323
		return names;
324
	}
187
	}
188
	
189
	
325
190
326
	private static char[] excludeNames(
191
	private static char[] excludeNames(
327
		char[] suffixName,
192
		char[] suffixName,
Lines 344-349 Link Here
344
		}
209
		}
345
		return suffixName;
210
		return suffixName;
346
	}
211
	}
212
	
213
	private static char[][] generateNonConstantName(char[][] nameParts, int namePartsPtr) {
214
		char[][] names = new char[namePartsPtr + 1][];
215
		
216
		char[] namePart = CharOperation.toLowerCase(nameParts[0]);
217
		int namePartLength = namePart.length;
218
		System.arraycopy(namePart, 0, namePart, 0, namePartLength);
219
		
220
		char[] name = namePart;
221
		
222
		names[namePartsPtr] = name;
223
		
224
		for (int i = 1; i <= namePartsPtr; i++) {
225
			namePart = CharOperation.toLowerCase(nameParts[i]);
226
			namePartLength = namePart.length;
227
			name = CharOperation.concat(namePart, name);
228
			name[namePartLength] = ScannerHelper.toUpperCase(name[namePartLength]);
229
			
230
			names[namePartsPtr - i] = name;
231
		}
232
		return names;
233
	}
234
235
	private static char[][] generateConstantName(char[][] nameParts, int namePartsPtr) {
236
		char[][] names = new char[namePartsPtr + 1][];
237
		
238
		char[] namePart = CharOperation.toUpperCase(nameParts[0]);
239
		int namePartLength = namePart.length;
240
		System.arraycopy(namePart, 0, namePart, 0, namePartLength);
241
		
242
		char[] name = namePart;
243
		
244
		names[namePartsPtr] = name;
245
		
246
		for (int i = 1; i <= namePartsPtr; i++) {
247
			namePart = CharOperation.toUpperCase(nameParts[i]);
248
			namePartLength = namePart.length;
249
			if (namePart[namePartLength - 1] != '_') {
250
				name = CharOperation.concat(namePart, name, '_');
251
			} else {
252
				name = CharOperation.concat(namePart, name);
253
			}
254
			
255
			names[namePartsPtr - i] = name;
256
		}
257
		return names;
258
	}
259
	
260
	public static char[] getBaseName(
261
			int variableKind,
262
			IJavaProject javaProject,
263
			char[] name) {
264
		
265
		AssistOptions assistOptions;
266
		if (javaProject != null) {
267
			assistOptions = new AssistOptions(javaProject.getOptions(true));
268
		} else {
269
			assistOptions = new AssistOptions(JavaCore.getOptions());
270
		}
271
		
272
		char[][] prefixes = null;
273
		char[][] suffixes = null;
274
		switch (variableKind) {
275
			case VK_INSTANCE_FIELD:
276
				prefixes = assistOptions.fieldPrefixes;
277
				suffixes = assistOptions.fieldSuffixes;
278
				break;
279
			case VK_STATIC_FIELD:
280
				prefixes = assistOptions.staticFieldPrefixes;
281
				suffixes = assistOptions.staticFieldSuffixes;
282
				break;
283
			case VK_CONSTANT_FIELD:
284
				prefixes = assistOptions.staticFinalFieldPrefixes;
285
				suffixes = assistOptions.staticFinalFieldSuffixes;
286
				break;
287
			case VK_LOCAL:
288
				prefixes = assistOptions.localPrefixes;
289
				suffixes = assistOptions.localSuffixes;
290
				break;
291
			case VK_PARAMETER:
292
				prefixes = assistOptions.argumentPrefixes;
293
				suffixes = assistOptions.argumentSuffixes;
294
				break;
295
		}
296
		
297
		
298
		return getBaseName(name, prefixes, suffixes, variableKind == VK_CONSTANT_FIELD);
299
	}
300
301
	private static char[] getBaseName(char[] name, char[][] prefixes, char[][] suffixes, boolean isConstant) {
302
		char[] nameWithoutPrefixAndSiffix = removeVariablePrefixAndSuffix(name, prefixes, suffixes, false);
303
		
304
		char[] baseName;
305
		if (isConstant) {
306
			int length = nameWithoutPrefixAndSiffix.length;
307
			baseName = new char[length];
308
			int baseNamePtr = -1;
309
			
310
			boolean previousIsUnderscore = false;
311
			for (int i = 0; i < length; i++) {
312
				char c = nameWithoutPrefixAndSiffix[i];
313
				if (c != '_') {
314
					if (previousIsUnderscore || i == 0) {
315
						baseName[++baseNamePtr] = ScannerHelper.toUpperCase(c);
316
						previousIsUnderscore = false;
317
					} else {
318
						baseName[++baseNamePtr] = ScannerHelper.toLowerCase(c);
319
					}
320
				} else {
321
					previousIsUnderscore = true;
322
				}
323
			}
324
			System.arraycopy(baseName, 0, baseName = new char[baseNamePtr + 1], 0, baseNamePtr + 1);
325
		} else {
326
			baseName = nameWithoutPrefixAndSiffix;
327
		}
328
		
329
		return baseName;
330
	}
331
	
332
	public static char[] removeVariablePrefixAndSuffix(
333
			int variableKind,
334
			IJavaProject javaProject,
335
			char[] name) {
336
		AssistOptions assistOptions;
337
		if (javaProject != null) {
338
			assistOptions = new AssistOptions(javaProject.getOptions(true));
339
		} else {
340
			assistOptions = new AssistOptions(JavaCore.getOptions());
341
		}
342
		
343
		char[][] prefixes = null;
344
		char[][] suffixes = null;
345
		switch (variableKind) {
346
			case VK_INSTANCE_FIELD:
347
				prefixes = assistOptions.fieldPrefixes;
348
				suffixes = assistOptions.fieldSuffixes;
349
				break;
350
			case VK_STATIC_FIELD:
351
				prefixes = assistOptions.staticFieldPrefixes;
352
				suffixes = assistOptions.staticFieldSuffixes;
353
				break;
354
			case VK_CONSTANT_FIELD:
355
				prefixes = assistOptions.staticFinalFieldPrefixes;
356
				suffixes = assistOptions.staticFinalFieldSuffixes;
357
				break;
358
			case VK_LOCAL:
359
				prefixes = assistOptions.localPrefixes;
360
				suffixes = assistOptions.localSuffixes;
361
				break;
362
			case VK_PARAMETER:
363
				prefixes = assistOptions.argumentPrefixes;
364
				suffixes = assistOptions.argumentSuffixes;
365
				break;
366
		}
367
		
368
		return InternalNamingConventions.removeVariablePrefixAndSuffix(name,	prefixes, suffixes, true);
369
	}
370
	
371
	private static char[] removeVariablePrefixAndSuffix(char[] name, char[][] prefixes, char[][] suffixes, boolean updateFirstCharacter) {
372
		// remove longer prefix
373
		char[] withoutPrefixName = name;
374
		if (prefixes != null) {
375
			int bestLength = 0;
376
			for (int i= 0; i < prefixes.length; i++) {
377
				char[] prefix = prefixes[i];
378
				if (CharOperation.prefixEquals(prefix, name)) {
379
					int currLen = prefix.length;
380
					boolean lastCharIsLetter = ScannerHelper.isLetter(prefix[currLen - 1]);
381
					if(!lastCharIsLetter || (lastCharIsLetter && name.length > currLen && ScannerHelper.isUpperCase(name[currLen]))) {
382
						if (bestLength < currLen && name.length != currLen) {
383
							withoutPrefixName = CharOperation.subarray(name, currLen, name.length);
384
							bestLength = currLen;
385
						}
386
					}
387
				}
388
			}
389
		}
390
391
		// remove longer suffix
392
		char[] withoutSuffixName = withoutPrefixName;
393
		if(suffixes != null) {
394
			int bestLength = 0;
395
			for (int i = 0; i < suffixes.length; i++) {
396
				char[] suffix = suffixes[i];
397
				if(CharOperation.endsWith(withoutPrefixName, suffix)) {
398
					int currLen = suffix.length;
399
					if(bestLength < currLen && withoutPrefixName.length != currLen) {
400
						withoutSuffixName = CharOperation.subarray(withoutPrefixName, 0, withoutPrefixName.length - currLen);
401
						bestLength = currLen;
402
					}
403
				}
404
			}
405
		}
406
407
		if (updateFirstCharacter) withoutSuffixName[0] = ScannerHelper.toLowerCase(withoutSuffixName[0]);
408
		return withoutSuffixName;
409
	}
347
410
348
	private static char[] removePrefix(char[] name, char[][] prefixes) {
411
	private static char[] removePrefix(char[] name, char[][] prefixes) {
349
		// remove longer prefix
412
		// remove longer prefix
Lines 430-433 Link Here
430
					return false;
493
					return false;
431
			return true;
494
			return true;
432
	}
495
	}
496
	
497
	public static final int VK_STATIC_FIELD = 1;
498
	public static final int VK_INSTANCE_FIELD = 2;
499
	public static final int VK_CONSTANT_FIELD = 3;
500
	public static final int VK_PARAMETER = 4;
501
	public static final int VK_LOCAL = 5;
502
	
503
	public static final int BK_SIMPLE_NAME = 1;
504
	public static final int BK_SIMPLE_TYPE_NAME = 2;
505
506
	public static void suggestVariableNames(
507
			int variableKind,
508
			int baseNameKind,
509
			char[] baseName,
510
			IJavaProject javaProject,
511
			int dim,
512
			char[] internalPrefix,
513
			char[][] excluded,
514
			boolean evaluateDefault,
515
			INamingRequestor requestor) {
516
		
517
		if(baseName == null || baseName.length == 0)
518
			return;
519
		
520
		Map options;
521
		if (javaProject != null) {
522
			options = javaProject.getOptions(true);
523
		} else {
524
			options = JavaCore.getOptions();
525
		}
526
		CompilerOptions compilerOptions = new CompilerOptions(options);
527
		AssistOptions assistOptions = new AssistOptions(options);
528
		
529
		boolean isConstantField = false;
530
		
531
		char[][] prefixes = null;
532
		char[][] suffixes = null;
533
		switch (variableKind) {
534
			case VK_INSTANCE_FIELD:
535
				prefixes = assistOptions.fieldPrefixes;
536
				suffixes = assistOptions.fieldSuffixes;
537
				break;
538
			case VK_STATIC_FIELD:
539
				prefixes = assistOptions.staticFieldPrefixes;
540
				suffixes = assistOptions.staticFieldSuffixes;
541
				break;
542
			case VK_CONSTANT_FIELD:
543
				isConstantField = true;
544
				prefixes = assistOptions.staticFinalFieldPrefixes;
545
				suffixes = assistOptions.staticFinalFieldSuffixes;
546
				break;
547
			case VK_LOCAL:
548
				prefixes = assistOptions.localPrefixes;
549
				suffixes = assistOptions.localSuffixes;
550
				break;
551
			case VK_PARAMETER:
552
				prefixes = assistOptions.argumentPrefixes;
553
				suffixes = assistOptions.argumentSuffixes;
554
				break;
555
		}
556
		
557
		if(prefixes == null || prefixes.length == 0) {
558
			prefixes = new char[1][0];
559
		} else {
560
			int length = prefixes.length;
561
			System.arraycopy(prefixes, 0, prefixes = new char[length+1][], 0, length);
562
			prefixes[length] = CharOperation.NO_CHAR;
563
		}
564
565
		if(suffixes == null || suffixes.length == 0) {
566
			suffixes = new char[1][0];
567
		} else {
568
			int length = suffixes.length;
569
			System.arraycopy(suffixes, 0, suffixes = new char[length+1][], 0, length);
570
			suffixes[length] = CharOperation.NO_CHAR;
571
		}
572
		
573
		if(internalPrefix == null) {
574
			internalPrefix = CharOperation.NO_CHAR;
575
		} else {
576
			internalPrefix = removePrefix(internalPrefix, prefixes);
577
		}
578
579
		char[][] tempNames = null;
580
		
581
		Scanner nameScanner = getNameScanner(compilerOptions);
582
		if (baseNameKind == BK_SIMPLE_TYPE_NAME) {
583
			boolean isBaseType = false;
584
			
585
			try{
586
				nameScanner.setSource(baseName);
587
				switch (nameScanner.getNextToken()) {
588
					case TerminalTokens.TokenNameint :
589
					case TerminalTokens.TokenNamebyte :
590
					case TerminalTokens.TokenNameshort :
591
					case TerminalTokens.TokenNamechar :
592
					case TerminalTokens.TokenNamelong :
593
					case TerminalTokens.TokenNamefloat :
594
					case TerminalTokens.TokenNamedouble :
595
					case TerminalTokens.TokenNameboolean :
596
						isBaseType = true;
597
						break;
598
				}
599
			} catch(InvalidInputException e){
600
				// ignore
601
			}
602
			if (isBaseType) {
603
				// compute variable name from base type
604
				if (internalPrefix.length > 0) return;
605
	
606
				tempNames = computeBaseTypeNames(baseName, isConstantField, excluded);
607
			} else {
608
				// compute variable name for non base type
609
				tempNames = computeNonBaseTypeNames(baseName, isConstantField);
610
			}
611
		} else {
612
			tempNames = new char[][]{baseName};
613
		}
614
615
		boolean acceptDefaultName = true;
616
		SimpleSetOfCharArray foundNames = new SimpleSetOfCharArray();
617
618
		for (int i = 0; i < tempNames.length; i++) {
619
			char[] tempName = tempNames[i];
620
			
621
			// add English plural form is necessary
622
			if(dim > 0) {
623
				int length = tempName.length;
624
				
625
				if (isConstantField) {
626
					if (tempName[length-1] == 'S'){
627
						if(tempName.length > 1 && tempName[length-2] == 'S') {
628
							System.arraycopy(tempName, 0, tempName = new char[length + 2], 0, length);
629
							tempName[length] = 'E';
630
							tempName[length+1] = 'S';
631
						}
632
					} else if(tempName[length-1] == 'Y') {
633
						System.arraycopy(tempName, 0, tempName = new char[length + 2], 0, length);
634
						tempName[length-1] = 'I';
635
						tempName[length] = 'E';
636
						tempName[length+1] = 'S';
637
					} else {
638
						System.arraycopy(tempName, 0, tempName = new char[length + 1], 0, length);
639
						tempName[length] = 'S';
640
					}
641
				} else {
642
					if (tempName[length-1] == 's'){
643
						if(tempName.length > 1 && tempName[length-2] == 's') {
644
							System.arraycopy(tempName, 0, tempName = new char[length + 2], 0, length);
645
							tempName[length] = 'e';
646
							tempName[length+1] = 's';
647
						}
648
					} else if(tempName[length-1] == 'y') {
649
						System.arraycopy(tempName, 0, tempName = new char[length + 2], 0, length);
650
						tempName[length-1] = 'i';
651
						tempName[length] = 'e';
652
						tempName[length+1] = 's';
653
					} else {
654
						System.arraycopy(tempName, 0, tempName = new char[length + 1], 0, length);
655
						tempName[length] = 's';
656
					}
657
				}
658
			}
659
			
660
			char[] unprefixedName = tempName;
661
			
662
			int matchingIndex = -1;
663
			if (!isConstantField) {
664
				unprefixedName[0] = ScannerHelper.toUpperCase(unprefixedName[0]);
665
				
666
				done : for (int j = 0; j <= internalPrefix.length; j++) {
667
					if(j == internalPrefix.length ||
668
							CharOperation.prefixEquals(CharOperation.subarray(internalPrefix, j, -1), unprefixedName, j != 0 /*do not check case when there is no prefix*/)) {
669
						matchingIndex = j;
670
						break done;
671
					}
672
				}
673
			} else {
674
				done : for (int j = 0; j <= internalPrefix.length; j++) {
675
					if(j == internalPrefix.length) {
676
						matchingIndex = j;
677
						break done;
678
					} else if(CharOperation.prefixEquals(CharOperation.subarray(internalPrefix, j, -1), unprefixedName, j != 0 /*do not check case when there is no prefix*/)) {
679
						if (j == 0 || internalPrefix[j - 1] == '_') {
680
							matchingIndex = j;
681
							break done;
682
						}
683
						
684
					}
685
				}
686
			}
687
688
			if(matchingIndex > -1) {
689
				if (!isConstantField) {
690
					tempName = CharOperation.concat(CharOperation.subarray(internalPrefix, 0, matchingIndex), unprefixedName);
691
					if(matchingIndex == 0) tempName[0] = ScannerHelper.toLowerCase(tempName[0]);
692
				} else {
693
					if(matchingIndex != 0 && tempName[0] != '_' && internalPrefix[matchingIndex - 1] != '_') {
694
						tempName = CharOperation.concat(CharOperation.subarray(CharOperation.toUpperCase(internalPrefix), 0, matchingIndex), unprefixedName, '_');
695
					} else {
696
						tempName = CharOperation.concat(CharOperation.subarray(CharOperation.toUpperCase(internalPrefix), 0, matchingIndex), unprefixedName);
697
					}
698
				}
699
				
700
				for (int k = 0; k < prefixes.length; k++) {
701
					if (!isConstantField) {
702
						if(prefixes[k].length > 0
703
							&& ScannerHelper.isLetterOrDigit(prefixes[k][prefixes[k].length - 1])) {
704
							tempName[0] = ScannerHelper.toUpperCase(tempName[0]);
705
						} else {
706
							tempName[0] = ScannerHelper.toLowerCase(tempName[0]);
707
						}
708
					}
709
					char[] prefixName = CharOperation.concat(prefixes[k], tempName);
710
					for (int l = 0; l < suffixes.length; l++) {
711
						char[] suffixName = CharOperation.concat(prefixName, suffixes[l]);
712
						suffixName =
713
							excludeNames(
714
								suffixName,
715
								prefixName,
716
								suffixes[l],
717
								excluded);
718
						try{
719
							nameScanner.setSource(suffixName);
720
							switch (nameScanner.getNextToken()) {
721
								case TerminalTokens.TokenNameIdentifier :
722
									int token = nameScanner.getNextToken();
723
									if (token == TerminalTokens.TokenNameEOF && nameScanner.startPosition == suffixName.length) {
724
										if (!foundNames.includes(suffixName)) {
725
											acceptName(suffixName, prefixes[k], suffixes[l],  k == 0, l == 0, internalPrefix.length - matchingIndex, requestor);
726
											foundNames.add(suffixName);
727
											acceptDefaultName = false;
728
										}
729
									}
730
									break;
731
								default:
732
									suffixName = CharOperation.concat(
733
										prefixName,
734
										String.valueOf(1).toCharArray(),
735
										suffixes[l]
736
									);
737
									suffixName =
738
										excludeNames(
739
											suffixName,
740
											prefixName,
741
											suffixes[l],
742
											excluded);
743
									nameScanner.setSource(suffixName);
744
									switch (nameScanner.getNextToken()) {
745
										case TerminalTokens.TokenNameIdentifier :
746
											token = nameScanner.getNextToken();
747
											if (token == TerminalTokens.TokenNameEOF && nameScanner.startPosition == suffixName.length) {
748
												if (!foundNames.includes(suffixName)) {
749
													acceptName(suffixName, prefixes[k], suffixes[l], k == 0, l == 0, internalPrefix.length - matchingIndex, requestor);
750
													foundNames.add(suffixName);
751
													acceptDefaultName = false;
752
												}
753
											}
754
									}
755
							}
756
						} catch(InvalidInputException e){
757
							// ignore
758
						}
759
					}
760
				}
761
			}
762
		}
763
		// if no names were found
764
		if(evaluateDefault && acceptDefaultName) {
765
			char[] name = excludeNames(DEFAULT_NAME, DEFAULT_NAME, CharOperation.NO_CHAR, excluded);
766
			requestor.acceptNameWithoutPrefixAndSuffix(name, 0);
767
		}
768
	}
433
}
769
}
(-)model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java (+2 lines)
Lines 77-86 Link Here
77
		defaultOptionsMap.put(JavaCore.CODEASSIST_IMPLICIT_QUALIFICATION, JavaCore.DISABLED);
77
		defaultOptionsMap.put(JavaCore.CODEASSIST_IMPLICIT_QUALIFICATION, JavaCore.DISABLED);
78
		defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
78
		defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
79
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
79
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
80
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXES, ""); //$NON-NLS-1$
80
		defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
81
		defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
81
		defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
82
		defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
82
		defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
83
		defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
83
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
84
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
85
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES, ""); //$NON-NLS-1$
84
		defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
86
		defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
85
		defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
87
		defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
86
		defaultOptionsMap.put(JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaCore.ENABLED);
88
		defaultOptionsMap.put(JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaCore.ENABLED);
(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (+2 lines)
Lines 1965-1974 Link Here
1965
		defaultOptionsMap.put(JavaCore.CODEASSIST_IMPLICIT_QUALIFICATION, JavaCore.DISABLED);
1965
		defaultOptionsMap.put(JavaCore.CODEASSIST_IMPLICIT_QUALIFICATION, JavaCore.DISABLED);
1966
		defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
1966
		defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
1967
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
1967
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
1968
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXES, ""); //$NON-NLS-1$
1968
		defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
1969
		defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
1969
		defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
1970
		defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
1970
		defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
1971
		defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
1971
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
1972
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
1973
		defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES, ""); //$NON-NLS-1$
1972
		defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
1974
		defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
1973
		defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
1975
		defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
1974
		defaultOptionsMap.put(JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaCore.ENABLED);
1976
		defaultOptionsMap.put(JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaCore.ENABLED);
(-)model/org/eclipse/jdt/core/JavaCore.java (+26 lines)
Lines 1812-1817 Link Here
1812
	 */
1812
	 */
1813
	public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
1813
	public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
1814
	/**
1814
	/**
1815
	 * Code assist option ID: Define the Prefixes for Static Final Field Name.
1816
	 * <p>When the prefixes is non empty, completion for static final field name will begin with
1817
	 *    one of the proposed prefixes.
1818
	 * <dl>
1819
	 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes"</code></dd>
1820
	 * <dt>Possible values:</dt><dd><code>{ "&lt;prefix&gt;[,&lt;prefix&gt;]*" }</code> where <code>&lt;prefix&gt;</code> is a String without any wild-card</dd>
1821
	 * <dt>Default:</dt><dd><code>""</code></dd>
1822
	 * </dl>
1823
	 * @since 3.5
1824
	 * @category CodeAssistOptionID
1825
	 */
1826
	public static final String CODEASSIST_STATIC_FINAL_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.staticFinalFieldPrefixes"; //$NON-NLS-1$
1827
	/**
1815
	 * Code assist option ID: Define the Prefixes for Local Variable Name.
1828
	 * Code assist option ID: Define the Prefixes for Local Variable Name.
1816
	 * <p>When the prefixes is non empty, completion for local variable name will begin with
1829
	 * <p>When the prefixes is non empty, completion for local variable name will begin with
1817
	 *    one of the proposed prefixes.
1830
	 *    one of the proposed prefixes.
Lines 1864-1869 Link Here
1864
	 */
1877
	 */
1865
	public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
1878
	public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
1866
	/**
1879
	/**
1880
	 * Code assist option ID: Define the Suffixes for Static Final Field Name.
1881
	 * <p>When the suffixes is non empty, completion for static final field name will end with
1882
	 *    one of the proposed suffixes.
1883
	 * <dl>
1884
	 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes"</code></dd>
1885
	 * <dt>Possible values:</dt><dd><code>{ "&lt;suffix&gt;[,&lt;suffix&gt;]*" }</code>< where <code>&lt;suffix&gt;</code> is a String without any wild-card</dd>
1886
	 * <dt>Default:</dt><dd><code>""</code></dd>
1887
	 * </dl>
1888
	 * @since 3.5
1889
	 * @category CodeAssistOptionID
1890
	 */
1891
	public static final String CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.staticFinalFieldSuffixes"; //$NON-NLS-1$
1892
	/**
1867
	 * Code assist option ID: Define the Suffixes for Local Variable Name.
1893
	 * Code assist option ID: Define the Suffixes for Local Variable Name.
1868
	 * <p>When the suffixes is non empty, completion for local variable name will end with
1894
	 * <p>When the suffixes is non empty, completion for local variable name will end with
1869
	 *    one of the proposed suffixes.
1895
	 *    one of the proposed suffixes.
(-)model/org/eclipse/jdt/core/NamingConventions.java (-244 / +408 lines)
Lines 11-17 Link Here
11
package org.eclipse.jdt.core;
11
package org.eclipse.jdt.core;
12
12
13
import org.eclipse.jdt.core.compiler.CharOperation;
13
import org.eclipse.jdt.core.compiler.CharOperation;
14
import org.eclipse.jdt.internal.codeassist.impl.AssistOptions;
15
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
14
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
16
import org.eclipse.jdt.internal.core.INamingRequestor;
15
import org.eclipse.jdt.internal.core.INamingRequestor;
17
import org.eclipse.jdt.internal.core.InternalNamingConventions;
16
import org.eclipse.jdt.internal.core.InternalNamingConventions;
Lines 48-57 Link Here
48
 * @noinstantiate This class is not intended to be instantiated by clients.
47
 * @noinstantiate This class is not intended to be instantiated by clients.
49
 */
48
 */
50
public final class NamingConventions {
49
public final class NamingConventions {
51
	private static final char[] GETTER_BOOL_NAME = "is".toCharArray(); //$NON-NLS-1$
52
	private static final char[] GETTER_NAME = "get".toCharArray(); //$NON-NLS-1$
53
	private static final char[] SETTER_NAME = "set".toCharArray(); //$NON-NLS-1$
54
55
	static class NamingRequestor implements INamingRequestor {
50
	static class NamingRequestor implements INamingRequestor {
56
		private final static int SIZE = 10;
51
		private final static int SIZE = 10;
57
52
Lines 80-85 Link Here
80
		// for acceptNameWithoutPrefixAndSuffix
75
		// for acceptNameWithoutPrefixAndSuffix
81
		private char[][] otherResults = new char[SIZE][];
76
		private char[][] otherResults = new char[SIZE][];
82
		private int otherResultsCount = 0;
77
		private int otherResultsCount = 0;
78
		public void acceptNameWithoutPrefixAndSuffix(char[] name, int reusedCharacters) {
79
			int length = this.otherResults.length;
80
			if(length == this.otherResultsCount) {
81
				System.arraycopy(
82
					this.otherResults,
83
					0,
84
					this.otherResults = new char[length * 2][],
85
					0,
86
					length);
87
			}
88
			this.otherResults[this.otherResultsCount++] = name;
89
		}
90
91
		public void acceptNameWithPrefix(char[] name, boolean isFirstPrefix, int reusedCharacters) {
92
			if(isFirstPrefix) {
93
				int length = this.firstPrefixResults.length;
94
				if(length == this.firstPrefixResultsCount) {
95
					System.arraycopy(
96
						this.firstPrefixResults,
97
						0,
98
						this.firstPrefixResults = new char[length * 2][],
99
						0,
100
						length);
101
				}
102
				this.firstPrefixResults[this.firstPrefixResultsCount++] = name;
103
			} else{
104
				int length = this.prefixResults.length;
105
				if(length == this.prefixResultsCount) {
106
					System.arraycopy(
107
						this.prefixResults,
108
						0,
109
						this.prefixResults = new char[length * 2][],
110
						0,
111
						length);
112
				}
113
				this.prefixResults[this.prefixResultsCount++] = name;
114
			}
115
		}
116
83
		public void acceptNameWithPrefixAndSuffix(char[] name, boolean isFirstPrefix, boolean isFirstSuffix, int reusedCharacters) {
117
		public void acceptNameWithPrefixAndSuffix(char[] name, boolean isFirstPrefix, boolean isFirstSuffix, int reusedCharacters) {
84
			if(isFirstPrefix && isFirstSuffix) {
118
			if(isFirstPrefix && isFirstSuffix) {
85
				int length = this.firstPrefixAndFirstSuffixResults.length;
119
				int length = this.firstPrefixAndFirstSuffixResults.length;
Lines 128-159 Link Here
128
			}
162
			}
129
		}
163
		}
130
164
131
		public void acceptNameWithPrefix(char[] name, boolean isFirstPrefix, int reusedCharacters) {
132
			if(isFirstPrefix) {
133
				int length = this.firstPrefixResults.length;
134
				if(length == this.firstPrefixResultsCount) {
135
					System.arraycopy(
136
						this.firstPrefixResults,
137
						0,
138
						this.firstPrefixResults = new char[length * 2][],
139
						0,
140
						length);
141
				}
142
				this.firstPrefixResults[this.firstPrefixResultsCount++] = name;
143
			} else{
144
				int length = this.prefixResults.length;
145
				if(length == this.prefixResultsCount) {
146
					System.arraycopy(
147
						this.prefixResults,
148
						0,
149
						this.prefixResults = new char[length * 2][],
150
						0,
151
						length);
152
				}
153
				this.prefixResults[this.prefixResultsCount++] = name;
154
			}
155
		}
156
157
		public void acceptNameWithSuffix(char[] name, boolean isFirstSuffix, int reusedCharacters) {
165
		public void acceptNameWithSuffix(char[] name, boolean isFirstSuffix, int reusedCharacters) {
158
			if(isFirstSuffix) {
166
			if(isFirstSuffix) {
159
				int length = this.firstSuffixResults.length;
167
				int length = this.firstSuffixResults.length;
Lines 179-197 Link Here
179
				this.suffixResults[this.suffixResultsCount++] = name;
187
				this.suffixResults[this.suffixResultsCount++] = name;
180
			}
188
			}
181
		}
189
		}
182
183
		public void acceptNameWithoutPrefixAndSuffix(char[] name, int reusedCharacters) {
184
			int length = this.otherResults.length;
185
			if(length == this.otherResultsCount) {
186
				System.arraycopy(
187
					this.otherResults,
188
					0,
189
					this.otherResults = new char[length * 2][],
190
					0,
191
					length);
192
			}
193
			this.otherResults[this.otherResultsCount++] = name;
194
		}
195
		public char[][] getResults(){
190
		public char[][] getResults(){
196
			int count =
191
			int count =
197
				this.firstPrefixAndFirstSuffixResultsCount
192
				this.firstPrefixAndFirstSuffixResultsCount
Lines 228-277 Link Here
228
			return results;
223
			return results;
229
		}
224
		}
230
	}
225
	}
226
	private static final char[] GETTER_BOOL_NAME = "is".toCharArray(); //$NON-NLS-1$
227
	private static final char[] GETTER_NAME = "get".toCharArray(); //$NON-NLS-1$
231
228
229
	private static final char[] SETTER_NAME = "set".toCharArray(); //$NON-NLS-1$
232
230
233
	private NamingConventions() {
234
		// Not instantiable
235
	}
236
231
237
	private static char[] removePrefixAndSuffix(char[] name, char[][] prefixes, char[][] suffixes) {
232
	/**
238
		// remove longer prefix
233
	 * Variable kind which represents a static field.
239
		char[] withoutPrefixName = name;
234
	 * 
240
		if (prefixes != null) {
235
	 * @since 3.5
241
			int bestLength = 0;
236
	 */
242
			for (int i= 0; i < prefixes.length; i++) {
237
	public static final int VK_STATIC_FIELD = InternalNamingConventions.VK_STATIC_FIELD;
243
				char[] prefix = prefixes[i];
238
	/**
244
				if (CharOperation.prefixEquals(prefix, name)) {
239
	 * Variable kind which represents an instance field.
245
					int currLen = prefix.length;
240
	 * 
246
					boolean lastCharIsLetter = ScannerHelper.isLetter(prefix[currLen - 1]);
241
	 * @since 3.5
247
					if(!lastCharIsLetter || (lastCharIsLetter && name.length > currLen && ScannerHelper.isUpperCase(name[currLen]))) {
242
	 */
248
						if (bestLength < currLen && name.length != currLen) {
243
	public static final int VK_INSTANCE_FIELD = InternalNamingConventions.VK_INSTANCE_FIELD;
249
							withoutPrefixName = CharOperation.subarray(name, currLen, name.length);
244
	/**
250
							bestLength = currLen;
245
	 * Variable kind which represents a constant field (static final).
251
						}
246
	 * 
252
					}
247
	 * @since 3.5
253
				}
248
	 */
254
			}
249
	public static final int VK_CONSTANT_FIELD = InternalNamingConventions.VK_CONSTANT_FIELD;
255
		}
250
	/**
251
	 * Variable kind which represents an argument.
252
	 * 
253
	 * @since 3.5
254
	 */
255
	public static final int VK_PARAMETER = InternalNamingConventions.VK_PARAMETER;
256
	/**
257
	 * Variable kind which represents a local variable.
258
	 * 
259
	 * @since 3.5
260
	 */
261
	public static final int VK_LOCAL = InternalNamingConventions.VK_LOCAL;
262
	
263
	/**
264
	 * The base name associated to this base name kind is a simple name.
265
	 * When this base name is used the whole name is considered.
266
	 * 
267
	 * @see #suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)
268
	 * 
269
	 * @since 3.5
270
	 */
271
	public static final int BK_NAME = InternalNamingConventions.BK_SIMPLE_NAME;
272
	
273
	/**
274
	 * The base name associated to this base name kind is a simple type name.
275
	 * When this base name is used to all the words of the name are considered.
276
	 * 
277
	 * @see #suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)
278
	 * 
279
	 * @since 3.5
280
	 */
281
	public static final int BK_TYPE_NAME = InternalNamingConventions.BK_SIMPLE_TYPE_NAME;
256
282
257
		// remove longer suffix
283
	private static String[] convertCharsToString(char[][] c) {
258
		char[] withoutSuffixName = withoutPrefixName;
284
		int length = c == null ? 0 : c.length;
259
		if(suffixes != null) {
285
		String[] s = new String[length];
260
			int bestLength = 0;
286
		for (int i = 0; i < length; i++) {
261
			for (int i = 0; i < suffixes.length; i++) {
287
			s[i] = String.valueOf(c[i]);
262
				char[] suffix = suffixes[i];
288
		}
263
				if(CharOperation.endsWith(withoutPrefixName, suffix)) {
289
		return s;
264
					int currLen = suffix.length;
290
	}
265
					if(bestLength < currLen && withoutPrefixName.length != currLen) {
291
	private static char[][] convertStringToChars(String[] s) {
266
						withoutSuffixName = CharOperation.subarray(withoutPrefixName, 0, withoutPrefixName.length - currLen);
292
		int length = s == null ? 0 : s.length;
267
						bestLength = currLen;
293
		char[][] c = new char[length][];
268
					}
294
		for (int i = 0; i < length; i++) {
269
				}
295
			if(s[i] == null) {
296
				c[i] = CharOperation.NO_CHAR;
297
			} else {
298
				c[i] = s[i].toCharArray();
270
			}
299
			}
271
		}
300
		}
272
301
		return c;
273
		withoutSuffixName[0] = ScannerHelper.toLowerCase(withoutSuffixName[0]);
274
		return withoutSuffixName;
275
	}
302
	}
276
303
277
	/**
304
	/**
Lines 296-308 Link Here
296
	 * @return char[] the name without prefix and suffix.
323
	 * @return char[] the name without prefix and suffix.
297
	 * @see JavaCore#setOptions(java.util.Hashtable)
324
	 * @see JavaCore#setOptions(java.util.Hashtable)
298
	 * @see JavaCore#getDefaultOptions()
325
	 * @see JavaCore#getDefaultOptions()
326
	 * 
327
	 * @deprecated Use {@link #getBaseName(int, String, IJavaProject)} instead with {@link #VK_PARAMETER} as variable kind.
299
	 */
328
	 */
300
	public static char[] removePrefixAndSuffixForArgumentName(IJavaProject javaProject, char[] argumentName) {
329
	public static char[] removePrefixAndSuffixForArgumentName(IJavaProject javaProject, char[] argumentName) {
301
		AssistOptions assistOptions = new AssistOptions(javaProject.getOptions(true));
330
		return InternalNamingConventions.removeVariablePrefixAndSuffix(VK_PARAMETER, javaProject, argumentName);
302
		return	removePrefixAndSuffix(
303
			argumentName,
304
			assistOptions.argumentPrefixes,
305
			assistOptions.argumentSuffixes);
306
	}
331
	}
307
332
308
	/**
333
	/**
Lines 327-337 Link Here
327
	 * @return char[] the name without prefix and suffix.
352
	 * @return char[] the name without prefix and suffix.
328
	 * @see JavaCore#setOptions(java.util.Hashtable)
353
	 * @see JavaCore#setOptions(java.util.Hashtable)
329
	 * @see JavaCore#getDefaultOptions()
354
	 * @see JavaCore#getDefaultOptions()
355
	 * 
356
	 * @deprecated Use {@link #getBaseName(int, String, IJavaProject)} instead with {@link #VK_PARAMETER} as variable kind.
330
	 */
357
	 */
331
	public static String removePrefixAndSuffixForArgumentName(IJavaProject javaProject, String argumentName) {
358
	public static String removePrefixAndSuffixForArgumentName(IJavaProject javaProject, String argumentName) {
332
		return String.valueOf(removePrefixAndSuffixForArgumentName(javaProject, argumentName.toCharArray()));
359
		return String.valueOf(removePrefixAndSuffixForArgumentName(javaProject, argumentName.toCharArray()));
333
	}
360
	}
334
335
	/**
361
	/**
336
	 * Remove prefix and suffix from a field name.
362
	 * Remove prefix and suffix from a field name.
337
	 * <p>
363
	 * <p>
Lines 358-371 Link Here
358
	 * @see Flags
384
	 * @see Flags
359
	 * @see JavaCore#setOptions(java.util.Hashtable)
385
	 * @see JavaCore#setOptions(java.util.Hashtable)
360
	 * @see JavaCore#getDefaultOptions()
386
	 * @see JavaCore#getDefaultOptions()
387
	 * 
388
	 * @deprecated Use {@link #getBaseName(int, String, IJavaProject)} instead
389
	 * with {@link #VK_INSTANCE_FIELD} or {@link #VK_STATIC_FIELD} as variable kind.
361
	 */
390
	 */
362
	public static char[] removePrefixAndSuffixForFieldName(IJavaProject javaProject, char[] fieldName, int modifiers) {
391
	public static char[] removePrefixAndSuffixForFieldName(IJavaProject javaProject, char[] fieldName, int modifiers) {
363
		boolean isStatic = Flags.isStatic(modifiers);
392
		boolean isStatic = Flags.isStatic(modifiers);
364
		AssistOptions assistOptions = new AssistOptions(javaProject.getOptions(true));
393
		return InternalNamingConventions.removeVariablePrefixAndSuffix(isStatic ? VK_STATIC_FIELD : VK_INSTANCE_FIELD, javaProject, fieldName);
365
		return	removePrefixAndSuffix(
366
			fieldName,
367
			isStatic ? assistOptions.staticFieldPrefixes : assistOptions.fieldPrefixes,
368
			isStatic ? assistOptions.staticFieldSuffixes : assistOptions.fieldSuffixes);
369
	}
394
	}
370
395
371
	/**
396
	/**
Lines 394-403 Link Here
394
	 * @see Flags
419
	 * @see Flags
395
	 * @see JavaCore#setOptions(java.util.Hashtable)
420
	 * @see JavaCore#setOptions(java.util.Hashtable)
396
	 * @see JavaCore#getDefaultOptions()
421
	 * @see JavaCore#getDefaultOptions()
422
	 * 
423
	 * @deprecated Use {@link #getBaseName(int, String, IJavaProject)} instead
424
	 * with {@link #VK_INSTANCE_FIELD} or {@link #VK_STATIC_FIELD} as variable kind.
397
	 */
425
	 */
398
	public static String removePrefixAndSuffixForFieldName(IJavaProject javaProject, String fieldName, int modifiers) {
426
	public static String removePrefixAndSuffixForFieldName(IJavaProject javaProject, String fieldName, int modifiers) {
399
		return String.valueOf(removePrefixAndSuffixForFieldName(javaProject, fieldName.toCharArray(), modifiers));
427
		return String.valueOf(removePrefixAndSuffixForFieldName(javaProject, fieldName.toCharArray(), modifiers));
400
	}
428
	}
429
401
	/**
430
	/**
402
	 * Remove prefix and suffix from a local variable name.
431
	 * Remove prefix and suffix from a local variable name.
403
	 * <p>
432
	 * <p>
Lines 420-432 Link Here
420
	 * @return char[] the name without prefix and suffix.
449
	 * @return char[] the name without prefix and suffix.
421
	 * @see JavaCore#setOptions(java.util.Hashtable)
450
	 * @see JavaCore#setOptions(java.util.Hashtable)
422
	 * @see JavaCore#getDefaultOptions()
451
	 * @see JavaCore#getDefaultOptions()
452
	 * 
453
	 * @deprecated Use {@link #getBaseName(int, String, IJavaProject)} instead with {@link #VK_LOCAL} as variable kind.
423
	 */
454
	 */
424
	public static char[] removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, char[] localName) {
455
	public static char[] removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, char[] localName) {
425
		AssistOptions assistOptions = new AssistOptions(javaProject.getOptions(true));
456
		return InternalNamingConventions.removeVariablePrefixAndSuffix(VK_LOCAL, javaProject, localName);
426
		return	removePrefixAndSuffix(
427
			localName,
428
			assistOptions.localPrefixes,
429
			assistOptions.localSuffixes);
430
	}
457
	}
431
458
432
	/**
459
	/**
Lines 451-460 Link Here
451
	 * @return char[] the name without prefix and suffix.
478
	 * @return char[] the name without prefix and suffix.
452
	 * @see JavaCore#setOptions(java.util.Hashtable)
479
	 * @see JavaCore#setOptions(java.util.Hashtable)
453
	 * @see JavaCore#getDefaultOptions()
480
	 * @see JavaCore#getDefaultOptions()
481
	 * 
482
	 * @deprecated Use {@link #getBaseName(int, String, IJavaProject)} instead with {@link #VK_LOCAL} as variable kind.
454
	 */
483
	 */
455
	public static String removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, String localName) {
484
	public static String removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, String localName) {
456
		return String.valueOf(removePrefixAndSuffixForLocalVariableName(javaProject, localName.toCharArray()));
485
		return String.valueOf(removePrefixAndSuffixForLocalVariableName(javaProject, localName.toCharArray()));
457
	}
486
	}
487
	
488
	/**
489
	 * Returns a base name which could be used to generate this variable name with {@link #suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)}.
490
	 * <p>
491
	 * e.g.<br>
492
	 * If the variable is a {@link #VK_LOCAL} and the variable name is <code>variableName</code> then the base name will be <code>VariableName</code>.<br>
493
	 * If the variable is a {@link #VK_CONSTANT_FIELD} and the variable name is <code>VARIABLE_NAME</code> then the base name will be <code>VariableName</code>.<br>
494
	 * </p>
495
	 * 
496
	 * @param variableKind specifies what type the variable is: {@link #VK_LOCAL}, {@link #VK_PARAMETER}, {@link #VK_STATIC_FIELD},
497
	 * {@link #VK_INSTANCE_FIELD} or {@link #VK_CONSTANT_FIELD}.
498
	 * @param variableName a variable name
499
	 * @param javaProject project which contains the variable or <code>null</code> to take into account only workspace settings.
500
	 * 
501
	 * @see #suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)
502
	 * @since 3.5
503
	 */
504
	public static String getBaseName(
505
			int variableKind,
506
			String variableName,
507
			IJavaProject javaProject) {
508
		return String.valueOf(InternalNamingConventions.getBaseName(variableKind, javaProject, variableName.toCharArray()));
509
	}
510
511
	private static char[] suggestAccessorName(IJavaProject project, char[] fieldName, int modifiers) {
512
		char[] name = removePrefixAndSuffixForFieldName(project, fieldName, modifiers);
513
		if (name.length > 0 && ScannerHelper.isLowerCase(name[0])) {
514
			name[0] = ScannerHelper.toUpperCase(name[0]);
515
		}
516
		return name;
517
	}
458
518
459
	/**
519
	/**
460
	 * Suggest names for an argument. The name is computed from argument's type
520
	 * Suggest names for an argument. The name is computed from argument's type
Lines 483-499 Link Here
483
	 * @return char[][] an array of names.
543
	 * @return char[][] an array of names.
484
	 * @see JavaCore#setOptions(java.util.Hashtable)
544
	 * @see JavaCore#setOptions(java.util.Hashtable)
485
	 * @see JavaCore#getDefaultOptions()
545
	 * @see JavaCore#getDefaultOptions()
546
	 * 
547
	 * @deprecated Use {@link #suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)} instead with {@link #VK_PARAMETER} as variable kind.
486
	 */
548
	 */
487
	public static char[][] suggestArgumentNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames) {
549
	public static char[][] suggestArgumentNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames) {
550
		if(qualifiedTypeName == null || qualifiedTypeName.length == 0)
551
			return CharOperation.NO_CHAR_CHAR;
552
		
553
		char[] typeName = CharOperation.lastSegment(qualifiedTypeName, '.');
554
		
488
		NamingRequestor requestor = new NamingRequestor();
555
		NamingRequestor requestor = new NamingRequestor();
489
		InternalNamingConventions.suggestArgumentNames(
556
		InternalNamingConventions.suggestVariableNames(
490
			javaProject,
557
				VK_PARAMETER,
491
			packageName,
558
				BK_TYPE_NAME,
492
			qualifiedTypeName,
559
				typeName,
493
			dim,
560
				javaProject,
494
			null,
561
				dim,
495
			excludedNames,
562
				null,
496
			requestor);
563
				excludedNames,
564
				true,
565
				requestor);
497
566
498
		return requestor.getResults();
567
		return requestor.getResults();
499
	}
568
	}
Lines 525-530 Link Here
525
	 * @return char[][] an array of names.
594
	 * @return char[][] an array of names.
526
	 * @see JavaCore#setOptions(java.util.Hashtable)
595
	 * @see JavaCore#setOptions(java.util.Hashtable)
527
	 * @see JavaCore#getDefaultOptions()
596
	 * @see JavaCore#getDefaultOptions()
597
	 * 
598
	 * @deprecated Use {@link #suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)} instead with {@link #VK_PARAMETER} as variable kind.
528
	 */
599
	 */
529
	public static String[] suggestArgumentNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames) {
600
	public static String[] suggestArgumentNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames) {
530
		return convertCharsToString(
601
		return convertCharsToString(
Lines 535-540 Link Here
535
				dim,
606
				dim,
536
				convertStringToChars(excludedNames)));
607
				convertStringToChars(excludedNames)));
537
	}
608
	}
609
538
	/**
610
	/**
539
	 * Suggest names for a field. The name is computed from field's type
611
	 * Suggest names for a field. The name is computed from field's type
540
	 * and possible prefixes or suffixes are added.
612
	 * and possible prefixes or suffixes are added.
Lines 566-583 Link Here
566
	 * @see Flags
638
	 * @see Flags
567
	 * @see JavaCore#setOptions(java.util.Hashtable)
639
	 * @see JavaCore#setOptions(java.util.Hashtable)
568
	 * @see JavaCore#getDefaultOptions()
640
	 * @see JavaCore#getDefaultOptions()
641
	 * 
642
	 * @deprecated Use {@link #suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)} instead 
643
	 * with {@link #VK_INSTANCE_FIELD} or  {@link #VK_STATIC_FIELD} as variable kind.
569
	 */
644
	 */
570
	public static char[][] suggestFieldNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, int modifiers, char[][] excludedNames) {
645
	public static char[][] suggestFieldNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, int modifiers, char[][] excludedNames) {
646
		if(qualifiedTypeName == null || qualifiedTypeName.length == 0)
647
			return CharOperation.NO_CHAR_CHAR;
648
		
649
		char[] typeName = CharOperation.lastSegment(qualifiedTypeName, '.');
650
		
571
		NamingRequestor requestor = new NamingRequestor();
651
		NamingRequestor requestor = new NamingRequestor();
572
		InternalNamingConventions.suggestFieldNames(
652
		InternalNamingConventions.suggestVariableNames(
573
			javaProject,
653
				Flags.isStatic(modifiers) ? VK_STATIC_FIELD : VK_INSTANCE_FIELD,
574
			packageName,
654
				BK_TYPE_NAME,
575
			qualifiedTypeName,
655
				typeName,
576
			dim,
656
				javaProject,
577
			modifiers,
657
				dim,
578
			null,
658
				null,
579
			excludedNames,
659
				excludedNames,
580
			requestor);
660
				true,
661
				requestor);
581
662
582
		return requestor.getResults();
663
		return requestor.getResults();
583
	}
664
	}
Lines 613-618 Link Here
613
	 * @see Flags
694
	 * @see Flags
614
	 * @see JavaCore#setOptions(java.util.Hashtable)
695
	 * @see JavaCore#setOptions(java.util.Hashtable)
615
	 * @see JavaCore#getDefaultOptions()
696
	 * @see JavaCore#getDefaultOptions()
697
	 * 
698
	 * @deprecated Use {@link #suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)} instead 
699
	 * with {@link #VK_INSTANCE_FIELD} or  {@link #VK_STATIC_FIELD} as variable kind.
616
	 */
700
	 */
617
	public static String[] suggestFieldNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, int modifiers, String[] excludedNames) {
701
	public static String[] suggestFieldNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, int modifiers, String[] excludedNames) {
618
		return convertCharsToString(
702
		return convertCharsToString(
Lines 624-710 Link Here
624
				modifiers,
708
				modifiers,
625
				convertStringToChars(excludedNames)));
709
				convertStringToChars(excludedNames)));
626
	}
710
	}
627
711
	
628
	/**
629
	 * Suggest names for a local variable. The name is computed from variable's type
630
	 * and possible prefixes or suffixes are added.
631
	 * <p>
632
	 * If the type of the local variable is <code>TypeName</code>, the prefix for local variable is <code>pre</code>
633
	 * and the suffix for local variable is <code>suf</code> then the proposed names are <code>preTypeNamesuf</code>
634
	 * and <code>preNamesuf</code>. If there is no prefix or suffix the proposals are <code>typeName</code>
635
	 * and <code>name</code>.
636
	 * </p>
637
	 * <p>
638
	 * This method is affected by the following JavaCore options :  {@link JavaCore#CODEASSIST_LOCAL_PREFIXES} and
639
	 *  {@link JavaCore#CODEASSIST_LOCAL_SUFFIXES}.
640
	 * </p>
641
	 * <p>
642
	 * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
643
	 * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
644
	 * </p>
645
	 *
646
	 * @param javaProject project which contains the variable.
647
	 * @param packageName package of the variable's type.
648
	 * @param qualifiedTypeName variable's type.
649
	 * @param dim variable's dimension (0 if the variable is not an array).
650
	 * @param excludedNames a list of names which cannot be suggested (already used names).
651
	 *         Can be <code>null</code> if there is no excluded names.
652
	 * @return char[][] an array of names.
653
	 * @see JavaCore#setOptions(java.util.Hashtable)
654
	 * @see JavaCore#getDefaultOptions()
655
	 */
656
	public static char[][] suggestLocalVariableNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames) {
657
		NamingRequestor requestor = new NamingRequestor();
658
		InternalNamingConventions.suggestLocalVariableNames(
659
			javaProject,
660
			packageName,
661
			qualifiedTypeName,
662
			dim,
663
			null,
664
			excludedNames,
665
			requestor);
666
667
		return requestor.getResults();
668
	}
669
670
	/**
671
	 * Suggest names for a local variable. The name is computed from variable's type
672
	 * and possible prefixes or suffixes are added.
673
	 * <p>
674
	 * If the type of the local variable is <code>TypeName</code>, the prefix for local variable is <code>pre</code>
675
	 * and the suffix for local variable is <code>suf</code> then the proposed names are <code>preTypeNamesuf</code>
676
	 * and <code>preNamesuf</code>. If there is no prefix or suffix the proposals are <code>typeName</code>
677
	 * and <code>name</code>.
678
	 * </p>
679
	 * <p>
680
	 * This method is affected by the following JavaCore options :  {@link JavaCore#CODEASSIST_LOCAL_PREFIXES} and
681
	 *  {@link JavaCore#CODEASSIST_LOCAL_SUFFIXES}.
682
	 * </p>
683
	 * <p>
684
	 * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
685
	 * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
686
	 * </p>
687
	 *
688
	 * @param javaProject project which contains the variable.
689
	 * @param packageName package of the variable's type.
690
	 * @param qualifiedTypeName variable's type.
691
	 * @param dim variable's dimension (0 if the variable is not an array).
692
	 * @param excludedNames a list of names which cannot be suggested (already used names).
693
	 *         Can be <code>null</code> if there is no excluded names.
694
	 * @return char[][] an array of names.
695
	 * @see JavaCore#setOptions(java.util.Hashtable)
696
	 * @see JavaCore#getDefaultOptions()
697
	 */
698
	public static String[] suggestLocalVariableNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames) {
699
		return convertCharsToString(
700
			suggestLocalVariableNames(
701
				javaProject,
702
				packageName.toCharArray(),
703
				qualifiedTypeName.toCharArray(),
704
				dim,
705
				convertStringToChars(excludedNames)));
706
	}
707
708
	/**
712
	/**
709
	 * Suggest name for a getter method. The name is computed from field's name
713
	 * Suggest name for a getter method. The name is computed from field's name
710
	 * and possible prefixes or suffixes are removed.
714
	 * and possible prefixes or suffixes are removed.
Lines 756-762 Link Here
756
			);
760
			);
757
		}
761
		}
758
	}
762
	}
759
760
	/**
763
	/**
761
	 * Suggest name for a getter method. The name is computed from field's name
764
	 * Suggest name for a getter method. The name is computed from field's name
762
	 * and possible prefixes or suffixes are removed.
765
	 * and possible prefixes or suffixes are removed.
Lines 797-803 Link Here
797
				isBoolean,
800
				isBoolean,
798
				convertStringToChars(excludedNames)));
801
				convertStringToChars(excludedNames)));
799
	}
802
	}
803
	/**
804
	 * Suggest names for a local variable. The name is computed from variable's type
805
	 * and possible prefixes or suffixes are added.
806
	 * <p>
807
	 * If the type of the local variable is <code>TypeName</code>, the prefix for local variable is <code>pre</code>
808
	 * and the suffix for local variable is <code>suf</code> then the proposed names are <code>preTypeNamesuf</code>
809
	 * and <code>preNamesuf</code>. If there is no prefix or suffix the proposals are <code>typeName</code>
810
	 * and <code>name</code>.
811
	 * </p>
812
	 * <p>
813
	 * This method is affected by the following JavaCore options :  {@link JavaCore#CODEASSIST_LOCAL_PREFIXES} and
814
	 *  {@link JavaCore#CODEASSIST_LOCAL_SUFFIXES}.
815
	 * </p>
816
	 * <p>
817
	 * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
818
	 * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
819
	 * </p>
820
	 *
821
	 * @param javaProject project which contains the variable.
822
	 * @param packageName package of the variable's type.
823
	 * @param qualifiedTypeName variable's type.
824
	 * @param dim variable's dimension (0 if the variable is not an array).
825
	 * @param excludedNames a list of names which cannot be suggested (already used names).
826
	 *         Can be <code>null</code> if there is no excluded names.
827
	 * @return char[][] an array of names.
828
	 * @see JavaCore#setOptions(java.util.Hashtable)
829
	 * @see JavaCore#getDefaultOptions()
830
	 * 
831
	 * @deprecated Use {@link #suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)} instead with {@link #VK_LOCAL} as variable kind.
832
	 */
833
	public static char[][] suggestLocalVariableNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames) {
834
		if(qualifiedTypeName == null || qualifiedTypeName.length == 0)
835
			return CharOperation.NO_CHAR_CHAR;
836
		
837
		char[] typeName = CharOperation.lastSegment(qualifiedTypeName, '.');
838
		
839
		NamingRequestor requestor = new NamingRequestor();
840
		InternalNamingConventions.suggestVariableNames(
841
				VK_LOCAL,
842
				BK_TYPE_NAME,
843
				typeName,
844
				javaProject,
845
				dim,
846
				null,
847
				excludedNames,
848
				true,
849
				requestor);
800
850
851
		return requestor.getResults();
852
	}
853
	/**
854
	 * Suggest names for a local variable. The name is computed from variable's type
855
	 * and possible prefixes or suffixes are added.
856
	 * <p>
857
	 * If the type of the local variable is <code>TypeName</code>, the prefix for local variable is <code>pre</code>
858
	 * and the suffix for local variable is <code>suf</code> then the proposed names are <code>preTypeNamesuf</code>
859
	 * and <code>preNamesuf</code>. If there is no prefix or suffix the proposals are <code>typeName</code>
860
	 * and <code>name</code>.
861
	 * </p>
862
	 * <p>
863
	 * This method is affected by the following JavaCore options :  {@link JavaCore#CODEASSIST_LOCAL_PREFIXES} and
864
	 *  {@link JavaCore#CODEASSIST_LOCAL_SUFFIXES}.
865
	 * </p>
866
	 * <p>
867
	 * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
868
	 * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
869
	 * </p>
870
	 *
871
	 * @param javaProject project which contains the variable.
872
	 * @param packageName package of the variable's type.
873
	 * @param qualifiedTypeName variable's type.
874
	 * @param dim variable's dimension (0 if the variable is not an array).
875
	 * @param excludedNames a list of names which cannot be suggested (already used names).
876
	 *         Can be <code>null</code> if there is no excluded names.
877
	 * @return char[][] an array of names.
878
	 * @see JavaCore#setOptions(java.util.Hashtable)
879
	 * @see JavaCore#getDefaultOptions()
880
	 * 
881
	 * @deprecated Use {@link #suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)} instead with {@link #VK_LOCAL} as variable kind.
882
	 */
883
	public static String[] suggestLocalVariableNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames) {
884
		return convertCharsToString(
885
			suggestLocalVariableNames(
886
				javaProject,
887
				packageName.toCharArray(),
888
				qualifiedTypeName.toCharArray(),
889
				dim,
890
				convertStringToChars(excludedNames)));
891
	}
892
	private static char[] suggestNewName(char[] name, char[][] excludedNames){
893
		if(excludedNames == null) {
894
			return name;
895
		}
896
897
		char[] newName = name;
898
		int count = 2;
899
		int i = 0;
900
		while (i < excludedNames.length) {
901
			if(CharOperation.equals(newName, excludedNames[i], false)) {
902
				newName = CharOperation.concat(name, String.valueOf(count++).toCharArray());
903
				i = 0;
904
			} else {
905
				i++;
906
			}
907
		}
908
		return newName;
909
	}
910
	
801
	/**
911
	/**
802
	 * Suggest name for a setter method. The name is computed from field's name
912
	 * Suggest name for a setter method. The name is computed from field's name
803
	 * and possible prefixes or suffixes are removed.
913
	 * and possible prefixes or suffixes are removed.
Lines 853-859 Link Here
853
			);
963
			);
854
		}
964
		}
855
	}
965
	}
856
857
	/**
966
	/**
858
	 * Suggest name for a setter method. The name is computed from field's name
967
	 * Suggest name for a setter method. The name is computed from field's name
859
	 * and possible prefixes or suffixes are removed.
968
	 * and possible prefixes or suffixes are removed.
Lines 893-945 Link Here
893
				isBoolean,
1002
				isBoolean,
894
				convertStringToChars(excludedNames)));
1003
				convertStringToChars(excludedNames)));
895
	}
1004
	}
1005
	
1006
	/**
1007
	 * Suggests names for a variable. The name is computed from a base name and possible prefixes or suffixes are added.
1008
	 *
1009
	 * <p>
1010
	 * The base name is used to compute the variable name.
1011
	 * Some different kinds of base name are possible and each kind is associated to a different heuristic to compute variable names.<br>
1012
	 * The heuristic depends also of the kind of the variable. Each kind of variable is identified by a constant starting with <code>VK_</code>.<br>
1013
	 * When a prefix and a suffix can be added then all combinations of prefix and suffix are suggested.
1014
	 * If the name is <code>name</code>, the prefix is <code>pre</code> and the suffix is <code>suf</code> then the suggested names will be
1015
	 * <code>prenamesuf</code>, <code>prename</code>, <code>namesuf</code> and <code>name</code>.<br>
1016
	 * <br>
1017
	 * The different kinds of base name are:
1018
	 * <ul>
1019
	 * <li>{@link #BK_NAME}: the base name is a Java name and the whole base name is considered to compute the variable names. A prefix and a suffix can be added.<br>
1020
	 * There is an heuristic by variable kind.
1021
	 * <ul>
1022
	 * <li>{@link #VK_PARAMETER}, {@link #VK_LOCAL}, {@link #VK_INSTANCE_FIELD} and {@link #VK_STATIC_FIELD}:<br>
1023
	 * In this case the first character will be converted to lower case and the other characters won't be changed.<br>
1024
	 * If the base name is <code>SimpleName</code> then the suggested name will be <code>simpleName</code>.<br></li>
1025
	 * <li>{@link #VK_CONSTANT_FIELD} :<br>
1026
	 * In this case all letters of the name will be converted to upper case and words will be separated by an underscore (<code>"_"</code>).<br>
1027
	 * If the base name is <code>SimpleName</code> then the suggested name will be <code>SIMPLE_NAME</code>.</li>
1028
	 * </ul></li>
1029
	 * <li>{@link #BK_TYPE_NAME}: the base name is a Java simple type name (e.g. <code>HashMap</code>) and all the words of the base name are considered to compute the variable names. A prefix and a suffix can be added to these names.<br>
1030
	 * There is an heuristic by variable kind.
1031
	 * <ul>
1032
	 * <li>{@link #VK_PARAMETER}, {@link #VK_LOCAL}, {@link #VK_INSTANCE_FIELD} and {@link #VK_STATIC_FIELD}:<br>
1033
	 * In this case a variable name will contain some words of the base name and the first character will be converted to lower case.<br>
1034
	 * If the type is <code>TypeName</code> then the suggested names will be <code>typeName</code> and <code>name</code>.</li>
1035
	 * <li>{@link #VK_CONSTANT_FIELD} :<br>
1036
	 * In this case a variable name will contain some words of the base name, all letters of the name will be converted to upper case and segments will be separated by a underscore (<code>"_"</code>).<br>
1037
	 * If the base name is <code>TypeName</code> then the suggested name will be <code>TYPE_NAME</code> and <code>NAME</code>.</li>
1038
	 * </ul></li>
1039
	 * </ul>
1040
	 * Some other kinds could be added in the future.
1041
	 * </p>
1042
	 * <p>
1043
	 * Each variable kind is affected by the following JavaCore options:
1044
	 * <ul>
1045
	 * <li>{@link #VK_PARAMETER}: {@link JavaCore#CODEASSIST_ARGUMENT_PREFIXES} and {@link JavaCore#CODEASSIST_ARGUMENT_SUFFIXES}</li>
1046
	 * <li>{@link #VK_LOCAL}: {@link JavaCore#CODEASSIST_LOCAL_PREFIXES} and {@link JavaCore#CODEASSIST_LOCAL_SUFFIXES}</li>
1047
	 * <li>{@link #VK_INSTANCE_FIELD}: {@link JavaCore#CODEASSIST_FIELD_PREFIXES} and {@link JavaCore#CODEASSIST_FIELD_SUFFIXES}</li>
1048
	 * <li>{@link #VK_STATIC_FIELD}: {@link JavaCore#CODEASSIST_STATIC_FIELD_PREFIXES} and {@link JavaCore#CODEASSIST_STATIC_FIELD_SUFFIXES}</li>
1049
	 * <li>{@link #VK_CONSTANT_FIELD}: {@link JavaCore#CODEASSIST_STATIC_FINAL_FIELD_PREFIXES} and {@link JavaCore#CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES}</li>
1050
	 * </ul>
1051
	 * </p>
1052
	 * <p>
1053
	 * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
1054
	 * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
1055
	 * </p>
1056
	 * <p>
1057
	 * Proposed names are sorted by relevance (best proposal first).<br>
1058
	 * The names are proposed in the following order:
1059
	 * <ol>
1060
	 * <li>Names with prefix and suffix. Longest name are proposed first</li>
1061
	 * <li>Names with prefix. Longest name are proposed first</li>
1062
	 * <li>Names with suffix. Longest name are proposed first</li>
1063
	 * <li>Names without prefix and suffix. Longest name are proposed first</li>
1064
	 * </ol>
1065
	 * </p>
1066
	 *
1067
	 * @param variableKind specifies what type the variable is: {@link #VK_LOCAL}, {@link #VK_PARAMETER}, {@link #VK_STATIC_FIELD},
1068
	 * {@link #VK_INSTANCE_FIELD} or {@link #VK_CONSTANT_FIELD}.
1069
	 * @param baseNameKind specifies what type the base name is: {@link #BK_NAME} or {@link #BK_TYPE_NAME}
1070
	 * @param baseName name used to compute the suggested names.
1071
	 * @param javaProject project which contains the variable or <code>null</code> to take into account only workspace settings.
1072
	 * @param dim variable dimension (0 if the field is not an array).
1073
	 * @param excluded a list of names which cannot be suggested (already used names).
1074
	 *         Can be <code>null</code> if there is no excluded names.
1075
	 * @param evaluateDefault if set, the result is guaranteed to contain at least one result. If not, the result can be an empty array. 
1076
	 * @return String[] an array of names.
1077
	 * @see JavaCore#setOptions(java.util.Hashtable)
1078
	 * @see JavaCore#getDefaultOptions()
1079
	 * 
1080
	 * @since 3.5
1081
	 */
1082
	public static String[] suggestVariableNames(
1083
			int variableKind,
1084
			int baseNameKind,
1085
			String baseName,
1086
			IJavaProject javaProject,
1087
			int dim,
1088
			String[] excluded,
1089
			boolean evaluateDefault) {
1090
		
1091
		NamingRequestor requestor = new NamingRequestor();
1092
		InternalNamingConventions.suggestVariableNames(
1093
			variableKind,
1094
			baseNameKind,
1095
			baseName.toCharArray(),
1096
			javaProject,
1097
			dim,
1098
			null,
1099
			convertStringToChars(excluded),
1100
			evaluateDefault,
1101
			requestor);
896
1102
897
	private static char[] suggestAccessorName(IJavaProject project, char[] fieldName, int modifiers) {
1103
		return convertCharsToString(requestor.getResults());
898
		char[] name = removePrefixAndSuffixForFieldName(project, fieldName, modifiers);
899
		if (name.length > 0 && ScannerHelper.isLowerCase(name[0])) {
900
			name[0] = ScannerHelper.toUpperCase(name[0]);
901
		}
902
		return name;
903
	}
904
905
	private static char[] suggestNewName(char[] name, char[][] excludedNames){
906
		if(excludedNames == null) {
907
			return name;
908
		}
909
910
		char[] newName = name;
911
		int count = 2;
912
		int i = 0;
913
		while (i < excludedNames.length) {
914
			if(CharOperation.equals(newName, excludedNames[i], false)) {
915
				newName = CharOperation.concat(name, String.valueOf(count++).toCharArray());
916
				i = 0;
917
			} else {
918
				i++;
919
			}
920
		}
921
		return newName;
922
	}
923
924
	private static String[] convertCharsToString(char[][] c) {
925
		int length = c == null ? 0 : c.length;
926
		String[] s = new String[length];
927
		for (int i = 0; i < length; i++) {
928
			s[i] = String.valueOf(c[i]);
929
		}
930
		return s;
931
	}
1104
	}
932
1105
	
933
	private static char[][] convertStringToChars(String[] s) {
1106
	private NamingConventions() {
934
		int length = s == null ? 0 : s.length;
1107
		// Not instantiable
935
		char[][] c = new char[length][];
936
		for (int i = 0; i < length; i++) {
937
			if(s[i] == null) {
938
				c[i] = CharOperation.NO_CHAR;
939
			} else {
940
				c[i] = s[i].toCharArray();
941
			}
942
		}
943
		return c;
944
	}
1108
	}
945
}
1109
}
(-)compiler/org/eclipse/jdt/core/compiler/CharOperation.java (+48 lines)
Lines 3582-3587 Link Here
3582
}
3582
}
3583
3583
3584
/**
3584
/**
3585
 * Answers the result of a char[] conversion to uppercase. Answers null if the given chars array is null.
3586
 * <br>
3587
 * NOTE: If no conversion was necessary, then answers back the argument one.
3588
 * <br>
3589
 * <br>
3590
 * For example:
3591
 * <ol>
3592
 * <li><pre>
3593
 *    chars = { 'A' , 'B' }
3594
 *    result => { 'A' , 'B' }
3595
 * </pre>
3596
 * </li>
3597
 * <li><pre>
3598
 *    array = { 'a', 'B' }
3599
 *    result => { 'A' , 'B' }
3600
 * </pre>
3601
 * </li>
3602
 * </ol>
3603
 *
3604
 * @param chars the chars to convert
3605
 * @return the result of a char[] conversion to uppercase
3606
 * 
3607
 * @since 3.5
3608
 */
3609
final static public char[] toUpperCase(char[] chars) {
3610
	if (chars == null)
3611
		return null;
3612
	int length = chars.length;
3613
	char[] upperChars = null;
3614
	for (int i = 0; i < length; i++) {
3615
		char c = chars[i];
3616
		char lc = ScannerHelper.toUpperCase(c);
3617
		if ((c != lc) || (upperChars != null)) {
3618
			if (upperChars == null) {
3619
				System.arraycopy(
3620
					chars,
3621
					0,
3622
					upperChars = new char[length],
3623
					0,
3624
					i);
3625
			}
3626
			upperChars[i] = lc;
3627
		}
3628
	}
3629
	return upperChars == null ? chars : upperChars;
3630
}
3631
3632
/**
3585
 * Answers a new array removing leading and trailing spaces (' '). Answers the given array if there is no
3633
 * Answers a new array removing leading and trailing spaces (' '). Answers the given array if there is no
3586
 * space characters to remove.
3634
 * space characters to remove.
3587
 * <br>
3635
 * <br>
(-)codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistOptions.java (+26 lines)
Lines 28-33 Link Here
28
		"org.eclipse.jdt.core.codeComplete.fieldPrefixes"; 	//$NON-NLS-1$
28
		"org.eclipse.jdt.core.codeComplete.fieldPrefixes"; 	//$NON-NLS-1$
29
	public static final String OPTION_StaticFieldPrefixes =
29
	public static final String OPTION_StaticFieldPrefixes =
30
		"org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"; 	//$NON-NLS-1$
30
		"org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"; 	//$NON-NLS-1$
31
	public static final String OPTION_StaticFinalFieldPrefixes =
32
		"org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes"; 	//$NON-NLS-1$
31
	public static final String OPTION_LocalPrefixes =
33
	public static final String OPTION_LocalPrefixes =
32
		"org.eclipse.jdt.core.codeComplete.localPrefixes"; 	//$NON-NLS-1$
34
		"org.eclipse.jdt.core.codeComplete.localPrefixes"; 	//$NON-NLS-1$
33
	public static final String OPTION_ArgumentPrefixes =
35
	public static final String OPTION_ArgumentPrefixes =
Lines 36-41 Link Here
36
		"org.eclipse.jdt.core.codeComplete.fieldSuffixes"; 	//$NON-NLS-1$
38
		"org.eclipse.jdt.core.codeComplete.fieldSuffixes"; 	//$NON-NLS-1$
37
	public static final String OPTION_StaticFieldSuffixes =
39
	public static final String OPTION_StaticFieldSuffixes =
38
		"org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"; 	//$NON-NLS-1$
40
		"org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"; 	//$NON-NLS-1$
41
	public static final String OPTION_StaticFinalFieldSuffixes =
42
		"org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes"; 	//$NON-NLS-1$
39
	public static final String OPTION_LocalSuffixes =
43
	public static final String OPTION_LocalSuffixes =
40
		"org.eclipse.jdt.core.codeComplete.localSuffixes"; 	//$NON-NLS-1$
44
		"org.eclipse.jdt.core.codeComplete.localSuffixes"; 	//$NON-NLS-1$
41
	public static final String OPTION_ArgumentSuffixes =
45
	public static final String OPTION_ArgumentSuffixes =
Lines 61-70 Link Here
61
	public boolean suggestStaticImport = true;
65
	public boolean suggestStaticImport = true;
62
	public char[][] fieldPrefixes = null;
66
	public char[][] fieldPrefixes = null;
63
	public char[][] staticFieldPrefixes = null;
67
	public char[][] staticFieldPrefixes = null;
68
	public char[][] staticFinalFieldPrefixes = null;
64
	public char[][] localPrefixes = null;
69
	public char[][] localPrefixes = null;
65
	public char[][] argumentPrefixes = null;
70
	public char[][] argumentPrefixes = null;
66
	public char[][] fieldSuffixes = null;
71
	public char[][] fieldSuffixes = null;
67
	public char[][] staticFieldSuffixes = null;
72
	public char[][] staticFieldSuffixes = null;
73
	public char[][] staticFinalFieldSuffixes = null;
68
	public char[][] localSuffixes = null;
74
	public char[][] localSuffixes = null;
69
	public char[][] argumentSuffixes = null;
75
	public char[][] argumentSuffixes = null;
70
76
Lines 121-126 Link Here
121
				}
127
				}
122
			}
128
			}
123
		}
129
		}
130
		if ((optionValue = optionsMap.get(OPTION_StaticFinalFieldPrefixes)) != null) {
131
			if (optionValue instanceof String) {
132
				String stringValue = (String) optionValue;
133
				if (stringValue.length() > 0){
134
					this.staticFinalFieldPrefixes = splitAndTrimOn(',', stringValue.toCharArray());
135
				} else {
136
					this.staticFinalFieldPrefixes = null;
137
				}
138
			}
139
		}
124
		if ((optionValue = optionsMap.get(OPTION_LocalPrefixes)) != null) {
140
		if ((optionValue = optionsMap.get(OPTION_LocalPrefixes)) != null) {
125
			if (optionValue instanceof String) {
141
			if (optionValue instanceof String) {
126
				String stringValue = (String) optionValue;
142
				String stringValue = (String) optionValue;
Lines 161-166 Link Here
161
				}
177
				}
162
			}
178
			}
163
		}
179
		}
180
		if ((optionValue = optionsMap.get(OPTION_StaticFinalFieldSuffixes)) != null) {
181
			if (optionValue instanceof String) {
182
				String stringValue = (String) optionValue;
183
				if (stringValue.length() > 0){
184
					this.staticFinalFieldSuffixes = splitAndTrimOn(',', stringValue.toCharArray());
185
				} else {
186
					this.staticFinalFieldSuffixes = null;
187
				}
188
			}
189
		}
164
		if ((optionValue = optionsMap.get(OPTION_LocalSuffixes)) != null) {
190
		if ((optionValue = optionsMap.get(OPTION_LocalSuffixes)) != null) {
165
			if (optionValue instanceof String) {
191
			if (optionValue instanceof String) {
166
				String stringValue = (String) optionValue;
192
				String stringValue = (String) optionValue;
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-57 / +39 lines)
Lines 342-351 Link Here
342
	private final static int SUPERTYPE = 1;
342
	private final static int SUPERTYPE = 1;
343
	private final static int SUBTYPE = 2;
343
	private final static int SUBTYPE = 2;
344
	
344
	
345
	private final static int FIELD = 0;
346
	private final static int LOCAL = 1;
347
	private final static int ARGUMENT = 2;
348
	
349
	int expectedTypesPtr = -1;
345
	int expectedTypesPtr = -1;
350
	TypeBinding[] expectedTypes = new TypeBinding[1];
346
	TypeBinding[] expectedTypes = new TypeBinding[1];
351
	int expectedTypesFilter;
347
	int expectedTypesFilter;
Lines 1559-1565 Link Here
1559
1555
1560
			this.completionToken = field.realName;
1556
			this.completionToken = field.realName;
1561
1557
1562
			findVariableNames(field.realName, field.type, excludeNames, null, FIELD, field.modifiers);
1558
			
1559
			int kind =
1560
				 (field.modifiers & ClassFileConstants.AccStatic) == 0 ? 
1561
						InternalNamingConventions.VK_INSTANCE_FIELD :
1562
							(field.modifiers & ClassFileConstants.AccFinal) == 0 ? 
1563
									InternalNamingConventions.VK_STATIC_FIELD :
1564
										InternalNamingConventions.VK_CONSTANT_FIELD;
1565
			
1566
			findVariableNames(field.realName, field.type, excludeNames, null, kind);
1563
		}
1567
		}
1564
	}
1568
	}
1565
	
1569
	
Lines 1826-1836 Link Here
1826
			int kind;
1830
			int kind;
1827
			if (variable instanceof CompletionOnLocalName){
1831
			if (variable instanceof CompletionOnLocalName){
1828
				this.completionToken = ((CompletionOnLocalName) variable).realName;
1832
				this.completionToken = ((CompletionOnLocalName) variable).realName;
1829
				kind = LOCAL;
1833
				kind = InternalNamingConventions.VK_LOCAL;
1830
			} else {
1834
			} else {
1831
				CompletionOnArgumentName arg = (CompletionOnArgumentName) variable;
1835
				CompletionOnArgumentName arg = (CompletionOnArgumentName) variable;
1832
				this.completionToken = arg.realName;
1836
				this.completionToken = arg.realName;
1833
				kind = arg.isCatchArgument ? LOCAL : ARGUMENT;
1837
				kind = arg.isCatchArgument ? InternalNamingConventions.VK_LOCAL : InternalNamingConventions.VK_PARAMETER;
1834
			}
1838
			}
1835
1839
1836
			char[][] alreadyDefinedName = computeAlreadyDefinedName((BlockScope)scope, variable);
1840
			char[][] alreadyDefinedName = computeAlreadyDefinedName((BlockScope)scope, variable);
Lines 1848-1854 Link Here
1848
1852
1849
			System.arraycopy(discouragedNames, 0, discouragedNames = new char[localCount][], 0, localCount);
1853
			System.arraycopy(discouragedNames, 0, discouragedNames = new char[localCount][], 0, localCount);
1850
1854
1851
			findVariableNames(this.completionToken, variable.type, discouragedNames, forbiddenNames, kind, variable.modifiers);
1855
			findVariableNames(this.completionToken, variable.type, discouragedNames, forbiddenNames, kind);
1852
		}
1856
		}
1853
	}
1857
	}
1854
	
1858
	
Lines 2166-2172 Link Here
2166
2170
2167
			this.completionToken = method.selector;
2171
			this.completionToken = method.selector;
2168
2172
2169
			findVariableNames(this.completionToken, method.returnType, excludeNames, null, FIELD, method.modifiers);
2173
			
2174
			int kind =
2175
				 (method.modifiers & ClassFileConstants.AccStatic) == 0 ? 
2176
						InternalNamingConventions.VK_INSTANCE_FIELD :
2177
							(method.modifiers & ClassFileConstants.AccFinal) == 0 ? 
2178
									InternalNamingConventions.VK_STATIC_FIELD :
2179
										InternalNamingConventions.VK_CONSTANT_FIELD;
2180
						
2181
			findVariableNames(this.completionToken, method.returnType, excludeNames, null, kind);
2170
		}
2182
		}
2171
	}
2183
	}
2172
	
2184
	
Lines 9674-9681 Link Here
9674
			final char[][] forbiddenNames,
9686
			final char[][] forbiddenNames,
9675
			boolean forCollection,
9687
			boolean forCollection,
9676
			int dim,
9688
			int dim,
9677
			int kind,
9689
			int kind){
9678
			int modifiers){
9679
9690
9680
		if(sourceName == null || sourceName.length == 0)
9691
		if(sourceName == null || sourceName.length == 0)
9681
			return;
9692
			return;
Lines 9755-9793 Link Here
9755
			}
9766
			}
9756
		};
9767
		};
9757
9768
9758
		switch (kind) {
9769
		InternalNamingConventions.suggestVariableNames(
9759
			case FIELD :
9770
				kind,
9760
				InternalNamingConventions.suggestFieldNames(
9771
				InternalNamingConventions.BK_SIMPLE_TYPE_NAME,
9761
					this.javaProject,
9772
				qualifiedSourceName,
9762
					qualifiedPackageName,
9773
				this.javaProject,
9763
					qualifiedSourceName,
9774
				dim,
9764
					dim,
9775
				token,
9765
					modifiers,
9776
				discouragedNames,
9766
					token,
9777
				true,
9767
					discouragedNames,
9778
				namingRequestor);
9768
					namingRequestor);
9769
				break;
9770
			case LOCAL :
9771
				InternalNamingConventions.suggestLocalVariableNames(
9772
					this.javaProject,
9773
					qualifiedPackageName,
9774
					qualifiedSourceName,
9775
					dim,
9776
					token,
9777
					discouragedNames,
9778
					namingRequestor);
9779
				break;
9780
			case ARGUMENT :
9781
				InternalNamingConventions.suggestArgumentNames(
9782
					this.javaProject,
9783
					qualifiedPackageName,
9784
					qualifiedSourceName,
9785
					dim,
9786
					token,
9787
					discouragedNames,
9788
					namingRequestor);
9789
				break;
9790
		}
9791
	}
9779
	}
9792
9780
9793
	// Helper method for private void findVariableNames(char[] name, TypeReference type )
9781
	// Helper method for private void findVariableNames(char[] name, TypeReference type )
Lines 9800-9807 Link Here
9800
			char[][] discouragedNames,
9788
			char[][] discouragedNames,
9801
			final char[][] forbiddenNames,
9789
			final char[][] forbiddenNames,
9802
			int dim,
9790
			int dim,
9803
			int kind,
9791
			int kind){
9804
			int modifiers){
9805
		findVariableName(
9792
		findVariableName(
9806
				token,
9793
				token,
9807
				qualifiedPackageName,
9794
				qualifiedPackageName,
Lines 9812-9819 Link Here
9812
				forbiddenNames,
9799
				forbiddenNames,
9813
				false,
9800
				false,
9814
				dim,
9801
				dim,
9815
				kind,
9802
				kind);
9816
				modifiers);
9817
	}
9803
	}
9818
	private void findVariableNameForCollection(
9804
	private void findVariableNameForCollection(
9819
			char[] token,
9805
			char[] token,
Lines 9823-9830 Link Here
9823
			final TypeBinding typeBinding,
9809
			final TypeBinding typeBinding,
9824
			char[][] discouragedNames,
9810
			char[][] discouragedNames,
9825
			final char[][] forbiddenNames,
9811
			final char[][] forbiddenNames,
9826
			int kind,
9812
			int kind){
9827
			int modifiers){
9828
9813
9829
		findVariableName(
9814
		findVariableName(
9830
				token,
9815
				token,
Lines 9836-9845 Link Here
9836
				forbiddenNames,
9821
				forbiddenNames,
9837
				false,
9822
				false,
9838
				1,
9823
				1,
9839
				kind,
9824
				kind);
9840
				modifiers);
9841
	}
9825
	}
9842
	private void findVariableNames(char[] name, TypeReference type , char[][] discouragedNames, char[][] forbiddenNames, int kind, int modifiers){
9826
	private void findVariableNames(char[] name, TypeReference type , char[][] discouragedNames, char[][] forbiddenNames, int kind){
9843
		if(type != null &&
9827
		if(type != null &&
9844
			type.resolvedType != null) {
9828
			type.resolvedType != null) {
9845
			TypeBinding tb = type.resolvedType;
9829
			TypeBinding tb = type.resolvedType;
Lines 9855-9862 Link Here
9855
					discouragedNames,
9839
					discouragedNames,
9856
					forbiddenNames,
9840
					forbiddenNames,
9857
					type.dimensions(),
9841
					type.dimensions(),
9858
					kind,
9842
					kind);
9859
					modifiers);
9860
				
9843
				
9861
				if (tb.isParameterizedType() &&
9844
				if (tb.isParameterizedType() &&
9862
						tb.findSuperTypeOriginatingFrom(TypeIds.T_JavaUtilCollection, false) != null) {
9845
						tb.findSuperTypeOriginatingFrom(TypeIds.T_JavaUtilCollection, false) != null) {
Lines 9872-9879 Link Here
9872
							tb,
9855
							tb,
9873
							discouragedNames,
9856
							discouragedNames,
9874
							forbiddenNames,
9857
							forbiddenNames,
9875
							kind,
9858
							kind);
9876
							modifiers);
9877
					}
9859
					}
9878
				}
9860
				}
9879
			}
9861
			}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (-5 / +122 lines)
Lines 5134-5141 Link Here
5134
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
5134
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
5135
5135
5136
	assertResults(
5136
	assertResults(
5137
			"nameRequestor[VARIABLE_DECLARATION]{nameRequestor, null, Ltest.TypeNameRequestor;, nameRequestor, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}\n" +
5137
			"nameTypeNameRequestor[VARIABLE_DECLARATION]{nameTypeNameRequestor, null, Ltest.TypeNameRequestor;, nameTypeNameRequestor, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}\n" +
5138
			"nameTypeNameRequestor[VARIABLE_DECLARATION]{nameTypeNameRequestor, null, Ltest.TypeNameRequestor;, nameTypeNameRequestor, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}",
5138
			"nameRequestor[VARIABLE_DECLARATION]{nameRequestor, null, Ltest.TypeNameRequestor;, nameRequestor, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED) + "}",
5139
			requestor.getResults());
5140
}
5141
5142
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
5143
public void testCompletionFieldName3() throws JavaModelException { 
5144
	this.workingCopies = new ICompilationUnit[1];
5145
	this.workingCopies[0] = getWorkingCopy(
5146
		"/Completion/src/test/TypeNameRequestor.java",
5147
		"package test;"+
5148
		"public class TypeNameRequestor {\n" +
5149
		"  public static final TypeNameRequestor \n" +
5150
		"}\n");
5151
5152
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
5153
	String str = this.workingCopies[0].getSource();
5154
	String completeBehind = "final TypeNameRequestor ";
5155
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5156
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
5157
5158
	assertResults(
5159
			"NAME_REQUESTOR[VARIABLE_DECLARATION]{NAME_REQUESTOR, null, Ltest.TypeNameRequestor;, NAME_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}\n" +
5160
			"REQUESTOR[VARIABLE_DECLARATION]{REQUESTOR, null, Ltest.TypeNameRequestor;, REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}\n" +
5161
			"TYPE_NAME_REQUESTOR[VARIABLE_DECLARATION]{TYPE_NAME_REQUESTOR, null, Ltest.TypeNameRequestor;, TYPE_NAME_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}",
5162
			requestor.getResults());
5163
}
5164
5165
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
5166
public void testCompletionFieldName4() throws JavaModelException { 
5167
	this.workingCopies = new ICompilationUnit[1];
5168
	this.workingCopies[0] = getWorkingCopy(
5169
		"/Completion/src/test/TypeNameRequestor.java",
5170
		"package test;"+
5171
		"public class TypeNameRequestor {\n" +
5172
		"  public static final TypeNameRequestor nam\n" +
5173
		"}\n");
5174
5175
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
5176
	String str = this.workingCopies[0].getSource();
5177
	String completeBehind = "final TypeNameRequestor nam";
5178
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5179
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
5180
5181
	assertResults(
5182
			"NAM_REQUESTOR[VARIABLE_DECLARATION]{NAM_REQUESTOR, null, Ltest.TypeNameRequestor;, NAM_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
5183
			"NAM_TYPE_NAME_REQUESTOR[VARIABLE_DECLARATION]{NAM_TYPE_NAME_REQUESTOR, null, Ltest.TypeNameRequestor;, NAM_TYPE_NAME_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_NON_RESTRICTED) + "}\n" +
5184
			"NAME_REQUESTOR[VARIABLE_DECLARATION]{NAME_REQUESTOR, null, Ltest.TypeNameRequestor;, NAME_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_NAME_LESS_NEW_CHARACTERS+ R_NON_RESTRICTED) + "}",
5185
			requestor.getResults());
5186
}
5187
5188
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
5189
public void testCompletionFieldName5() throws JavaModelException { 
5190
	this.workingCopies = new ICompilationUnit[1];
5191
	this.workingCopies[0] = getWorkingCopy(
5192
		"/Completion/src/test/TypeNameRequestor.java",
5193
		"package test;"+
5194
		"public class TypeNameRequestor {\n" +
5195
		"  public static final TypeNameRequestor ZZ\n" +
5196
		"}\n");
5197
5198
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
5199
	String str = this.workingCopies[0].getSource();
5200
	String completeBehind = "final TypeNameRequestor ZZ";
5201
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5202
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
5203
5204
	assertResults(
5205
			"ZZ_NAME_REQUESTOR[VARIABLE_DECLARATION]{ZZ_NAME_REQUESTOR, null, Ltest.TypeNameRequestor;, ZZ_NAME_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
5206
			"ZZ_REQUESTOR[VARIABLE_DECLARATION]{ZZ_REQUESTOR, null, Ltest.TypeNameRequestor;, ZZ_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
5207
			"ZZ_TYPE_NAME_REQUESTOR[VARIABLE_DECLARATION]{ZZ_TYPE_NAME_REQUESTOR, null, Ltest.TypeNameRequestor;, ZZ_TYPE_NAME_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}",
5208
			requestor.getResults());
5209
}
5210
5211
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
5212
public void testCompletionFieldName6() throws JavaModelException { 
5213
	this.workingCopies = new ICompilationUnit[1];
5214
	this.workingCopies[0] = getWorkingCopy(
5215
		"/Completion/src/test/TypeNameRequestor.java",
5216
		"package test;"+
5217
		"public class TypeNameRequestor {\n" +
5218
		"  public static final TypeNameRequestor ZZN\n" +
5219
		"}\n");
5220
5221
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
5222
	String str = this.workingCopies[0].getSource();
5223
	String completeBehind = "final TypeNameRequestor ZZN";
5224
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5225
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
5226
5227
	assertResults(
5228
			"ZZN_NAME_REQUESTOR[VARIABLE_DECLARATION]{ZZN_NAME_REQUESTOR, null, Ltest.TypeNameRequestor;, ZZN_NAME_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
5229
			"ZZN_REQUESTOR[VARIABLE_DECLARATION]{ZZN_REQUESTOR, null, Ltest.TypeNameRequestor;, ZZN_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
5230
			"ZZN_TYPE_NAME_REQUESTOR[VARIABLE_DECLARATION]{ZZN_TYPE_NAME_REQUESTOR, null, Ltest.TypeNameRequestor;, ZZN_TYPE_NAME_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}",
5231
			requestor.getResults());
5232
}
5233
5234
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
5235
public void testCompletionFieldName7() throws JavaModelException { 
5236
	this.workingCopies = new ICompilationUnit[1];
5237
	this.workingCopies[0] = getWorkingCopy(
5238
		"/Completion/src/test/TypeNameRequestor.java",
5239
		"package test;"+
5240
		"public class TypeNameRequestor {\n" +
5241
		"  public static final TypeNameRequestor ZZ_N\n" +
5242
		"}\n");
5243
5244
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
5245
	String str = this.workingCopies[0].getSource();
5246
	String completeBehind = "final TypeNameRequestor ZZ_N";
5247
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
5248
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
5249
5250
	assertResults(
5251
			"ZZ_N_REQUESTOR[VARIABLE_DECLARATION]{ZZ_N_REQUESTOR, null, Ltest.TypeNameRequestor;, ZZ_N_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
5252
			"ZZ_N_TYPE_NAME_REQUESTOR[VARIABLE_DECLARATION]{ZZ_N_TYPE_NAME_REQUESTOR, null, Ltest.TypeNameRequestor;, ZZ_N_TYPE_NAME_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" +
5253
			"ZZ_NAME_REQUESTOR[VARIABLE_DECLARATION]{ZZ_NAME_REQUESTOR, null, Ltest.TypeNameRequestor;, ZZ_NAME_REQUESTOR, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NAME_LESS_NEW_CHARACTERS + R_NON_RESTRICTED) + "}",
5139
			requestor.getResults());
5254
			requestor.getResults());
5140
}
5255
}
5141
5256
Lines 13880-13886 Link Here
13880
13995
13881
	assertEquals(
13996
	assertEquals(
13882
		"element:class1    completion:class1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
13997
		"element:class1    completion:class1    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
13883
		"element:myClass    completion:myClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
13998
		"element:fooMyClass    completion:fooMyClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
13999
		"element:myClass    completion:myClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
14000
		"element:testFooMyClass    completion:testFooMyClass    relevance:"+(R_DEFAULT + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
13884
		requestor.getResults());
14001
		requestor.getResults());
13885
}
14002
}
13886
public void testCompletionVariableName10() throws JavaModelException {
14003
public void testCompletionVariableName10() throws JavaModelException {
Lines 14270-14279 Link Here
14270
	cu.codeComplete(cursorLocation, requestor);
14387
	cu.codeComplete(cursorLocation, requestor);
14271
14388
14272
	assertEquals(
14389
	assertEquals(
14273
		"element:bar_MyClass    completion:bar_MyClass    relevance:"+(R_DEFAULT  + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
14390
		"element:barMyClass    completion:barMyClass    relevance:"+(R_DEFAULT  + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
14274
		"element:class1    completion:class1    relevance:"+(R_DEFAULT  + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
14391
		"element:class1    completion:class1    relevance:"+(R_DEFAULT  + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
14275
		"element:myClass    completion:myClass    relevance:"+(R_DEFAULT  + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
14392
		"element:myClass    completion:myClass    relevance:"+(R_DEFAULT  + R_INTERESTING + R_CASE + R_NON_RESTRICTED)+"\n" +
14276
		"element:test_Bar_MyClass    completion:test_Bar_MyClass    relevance:"+(R_DEFAULT  + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
14393
		"element:testBarMyClass    completion:testBarMyClass    relevance:"+(R_DEFAULT  + R_INTERESTING + R_CASE+ R_NON_RESTRICTED),
14277
		requestor.getResults());
14394
		requestor.getResults());
14278
}
14395
}
14279
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
14396
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=150228
(-)src/org/eclipse/jdt/core/tests/model/NamingConventionTests.java (-202 / +627 lines)
Lines 41-47 Link Here
41
	super.setUp();
41
	super.setUp();
42
	this.project = createJavaProject("P", new String[]{"src"}, "bin"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
42
	this.project = createJavaProject("P", new String[]{"src"}, "bin"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
43
	this.oldOptions = JavaCore.getOptions();
43
	this.oldOptions = JavaCore.getOptions();
44
	this.abortOnFailure = false; // some tests have failing one time on macos boxes => do not abort on failures
44
//	this.abortOnFailure = false; // some tests have failing one time on macos boxes => do not abort on failures
45
}
45
}
46
/**
46
/**
47
 * Cleanup after the previous test.
47
 * Cleanup after the previous test.
Lines 53-97 Link Here
53
53
54
	super.tearDown();
54
	super.tearDown();
55
}
55
}
56
private String toString(char[][] suggestions) {
56
/*
57
	if(suggestions == null) {
57
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
58
		return ""; //$NON-NLS-1$
58
 */
59
	}
59
public void testGetBaseName001() {
60
60
	String baseName = NamingConventions.getBaseName(
61
	StringBuffer buffer = new StringBuffer();
61
			NamingConventions.VK_INSTANCE_FIELD,
62
	for (int i = 0; i < suggestions.length; i++) {
62
			"OneName", //$NON-NLS-1$
63
		if(i != 0) {
63
			this.project);
64
			buffer.append('\n');
64
	
65
		}
65
	assertEquals(
66
		buffer.append(suggestions[i]);
66
			"OneName", //$NON-NLS-1$
67
	}
67
			baseName);
68
	return buffer.toString();
68
}
69
/*
70
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
71
 */
72
public void testGetBaseName002() {
73
	String baseName = NamingConventions.getBaseName(
74
			NamingConventions.VK_CONSTANT_FIELD,
75
			"ONE_NAME", //$NON-NLS-1$
76
			this.project);
77
	
78
	assertEquals(
79
			"OneName", //$NON-NLS-1$
80
			baseName);
81
}
82
/*
83
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
84
 */
85
public void testGetBaseName003() {
86
	Hashtable options = JavaCore.getOptions();
87
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"pre"); //$NON-NLS-1$
88
	options.put(JavaCore.CODEASSIST_FIELD_SUFFIXES,"suf"); //$NON-NLS-1$
89
	JavaCore.setOptions(options);
90
	
91
	String baseName = NamingConventions.getBaseName(
92
			NamingConventions.VK_INSTANCE_FIELD,
93
			"preOneNamesuf", //$NON-NLS-1$
94
			this.project);
95
	
96
	assertEquals(
97
			"OneName", //$NON-NLS-1$
98
			baseName);
99
}
100
/*
101
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
102
 */
103
public void testGetBaseName004() {
104
	Hashtable options = JavaCore.getOptions();
105
	options.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXES,"pre"); //$NON-NLS-1$
106
	options.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES,"suf"); //$NON-NLS-1$
107
	JavaCore.setOptions(options);
108
	
109
	String baseName = NamingConventions.getBaseName(
110
			NamingConventions.VK_CONSTANT_FIELD,
111
			"preONE_NAMEsuf", //$NON-NLS-1$
112
			this.project);
113
	
114
	assertEquals(
115
			"OneName", //$NON-NLS-1$
116
			baseName);
69
}
117
}
70
public void testSuggestFieldName001() {
118
public void testSuggestFieldName001() {
71
	char[][] suggestions = NamingConventions.suggestFieldNames(
119
	String[] suggestions = NamingConventions.suggestVariableNames(
72
		this.project,
120
			NamingConventions.VK_INSTANCE_FIELD,
73
		"a.b.c".toCharArray(), //$NON-NLS-1$
121
			NamingConventions.BK_TYPE_NAME,
74
		"OneName".toCharArray(), //$NON-NLS-1$
122
			"OneName", //$NON-NLS-1$
75
		0,
123
			this.project,
76
		0,
124
			0,
77
		CharOperation.NO_CHAR_CHAR);
125
			new String[]{},
126
			true);
127
78
	assumeEquals(
128
	assumeEquals(
79
		"name\n" + //$NON-NLS-1$
129
		"oneName\n" + //$NON-NLS-1$
80
		"oneName", //$NON-NLS-1$
130
		"name", //$NON-NLS-1$
81
		toString(suggestions));
131
		toString(suggestions));
82
}
132
}
83
public void testSuggestFieldName002() {
133
public void testSuggestFieldName002() {
84
	char[][] suggestions = NamingConventions.suggestFieldNames(
134
	String[] suggestions = NamingConventions.suggestVariableNames(
85
		this.project,
135
			NamingConventions.VK_INSTANCE_FIELD,
86
		"a.b.c".toCharArray(), //$NON-NLS-1$
136
			NamingConventions.BK_TYPE_NAME,
87
		"OneClass".toCharArray(), //$NON-NLS-1$
137
			"OneClass", //$NON-NLS-1$
88
		0,
138
			this.project,
89
		0,
139
			0,
90
		CharOperation.NO_CHAR_CHAR);
140
			new String[]{},
91
141
			true);
142
	
92
	assumeEquals(
143
	assumeEquals(
93
		"class1\n" + //$NON-NLS-1$
144
		"oneClass\n" + //$NON-NLS-1$
94
		"oneClass", //$NON-NLS-1$
145
		"class1", //$NON-NLS-1$
95
		toString(suggestions));
146
		toString(suggestions));
96
}
147
}
97
public void testSuggestFieldName003() {
148
public void testSuggestFieldName003() {
Lines 99-117 Link Here
99
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"f"); //$NON-NLS-1$
150
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"f"); //$NON-NLS-1$
100
	JavaCore.setOptions(options);
151
	JavaCore.setOptions(options);
101
152
102
	char[][] suggestions = NamingConventions.suggestFieldNames(
153
	String[] suggestions = NamingConventions.suggestVariableNames(
103
		this.project,
154
			NamingConventions.VK_INSTANCE_FIELD,
104
		"a.b.c".toCharArray(), //$NON-NLS-1$
155
			NamingConventions.BK_TYPE_NAME,
105
		"OneName".toCharArray(), //$NON-NLS-1$
156
			"OneName", //$NON-NLS-1$
106
		0,
157
			this.project,
107
		0,
158
			0,
108
		CharOperation.NO_CHAR_CHAR);
159
			new String[]{},
160
			true);
109
161
110
	assumeEquals(
162
	assumeEquals(
111
		"fName\n" + //$NON-NLS-1$
112
		"fOneName\n" + //$NON-NLS-1$
163
		"fOneName\n" + //$NON-NLS-1$
113
		"name\n" + //$NON-NLS-1$
164
		"fName\n" + //$NON-NLS-1$
114
		"oneName", //$NON-NLS-1$
165
		"oneName\n" + //$NON-NLS-1$
166
		"name", //$NON-NLS-1$
115
		toString(suggestions));
167
		toString(suggestions));
116
}
168
}
117
public void testSuggestFieldName004() {
169
public void testSuggestFieldName004() {
Lines 119-137 Link Here
119
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"_"); //$NON-NLS-1$
171
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"_"); //$NON-NLS-1$
120
	JavaCore.setOptions(options);
172
	JavaCore.setOptions(options);
121
173
122
	char[][] suggestions = NamingConventions.suggestFieldNames(
174
	String[] suggestions = NamingConventions.suggestVariableNames(
123
		this.project,
175
			NamingConventions.VK_INSTANCE_FIELD,
124
		"a.b.c".toCharArray(), //$NON-NLS-1$
176
			NamingConventions.BK_TYPE_NAME,
125
		"OneName".toCharArray(), //$NON-NLS-1$
177
			"OneName", //$NON-NLS-1$
126
		0,
178
			this.project,
127
		0,
179
			0,
128
		CharOperation.NO_CHAR_CHAR);
180
			new String[]{},
181
			true);
129
182
130
	assumeEquals(
183
	assumeEquals(
131
		"_name\n" + //$NON-NLS-1$
132
		"_oneName\n" + //$NON-NLS-1$
184
		"_oneName\n" + //$NON-NLS-1$
133
		"name\n" + //$NON-NLS-1$
185
		"_name\n" + //$NON-NLS-1$
134
		"oneName", //$NON-NLS-1$
186
		"oneName\n" + //$NON-NLS-1$
187
		"name", //$NON-NLS-1$
135
		toString(suggestions));
188
		toString(suggestions));
136
}
189
}
137
public void testSuggestFieldName005() {
190
public void testSuggestFieldName005() {
Lines 139-158 Link Here
139
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"f"); //$NON-NLS-1$
192
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"f"); //$NON-NLS-1$
140
	options.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES,"fg"); //$NON-NLS-1$
193
	options.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES,"fg"); //$NON-NLS-1$
141
	JavaCore.setOptions(options);
194
	JavaCore.setOptions(options);
142
195
	
143
	char[][] suggestions = NamingConventions.suggestFieldNames(
196
	String[] suggestions = NamingConventions.suggestVariableNames(
144
		this.project,
197
			NamingConventions.VK_STATIC_FIELD,
145
		"a.b.c".toCharArray(), //$NON-NLS-1$
198
			NamingConventions.BK_TYPE_NAME,
146
		"OneName".toCharArray(), //$NON-NLS-1$
199
			"OneName", //$NON-NLS-1$
147
		0,
200
			this.project,
148
		Flags.AccStatic,
201
			0,
149
		CharOperation.NO_CHAR_CHAR);
202
			new String[]{},
203
			true);
150
204
151
	assumeEquals(
205
	assumeEquals(
152
		"fgName\n" + //$NON-NLS-1$
153
		"fgOneName\n" + //$NON-NLS-1$
206
		"fgOneName\n" + //$NON-NLS-1$
154
		"name\n" + //$NON-NLS-1$
207
		"fgName\n" + //$NON-NLS-1$
155
		"oneName", //$NON-NLS-1$
208
		"oneName\n" + //$NON-NLS-1$
209
		"name", //$NON-NLS-1$
156
		toString(suggestions));
210
		toString(suggestions));
157
}
211
}
158
public void testSuggestFieldName006() {
212
public void testSuggestFieldName006() {
Lines 161-183 Link Here
161
	options.put(JavaCore.CODEASSIST_FIELD_SUFFIXES,"suf"); //$NON-NLS-1$
215
	options.put(JavaCore.CODEASSIST_FIELD_SUFFIXES,"suf"); //$NON-NLS-1$
162
	JavaCore.setOptions(options);
216
	JavaCore.setOptions(options);
163
217
164
	char[][] suggestions = NamingConventions.suggestFieldNames(
218
	String[] suggestions = NamingConventions.suggestVariableNames(
165
		this.project,
219
			NamingConventions.VK_INSTANCE_FIELD,
166
		"a.b.c".toCharArray(), //$NON-NLS-1$
220
			NamingConventions.BK_TYPE_NAME,
167
		"OneName".toCharArray(), //$NON-NLS-1$
221
			"OneName", //$NON-NLS-1$
168
		0,
222
			this.project,
169
		0,
223
			0,
170
		CharOperation.NO_CHAR_CHAR);
224
			new String[]{},
225
			true);
171
226
172
	assumeEquals(
227
	assumeEquals(
173
		"preNamesuf\n" + //$NON-NLS-1$
174
		"preOneNamesuf\n" + //$NON-NLS-1$
228
		"preOneNamesuf\n" + //$NON-NLS-1$
175
		"preName\n" + //$NON-NLS-1$
229
		"preNamesuf\n" + //$NON-NLS-1$
176
		"preOneName\n" + //$NON-NLS-1$
230
		"preOneName\n" + //$NON-NLS-1$
177
		"namesuf\n" + //$NON-NLS-1$
231
		"preName\n" + //$NON-NLS-1$
178
		"oneNamesuf\n" + //$NON-NLS-1$
232
		"oneNamesuf\n" + //$NON-NLS-1$
179
		"name\n" + //$NON-NLS-1$
233
		"namesuf\n" + //$NON-NLS-1$
180
		"oneName", //$NON-NLS-1$
234
		"oneName\n" + //$NON-NLS-1$
235
		"name", //$NON-NLS-1$
181
		toString(suggestions));
236
		toString(suggestions));
182
}
237
}
183
public void testSuggestFieldName007() {
238
public void testSuggestFieldName007() {
Lines 186-198 Link Here
186
	options.put(JavaCore.CODEASSIST_FIELD_SUFFIXES,"suf"); //$NON-NLS-1$
241
	options.put(JavaCore.CODEASSIST_FIELD_SUFFIXES,"suf"); //$NON-NLS-1$
187
	JavaCore.setOptions(options);
242
	JavaCore.setOptions(options);
188
243
189
	char[][] suggestions = NamingConventions.suggestFieldNames(
244
	String[] suggestions = NamingConventions.suggestVariableNames(
190
		this.project,
245
			NamingConventions.VK_INSTANCE_FIELD,
191
		"a.b.c".toCharArray(), //$NON-NLS-1$
246
			NamingConventions.BK_TYPE_NAME,
192
		"int".toCharArray(), //$NON-NLS-1$
247
			"int", //$NON-NLS-1$
193
		0,
248
			this.project,
194
		0,
249
			0,
195
		CharOperation.NO_CHAR_CHAR);
250
			new String[]{},
251
			true);
196
252
197
	assumeEquals(
253
	assumeEquals(
198
		"preIsuf\n" + //$NON-NLS-1$
254
		"preIsuf\n" + //$NON-NLS-1$
Lines 202-218 Link Here
202
		toString(suggestions));
258
		toString(suggestions));
203
}
259
}
204
public void testSuggestFieldName008() {
260
public void testSuggestFieldName008() {
205
	char[][] suggestions = NamingConventions.suggestFieldNames(
261
	String[] suggestions = NamingConventions.suggestVariableNames(
206
		this.project,
262
			NamingConventions.VK_INSTANCE_FIELD,
207
		"a.b.c".toCharArray(), //$NON-NLS-1$
263
			NamingConventions.BK_TYPE_NAME,
208
		"OneName".toCharArray(), //$NON-NLS-1$
264
			"OneName", //$NON-NLS-1$
209
		0,
265
			this.project,
210
		0,
266
			0,
211
		new char[][]{"name".toCharArray()}); //$NON-NLS-1$
267
			new String[]{"name"}, //$NON-NLS-1$
268
			true);
212
269
213
	assumeEquals(
270
	assumeEquals(
214
		"name2\n" + //$NON-NLS-1$
271
		"oneName\n" + //$NON-NLS-1$
215
		"oneName", //$NON-NLS-1$
272
		"name2", //$NON-NLS-1$
216
		toString(suggestions));
273
		toString(suggestions));
217
}
274
}
218
public void testSuggestFieldName009() {
275
public void testSuggestFieldName009() {
Lines 221-243 Link Here
221
	options.put(JavaCore.CODEASSIST_FIELD_SUFFIXES,"suf"); //$NON-NLS-1$
278
	options.put(JavaCore.CODEASSIST_FIELD_SUFFIXES,"suf"); //$NON-NLS-1$
222
	JavaCore.setOptions(options);
279
	JavaCore.setOptions(options);
223
280
224
	char[][] suggestions = NamingConventions.suggestFieldNames(
281
	String[] suggestions = NamingConventions.suggestVariableNames(
225
		this.project,
282
			NamingConventions.VK_INSTANCE_FIELD,
226
		"a.b.c".toCharArray(), //$NON-NLS-1$
283
			NamingConventions.BK_TYPE_NAME,
227
		"OneName".toCharArray(), //$NON-NLS-1$
284
			"OneName", //$NON-NLS-1$
228
		0,
285
			this.project,
229
		0,
286
			0,
230
		new char[][]{"preNamesuf".toCharArray()}); //$NON-NLS-1$
287
			new String[]{"preNamesuf"}, //$NON-NLS-1$
231
288
			true);
289
	
232
	assumeEquals(
290
	assumeEquals(
233
		"preName2suf\n" + //$NON-NLS-1$
234
		"preOneNamesuf\n" + //$NON-NLS-1$
291
		"preOneNamesuf\n" + //$NON-NLS-1$
235
		"preName\n" + //$NON-NLS-1$
292
		"preName2suf\n" + //$NON-NLS-1$
236
		"preOneName\n" + //$NON-NLS-1$
293
		"preOneName\n" + //$NON-NLS-1$
237
		"namesuf\n" + //$NON-NLS-1$
294
		"preName\n" + //$NON-NLS-1$
238
		"oneNamesuf\n" + //$NON-NLS-1$
295
		"oneNamesuf\n" + //$NON-NLS-1$
239
		"name\n" + //$NON-NLS-1$
296
		"namesuf\n" + //$NON-NLS-1$
240
		"oneName", //$NON-NLS-1$
297
		"oneName\n" + //$NON-NLS-1$
298
		"name", //$NON-NLS-1$
241
		toString(suggestions));
299
		toString(suggestions));
242
}
300
}
243
public void testSuggestFieldName010() {
301
public void testSuggestFieldName010() {
Lines 245-344 Link Here
245
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"pre"); //$NON-NLS-1$
303
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"pre"); //$NON-NLS-1$
246
	options.put(JavaCore.CODEASSIST_FIELD_SUFFIXES,"suf"); //$NON-NLS-1$
304
	options.put(JavaCore.CODEASSIST_FIELD_SUFFIXES,"suf"); //$NON-NLS-1$
247
	JavaCore.setOptions(options);
305
	JavaCore.setOptions(options);
248
306
	
249
	char[][] suggestions = NamingConventions.suggestFieldNames(
307
	String[] suggestions = NamingConventions.suggestVariableNames(
250
		this.project,
308
			NamingConventions.VK_INSTANCE_FIELD,
251
		"a.b.c".toCharArray(), //$NON-NLS-1$
309
			NamingConventions.BK_TYPE_NAME,
252
		"OneName".toCharArray(), //$NON-NLS-1$
310
			"OneName", //$NON-NLS-1$
253
		1,
311
			this.project,
254
		0,
312
			1,
255
		new char[][]{"preNamesuf".toCharArray()}); //$NON-NLS-1$
313
			new String[]{"preNamesuf"}, //$NON-NLS-1$
314
			true);
256
315
257
	assumeEquals(
316
	assumeEquals(
258
		"preNamessuf\n" + //$NON-NLS-1$
259
		"preOneNamessuf\n" + //$NON-NLS-1$
317
		"preOneNamessuf\n" + //$NON-NLS-1$
260
		"preNames\n" + //$NON-NLS-1$
318
		"preNamessuf\n" + //$NON-NLS-1$
261
		"preOneNames\n" + //$NON-NLS-1$
319
		"preOneNames\n" + //$NON-NLS-1$
262
		"namessuf\n" + //$NON-NLS-1$
320
		"preNames\n" + //$NON-NLS-1$
263
		"oneNamessuf\n" + //$NON-NLS-1$
321
		"oneNamessuf\n" + //$NON-NLS-1$
264
		"names\n" + //$NON-NLS-1$
322
		"namessuf\n" + //$NON-NLS-1$
265
		"oneNames", //$NON-NLS-1$
323
		"oneNames\n" + //$NON-NLS-1$
324
		"names", //$NON-NLS-1$
266
		toString(suggestions));
325
		toString(suggestions));
267
}
326
}
268
public void testSuggestFieldName011() {
327
public void testSuggestFieldName011() {
269
	char[][] suggestions = NamingConventions.suggestFieldNames(
328
	
270
		this.project,
329
	String[] suggestions = NamingConventions.suggestVariableNames(
271
		"a.b.c".toCharArray(), //$NON-NLS-1$
330
			NamingConventions.VK_INSTANCE_FIELD,
272
		"Factory".toCharArray(), //$NON-NLS-1$
331
			NamingConventions.BK_TYPE_NAME,
273
		1,
332
			"Factory", //$NON-NLS-1$
274
		0,
333
			this.project,
275
		CharOperation.NO_CHAR_CHAR); //$NON-NLS-1$
334
			1,
335
			new String[]{},
336
			true);
276
337
277
	assumeEquals(
338
	assumeEquals(
278
		"factories", //$NON-NLS-1$
339
		"factories", //$NON-NLS-1$
279
		toString(suggestions));
340
		toString(suggestions));
280
}
341
}
281
public void testSuggestFieldName012() {
342
public void testSuggestFieldName012() {
282
	String[] suggestions = NamingConventions.suggestFieldNames(
343
	String[] suggestions = NamingConventions.suggestVariableNames(
283
		this.project,
344
			NamingConventions.VK_INSTANCE_FIELD,
284
		"a.b.c", //$NON-NLS-1$
345
			NamingConventions.BK_TYPE_NAME,
285
		"FooBar", //$NON-NLS-1$
346
			"FooBar", //$NON-NLS-1$
286
		0,
347
			this.project,
287
		0,
348
			0,
288
		new String[]{"bar"}); //$NON-NLS-1$
349
			new String[]{"bar"}, //$NON-NLS-1$
350
			true);
289
351
290
	assumeEquals(
352
	assumeEquals(
291
		"bar2\n" + //$NON-NLS-1$
353
		"fooBar\n" + //$NON-NLS-1$
292
		"fooBar", //$NON-NLS-1$
354
		"bar2", //$NON-NLS-1$
293
		toString(suggestions));
355
		toString(suggestions));
294
}
356
}
295
public void testSuggestFieldName013() {
357
public void testSuggestFieldName013() {
296
	char[][] suggestions = NamingConventions.suggestFieldNames(
358
	String[] suggestions = NamingConventions.suggestVariableNames(
297
		this.project,
359
			NamingConventions.VK_INSTANCE_FIELD,
298
		"java.lang".toCharArray(), //$NON-NLS-1$
360
			NamingConventions.BK_TYPE_NAME,
299
		"Class".toCharArray(), //$NON-NLS-1$
361
			"Class", //$NON-NLS-1$
300
		0,
362
			this.project,
301
		0,
363
			0,
302
		CharOperation.NO_CHAR_CHAR);
364
			new String[]{},
365
			true);
303
366
304
	assumeEquals(
367
	assumeEquals(
305
		"class1",//$NON-NLS-1$
368
		"class1",//$NON-NLS-1$
306
		toString(suggestions));
369
		toString(suggestions));
307
}
370
}
308
public void testSuggestFieldName014() {
371
public void testSuggestFieldName014() {
309
	char[][] suggestions = NamingConventions.suggestFieldNames(
372
	String[] suggestions = NamingConventions.suggestVariableNames(
310
		this.project,
373
			NamingConventions.VK_INSTANCE_FIELD,
311
		"java.lang".toCharArray(), //$NON-NLS-1$
374
			NamingConventions.BK_TYPE_NAME,
312
		"Class".toCharArray(), //$NON-NLS-1$
375
			"Class", //$NON-NLS-1$
313
		0,
376
			this.project,
314
		0,
377
			0,
315
		new char[][]{"class1".toCharArray()}); //$NON-NLS-1$
378
			new String[]{"class1"}, //$NON-NLS-1$
379
			true);
316
380
317
	assumeEquals(
381
	assumeEquals(
318
		"class2",//$NON-NLS-1$
382
		"class2",//$NON-NLS-1$
319
		toString(suggestions));
383
		toString(suggestions));
320
}
384
}
321
public void testSuggestFieldName015() {
385
public void testSuggestFieldName015() {
322
	char[][] suggestions = NamingConventions.suggestFieldNames(
386
	String[] suggestions = NamingConventions.suggestVariableNames(
323
		this.project,
387
			NamingConventions.VK_INSTANCE_FIELD,
324
		"".toCharArray(), //$NON-NLS-1$
388
			NamingConventions.BK_TYPE_NAME,
325
		"#".toCharArray(), //$NON-NLS-1$
389
			"#", //$NON-NLS-1$
326
		0,
390
			this.project,
327
		0,
391
			0,
328
		CharOperation.NO_CHAR_CHAR);
392
			new String[]{},
393
			true);
329
394
330
	assumeEquals(
395
	assumeEquals(
331
		"name",//$NON-NLS-1$
396
		"name",//$NON-NLS-1$
332
		toString(suggestions));
397
		toString(suggestions));
333
}
398
}
334
public void testSuggestFieldName016() {
399
public void testSuggestFieldName016() {
335
	char[][] suggestions = NamingConventions.suggestFieldNames(
400
	String[] suggestions = NamingConventions.suggestVariableNames(
336
		this.project,
401
			NamingConventions.VK_INSTANCE_FIELD,
337
		"".toCharArray(), //$NON-NLS-1$
402
			NamingConventions.BK_TYPE_NAME,
338
		"#".toCharArray(), //$NON-NLS-1$
403
			"#", //$NON-NLS-1$
339
		0,
404
			this.project,
340
		0,
405
			0,
341
		new char[][]{"name".toCharArray()}); //$NON-NLS-1$
406
			new String[]{"name"}, //$NON-NLS-1$
407
			true);
342
408
343
	assumeEquals(
409
	assumeEquals(
344
		"name2",//$NON-NLS-1$
410
		"name2",//$NON-NLS-1$
Lines 348-360 Link Here
348
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=35356
414
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=35356
349
 */
415
 */
350
public void testSuggestFieldName017() {
416
public void testSuggestFieldName017() {
351
	char[][] suggestions = NamingConventions.suggestFieldNames(
417
	String[] suggestions = NamingConventions.suggestVariableNames(
352
		this.project,
418
			NamingConventions.VK_INSTANCE_FIELD,
353
		"".toCharArray(), //$NON-NLS-1$
419
			NamingConventions.BK_TYPE_NAME,
354
		"names".toCharArray(), //$NON-NLS-1$
420
			"names", //$NON-NLS-1$
355
		0,
421
			this.project,
356
		0,
422
			0,
357
		new char[][]{});
423
			new String[]{},
424
			true);
358
425
359
	assumeEquals(
426
	assumeEquals(
360
		"names",//$NON-NLS-1$
427
		"names",//$NON-NLS-1$
Lines 364-376 Link Here
364
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=35356
431
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=35356
365
 */
432
 */
366
public void testSuggestFieldName018() {
433
public void testSuggestFieldName018() {
367
	char[][] suggestions = NamingConventions.suggestFieldNames(
434
	String[] suggestions = NamingConventions.suggestVariableNames(
368
		this.project,
435
			NamingConventions.VK_INSTANCE_FIELD,
369
		"".toCharArray(), //$NON-NLS-1$
436
			NamingConventions.BK_TYPE_NAME,
370
		"names".toCharArray(), //$NON-NLS-1$
437
			"names", //$NON-NLS-1$
371
		1,
438
			this.project,
372
		0,
439
			1,
373
		new char[][]{});
440
			new String[]{},
441
			true);
374
442
375
	assumeEquals(
443
	assumeEquals(
376
		"names",//$NON-NLS-1$
444
		"names",//$NON-NLS-1$
Lines 380-415 Link Here
380
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=35356
448
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=35356
381
 */
449
 */
382
public void testSuggestFieldName019() {
450
public void testSuggestFieldName019() {
383
	char[][] suggestions = NamingConventions.suggestFieldNames(
451
	String[] suggestions = NamingConventions.suggestVariableNames(
384
		this.project,
452
			NamingConventions.VK_INSTANCE_FIELD,
385
		"".toCharArray(), //$NON-NLS-1$
453
			NamingConventions.BK_TYPE_NAME,
386
		"MyClass".toCharArray(), //$NON-NLS-1$
454
			"MyClass", //$NON-NLS-1$
387
		0,
455
			this.project,
388
		0,
456
			0,
389
		new char[][]{});
457
			new String[]{},
458
			true);
390
459
391
	assumeEquals(
460
	assumeEquals(
392
		"class1\n" + //$NON-NLS-1$
461
		"myClass\n" + //$NON-NLS-1$
393
		"myClass", //$NON-NLS-1$
462
		"class1", //$NON-NLS-1$
394
		toString(suggestions));
463
		toString(suggestions));
395
}
464
}
396
/*
465
/*
397
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=35356
466
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=35356
398
 */
467
 */
399
public void testSuggestFieldName020() {
468
public void testSuggestFieldName020() {
400
	char[][] suggestions = NamingConventions.suggestFieldNames(
469
	String[] suggestions = NamingConventions.suggestVariableNames(
401
		this.project,
470
			NamingConventions.VK_INSTANCE_FIELD,
402
		"".toCharArray(), //$NON-NLS-1$
471
			NamingConventions.BK_TYPE_NAME,
403
		"MyClass".toCharArray(), //$NON-NLS-1$
472
			"MyClass", //$NON-NLS-1$
404
		1,
473
			this.project,
405
		0,
474
			1,
406
		new char[][]{});
475
			new String[]{},
476
			true);
477
478
	assumeEquals(
479
		"myClasses\n" + //$NON-NLS-1$
480
		"classes", //$NON-NLS-1$
481
		toString(suggestions));
482
}
483
/*
484
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
485
 */
486
public void testSuggestFieldName021() {
487
	String[] suggestions = NamingConventions.suggestVariableNames(
488
			NamingConventions.VK_CONSTANT_FIELD,
489
			NamingConventions.BK_TYPE_NAME,
490
			"MyType", //$NON-NLS-1$
491
			this.project,
492
			0,
493
			new String[]{},
494
			true);
495
496
	assumeEquals(
497
		"MY_TYPE\n" + //$NON-NLS-1$
498
		"TYPE", //$NON-NLS-1$
499
		toString(suggestions));
500
}
501
/*
502
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
503
 */
504
public void testSuggestFieldName022() {
505
	Hashtable options = JavaCore.getOptions();
506
	options.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXES,"pre"); //$NON-NLS-1$
507
	options.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES,"suf"); //$NON-NLS-1$
508
	JavaCore.setOptions(options);
509
	
510
	String[] suggestions = NamingConventions.suggestVariableNames(
511
			NamingConventions.VK_CONSTANT_FIELD,
512
			NamingConventions.BK_TYPE_NAME,
513
			"MyType", //$NON-NLS-1$
514
			this.project,
515
			0,
516
			new String[]{},
517
			true);
518
519
	assumeEquals(
520
		"preMY_TYPEsuf\n" + //$NON-NLS-1$
521
		"preTYPEsuf\n" + //$NON-NLS-1$
522
		"preMY_TYPE\n" + //$NON-NLS-1$
523
		"preTYPE\n" + //$NON-NLS-1$
524
		"MY_TYPEsuf\n" + //$NON-NLS-1$
525
		"TYPEsuf\n" + //$NON-NLS-1$
526
		"MY_TYPE\n" + //$NON-NLS-1$
527
		"TYPE", //$NON-NLS-1$
528
		toString(suggestions));
529
}
530
/*
531
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
532
 */
533
public void testSuggestFieldName023() {
534
	String[] suggestions = NamingConventions.suggestVariableNames(
535
			NamingConventions.VK_INSTANCE_FIELD,
536
			NamingConventions.BK_NAME,
537
			"oneName", //$NON-NLS-1$
538
			this.project,
539
			0,
540
			new String[]{},
541
			true);
542
543
	assumeEquals(
544
		"oneName", //$NON-NLS-1$
545
		toString(suggestions));
546
}
547
/*
548
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
549
 */
550
public void testSuggestFieldName024() {
551
	Hashtable options = JavaCore.getOptions();
552
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"pre"); //$NON-NLS-1$
553
	options.put(JavaCore.CODEASSIST_FIELD_SUFFIXES,"suf"); //$NON-NLS-1$
554
	JavaCore.setOptions(options);
555
	
556
	String[] suggestions = NamingConventions.suggestVariableNames(
557
			NamingConventions.VK_INSTANCE_FIELD,
558
			NamingConventions.BK_NAME,
559
			"oneName", //$NON-NLS-1$
560
			this.project,
561
			0,
562
			new String[]{},
563
			true);
564
565
	assumeEquals(
566
		"preOneNamesuf\n" + //$NON-NLS-1$
567
		"preOneName\n" + //$NON-NLS-1$
568
		"oneNamesuf\n" + //$NON-NLS-1$
569
		"oneName", //$NON-NLS-1$
570
		toString(suggestions));
571
}
572
/*
573
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
574
 */
575
public void testSuggestFieldName025() {
576
	String[] suggestions = NamingConventions.suggestVariableNames(
577
			NamingConventions.VK_CONSTANT_FIELD,
578
			NamingConventions.BK_TYPE_NAME,
579
			"My_Type", //$NON-NLS-1$
580
			this.project,
581
			0,
582
			new String[]{},
583
			true);
584
585
	assumeEquals(
586
		"MY_TYPE\n" + //$NON-NLS-1$
587
		"TYPE", //$NON-NLS-1$
588
		toString(suggestions));
589
}
590
/*
591
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
592
 */
593
public void testSuggestFieldName026() {
594
	String[] suggestions = NamingConventions.suggestVariableNames(
595
			NamingConventions.VK_CONSTANT_FIELD,
596
			NamingConventions.BK_TYPE_NAME,
597
			"_MyType", //$NON-NLS-1$
598
			this.project,
599
			0,
600
			new String[]{},
601
			true);
602
603
	assumeEquals(
604
		"MY_TYPE\n" + //$NON-NLS-1$
605
		"TYPE", //$NON-NLS-1$
606
		toString(suggestions));
607
}
608
/*
609
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
610
 */
611
public void testSuggestFieldName027() {
612
	String[] suggestions = NamingConventions.suggestVariableNames(
613
			NamingConventions.VK_CONSTANT_FIELD,
614
			NamingConventions.BK_TYPE_NAME,
615
			"MyType_", //$NON-NLS-1$
616
			this.project,
617
			0,
618
			new String[]{},
619
			true);
620
621
	assumeEquals(
622
		"MY_TYPE\n" + //$NON-NLS-1$
623
		"TYPE", //$NON-NLS-1$
624
		toString(suggestions));
625
}
626
/*
627
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
628
 */
629
public void testSuggestFieldName028() {
630
	String[] suggestions = NamingConventions.suggestVariableNames(
631
			NamingConventions.VK_CONSTANT_FIELD,
632
			NamingConventions.BK_TYPE_NAME,
633
			"MyTyp_e", //$NON-NLS-1$
634
			this.project,
635
			0,
636
			new String[]{},
637
			true);
638
639
	assumeEquals(
640
		"MY_TYP_E\n" + //$NON-NLS-1$
641
		"TYP_E\n" + //$NON-NLS-1$
642
		"E", //$NON-NLS-1$
643
		toString(suggestions));
644
}
645
/*
646
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
647
 */
648
public void testSuggestFieldName029() {
649
	String[] suggestions = NamingConventions.suggestVariableNames(
650
			NamingConventions.VK_INSTANCE_FIELD,
651
			NamingConventions.BK_TYPE_NAME,
652
			"My1Type", //$NON-NLS-1$
653
			this.project,
654
			0,
655
			new String[]{},
656
			true);
657
658
	assumeEquals(
659
		"my1Type\n" + //$NON-NLS-1$
660
		"type", //$NON-NLS-1$
661
		toString(suggestions));
662
}
663
/*
664
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
665
 */
666
public void testSuggestFieldName030() {
667
	String[] suggestions = NamingConventions.suggestVariableNames(
668
			NamingConventions.VK_INSTANCE_FIELD,
669
			NamingConventions.BK_TYPE_NAME,
670
			"M1yType", //$NON-NLS-1$
671
			this.project,
672
			0,
673
			new String[]{},
674
			true);
675
676
	assumeEquals(
677
		"m1yType\n" + //$NON-NLS-1$
678
		"type", //$NON-NLS-1$
679
		toString(suggestions));
680
}
681
/*
682
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
683
 */
684
public void testSuggestFieldName031() {
685
	String[] suggestions = NamingConventions.suggestVariableNames(
686
			NamingConventions.VK_INSTANCE_FIELD,
687
			NamingConventions.BK_TYPE_NAME,
688
			"MY1Type", //$NON-NLS-1$
689
			this.project,
690
			0,
691
			new String[]{},
692
			true);
693
694
	assumeEquals(
695
		"my1Type\n" + //$NON-NLS-1$
696
		"type", //$NON-NLS-1$
697
		toString(suggestions));
698
}
699
/*
700
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
701
 */
702
public void testSuggestFieldName032() {
703
	String[] suggestions = NamingConventions.suggestVariableNames(
704
			NamingConventions.VK_INSTANCE_FIELD,
705
			NamingConventions.BK_TYPE_NAME,
706
			"M1YType", //$NON-NLS-1$
707
			this.project,
708
			0,
709
			new String[]{},
710
			true);
711
712
	assumeEquals(
713
		"m1yType\n" + //$NON-NLS-1$
714
		"type", //$NON-NLS-1$
715
		toString(suggestions));
716
}
717
/*
718
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
719
 */
720
public void testSuggestFieldName033() {
721
	String[] suggestions = NamingConventions.suggestVariableNames(
722
			NamingConventions.VK_INSTANCE_FIELD,
723
			NamingConventions.BK_TYPE_NAME,
724
			"My_First_Type", //$NON-NLS-1$
725
			this.project,
726
			0,
727
			new String[]{},
728
			true);
729
730
	assumeEquals(
731
		"myFirstType\n" +  //$NON-NLS-1$
732
		"firstType\n" +  //$NON-NLS-1$
733
		"type", //$NON-NLS-1$
734
		toString(suggestions));
735
}
736
/*
737
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
738
 */
739
public void testSuggestFieldName034() {
740
	String[] suggestions = NamingConventions.suggestVariableNames(
741
			NamingConventions.VK_INSTANCE_FIELD,
742
			NamingConventions.BK_TYPE_NAME,
743
			"MY_FIRST_Type", //$NON-NLS-1$
744
			this.project,
745
			0,
746
			new String[]{},
747
			true);
748
749
	assumeEquals(
750
		"myFirstType\n" +  //$NON-NLS-1$
751
		"firstType\n" +  //$NON-NLS-1$
752
		"type", //$NON-NLS-1$
753
		toString(suggestions));
754
}
755
/*
756
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
757
 */
758
public void testSuggestFieldName035() {
759
	String[] suggestions = NamingConventions.suggestVariableNames(
760
			NamingConventions.VK_INSTANCE_FIELD,
761
			NamingConventions.BK_TYPE_NAME,
762
			"my_first_Type", //$NON-NLS-1$
763
			this.project,
764
			0,
765
			new String[]{},
766
			true);
767
768
	assumeEquals(
769
		"myFirstType\n" + //$NON-NLS-1$
770
		"firstType\n" + //$NON-NLS-1$
771
		"type", //$NON-NLS-1$
772
		toString(suggestions));
773
}
774
/*
775
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
776
 */
777
public void testSuggestFieldName036() {
778
	String[] suggestions = NamingConventions.suggestVariableNames(
779
			NamingConventions.VK_INSTANCE_FIELD,
780
			NamingConventions.BK_TYPE_NAME,
781
			"MyFirst_9_Type", //$NON-NLS-1$
782
			this.project,
783
			0,
784
			new String[]{},
785
			true);
786
787
	assumeEquals(
788
		"myFirst_9Type\n" + //$NON-NLS-1$
789
		"first_9Type\n" + //$NON-NLS-1$
790
		"type", //$NON-NLS-1$
791
		toString(suggestions));
792
}
793
/*
794
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
795
 */
796
public void testSuggestFieldName037() {
797
	String[] suggestions = NamingConventions.suggestVariableNames(
798
			NamingConventions.VK_INSTANCE_FIELD,
799
			NamingConventions.BK_TYPE_NAME,
800
			"AType", //$NON-NLS-1$
801
			this.project,
802
			0,
803
			new String[]{},
804
			true);
805
806
	assumeEquals(
807
		"aType\n" + //$NON-NLS-1$
808
		"type", //$NON-NLS-1$
809
		toString(suggestions));
810
}
811
/*
812
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=38111
813
 */
814
public void testSuggestFieldName038() {
815
	String[] suggestions = NamingConventions.suggestVariableNames(
816
			NamingConventions.VK_INSTANCE_FIELD,
817
			NamingConventions.BK_TYPE_NAME,
818
			"aType", //$NON-NLS-1$
819
			this.project,
820
			0,
821
			new String[]{},
822
			true);
407
823
408
	assumeEquals(
824
	assumeEquals(
409
		"classes\n" + //$NON-NLS-1$
825
		"aType\n" + //$NON-NLS-1$
410
		"myClasses", //$NON-NLS-1$
826
		"type", //$NON-NLS-1$
411
		toString(suggestions));
827
		toString(suggestions));
412
}
828
}
829
/** @deprecated */
413
public void testRemovePrefixAndSuffixForFieldName001() {
830
public void testRemovePrefixAndSuffixForFieldName001() {
414
	Hashtable options = JavaCore.getOptions();
831
	Hashtable options = JavaCore.getOptions();
415
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"pre"); //$NON-NLS-1$
832
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"pre"); //$NON-NLS-1$
Lines 425-430 Link Here
425
		"oneName", //$NON-NLS-1$
842
		"oneName", //$NON-NLS-1$
426
		new String(name));
843
		new String(name));
427
}
844
}
845
/** @deprecated */
428
public void testRemovePrefixAndSuffixForFieldName002() {
846
public void testRemovePrefixAndSuffixForFieldName002() {
429
	Hashtable options = JavaCore.getOptions();
847
	Hashtable options = JavaCore.getOptions();
430
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"pr, pre"); //$NON-NLS-1$
848
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"pr, pre"); //$NON-NLS-1$
Lines 440-445 Link Here
440
		"preOneNamesuf", //$NON-NLS-1$
858
		"preOneNamesuf", //$NON-NLS-1$
441
		new String(name));
859
		new String(name));
442
}
860
}
861
/** @deprecated */
443
public void testRemovePrefixAndSuffixForFieldName003() {
862
public void testRemovePrefixAndSuffixForFieldName003() {
444
	Hashtable options = JavaCore.getOptions();
863
	Hashtable options = JavaCore.getOptions();
445
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"pr, pre"); //$NON-NLS-1$
864
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"pr, pre"); //$NON-NLS-1$
Lines 456-461 Link Here
456
		new String(name));
875
		new String(name));
457
}
876
}
458
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=114086
877
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=114086
878
/** @deprecated */
459
public void testRemovePrefixAndSuffixForFieldName004() {
879
public void testRemovePrefixAndSuffixForFieldName004() {
460
	Hashtable options = JavaCore.getOptions();
880
	Hashtable options = JavaCore.getOptions();
461
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"pre,"); //$NON-NLS-1$
881
	options.put(JavaCore.CODEASSIST_FIELD_PREFIXES,"pre,"); //$NON-NLS-1$
Lines 470-475 Link Here
470
		"oneName", //$NON-NLS-1$
890
		"oneName", //$NON-NLS-1$
471
		new String(name));
891
		new String(name));
472
}
892
}
893
/** @deprecated */
473
public void testRemovePrefixAndSuffixForLocalName001() {
894
public void testRemovePrefixAndSuffixForLocalName001() {
474
	Hashtable options = JavaCore.getOptions();
895
	Hashtable options = JavaCore.getOptions();
475
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pr, pre"); //$NON-NLS-1$
896
	options.put(JavaCore.CODEASSIST_LOCAL_PREFIXES,"pr, pre"); //$NON-NLS-1$
Lines 633-644 Link Here
633
		newOptions.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
1054
		newOptions.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
634
		this.project.setOptions(newOptions);
1055
		this.project.setOptions(newOptions);
635
1056
636
		String[] suggestions = NamingConventions.suggestLocalVariableNames(
1057
		String[] suggestions = NamingConventions.suggestVariableNames(
1058
			NamingConventions.VK_LOCAL,
1059
			NamingConventions.BK_TYPE_NAME,
1060
			"Enum",
637
			this.project,
1061
			this.project,
638
			"",//$NON-NLS-1$
639
			"Enum",//$NON-NLS-1$
640
			0,
1062
			0,
641
			new String[]{"o"});
1063
			new String[]{"o"}, //$NON-NLS-1$
1064
			true);
642
1065
643
		assumeEquals(
1066
		assumeEquals(
644
			"enum1", //$NON-NLS-1$
1067
			"enum1", //$NON-NLS-1$
Lines 659-670 Link Here
659
		newOptions.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
1082
		newOptions.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
660
		this.project.setOptions(newOptions);
1083
		this.project.setOptions(newOptions);
661
1084
662
		String[] suggestions = NamingConventions.suggestLocalVariableNames(
1085
		String[] suggestions = NamingConventions.suggestVariableNames(
1086
			NamingConventions.VK_LOCAL,
1087
			NamingConventions.BK_TYPE_NAME,
1088
			"Enums",
663
			this.project,
1089
			this.project,
664
			"",//$NON-NLS-1$
665
			"Enums",//$NON-NLS-1$
666
			0,
1090
			0,
667
			new String[]{"o"});
1091
			new String[]{"o"}, //$NON-NLS-1$
1092
			true);
668
1093
669
		assumeEquals(
1094
		assumeEquals(
670
			"enums", //$NON-NLS-1$
1095
			"enums", //$NON-NLS-1$

Return to bug 38111