Lines 10-19
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.internal.codeassist; |
11 |
package org.eclipse.jdt.internal.codeassist; |
12 |
|
12 |
|
|
|
13 |
import org.eclipse.core.runtime.IProgressMonitor; |
14 |
import org.eclipse.jdt.core.CompletionFlags; |
15 |
import org.eclipse.jdt.core.CompletionProposal; |
16 |
import org.eclipse.jdt.core.CompletionRequestor; |
17 |
import org.eclipse.jdt.core.Flags; |
13 |
import org.eclipse.jdt.core.IAccessRule; |
18 |
import org.eclipse.jdt.core.IAccessRule; |
|
|
19 |
import org.eclipse.jdt.core.ICodeAssist; |
20 |
import org.eclipse.jdt.core.ICompilationUnit; |
14 |
import org.eclipse.jdt.core.IMethod; |
21 |
import org.eclipse.jdt.core.IMethod; |
15 |
import org.eclipse.jdt.core.IType; |
22 |
import org.eclipse.jdt.core.IType; |
16 |
import org.eclipse.jdt.core.JavaModelException; |
23 |
import org.eclipse.jdt.core.JavaModelException; |
|
|
24 |
import org.eclipse.jdt.core.Signature; |
17 |
import org.eclipse.jdt.core.compiler.CharOperation; |
25 |
import org.eclipse.jdt.core.compiler.CharOperation; |
18 |
import org.eclipse.jdt.internal.core.BinaryType; |
26 |
import org.eclipse.jdt.internal.core.BinaryType; |
19 |
import org.eclipse.jdt.internal.core.NameLookup; |
27 |
import org.eclipse.jdt.internal.core.NameLookup; |
Lines 22-28
Link Here
|
22 |
* Internal completion proposal |
30 |
* Internal completion proposal |
23 |
* @since 3.1 |
31 |
* @since 3.1 |
24 |
*/ |
32 |
*/ |
25 |
public class InternalCompletionProposal { |
33 |
public class InternalCompletionProposal extends CompletionProposal { |
26 |
private static Object NO_ATTACHED_SOURCE = new Object(); |
34 |
private static Object NO_ATTACHED_SOURCE = new Object(); |
27 |
|
35 |
|
28 |
static final char[] ARG = "arg".toCharArray(); //$NON-NLS-1$ |
36 |
static final char[] ARG = "arg".toCharArray(); //$NON-NLS-1$ |
Lines 47-87
Link Here
|
47 |
|
55 |
|
48 |
protected char[] originalSignature; |
56 |
protected char[] originalSignature; |
49 |
|
57 |
|
|
|
58 |
private boolean updateCompletion = false; |
59 |
|
50 |
protected int accessibility = IAccessRule.K_ACCESSIBLE; |
60 |
protected int accessibility = IAccessRule.K_ACCESSIBLE; |
51 |
|
61 |
|
52 |
protected boolean isConstructor = false; |
62 |
protected boolean isConstructor = false; |
53 |
|
63 |
|
|
|
64 |
/** |
65 |
* Kind of completion request. |
66 |
*/ |
67 |
private int completionKind; |
68 |
|
69 |
/** |
70 |
* Offset in original buffer where ICodeAssist.codeComplete() was |
71 |
* requested. |
72 |
*/ |
73 |
private int completionLocation; |
74 |
|
75 |
/** |
76 |
* Start position (inclusive) of source range in original buffer |
77 |
* containing the relevant token |
78 |
* defaults to empty subrange at [0,0). |
79 |
*/ |
80 |
private int tokenStart = 0; |
81 |
|
82 |
/** |
83 |
* End position (exclusive) of source range in original buffer |
84 |
* containing the relevant token; |
85 |
* defaults to empty subrange at [0,0). |
86 |
*/ |
87 |
private int tokenEnd = 0; |
88 |
|
89 |
/** |
90 |
* Completion string; defaults to empty string. |
91 |
*/ |
92 |
private char[] completion = CharOperation.NO_CHAR; |
93 |
|
94 |
/** |
95 |
* Start position (inclusive) of source range in original buffer |
96 |
* to be replaced by completion string; |
97 |
* defaults to empty subrange at [0,0). |
98 |
*/ |
99 |
private int replaceStart = 0; |
100 |
|
101 |
/** |
102 |
* End position (exclusive) of source range in original buffer |
103 |
* to be replaced by completion string; |
104 |
* defaults to empty subrange at [0,0). |
105 |
*/ |
106 |
private int replaceEnd = 0; |
107 |
|
108 |
/** |
109 |
* Relevance rating; positive; higher means better; |
110 |
* defaults to minimum rating. |
111 |
*/ |
112 |
private int relevance = 1; |
113 |
|
114 |
/** |
115 |
* Signature of the relevant package or type declaration |
116 |
* in the context, or <code>null</code> if none. |
117 |
* Defaults to null. |
118 |
*/ |
119 |
private char[] declarationSignature = null; |
120 |
|
121 |
/** |
122 |
* Unique key of the relevant package or type declaration |
123 |
* in the context, or <code>null</code> if none. |
124 |
* Defaults to null. |
125 |
*/ |
126 |
private char[] declarationKey = null; |
127 |
|
128 |
/** |
129 |
* Simple name of the method, field, |
130 |
* member, or variable relevant in the context, or |
131 |
* <code>null</code> if none. |
132 |
* Defaults to null. |
133 |
*/ |
134 |
private char[] name = null; |
135 |
|
136 |
/** |
137 |
* Signature of the method, field type, member type, |
138 |
* relevant in the context, or <code>null</code> if none. |
139 |
* Defaults to null. |
140 |
*/ |
141 |
private char[] signature = null; |
142 |
|
143 |
/** |
144 |
* Unique of the method, field type, member type, |
145 |
* relevant in the context, or <code>null</code> if none. |
146 |
* Defaults to null. |
147 |
*/ |
148 |
private char[] key = null; |
149 |
|
150 |
/** |
151 |
* Array of required completion proposals, or <code>null</code> if none. |
152 |
* The proposal can not be applied if the required proposals aren't applied. |
153 |
* Defaults to <code>null</code>. |
154 |
*/ |
155 |
private CompletionProposal[] requiredProposals; |
156 |
|
157 |
/** |
158 |
* Modifier flags relevant in the context, or |
159 |
* <code>Flags.AccDefault</code> if none. |
160 |
* Defaults to <code>Flags.AccDefault</code>. |
161 |
*/ |
162 |
private int flags = Flags.AccDefault; |
163 |
|
164 |
/** |
165 |
* Completion flags relevant in the context, or |
166 |
* <code>CompletionFlags.Default</code> if none. |
167 |
* Defaults to <code>CompletionFlags.Default</code>. |
168 |
*/ |
169 |
private int additionalFlags = CompletionFlags.Default; |
170 |
|
171 |
/** |
172 |
* Parameter names (for method completions), or |
173 |
* <code>null</code> if none. Lazily computed. |
174 |
* Defaults to <code>null</code>. |
175 |
*/ |
176 |
private char[][] parameterNames = null; |
177 |
|
178 |
/** |
179 |
* Indicates whether parameter names have been computed. |
180 |
*/ |
181 |
private boolean parameterNamesComputed = false; |
182 |
|
54 |
protected char[][] createDefaultParameterNames(int length) { |
183 |
protected char[][] createDefaultParameterNames(int length) { |
55 |
char[][] parameterNames; |
184 |
char[][] parameters; |
56 |
switch (length) { |
185 |
switch (length) { |
57 |
case 0 : |
186 |
case 0 : |
58 |
parameterNames = new char[length][]; |
187 |
parameters = new char[length][]; |
59 |
break; |
188 |
break; |
60 |
case 1 : |
189 |
case 1 : |
61 |
parameterNames = ARGS1; |
190 |
parameters = ARGS1; |
62 |
break; |
191 |
break; |
63 |
case 2 : |
192 |
case 2 : |
64 |
parameterNames = ARGS2; |
193 |
parameters = ARGS2; |
65 |
break; |
194 |
break; |
66 |
case 3 : |
195 |
case 3 : |
67 |
parameterNames = ARGS3; |
196 |
parameters = ARGS3; |
68 |
break; |
197 |
break; |
69 |
case 4 : |
198 |
case 4 : |
70 |
parameterNames = ARGS4; |
199 |
parameters = ARGS4; |
71 |
break; |
200 |
break; |
72 |
default : |
201 |
default : |
73 |
parameterNames = new char[length][]; |
202 |
parameters = new char[length][]; |
74 |
for (int i = 0; i < length; i++) { |
203 |
for (int i = 0; i < length; i++) { |
75 |
parameterNames[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray()); |
204 |
parameters[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray()); |
76 |
} |
205 |
} |
77 |
break; |
206 |
break; |
78 |
} |
207 |
} |
79 |
return parameterNames; |
208 |
return parameters; |
80 |
} |
209 |
} |
81 |
protected char[][] findMethodParameterNames(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] paramTypeNames){ |
210 |
protected char[][] findMethodParameterNames(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] paramTypeNames){ |
82 |
if(paramTypeNames == null || declaringTypeName == null) return null; |
211 |
if(paramTypeNames == null || declaringTypeName == null) return null; |
83 |
|
212 |
|
84 |
char[][] parameterNames = null; |
213 |
char[][] parameters = null; |
85 |
int length = paramTypeNames.length; |
214 |
int length = paramTypeNames.length; |
86 |
|
215 |
|
87 |
char[] tName = CharOperation.concat(declaringTypePackageName,declaringTypeName,'.'); |
216 |
char[] tName = CharOperation.concat(declaringTypePackageName,declaringTypeName,'.'); |
Lines 116-137
Link Here
|
116 |
} |
245 |
} |
117 |
IMethod method = type.getMethod(new String(selector),args); |
246 |
IMethod method = type.getMethod(new String(selector),args); |
118 |
try{ |
247 |
try{ |
119 |
parameterNames = new char[length][]; |
248 |
parameters = new char[length][]; |
120 |
String[] params = method.getParameterNames(); |
249 |
String[] params = method.getParameterNames(); |
121 |
for(int i = 0; i< length ; i++){ |
250 |
for(int i = 0; i< length ; i++){ |
122 |
parameterNames[i] = params[i].toCharArray(); |
251 |
parameters[i] = params[i].toCharArray(); |
123 |
} |
252 |
} |
124 |
} catch(JavaModelException e){ |
253 |
} catch(JavaModelException e){ |
125 |
parameterNames = null; |
254 |
parameters = null; |
126 |
} |
255 |
} |
127 |
} |
256 |
} |
128 |
|
257 |
|
129 |
// default parameters name |
258 |
// default parameters name |
130 |
if(parameterNames == null) { |
259 |
if(parameters == null) { |
131 |
parameterNames = createDefaultParameterNames(length); |
260 |
parameters = createDefaultParameterNames(length); |
132 |
} |
261 |
} |
133 |
|
262 |
|
134 |
return parameterNames; |
263 |
return parameters; |
135 |
} |
264 |
} |
136 |
|
265 |
|
137 |
protected char[] getDeclarationPackageName() { |
266 |
protected char[] getDeclarationPackageName() { |
Lines 193-196
Link Here
|
193 |
public void setOriginalSignature(char[] originalSignature) { |
322 |
public void setOriginalSignature(char[] originalSignature) { |
194 |
this.originalSignature = originalSignature; |
323 |
this.originalSignature = originalSignature; |
195 |
} |
324 |
} |
|
|
325 |
/** |
326 |
* Creates a basic completion proposal. All instance |
327 |
* field have plausible default values unless otherwise noted. |
328 |
* <p> |
329 |
* Note that the constructors for this class are internal to the |
330 |
* Java model implementation. Clients cannot directly create |
331 |
* CompletionProposal objects. |
332 |
* </p> |
333 |
* |
334 |
* @param kind one of the kind constants declared on this class |
335 |
* @param completionLocation original offset of code completion request |
336 |
*/ |
337 |
public InternalCompletionProposal(int kind, int completionLocation) { |
338 |
if ((kind < FIRST_KIND) |
339 |
|| (kind > LAST_KIND)) { |
340 |
throw new IllegalArgumentException(); |
341 |
} |
342 |
if (this.completion == null || completionLocation < 0) { |
343 |
// Work around for bug 132558 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=132558). |
344 |
// completionLocation can be -1 if the completion occur at the start of a file or |
345 |
// the start of a code snippet but this API isn't design to support negative position. |
346 |
if(this.completion == null || completionLocation != -1) { |
347 |
throw new IllegalArgumentException(); |
348 |
} |
349 |
completionLocation = 0; |
350 |
} |
351 |
this.completionKind = kind; |
352 |
this.completionLocation = completionLocation; |
353 |
} |
354 |
|
355 |
/** |
356 |
* Returns the completion flags relevant in the context, or |
357 |
* <code>CompletionFlags.Default</code> if none. |
358 |
* <p> |
359 |
* This field is available for the following kinds of |
360 |
* completion proposals: |
361 |
* <ul> |
362 |
* <li><code>FIELD_IMPORT</code> - completion flags |
363 |
* of the attribute that is referenced. Completion flags for |
364 |
* this proposal kind can only include <code>CompletionFlags.StaticImport</code></li> |
365 |
* <li><code>METHOD_IMPORT</code> - completion flags |
366 |
* of the attribute that is referenced. Completion flags for |
367 |
* this proposal kind can only include <code>CompletionFlags.StaticImport</code></li> |
368 |
* <li><code>TYPE_IMPORT</code> - completion flags |
369 |
* of the attribute that is referenced. Completion flags for |
370 |
* this proposal kind can only include <code>CompletionFlags.StaticImport</code></li> |
371 |
* </ul> |
372 |
* For other kinds of completion proposals, this method returns |
373 |
* <code>CompletionFlags.Default</code>. |
374 |
* </p> |
375 |
* |
376 |
* @return the completion flags, or |
377 |
* <code>CompletionFlags.Default</code> if none |
378 |
* @see CompletionFlags |
379 |
* |
380 |
* @since 3.3 |
381 |
*/ |
382 |
public int getAdditionalFlags() { |
383 |
return this.additionalFlags; |
384 |
} |
385 |
|
386 |
/** |
387 |
* Sets the completion flags relevant in the context. |
388 |
* <p> |
389 |
* If not set, defaults to none. |
390 |
* </p> |
391 |
* <p> |
392 |
* The completion engine creates instances of this class and sets |
393 |
* its properties; this method is not intended to be used by other clients. |
394 |
* </p> |
395 |
* |
396 |
* @param additionalFlags the completion flags, or |
397 |
* <code>CompletionFlags.Default</code> if none |
398 |
* |
399 |
* @since 3.3 |
400 |
*/ |
401 |
public void setAdditionalFlags(int additionalFlags) { |
402 |
this.additionalFlags = additionalFlags; |
403 |
} |
404 |
|
405 |
/** |
406 |
* Returns the kind of completion being proposed. |
407 |
* <p> |
408 |
* The set of different kinds of completion proposals is |
409 |
* expected to change over time. It is strongly recommended |
410 |
* that clients do <b>not</b> assume that the kind is one of the |
411 |
* ones they know about, and code defensively for the |
412 |
* possibility of unexpected future growth. |
413 |
* </p> |
414 |
* |
415 |
* @return the kind; one of the kind constants |
416 |
* declared on this class, or possibly a kind unknown |
417 |
* to the caller |
418 |
*/ |
419 |
public int getKind() { |
420 |
return this.completionKind; |
421 |
} |
422 |
|
423 |
/** |
424 |
* Returns the character index in the source file buffer |
425 |
* where source completion was requested (the |
426 |
* <code>offset</code> parameter to |
427 |
* <code>ICodeAssist.codeComplete</code> minus one). |
428 |
* |
429 |
* @return character index in source file buffer |
430 |
* @see ICodeAssist#codeComplete(int,CompletionRequestor) |
431 |
*/ |
432 |
// TODO (david) https://bugs.eclipse.org/bugs/show_bug.cgi?id=132558 |
433 |
public int getCompletionLocation() { |
434 |
return this.completionLocation; |
435 |
} |
436 |
|
437 |
/** |
438 |
* Returns the character index of the start of the |
439 |
* subrange in the source file buffer containing the |
440 |
* relevant token being completed. This |
441 |
* token is either the identifier or Java language keyword |
442 |
* under, or immediately preceding, the original request |
443 |
* offset. If the original request offset is not within |
444 |
* or immediately after an identifier or keyword, then the |
445 |
* position returned is original request offset and the |
446 |
* token range is empty. |
447 |
* |
448 |
* @return character index of token start position (inclusive) |
449 |
*/ |
450 |
public int getTokenStart() { |
451 |
return this.tokenStart; |
452 |
} |
453 |
|
454 |
/** |
455 |
* Returns the character index of the end (exclusive) of the subrange |
456 |
* in the source file buffer containing the |
457 |
* relevant token. When there is no relevant token, the |
458 |
* range is empty |
459 |
* (<code>getEndToken() == getStartToken()</code>). |
460 |
* |
461 |
* @return character index of token end position (exclusive) |
462 |
*/ |
463 |
public int getTokenEnd() { |
464 |
return this.tokenEnd; |
465 |
} |
466 |
|
467 |
/** |
468 |
* Sets the character indices of the subrange in the |
469 |
* source file buffer containing the relevant token being |
470 |
* completed. This token is either the identifier or |
471 |
* Java language keyword under, or immediately preceding, |
472 |
* the original request offset. If the original request |
473 |
* offset is not within or immediately after an identifier |
474 |
* or keyword, then the source range begins at original |
475 |
* request offset and is empty. |
476 |
* <p> |
477 |
* If not set, defaults to empty subrange at [0,0). |
478 |
* </p> |
479 |
* |
480 |
* @param startIndex character index of token start position (inclusive) |
481 |
* @param endIndex character index of token end position (exclusive) |
482 |
*/ |
483 |
public void setTokenRange(int startIndex, int endIndex) { |
484 |
if (startIndex < 0 || endIndex < startIndex) { |
485 |
throw new IllegalArgumentException(); |
486 |
} |
487 |
this.tokenStart = startIndex; |
488 |
this.tokenEnd = endIndex; |
489 |
} |
490 |
|
491 |
/** |
492 |
* Returns the proposed sequence of characters to insert into the |
493 |
* source file buffer, replacing the characters at the specified |
494 |
* source range. The string can be arbitrary; for example, it might |
495 |
* include not only the name of a method but a set of parentheses. |
496 |
* <p> |
497 |
* The client must not modify the array returned. |
498 |
* </p> |
499 |
* |
500 |
* @return the completion string |
501 |
*/ |
502 |
public char[] getCompletion() { |
503 |
if(this.completionKind == METHOD_DECLARATION) { |
504 |
findParameterNames(null); |
505 |
if(this.updateCompletion) { |
506 |
this.updateCompletion = false; |
507 |
|
508 |
if(this.parameterNames != null) { |
509 |
int length = this.parameterNames.length; |
510 |
StringBuffer completionBuffer = new StringBuffer(this.completion.length); |
511 |
|
512 |
int start = 0; |
513 |
int end = CharOperation.indexOf('%', this.completion); |
514 |
|
515 |
completionBuffer.append(this.completion, start, end - start); |
516 |
|
517 |
for(int i = 0 ; i < length ; i++){ |
518 |
completionBuffer.append(this.parameterNames[i]); |
519 |
start = end + 1; |
520 |
end = CharOperation.indexOf('%', this.completion, start); |
521 |
if(end > -1){ |
522 |
completionBuffer.append(this.completion, start, end - start); |
523 |
} else { |
524 |
completionBuffer.append(this.completion, start, this.completion.length - start); |
525 |
} |
526 |
} |
527 |
int nameLength = completionBuffer.length(); |
528 |
this.completion = new char[nameLength]; |
529 |
completionBuffer.getChars(0, nameLength, this.completion, 0); |
530 |
} |
531 |
} |
532 |
} |
533 |
return this.completion; |
534 |
} |
535 |
|
536 |
/** |
537 |
* Sets the proposed sequence of characters to insert into the |
538 |
* source file buffer, replacing the characters at the specified |
539 |
* source range. The string can be arbitrary; for example, it might |
540 |
* include not only the name of a method but a set of parentheses. |
541 |
* <p> |
542 |
* If not set, defaults to an empty character array. |
543 |
* </p> |
544 |
* <p> |
545 |
* The completion engine creates instances of this class and sets |
546 |
* its properties; this method is not intended to be used by other clients. |
547 |
* </p> |
548 |
* |
549 |
* @param completion the completion string |
550 |
*/ |
551 |
public void setCompletion(char[] completion) { |
552 |
this.completion = completion; |
553 |
} |
554 |
|
555 |
/** |
556 |
* Returns the character index of the start of the |
557 |
* subrange in the source file buffer to be replaced |
558 |
* by the completion string. If the subrange is empty |
559 |
* (<code>getReplaceEnd() == getReplaceStart()</code>), |
560 |
* the completion string is to be inserted at this |
561 |
* index. |
562 |
* <p> |
563 |
* Note that while the token subrange is precisely |
564 |
* specified, the replacement range is loosely |
565 |
* constrained and may not bear any direct relation |
566 |
* to the original request offset. For example, |
567 |
* it would be possible for a type completion to |
568 |
* propose inserting an import declaration at the |
569 |
* top of the compilation unit; or the completion |
570 |
* might include trailing parentheses and |
571 |
* punctuation for a method completion. |
572 |
* </p> |
573 |
* |
574 |
* @return replacement start position (inclusive) |
575 |
*/ |
576 |
public int getReplaceStart() { |
577 |
return this.replaceStart; |
578 |
} |
579 |
|
580 |
/** |
581 |
* Returns the character index of the end of the |
582 |
* subrange in the source file buffer to be replaced |
583 |
* by the completion string. If the subrange is empty |
584 |
* (<code>getReplaceEnd() == getReplaceStart()</code>), |
585 |
* the completion string is to be inserted at this |
586 |
* index. |
587 |
* |
588 |
* @return replacement end position (exclusive) |
589 |
*/ |
590 |
public int getReplaceEnd() { |
591 |
return this.replaceEnd; |
592 |
} |
593 |
|
594 |
/** |
595 |
* Sets the character indices of the subrange in the |
596 |
* source file buffer to be replaced by the completion |
597 |
* string. If the subrange is empty |
598 |
* (<code>startIndex == endIndex</code>), |
599 |
* the completion string is to be inserted at this |
600 |
* index. |
601 |
* <p> |
602 |
* If not set, defaults to empty subrange at [0,0). |
603 |
* </p> |
604 |
* <p> |
605 |
* The completion engine creates instances of this class and sets |
606 |
* its properties; this method is not intended to be used by other clients. |
607 |
* </p> |
608 |
* |
609 |
* @param startIndex character index of replacement start position (inclusive) |
610 |
* @param endIndex character index of replacement end position (exclusive) |
611 |
*/ |
612 |
public void setReplaceRange(int startIndex, int endIndex) { |
613 |
if (startIndex < 0 || endIndex < startIndex) { |
614 |
throw new IllegalArgumentException(); |
615 |
} |
616 |
this.replaceStart = startIndex; |
617 |
this.replaceEnd = endIndex; |
618 |
} |
619 |
|
620 |
/** |
621 |
* Returns the relative relevance rating of this proposal. |
622 |
* |
623 |
* @return relevance rating of this proposal; ratings are positive; higher means better |
624 |
*/ |
625 |
public int getRelevance() { |
626 |
return this.relevance; |
627 |
} |
628 |
|
629 |
/** |
630 |
* Sets the relative relevance rating of this proposal. |
631 |
* <p> |
632 |
* If not set, defaults to the lowest possible rating (1). |
633 |
* </p> |
634 |
* <p> |
635 |
* The completion engine creates instances of this class and sets |
636 |
* its properties; this method is not intended to be used by other clients. |
637 |
* </p> |
638 |
* |
639 |
* @param rating relevance rating of this proposal; ratings are positive; higher means better |
640 |
*/ |
641 |
public void setRelevance(int rating) { |
642 |
if (rating <= 0) { |
643 |
throw new IllegalArgumentException(); |
644 |
} |
645 |
this.relevance = rating; |
646 |
} |
647 |
|
648 |
/** |
649 |
* Returns the type signature or package name of the relevant |
650 |
* declaration in the context, or <code>null</code> if none. |
651 |
* <p> |
652 |
* This field is available for the following kinds of |
653 |
* completion proposals: |
654 |
* <ul> |
655 |
* <li><code>ANNOTATION_ATTRIBUT_REF</code> - type signature |
656 |
* of the annotation that declares the attribute that is referenced</li> |
657 |
* <li><code>ANONYMOUS_CLASS_DECLARATION</code> - type signature |
658 |
* of the type that is being subclassed or implemented</li> |
659 |
* <li><code>FIELD_IMPORT</code> - type signature |
660 |
* of the type that declares the field that is imported</li> |
661 |
* <li><code>FIELD_REF</code> - type signature |
662 |
* of the type that declares the field that is referenced</li> |
663 |
* <li><code>FIELD_REF_WITH_CASTED_RECEIVER</code> - type signature |
664 |
* of the type that declares the field that is referenced</li> |
665 |
* <li><code>METHOD_IMPORT</code> - type signature |
666 |
* of the type that declares the method that is imported</li> |
667 |
* <li><code>METHOD_REF</code> - type signature |
668 |
* of the type that declares the method that is referenced</li> |
669 |
* <li><code>METHOD_REF_WITH_CASTED_RECEIVER</code> - type signature |
670 |
* of the type that declares the method that is referenced</li> |
671 |
* <li><code>METHOD_DECLARATION</code> - type signature |
672 |
* of the type that declares the method that is being |
673 |
* implemented or overridden</li> |
674 |
* <li><code>PACKAGE_REF</code> - dot-based package |
675 |
* name of the package that is referenced</li> |
676 |
* <li><code>TYPE_IMPORT</code> - dot-based package |
677 |
* name of the package containing the type that is imported</li> |
678 |
* <li><code>TYPE_REF</code> - dot-based package |
679 |
* name of the package containing the type that is referenced</li> |
680 |
* <li><code>POTENTIAL_METHOD_DECLARATION</code> - type signature |
681 |
* of the type that declares the method that is being created</li> |
682 |
* </ul> |
683 |
* For kinds of completion proposals, this method returns |
684 |
* <code>null</code>. Clients must not modify the array |
685 |
* returned. |
686 |
* </p> |
687 |
* |
688 |
* @return a type signature or a package name (depending |
689 |
* on the kind of completion), or <code>null</code> if none |
690 |
* @see Signature |
691 |
*/ |
692 |
public char[] getDeclarationSignature() { |
693 |
return this.declarationSignature; |
694 |
} |
695 |
|
696 |
/** |
697 |
* Returns the key of the relevant |
698 |
* declaration in the context, or <code>null</code> if none. |
699 |
* <p> |
700 |
* This field is available for the following kinds of |
701 |
* completion proposals: |
702 |
* <ul> |
703 |
* <li><code>ANONYMOUS_CLASS_DECLARATION</code> - key |
704 |
* of the type that is being subclassed or implemented</li> |
705 |
* <li><code>METHOD_DECLARATION</code> - key |
706 |
* of the type that declares the method that is being |
707 |
* implemented or overridden</li> |
708 |
* </ul> |
709 |
* For kinds of completion proposals, this method returns |
710 |
* <code>null</code>. Clients must not modify the array |
711 |
* returned. |
712 |
* </p> |
713 |
* |
714 |
* @return a key, or <code>null</code> if none |
715 |
* @see org.eclipse.jdt.core.dom.ASTParser#createASTs(ICompilationUnit[], String[], org.eclipse.jdt.core.dom.ASTRequestor, IProgressMonitor) |
716 |
* @since 3.1 |
717 |
*/ |
718 |
public char[] getDeclarationKey() { |
719 |
return this.declarationKey; |
720 |
} |
721 |
|
722 |
/** |
723 |
* Sets the type or package signature of the relevant |
724 |
* declaration in the context, or <code>null</code> if none. |
725 |
* <p> |
726 |
* If not set, defaults to none. |
727 |
* </p> |
728 |
* <p> |
729 |
* The completion engine creates instances of this class and sets |
730 |
* its properties; this method is not intended to be used by other clients. |
731 |
* </p> |
732 |
* |
733 |
* @param signature the type or package signature, or |
734 |
* <code>null</code> if none |
735 |
*/ |
736 |
public void setDeclarationSignature(char[] signature) { |
737 |
this.declarationSignature = signature; |
738 |
} |
739 |
|
740 |
/** |
741 |
* Sets the type or package key of the relevant |
742 |
* declaration in the context, or <code>null</code> if none. |
743 |
* <p> |
744 |
* If not set, defaults to none. |
745 |
* </p> |
746 |
* <p> |
747 |
* The completion engine creates instances of this class and sets |
748 |
* its properties; this method is not intended to be used by other clients. |
749 |
* </p> |
750 |
* |
751 |
* @param key the type or package key, or |
752 |
* <code>null</code> if none |
753 |
* @since 3.1 |
754 |
*/ |
755 |
public void setDeclarationKey(char[] key) { |
756 |
this.declarationKey = key; |
757 |
} |
758 |
|
759 |
/** |
760 |
* Returns the simple name of the method, field, |
761 |
* member, or variable relevant in the context, or |
762 |
* <code>null</code> if none. |
763 |
* <p> |
764 |
* This field is available for the following kinds of |
765 |
* completion proposals: |
766 |
* <ul> |
767 |
* <li><code>ANNOTATION_ATTRIBUT_REF</code> - the name of the attribute</li> |
768 |
* <li><code>FIELD_IMPORT</code> - the name of the field</li> |
769 |
* <li><code>FIELD_REF</code> - the name of the field</li> |
770 |
* <li><code>FIELD_REF_WITH_CASTED_RECEIVER</code> - the name of the field</li> |
771 |
* <li><code>KEYWORD</code> - the keyword</li> |
772 |
* <li><code>LABEL_REF</code> - the name of the label</li> |
773 |
* <li><code>LOCAL_VARIABLE_REF</code> - the name of the local variable</li> |
774 |
* <li><code>METHOD_IMPORT</code> - the name of the method</li> |
775 |
* <li><code>METHOD_REF</code> - the name of the method (the type simple name for constructor)</li> |
776 |
* <li><code>METHOD_REF_WITH_CASTED_RECEIVER</code> - the name of the method</li> |
777 |
* <li><code>METHOD_DECLARATION</code> - the name of the method (the type simple name for constructor)</li> |
778 |
* <li><code>VARIABLE_DECLARATION</code> - the name of the variable</li> |
779 |
* <li><code>POTENTIAL_METHOD_DECLARATION</code> - the name of the method</li> |
780 |
* </ul> |
781 |
* For kinds of completion proposals, this method returns |
782 |
* <code>null</code>. Clients must not modify the array |
783 |
* returned. |
784 |
* </p> |
785 |
* |
786 |
* @return the keyword, field, method, local variable, or member |
787 |
* name, or <code>null</code> if none |
788 |
*/ |
789 |
public char[] getName() { |
790 |
return this.name; |
791 |
} |
792 |
|
793 |
|
794 |
/** |
795 |
* Sets the simple name of the method (type simple name for constructor), field, |
796 |
* member, or variable relevant in the context, or |
797 |
* <code>null</code> if none. |
798 |
* <p> |
799 |
* If not set, defaults to none. |
800 |
* </p> |
801 |
* <p> |
802 |
* The completion engine creates instances of this class and sets |
803 |
* its properties; this method is not intended to be used by other clients. |
804 |
* </p> |
805 |
* |
806 |
* @param name the keyword, field, method, local variable, |
807 |
* or member name, or <code>null</code> if none |
808 |
*/ |
809 |
public void setName(char[] name) { |
810 |
this.name = name; |
811 |
} |
812 |
|
813 |
/** |
814 |
* Returns the signature of the method or type |
815 |
* relevant in the context, or <code>null</code> if none. |
816 |
* <p> |
817 |
* This field is available for the following kinds of |
818 |
* completion proposals: |
819 |
* <ul> |
820 |
* <li><code>ANNOTATION_ATTRIBUT_REF</code> - the type signature |
821 |
* of the referenced attribute's type</li> |
822 |
* <li><code>ANONYMOUS_CLASS_DECLARATION</code> - method signature |
823 |
* of the constructor that is being invoked</li> |
824 |
* <li><code>FIELD_IMPORT</code> - the type signature |
825 |
* of the referenced field's type</li> |
826 |
* <li><code>FIELD_REF</code> - the type signature |
827 |
* of the referenced field's type</li> |
828 |
* <li><code>FIELD_REF_WITH_CASTED_RECEIVER</code> - the type signature |
829 |
* of the referenced field's type</li> |
830 |
* <li><code>LOCAL_VARIABLE_REF</code> - the type signature |
831 |
* of the referenced local variable's type</li> |
832 |
* <li><code>METHOD_IMPORT</code> - method signature |
833 |
* of the method that is imported</li> |
834 |
* <li><code>METHOD_REF</code> - method signature |
835 |
* of the method that is referenced</li> |
836 |
* <li><code>METHOD_REF_WITH_CASTED_RECEIVER</code> - method signature |
837 |
* of the method that is referenced</li> |
838 |
* <li><code>METHOD_DECLARATION</code> - method signature |
839 |
* of the method that is being implemented or overridden</li> |
840 |
* <li><code>TYPE_IMPORT</code> - type signature |
841 |
* of the type that is imported</li> |
842 |
* <li><code>TYPE_REF</code> - type signature |
843 |
* of the type that is referenced</li> |
844 |
* <li><code>VARIABLE_DECLARATION</code> - the type signature |
845 |
* of the type of the variable being declared</li> |
846 |
* <li><code>POTENTIAL_METHOD_DECLARATION</code> - method signature |
847 |
* of the method that is being created</li> |
848 |
* </ul> |
849 |
* For kinds of completion proposals, this method returns |
850 |
* <code>null</code>. Clients must not modify the array |
851 |
* returned. |
852 |
* </p> |
853 |
* |
854 |
* @return the signature, or <code>null</code> if none |
855 |
* @see Signature |
856 |
*/ |
857 |
public char[] getSignature() { |
858 |
return this.signature; |
859 |
} |
860 |
|
861 |
/** |
862 |
* Returns the key relevant in the context, |
863 |
* or <code>null</code> if none. |
864 |
* <p> |
865 |
* This field is available for the following kinds of |
866 |
* completion proposals: |
867 |
* <ul> |
868 |
* <li><code>ANONYMOUS_CLASS_DECLARATION</code> - method key |
869 |
* of the constructor that is being invoked, or <code>null</code> if |
870 |
* the declaring type is an interface</li> |
871 |
* <li><code>METHOD_DECLARATION</code> - method key |
872 |
* of the method that is being implemented or overridden</li> |
873 |
* </ul> |
874 |
* For kinds of completion proposals, this method returns |
875 |
* <code>null</code>. Clients must not modify the array |
876 |
* returned. |
877 |
* </p> |
878 |
* |
879 |
* @return the key, or <code>null</code> if none |
880 |
* @see org.eclipse.jdt.core.dom.ASTParser#createASTs(ICompilationUnit[], String[], org.eclipse.jdt.core.dom.ASTRequestor, IProgressMonitor) |
881 |
* @since 3.1 |
882 |
*/ |
883 |
public char[] getKey() { |
884 |
return this.key; |
885 |
} |
886 |
|
887 |
// /** |
888 |
// * Returns the package name of the relevant |
889 |
// * declaration in the context, or <code>null</code> if none. |
890 |
// * <p> |
891 |
// * This field is available for the following kinds of |
892 |
// * completion proposals: |
893 |
// * <ul> |
894 |
// * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - the dot-based package name |
895 |
// * of the type that is being subclassed or implemented</li> |
896 |
// * <li><code>FIELD_REF</code> - the dot-based package name |
897 |
// * of the type that declares the field that is referenced</li> |
898 |
// * <li><code>METHOD_REF</code> - the dot-based package name |
899 |
// * of the type that declares the method that is referenced</li> |
900 |
// * <li><code>METHOD_DECLARATION</code> - the dot-based package name |
901 |
// * of the type that declares the method that is being |
902 |
// * implemented or overridden</li> |
903 |
// * </ul> |
904 |
// * For kinds of completion proposals, this method returns |
905 |
// * <code>null</code>. Clients must not modify the array |
906 |
// * returned. |
907 |
// * </p> |
908 |
// * |
909 |
// * @return the dot-based package name, or |
910 |
// * <code>null</code> if none |
911 |
// * @see #getDeclarationSignature() |
912 |
// * @see #getSignature() |
913 |
// * |
914 |
// * @since 3.1 |
915 |
// */ |
916 |
// public char[] getDeclarationPackageName() { |
917 |
// return this.declarationPackageName; |
918 |
// } |
919 |
// |
920 |
// /** |
921 |
// * Returns the type name of the relevant |
922 |
// * declaration in the context without the package fragment, |
923 |
// * or <code>null</code> if none. |
924 |
// * <p> |
925 |
// * This field is available for the following kinds of |
926 |
// * completion proposals: |
927 |
// * <ul> |
928 |
// * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - the dot-based type name |
929 |
// * of the type that is being subclassed or implemented</li> |
930 |
// * <li><code>FIELD_REF</code> - the dot-based type name |
931 |
// * of the type that declares the field that is referenced |
932 |
// * or an anonymous type instantiation ("new X(){}") if it is an anonymous type</li> |
933 |
// * <li><code>METHOD_REF</code> - the dot-based type name |
934 |
// * of the type that declares the method that is referenced |
935 |
// * or an anonymous type instantiation ("new X(){}") if it is an anonymous type</li> |
936 |
// * <li><code>METHOD_DECLARATION</code> - the dot-based type name |
937 |
// * of the type that declares the method that is being |
938 |
// * implemented or overridden</li> |
939 |
// * </ul> |
940 |
// * For kinds of completion proposals, this method returns |
941 |
// * <code>null</code>. Clients must not modify the array |
942 |
// * returned. |
943 |
// * </p> |
944 |
// * |
945 |
// * @return the dot-based package name, or |
946 |
// * <code>null</code> if none |
947 |
// * @see #getDeclarationSignature() |
948 |
// * @see #getSignature() |
949 |
// * |
950 |
// * @since 3.1 |
951 |
// */ |
952 |
// public char[] getDeclarationTypeName() { |
953 |
// return this.declarationTypeName; |
954 |
// } |
955 |
// |
956 |
// /** |
957 |
// * Returns the package name of the method or type |
958 |
// * relevant in the context, or <code>null</code> if none. |
959 |
// * <p> |
960 |
// * This field is available for the following kinds of |
961 |
// * completion proposals: |
962 |
// * <ul> |
963 |
// * <li><code>FIELD_REF</code> - the dot-based package name |
964 |
// * of the referenced field's type</li> |
965 |
// * <li><code>LOCAL_VARIABLE_REF</code> - the dot-based package name |
966 |
// * of the referenced local variable's type</li> |
967 |
// * <li><code>METHOD_REF</code> - the dot-based package name |
968 |
// * of the return type of the method that is referenced</li> |
969 |
// * <li><code>METHOD_DECLARATION</code> - the dot-based package name |
970 |
// * of the return type of the method that is being implemented |
971 |
// * or overridden</li> |
972 |
// * <li><code>PACKAGE_REF</code> - the dot-based package name |
973 |
// * of the package that is referenced</li> |
974 |
// * <li><code>TYPE_REF</code> - the dot-based package name |
975 |
// * of the type that is referenced</li> |
976 |
// * <li><code>VARIABLE_DECLARATION</code> - the dot-based package name |
977 |
// * of the type of the variable being declared</li> |
978 |
// * </ul> |
979 |
// * For kinds of completion proposals, this method returns |
980 |
// * <code>null</code>. Clients must not modify the array |
981 |
// * returned. |
982 |
// * </p> |
983 |
// * |
984 |
// * @return the package name, or <code>null</code> if none |
985 |
// * |
986 |
// * @see #getDeclarationSignature() |
987 |
// * @see #getSignature() |
988 |
// * |
989 |
// * @since 3.1 |
990 |
// */ |
991 |
// public char[] getPackageName() { |
992 |
// return this.packageName; |
993 |
// } |
994 |
// |
995 |
// /** |
996 |
// * Returns the type name without the package fragment of the method or type |
997 |
// * relevant in the context, or <code>null</code> if none. |
998 |
// * <p> |
999 |
// * This field is available for the following kinds of |
1000 |
// * completion proposals: |
1001 |
// * <ul> |
1002 |
// * <li><code>FIELD_REF</code> - the dot-based type name |
1003 |
// * of the referenced field's type</li> |
1004 |
// * <li><code>LOCAL_VARIABLE_REF</code> - the dot-based type name |
1005 |
// * of the referenced local variable's type</li> |
1006 |
// * <li><code>METHOD_REF</code> - the dot-based type name |
1007 |
// * of the return type of the method that is referenced</li> |
1008 |
// * <li><code>METHOD_DECLARATION</code> - the dot-based type name |
1009 |
// * of the return type of the method that is being implemented |
1010 |
// * or overridden</li> |
1011 |
// * <li><code>TYPE_REF</code> - the dot-based type name |
1012 |
// * of the type that is referenced</li> |
1013 |
// * <li><code>VARIABLE_DECLARATION</code> - the dot-based package name |
1014 |
// * of the type of the variable being declared</li> |
1015 |
// * </ul> |
1016 |
// * For kinds of completion proposals, this method returns |
1017 |
// * <code>null</code>. Clients must not modify the array |
1018 |
// * returned. |
1019 |
// * </p> |
1020 |
// * |
1021 |
// * @return the package name, or <code>null</code> if none |
1022 |
// * |
1023 |
// * @see #getDeclarationSignature() |
1024 |
// * @see #getSignature() |
1025 |
// * |
1026 |
// * @since 3.1 |
1027 |
// */ |
1028 |
// public char[] getTypeName() { |
1029 |
// return this.typeName; |
1030 |
// } |
1031 |
// |
1032 |
// /** |
1033 |
// * Returns the parameter package names of the method |
1034 |
// * relevant in the context, or <code>null</code> if none. |
1035 |
// * <p> |
1036 |
// * This field is available for the following kinds of |
1037 |
// * completion proposals: |
1038 |
// * <ul> |
1039 |
// * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - parameter package names |
1040 |
// * of the constructor that is being invoked</li> |
1041 |
// * <li><code>METHOD_REF</code> - parameter package names |
1042 |
// * of the method that is referenced</li> |
1043 |
// * <li><code>METHOD_DECLARATION</code> - parameter package names |
1044 |
// * of the method that is being implemented or overridden</li> |
1045 |
// * </ul> |
1046 |
// * For kinds of completion proposals, this method returns |
1047 |
// * <code>null</code>. Clients must not modify the array |
1048 |
// * returned. |
1049 |
// * </p> |
1050 |
// * |
1051 |
// * @return the package name, or <code>null</code> if none |
1052 |
// * |
1053 |
// * @see #getDeclarationSignature() |
1054 |
// * @see #getSignature() |
1055 |
// * |
1056 |
// * @since 3.1 |
1057 |
// */ |
1058 |
// public char[][] getParameterPackageNames() { |
1059 |
// return this.parameterPackageNames; |
1060 |
// } |
1061 |
// |
1062 |
// /** |
1063 |
// * Returns the parameter type names without the package fragment of |
1064 |
// * the method relevant in the context, or <code>null</code> if none. |
1065 |
// * <p> |
1066 |
// * This field is available for the following kinds of |
1067 |
// * completion proposals: |
1068 |
// * <ul> |
1069 |
// * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - parameter type names |
1070 |
// * of the constructor that is being invoked</li> |
1071 |
// * <li><code>METHOD_REF</code> - parameter type names |
1072 |
// * of the method that is referenced</li> |
1073 |
// * <li><code>METHOD_DECLARATION</code> - parameter type names |
1074 |
// * of the method that is being implemented or overridden</li> |
1075 |
// * </ul> |
1076 |
// * For kinds of completion proposals, this method returns |
1077 |
// * <code>null</code>. Clients must not modify the array |
1078 |
// * returned. |
1079 |
// * </p> |
1080 |
// * |
1081 |
// * @return the package name, or <code>null</code> if none |
1082 |
// * |
1083 |
// * @see #getDeclarationSignature() |
1084 |
// * @see #getSignature() |
1085 |
// * |
1086 |
// * @since 3.1 |
1087 |
// */ |
1088 |
// public char[][] getParameterTypeNames() { |
1089 |
// return this.parameterTypeNames; |
1090 |
// } |
1091 |
|
1092 |
/** |
1093 |
* Sets the signature of the method, field type, member type, |
1094 |
* relevant in the context, or <code>null</code> if none. |
1095 |
* <p> |
1096 |
* If not set, defaults to none. |
1097 |
* </p> |
1098 |
* <p> |
1099 |
* The completion engine creates instances of this class and sets |
1100 |
* its properties; this method is not intended to be used by other clients. |
1101 |
* </p> |
1102 |
* |
1103 |
* @param signature the signature, or <code>null</code> if none |
1104 |
*/ |
1105 |
public void setSignature(char[] signature) { |
1106 |
this.signature = signature; |
1107 |
} |
1108 |
|
1109 |
/** |
1110 |
* Sets the key of the method, field type, member type, |
1111 |
* relevant in the context, or <code>null</code> if none. |
1112 |
* <p> |
1113 |
* If not set, defaults to none. |
1114 |
* </p> |
1115 |
* <p> |
1116 |
* The completion engine creates instances of this class and sets |
1117 |
* its properties; this method is not intended to be used by other clients. |
1118 |
* </p> |
1119 |
* |
1120 |
* @param key the key, or <code>null</code> if none |
1121 |
* @since 3.1 |
1122 |
*/ |
1123 |
public void setKey(char[] key) { |
1124 |
this.key = key; |
1125 |
} |
1126 |
|
1127 |
/** |
1128 |
* Returns the modifier flags relevant in the context, or |
1129 |
* <code>Flags.AccDefault</code> if none. |
1130 |
* <p> |
1131 |
* This field is available for the following kinds of |
1132 |
* completion proposals: |
1133 |
* <ul> |
1134 |
* <li><code>ANNOTATION_ATTRIBUT_REF</code> - modifier flags |
1135 |
* of the attribute that is referenced; |
1136 |
* <li><code>ANONYMOUS_CLASS_DECLARATION</code> - modifier flags |
1137 |
* of the constructor that is referenced</li> |
1138 |
* <li><code>FIELD_IMPORT</code> - modifier flags |
1139 |
* of the field that is imported.</li> |
1140 |
* <li><code>FIELD_REF</code> - modifier flags |
1141 |
* of the field that is referenced; |
1142 |
* <code>Flags.AccEnum</code> can be used to recognize |
1143 |
* references to enum constants |
1144 |
* </li> |
1145 |
* <li><code>FIELD_REF_WITH_CASTED_RECEIVER</code> - modifier flags |
1146 |
* of the field that is referenced. |
1147 |
* </li> |
1148 |
* <li><code>KEYWORD</code> - modifier flag |
1149 |
* corresponding to the modifier keyword</li> |
1150 |
* <li><code>LOCAL_VARIABLE_REF</code> - modifier flags |
1151 |
* of the local variable that is referenced</li> |
1152 |
* <li><code>METHOD_IMPORT</code> - modifier flags |
1153 |
* of the method that is imported; |
1154 |
* </li> |
1155 |
* <li><code>METHOD_REF</code> - modifier flags |
1156 |
* of the method that is referenced; |
1157 |
* <code>Flags.AccAnnotation</code> can be used to recognize |
1158 |
* references to annotation type members |
1159 |
* </li> |
1160 |
* <li><code>METHOD_REF_WITH_CASTED_RECEIVER</code> - modifier flags |
1161 |
* of the method that is referenced. |
1162 |
* </li> |
1163 |
* <li><code>METHOD_DECLARATION</code> - modifier flags |
1164 |
* for the method that is being implemented or overridden</li> |
1165 |
* <li><code>TYPE_IMPORT</code> - modifier flags |
1166 |
* of the type that is imported; <code>Flags.AccInterface</code> |
1167 |
* can be used to recognize references to interfaces, |
1168 |
* <code>Flags.AccEnum</code> enum types, |
1169 |
* and <code>Flags.AccAnnotation</code> annotation types</li> |
1170 |
* <li><code>TYPE_REF</code> - modifier flags |
1171 |
* of the type that is referenced; <code>Flags.AccInterface</code> |
1172 |
* can be used to recognize references to interfaces, |
1173 |
* <code>Flags.AccEnum</code> enum types, |
1174 |
* and <code>Flags.AccAnnotation</code> annotation types |
1175 |
* </li> |
1176 |
* <li><code>VARIABLE_DECLARATION</code> - modifier flags |
1177 |
* for the variable being declared</li> |
1178 |
* <li><code>POTENTIAL_METHOD_DECLARATION</code> - modifier flags |
1179 |
* for the method that is being created</li> |
1180 |
* </ul> |
1181 |
* For other kinds of completion proposals, this method returns |
1182 |
* <code>Flags.AccDefault</code>. |
1183 |
* </p> |
1184 |
* |
1185 |
* @return the modifier flags, or |
1186 |
* <code>Flags.AccDefault</code> if none |
1187 |
* @see Flags |
1188 |
*/ |
1189 |
public int getFlags() { |
1190 |
return this.flags; |
1191 |
} |
1192 |
|
1193 |
/** |
1194 |
* Sets the modifier flags relevant in the context. |
1195 |
* <p> |
1196 |
* If not set, defaults to none. |
1197 |
* </p> |
1198 |
* <p> |
1199 |
* The completion engine creates instances of this class and sets |
1200 |
* its properties; this method is not intended to be used by other clients. |
1201 |
* </p> |
1202 |
* |
1203 |
* @param flags the modifier flags, or |
1204 |
* <code>Flags.AccDefault</code> if none |
1205 |
*/ |
1206 |
public void setFlags(int flags) { |
1207 |
this.flags = flags; |
1208 |
} |
1209 |
|
1210 |
/** |
1211 |
* Returns the required completion proposals. |
1212 |
* The proposal can be apply only if these required completion proposals are also applied. |
1213 |
* If the required proposal aren't applied the completion could create completion problems. |
1214 |
* |
1215 |
* <p> |
1216 |
* This field is available for the following kinds of |
1217 |
* completion proposals: |
1218 |
* <ul> |
1219 |
* <li><code>FIELD_REF</code> - The allowed required proposals for this kind are: |
1220 |
* <ul> |
1221 |
* <li><code>TYPE_REF</code></li> |
1222 |
* <li><code>TYPE_IMPORT</code></li> |
1223 |
* <li><code>FIELD_IMPORT</code></li> |
1224 |
* </ul> |
1225 |
* </li> |
1226 |
* <li><code>METHOD_REF</code> - The allowed required proposals for this kind are: |
1227 |
* <ul> |
1228 |
* <li><code>TYPE_REF</code></li> |
1229 |
* <li><code>TYPE_IMPORT</code></li> |
1230 |
* <li><code>METHOD_IMPORT</code></li> |
1231 |
* </ul> |
1232 |
* </li> |
1233 |
* </li> |
1234 |
* <li><code>TYPE_REF</code> - The allowed required proposals for this kind are: |
1235 |
* <ul> |
1236 |
* <li><code>TYPE_REF</code></li> |
1237 |
* </ul> |
1238 |
* </li> |
1239 |
* </ul> |
1240 |
* </p> |
1241 |
* <p> |
1242 |
* Other kinds of required proposals will be returned in the future, therefore clients of this |
1243 |
* API must allow with {@link CompletionRequestor#setAllowsRequiredProposals(int, int, boolean)} |
1244 |
* only kinds which are in this list to avoid unexpected results in the future. |
1245 |
* </p> |
1246 |
* <p> |
1247 |
* A required proposal of a given kind is proposed even if {@link CompletionRequestor#isIgnored(int)} |
1248 |
* return <code>true</code> for that kind. |
1249 |
* </p> |
1250 |
* <p> |
1251 |
* A required completion proposal cannot have required completion proposals. |
1252 |
* </p> |
1253 |
* |
1254 |
* @return the required completion proposals, or <code>null</code> if none. |
1255 |
* |
1256 |
* @see CompletionRequestor#setAllowsRequiredProposals(int, int,boolean) |
1257 |
* |
1258 |
* @since 3.3 |
1259 |
*/ |
1260 |
public CompletionProposal[] getRequiredProposals() { |
1261 |
return this.requiredProposals; |
1262 |
} |
1263 |
|
1264 |
|
1265 |
/** |
1266 |
* Sets the list of required completion proposals, or <code>null</code> if none. |
1267 |
* <p> |
1268 |
* If not set, defaults to none. |
1269 |
* </p> |
1270 |
* <p> |
1271 |
* The completion engine creates instances of this class and sets |
1272 |
* its properties; this method is not intended to be used by other clients. |
1273 |
* </p> |
1274 |
* |
1275 |
* @param proposals the list of required completion proposals, or |
1276 |
* <code>null</code> if none |
1277 |
* @since 3.3 |
1278 |
*/ |
1279 |
public void setRequiredProposals(CompletionProposal[] proposals) { |
1280 |
this.requiredProposals = proposals; |
1281 |
} |
1282 |
|
1283 |
/** |
1284 |
* Finds the method parameter names. |
1285 |
* This information is relevant to method reference (and |
1286 |
* method declaration proposals). Returns <code>null</code> |
1287 |
* if not available or not relevant. |
1288 |
* <p> |
1289 |
* The client must not modify the array returned. |
1290 |
* </p> |
1291 |
* <p> |
1292 |
* <b>Note that this is an expensive thing to compute, which may require |
1293 |
* parsing Java source files, etc. Use sparingly.</b> |
1294 |
* </p> |
1295 |
* |
1296 |
* @param monitor the progress monitor, or <code>null</code> if none |
1297 |
* @return the parameter names, or <code>null</code> if none |
1298 |
* or not available or not relevant |
1299 |
*/ |
1300 |
public char[][] findParameterNames(IProgressMonitor monitor) { |
1301 |
if (!this.parameterNamesComputed) { |
1302 |
this.parameterNamesComputed = true; |
1303 |
|
1304 |
switch(this.completionKind) { |
1305 |
case ANONYMOUS_CLASS_DECLARATION: |
1306 |
try { |
1307 |
this.parameterNames = findMethodParameterNames( |
1308 |
this.declarationPackageName, |
1309 |
this.declarationTypeName, |
1310 |
CharOperation.lastSegment(this.declarationTypeName, '.'), |
1311 |
Signature.getParameterTypes(this.originalSignature == null ? this.signature : this.originalSignature)); |
1312 |
} catch(IllegalArgumentException e) { |
1313 |
// protection for invalid signature |
1314 |
if(this.parameterTypeNames != null) { |
1315 |
this.parameterNames = createDefaultParameterNames(this.parameterTypeNames.length); |
1316 |
} else { |
1317 |
this.parameterNames = null; |
1318 |
} |
1319 |
} |
1320 |
break; |
1321 |
case METHOD_REF: |
1322 |
case METHOD_REF_WITH_CASTED_RECEIVER: |
1323 |
try { |
1324 |
this.parameterNames = findMethodParameterNames( |
1325 |
this.declarationPackageName, |
1326 |
this.declarationTypeName, |
1327 |
this.name, |
1328 |
Signature.getParameterTypes(this.originalSignature == null ? this.signature : this.originalSignature)); |
1329 |
} catch(IllegalArgumentException e) { |
1330 |
// protection for invalid signature |
1331 |
if(this.parameterTypeNames != null) { |
1332 |
this.parameterNames = createDefaultParameterNames(this.parameterTypeNames.length); |
1333 |
} else { |
1334 |
this.parameterNames = null; |
1335 |
} |
1336 |
} |
1337 |
break; |
1338 |
case METHOD_DECLARATION: |
1339 |
try { |
1340 |
this.parameterNames = findMethodParameterNames( |
1341 |
this.declarationPackageName, |
1342 |
this.declarationTypeName, |
1343 |
this.name, |
1344 |
Signature.getParameterTypes(this.originalSignature == null ? this.signature : this.originalSignature)); |
1345 |
} catch(IllegalArgumentException e) { |
1346 |
// protection for invalid signature |
1347 |
if(this.parameterTypeNames != null) { |
1348 |
this.parameterNames = createDefaultParameterNames(this.parameterTypeNames.length); |
1349 |
} else { |
1350 |
this.parameterNames = null; |
1351 |
} |
1352 |
} |
1353 |
if(this.parameterNames != null) { |
1354 |
this.updateCompletion = true; |
1355 |
} |
1356 |
break; |
1357 |
} |
1358 |
} |
1359 |
return this.parameterNames; |
1360 |
} |
1361 |
|
1362 |
/** |
1363 |
* Sets the method parameter names. |
1364 |
* This information is relevant to method reference (and |
1365 |
* method declaration proposals). |
1366 |
* <p> |
1367 |
* The completion engine creates instances of this class and sets |
1368 |
* its properties; this method is not intended to be used by other clients. |
1369 |
* </p> |
1370 |
* |
1371 |
* @param parameterNames the parameter names, or <code>null</code> if none |
1372 |
*/ |
1373 |
public void setParameterNames(char[][] parameterNames) { |
1374 |
this.parameterNames = parameterNames; |
1375 |
this.parameterNamesComputed = true; |
1376 |
} |
1377 |
|
1378 |
/** |
1379 |
* Returns the accessibility of the proposal. |
1380 |
* <p> |
1381 |
* This field is available for the following kinds of |
1382 |
* completion proposals: |
1383 |
* <ul> |
1384 |
* <li><code>TYPE_REF</code> - accessibility of the type</li> |
1385 |
* </ul> |
1386 |
* For these kinds of completion proposals, this method returns |
1387 |
* {@link IAccessRule#K_ACCESSIBLE} or {@link IAccessRule#K_DISCOURAGED} |
1388 |
* or {@link IAccessRule#K_NON_ACCESSIBLE}. |
1389 |
* By default this method return {@link IAccessRule#K_ACCESSIBLE}. |
1390 |
* </p> |
1391 |
* |
1392 |
* @see IAccessRule |
1393 |
* |
1394 |
* @return the accessibility of the proposal |
1395 |
* |
1396 |
* @since 3.1 |
1397 |
*/ |
1398 |
public int getAccessibility() { |
1399 |
return this.accessibility; |
1400 |
} |
1401 |
|
1402 |
/** |
1403 |
* Returns whether this proposal is a constructor. |
1404 |
* <p> |
1405 |
* This field is available for the following kinds of |
1406 |
* completion proposals: |
1407 |
* <ul> |
1408 |
* <li><code>METHOD_REF</code> - return <code>true</code> |
1409 |
* if the referenced method is a constructor</li> |
1410 |
* <li><code>METHOD_DECLARATION</code> - return <code>true</code> |
1411 |
* if the declared method is a constructor</li> |
1412 |
* </ul> |
1413 |
* For kinds of completion proposals, this method returns |
1414 |
* <code>false</code>. |
1415 |
* </p> |
1416 |
* |
1417 |
* @return <code>true</code> if the proposal is a constructor. |
1418 |
* @since 3.1 |
1419 |
*/ |
1420 |
public boolean isConstructor() { |
1421 |
return this.isConstructor; |
1422 |
} |
1423 |
|
1424 |
private int receiverStart; |
1425 |
private int receiverEnd; |
1426 |
private char[] receiverSignature; |
1427 |
|
1428 |
/** |
1429 |
* Returns the type signature or package name of the relevant |
1430 |
* receiver in the context, or <code>null</code> if none. |
1431 |
* <p> |
1432 |
* This field is available for the following kinds of |
1433 |
* completion proposals: |
1434 |
* <ul> |
1435 |
* <li><code>FIELD_REF_WITH_CASTED_RECEIVER</code> - type signature |
1436 |
* of the type that cast the receiver of the field that is referenced</li> |
1437 |
* <li><code>METHOD_REF_WITH_CASTED_RECEIVER</code> - type signature |
1438 |
* of the type that cast the receiver of the method that is referenced</li> |
1439 |
* </ul> |
1440 |
* For kinds of completion proposals, this method returns |
1441 |
* <code>null</code>. Clients must not modify the array |
1442 |
* returned. |
1443 |
* </p> |
1444 |
* |
1445 |
* @return a type signature or a package name (depending |
1446 |
* on the kind of completion), or <code>null</code> if none |
1447 |
* @see Signature |
1448 |
* |
1449 |
* @since 3.4 |
1450 |
*/ |
1451 |
public char[] getReceiverSignature() { |
1452 |
return this.receiverSignature; |
1453 |
} |
1454 |
|
1455 |
/** |
1456 |
* Returns the character index of the start of the |
1457 |
* subrange in the source file buffer containing the |
1458 |
* relevant receiver of the member being completed. This |
1459 |
* receiver is an expression. |
1460 |
* |
1461 |
* <p> |
1462 |
* This field is available for the following kinds of |
1463 |
* completion proposals: |
1464 |
* <ul> |
1465 |
* <li><code>FIELD_REF_WITH_CASTED_RECEIVER</code></li> |
1466 |
* <li><code>METHOD_REF_WITH_CASTED_RECEIVER</code></li> |
1467 |
* </ul> |
1468 |
* For kinds of completion proposals, this method returns <code>0</code>. |
1469 |
* </p> |
1470 |
* |
1471 |
* @return character index of receiver start position (inclusive) |
1472 |
* |
1473 |
* @since 3.4 |
1474 |
*/ |
1475 |
public int getReceiverStart() { |
1476 |
return this.receiverStart; |
1477 |
} |
1478 |
|
1479 |
/** |
1480 |
* Returns the character index of the end (exclusive) of the subrange |
1481 |
* in the source file buffer containing the |
1482 |
* relevant receiver of the member being completed. |
1483 |
* |
1484 |
* * <p> |
1485 |
* This field is available for the following kinds of |
1486 |
* completion proposals: |
1487 |
* <ul> |
1488 |
* <li><code>FIELD_REF_WITH_CASTED_RECEIVER</code></li> |
1489 |
* <li><code>METHOD_REF_WITH_CASTED_RECEIVER</code></li> |
1490 |
* </ul> |
1491 |
* For kinds of completion proposals, this method returns <code>0</code>. |
1492 |
* </p> |
1493 |
* |
1494 |
* @return character index of receiver end position (exclusive) |
1495 |
* |
1496 |
* @since 3.4 |
1497 |
*/ |
1498 |
public int getReceiverEnd() { |
1499 |
return this.receiverEnd; |
1500 |
} |
1501 |
|
1502 |
/** |
1503 |
* Sets the type or package signature of the relevant |
1504 |
* receiver in the context, or <code>null</code> if none. |
1505 |
* <p> |
1506 |
* If not set, defaults to none. |
1507 |
* </p> |
1508 |
* <p> |
1509 |
* The completion engine creates instances of this class and sets |
1510 |
* its properties; this method is not intended to be used by other clients. |
1511 |
* </p> |
1512 |
* |
1513 |
* @param signature the type or package signature, or |
1514 |
* <code>null</code> if none |
1515 |
* |
1516 |
* @since 3.4 |
1517 |
*/ |
1518 |
public void setReceiverSignature(char[] signature) { |
1519 |
this.receiverSignature = signature; |
1520 |
} |
1521 |
|
1522 |
/** |
1523 |
* Sets the character indices of the subrange in the |
1524 |
* source file buffer containing the relevant receiver |
1525 |
* of the member being completed. |
1526 |
* |
1527 |
* <p> |
1528 |
* If not set, defaults to empty subrange at [0,0). |
1529 |
* </p> |
1530 |
* |
1531 |
* @param startIndex character index of receiver start position (inclusive) |
1532 |
* @param endIndex character index of receiver end position (exclusive) |
1533 |
* |
1534 |
* @since 3.4 |
1535 |
*/ |
1536 |
public void setReceiverRange(int startIndex, int endIndex) { |
1537 |
this.receiverStart = startIndex; |
1538 |
this.receiverEnd = endIndex; |
1539 |
} |
1540 |
|
1541 |
public String toString() { |
1542 |
StringBuffer buffer = new StringBuffer(); |
1543 |
buffer.append('['); |
1544 |
switch(this.completionKind) { |
1545 |
case CompletionProposal.ANONYMOUS_CLASS_DECLARATION : |
1546 |
buffer.append("ANONYMOUS_CLASS_DECLARATION"); //$NON-NLS-1$ |
1547 |
break; |
1548 |
case CompletionProposal.FIELD_REF : |
1549 |
buffer.append("FIELD_REF"); //$NON-NLS-1$ |
1550 |
break; |
1551 |
case CompletionProposal.KEYWORD : |
1552 |
buffer.append("KEYWORD"); //$NON-NLS-1$ |
1553 |
break; |
1554 |
case CompletionProposal.LABEL_REF : |
1555 |
buffer.append("LABEL_REF"); //$NON-NLS-1$ |
1556 |
break; |
1557 |
case CompletionProposal.LOCAL_VARIABLE_REF : |
1558 |
buffer.append("LOCAL_VARIABLE_REF"); //$NON-NLS-1$ |
1559 |
break; |
1560 |
case CompletionProposal.METHOD_DECLARATION : |
1561 |
buffer.append("METHOD_DECLARATION"); //$NON-NLS-1$ |
1562 |
if(this.isConstructor) { |
1563 |
buffer.append("<CONSTRUCTOR>"); //$NON-NLS-1$ |
1564 |
} |
1565 |
break; |
1566 |
case CompletionProposal.METHOD_REF : |
1567 |
buffer.append("METHOD_REF"); //$NON-NLS-1$ |
1568 |
if(this.isConstructor) { |
1569 |
buffer.append("<CONSTRUCTOR>"); //$NON-NLS-1$ |
1570 |
} |
1571 |
break; |
1572 |
case CompletionProposal.PACKAGE_REF : |
1573 |
buffer.append("PACKAGE_REF"); //$NON-NLS-1$ |
1574 |
break; |
1575 |
case CompletionProposal.TYPE_REF : |
1576 |
buffer.append("TYPE_REF"); //$NON-NLS-1$ |
1577 |
break; |
1578 |
case CompletionProposal.VARIABLE_DECLARATION : |
1579 |
buffer.append("VARIABLE_DECLARATION"); //$NON-NLS-1$ |
1580 |
break; |
1581 |
case CompletionProposal.POTENTIAL_METHOD_DECLARATION : |
1582 |
buffer.append("POTENTIAL_METHOD_DECLARATION"); //$NON-NLS-1$ |
1583 |
break; |
1584 |
case CompletionProposal.METHOD_NAME_REFERENCE : |
1585 |
buffer.append("METHOD_IMPORT"); //$NON-NLS-1$ |
1586 |
break; |
1587 |
case CompletionProposal.ANNOTATION_ATTRIBUTE_REF : |
1588 |
buffer.append("ANNOTATION_ATTRIBUTE_REF"); //$NON-NLS-1$ |
1589 |
break; |
1590 |
case CompletionProposal.JAVADOC_BLOCK_TAG : |
1591 |
buffer.append("JAVADOC_BLOCK_TAG"); //$NON-NLS-1$ |
1592 |
break; |
1593 |
case CompletionProposal.JAVADOC_INLINE_TAG : |
1594 |
buffer.append("JAVADOC_INLINE_TAG"); //$NON-NLS-1$ |
1595 |
break; |
1596 |
case CompletionProposal.JAVADOC_FIELD_REF: |
1597 |
buffer.append("JAVADOC_FIELD_REF"); //$NON-NLS-1$ |
1598 |
break; |
1599 |
case CompletionProposal.JAVADOC_METHOD_REF : |
1600 |
buffer.append("JAVADOC_METHOD_REF"); //$NON-NLS-1$ |
1601 |
break; |
1602 |
case CompletionProposal.JAVADOC_TYPE_REF : |
1603 |
buffer.append("JAVADOC_TYPE_REF"); //$NON-NLS-1$ |
1604 |
break; |
1605 |
case CompletionProposal.JAVADOC_PARAM_REF : |
1606 |
buffer.append("JAVADOC_PARAM_REF"); //$NON-NLS-1$ |
1607 |
break; |
1608 |
case CompletionProposal.JAVADOC_VALUE_REF : |
1609 |
buffer.append("JAVADOC_VALUE_REF"); //$NON-NLS-1$ |
1610 |
break; |
1611 |
case CompletionProposal.FIELD_IMPORT : |
1612 |
buffer.append("FIELD_IMPORT"); //$NON-NLS-1$ |
1613 |
break; |
1614 |
case CompletionProposal.METHOD_IMPORT : |
1615 |
buffer.append("METHOD_IMPORT"); //$NON-NLS-1$ |
1616 |
break; |
1617 |
case CompletionProposal.TYPE_IMPORT : |
1618 |
buffer.append("TYPE_IMPORT"); //$NON-NLS-1$ |
1619 |
break; |
1620 |
case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER : |
1621 |
buffer.append("METHOD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$ |
1622 |
break; |
1623 |
case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER : |
1624 |
buffer.append("FIELD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$ |
1625 |
break; |
1626 |
default : |
1627 |
buffer.append("PROPOSAL"); //$NON-NLS-1$ |
1628 |
break; |
1629 |
|
1630 |
} |
1631 |
buffer.append("]{completion:"); //$NON-NLS-1$ |
1632 |
if (this.completion != null) buffer.append(this.completion); |
1633 |
buffer.append(", declSign:"); //$NON-NLS-1$ |
1634 |
if (this.declarationSignature != null) buffer.append(this.declarationSignature); |
1635 |
buffer.append(", sign:"); //$NON-NLS-1$ |
1636 |
if (this.signature != null) buffer.append(this.signature); |
1637 |
buffer.append(", declKey:"); //$NON-NLS-1$ |
1638 |
if (this.declarationKey != null) buffer.append(this.declarationKey); |
1639 |
buffer.append(", key:"); //$NON-NLS-1$ |
1640 |
if (this.key != null) buffer.append(this.key); |
1641 |
buffer.append(", name:"); //$NON-NLS-1$ |
1642 |
if (this.name != null) buffer.append(this.name); |
1643 |
buffer.append(", replace:["); //$NON-NLS-1$ |
1644 |
buffer.append(this.replaceStart); |
1645 |
buffer.append(','); |
1646 |
buffer.append(this.replaceEnd); |
1647 |
buffer.append("], token:["); //$NON-NLS-1$ |
1648 |
buffer.append(this.tokenStart); |
1649 |
buffer.append(','); |
1650 |
buffer.append(this.tokenEnd); |
1651 |
buffer.append("], relevance:"); //$NON-NLS-1$ |
1652 |
buffer.append(this.relevance); |
1653 |
buffer.append('}'); |
1654 |
return buffer.toString(); |
1655 |
} |
196 |
} |
1656 |
} |