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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/InternalNamingConventions.java (-13 / +21 lines)
Lines 282-293 Link Here
282
	}
282
	}
283
283
284
	private static char[][] computeBaseTypeNames(char[] typeName, boolean isConstantField, char[][] excludedNames){
284
	private static char[][] computeBaseTypeNames(char[] typeName, boolean isConstantField, char[][] excludedNames){
285
		char[] name = computeBaseTypeNames(typeName[0], excludedNames);
285
		if (isConstantField) {
286
		if(name != null) {
286
			return computeNonBaseTypeNames(typeName, isConstantField);
287
			return new char[][]{name};
288
		} else {
287
		} else {
289
			// compute variable name like from non base type
288
			char[] name = computeBaseTypeNames(typeName[0], excludedNames);
290
			return  computeNonBaseTypeNames(typeName, isConstantField);
289
			if(name != null) {
290
				return new char[][]{name};
291
			} else {
292
				// compute variable name like from non base type
293
				return computeNonBaseTypeNames(typeName, isConstantField);
294
			}
291
		}
295
		}
292
	}
296
	}
293
	private static char[] computeBaseTypeNames(char firstName, char[][] excludedNames){
297
	private static char[] computeBaseTypeNames(char firstName, char[][] excludedNames){
Lines 344-350 Link Here
344
		}
348
		}
345
		
349
		
346
		if (length == 1) {
350
		if (length == 1) {
347
			return new char[][]{CharOperation.toLowerCase(sourceName)};
351
			if (isConstantField) {
352
				return generateConstantName(new char[][]{CharOperation.toLowerCase(sourceName)}, 0);
353
			} else {
354
				return generateNonConstantName(new char[][]{CharOperation.toLowerCase(sourceName)}, 0);
355
			}
348
		}
356
		}
349
		
357
		
350
		char[][] nameParts = new char[length][];
358
		char[][] nameParts = new char[length][];
Lines 533-539 Link Here
533
				prefixes = assistOptions.staticFieldPrefixes;
541
				prefixes = assistOptions.staticFieldPrefixes;
534
				suffixes = assistOptions.staticFieldSuffixes;
542
				suffixes = assistOptions.staticFieldSuffixes;
535
				break;
543
				break;
536
			case VK_CONSTANT_FIELD:
544
			case VK_STATIC_FINAL_FIELD:
537
				prefixes = assistOptions.staticFinalFieldPrefixes;
545
				prefixes = assistOptions.staticFinalFieldPrefixes;
538
				suffixes = assistOptions.staticFinalFieldSuffixes;
546
				suffixes = assistOptions.staticFinalFieldSuffixes;
539
				break;
547
				break;
Lines 548-558 Link Here
548
		}
556
		}
549
		
557
		
550
		
558
		
551
		return getBaseName(name, prefixes, suffixes, variableKind == VK_CONSTANT_FIELD);
559
		return getBaseName(name, prefixes, suffixes, variableKind == VK_STATIC_FINAL_FIELD);
552
	}
560
	}
