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() |