|
Lines 52-58
import org.eclipse.jdt.internal.ui.JavaPlugin;
Link Here
|
| 52 |
|
52 |
|
| 53 |
/** |
53 |
/** |
| 54 |
* Describes a category extension to the "javaCompletionProposalComputer" extension point. |
54 |
* Describes a category extension to the "javaCompletionProposalComputer" extension point. |
| 55 |
* |
55 |
* |
| 56 |
* @since 3.2 |
56 |
* @since 3.2 |
| 57 |
*/ |
57 |
*/ |
| 58 |
public final class CompletionProposalCategory { |
58 |
public final class CompletionProposalCategory { |
|
Lines 60-81
public final class CompletionProposalCategory {
Link Here
|
| 60 |
private static final String ICON= "icon"; //$NON-NLS-1$ |
60 |
private static final String ICON= "icon"; //$NON-NLS-1$ |
| 61 |
|
61 |
|
| 62 |
private final String fId; |
62 |
private final String fId; |
|
|
63 |
|
| 63 |
private final String fName; |
64 |
private final String fName; |
|
|
65 |
|
| 64 |
private final IConfigurationElement fElement; |
66 |
private final IConfigurationElement fElement; |
|
|
67 |
|
| 65 |
/** The image descriptor for this category, or <code>null</code> if none specified. */ |
68 |
/** The image descriptor for this category, or <code>null</code> if none specified. */ |
| 66 |
private final ImageDescriptor fImage; |
69 |
private final ImageDescriptor fImage; |
| 67 |
|
70 |
|
| 68 |
/** The enablement expression for this category, or <code>null</code> if none specified. */ |
71 |
/** The enablement expression for this category, or <code>null</code> if none specified. */ |
| 69 |
private final Expression fEnablementExpression; |
72 |
private final Expression fEnablementExpression; |
| 70 |
|
73 |
|
| 71 |
private boolean fIsSeparateCommand= true; |
74 |
private boolean fIsSeparateCommand= true; |
|
|
75 |
|
| 72 |
private boolean fIsEnabled= true; |
76 |
private boolean fIsEnabled= true; |
|
|
77 |
|
| 73 |
private boolean fIsIncluded= true; |
78 |
private boolean fIsIncluded= true; |
|
|
79 |
|
| 74 |
private final CompletionProposalComputerRegistry fRegistry; |
80 |
private final CompletionProposalComputerRegistry fRegistry; |
| 75 |
|
81 |
|
| 76 |
private int fSortOrder= 0xffff - 1; |
82 |
private int fSortOrder= 0xffff - 1; |
|
|
83 |
|
| 77 |
private String fLastError= null; |
84 |
private String fLastError= null; |
| 78 |
|
85 |
|
|
|
86 |
private boolean fRequiresReordering; |
| 87 |
|
| 79 |
CompletionProposalCategory(IConfigurationElement element, CompletionProposalComputerRegistry registry) throws CoreException { |
88 |
CompletionProposalCategory(IConfigurationElement element, CompletionProposalComputerRegistry registry) throws CoreException { |
| 80 |
fElement= element; |
89 |
fElement= element; |
| 81 |
fRegistry= registry; |
90 |
fRegistry= registry; |
|
Lines 87-102
public final class CompletionProposalCategory {
Link Here
|
| 87 |
fName= fId; |
96 |
fName= fId; |
| 88 |
else |
97 |
else |
| 89 |
fName= name; |
98 |
fName= name; |
| 90 |
|
99 |
|
| 91 |
IConfigurationElement[] children= fElement.getChildren(ExpressionTagNames.ENABLEMENT); |
100 |
IConfigurationElement[] children= fElement.getChildren(ExpressionTagNames.ENABLEMENT); |
| 92 |
if (children.length == 1) { |
101 |
if (children.length == 1) { |
| 93 |
ExpressionConverter parser= ExpressionConverter.getDefault(); |
102 |
ExpressionConverter parser= ExpressionConverter.getDefault(); |
| 94 |
fEnablementExpression = parser.perform(children[0]); |
103 |
fEnablementExpression= parser.perform(children[0]); |
| 95 |
} |
104 |
} |
| 96 |
else { |
105 |
else { |
| 97 |
fEnablementExpression = null; |
106 |
fEnablementExpression= null; |
| 98 |
} |
107 |
} |
| 99 |
|
108 |
|
| 100 |
String icon= element.getAttribute(ICON); |
109 |
String icon= element.getAttribute(ICON); |
| 101 |
ImageDescriptor img= null; |
110 |
ImageDescriptor img= null; |
| 102 |
if (icon != null) { |
111 |
if (icon != null) { |
|
Lines 108-114
public final class CompletionProposalCategory {
Link Here
|
| 108 |
} |
117 |
} |
| 109 |
} |
118 |
} |
| 110 |
fImage= img; |
119 |
fImage= img; |
| 111 |
|
|
|
| 112 |
} |
120 |
} |
| 113 |
|
121 |
|
| 114 |
CompletionProposalCategory(String id, String name, CompletionProposalComputerRegistry registry) { |
122 |
CompletionProposalCategory(String id, String name, CompletionProposalComputerRegistry registry) { |
|
Lines 116-122
public final class CompletionProposalCategory {
Link Here
|
| 116 |
fId= id; |
124 |
fId= id; |
| 117 |
fName= name; |
125 |
fName= name; |
| 118 |
fElement= null; |
126 |
fElement= null; |
| 119 |
fEnablementExpression = null; |
127 |
fEnablementExpression= null; |
| 120 |
fImage= null; |
128 |
fImage= null; |
| 121 |
} |
129 |
} |
| 122 |
|
130 |
|
|
Lines 128-134
public final class CompletionProposalCategory {
Link Here
|
| 128 |
|
136 |
|
| 129 |
/** |
137 |
/** |
| 130 |
* Checks that the given attribute value is not <code>null</code>. |
138 |
* Checks that the given attribute value is not <code>null</code>. |
| 131 |
* |
139 |
* |
| 132 |
* @param value the element to be checked |
140 |
* @param value the element to be checked |
| 133 |
* @param attribute the attribute |
141 |
* @param attribute the attribute |
| 134 |
* @throws CoreException if <code>value</code> is <code>null</code> |
142 |
* @throws CoreException if <code>value</code> is <code>null</code> |
|
Lines 142-150
public final class CompletionProposalCategory {
Link Here
|
| 142 |
} |
150 |
} |
| 143 |
} |
151 |
} |
| 144 |
|
152 |
|
|
|
153 |
|
| 145 |
/** |
154 |
/** |
| 146 |
* Returns the identifier of the described extension. |
155 |
* Returns the identifier of the described extension. |
| 147 |
* |
156 |
* |
| 148 |
* @return Returns the id |
157 |
* @return Returns the id |
| 149 |
*/ |
158 |
*/ |
| 150 |
public String getId() { |
159 |
public String getId() { |
|
Lines 153-159
public final class CompletionProposalCategory {
Link Here
|
| 153 |
|
162 |
|
| 154 |
/** |
163 |
/** |
| 155 |
* Returns the name of the described extension. |
164 |
* Returns the name of the described extension. |
| 156 |
* |
165 |
* |
| 157 |
* @return Returns the name |
166 |
* @return Returns the name |
| 158 |
*/ |
167 |
*/ |
| 159 |
public String getName() { |
168 |
public String getName() { |
|
Lines 161-170
public final class CompletionProposalCategory {
Link Here
|
| 161 |
} |
170 |
} |
| 162 |
|
171 |
|
| 163 |
/** |
172 |
/** |
| 164 |
* Returns the name of the described extension |
173 |
* Returns the name of the described extension without mnemonic hint in order to be displayed in |
| 165 |
* without mnemonic hint in order to be displayed |
174 |
* a message. |
| 166 |
* in a message. |
175 |
* |
| 167 |
* |
|
|
| 168 |
* @return Returns the name |
176 |
* @return Returns the name |
| 169 |
*/ |
177 |
*/ |
| 170 |
public String getDisplayName() { |
178 |
public String getDisplayName() { |
|
Lines 173-179
public final class CompletionProposalCategory {
Link Here
|
| 173 |
|
181 |
|
| 174 |
/** |
182 |
/** |
| 175 |
* Returns the image descriptor of the described category. |
183 |
* Returns the image descriptor of the described category. |
| 176 |
* |
184 |
* |
| 177 |
* @return the image descriptor of the described category |
185 |
* @return the image descriptor of the described category |
| 178 |
*/ |
186 |
*/ |
| 179 |
public ImageDescriptor getImageDescriptor() { |
187 |
public ImageDescriptor getImageDescriptor() { |
|
Lines 182-188
public final class CompletionProposalCategory {
Link Here
|
| 182 |
|
190 |
|
| 183 |
/** |
191 |
/** |
| 184 |
* Sets the separate command state of the category. |
192 |
* Sets the separate command state of the category. |
| 185 |
* |
193 |
* |
| 186 |
* @param enabled the new enabled state. |
194 |
* @param enabled the new enabled state. |
| 187 |
*/ |
195 |
*/ |
| 188 |
public void setSeparateCommand(boolean enabled) { |
196 |
public void setSeparateCommand(boolean enabled) { |
|
Lines 191-197
public final class CompletionProposalCategory {
Link Here
|
| 191 |
|
199 |
|
| 192 |
/** |
200 |
/** |
| 193 |
* Returns the enablement state of the category. |
201 |
* Returns the enablement state of the category. |
| 194 |
* |
202 |
* |
| 195 |
* @return the enablement state of the category |
203 |
* @return the enablement state of the category |
| 196 |
*/ |
204 |
*/ |
| 197 |
public boolean isSeparateCommand() { |
205 |
public boolean isSeparateCommand() { |
|
Lines 223-229
public final class CompletionProposalCategory {
Link Here
|
| 223 |
/** |
231 |
/** |
| 224 |
* Returns <code>true</code> if the category contains any computers, <code>false</code> |
232 |
* Returns <code>true</code> if the category contains any computers, <code>false</code> |
| 225 |
* otherwise. |
233 |
* otherwise. |
| 226 |
* |
234 |
* |
| 227 |
* @return <code>true</code> if the category contains any computers, <code>false</code> |
235 |
* @return <code>true</code> if the category contains any computers, <code>false</code> |
| 228 |
* otherwise |
236 |
* otherwise |
| 229 |
*/ |
237 |
*/ |
|
Lines 238-246
public final class CompletionProposalCategory {
Link Here
|
| 238 |
} |
246 |
} |
| 239 |
|
247 |
|
| 240 |
/** |
248 |
/** |
| 241 |
* Returns <code>true</code> if the category contains any computers in the given partition, <code>false</code> |
249 |
* Returns <code>true</code> if the category contains any computers in the given partition, |
| 242 |
* otherwise. |
250 |
* <code>false</code> otherwise. |
| 243 |
* |
251 |
* |
| 244 |
* @param partition the partition |
252 |
* @param partition the partition |
| 245 |
* @return <code>true</code> if the category contains any computers, <code>false</code> |
253 |
* @return <code>true</code> if the category contains any computers, <code>false</code> |
| 246 |
* otherwise |
254 |
* otherwise |
|
Lines 268-274
public final class CompletionProposalCategory {
Link Here
|
| 268 |
public void setSortOrder(int sortOrder) { |
276 |
public void setSortOrder(int sortOrder) { |
| 269 |
fSortOrder= sortOrder; |
277 |
fSortOrder= sortOrder; |
| 270 |
} |
278 |
} |
| 271 |
|
279 |
|
| 272 |
/** |
280 |
/** |
| 273 |
* Determines if the project matches any enablement expression defined on the extension. |
281 |
* Determines if the project matches any enablement expression defined on the extension. |
| 274 |
* |
282 |
* |
|
Lines 283-293
public final class CompletionProposalCategory {
Link Here
|
| 283 |
if (fEnablementExpression == null) { |
291 |
if (fEnablementExpression == null) { |
| 284 |
return true; |
292 |
return true; |
| 285 |
} |
293 |
} |
| 286 |
|
294 |
|
| 287 |
if (javaProject == null) { |
295 |
if (javaProject == null) { |
| 288 |
return false; |
296 |
return false; |
| 289 |
} |
297 |
} |
| 290 |
|
298 |
|
| 291 |
try { |
299 |
try { |
| 292 |
EvaluationContext evalContext= new EvaluationContext(null, javaProject); |
300 |
EvaluationContext evalContext= new EvaluationContext(null, javaProject); |
| 293 |
evalContext.addVariable("project", javaProject); //$NON-NLS-1$ |
301 |
evalContext.addVariable("project", javaProject); //$NON-NLS-1$ |
|
Lines 295-301
public final class CompletionProposalCategory {
Link Here
|
| 295 |
} catch (CoreException e) { |
303 |
} catch (CoreException e) { |
| 296 |
JavaPlugin.log(e); |
304 |
JavaPlugin.log(e); |
| 297 |
} |
305 |
} |
| 298 |
|
306 |
|
| 299 |
return false; |
307 |
return false; |
| 300 |
} |
308 |
} |
| 301 |
|
309 |
|
|
Lines 303-309
public final class CompletionProposalCategory {
Link Here
|
| 303 |
* Safely computes completion proposals of all computers of this category through their |
311 |
* Safely computes completion proposals of all computers of this category through their |
| 304 |
* extension. If an extension is disabled, throws an exception or otherwise does not adhere to |
312 |
* extension. If an extension is disabled, throws an exception or otherwise does not adhere to |
| 305 |
* the contract described in {@link IJavaCompletionProposalComputer}, it is disabled. |
313 |
* the contract described in {@link IJavaCompletionProposalComputer}, it is disabled. |
| 306 |
* |
314 |
* |
| 307 |
* @param context the invocation context passed on to the extension |
315 |
* @param context the invocation context passed on to the extension |
| 308 |
* @param partition the partition type where to invocation occurred |
316 |
* @param partition the partition type where to invocation occurred |
| 309 |
* @param monitor the progress monitor passed on to the extension |
317 |
* @param monitor the progress monitor passed on to the extension |
|
Lines 328-334
public final class CompletionProposalCategory {
Link Here
|
| 328 |
* Safely computes context information objects of all computers of this category through their |
336 |
* Safely computes context information objects of all computers of this category through their |
| 329 |
* extension. If an extension is disabled, throws an exception or otherwise does not adhere to |
337 |
* extension. If an extension is disabled, throws an exception or otherwise does not adhere to |
| 330 |
* the contract described in {@link IJavaCompletionProposalComputer}, it is disabled. |
338 |
* the contract described in {@link IJavaCompletionProposalComputer}, it is disabled. |
| 331 |
* |
339 |
* |
| 332 |
* @param context the invocation context passed on to the extension |
340 |
* @param context the invocation context passed on to the extension |
| 333 |
* @param partition the partition type where to invocation occurred |
341 |
* @param partition the partition type where to invocation occurred |
| 334 |
* @param monitor the progress monitor passed on to the extension |
342 |
* @param monitor the progress monitor passed on to the extension |
|
Lines 351-357
public final class CompletionProposalCategory {
Link Here
|
| 351 |
|
359 |
|
| 352 |
/** |
360 |
/** |
| 353 |
* Returns the error message from the computers in this category. |
361 |
* Returns the error message from the computers in this category. |
| 354 |
* |
362 |
* |
| 355 |
* @return the error message from the computers in this category |
363 |
* @return the error message from the computers in this category |
| 356 |
*/ |
364 |
*/ |
| 357 |
public String getErrorMessage() { |
365 |
public String getErrorMessage() { |
|
Lines 365-372
public final class CompletionProposalCategory {
Link Here
|
| 365 |
List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors()); |
373 |
List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors()); |
| 366 |
for (Iterator<CompletionProposalComputerDescriptor> it= descriptors.iterator(); it.hasNext();) { |
374 |
for (Iterator<CompletionProposalComputerDescriptor> it= descriptors.iterator(); it.hasNext();) { |
| 367 |
CompletionProposalComputerDescriptor desc= it.next(); |
375 |
CompletionProposalComputerDescriptor desc= it.next(); |
| 368 |
if (desc.getCategory() == this) |
376 |
if (desc.getCategory() == this){ |
| 369 |
desc.sessionStarted(); |
377 |
desc.sessionStarted(); |
|
|
378 |
fRequiresReordering|= desc.requiresReordering(); |
| 379 |
} |
| 370 |
if (fLastError == null) |
380 |
if (fLastError == null) |
| 371 |
fLastError= desc.getErrorMessage(); |
381 |
fLastError= desc.getErrorMessage(); |
| 372 |
} |
382 |
} |
|
Lines 386-389
public final class CompletionProposalCategory {
Link Here
|
| 386 |
} |
396 |
} |
| 387 |
} |
397 |
} |
| 388 |
|
398 |
|
|
|
399 |
/** |
| 400 |
* Returns whether any completion proposal computer associated with this category requires |
| 401 |
* proposals to be reordered. |
| 402 |
* |
| 403 |
* @return <code>true</code> if any completion proposal computer in this category requires |
| 404 |
* proposals to be reordered. |
| 405 |
*/ |
| 406 |
public boolean requiresReordering() { |
| 407 |
return fRequiresReordering; |
| 408 |
} |
| 389 |
} |
409 |
} |