553
561
554
	private static char[] getBaseName(char[] name, char[][] prefixes, char[][] suffixes, boolean isConstant) {
562
	private static char[] getBaseName(char[] name, char[][] prefixes, char[][] suffixes, boolean isConstant) {
555
		char[] nameWithoutPrefixAndSiffix = removeVariablePrefixAndSuffix(name, prefixes, suffixes, false);
563
		char[] nameWithoutPrefixAndSiffix = removeVariablePrefixAndSuffix(name, prefixes, suffixes, true);
556
		
564
		
557
		char[] baseName;
565
		char[] baseName;
558
		if (isConstant) {
566
		if (isConstant) {
Lines 564-570 Link Here
564
			for (int i = 0; i < length; i++) {
572
			for (int i = 0; i < length; i++) {
565
				char c = nameWithoutPrefixAndSiffix[i];
573
				char c = nameWithoutPrefixAndSiffix[i];
566
				if (c != '_') {
574
				if (c != '_') {
567
					if (previousIsUnderscore || i == 0) {
575
					if (previousIsUnderscore) {
568
						baseName[++baseNamePtr] = ScannerHelper.toUpperCase(c);
576
						baseName[++baseNamePtr] = ScannerHelper.toUpperCase(c);
569
						previousIsUnderscore = false;
577
						previousIsUnderscore = false;
570
					} else {
578
					} else {
Lines 604-610 Link Here
604
				prefixes = assistOptions.staticFieldPrefixes;
612
				prefixes = assistOptions.staticFieldPrefixes;
605
				suffixes = assistOptions.staticFieldSuffixes;
613
				suffixes = assistOptions.staticFieldSuffixes;
606
				break;
614
				break;
607
			case VK_CONSTANT_FIELD:
615
			case VK_STATIC_FINAL_FIELD:
608
				prefixes = assistOptions.staticFinalFieldPrefixes;
616
				prefixes = assistOptions.staticFinalFieldPrefixes;
609
				suffixes = assistOptions.staticFinalFieldSuffixes;
617
				suffixes = assistOptions.staticFinalFieldSuffixes;
610
				break;
618
				break;
Lines 749-755 Link Here
749
	
757
	
750
	public static final int VK_STATIC_FIELD = 1;
758
	public static final int VK_STATIC_FIELD = 1;
751
	public static final int VK_INSTANCE_FIELD = 2;
759
	public static final int VK_INSTANCE_FIELD = 2;
752
	public static final int VK_CONSTANT_FIELD = 3;
760
	public static final int VK_STATIC_FINAL_FIELD = 3;
753
	public static final int VK_PARAMETER = 4;
761
	public static final int VK_PARAMETER = 4;
754
	public static final int VK_LOCAL = 5;
762
	public static final int VK_LOCAL = 5;
755
	
763
	
Lines 792-798 Link Here
792
				prefixes = assistOptions.staticFieldPrefixes;
800
				prefixes = assistOptions.staticFieldPrefixes;
793
				suffixes = assistOptions.staticFieldSuffixes;
801
				suffixes = assistOptions.staticFieldSuffixes;
794
				break;
802
				break;
795
			case VK_CONSTANT_FIELD:
803
			case VK_STATIC_FINAL_FIELD:
796
				isConstantField = true;
804
				isConstantField = true;
797
				prefixes = assistOptions.staticFinalFieldPrefixes;
805
				prefixes = assistOptions.staticFinalFieldPrefixes;
798
				suffixes = assistOptions.staticFinalFieldSuffixes;
806
				suffixes = assistOptions.staticFinalFieldSuffixes;
(-)model/org/eclipse/jdt/core/NamingConventions.java (-25 / +55 lines)
Lines 11-16 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
14
import org.eclipse.jdt.internal.codeassist.impl.AssistOptions;
15
import org.eclipse.jdt.internal.codeassist.impl.AssistOptions;
15
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
16
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper;
16
import org.eclipse.jdt.internal.core.INamingRequestor;
17
import org.eclipse.jdt.internal.core.INamingRequestor;
Lines 25-42 Link Here
25
 * The possible options are :
26
 * The possible options are :
26
 * <ul>
27
 * <ul>
27
 * <li> {@link JavaCore#CODEASSIST_FIELD_PREFIXES} : Define the Prefixes for Field Name.</li>
28
 * <li> {@link JavaCore#CODEASSIST_FIELD_PREFIXES} : Define the Prefixes for Field Name.</li>
28
 * <li> {@link JavaCore#CODEASSIST_STATIC_FIELD_PREFIXES} : Define the Prefixes for Static Field Name.</li>
29
 * <li> {@link JavaCore#CODEASSIST_LOCAL_PREFIXES} : Define the Prefixes for Local Variable Name.</li>
30
 * <li> {@link JavaCore#CODEASSIST_ARGUMENT_PREFIXES} : Define the Prefixes for Argument Name.</li>
31
 * <li> {@link JavaCore#CODEASSIST_FIELD_SUFFIXES} : Define the Suffixes for Field Name.</li>
29
 * <li> {@link JavaCore#CODEASSIST_FIELD_SUFFIXES} : Define the Suffixes for Field Name.</li>
30
 * 
31
 * <li> {@link JavaCore#CODEASSIST_STATIC_FIELD_PREFIXES} : Define the Prefixes for Static Field Name.</li>
32
 * <li> {@link JavaCore#CODEASSIST_STATIC_FIELD_SUFFIXES} : Define the Suffixes for Static Field Name.</li>
32
 * <li> {@link JavaCore#CODEASSIST_STATIC_FIELD_SUFFIXES} : Define the Suffixes for Static Field Name.</li>
33
 * 
34
 * <li> {@link JavaCore#CODEASSIST_STATIC_FINAL_FIELD_PREFIXES} : Define the Prefixes for Static Final Field Name.</li>
35
 * <li> {@link JavaCore#CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES} : Define the Suffixes for Static Final Field Name.</li>
36
 * 
37
 * <li> {@link JavaCore#CODEASSIST_LOCAL_PREFIXES} : Define the Prefixes for Local Variable Name.</li>
33
 * <li> {@link JavaCore#CODEASSIST_LOCAL_SUFFIXES} : Define the Suffixes for Local Variable Name.</li>
38
 * <li> {@link JavaCore#CODEASSIST_LOCAL_SUFFIXES} : Define the Suffixes for Local Variable Name.</li>
39
 * 
40
 * <li> {@link JavaCore#CODEASSIST_ARGUMENT_PREFIXES} : Define the Prefixes for Argument Name.</li>
34
 * <li> {@link JavaCore#CODEASSIST_ARGUMENT_SUFFIXES} : Define the Suffixes for Argument Name.</li>
41
 * <li> {@link JavaCore#CODEASSIST_ARGUMENT_SUFFIXES} : Define the Suffixes for Argument Name.</li>
35
 * </ul>
42
 * </ul>
36
 * </p>
43
 * </p>
37
 * <p>
44
 * <p>
38
 * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
45
 * For a complete description of the configurable options, see {@link JavaCore#getDefaultOptions()}.
39
 * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
46
 * To programmatically change these options, see {@link JavaCore#setOptions(java.util.Hashtable)}.
40
 * </p>
47
 * </p>
41
 * <p>
48
 * <p>
42
 * This class provides static methods and constants only.
49
 * This class provides static methods and constants only.
Lines 243-253 Link Here
243
	 */
250
	 */
244
	public static final int VK_INSTANCE_FIELD = InternalNamingConventions.VK_INSTANCE_FIELD;
251
	public static final int VK_INSTANCE_FIELD = InternalNamingConventions.VK_INSTANCE_FIELD;
245
	/**
252
	/**
253
	 * Variable kind which represents a static final field.
254
	 * 
255
	 * @since 3.5
256
	 */
257
	public static final int VK_STATIC_FINAL_FIELD = InternalNamingConventions.VK_STATIC_FINAL_FIELD;
258
	/**
246
	 * Variable kind which represents a constant field (static final).
259
	 * Variable kind which represents a constant field (static final).
247
	 * 
260
	 * 
248
	 * @since 3.5
261
	 * @since 3.5
262
	 * @deprecated use VK_STATIC_FINAL_FIELD instead. This constant will be removed before 3.5M5.
249
	 */
263
	 */
250
	public static final int VK_CONSTANT_FIELD = InternalNamingConventions.VK_CONSTANT_FIELD;
264
	public static final int VK_CONSTANT_FIELD = InternalNamingConventions.VK_STATIC_FINAL_FIELD;
251
	/**
265
	/**
252
	 * Variable kind which represents an argument.
266
	 * Variable kind which represents an argument.
253
	 * 
267
	 * 
Lines 542-553 Link Here
542
	 * Returns a base name which could be used to generate the given variable name with {@link #suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)}.
556
	 * Returns a base name which could be used to generate the given variable name with {@link #suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)}.
543
	 * <p>
557
	 * <p>
544
	 * e.g.<br>
558
	 * e.g.<br>
545
	 * 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>
559
	 * 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>
546
	 * 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>
560
	 * If the variable is a {@link #VK_STATIC_FINAL_FIELD} and the variable name is <code>VARIABLE_NAME</code> then the base name will be <code>variableName</code>.<br>
561
	 * </p>
562
	 * <p>
563
	 * Prefixes and suffixes defined in JavaCore options will be also removed from the variable name.<br>
564
	 * Each variable kind is affected by the following JavaCore options:
565
	 * <ul>
566
	 * <li>{@link #VK_PARAMETER}: {@link JavaCore#CODEASSIST_ARGUMENT_PREFIXES} and {@link JavaCore#CODEASSIST_ARGUMENT_SUFFIXES}</li>
567
	 * <li>{@link #VK_LOCAL}: {@link JavaCore#CODEASSIST_LOCAL_PREFIXES} and {@link JavaCore#CODEASSIST_LOCAL_SUFFIXES}</li>
568
	 * <li>{@link #VK_INSTANCE_FIELD}: {@link JavaCore#CODEASSIST_FIELD_PREFIXES} and {@link JavaCore#CODEASSIST_FIELD_SUFFIXES}</li>
569
	 * <li>{@link #VK_STATIC_FIELD}: {@link JavaCore#CODEASSIST_STATIC_FIELD_PREFIXES} and {@link JavaCore#CODEASSIST_STATIC_FIELD_SUFFIXES}</li>
570
	 * <li>{@link #VK_STATIC_FINAL_FIELD}: {@link JavaCore#CODEASSIST_STATIC_FINAL_FIELD_PREFIXES} and {@link JavaCore#CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES}</li>
571
	 * </ul>
572
	 * </p>
573
	 * <p>
574
	 * e.g.<br>
575
	 * If the variable is a {@link #VK_LOCAL}, the variable name is <code>preVariableNamesuf</code>, a possible prefix is <code>pre</code> and a possible suffix is <code>suf</code>
576
	 * then the base name will be <code>variableName</code>.<br>
547
	 * </p>
577
	 * </p>
548
	 * 
578
	 * 
549
	 * @param variableKind specifies what type the variable is: {@link #VK_LOCAL}, {@link #VK_PARAMETER}, {@link #VK_STATIC_FIELD},
579
	 * @param variableKind specifies what type the variable is: {@link #VK_LOCAL}, {@link #VK_PARAMETER}, {@link #VK_STATIC_FIELD},
550
	 * {@link #VK_INSTANCE_FIELD} or {@link #VK_CONSTANT_FIELD}.
580
	 * {@link #VK_INSTANCE_FIELD} or {@link #VK_STATIC_FINAL_FIELD}.
551
	 * @param variableName a variable name
581
	 * @param variableName a variable name
552
	 * @param javaProject project which contains the variable or <code>null</code> to take into account only workspace settings.
582
	 * @param javaProject project which contains the variable or <code>null</code> to take into account only workspace settings.
553
	 * 
583
	 * 
Lines 1041-1071 Link Here
1041
	 *
1071
	 *
1042
	 * <p>
1072
	 * <p>
1043
	 * The base name is used to compute the variable name.
1073
	 * The base name is used to compute the variable name.
1044
	 * Some different kinds of base name are possible and each kind is associated to a different heuristic to compute variable names.<br>
1074
	 * Some different kinds of base names are possible and each kind is associated to a different heuristic to compute variable names.<br>
1045
	 * The heuristic depends also on the kind of the variable. Each kind of variable is identified by a constant starting with <code>VK_</code>.<br>
1075
	 * The heuristic depends also on the kind of the variable. Each kind of variable is identified by a constant starting with <code>VK_</code>.<br>
1046
	 * When a prefix and a suffix can be added then all combinations of prefix and suffix are suggested.
1076
	 * When a prefix and a suffix can be added then all combinations of prefix and suffix are suggested.
1047
	 * 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
1077
	 * 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
1048
	 * <code>prenamesuf</code>, <code>prename</code>, <code>namesuf</code> and <code>name</code>.<br>
1078
	 * <code>prenamesuf</code>, <code>prename</code>, <code>namesuf</code> and <code>name</code>.<br>
1049
	 * <br>
1079
	 * <br>
1050
	 * The different kinds of base name are:
1080
	 * The different kinds of base names are:
1051
	 * <ul>
1081
	 * <ul>
1052
	 * <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>
1082
	 * <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>
1053
	 * There is an heuristic by variable kind.
1083
	 * There is a heuristic by variable kind.
1054
	 * <ul>
1084
	 * <ul>
1055
	 * <li>{@link #VK_PARAMETER}, {@link #VK_LOCAL}, {@link #VK_INSTANCE_FIELD} and {@link #VK_STATIC_FIELD}:<br>
1085
	 * <li>{@link #VK_PARAMETER}, {@link #VK_LOCAL}, {@link #VK_INSTANCE_FIELD} and {@link #VK_STATIC_FIELD}:<br>
1056
	 * In this case the first character will be converted to lower case and the other characters won't be changed.<br>
1086
	 * In this case the first character will be converted to lower case and the other characters won't be changed.<br>
1057
	 * If the base name is <code>SimpleName</code> then the suggested name will be <code>simpleName</code>.<br></li>
1087
	 * If the base name is <code>SimpleName</code> then the suggested name will be <code>simpleName</code>.<br></li>
1058
	 * <li>{@link #VK_CONSTANT_FIELD} :<br>
1088
	 * <li>{@link #VK_STATIC_FINAL_FIELD} :<br>
1059
	 * 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>
1089
	 * 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>
1060
	 * If the base name is <code>SimpleName</code> then the suggested name will be <code>SIMPLE_NAME</code>.</li>
1090
	 * If the base name is <code>SimpleName</code> then the suggested name will be <code>SIMPLE_NAME</code>.</li>
1061
	 * </ul></li>
1091
	 * </ul></li>
1062
	 * <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>
1092
	 * <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>
1063
	 * There is an heuristic by variable kind.
1093
	 * There is a heuristic by variable kind.
1064
	 * <ul>
1094
	 * <ul>
1065
	 * <li>{@link #VK_PARAMETER}, {@link #VK_LOCAL}, {@link #VK_INSTANCE_FIELD} and {@link #VK_STATIC_FIELD}:<br>
1095
	 * <li>{@link #VK_PARAMETER}, {@link #VK_LOCAL}, {@link #VK_INSTANCE_FIELD} and {@link #VK_STATIC_FIELD}:<br>
1066
	 * 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>
1096
	 * 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>
1067
	 * If the type is <code>TypeName</code> then the suggested names will be <code>typeName</code> and <code>name</code>.</li>
1097
	 * If the type is <code>TypeName</code> then the suggested names will be <code>typeName</code> and <code>name</code>.</li>
1068
	 * <li>{@link #VK_CONSTANT_FIELD} :<br>
1098
	 * <li>{@link #VK_STATIC_FINAL_FIELD} :<br>
1069
	 * 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>
1099
	 * 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>
1070
	 * If the base name is <code>TypeName</code> then the suggested name will be <code>TYPE_NAME</code> and <code>NAME</code>.</li>
1100
	 * If the base name is <code>TypeName</code> then the suggested name will be <code>TYPE_NAME</code> and <code>NAME</code>.</li>
1071
	 * </ul></li>
1101
	 * </ul></li>
Lines 1079-1111 Link Here
1079
	 * <li>{@link #VK_LOCAL}: {@link JavaCore#CODEASSIST_LOCAL_PREFIXES} and {@link JavaCore#CODEASSIST_LOCAL_SUFFIXES}</li>
1109
	 * <li>{@link #VK_LOCAL}: {@link JavaCore#CODEASSIST_LOCAL_PREFIXES} and {@link JavaCore#CODEASSIST_LOCAL_SUFFIXES}</li>
1080
	 * <li>{@link #VK_INSTANCE_FIELD}: {@link JavaCore#CODEASSIST_FIELD_PREFIXES} and {@link JavaCore#CODEASSIST_FIELD_SUFFIXES}</li>
1110
	 * <li>{@link #VK_INSTANCE_FIELD}: {@link JavaCore#CODEASSIST_FIELD_PREFIXES} and {@link JavaCore#CODEASSIST_FIELD_SUFFIXES}</li>
1081
	 * <li>{@link #VK_STATIC_FIELD}: {@link JavaCore#CODEASSIST_STATIC_FIELD_PREFIXES} and {@link JavaCore#CODEASSIST_STATIC_FIELD_SUFFIXES}</li>
1111
	 * <li>{@link #VK_STATIC_FIELD}: {@link JavaCore#CODEASSIST_STATIC_FIELD_PREFIXES} and {@link JavaCore#CODEASSIST_STATIC_FIELD_SUFFIXES}</li>
1082
	 * <li>{@link #VK_CONSTANT_FIELD}: {@link JavaCore#CODEASSIST_STATIC_FINAL_FIELD_PREFIXES} and {@link JavaCore#CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES}</li>
1112
	 * <li>{@link #VK_STATIC_FINAL_FIELD}: {@link JavaCore#CODEASSIST_STATIC_FINAL_FIELD_PREFIXES} and {@link JavaCore#CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES}</li>
1083
	 * </ul>
1113
	 * </ul>
1084
	 * </p>
1114
	 * </p>
1085
	 * <p>
1115
	 * <p>
1086
	 * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
1116
	 * For a complete description of these configurable options, see {@link JavaCore#getDefaultOptions()}.
1087
	 * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
1117
	 * To programmatically change these options, see {@link JavaCore#setOptions(java.util.Hashtable)} and {@link IJavaProject#setOptions(java.util.Map)}
1088
	 * </p>
1118
	 * </p>
1089
	 * <p>
1119
	 * <p>
1090
	 * Proposed names are sorted by relevance (best proposal first).<br>
1120
	 * Proposed names are sorted by relevance (best proposal first).<br>
1091
	 * The names are proposed in the following order:
1121
	 * The names are proposed in the following order:
1092
	 * <ol>
1122
	 * <ol>
1093
	 * <li>Names with prefix and suffix. Longest name are proposed first</li>
1123
	 * <li>Names with prefix and suffix. Longer names are proposed first</li>
1094
	 * <li>Names with prefix. Longest name are proposed first</li>
1124
	 * <li>Names with prefix. Longer names are proposed first</li>
1095
	 * <li>Names with suffix. Longest name are proposed first</li>
1125
	 * <li>Names with suffix. Longer names are proposed first</li>
1096
	 * <li>Names without prefix and suffix. Longest name are proposed first</li>
1126
	 * <li>Names without prefix and suffix. Longer names are proposed first</li>
1097
	 * </ol>
1127
	 * </ol>
1098
	 * </p>
1128
	 * </p>
1099
	 *
1129
	 *
1100
	 * @param variableKind specifies what type the variable is: {@link #VK_LOCAL}, {@link #VK_PARAMETER}, {@link #VK_STATIC_FIELD},
1130
	 * @param variableKind specifies what type the variable is: {@link #VK_LOCAL}, {@link #VK_PARAMETER}, {@link #VK_STATIC_FIELD},
1101
	 * {@link #VK_INSTANCE_FIELD} or {@link #VK_CONSTANT_FIELD}.
1131
	 * {@link #VK_INSTANCE_FIELD} or {@link #VK_STATIC_FINAL_FIELD}.
1102
	 * @param baseNameKind specifies what type the base name is: {@link #BK_NAME} or {@link #BK_TYPE_NAME}
1132
	 * @param baseNameKind specifies what type the base name is: {@link #BK_NAME} or {@link #BK_TYPE_NAME}
1103
	 * @param baseName name used to compute the suggested names.
1133
	 * @param baseName name used to compute the suggested names.
1104
	 * @param javaProject project which contains the variable or <code>null</code> to take into account only workspace settings.
1134
	 * @param javaProject project which contains the variable or <code>null</code> to take into account only workspace settings.
1105
	 * @param dim variable dimension (0 if the field is not an array).
1135
	 * @param dim variable dimension (0 if the field is not an array).
1106
	 * @param excluded a list of names which cannot be suggested (already used names).
1136
	 * @param excluded a list of names which cannot be suggested (already used names).
1107
	 *         Can be <code>null</code> if there is no excluded names.
1137
	 *         Can be <code>null</code> if there are no excluded names.
1108
	 * @param evaluateDefault if set, the result is guaranteed to contain at least one result. If not, the result can be an empty array. 
1138
	 * @param evaluateDefault if <code>true</code>, the result is guaranteed to contain at least one result. If <code>false</code>, the result can be an empty array.
1109
	 * @return String[] an array of names.
1139
	 * @return String[] an array of names.
1110
	 * @see JavaCore#setOptions(java.util.Hashtable)
1140
	 * @see JavaCore#setOptions(java.util.Hashtable)
1111
	 * @see JavaCore#getDefaultOptions()
1141
	 * @see JavaCore#getDefaultOptions()
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-2 / +2 lines)
Lines 1561-1567 Link Here
1561
						InternalNamingConventions.VK_INSTANCE_FIELD :
1561
						InternalNamingConventions.VK_INSTANCE_FIELD :
1562
							(field.modifiers & ClassFileConstants.AccFinal) == 0 ? 
1562
							(field.modifiers & ClassFileConstants.AccFinal) == 0 ? 
1563
									InternalNamingConventions.VK_STATIC_FIELD :
1563
									InternalNamingConventions.VK_STATIC_FIELD :
1564
										InternalNamingConventions.VK_CONSTANT_FIELD;
1564
										InternalNamingConventions.VK_STATIC_FINAL_FIELD;
1565
			
1565
			
1566
			findVariableNames(field.realName, field.type, excludeNames, null, kind);
1566
			findVariableNames(field.realName, field.type, excludeNames, null, kind);
1567
		}
1567
		}
Lines 2176-2182 Link Here
2176
						InternalNamingConventions.VK_INSTANCE_FIELD :
2176
						InternalNamingConventions.VK_INSTANCE_FIELD :
2177
							(method.modifiers & ClassFileConstants.AccFinal) == 0 ? 
2177
							(method.modifiers & ClassFileConstants.AccFinal) == 0 ? 
2178
									InternalNamingConventions.VK_STATIC_FIELD :
2178
									InternalNamingConventions.VK_STATIC_FIELD :
2179
										InternalNamingConventions.VK_CONSTANT_FIELD;
2179
										InternalNamingConventions.VK_STATIC_FINAL_FIELD;
2180
						
2180
						
2181
			findVariableNames(this.completionToken, method.returnType, excludeNames, null, kind);
2181
			findVariableNames(this.completionToken, method.returnType, excludeNames, null, kind);
2182
		}
2182
		}
(-)src/org/eclipse/jdt/core/tests/model/NamingConventionTests.java (-12 / +46 lines)
Lines 63-69 Link Here
63
			this.project);
63
			this.project);
64
	
64
	
65
	assertEquals(
65
	assertEquals(
66
			"OneName", //$NON-NLS-1$
66
			"oneName", //$NON-NLS-1$
67
			baseName);
67
			baseName);
68
}
68
}
69
/*
69
/*
Lines 71-82 Link Here
71
 */
71
 */
72
public void testGetBaseName002() {
72
public void testGetBaseName002() {
73
	String baseName = NamingConventions.getBaseName(
73
	String baseName = NamingConventions.getBaseName(
74
			NamingConventions.VK_CONSTANT_FIELD,
74
			NamingConventions.VK_STATIC_FINAL_FIELD,
75
			"ONE_NAME", //$NON-NLS-1$
75
			"ONE_NAME", //$NON-NLS-1$
76
			this.project);
76
			this.project);
77
	
77
	
78
	assertEquals(
78
	assertEquals(
79
			"OneName", //$NON-NLS-1$
79
			"oneName", //$NON-NLS-1$
80
			baseName);
80
			baseName);
81
}
81
}
82
/*
82
/*
Lines 94-100 Link Here
94
			this.project);
94
			this.project);
95
	
95
	
96
	assertEquals(
96
	assertEquals(
97
			"OneName", //$NON-NLS-1$
97
			"oneName", //$NON-NLS-1$
98
			baseName);
98
			baseName);
99
}
99
}
100
/*
100
/*
Lines 107-118 Link Here
107
	JavaCore.setOptions(options);
107
	JavaCore.setOptions(options);
108
	
108
	
109
	String baseName = NamingConventions.getBaseName(
109
	String baseName = NamingConventions.getBaseName(
110
			NamingConventions.VK_CONSTANT_FIELD,
110
			NamingConventions.VK_STATIC_FINAL_FIELD,
111
			"preONE_NAMEsuf", //$NON-NLS-1$
111
			"preONE_NAMEsuf", //$NON-NLS-1$
112
			this.project);
112
			this.project);
113
	
113
	
114
	assertEquals(
114
	assertEquals(
115
			"OneName", //$NON-NLS-1$
115
			"oneName", //$NON-NLS-1$
116
			baseName);
116
			baseName);
117
}
117
}
118
public void testSuggestFieldName001() {
118
public void testSuggestFieldName001() {
Lines 485-491 Link Here
485
 */
485
 */
486
public void testSuggestFieldName021() {
486
public void testSuggestFieldName021() {
487
	String[] suggestions = NamingConventions.suggestVariableNames(
487
	String[] suggestions = NamingConventions.suggestVariableNames(
488
			NamingConventions.VK_CONSTANT_FIELD,
488
			NamingConventions.VK_STATIC_FINAL_FIELD,
489
			NamingConventions.BK_TYPE_NAME,
489
			NamingConventions.BK_TYPE_NAME,
490
			"MyType", //$NON-NLS-1$
490
			"MyType", //$NON-NLS-1$
491
			this.project,
491
			this.project,
Lines 508-514 Link Here
508
	JavaCore.setOptions(options);
508
	JavaCore.setOptions(options);
509
	
509
	
510
	String[] suggestions = NamingConventions.suggestVariableNames(
510
	String[] suggestions = NamingConventions.suggestVariableNames(
511
			NamingConventions.VK_CONSTANT_FIELD,
511
			NamingConventions.VK_STATIC_FINAL_FIELD,
512
			NamingConventions.BK_TYPE_NAME,
512
			NamingConventions.BK_TYPE_NAME,
513
			"MyType", //$NON-NLS-1$
513
			"MyType", //$NON-NLS-1$
514
			this.project,
514
			this.project,
Lines 574-580 Link Here
574
 */
574
 */
575
public void testSuggestFieldName025() {
575
public void testSuggestFieldName025() {
576
	String[] suggestions = NamingConventions.suggestVariableNames(
576
	String[] suggestions = NamingConventions.suggestVariableNames(
577
			NamingConventions.VK_CONSTANT_FIELD,
577
			NamingConventions.VK_STATIC_FINAL_FIELD,
578
			NamingConventions.BK_TYPE_NAME,
578
			NamingConventions.BK_TYPE_NAME,
579
			"My_Type", //$NON-NLS-1$
579
			"My_Type", //$NON-NLS-1$
580
			this.project,
580
			this.project,
Lines 592-598 Link Here
592
 */
592
 */
593
public void testSuggestFieldName026() {
593
public void testSuggestFieldName026() {
594
	String[] suggestions = NamingConventions.suggestVariableNames(
594
	String[] suggestions = NamingConventions.suggestVariableNames(
595
			NamingConventions.VK_CONSTANT_FIELD,
595
			NamingConventions.VK_STATIC_FINAL_FIELD,
596
			NamingConventions.BK_TYPE_NAME,
596
			NamingConventions.BK_TYPE_NAME,
597
			"_MyType", //$NON-NLS-1$
597
			"_MyType", //$NON-NLS-1$
598
			this.project,
598
			this.project,
Lines 610-616 Link Here
610
 */
610
 */
611
public void testSuggestFieldName027() {
611
public void testSuggestFieldName027() {
612
	String[] suggestions = NamingConventions.suggestVariableNames(
612
	String[] suggestions = NamingConventions.suggestVariableNames(
613
			NamingConventions.VK_CONSTANT_FIELD,
613
			NamingConventions.VK_STATIC_FINAL_FIELD,
614
			NamingConventions.BK_TYPE_NAME,
614
			NamingConventions.BK_TYPE_NAME,
615
			"MyType_", //$NON-NLS-1$
615
			"MyType_", //$NON-NLS-1$
616
			this.project,
616
			this.project,
Lines 628-634 Link Here
628
 */
628
 */
629
public void testSuggestFieldName028() {
629
public void testSuggestFieldName028() {
630
	String[] suggestions = NamingConventions.suggestVariableNames(
630
	String[] suggestions = NamingConventions.suggestVariableNames(
631
			NamingConventions.VK_CONSTANT_FIELD,
631
			NamingConventions.VK_STATIC_FINAL_FIELD,
632
			NamingConventions.BK_TYPE_NAME,
632
			NamingConventions.BK_TYPE_NAME,
633
			"MyTyp_e", //$NON-NLS-1$
633
			"MyTyp_e", //$NON-NLS-1$
634
			this.project,
634
			this.project,
Lines 826-831 Link Here
826
		"type", //$NON-NLS-1$
826
		"type", //$NON-NLS-1$
827
		toString(suggestions));
827
		toString(suggestions));
828
}
828
}
829
/*
830
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=255345
831
 */
832
public void testSuggestFieldName039() {
833
	String[] suggestions = NamingConventions.suggestVariableNames(
834
			NamingConventions.VK_STATIC_FINAL_FIELD,
835
			NamingConventions.BK_TYPE_NAME,
836
			"A", //$NON-NLS-1$
837
			this.project,
838
			0,
839
			new String[]{},
840
			true);
841
	
842
	assumeEquals(
843
		"A", //$NON-NLS-1$
844
		toString(suggestions));
845
}
846
/*
847
 * bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=255345
848
 */
849
public void testSuggestFieldName040() {
850
	String[] suggestions = NamingConventions.suggestVariableNames(
851
			NamingConventions.VK_STATIC_FINAL_FIELD,
852
			NamingConventions.BK_TYPE_NAME,
853
			"int", //$NON-NLS-1$
854
			this.project,
855
			0,
856
			new String[]{},
857
			true);
858
	
859
	assumeEquals(
860
		"INT", //$NON-NLS-1$
861
		toString(suggestions));
862
}
829
/** @deprecated */
863
/** @deprecated */
830
public void testRemovePrefixAndSuffixForFieldName001() {
864
public void testRemovePrefixAndSuffixForFieldName001() {
831
	Hashtable options = JavaCore.getOptions();
865
	Hashtable options = JavaCore.getOptions();

Return to bug 255345