### 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: + *

+ * For other kinds of completion proposals, this method returns + * 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, or null if none. + *

+ * This field is available for the following kinds of + * completion proposals: + *

+ * For kinds of completion proposals, this method returns + * null. 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: + *

+ * For kinds of completion proposals, this method returns + * null. 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: + *

+ * For kinds of completion proposals, this method returns + * null. 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, or null 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: + *

+ * For kinds of completion proposals, this method returns + * null. 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: + *

+ * For kinds of completion proposals, this method returns + * null. 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: +// *

+// * For kinds of completion proposals, this method returns +// * null. 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: +// *

+// * For kinds of completion proposals, this method returns +// * null. 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: +// *

+// * For kinds of completion proposals, this method returns +// * null. 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: +// *

+// * For kinds of completion proposals, this method returns +// * null. 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: +// *

+// * For kinds of completion proposals, this method returns +// * null. 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: +// *

+// * For kinds of completion proposals, this method returns +// * null. 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, or null 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, or null 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: + *

+ * For other kinds of completion proposals, this method returns + * Flags.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: + *

+ *

+ *

+ * 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, or null 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, or null 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, or null 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: + *

+ * For these kinds of completion proposals, this method returns + * {@link IAccessRule#K_ACCESSIBLE} or {@link IAccessRule#K_DISCOURAGED} + * or {@link IAccessRule#K_NON_ACCESSIBLE}. + * By default this method return {@link IAccessRule#K_ACCESSIBLE}. + *

+ * + * @see IAccessRule + * + * @return the accessibility of the proposal + * + * @since 3.1 + */ + public int getAccessibility() { + return this.accessibility; + } + + /** + * Returns whether this proposal is a constructor. + *

+ * This field is available for the following kinds of + * completion proposals: + *

+ * For kinds of completion proposals, this method returns + * false. + *

+ * + * @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: + *

+ * For kinds of completion proposals, this method returns + * null. 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: + *

+ * For kinds of completion proposals, this method returns 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: + *

+ * For kinds of completion proposals, this method returns 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(""); //$NON-NLS-1$ + } + break; + case CompletionProposal.METHOD_REF : + buffer.append("METHOD_REF"); //$NON-NLS-1$ + if(this.isConstructor) { + buffer.append(""); //$NON-NLS-1$ + } + break; + case CompletionProposal.PACKAGE_REF : + buffer.append("PACKAGE_REF"); //$NON-NLS-1$ + break; + case CompletionProposal.TYPE_REF : + buffer.append("TYPE_REF"); //$NON-NLS-1$ + break; + case CompletionProposal.VARIABLE_DECLARATION : + buffer.append("VARIABLE_DECLARATION"); //$NON-NLS-1$ + break; + case CompletionProposal.POTENTIAL_METHOD_DECLARATION : + buffer.append("POTENTIAL_METHOD_DECLARATION"); //$NON-NLS-1$ + break; + case CompletionProposal.METHOD_NAME_REFERENCE : + buffer.append("METHOD_IMPORT"); //$NON-NLS-1$ + break; + case CompletionProposal.ANNOTATION_ATTRIBUTE_REF : + buffer.append("ANNOTATION_ATTRIBUTE_REF"); //$NON-NLS-1$ + break; + case CompletionProposal.JAVADOC_BLOCK_TAG : + buffer.append("JAVADOC_BLOCK_TAG"); //$NON-NLS-1$ + break; + case CompletionProposal.JAVADOC_INLINE_TAG : + buffer.append("JAVADOC_INLINE_TAG"); //$NON-NLS-1$ + break; + case CompletionProposal.JAVADOC_FIELD_REF: + buffer.append("JAVADOC_FIELD_REF"); //$NON-NLS-1$ + break; + case CompletionProposal.JAVADOC_METHOD_REF : + buffer.append("JAVADOC_METHOD_REF"); //$NON-NLS-1$ + break; + case CompletionProposal.JAVADOC_TYPE_REF : + buffer.append("JAVADOC_TYPE_REF"); //$NON-NLS-1$ + break; + case CompletionProposal.JAVADOC_PARAM_REF : + buffer.append("JAVADOC_PARAM_REF"); //$NON-NLS-1$ + break; + case CompletionProposal.JAVADOC_VALUE_REF : + buffer.append("JAVADOC_VALUE_REF"); //$NON-NLS-1$ + break; + case CompletionProposal.FIELD_IMPORT : + buffer.append("FIELD_IMPORT"); //$NON-NLS-1$ + break; + case CompletionProposal.METHOD_IMPORT : + buffer.append("METHOD_IMPORT"); //$NON-NLS-1$ + break; + case CompletionProposal.TYPE_IMPORT : + buffer.append("TYPE_IMPORT"); //$NON-NLS-1$ + break; + case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER : + buffer.append("METHOD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$ + break; + case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER : + buffer.append("FIELD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$ + break; + default : + buffer.append("PROPOSAL"); //$NON-NLS-1$ + break; + + } + buffer.append("]{completion:"); //$NON-NLS-1$ + if (this.completion != null) buffer.append(this.completion); + buffer.append(", declSign:"); //$NON-NLS-1$ + if (this.declarationSignature != null) buffer.append(this.declarationSignature); + buffer.append(", sign:"); //$NON-NLS-1$ + if (this.signature != null) buffer.append(this.signature); + buffer.append(", declKey:"); //$NON-NLS-1$ + if (this.declarationKey != null) buffer.append(this.declarationKey); + buffer.append(", key:"); //$NON-NLS-1$ + if (this.key != null) buffer.append(this.key); + buffer.append(", name:"); //$NON-NLS-1$ + if (this.name != null) buffer.append(this.name); + buffer.append(", replace:["); //$NON-NLS-1$ + buffer.append(this.replaceStart); + buffer.append(','); + buffer.append(this.replaceEnd); + buffer.append("], token:["); //$NON-NLS-1$ + buffer.append(this.tokenStart); + buffer.append(','); + buffer.append(this.tokenEnd); + buffer.append("], relevance:"); //$NON-NLS-1$ + buffer.append(this.relevance); + buffer.append('}'); + return buffer.toString(); + } } Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionRequestorWrapper.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionRequestorWrapper.java,v retrieving revision 1.8 diff -u -r1.8 CompletionRequestorWrapper.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionRequestorWrapper.java 27 Jun 2008 16:04:03 -0000 1.8 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionRequestorWrapper.java 1 Sep 2008 10:49:27 -0000 @@ -31,255 +31,256 @@ } public void accept(CompletionProposal proposal) { - switch(proposal.getKind()) { + InternalCompletionProposal internalCompletionProposal = (InternalCompletionProposal) proposal; + switch(internalCompletionProposal.getKind()) { case CompletionProposal.KEYWORD: this.requestor.acceptKeyword( - proposal.getName(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance()); + internalCompletionProposal.getName(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance()); break; case CompletionProposal.PACKAGE_REF: if(DECODE_SIGNATURE) { this.requestor.acceptPackage( - proposal.getDeclarationSignature(), - proposal.getCompletion(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance()); + internalCompletionProposal.getDeclarationSignature(), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance()); } else { this.requestor.acceptPackage( - proposal.getPackageName(), - proposal.getCompletion(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance()); + internalCompletionProposal.getPackageName(), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance()); } break; case CompletionProposal.TYPE_REF: - if((proposal.getFlags() & Flags.AccEnum) != 0) { + if((internalCompletionProposal.getFlags() & Flags.AccEnum) != 0) { // does not exist for old requestor - } else if((proposal.getFlags() & Flags.AccInterface) != 0) { + } else if((internalCompletionProposal.getFlags() & Flags.AccInterface) != 0) { if(DECODE_SIGNATURE) { this.requestor.acceptInterface( - proposal.getDeclarationSignature(), - Signature.getSignatureSimpleName(proposal.getSignature()), - proposal.getCompletion(), - proposal.getFlags() & ~Flags.AccInterface, - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance()); + internalCompletionProposal.getDeclarationSignature(), + Signature.getSignatureSimpleName(internalCompletionProposal.getSignature()), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getFlags() & ~Flags.AccInterface, + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance()); } else { this.requestor.acceptInterface( - proposal.getPackageName() == null ? CharOperation.NO_CHAR : proposal.getPackageName(), - proposal.getTypeName(), - proposal.getCompletion(), - proposal.getFlags() & ~Flags.AccInterface, - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance()); + internalCompletionProposal.getPackageName() == null ? CharOperation.NO_CHAR : internalCompletionProposal.getPackageName(), + internalCompletionProposal.getTypeName(), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getFlags() & ~Flags.AccInterface, + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance()); } } else { if(DECODE_SIGNATURE) { this.requestor.acceptClass( - proposal.getDeclarationSignature(), - Signature.getSignatureSimpleName(proposal.getSignature()), - proposal.getCompletion(), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance()); + internalCompletionProposal.getDeclarationSignature(), + Signature.getSignatureSimpleName(internalCompletionProposal.getSignature()), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance()); } else { this.requestor.acceptClass( - proposal.getPackageName() == null ? CharOperation.NO_CHAR : proposal.getPackageName(), - proposal.getTypeName(), - proposal.getCompletion(), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance()); + internalCompletionProposal.getPackageName() == null ? CharOperation.NO_CHAR : internalCompletionProposal.getPackageName(), + internalCompletionProposal.getTypeName(), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance()); } } break; case CompletionProposal.FIELD_REF: if(DECODE_SIGNATURE) { this.requestor.acceptField( - Signature.getSignatureQualifier(proposal.getDeclarationSignature()), - Signature.getSignatureSimpleName(proposal.getDeclarationSignature()), - proposal.getName(), - Signature.getSignatureQualifier(proposal.getSignature()), - Signature.getSignatureSimpleName(proposal.getSignature()), - proposal.getCompletion(), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + Signature.getSignatureQualifier(internalCompletionProposal.getDeclarationSignature()), + Signature.getSignatureSimpleName(internalCompletionProposal.getDeclarationSignature()), + internalCompletionProposal.getName(), + Signature.getSignatureQualifier(internalCompletionProposal.getSignature()), + Signature.getSignatureSimpleName(internalCompletionProposal.getSignature()), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } else { this.requestor.acceptField( - proposal.getDeclarationPackageName() == null ? CharOperation.NO_CHAR : proposal.getDeclarationPackageName(), - proposal.getDeclarationTypeName() == null ? CharOperation.NO_CHAR : proposal.getDeclarationTypeName(), - proposal.getName(), - proposal.getPackageName() == null ? CharOperation.NO_CHAR : proposal.getPackageName(), - proposal.getTypeName() == null ? CharOperation.NO_CHAR : proposal.getTypeName(), - proposal.getCompletion(), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + internalCompletionProposal.getDeclarationPackageName() == null ? CharOperation.NO_CHAR : internalCompletionProposal.getDeclarationPackageName(), + internalCompletionProposal.getDeclarationTypeName() == null ? CharOperation.NO_CHAR : internalCompletionProposal.getDeclarationTypeName(), + internalCompletionProposal.getName(), + internalCompletionProposal.getPackageName() == null ? CharOperation.NO_CHAR : internalCompletionProposal.getPackageName(), + internalCompletionProposal.getTypeName() == null ? CharOperation.NO_CHAR : internalCompletionProposal.getTypeName(), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } break; case CompletionProposal.METHOD_REF: if(DECODE_SIGNATURE) { this.requestor.acceptMethod( - Signature.getSignatureQualifier(proposal.getDeclarationSignature()), - Signature.getSignatureSimpleName(proposal.getDeclarationSignature()), - proposal.getName(), - getParameterPackages(proposal.getSignature()), - getParameterTypes(proposal.getSignature()), - proposal.findParameterNames(null) == null ? CharOperation.NO_CHAR_CHAR : proposal.findParameterNames(null), - Signature.getSignatureQualifier(Signature.getReturnType(proposal.getSignature())), - Signature.getSignatureSimpleName(Signature.getReturnType(proposal.getSignature())), - proposal.getCompletion(), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + Signature.getSignatureQualifier(internalCompletionProposal.getDeclarationSignature()), + Signature.getSignatureSimpleName(internalCompletionProposal.getDeclarationSignature()), + internalCompletionProposal.getName(), + getParameterPackages(internalCompletionProposal.getSignature()), + getParameterTypes(internalCompletionProposal.getSignature()), + internalCompletionProposal.findParameterNames(null) == null ? CharOperation.NO_CHAR_CHAR : internalCompletionProposal.findParameterNames(null), + Signature.getSignatureQualifier(Signature.getReturnType(internalCompletionProposal.getSignature())), + Signature.getSignatureSimpleName(Signature.getReturnType(internalCompletionProposal.getSignature())), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } else { this.requestor.acceptMethod( - proposal.getDeclarationPackageName() == null ? CharOperation.NO_CHAR : proposal.getDeclarationPackageName(), - proposal.getDeclarationTypeName() == null ? CharOperation.NO_CHAR : proposal.getDeclarationTypeName(), - proposal.getName(), - proposal.getParameterPackageNames() == null ? CharOperation.NO_CHAR_CHAR : proposal.getParameterPackageNames(), - proposal.getParameterTypeNames() == null ? CharOperation.NO_CHAR_CHAR : proposal.getParameterTypeNames(), - proposal.findParameterNames(null) == null ? CharOperation.NO_CHAR_CHAR : proposal.findParameterNames(null), - proposal.getPackageName() == null ? CharOperation.NO_CHAR : proposal.getPackageName(), - proposal.getTypeName() == null ? CharOperation.NO_CHAR : proposal.getTypeName(), - proposal.getCompletion(), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + internalCompletionProposal.getDeclarationPackageName() == null ? CharOperation.NO_CHAR : internalCompletionProposal.getDeclarationPackageName(), + internalCompletionProposal.getDeclarationTypeName() == null ? CharOperation.NO_CHAR : internalCompletionProposal.getDeclarationTypeName(), + internalCompletionProposal.getName(), + internalCompletionProposal.getParameterPackageNames() == null ? CharOperation.NO_CHAR_CHAR : internalCompletionProposal.getParameterPackageNames(), + internalCompletionProposal.getParameterTypeNames() == null ? CharOperation.NO_CHAR_CHAR : internalCompletionProposal.getParameterTypeNames(), + internalCompletionProposal.findParameterNames(null) == null ? CharOperation.NO_CHAR_CHAR : internalCompletionProposal.findParameterNames(null), + internalCompletionProposal.getPackageName() == null ? CharOperation.NO_CHAR : internalCompletionProposal.getPackageName(), + internalCompletionProposal.getTypeName() == null ? CharOperation.NO_CHAR : internalCompletionProposal.getTypeName(), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } break; case CompletionProposal.METHOD_DECLARATION: if(DECODE_SIGNATURE) { this.requestor.acceptMethodDeclaration( - Signature.getSignatureQualifier(proposal.getDeclarationSignature()), - Signature.getSignatureSimpleName(proposal.getDeclarationSignature()), - proposal.getName(), - getParameterPackages(proposal.getSignature()), - getParameterTypes(proposal.getSignature()), - proposal.findParameterNames(null) == null ? CharOperation.NO_CHAR_CHAR : proposal.findParameterNames(null), - Signature.getSignatureQualifier(Signature.getReturnType(proposal.getSignature())), - Signature.getSignatureSimpleName(Signature.getReturnType(proposal.getSignature())), - proposal.getCompletion(), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + Signature.getSignatureQualifier(internalCompletionProposal.getDeclarationSignature()), + Signature.getSignatureSimpleName(internalCompletionProposal.getDeclarationSignature()), + internalCompletionProposal.getName(), + getParameterPackages(internalCompletionProposal.getSignature()), + getParameterTypes(internalCompletionProposal.getSignature()), + internalCompletionProposal.findParameterNames(null) == null ? CharOperation.NO_CHAR_CHAR : internalCompletionProposal.findParameterNames(null), + Signature.getSignatureQualifier(Signature.getReturnType(internalCompletionProposal.getSignature())), + Signature.getSignatureSimpleName(Signature.getReturnType(internalCompletionProposal.getSignature())), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } else { this.requestor.acceptMethodDeclaration( - proposal.getDeclarationPackageName(), - proposal.getDeclarationTypeName(), - proposal.getName(), - proposal.getParameterPackageNames() == null ? CharOperation.NO_CHAR_CHAR : proposal.getParameterPackageNames(), - proposal.getParameterTypeNames() == null ? CharOperation.NO_CHAR_CHAR : proposal.getParameterTypeNames(), - proposal.findParameterNames(null) == null ? CharOperation.NO_CHAR_CHAR : proposal.findParameterNames(null), - proposal.getPackageName(), - proposal.getTypeName(), - proposal.getCompletion(), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + internalCompletionProposal.getDeclarationPackageName(), + internalCompletionProposal.getDeclarationTypeName(), + internalCompletionProposal.getName(), + internalCompletionProposal.getParameterPackageNames() == null ? CharOperation.NO_CHAR_CHAR : internalCompletionProposal.getParameterPackageNames(), + internalCompletionProposal.getParameterTypeNames() == null ? CharOperation.NO_CHAR_CHAR : internalCompletionProposal.getParameterTypeNames(), + internalCompletionProposal.findParameterNames(null) == null ? CharOperation.NO_CHAR_CHAR : internalCompletionProposal.findParameterNames(null), + internalCompletionProposal.getPackageName(), + internalCompletionProposal.getTypeName(), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } break; case CompletionProposal.ANONYMOUS_CLASS_DECLARATION: if(DECODE_SIGNATURE) { this.requestor.acceptAnonymousType( - Signature.getSignatureQualifier(proposal.getDeclarationSignature()), - Signature.getSignatureSimpleName(proposal.getDeclarationSignature()), - getParameterPackages(proposal.getSignature()), - getParameterTypes(proposal.getSignature()), - proposal.findParameterNames(null) == null ? CharOperation.NO_CHAR_CHAR : proposal.findParameterNames(null), - proposal.getCompletion(), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + Signature.getSignatureQualifier(internalCompletionProposal.getDeclarationSignature()), + Signature.getSignatureSimpleName(internalCompletionProposal.getDeclarationSignature()), + getParameterPackages(internalCompletionProposal.getSignature()), + getParameterTypes(internalCompletionProposal.getSignature()), + internalCompletionProposal.findParameterNames(null) == null ? CharOperation.NO_CHAR_CHAR : internalCompletionProposal.findParameterNames(null), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } else { this.requestor.acceptAnonymousType( - proposal.getDeclarationPackageName(), - proposal.getDeclarationTypeName(), - proposal.getParameterPackageNames() == null ? CharOperation.NO_CHAR_CHAR : proposal.getParameterPackageNames(), - proposal.getParameterTypeNames() == null ? CharOperation.NO_CHAR_CHAR : proposal.getParameterTypeNames(), - proposal.findParameterNames(null) == null ? CharOperation.NO_CHAR_CHAR : proposal.findParameterNames(null), - proposal.getCompletion(), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + internalCompletionProposal.getDeclarationPackageName(), + internalCompletionProposal.getDeclarationTypeName(), + internalCompletionProposal.getParameterPackageNames() == null ? CharOperation.NO_CHAR_CHAR : internalCompletionProposal.getParameterPackageNames(), + internalCompletionProposal.getParameterTypeNames() == null ? CharOperation.NO_CHAR_CHAR : internalCompletionProposal.getParameterTypeNames(), + internalCompletionProposal.findParameterNames(null) == null ? CharOperation.NO_CHAR_CHAR : internalCompletionProposal.findParameterNames(null), + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } break; case CompletionProposal.LABEL_REF : this.requestor.acceptLabel( - proposal.getCompletion(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); break; case CompletionProposal.LOCAL_VARIABLE_REF: if(DECODE_SIGNATURE) { this.requestor.acceptLocalVariable( - proposal.getCompletion(), - Signature.getSignatureQualifier(proposal.getSignature()), - Signature.getSignatureSimpleName(proposal.getSignature()), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + internalCompletionProposal.getCompletion(), + Signature.getSignatureQualifier(internalCompletionProposal.getSignature()), + Signature.getSignatureSimpleName(internalCompletionProposal.getSignature()), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } else { this.requestor.acceptLocalVariable( - proposal.getCompletion(), - proposal.getPackageName() == null ? CharOperation.NO_CHAR : proposal.getPackageName(), - proposal.getTypeName(), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getPackageName() == null ? CharOperation.NO_CHAR : internalCompletionProposal.getPackageName(), + internalCompletionProposal.getTypeName(), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } break; case CompletionProposal.VARIABLE_DECLARATION: if(DECODE_SIGNATURE) { this.requestor.acceptLocalVariable( - proposal.getCompletion(), - Signature.getSignatureQualifier(proposal.getSignature()), - Signature.getSignatureSimpleName(proposal.getSignature()), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + internalCompletionProposal.getCompletion(), + Signature.getSignatureQualifier(internalCompletionProposal.getSignature()), + Signature.getSignatureSimpleName(internalCompletionProposal.getSignature()), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } else { this.requestor.acceptLocalVariable( - proposal.getCompletion(), - proposal.getPackageName(), - proposal.getTypeName(), - proposal.getFlags(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + internalCompletionProposal.getCompletion(), + internalCompletionProposal.getPackageName(), + internalCompletionProposal.getTypeName(), + internalCompletionProposal.getFlags(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } break; @@ -288,21 +289,21 @@ IExtendedCompletionRequestor r = (IExtendedCompletionRequestor) this.requestor; if(DECODE_SIGNATURE) { r.acceptPotentialMethodDeclaration( - Signature.getSignatureQualifier(proposal.getDeclarationSignature()), - Signature.getSignatureSimpleName(proposal.getDeclarationSignature()), - proposal.getName(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + Signature.getSignatureQualifier(internalCompletionProposal.getDeclarationSignature()), + Signature.getSignatureSimpleName(internalCompletionProposal.getDeclarationSignature()), + internalCompletionProposal.getName(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } else { r.acceptPotentialMethodDeclaration( - proposal.getDeclarationPackageName(), - proposal.getDeclarationTypeName(), - proposal.getName(), - proposal.getReplaceStart(), - proposal.getReplaceEnd(), - proposal.getRelevance() + internalCompletionProposal.getDeclarationPackageName(), + internalCompletionProposal.getDeclarationTypeName(), + internalCompletionProposal.getName(), + internalCompletionProposal.getReplaceStart(), + internalCompletionProposal.getReplaceEnd(), + internalCompletionProposal.getRelevance() ); } } Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v retrieving revision 1.371 diff -u -r1.371 CompletionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 8 Jul 2008 13:29:04 -0000 1.371 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 1 Sep 2008 10:49:27 -0000 @@ -693,7 +693,7 @@ relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for local variable CompletionEngine.this.noProposal = false; if(!CompletionEngine.this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) { - CompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.LOCAL_VARIABLE_REF, CompletionEngine.this.actualCompletionPosition); + InternalCompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.LOCAL_VARIABLE_REF, CompletionEngine.this.actualCompletionPosition); proposal.setSignature(JAVA_LANG_OBJECT_SIGNATURE); proposal.setPackageName(JAVA_LANG_NAME); proposal.setTypeName(OBJECT); @@ -848,7 +848,7 @@ this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.PACKAGE_REF)) { - CompletionProposal proposal = createProposal(CompletionProposal.PACKAGE_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.PACKAGE_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(packageName); proposal.setPackageName(packageName); proposal.setCompletion(completion); @@ -2726,7 +2726,7 @@ this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) { - CompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(currentType)); proposal.setDeclarationKey(currentType.computeUniqueKey()); proposal.setSignature( @@ -2791,7 +2791,7 @@ this.noProposal = false; if(!isIgnored(CompletionProposal.FIELD_REF, missingElements != null)) { - CompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); //proposal.setDeclarationSignature(null); char[] signature = createNonGenericTypeSignature( @@ -2884,7 +2884,7 @@ char[] completion = fieldName; if(!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) { - CompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(field.declaringClass)); proposal.setSignature(getSignature(field.type)); proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName()); @@ -2911,7 +2911,7 @@ if (!needImport) { if(!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) { - CompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(field.declaringClass)); proposal.setSignature(getSignature(field.type)); proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName()); @@ -2937,7 +2937,7 @@ ReferenceBinding fieldType = (ReferenceBinding)field.type; - CompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(field.declaringClass)); proposal.setSignature(getSignature(field.type)); proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName()); @@ -2953,7 +2953,7 @@ char[] typeImportCompletion = createImportCharArray(CharOperation.concatWith(fieldType.compoundName, '.'), false, false); - CompletionProposal typeImportProposal = createProposal(CompletionProposal.TYPE_IMPORT, this.actualCompletionPosition); + InternalCompletionProposal typeImportProposal = createProposal(CompletionProposal.TYPE_IMPORT, this.actualCompletionPosition); typeImportProposal.nameLookup = this.nameEnvironment.nameLookup; typeImportProposal.completionEngine = this; char[] packageName = fieldType.qualifiedPackageName(); @@ -3280,7 +3280,7 @@ this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) { - CompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(currentType)); proposal.setSignature(getSignature(constructor)); MethodBinding original = constructor.original(); @@ -3366,7 +3366,7 @@ this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION)) { - CompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.ANONYMOUS_CLASS_DECLARATION, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(currentType)); proposal.setDeclarationKey(currentType.computeUniqueKey()); proposal.setSignature(getSignature(constructor)); @@ -3454,7 +3454,7 @@ // Create standard proposal this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) { - CompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(currentType)); proposal.setSignature(getSignature(constructor)); MethodBinding original = constructor.original(); @@ -3483,7 +3483,7 @@ } if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_METHOD_REF)) { char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK); - CompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(currentType)); proposal.setSignature(getSignature(constructor)); MethodBinding original = constructor.original(); @@ -3716,7 +3716,7 @@ if (castedReceiver == null) { // Standard proposal if (!this.isIgnored(CompletionProposal.FIELD_REF, missingElements != null) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) { - CompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(field.declaringClass)); proposal.setSignature(getSignature(field.type)); proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName()); @@ -3750,7 +3750,7 @@ // Javadoc completions if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_FIELD_REF)) { char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK); - CompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_FIELD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_FIELD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(field.declaringClass)); proposal.setSignature(getSignature(field.type)); proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName()); @@ -3771,7 +3771,7 @@ // Javadoc value completion for static fields if (field.isStatic() && !this.requestor.isIgnored(CompletionProposal.JAVADOC_VALUE_REF)) { javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_VALUE); - CompletionProposal valueProposal = createProposal(CompletionProposal.JAVADOC_VALUE_REF, this.actualCompletionPosition); + InternalCompletionProposal valueProposal = createProposal(CompletionProposal.JAVADOC_VALUE_REF, this.actualCompletionPosition); valueProposal.setDeclarationSignature(getSignature(field.declaringClass)); valueProposal.setSignature(getSignature(field.type)); valueProposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName()); @@ -3792,7 +3792,7 @@ } } else { if(!this.isIgnored(CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER, missingElements != null)) { - CompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(field.declaringClass)); proposal.setSignature(getSignature(field.type)); proposal.setReceiverSignature(getSignature(receiverType)); @@ -4069,7 +4069,7 @@ this.noProposal = false; if (castedReceiver == null) { if(!isIgnored(CompletionProposal.FIELD_REF, missingElements != null)) { - CompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(receiverType)); proposal.setSignature(INT_SIGNATURE); proposal.setTypeName(INT); @@ -4100,7 +4100,7 @@ char[] completion = CharOperation.concat(castedReceiver, lengthField); if(!this.isIgnored(CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER, missingElements != null)) { - CompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(receiverType)); proposal.setSignature(INT_SIGNATURE); proposal.setReceiverSignature(getSignature(receiverType)); @@ -4164,7 +4164,7 @@ this.noProposal = false; if (castedReceiver == null) { if (!this.isIgnored(CompletionProposal.METHOD_REF, missingElements != null)) { - CompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(receiverType)); proposal.setSignature( this.compilerOptions.sourceLevel > ClassFileConstants.JDK1_4 && receiverType.isArrayType() ? @@ -4210,7 +4210,7 @@ methodsFound.add(new Object[]{objectRef.getMethods(cloneMethod)[0], objectRef}); } else { if(!this.isIgnored(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, missingElements != null)) { - CompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(receiverType)); proposal.setSignature( this.compilerOptions.sourceLevel > ClassFileConstants.JDK1_4 && receiverType.isArrayType() ? @@ -4630,7 +4630,7 @@ if (!this.isIgnored(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_IMPORT)) { char[] completion = CharOperation.concat(receiverType.sourceName, field.name, '.'); - CompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(field.declaringClass)); proposal.setSignature(getSignature(field.type)); proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName()); @@ -4646,7 +4646,7 @@ char[] typeImportCompletion = createImportCharArray(typeName, false, false); - CompletionProposal typeImportProposal = createProposal(CompletionProposal.TYPE_IMPORT, this.actualCompletionPosition); + InternalCompletionProposal typeImportProposal = createProposal(CompletionProposal.TYPE_IMPORT, this.actualCompletionPosition); typeImportProposal.nameLookup = this.nameEnvironment.nameLookup; typeImportProposal.completionEngine = this; char[] packageName = receiverType.qualifiedPackageName(); @@ -4672,7 +4672,7 @@ if (!this.isIgnored(CompletionProposal.FIELD_REF, CompletionProposal.FIELD_IMPORT)) { char[] completion = field.name; - CompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(field.declaringClass)); proposal.setSignature(getSignature(field.type)); proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName()); @@ -4688,7 +4688,7 @@ char[] fieldImportCompletion = createImportCharArray(CharOperation.concat(typeName, field.name, '.'), true, false); - CompletionProposal fieldImportProposal = createProposal(CompletionProposal.FIELD_IMPORT, this.actualCompletionPosition); + InternalCompletionProposal fieldImportProposal = createProposal(CompletionProposal.FIELD_IMPORT, this.actualCompletionPosition); fieldImportProposal.setDeclarationSignature(getSignature(field.declaringClass)); fieldImportProposal.setSignature(getSignature(field.type)); fieldImportProposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName()); @@ -4848,7 +4848,7 @@ this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.FIELD_REF)) { - CompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(field.declaringClass)); proposal.setSignature(getSignature(field.type)); proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName()); @@ -4917,7 +4917,7 @@ this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.METHOD_NAME_REFERENCE)) { - CompletionProposal proposal = createProposal(CompletionProposal.METHOD_NAME_REFERENCE, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_NAME_REFERENCE, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(method.declaringClass)); proposal.setSignature(getSignature(method)); proposal.setDeclarationPackageName(method.declaringClass.qualifiedPackageName()); @@ -4956,7 +4956,7 @@ this.noProposal = false; if (!this.requestor.isIgnored(CompletionProposal.JAVADOC_BLOCK_TAG)) { char[] possibleTag = possibleTags[i]; - CompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_BLOCK_TAG, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_BLOCK_TAG, this.actualCompletionPosition); proposal.setName(possibleTag); int tagLength = possibleTag.length; char[] completion = new char[1+tagLength]; @@ -4989,7 +4989,7 @@ this.noProposal = false; if (!this.requestor.isIgnored(CompletionProposal.JAVADOC_INLINE_TAG)) { char[] possibleTag = possibleTags[i]; - CompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_INLINE_TAG, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_INLINE_TAG, this.actualCompletionPosition); proposal.setName(possibleTag); int tagLength = possibleTag.length; // boolean inlineTagStarted = javadocTag.completeInlineTagStarted(); @@ -5036,7 +5036,7 @@ } this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.KEYWORD)) { - CompletionProposal proposal = createProposal(CompletionProposal.KEYWORD, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.KEYWORD, this.actualCompletionPosition); proposal.setName(choices[i]); proposal.setCompletion(choices[i]); proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); @@ -5069,7 +5069,7 @@ this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.KEYWORD)) { - CompletionProposal proposal = createProposal(CompletionProposal.KEYWORD, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.KEYWORD, this.actualCompletionPosition); proposal.setName(choices[i]); proposal.setCompletion(choices[i]); proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); @@ -5231,7 +5231,7 @@ this.noProposal = false; if (!this.requestor.isIgnored(CompletionProposal.KEYWORD)) { - CompletionProposal proposal = createProposal(CompletionProposal.KEYWORD, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.KEYWORD, this.actualCompletionPosition); proposal.setName(Keywords.THIS); proposal.setCompletion(Keywords.THIS); proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); @@ -5733,7 +5733,7 @@ this.noProposal = false; if (!this.requestor.isIgnored(CompletionProposal.JAVADOC_PARAM_REF)) { - CompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_PARAM_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_PARAM_REF, this.actualCompletionPosition); proposal.setName(argName); char[] completion = isTypeParam ? CharOperation.concat('<', argName, '>') : argName; proposal.setCompletion(completion); @@ -6191,7 +6191,7 @@ if (castedReceiver == null) { // Standard proposal if(!this.isIgnored(CompletionProposal.METHOD_REF, missingElements != null) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) { - CompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(method.declaringClass)); proposal.setSignature(getSignature(method)); MethodBinding original = method.original(); @@ -6232,7 +6232,7 @@ // Javadoc proposal if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_METHOD_REF)) { char[] javadocCompletion = inlineTagCompletion(completion, JavadocTagConstants.TAG_LINK); - CompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.JAVADOC_METHOD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(method.declaringClass)); proposal.setSignature(getSignature(method)); MethodBinding original = method.original(); @@ -6260,7 +6260,7 @@ } } else { if(!this.isIgnored(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, missingElements != null)) { - CompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(method.declaringClass)); proposal.setSignature(getSignature(method)); MethodBinding original = method.original(); @@ -6451,7 +6451,7 @@ if (!isIgnored(CompletionProposal.METHOD_REF)) { completion = CharOperation.concat(receiverType.sourceName, completion, '.'); - CompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(method.declaringClass)); proposal.setSignature(getSignature(method)); MethodBinding original = method.original(); @@ -6480,7 +6480,7 @@ } else if (!this.isIgnored(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_IMPORT)) { completion = CharOperation.concat(receiverType.sourceName, completion, '.'); - CompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(method.declaringClass)); proposal.setSignature(getSignature(method)); MethodBinding original = method.original(); @@ -6503,7 +6503,7 @@ char[] typeImportCompletion = createImportCharArray(typeName, false, false); - CompletionProposal typeImportProposal = createProposal(CompletionProposal.TYPE_IMPORT, this.actualCompletionPosition); + InternalCompletionProposal typeImportProposal = createProposal(CompletionProposal.TYPE_IMPORT, this.actualCompletionPosition); typeImportProposal.nameLookup = this.nameEnvironment.nameLookup; typeImportProposal.completionEngine = this; char[] packageName = receiverType.qualifiedPackageName(); @@ -6527,7 +6527,7 @@ } } else { if (!this.isIgnored(CompletionProposal.METHOD_REF, CompletionProposal.METHOD_IMPORT)) { - CompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(method.declaringClass)); proposal.setSignature(getSignature(method)); MethodBinding original = method.original(); @@ -6550,7 +6550,7 @@ char[] methodImportCompletion = createImportCharArray(CharOperation.concat(typeName, method.selector, '.'), true, false); - CompletionProposal methodImportProposal = createProposal(CompletionProposal.METHOD_IMPORT, this.actualCompletionPosition); + InternalCompletionProposal methodImportProposal = createProposal(CompletionProposal.METHOD_IMPORT, this.actualCompletionPosition); methodImportProposal.setDeclarationSignature(getSignature(method.declaringClass)); methodImportProposal.setSignature(getSignature(method)); if(original != method) { @@ -6586,7 +6586,7 @@ } private CompletionProposal createRequiredTypeProposal(Binding binding, int start, int end, int relevance) { - CompletionProposal proposal = null; + InternalCompletionProposal proposal = null; if (binding instanceof ReferenceBinding) { ReferenceBinding typeBinding = (ReferenceBinding) binding; @@ -6714,7 +6714,7 @@ this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) { - CompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(method.declaringClass)); proposal.setSignature(getSignature(method)); MethodBinding original = method.original(); @@ -6944,7 +6944,7 @@ this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.LABEL_REF)) { - CompletionProposal proposal = createProposal(CompletionProposal.LABEL_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.LABEL_REF, this.actualCompletionPosition); proposal.setName(choices[i]); proposal.setCompletion(choices[i]); proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset); @@ -7064,7 +7064,7 @@ this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.METHOD_DECLARATION)) { - CompletionProposal proposal = createProposal(CompletionProposal.METHOD_DECLARATION, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.METHOD_DECLARATION, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(method.declaringClass)); proposal.setDeclarationKey(method.declaringClass.computeUniqueKey()); proposal.setSignature(getSignature(method)); @@ -8036,7 +8036,7 @@ this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { - CompletionProposal proposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(packageName); proposal.setSignature(getSignature(refBinding)); proposal.setPackageName(packageName); @@ -8299,7 +8299,7 @@ this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { - CompletionProposal proposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.TYPE_REF, this.actualCompletionPosition); proposal.setDeclarationSignature(typeBinding.qualifiedPackageName()); proposal.setSignature(getSignature(typeBinding)); proposal.setPackageName(typeBinding.qualifiedPackageName()); @@ -8391,7 +8391,7 @@ relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for local variable this.noProposal = false; if(!this.requestor.isIgnored(CompletionProposal.LOCAL_VARIABLE_REF)) { - CompletionProposal proposal = createProposal(CompletionProposal.LOCAL_VARIABLE_REF, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.LOCAL_VARIABLE_REF, this.actualCompletionPosition); proposal.setSignature( local.type == null ? createTypeSignature( @@ -8693,7 +8693,7 @@ // accept result CompletionEngine.this.noProposal = false; if(!CompletionEngine.this.requestor.isIgnored(CompletionProposal.VARIABLE_DECLARATION)) { - CompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.VARIABLE_DECLARATION, CompletionEngine.this.actualCompletionPosition); + InternalCompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.VARIABLE_DECLARATION, CompletionEngine.this.actualCompletionPosition); proposal.setSignature(getSignature(type.resolvedType)); proposal.setPackageName(type.resolvedType.qualifiedPackageName()); proposal.setTypeName(type.resolvedType.qualifiedSourceName()); @@ -8961,7 +8961,7 @@ // accept result CompletionEngine.this.noProposal = false; if(!CompletionEngine.this.requestor.isIgnored(CompletionProposal.VARIABLE_DECLARATION)) { - CompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.VARIABLE_DECLARATION, CompletionEngine.this.actualCompletionPosition); + InternalCompletionProposal proposal = CompletionEngine.this.createProposal(CompletionProposal.VARIABLE_DECLARATION, CompletionEngine.this.actualCompletionPosition); proposal.setSignature(getSignature(typeBinding)); proposal.setPackageName(q); proposal.setTypeName(displayName); @@ -9921,7 +9921,7 @@ relevance += computeRelevanceForInterestingProposal(); relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE); // no access restriction for new method - CompletionProposal proposal = createProposal(CompletionProposal.POTENTIAL_METHOD_DECLARATION, this.actualCompletionPosition); + InternalCompletionProposal proposal = createProposal(CompletionProposal.POTENTIAL_METHOD_DECLARATION, this.actualCompletionPosition); proposal.setDeclarationSignature(getSignature(reference)); proposal.setSignature( createMethodSignature( @@ -10106,8 +10106,8 @@ returnTypeSignature); } - protected CompletionProposal createProposal(int kind, int completionOffset) { - CompletionProposal proposal = CompletionProposal.create(kind, completionOffset - this.offset); + protected InternalCompletionProposal createProposal(int kind, int completionOffset) { + InternalCompletionProposal proposal = (InternalCompletionProposal) CompletionProposal.create(kind, completionOffset - this.offset); proposal.nameLookup = this.nameEnvironment.nameLookup; proposal.completionEngine = this; return proposal; @@ -10120,7 +10120,7 @@ // Create standard type proposal if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) { - CompletionProposal proposal = CompletionProposal.create(CompletionProposal.TYPE_REF, this.actualCompletionPosition - this.offset); + InternalCompletionProposal proposal = (InternalCompletionProposal) CompletionProposal.create(CompletionProposal.TYPE_REF, this.actualCompletionPosition - this.offset); proposal.nameLookup = this.nameEnvironment.nameLookup; proposal.completionEngine = this; proposal.setDeclarationSignature(packageName); @@ -10142,7 +10142,7 @@ // Create javadoc text proposal if necessary if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF)) { char[] javadocCompletion= inlineTagCompletion(completionName, JavadocTagConstants.TAG_LINK); - CompletionProposal proposal = CompletionProposal.create(CompletionProposal.JAVADOC_TYPE_REF, this.actualCompletionPosition - this.offset); + InternalCompletionProposal proposal = (InternalCompletionProposal) CompletionProposal.create(CompletionProposal.JAVADOC_TYPE_REF, this.actualCompletionPosition - this.offset); proposal.nameLookup = this.nameEnvironment.nameLookup; proposal.completionEngine = this; proposal.setDeclarationSignature(packageName); @@ -10179,7 +10179,7 @@ // Create standard type proposal if(!this.isIgnored(CompletionProposal.TYPE_REF, missingElements != null) && (this.assistNodeInJavadoc & CompletionOnJavadoc.ONLY_INLINE_TAG) == 0) { - CompletionProposal proposal = CompletionProposal.create(CompletionProposal.TYPE_REF, this.actualCompletionPosition - this.offset); + InternalCompletionProposal proposal = (InternalCompletionProposal) CompletionProposal.create(CompletionProposal.TYPE_REF, this.actualCompletionPosition - this.offset); proposal.nameLookup = this.nameEnvironment.nameLookup; proposal.completionEngine = this; proposal.setDeclarationSignature(refBinding.qualifiedPackageName()); @@ -10212,7 +10212,7 @@ // Create javadoc text proposal if necessary if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF)) { char[] javadocCompletion= inlineTagCompletion(completionName, JavadocTagConstants.TAG_LINK); - CompletionProposal proposal = CompletionProposal.create(CompletionProposal.JAVADOC_TYPE_REF, this.actualCompletionPosition - this.offset); + InternalCompletionProposal proposal = (InternalCompletionProposal) CompletionProposal.create(CompletionProposal.JAVADOC_TYPE_REF, this.actualCompletionPosition - this.offset); proposal.nameLookup = this.nameEnvironment.nameLookup; proposal.completionEngine = this; proposal.setDeclarationSignature(refBinding.qualifiedPackageName()); @@ -10240,7 +10240,7 @@ // Create standard type proposal if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) { - CompletionProposal proposal = CompletionProposal.create(CompletionProposal.TYPE_REF, this.actualCompletionPosition - this.offset); + InternalCompletionProposal proposal = (InternalCompletionProposal) CompletionProposal.create(CompletionProposal.TYPE_REF, this.actualCompletionPosition - this.offset); proposal.nameLookup = this.nameEnvironment.nameLookup; proposal.completionEngine = this; proposal.setSignature(getSignature(typeParameter.binding)); @@ -10259,7 +10259,7 @@ // Create javadoc text proposal if necessary if ((this.assistNodeInJavadoc & CompletionOnJavadoc.TEXT) != 0 && !this.requestor.isIgnored(CompletionProposal.JAVADOC_TYPE_REF)) { char[] javadocCompletion= inlineTagCompletion(completionName, JavadocTagConstants.TAG_LINK); - CompletionProposal proposal = CompletionProposal.create(CompletionProposal.JAVADOC_TYPE_REF, this.actualCompletionPosition - this.offset); + InternalCompletionProposal proposal = (InternalCompletionProposal) CompletionProposal.create(CompletionProposal.JAVADOC_TYPE_REF, this.actualCompletionPosition - this.offset); proposal.nameLookup = this.nameEnvironment.nameLookup; proposal.completionEngine = this; proposal.setSignature(getSignature(typeParameter.binding)); Index: model/org/eclipse/jdt/core/CompletionProposal.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CompletionProposal.java,v retrieving revision 1.45 diff -u -r1.45 CompletionProposal.java --- model/org/eclipse/jdt/core/CompletionProposal.java 27 Jun 2008 16:04:01 -0000 1.45 +++ model/org/eclipse/jdt/core/CompletionProposal.java 1 Sep 2008 10:49:27 -0000 @@ -11,7 +11,6 @@ package org.eclipse.jdt.core; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.codeassist.InternalCompletionProposal; /** @@ -49,9 +48,9 @@ * @see ICodeAssist#codeComplete(int, CompletionRequestor) * @since 3.0 * @noinstantiate This class is not intended to be instantiated by clients. + * @noextend This class is not intended to be subclassed by clients. */ -public final class CompletionProposal extends InternalCompletionProposal { - private boolean updateCompletion = false; +public class CompletionProposal { /** * Completion is a declaration of an anonymous class. @@ -809,125 +808,6 @@ protected static final int LAST_KIND = FIELD_REF_WITH_CASTED_RECEIVER; /** - * 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; - - /** * 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: -// *

-// * For kinds of completion proposals, this method returns -// * null. 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: -// *

-// * For kinds of completion proposals, this method returns -// * null. 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: -// *

-// * For kinds of completion proposals, this method returns -// * null. 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: -// *

-// * For kinds of completion proposals, this method returns -// * null. 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: -// *

-// * For kinds of completion proposals, this method returns -// * null. 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: -// *

-// * For kinds of completion proposals, this method returns -// * null. 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(""); //$NON-NLS-1$ - } - break; - case CompletionProposal.METHOD_REF : - buffer.append("METHOD_REF"); //$NON-NLS-1$ - if(this.isConstructor) { - buffer.append(""); //$NON-NLS-1$ - } - break; - case CompletionProposal.PACKAGE_REF : - buffer.append("PACKAGE_REF"); //$NON-NLS-1$ - break; - case CompletionProposal.TYPE_REF : - buffer.append("TYPE_REF"); //$NON-NLS-1$ - break; - case CompletionProposal.VARIABLE_DECLARATION : - buffer.append("VARIABLE_DECLARATION"); //$NON-NLS-1$ - break; - case CompletionProposal.POTENTIAL_METHOD_DECLARATION : - buffer.append("POTENTIAL_METHOD_DECLARATION"); //$NON-NLS-1$ - break; - case CompletionProposal.METHOD_NAME_REFERENCE : - buffer.append("METHOD_IMPORT"); //$NON-NLS-1$ - break; - case CompletionProposal.ANNOTATION_ATTRIBUTE_REF : - buffer.append("ANNOTATION_ATTRIBUTE_REF"); //$NON-NLS-1$ - break; - case CompletionProposal.JAVADOC_BLOCK_TAG : - buffer.append("JAVADOC_BLOCK_TAG"); //$NON-NLS-1$ - break; - case CompletionProposal.JAVADOC_INLINE_TAG : - buffer.append("JAVADOC_INLINE_TAG"); //$NON-NLS-1$ - break; - case CompletionProposal.JAVADOC_FIELD_REF: - buffer.append("JAVADOC_FIELD_REF"); //$NON-NLS-1$ - break; - case CompletionProposal.JAVADOC_METHOD_REF : - buffer.append("JAVADOC_METHOD_REF"); //$NON-NLS-1$ - break; - case CompletionProposal.JAVADOC_TYPE_REF : - buffer.append("JAVADOC_TYPE_REF"); //$NON-NLS-1$ - break; - case CompletionProposal.JAVADOC_PARAM_REF : - buffer.append("JAVADOC_PARAM_REF"); //$NON-NLS-1$ - break; - case CompletionProposal.JAVADOC_VALUE_REF : - buffer.append("JAVADOC_VALUE_REF"); //$NON-NLS-1$ - break; - case CompletionProposal.FIELD_IMPORT : - buffer.append("FIELD_IMPORT"); //$NON-NLS-1$ - break; - case CompletionProposal.METHOD_IMPORT : - buffer.append("METHOD_IMPORT"); //$NON-NLS-1$ - break; - case CompletionProposal.TYPE_IMPORT : - buffer.append("TYPE_IMPORT"); //$NON-NLS-1$ - break; - case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER : - buffer.append("METHOD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$ - break; - case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER : - buffer.append("FIELD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$ - break; - default : - buffer.append("PROPOSAL"); //$NON-NLS-1$ - break; - - } - buffer.append("]{completion:"); //$NON-NLS-1$ - if (this.completion != null) buffer.append(this.completion); - buffer.append(", declSign:"); //$NON-NLS-1$ - if (this.declarationSignature != null) buffer.append(this.declarationSignature); - buffer.append(", sign:"); //$NON-NLS-1$ - if (this.signature != null) buffer.append(this.signature); - buffer.append(", declKey:"); //$NON-NLS-1$ - if (this.declarationKey != null) buffer.append(this.declarationKey); - buffer.append(", key:"); //$NON-NLS-1$ - if (this.key != null) buffer.append(this.key); - buffer.append(", name:"); //$NON-NLS-1$ - if (this.name != null) buffer.append(this.name); - buffer.append(", replace:["); //$NON-NLS-1$ - buffer.append(this.replaceStart); - buffer.append(','); - buffer.append(this.replaceEnd); - buffer.append("], token:["); //$NON-NLS-1$ - buffer.append(this.tokenStart); - buffer.append(','); - buffer.append(this.tokenEnd); - buffer.append("], relevance:"); //$NON-NLS-1$ - buffer.append(this.relevance); - buffer.append('}'); - return buffer.toString(); + // default overridden by concrete implementation } }