### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core
Index: codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java,v
retrieving revision 1.11
diff -u -r1.11 InternalCompletionProposal.java
--- codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java 27 Jun 2008 16:04:03 -0000 1.11
+++ codeassist/org/eclipse/jdt/internal/codeassist/InternalCompletionProposal.java 1 Sep 2008 10:49:27 -0000
@@ -10,10 +10,18 @@
*******************************************************************************/
package org.eclipse.jdt.internal.codeassist;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.CompletionFlags;
+import org.eclipse.jdt.core.CompletionProposal;
+import org.eclipse.jdt.core.CompletionRequestor;
+import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IAccessRule;
+import org.eclipse.jdt.core.ICodeAssist;
+import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.core.BinaryType;
import org.eclipse.jdt.internal.core.NameLookup;
@@ -22,7 +30,7 @@
* Internal completion proposal
* @since 3.1
*/
-public class InternalCompletionProposal {
+public class InternalCompletionProposal extends CompletionProposal {
private static Object NO_ATTACHED_SOURCE = new Object();
static final char[] ARG = "arg".toCharArray(); //$NON-NLS-1$
@@ -47,41 +55,162 @@
protected char[] originalSignature;
+ private boolean updateCompletion = false;
+
protected int accessibility = IAccessRule.K_ACCESSIBLE;
protected boolean isConstructor = false;
+ /**
+ * Kind of completion request.
+ */
+ private int completionKind;
+
+ /**
+ * Offset in original buffer where ICodeAssist.codeComplete() was
+ * requested.
+ */
+ private int completionLocation;
+
+ /**
+ * Start position (inclusive) of source range in original buffer
+ * containing the relevant token
+ * defaults to empty subrange at [0,0).
+ */
+ private int tokenStart = 0;
+
+ /**
+ * End position (exclusive) of source range in original buffer
+ * containing the relevant token;
+ * defaults to empty subrange at [0,0).
+ */
+ private int tokenEnd = 0;
+
+ /**
+ * Completion string; defaults to empty string.
+ */
+ private char[] completion = CharOperation.NO_CHAR;
+
+ /**
+ * Start position (inclusive) of source range in original buffer
+ * to be replaced by completion string;
+ * defaults to empty subrange at [0,0).
+ */
+ private int replaceStart = 0;
+
+ /**
+ * End position (exclusive) of source range in original buffer
+ * to be replaced by completion string;
+ * defaults to empty subrange at [0,0).
+ */
+ private int replaceEnd = 0;
+
+ /**
+ * Relevance rating; positive; higher means better;
+ * defaults to minimum rating.
+ */
+ private int relevance = 1;
+
+ /**
+ * Signature of the relevant package or type declaration
+ * in the context, or null
if none.
+ * Defaults to null.
+ */
+ private char[] declarationSignature = null;
+
+ /**
+ * Unique key of the relevant package or type declaration
+ * in the context, or null
if none.
+ * Defaults to null.
+ */
+ private char[] declarationKey = null;
+
+ /**
+ * Simple name of the method, field,
+ * member, or variable relevant in the context, or
+ * null
if none.
+ * Defaults to null.
+ */
+ private char[] name = null;
+
+ /**
+ * Signature of the method, field type, member type,
+ * relevant in the context, or null
if none.
+ * Defaults to null.
+ */
+ private char[] signature = null;
+
+ /**
+ * Unique of the method, field type, member type,
+ * relevant in the context, or null
if none.
+ * Defaults to null.
+ */
+ private char[] key = null;
+
+ /**
+ * Array of required completion proposals, or null
if none.
+ * The proposal can not be applied if the required proposals aren't applied.
+ * Defaults to null
.
+ */
+ private CompletionProposal[] requiredProposals;
+
+ /**
+ * Modifier flags relevant in the context, or
+ * Flags.AccDefault
if none.
+ * Defaults to Flags.AccDefault
.
+ */
+ private int flags = Flags.AccDefault;
+
+ /**
+ * Completion flags relevant in the context, or
+ * CompletionFlags.Default
if none.
+ * Defaults to CompletionFlags.Default
.
+ */
+ private int additionalFlags = CompletionFlags.Default;
+
+ /**
+ * Parameter names (for method completions), or
+ * null
if none. Lazily computed.
+ * Defaults to null
.
+ */
+ private char[][] parameterNames = null;
+
+ /**
+ * Indicates whether parameter names have been computed.
+ */
+ private boolean parameterNamesComputed = false;
+
protected char[][] createDefaultParameterNames(int length) {
- char[][] parameterNames;
+ char[][] parameters;
switch (length) {
case 0 :
- parameterNames = new char[length][];
+ parameters = new char[length][];
break;
case 1 :
- parameterNames = ARGS1;
+ parameters = ARGS1;
break;
case 2 :
- parameterNames = ARGS2;
+ parameters = ARGS2;
break;
case 3 :
- parameterNames = ARGS3;
+ parameters = ARGS3;
break;
case 4 :
- parameterNames = ARGS4;
+ parameters = ARGS4;
break;
default :
- parameterNames = new char[length][];
+ parameters = new char[length][];
for (int i = 0; i < length; i++) {
- parameterNames[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray());
+ parameters[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray());
}
break;
}
- return parameterNames;
+ return parameters;
}
protected char[][] findMethodParameterNames(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, char[][] paramTypeNames){
if(paramTypeNames == null || declaringTypeName == null) return null;
- char[][] parameterNames = null;
+ char[][] parameters = null;
int length = paramTypeNames.length;
char[] tName = CharOperation.concat(declaringTypePackageName,declaringTypeName,'.');
@@ -116,22 +245,22 @@
}
IMethod method = type.getMethod(new String(selector),args);
try{
- parameterNames = new char[length][];
+ parameters = new char[length][];
String[] params = method.getParameterNames();
for(int i = 0; i< length ; i++){
- parameterNames[i] = params[i].toCharArray();
+ parameters[i] = params[i].toCharArray();
}
} catch(JavaModelException e){
- parameterNames = null;
+ parameters = null;
}
}
// default parameters name
- if(parameterNames == null) {
- parameterNames = createDefaultParameterNames(length);
+ if(parameters == null) {
+ parameters = createDefaultParameterNames(length);
}
- return parameterNames;
+ return parameters;
}
protected char[] getDeclarationPackageName() {
@@ -193,4 +322,1335 @@
public void setOriginalSignature(char[] originalSignature) {
this.originalSignature = originalSignature;
}
+ /**
+ * Creates a basic completion proposal. All instance
+ * field have plausible default values unless otherwise noted.
+ *
+ * Note that the constructors for this class are internal to the + * Java model implementation. Clients cannot directly create + * CompletionProposal objects. + *
+ * + * @param kind one of the kind constants declared on this class + * @param completionLocation original offset of code completion request + */ + public InternalCompletionProposal(int kind, int completionLocation) { + if ((kind < FIRST_KIND) + || (kind > LAST_KIND)) { + throw new IllegalArgumentException(); + } + if (this.completion == null || completionLocation < 0) { + // Work around for bug 132558 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=132558). + // completionLocation can be -1 if the completion occur at the start of a file or + // the start of a code snippet but this API isn't design to support negative position. + if(this.completion == null || completionLocation != -1) { + throw new IllegalArgumentException(); + } + completionLocation = 0; + } + this.completionKind = kind; + this.completionLocation = completionLocation; + } + + /** + * Returns the completion flags relevant in the context, or + *CompletionFlags.Default
if none.
+ * + * This field is available for the following kinds of + * completion proposals: + *
FIELD_IMPORT
- completion flags
+ * of the attribute that is referenced. Completion flags for
+ * this proposal kind can only include CompletionFlags.StaticImport
METHOD_IMPORT
- completion flags
+ * of the attribute that is referenced. Completion flags for
+ * this proposal kind can only include CompletionFlags.StaticImport
TYPE_IMPORT
- completion flags
+ * of the attribute that is referenced. Completion flags for
+ * this proposal kind can only include CompletionFlags.StaticImport
CompletionFlags.Default
.
+ *
+ *
+ * @return the completion flags, or
+ * CompletionFlags.Default
if none
+ * @see CompletionFlags
+ *
+ * @since 3.3
+ */
+ public int getAdditionalFlags() {
+ return this.additionalFlags;
+ }
+
+ /**
+ * Sets the completion flags relevant in the context.
+ * + * If not set, defaults to none. + *
+ *+ * The completion engine creates instances of this class and sets + * its properties; this method is not intended to be used by other clients. + *
+ * + * @param additionalFlags the completion flags, or + *CompletionFlags.Default
if none
+ *
+ * @since 3.3
+ */
+ public void setAdditionalFlags(int additionalFlags) {
+ this.additionalFlags = additionalFlags;
+ }
+
+ /**
+ * Returns the kind of completion being proposed.
+ * + * The set of different kinds of completion proposals is + * expected to change over time. It is strongly recommended + * that clients do not assume that the kind is one of the + * ones they know about, and code defensively for the + * possibility of unexpected future growth. + *
+ * + * @return the kind; one of the kind constants + * declared on this class, or possibly a kind unknown + * to the caller + */ + public int getKind() { + return this.completionKind; + } + + /** + * Returns the character index in the source file buffer + * where source completion was requested (the + *offset
parameter to
+ * ICodeAssist.codeComplete
minus one).
+ *
+ * @return character index in source file buffer
+ * @see ICodeAssist#codeComplete(int,CompletionRequestor)
+ */
+ // TODO (david) https://bugs.eclipse.org/bugs/show_bug.cgi?id=132558
+ public int getCompletionLocation() {
+ return this.completionLocation;
+ }
+
+ /**
+ * Returns the character index of the start of the
+ * subrange in the source file buffer containing the
+ * relevant token being completed. This
+ * token is either the identifier or Java language keyword
+ * under, or immediately preceding, the original request
+ * offset. If the original request offset is not within
+ * or immediately after an identifier or keyword, then the
+ * position returned is original request offset and the
+ * token range is empty.
+ *
+ * @return character index of token start position (inclusive)
+ */
+ public int getTokenStart() {
+ return this.tokenStart;
+ }
+
+ /**
+ * Returns the character index of the end (exclusive) of the subrange
+ * in the source file buffer containing the
+ * relevant token. When there is no relevant token, the
+ * range is empty
+ * (getEndToken() == getStartToken()
).
+ *
+ * @return character index of token end position (exclusive)
+ */
+ public int getTokenEnd() {
+ return this.tokenEnd;
+ }
+
+ /**
+ * Sets the character indices of the subrange in the
+ * source file buffer containing the relevant token being
+ * completed. This token is either the identifier or
+ * Java language keyword under, or immediately preceding,
+ * the original request offset. If the original request
+ * offset is not within or immediately after an identifier
+ * or keyword, then the source range begins at original
+ * request offset and is empty.
+ * + * If not set, defaults to empty subrange at [0,0). + *
+ * + * @param startIndex character index of token start position (inclusive) + * @param endIndex character index of token end position (exclusive) + */ + public void setTokenRange(int startIndex, int endIndex) { + if (startIndex < 0 || endIndex < startIndex) { + throw new IllegalArgumentException(); + } + this.tokenStart = startIndex; + this.tokenEnd = endIndex; + } + + /** + * Returns the proposed sequence of characters to insert into the + * source file buffer, replacing the characters at the specified + * source range. The string can be arbitrary; for example, it might + * include not only the name of a method but a set of parentheses. + *+ * The client must not modify the array returned. + *
+ * + * @return the completion string + */ + public char[] getCompletion() { + if(this.completionKind == METHOD_DECLARATION) { + findParameterNames(null); + if(this.updateCompletion) { + this.updateCompletion = false; + + if(this.parameterNames != null) { + int length = this.parameterNames.length; + StringBuffer completionBuffer = new StringBuffer(this.completion.length); + + int start = 0; + int end = CharOperation.indexOf('%', this.completion); + + completionBuffer.append(this.completion, start, end - start); + + for(int i = 0 ; i < length ; i++){ + completionBuffer.append(this.parameterNames[i]); + start = end + 1; + end = CharOperation.indexOf('%', this.completion, start); + if(end > -1){ + completionBuffer.append(this.completion, start, end - start); + } else { + completionBuffer.append(this.completion, start, this.completion.length - start); + } + } + int nameLength = completionBuffer.length(); + this.completion = new char[nameLength]; + completionBuffer.getChars(0, nameLength, this.completion, 0); + } + } + } + return this.completion; + } + + /** + * Sets the proposed sequence of characters to insert into the + * source file buffer, replacing the characters at the specified + * source range. The string can be arbitrary; for example, it might + * include not only the name of a method but a set of parentheses. + *+ * If not set, defaults to an empty character array. + *
+ *+ * The completion engine creates instances of this class and sets + * its properties; this method is not intended to be used by other clients. + *
+ * + * @param completion the completion string + */ + public void setCompletion(char[] completion) { + this.completion = completion; + } + + /** + * Returns the character index of the start of the + * subrange in the source file buffer to be replaced + * by the completion string. If the subrange is empty + * (getReplaceEnd() == getReplaceStart()
),
+ * the completion string is to be inserted at this
+ * index.
+ * + * Note that while the token subrange is precisely + * specified, the replacement range is loosely + * constrained and may not bear any direct relation + * to the original request offset. For example, + * it would be possible for a type completion to + * propose inserting an import declaration at the + * top of the compilation unit; or the completion + * might include trailing parentheses and + * punctuation for a method completion. + *
+ * + * @return replacement start position (inclusive) + */ + public int getReplaceStart() { + return this.replaceStart; + } + + /** + * Returns the character index of the end of the + * subrange in the source file buffer to be replaced + * by the completion string. If the subrange is empty + * (getReplaceEnd() == getReplaceStart()
),
+ * the completion string is to be inserted at this
+ * index.
+ *
+ * @return replacement end position (exclusive)
+ */
+ public int getReplaceEnd() {
+ return this.replaceEnd;
+ }
+
+ /**
+ * Sets the character indices of the subrange in the
+ * source file buffer to be replaced by the completion
+ * string. If the subrange is empty
+ * (startIndex == endIndex
),
+ * the completion string is to be inserted at this
+ * index.
+ * + * If not set, defaults to empty subrange at [0,0). + *
+ *+ * The completion engine creates instances of this class and sets + * its properties; this method is not intended to be used by other clients. + *
+ * + * @param startIndex character index of replacement start position (inclusive) + * @param endIndex character index of replacement end position (exclusive) + */ + public void setReplaceRange(int startIndex, int endIndex) { + if (startIndex < 0 || endIndex < startIndex) { + throw new IllegalArgumentException(); + } + this.replaceStart = startIndex; + this.replaceEnd = endIndex; + } + + /** + * Returns the relative relevance rating of this proposal. + * + * @return relevance rating of this proposal; ratings are positive; higher means better + */ + public int getRelevance() { + return this.relevance; + } + + /** + * Sets the relative relevance rating of this proposal. + *+ * If not set, defaults to the lowest possible rating (1). + *
+ *+ * The completion engine creates instances of this class and sets + * its properties; this method is not intended to be used by other clients. + *
+ * + * @param rating relevance rating of this proposal; ratings are positive; higher means better + */ + public void setRelevance(int rating) { + if (rating <= 0) { + throw new IllegalArgumentException(); + } + this.relevance = rating; + } + + /** + * Returns the type signature or package name of the relevant + * declaration in the context, ornull
if none.
+ * + * This field is available for the following kinds of + * completion proposals: + *
ANNOTATION_ATTRIBUT_REF
- type signature
+ * of the annotation that declares the attribute that is referencedANONYMOUS_CLASS_DECLARATION
- type signature
+ * of the type that is being subclassed or implementedFIELD_IMPORT
- type signature
+ * of the type that declares the field that is importedFIELD_REF
- type signature
+ * of the type that declares the field that is referencedFIELD_REF_WITH_CASTED_RECEIVER
- type signature
+ * of the type that declares the field that is referencedMETHOD_IMPORT
- type signature
+ * of the type that declares the method that is importedMETHOD_REF
- type signature
+ * of the type that declares the method that is referencedMETHOD_REF_WITH_CASTED_RECEIVER
- type signature
+ * of the type that declares the method that is referencedMETHOD_DECLARATION
- type signature
+ * of the type that declares the method that is being
+ * implemented or overriddenPACKAGE_REF
- dot-based package
+ * name of the package that is referencedTYPE_IMPORT
- dot-based package
+ * name of the package containing the type that is importedTYPE_REF
- dot-based package
+ * name of the package containing the type that is referencedPOTENTIAL_METHOD_DECLARATION
- type signature
+ * of the type that declares the method that is being creatednull
. Clients must not modify the array
+ * returned.
+ *
+ *
+ * @return a type signature or a package name (depending
+ * on the kind of completion), or null
if none
+ * @see Signature
+ */
+ public char[] getDeclarationSignature() {
+ return this.declarationSignature;
+ }
+
+ /**
+ * Returns the key of the relevant
+ * declaration in the context, or null
if none.
+ * + * This field is available for the following kinds of + * completion proposals: + *
ANONYMOUS_CLASS_DECLARATION
- key
+ * of the type that is being subclassed or implementedMETHOD_DECLARATION
- key
+ * of the type that declares the method that is being
+ * implemented or overriddennull
. Clients must not modify the array
+ * returned.
+ *
+ *
+ * @return a key, or null
if none
+ * @see org.eclipse.jdt.core.dom.ASTParser#createASTs(ICompilationUnit[], String[], org.eclipse.jdt.core.dom.ASTRequestor, IProgressMonitor)
+ * @since 3.1
+ */
+ public char[] getDeclarationKey() {
+ return this.declarationKey;
+ }
+
+ /**
+ * Sets the type or package signature of the relevant
+ * declaration in the context, or null
if none.
+ * + * If not set, defaults to none. + *
+ *+ * The completion engine creates instances of this class and sets + * its properties; this method is not intended to be used by other clients. + *
+ * + * @param signature the type or package signature, or + *null
if none
+ */
+ public void setDeclarationSignature(char[] signature) {
+ this.declarationSignature = signature;
+ }
+
+ /**
+ * Sets the type or package key of the relevant
+ * declaration in the context, or null
if none.
+ * + * If not set, defaults to none. + *
+ *+ * The completion engine creates instances of this class and sets + * its properties; this method is not intended to be used by other clients. + *
+ * + * @param key the type or package key, or + *null
if none
+ * @since 3.1
+ */
+ public void setDeclarationKey(char[] key) {
+ this.declarationKey = key;
+ }
+
+ /**
+ * Returns the simple name of the method, field,
+ * member, or variable relevant in the context, or
+ * null
if none.
+ * + * This field is available for the following kinds of + * completion proposals: + *
ANNOTATION_ATTRIBUT_REF
- the name of the attributeFIELD_IMPORT
- the name of the fieldFIELD_REF
- the name of the fieldFIELD_REF_WITH_CASTED_RECEIVER
- the name of the fieldKEYWORD
- the keywordLABEL_REF
- the name of the labelLOCAL_VARIABLE_REF
- the name of the local variableMETHOD_IMPORT
- the name of the methodMETHOD_REF
- the name of the method (the type simple name for constructor)METHOD_REF_WITH_CASTED_RECEIVER
- the name of the methodMETHOD_DECLARATION
- the name of the method (the type simple name for constructor)VARIABLE_DECLARATION
- the name of the variablePOTENTIAL_METHOD_DECLARATION
- the name of the methodnull
. Clients must not modify the array
+ * returned.
+ *
+ *
+ * @return the keyword, field, method, local variable, or member
+ * name, or null
if none
+ */
+ public char[] getName() {
+ return this.name;
+ }
+
+
+ /**
+ * Sets the simple name of the method (type simple name for constructor), field,
+ * member, or variable relevant in the context, or
+ * null
if none.
+ * + * If not set, defaults to none. + *
+ *+ * The completion engine creates instances of this class and sets + * its properties; this method is not intended to be used by other clients. + *
+ * + * @param name the keyword, field, method, local variable, + * or member name, ornull
if none
+ */
+ public void setName(char[] name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the signature of the method or type
+ * relevant in the context, or null
if none.
+ * + * This field is available for the following kinds of + * completion proposals: + *
ANNOTATION_ATTRIBUT_REF
- the type signature
+ * of the referenced attribute's typeANONYMOUS_CLASS_DECLARATION
- method signature
+ * of the constructor that is being invokedFIELD_IMPORT
- the type signature
+ * of the referenced field's typeFIELD_REF
- the type signature
+ * of the referenced field's typeFIELD_REF_WITH_CASTED_RECEIVER
- the type signature
+ * of the referenced field's typeLOCAL_VARIABLE_REF
- the type signature
+ * of the referenced local variable's typeMETHOD_IMPORT
- method signature
+ * of the method that is importedMETHOD_REF
- method signature
+ * of the method that is referencedMETHOD_REF_WITH_CASTED_RECEIVER
- method signature
+ * of the method that is referencedMETHOD_DECLARATION
- method signature
+ * of the method that is being implemented or overriddenTYPE_IMPORT
- type signature
+ * of the type that is importedTYPE_REF
- type signature
+ * of the type that is referencedVARIABLE_DECLARATION
- the type signature
+ * of the type of the variable being declaredPOTENTIAL_METHOD_DECLARATION
- method signature
+ * of the method that is being creatednull
. Clients must not modify the array
+ * returned.
+ *
+ *
+ * @return the signature, or null
if none
+ * @see Signature
+ */
+ public char[] getSignature() {
+ return this.signature;
+ }
+
+ /**
+ * Returns the key relevant in the context,
+ * or null
if none.
+ * + * This field is available for the following kinds of + * completion proposals: + *
ANONYMOUS_CLASS_DECLARATION
- method key
+ * of the constructor that is being invoked, or null
if
+ * the declaring type is an interfaceMETHOD_DECLARATION
- method key
+ * of the method that is being implemented or overriddennull
. Clients must not modify the array
+ * returned.
+ *
+ *
+ * @return the key, or null
if none
+ * @see org.eclipse.jdt.core.dom.ASTParser#createASTs(ICompilationUnit[], String[], org.eclipse.jdt.core.dom.ASTRequestor, IProgressMonitor)
+ * @since 3.1
+ */
+ public char[] getKey() {
+ return this.key;
+ }
+
+// /**
+// * Returns the package name of the relevant
+// * declaration in the context, or null
if none.
+// * +// * This field is available for the following kinds of +// * completion proposals: +// *
ANONYMOUS_CLASS_DECLARATION
- the dot-based package name
+// * of the type that is being subclassed or implementedFIELD_REF
- the dot-based package name
+// * of the type that declares the field that is referencedMETHOD_REF
- the dot-based package name
+// * of the type that declares the method that is referencedMETHOD_DECLARATION
- the dot-based package name
+// * of the type that declares the method that is being
+// * implemented or overriddennull
. Clients must not modify the array
+// * returned.
+// *
+// *
+// * @return the dot-based package name, or
+// * null
if none
+// * @see #getDeclarationSignature()
+// * @see #getSignature()
+// *
+// * @since 3.1
+// */
+// public char[] getDeclarationPackageName() {
+// return this.declarationPackageName;
+// }
+//
+// /**
+// * Returns the type name of the relevant
+// * declaration in the context without the package fragment,
+// * or null
if none.
+// * +// * This field is available for the following kinds of +// * completion proposals: +// *
ANONYMOUS_CLASS_DECLARATION
- the dot-based type name
+// * of the type that is being subclassed or implementedFIELD_REF
- the dot-based type name
+// * of the type that declares the field that is referenced
+// * or an anonymous type instantiation ("new X(){}") if it is an anonymous typeMETHOD_REF
- the dot-based type name
+// * of the type that declares the method that is referenced
+// * or an anonymous type instantiation ("new X(){}") if it is an anonymous typeMETHOD_DECLARATION
- the dot-based type name
+// * of the type that declares the method that is being
+// * implemented or overriddennull
. Clients must not modify the array
+// * returned.
+// *
+// *
+// * @return the dot-based package name, or
+// * null
if none
+// * @see #getDeclarationSignature()
+// * @see #getSignature()
+// *
+// * @since 3.1
+// */
+// public char[] getDeclarationTypeName() {
+// return this.declarationTypeName;
+// }
+//
+// /**
+// * Returns the package name of the method or type
+// * relevant in the context, or null
if none.
+// * +// * This field is available for the following kinds of +// * completion proposals: +// *
FIELD_REF
- the dot-based package name
+// * of the referenced field's typeLOCAL_VARIABLE_REF
- the dot-based package name
+// * of the referenced local variable's typeMETHOD_REF
- the dot-based package name
+// * of the return type of the method that is referencedMETHOD_DECLARATION
- the dot-based package name
+// * of the return type of the method that is being implemented
+// * or overriddenPACKAGE_REF
- the dot-based package name
+// * of the package that is referencedTYPE_REF
- the dot-based package name
+// * of the type that is referencedVARIABLE_DECLARATION
- the dot-based package name
+// * of the type of the variable being declarednull
. Clients must not modify the array
+// * returned.
+// *
+// *
+// * @return the package name, or null
if none
+// *
+// * @see #getDeclarationSignature()
+// * @see #getSignature()
+// *
+// * @since 3.1
+// */
+// public char[] getPackageName() {
+// return this.packageName;
+// }
+//
+// /**
+// * Returns the type name without the package fragment of the method or type
+// * relevant in the context, or null
if none.
+// * +// * This field is available for the following kinds of +// * completion proposals: +// *
FIELD_REF
- the dot-based type name
+// * of the referenced field's typeLOCAL_VARIABLE_REF
- the dot-based type name
+// * of the referenced local variable's typeMETHOD_REF
- the dot-based type name
+// * of the return type of the method that is referencedMETHOD_DECLARATION
- the dot-based type name
+// * of the return type of the method that is being implemented
+// * or overriddenTYPE_REF
- the dot-based type name
+// * of the type that is referencedVARIABLE_DECLARATION
- the dot-based package name
+// * of the type of the variable being declarednull
. Clients must not modify the array
+// * returned.
+// *
+// *
+// * @return the package name, or null
if none
+// *
+// * @see #getDeclarationSignature()
+// * @see #getSignature()
+// *
+// * @since 3.1
+// */
+// public char[] getTypeName() {
+// return this.typeName;
+// }
+//
+// /**
+// * Returns the parameter package names of the method
+// * relevant in the context, or null
if none.
+// * +// * This field is available for the following kinds of +// * completion proposals: +// *
ANONYMOUS_CLASS_DECLARATION
- parameter package names
+// * of the constructor that is being invokedMETHOD_REF
- parameter package names
+// * of the method that is referencedMETHOD_DECLARATION
- parameter package names
+// * of the method that is being implemented or overriddennull
. Clients must not modify the array
+// * returned.
+// *
+// *
+// * @return the package name, or null
if none
+// *
+// * @see #getDeclarationSignature()
+// * @see #getSignature()
+// *
+// * @since 3.1
+// */
+// public char[][] getParameterPackageNames() {
+// return this.parameterPackageNames;
+// }
+//
+// /**
+// * Returns the parameter type names without the package fragment of
+// * the method relevant in the context, or null
if none.
+// * +// * This field is available for the following kinds of +// * completion proposals: +// *
ANONYMOUS_CLASS_DECLARATION
- parameter type names
+// * of the constructor that is being invokedMETHOD_REF
- parameter type names
+// * of the method that is referencedMETHOD_DECLARATION
- parameter type names
+// * of the method that is being implemented or overriddennull
. Clients must not modify the array
+// * returned.
+// *
+// *
+// * @return the package name, or null
if none
+// *
+// * @see #getDeclarationSignature()
+// * @see #getSignature()
+// *
+// * @since 3.1
+// */
+// public char[][] getParameterTypeNames() {
+// return this.parameterTypeNames;
+// }
+
+ /**
+ * Sets the signature of the method, field type, member type,
+ * relevant in the context, or null
if none.
+ * + * If not set, defaults to none. + *
+ *+ * The completion engine creates instances of this class and sets + * its properties; this method is not intended to be used by other clients. + *
+ * + * @param signature the signature, ornull
if none
+ */
+ public void setSignature(char[] signature) {
+ this.signature = signature;
+ }
+
+ /**
+ * Sets the key of the method, field type, member type,
+ * relevant in the context, or null
if none.
+ * + * If not set, defaults to none. + *
+ *+ * The completion engine creates instances of this class and sets + * its properties; this method is not intended to be used by other clients. + *
+ * + * @param key the key, ornull
if none
+ * @since 3.1
+ */
+ public void setKey(char[] key) {
+ this.key = key;
+ }
+
+ /**
+ * Returns the modifier flags relevant in the context, or
+ * Flags.AccDefault
if none.
+ * + * This field is available for the following kinds of + * completion proposals: + *
ANNOTATION_ATTRIBUT_REF
- modifier flags
+ * of the attribute that is referenced;
+ * ANONYMOUS_CLASS_DECLARATION
- modifier flags
+ * of the constructor that is referencedFIELD_IMPORT
- modifier flags
+ * of the field that is imported.FIELD_REF
- modifier flags
+ * of the field that is referenced;
+ * Flags.AccEnum
can be used to recognize
+ * references to enum constants
+ * FIELD_REF_WITH_CASTED_RECEIVER
- modifier flags
+ * of the field that is referenced.
+ * KEYWORD
- modifier flag
+ * corresponding to the modifier keywordLOCAL_VARIABLE_REF
- modifier flags
+ * of the local variable that is referencedMETHOD_IMPORT
- modifier flags
+ * of the method that is imported;
+ * METHOD_REF
- modifier flags
+ * of the method that is referenced;
+ * Flags.AccAnnotation
can be used to recognize
+ * references to annotation type members
+ * METHOD_REF_WITH_CASTED_RECEIVER
- modifier flags
+ * of the method that is referenced.
+ * METHOD_DECLARATION
- modifier flags
+ * for the method that is being implemented or overriddenTYPE_IMPORT
- modifier flags
+ * of the type that is imported; Flags.AccInterface
+ * can be used to recognize references to interfaces,
+ * Flags.AccEnum
enum types,
+ * and Flags.AccAnnotation
annotation typesTYPE_REF
- modifier flags
+ * of the type that is referenced; Flags.AccInterface
+ * can be used to recognize references to interfaces,
+ * Flags.AccEnum
enum types,
+ * and Flags.AccAnnotation
annotation types
+ * VARIABLE_DECLARATION
- modifier flags
+ * for the variable being declaredPOTENTIAL_METHOD_DECLARATION
- modifier flags
+ * for the method that is being createdFlags.AccDefault
.
+ *
+ *
+ * @return the modifier flags, or
+ * Flags.AccDefault
if none
+ * @see Flags
+ */
+ public int getFlags() {
+ return this.flags;
+ }
+
+ /**
+ * Sets the modifier flags relevant in the context.
+ * + * If not set, defaults to none. + *
+ *+ * The completion engine creates instances of this class and sets + * its properties; this method is not intended to be used by other clients. + *
+ * + * @param flags the modifier flags, or + *Flags.AccDefault
if none
+ */
+ public void setFlags(int flags) {
+ this.flags = flags;
+ }
+
+ /**
+ * Returns the required completion proposals.
+ * The proposal can be apply only if these required completion proposals are also applied.
+ * If the required proposal aren't applied the completion could create completion problems.
+ *
+ * + * This field is available for the following kinds of + * completion proposals: + *
FIELD_REF
- The allowed required proposals for this kind are:
+ * TYPE_REF
TYPE_IMPORT
FIELD_IMPORT
METHOD_REF
- The allowed required proposals for this kind are:
+ * TYPE_REF
TYPE_IMPORT
METHOD_IMPORT
TYPE_REF
- The allowed required proposals for this kind are:
+ * TYPE_REF
+ * Other kinds of required proposals will be returned in the future, therefore clients of this + * API must allow with {@link CompletionRequestor#setAllowsRequiredProposals(int, int, boolean)} + * only kinds which are in this list to avoid unexpected results in the future. + *
+ *
+ * A required proposal of a given kind is proposed even if {@link CompletionRequestor#isIgnored(int)}
+ * return true
for that kind.
+ *
+ * A required completion proposal cannot have required completion proposals. + *
+ * + * @return the required completion proposals, ornull
if none.
+ *
+ * @see CompletionRequestor#setAllowsRequiredProposals(int, int,boolean)
+ *
+ * @since 3.3
+ */
+ public CompletionProposal[] getRequiredProposals() {
+ return this.requiredProposals;
+ }
+
+
+ /**
+ * Sets the list of required completion proposals, or null
if none.
+ * + * If not set, defaults to none. + *
+ *+ * The completion engine creates instances of this class and sets + * its properties; this method is not intended to be used by other clients. + *
+ * + * @param proposals the list of required completion proposals, or + *null
if none
+ * @since 3.3
+ */
+ public void setRequiredProposals(CompletionProposal[] proposals) {
+ this.requiredProposals = proposals;
+ }
+
+ /**
+ * Finds the method parameter names.
+ * This information is relevant to method reference (and
+ * method declaration proposals). Returns null
+ * if not available or not relevant.
+ * + * The client must not modify the array returned. + *
+ *+ * Note that this is an expensive thing to compute, which may require + * parsing Java source files, etc. Use sparingly. + *
+ * + * @param monitor the progress monitor, ornull
if none
+ * @return the parameter names, or null
if none
+ * or not available or not relevant
+ */
+ public char[][] findParameterNames(IProgressMonitor monitor) {
+ if (!this.parameterNamesComputed) {
+ this.parameterNamesComputed = true;
+
+ switch(this.completionKind) {
+ case ANONYMOUS_CLASS_DECLARATION:
+ try {
+ this.parameterNames = findMethodParameterNames(
+ this.declarationPackageName,
+ this.declarationTypeName,
+ CharOperation.lastSegment(this.declarationTypeName, '.'),
+ Signature.getParameterTypes(this.originalSignature == null ? this.signature : this.originalSignature));
+ } catch(IllegalArgumentException e) {
+ // protection for invalid signature
+ if(this.parameterTypeNames != null) {
+ this.parameterNames = createDefaultParameterNames(this.parameterTypeNames.length);
+ } else {
+ this.parameterNames = null;
+ }
+ }
+ break;
+ case METHOD_REF:
+ case METHOD_REF_WITH_CASTED_RECEIVER:
+ try {
+ this.parameterNames = findMethodParameterNames(
+ this.declarationPackageName,
+ this.declarationTypeName,
+ this.name,
+ Signature.getParameterTypes(this.originalSignature == null ? this.signature : this.originalSignature));
+ } catch(IllegalArgumentException e) {
+ // protection for invalid signature
+ if(this.parameterTypeNames != null) {
+ this.parameterNames = createDefaultParameterNames(this.parameterTypeNames.length);
+ } else {
+ this.parameterNames = null;
+ }
+ }
+ break;
+ case METHOD_DECLARATION:
+ try {
+ this.parameterNames = findMethodParameterNames(
+ this.declarationPackageName,
+ this.declarationTypeName,
+ this.name,
+ Signature.getParameterTypes(this.originalSignature == null ? this.signature : this.originalSignature));
+ } catch(IllegalArgumentException e) {
+ // protection for invalid signature
+ if(this.parameterTypeNames != null) {
+ this.parameterNames = createDefaultParameterNames(this.parameterTypeNames.length);
+ } else {
+ this.parameterNames = null;
+ }
+ }
+ if(this.parameterNames != null) {
+ this.updateCompletion = true;
+ }
+ break;
+ }
+ }
+ return this.parameterNames;
+ }
+
+ /**
+ * Sets the method parameter names.
+ * This information is relevant to method reference (and
+ * method declaration proposals).
+ * + * The completion engine creates instances of this class and sets + * its properties; this method is not intended to be used by other clients. + *
+ * + * @param parameterNames the parameter names, ornull
if none
+ */
+ public void setParameterNames(char[][] parameterNames) {
+ this.parameterNames = parameterNames;
+ this.parameterNamesComputed = true;
+ }
+
+ /**
+ * Returns the accessibility of the proposal.
+ * + * This field is available for the following kinds of + * completion proposals: + *
TYPE_REF
- accessibility of the type+ * This field is available for the following kinds of + * completion proposals: + *
METHOD_REF
- return true
+ * if the referenced method is a constructorMETHOD_DECLARATION
- return true
+ * if the declared method is a constructorfalse
.
+ *
+ *
+ * @return true
if the proposal is a constructor.
+ * @since 3.1
+ */
+ public boolean isConstructor() {
+ return this.isConstructor;
+ }
+
+ private int receiverStart;
+ private int receiverEnd;
+ private char[] receiverSignature;
+
+ /**
+ * Returns the type signature or package name of the relevant
+ * receiver in the context, or null
if none.
+ * + * This field is available for the following kinds of + * completion proposals: + *
FIELD_REF_WITH_CASTED_RECEIVER
- type signature
+ * of the type that cast the receiver of the field that is referencedMETHOD_REF_WITH_CASTED_RECEIVER
- type signature
+ * of the type that cast the receiver of the method that is referencednull
. Clients must not modify the array
+ * returned.
+ *
+ *
+ * @return a type signature or a package name (depending
+ * on the kind of completion), or null
if none
+ * @see Signature
+ *
+ * @since 3.4
+ */
+ public char[] getReceiverSignature() {
+ return this.receiverSignature;
+ }
+
+ /**
+ * Returns the character index of the start of the
+ * subrange in the source file buffer containing the
+ * relevant receiver of the member being completed. This
+ * receiver is an expression.
+ *
+ * + * This field is available for the following kinds of + * completion proposals: + *
FIELD_REF_WITH_CASTED_RECEIVER
METHOD_REF_WITH_CASTED_RECEIVER
0
.
+ *
+ *
+ * @return character index of receiver start position (inclusive)
+ *
+ * @since 3.4
+ */
+ public int getReceiverStart() {
+ return this.receiverStart;
+ }
+
+ /**
+ * Returns the character index of the end (exclusive) of the subrange
+ * in the source file buffer containing the
+ * relevant receiver of the member being completed.
+ *
+ * * + * This field is available for the following kinds of + * completion proposals: + *
FIELD_REF_WITH_CASTED_RECEIVER
METHOD_REF_WITH_CASTED_RECEIVER
0
.
+ *
+ *
+ * @return character index of receiver end position (exclusive)
+ *
+ * @since 3.4
+ */
+ public int getReceiverEnd() {
+ return this.receiverEnd;
+ }
+
+ /**
+ * Sets the type or package signature of the relevant
+ * receiver in the context, or null
if none.
+ * + * If not set, defaults to none. + *
+ *+ * The completion engine creates instances of this class and sets + * its properties; this method is not intended to be used by other clients. + *
+ * + * @param signature the type or package signature, or + *null
if none
+ *
+ * @since 3.4
+ */
+ public void setReceiverSignature(char[] signature) {
+ this.receiverSignature = signature;
+ }
+
+ /**
+ * Sets the character indices of the subrange in the
+ * source file buffer containing the relevant receiver
+ * of the member being completed.
+ *
+ * + * If not set, defaults to empty subrange at [0,0). + *
+ * + * @param startIndex character index of receiver start position (inclusive) + * @param endIndex character index of receiver end position (exclusive) + * + * @since 3.4 + */ + public void setReceiverRange(int startIndex, int endIndex) { + this.receiverStart = startIndex; + this.receiverEnd = endIndex; + } + + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append('['); + switch(this.completionKind) { + case CompletionProposal.ANONYMOUS_CLASS_DECLARATION : + buffer.append("ANONYMOUS_CLASS_DECLARATION"); //$NON-NLS-1$ + break; + case CompletionProposal.FIELD_REF : + buffer.append("FIELD_REF"); //$NON-NLS-1$ + break; + case CompletionProposal.KEYWORD : + buffer.append("KEYWORD"); //$NON-NLS-1$ + break; + case CompletionProposal.LABEL_REF : + buffer.append("LABEL_REF"); //$NON-NLS-1$ + break; + case CompletionProposal.LOCAL_VARIABLE_REF : + buffer.append("LOCAL_VARIABLE_REF"); //$NON-NLS-1$ + break; + case CompletionProposal.METHOD_DECLARATION : + buffer.append("METHOD_DECLARATION"); //$NON-NLS-1$ + if(this.isConstructor) { + buffer.append("null
if none.
- * Defaults to null.
- */
- private char[] declarationSignature = null;
-
- /**
- * Unique key of the relevant package or type declaration
- * in the context, or null
if none.
- * Defaults to null.
- */
- private char[] declarationKey = null;
-
- /**
- * Simple name of the method, field,
- * member, or variable relevant in the context, or
- * null
if none.
- * Defaults to null.
- */
- private char[] name = null;
-
- /**
- * Signature of the method, field type, member type,
- * relevant in the context, or null
if none.
- * Defaults to null.
- */
- private char[] signature = null;
-
- /**
- * Unique of the method, field type, member type,
- * relevant in the context, or null
if none.
- * Defaults to null.
- */
- private char[] key = null;
-
- /**
- * Array of required completion proposals, or null
if none.
- * The proposal can not be applied if the required proposals aren't applied.
- * Defaults to null
.
- */
- private CompletionProposal[] requiredProposals;
-
- /**
- * Modifier flags relevant in the context, or
- * Flags.AccDefault
if none.
- * Defaults to Flags.AccDefault
.
- */
- private int flags = Flags.AccDefault;
-
- /**
- * Completion flags relevant in the context, or
- * CompletionFlags.Default
if none.
- * Defaults to CompletionFlags.Default
.
- */
- private int additionalFlags = CompletionFlags.Default;
-
- /**
- * Parameter names (for method completions), or
- * null
if none. Lazily computed.
- * Defaults to null
.
- */
- private char[][] parameterNames = null;
-
- /**
- * Indicates whether parameter names have been computed.
- */
- private boolean parameterNamesComputed = false;
-
- /**
* Creates a basic completion proposal. All instance
* field have plausible default values unless otherwise noted.
* @@ -941,37 +821,7 @@ * @return a new completion proposal */ public static CompletionProposal create(int kind, int completionOffset) { - return new CompletionProposal(kind, completionOffset); - } - - /** - * Creates a basic completion proposal. All instance - * field have plausible default values unless otherwise noted. - *
- * Note that the constructors for this class are internal to the - * Java model implementation. Clients cannot directly create - * CompletionProposal objects. - *
- * - * @param kind one of the kind constants declared on this class - * @param completionLocation original offset of code completion request - */ - CompletionProposal(int kind, int completionLocation) { - if ((kind < CompletionProposal.FIRST_KIND) - || (kind > CompletionProposal.LAST_KIND)) { - throw new IllegalArgumentException(); - } - if (this.completion == null || completionLocation < 0) { - // Work around for bug 132558 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=132558). - // completionLocation can be -1 if the completion occur at the start of a file or - // the start of a code snippet but this API isn't design to support negative position. - if(this.completion == null || completionLocation != -1) { - throw new IllegalArgumentException(); - } - completionLocation = 0; - } - this.completionKind = kind; - this.completionLocation = completionLocation; + return new InternalCompletionProposal(kind, completionOffset); } /** @@ -1002,7 +852,7 @@ * @since 3.3 */ public int getAdditionalFlags() { - return this.additionalFlags; + return -1; // default overridden by concrete implementation } /** @@ -1021,7 +871,7 @@ * @since 3.3 */ public void setAdditionalFlags(int additionalFlags) { - this.additionalFlags = additionalFlags; + // default overridden by concrete implementation } /** @@ -1039,7 +889,7 @@ * to the caller */ public int getKind() { - return this.completionKind; + return -1; // default overridden by concrete implementation } /** @@ -1053,7 +903,7 @@ */ // TODO (david) https://bugs.eclipse.org/bugs/show_bug.cgi?id=132558 public int getCompletionLocation() { - return this.completionLocation; + return -1; // default overridden by concrete implementation } /** @@ -1070,7 +920,7 @@ * @return character index of token start position (inclusive) */ public int getTokenStart() { - return this.tokenStart; + return -1; // default overridden by concrete implementation } /** @@ -1083,7 +933,7 @@ * @return character index of token end position (exclusive) */ public int getTokenEnd() { - return this.tokenEnd; + return -1; // default overridden by concrete implementation } /** @@ -1103,11 +953,7 @@ * @param endIndex character index of token end position (exclusive) */ public void setTokenRange(int startIndex, int endIndex) { - if (startIndex < 0 || endIndex < startIndex) { - throw new IllegalArgumentException(); - } - this.tokenStart = startIndex; - this.tokenEnd = endIndex; + // default overridden by concrete implementation } /** @@ -1122,37 +968,7 @@ * @return the completion string */ public char[] getCompletion() { - if(this.completionKind == METHOD_DECLARATION) { - findParameterNames(null); - if(this.updateCompletion) { - this.updateCompletion = false; - - if(this.parameterNames != null) { - int length = this.parameterNames.length; - StringBuffer completionBuffer = new StringBuffer(this.completion.length); - - int start = 0; - int end = CharOperation.indexOf('%', this.completion); - - completionBuffer.append(this.completion, start, end - start); - - for(int i = 0 ; i < length ; i++){ - completionBuffer.append(this.parameterNames[i]); - start = end + 1; - end = CharOperation.indexOf('%', this.completion, start); - if(end > -1){ - completionBuffer.append(this.completion, start, end - start); - } else { - completionBuffer.append(this.completion, start, this.completion.length - start); - } - } - int nameLength = completionBuffer.length(); - this.completion = new char[nameLength]; - completionBuffer.getChars(0, nameLength, this.completion, 0); - } - } - } - return this.completion; + return null; // default overridden by concrete implementation } /** @@ -1171,7 +987,7 @@ * @param completion the completion string */ public void setCompletion(char[] completion) { - this.completion = completion; + // default overridden by concrete implementation } /** @@ -1196,7 +1012,7 @@ * @return replacement start position (inclusive) */ public int getReplaceStart() { - return this.replaceStart; + return -1; // default overridden by concrete implementation } /** @@ -1210,7 +1026,7 @@ * @return replacement end position (exclusive) */ public int getReplaceEnd() { - return this.replaceEnd; + return -1; // default overridden by concrete implementation } /** @@ -1232,11 +1048,7 @@ * @param endIndex character index of replacement end position (exclusive) */ public void setReplaceRange(int startIndex, int endIndex) { - if (startIndex < 0 || endIndex < startIndex) { - throw new IllegalArgumentException(); - } - this.replaceStart = startIndex; - this.replaceEnd = endIndex; + // default overridden by concrete implementation } /** @@ -1245,7 +1057,7 @@ * @return relevance rating of this proposal; ratings are positive; higher means better */ public int getRelevance() { - return this.relevance; + return -1; // default overridden by concrete implementation } /** @@ -1261,10 +1073,7 @@ * @param rating relevance rating of this proposal; ratings are positive; higher means better */ public void setRelevance(int rating) { - if (rating <= 0) { - throw new IllegalArgumentException(); - } - this.relevance = rating; + // default overridden by concrete implementation } /** @@ -1312,7 +1121,8 @@ * @see Signature */ public char[] getDeclarationSignature() { - return this.declarationSignature; + return null; // default overridden by concrete implementation + } /** @@ -1338,7 +1148,7 @@ * @since 3.1 */ public char[] getDeclarationKey() { - return this.declarationKey; + return null; // default overridden by concrete implementation } /** @@ -1356,7 +1166,7 @@ *null
if none
*/
public void setDeclarationSignature(char[] signature) {
- this.declarationSignature = signature;
+ // default overridden by concrete implementation
}
/**
@@ -1375,7 +1185,7 @@
* @since 3.1
*/
public void setDeclarationKey(char[] key) {
- this.declarationKey = key;
+ // default overridden by concrete implementation
}
/**
@@ -1409,7 +1219,7 @@
* name, or null
if none
*/
public char[] getName() {
- return this.name;
+ return null; // default overridden by concrete implementation
}
@@ -1429,7 +1239,7 @@
* or member name, or null
if none
*/
public void setName(char[] name) {
- this.name = name;
+ // default overridden by concrete implementation
}
/**
@@ -1477,7 +1287,7 @@
* @see Signature
*/
public char[] getSignature() {
- return this.signature;
+ return null; // default overridden by concrete implementation
}
/**
@@ -1503,214 +1313,9 @@
* @since 3.1
*/
public char[] getKey() {
- return this.key;
+ return null; // default overridden by concrete implementation
}
-// /**
-// * Returns the package name of the relevant
-// * declaration in the context, or null
if none.
-// * -// * This field is available for the following kinds of -// * completion proposals: -// *
ANONYMOUS_CLASS_DECLARATION
- the dot-based package name
-// * of the type that is being subclassed or implementedFIELD_REF
- the dot-based package name
-// * of the type that declares the field that is referencedMETHOD_REF
- the dot-based package name
-// * of the type that declares the method that is referencedMETHOD_DECLARATION
- the dot-based package name
-// * of the type that declares the method that is being
-// * implemented or overriddennull
. Clients must not modify the array
-// * returned.
-// *
-// *
-// * @return the dot-based package name, or
-// * null
if none
-// * @see #getDeclarationSignature()
-// * @see #getSignature()
-// *
-// * @since 3.1
-// */
-// public char[] getDeclarationPackageName() {
-// return this.declarationPackageName;
-// }
-//
-// /**
-// * Returns the type name of the relevant
-// * declaration in the context without the package fragment,
-// * or null
if none.
-// * -// * This field is available for the following kinds of -// * completion proposals: -// *
ANONYMOUS_CLASS_DECLARATION
- the dot-based type name
-// * of the type that is being subclassed or implementedFIELD_REF
- the dot-based type name
-// * of the type that declares the field that is referenced
-// * or an anonymous type instantiation ("new X(){}") if it is an anonymous typeMETHOD_REF
- the dot-based type name
-// * of the type that declares the method that is referenced
-// * or an anonymous type instantiation ("new X(){}") if it is an anonymous typeMETHOD_DECLARATION
- the dot-based type name
-// * of the type that declares the method that is being
-// * implemented or overriddennull
. Clients must not modify the array
-// * returned.
-// *
-// *
-// * @return the dot-based package name, or
-// * null
if none
-// * @see #getDeclarationSignature()
-// * @see #getSignature()
-// *
-// * @since 3.1
-// */
-// public char[] getDeclarationTypeName() {
-// return this.declarationTypeName;
-// }
-//
-// /**
-// * Returns the package name of the method or type
-// * relevant in the context, or null
if none.
-// * -// * This field is available for the following kinds of -// * completion proposals: -// *
FIELD_REF
- the dot-based package name
-// * of the referenced field's typeLOCAL_VARIABLE_REF
- the dot-based package name
-// * of the referenced local variable's typeMETHOD_REF
- the dot-based package name
-// * of the return type of the method that is referencedMETHOD_DECLARATION
- the dot-based package name
-// * of the return type of the method that is being implemented
-// * or overriddenPACKAGE_REF
- the dot-based package name
-// * of the package that is referencedTYPE_REF
- the dot-based package name
-// * of the type that is referencedVARIABLE_DECLARATION
- the dot-based package name
-// * of the type of the variable being declarednull
. Clients must not modify the array
-// * returned.
-// *
-// *
-// * @return the package name, or null
if none
-// *
-// * @see #getDeclarationSignature()
-// * @see #getSignature()
-// *
-// * @since 3.1
-// */
-// public char[] getPackageName() {
-// return this.packageName;
-// }
-//
-// /**
-// * Returns the type name without the package fragment of the method or type
-// * relevant in the context, or null
if none.
-// * -// * This field is available for the following kinds of -// * completion proposals: -// *
FIELD_REF
- the dot-based type name
-// * of the referenced field's typeLOCAL_VARIABLE_REF
- the dot-based type name
-// * of the referenced local variable's typeMETHOD_REF
- the dot-based type name
-// * of the return type of the method that is referencedMETHOD_DECLARATION
- the dot-based type name
-// * of the return type of the method that is being implemented
-// * or overriddenTYPE_REF
- the dot-based type name
-// * of the type that is referencedVARIABLE_DECLARATION
- the dot-based package name
-// * of the type of the variable being declarednull
. Clients must not modify the array
-// * returned.
-// *
-// *
-// * @return the package name, or null
if none
-// *
-// * @see #getDeclarationSignature()
-// * @see #getSignature()
-// *
-// * @since 3.1
-// */
-// public char[] getTypeName() {
-// return this.typeName;
-// }
-//
-// /**
-// * Returns the parameter package names of the method
-// * relevant in the context, or null
if none.
-// * -// * This field is available for the following kinds of -// * completion proposals: -// *
ANONYMOUS_CLASS_DECLARATION
- parameter package names
-// * of the constructor that is being invokedMETHOD_REF
- parameter package names
-// * of the method that is referencedMETHOD_DECLARATION
- parameter package names
-// * of the method that is being implemented or overriddennull
. Clients must not modify the array
-// * returned.
-// *
-// *
-// * @return the package name, or null
if none
-// *
-// * @see #getDeclarationSignature()
-// * @see #getSignature()
-// *
-// * @since 3.1
-// */
-// public char[][] getParameterPackageNames() {
-// return this.parameterPackageNames;
-// }
-//
-// /**
-// * Returns the parameter type names without the package fragment of
-// * the method relevant in the context, or null
if none.
-// * -// * This field is available for the following kinds of -// * completion proposals: -// *
ANONYMOUS_CLASS_DECLARATION
- parameter type names
-// * of the constructor that is being invokedMETHOD_REF
- parameter type names
-// * of the method that is referencedMETHOD_DECLARATION
- parameter type names
-// * of the method that is being implemented or overriddennull
. Clients must not modify the array
-// * returned.
-// *
-// *
-// * @return the package name, or null
if none
-// *
-// * @see #getDeclarationSignature()
-// * @see #getSignature()
-// *
-// * @since 3.1
-// */
-// public char[][] getParameterTypeNames() {
-// return this.parameterTypeNames;
-// }
-
/**
* Sets the signature of the method, field type, member type,
* relevant in the context, or null
if none.
@@ -1725,7 +1330,7 @@
* @param signature the signature, or null
if none
*/
public void setSignature(char[] signature) {
- this.signature = signature;
+ // default overridden by concrete implementation
}
/**
@@ -1743,7 +1348,7 @@
* @since 3.1
*/
public void setKey(char[] key) {
- this.key = key;
+ // default overridden by concrete implementation
}
/**
@@ -1809,7 +1414,7 @@
* @see Flags
*/
public int getFlags() {
- return this.flags;
+ return -1; // default overridden by concrete implementation
}
/**
@@ -1826,7 +1431,7 @@
* Flags.AccDefault
if none
*/
public void setFlags(int flags) {
- this.flags = flags;
+ // default overridden by concrete implementation
}
/**
@@ -1880,7 +1485,7 @@
* @since 3.3
*/
public CompletionProposal[] getRequiredProposals() {
- return this.requiredProposals;
+ return null; // default overridden by concrete implementation
}
@@ -1899,7 +1504,7 @@
* @since 3.3
*/
public void setRequiredProposals(CompletionProposal[] proposals) {
- this.requiredProposals = proposals;
+ // default overridden by concrete implementation
}
/**
@@ -1920,65 +1525,7 @@
* or not available or not relevant
*/
public char[][] findParameterNames(IProgressMonitor monitor) {
- if (!this.parameterNamesComputed) {
- this.parameterNamesComputed = true;
-
- switch(this.completionKind) {
- case ANONYMOUS_CLASS_DECLARATION:
- try {
- this.parameterNames = findMethodParameterNames(
- this.declarationPackageName,
- this.declarationTypeName,
- CharOperation.lastSegment(this.declarationTypeName, '.'),
- Signature.getParameterTypes(this.originalSignature == null ? this.signature : this.originalSignature));
- } catch(IllegalArgumentException e) {
- // protection for invalid signature
- if(this.parameterTypeNames != null) {
- this.parameterNames = createDefaultParameterNames(this.parameterTypeNames.length);
- } else {
- this.parameterNames = null;
- }
- }
- break;
- case METHOD_REF:
- case METHOD_REF_WITH_CASTED_RECEIVER:
- try {
- this.parameterNames = findMethodParameterNames(
- this.declarationPackageName,
- this.declarationTypeName,
- this.name,
- Signature.getParameterTypes(this.originalSignature == null ? this.signature : this.originalSignature));
- } catch(IllegalArgumentException e) {
- // protection for invalid signature
- if(this.parameterTypeNames != null) {
- this.parameterNames = createDefaultParameterNames(this.parameterTypeNames.length);
- } else {
- this.parameterNames = null;
- }
- }
- break;
- case METHOD_DECLARATION:
- try {
- this.parameterNames = findMethodParameterNames(
- this.declarationPackageName,
- this.declarationTypeName,
- this.name,
- Signature.getParameterTypes(this.originalSignature == null ? this.signature : this.originalSignature));
- } catch(IllegalArgumentException e) {
- // protection for invalid signature
- if(this.parameterTypeNames != null) {
- this.parameterNames = createDefaultParameterNames(this.parameterTypeNames.length);
- } else {
- this.parameterNames = null;
- }
- }
- if(this.parameterNames != null) {
- this.updateCompletion = true;
- }
- break;
- }
- }
- return this.parameterNames;
+ return null; // default overridden by concrete implementation
}
/**
@@ -1993,8 +1540,7 @@
* @param parameterNames the parameter names, or null
if none
*/
public void setParameterNames(char[][] parameterNames) {
- this.parameterNames = parameterNames;
- this.parameterNamesComputed = true;
+ // default overridden by concrete implementation
}
/**
@@ -2018,7 +1564,7 @@
* @since 3.1
*/
public int getAccessibility() {
- return this.accessibility;
+ return -1; // default overridden by concrete implementation
}
/**
@@ -2040,13 +1586,9 @@
* @since 3.1
*/
public boolean isConstructor() {
- return this.isConstructor;
+ return false; // default overridden by concrete implementation
}
- private int receiverStart;
- private int receiverEnd;
- private char[] receiverSignature;
-
/**
* Returns the type signature or package name of the relevant
* receiver in the context, or null
if none.
@@ -2071,7 +1613,7 @@
* @since 3.4
*/
public char[] getReceiverSignature() {
- return this.receiverSignature;
+ return null; // default overridden by concrete implementation
}
/**
@@ -2095,7 +1637,7 @@
* @since 3.4
*/
public int getReceiverStart() {
- return this.receiverStart;
+ return -1; // default overridden by concrete implementation
}
/**
@@ -2118,7 +1660,7 @@
* @since 3.4
*/
public int getReceiverEnd() {
- return this.receiverEnd;
+ return -1; // default overridden by concrete implementation
}
/**
@@ -2138,7 +1680,7 @@
* @since 3.4
*/
public void setReceiverSignature(char[] signature) {
- this.receiverSignature = signature;
+ // default overridden by concrete implementation
}
/**
@@ -2156,123 +1698,6 @@
* @since 3.4
*/
public void setReceiverRange(int startIndex, int endIndex) {
- this.receiverStart = startIndex;
- this.receiverEnd = endIndex;
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append('[');
- switch(this.completionKind) {
- case CompletionProposal.ANONYMOUS_CLASS_DECLARATION :
- buffer.append("ANONYMOUS_CLASS_DECLARATION"); //$NON-NLS-1$
- break;
- case CompletionProposal.FIELD_REF :
- buffer.append("FIELD_REF"); //$NON-NLS-1$
- break;
- case CompletionProposal.KEYWORD :
- buffer.append("KEYWORD"); //$NON-NLS-1$
- break;
- case CompletionProposal.LABEL_REF :
- buffer.append("LABEL_REF"); //$NON-NLS-1$
- break;
- case CompletionProposal.LOCAL_VARIABLE_REF :
- buffer.append("LOCAL_VARIABLE_REF"); //$NON-NLS-1$
- break;
- case CompletionProposal.METHOD_DECLARATION :
- buffer.append("METHOD_DECLARATION"); //$NON-NLS-1$
- if(this.isConstructor) {
- buffer.append("