Class CompletionProposal
In typical usage, the user working in a Java code editor issues
a code assist command. This command results in a call to
ICodeAssist.codeComplete(position, completionRequestor)
passing the current position in the source code. The code assist
engine analyzes the code in the buffer, determines what kind of
Java language construct is at that position, and proposes ways
to complete that construct. These proposals are instances of
the class CompletionProposal
. These proposals,
perhaps after sorting and filtering, are presented to the user
to make a choice.
The proposal is as follows: insert
the completion string into the
source file buffer, replacing the characters between
the start
and end. The string
can be arbitrary; for example, it might include not only the
name of a method but a set of parentheses. Moreover, the source
range may include source positions before or after the source
position where ICodeAssist.codeComplete
was invoked.
The rest of the information associated with the proposal is
to provide context that may help a user to choose from among
competing proposals.
The completion engine creates instances of this class.
- Since:
- 3.0
- See Also:
- Restriction:
- This class is not intended to be subclassed by clients.
- Restriction:
- This class is not intended to be instantiated by clients.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Completion is a reference to annotation's attribute.static final int
Completion is a reference of a constructor of an anonymous class.static final int
Completion is a declaration of an anonymous class.static final int
Completion is a reference to a constructor.static final int
Completion is an import of reference to a static field.static final int
Completion is a reference to a field.static final int
Completion is a reference to a field with a casted receiver.protected static final int
First valid completion kind.static final int
Completion is a javadoc block tag.static final int
Completion is a link reference to a field in a javadoc text.static final int
Completion is a javadoc inline tag.static final int
Completion is a link reference to a method in a javadoc text.static final int
Completion is a method argument or a class/method type parameter in javadoc param tag.static final int
Completion is a link reference to a type in a javadoc text.static final int
Completion is a value reference to a static field in a javadoc text.static final int
Completion is a keyword.static final int
Completion is a reference to a label.static final int
/** Completion is a lambda expression.protected static final int
Last valid completion kind.static final int
Completion is a reference to a local variable.static final int
Completion is a declaration of a method.static final int
Completion is an import of reference to a static method.static final int
Completion is a reference to a method name.static final int
Completion is a reference to a method.static final int
Completion is a reference to a method with a casted receiver.static final int
Completion is a declaration of a module.static final int
/** Completion is a reference to a module.static final int
Completion is a reference to a package.static final int
Completion is a declaration of a new potential method.static final int
Completion is an import of reference to a type.static final int
Completion is a reference to a type.static final int
Completion is a declaration of a variable (locals, parameters, fields, etc.). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canUseDiamond
(CompletionContext coreContext) Returns whether it is safe to use the'<>'
(diamond) operator in place of explicitly specifying type arguments for this proposal.static CompletionProposal
create
(int kind, int completionOffset) Creates a basic completion proposal.char[][]
findParameterNames
(org.eclipse.core.runtime.IProgressMonitor monitor) Finds the method parameter names.int
Returns the accessibility of the proposal.int
Returns the completion flags relevant in the context, orCompletionFlags.Default
if none.int
Returns the dimension count if this proposal holds a array completion.char[]
Returns the proposed sequence of characters to insert into the source file buffer, replacing the characters at the specified source range.int
Returns the character index in the source file buffer where source completion was requested (theoffset
parameter toICodeAssist.codeComplete
minus one).char[]
Returns the key of the relevant declaration in the context, ornull
if none.char[]
Returns the type signature or package name or module name (9) of the relevant declaration in the context, ornull
if none.int
getFlags()
Returns the modifier flags relevant in the context, orFlags.AccDefault
if none.char[]
getKey()
Returns the key relevant in the context, ornull
if none.int
getKind()
Returns the kind of completion being proposed.char[]
getName()
Returns the simple name of the method, field, member, or variable relevant in the context, ornull
if none.int
Returns the character index of the end (exclusive) of the subrange in the source file buffer containing the relevant receiver of the member being completedchar[]
Returns the type signature or package name of the relevant receiver in the context, ornull
if none.int
Returns the character index of the start of the subrange in the source file buffer containing the relevant receiver of the member being completed.int
Returns the relative relevance rating of this proposal.int
Returns the character index of the end of the subrange in the source file buffer to be replaced by the completion string.int
Returns the character index of the start of the subrange in the source file buffer to be replaced by the completion string.Returns the required completion proposals.char[]
Returns the signature of the method or type relevant in the context, ornull
if none.int
Returns the character index of the end (exclusive) of the subrange in the source file buffer containing the relevant token.int
Returns the character index of the start of the subrange in the source file buffer containing the relevant token being completed.boolean
Returns whether this proposal is a constructor.void
setAdditionalFlags
(int additionalFlags) Sets the completion flags relevant in the context.void
setCompletion
(char[] completion) Sets the proposed sequence of characters to insert into the source file buffer, replacing the characters at the specified source range.void
setDeclarationKey
(char[] key) Sets the type or package key of the relevant declaration in the context, ornull
if none.void
setDeclarationSignature
(char[] signature) Sets the type or package signature or module name (9) of the relevant declaration in the context, ornull
if none.void
setFlags
(int flags) Sets the modifier flags relevant in the context.void
setKey
(char[] key) Sets the key of the method, field type, member type, relevant in the context, ornull
if none.void
setName
(char[] name) Sets the simple name of the method (type simple name for constructor), field, member, or variable relevant in the context, ornull
if none.void
setParameterNames
(char[][] parameterNames) Sets the method parameter names.void
setReceiverRange
(int startIndex, int endIndex) Sets the character indices of the subrange in the source file buffer containing the relevant receiver of the member being completed.void
setReceiverSignature
(char[] signature) Sets the type or package signature of the relevant receiver in the context, ornull
if none.void
setRelevance
(int rating) Sets the relative relevance rating of this proposal.void
setReplaceRange
(int startIndex, int endIndex) Sets the character indices of the subrange in the source file buffer to be replaced by the completion string.void
setRequiredProposals
(CompletionProposal[] proposals) Sets the list of required completion proposals, ornull
if none.void
setSignature
(char[] signature) Sets the signature of the method, field type, member type, relevant in the context, ornull
if none.void
setTokenRange
(int startIndex, int endIndex) Sets the character indices of the subrange in the source file buffer containing the relevant token being completed.
-
Field Details
-
ANONYMOUS_CLASS_DECLARATION
public static final int ANONYMOUS_CLASS_DECLARATIONCompletion is a declaration of an anonymous class. This kind of completion might occur in a context like"new List(^;"
and complete it to"new List() {}"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type being implemented or subclassedgetDeclarationKey()
- the type unique key of the type being implemented or subclassedgetSignature()
- the method signature of the constructor that is referencedgetKey()
- the method unique key of the constructor that is referenced if the declaring type is not an interfacegetFlags()
- the modifiers flags of the constructor that is referenced
- See Also:
-
FIELD_REF
public static final int FIELD_REFCompletion is a reference to a field. This kind of completion might occur in a context like"this.ref^ = 0;"
and complete it to"this.refcount = 0;"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the field that is referencedgetFlags()
- the modifiers flags (including ACC_ENUM) of the field that is referencedgetName()
- the simple name of the field that is referencedgetSignature()
- the type signature of the field's type (as opposed to the signature of the type in which the referenced field is declared)
- See Also:
-
KEYWORD
public static final int KEYWORDCompletion is a keyword. This kind of completion might occur in a context like"public cl^ Foo {}"
and complete it to"public class Foo {}"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getName()
- the keyword tokengetFlags()
- the corresponding modifier flags if the keyword is a modifier
- See Also:
-
LABEL_REF
public static final int LABEL_REFCompletion is a reference to a label. This kind of completion might occur in a context like"break lo^;"
and complete it to"break loop;"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getName()
- the simple name of the label that is referenced
- See Also:
-
LOCAL_VARIABLE_REF
public static final int LOCAL_VARIABLE_REFCompletion is a reference to a local variable. This kind of completion might occur in a context like"ke^ = 4;"
and complete it to"keys = 4;"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getFlags()
- the modifiers flags of the local variable that is referencedgetName()
- the simple name of the local variable that is referencedgetSignature()
- the type signature of the local variable's type
- See Also:
-
METHOD_REF
public static final int METHOD_REFCompletion is a reference to a method. This kind of completion might occur in a context like"System.out.pr^();"
and complete it to""System.out.println();"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the method that is referencedgetFlags()
- the modifiers flags of the method that is referencedgetName()
- the simple name of the method that is referencedgetSignature()
- the method signature of the method that is referenced
- See Also:
-
METHOD_DECLARATION
public static final int METHOD_DECLARATIONCompletion is a declaration of a method. This kind of completion might occur in a context like"new List() {si^};"
and complete it to"new List() {public int size() {} };"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the method that is being overridden or implementedgetDeclarationKey()
- the unique of the type that declares the method that is being overridden or implementedgetName()
- the simple name of the method that is being overridden or implementedgetSignature()
- the method signature of the method that is being overridden or implementedgetKey()
- the method unique key of the method that is being overridden or implementedgetFlags()
- the modifiers flags of the method that is being overridden or implemented
- See Also:
-
PACKAGE_REF
public static final int PACKAGE_REFCompletion is a reference to a package. This kind of completion might occur in a context like"import java.u^.*;"
and complete it to"import java.util.*;"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the dot-based package name of the package that is referenced
- See Also:
-
TYPE_REF
public static final int TYPE_REFCompletion is a reference to a type. Any kind of type is allowed, including primitive types, reference types, array types, parameterized types, and type variables. This kind of completion might occur in a context like"public static Str^ key;"
and complete it to"public static String key;"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the dot-based package name of the package that contains the type that is referencedgetSignature()
- the type signature of the type that is referencedgetFlags()
- the modifiers flags (including Flags.AccInterface, AccEnum, and AccAnnotation) of the type that is referenced
- See Also:
-
VARIABLE_DECLARATION
public static final int VARIABLE_DECLARATIONCompletion is a declaration of a variable (locals, parameters, fields, etc.).The following additional context information is available for this kind of completion proposal at little extra cost:
getName()
- the simple name of the variable being declaredgetSignature()
- the type signature of the type of the variable being declaredgetFlags()
- the modifiers flags of the variable being declared
- See Also:
-
POTENTIAL_METHOD_DECLARATION
public static final int POTENTIAL_METHOD_DECLARATIONCompletion is a declaration of a new potential method. This kind of completion might occur in a context like"new List() {si^};"
and complete it to"new List() {public int si() {} };"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the method that is being createdgetName()
- the simple name of the method that is being createdgetSignature()
- the method signature of the method that is being createdgetFlags()
- the modifiers flags of the method that is being created
- Since:
- 3.1
- See Also:
-
METHOD_NAME_REFERENCE
public static final int METHOD_NAME_REFERENCECompletion is a reference to a method name. This kind of completion might occur in a context like"import p.X.fo^"
and complete it to"import p.X.foo;"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the method that is referencedgetFlags()
- the modifiers flags of the method that is referencedgetName()
- the simple name of the method that is referencedgetSignature()
- the method signature of the method that is referenced
- Since:
- 3.1
- See Also:
-
ANNOTATION_ATTRIBUTE_REF
public static final int ANNOTATION_ATTRIBUTE_REFCompletion is a reference to annotation's attribute. This kind of completion might occur in a context like"@Annot(attr^=value)"
and complete it to"@Annot(attribute^=value)"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the annotation that declares the attribute that is referencedgetFlags()
- the modifiers flags of the attribute that is referencedgetName()
- the simple name of the attribute that is referencedgetSignature()
- the type signature of the attribute's type (as opposed to the signature of the type in which the referenced attribute is declared)
- Since:
- 3.1
- See Also:
-
JAVADOC_FIELD_REF
public static final int JAVADOC_FIELD_REFCompletion is a link reference to a field in a javadoc text. This kind of completion might occur in a context like" * blabla System.o^ blabla"
and complete it to" * blabla {@link System#out } blabla"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the field that is referencedgetFlags()
- the modifiers flags (including ACC_ENUM) of the field that is referencedgetName()
- the simple name of the field that is referencedgetSignature()
- the type signature of the field's type (as opposed to the signature of the type in which the referenced field is declared)
- Since:
- 3.2
- See Also:
-
JAVADOC_METHOD_REF
public static final int JAVADOC_METHOD_REFCompletion is a link reference to a method in a javadoc text. This kind of completion might occur in a context like" * blabla Runtime#get^ blabla"
and complete it to" * blabla {@link Runtime#getRuntime() }"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the method that is referencedgetFlags()
- the modifiers flags of the method that is referencedgetName()
- the simple name of the method that is referencedgetSignature()
- the method signature of the method that is referenced
- Since:
- 3.2
- See Also:
-
JAVADOC_TYPE_REF
public static final int JAVADOC_TYPE_REFCompletion is a link reference to a type in a javadoc text. Any kind of type is allowed, including primitive types, reference types, array types, parameterized types, and type variables. This kind of completion might occur in a context like" * blabla Str^ blabla"
and complete it to" * blabla {@link String } blabla"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the dot-based package name of the package that contains the type that is referencedgetSignature()
- the type signature of the type that is referencedgetFlags()
- the modifiers flags (including Flags.AccInterface, AccEnum, and AccAnnotation) of the type that is referenced
- Since:
- 3.2
- See Also:
-
JAVADOC_VALUE_REF
public static final int JAVADOC_VALUE_REFCompletion is a value reference to a static field in a javadoc text. This kind of completion might occur in a context like" * blabla System.o^ blabla"
and complete it to" * blabla {@value System#out } blabla"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the field that is referencedgetFlags()
- the modifiers flags (including ACC_ENUM) of the field that is referencedgetName()
- the simple name of the field that is referencedgetSignature()
- the type signature of the field's type (as opposed to the signature of the type in which the referenced field is declared)
- Since:
- 3.2
- See Also:
-
JAVADOC_PARAM_REF
public static final int JAVADOC_PARAM_REFCompletion is a method argument or a class/method type parameter in javadoc param tag. This kind of completion might occur in a context like" * @param arg^ blabla"
and complete it to" * @param argument blabla"
. or" * @param <T^ blabla"
and complete it to" * @param <TT> blabla"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the field that is referencedgetFlags()
- the modifiers flags (including ACC_ENUM) of the field that is referencedgetName()
- the simple name of the field that is referencedgetSignature()
- the type signature of the field's type (as opposed to the signature of the type in which the referenced field is declared)
- Since:
- 3.2
- See Also:
-
JAVADOC_BLOCK_TAG
public static final int JAVADOC_BLOCK_TAGCompletion is a javadoc block tag. This kind of completion might occur in a context like" * @s^ blabla"
and complete it to" * @see blabla"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the field that is referencedgetFlags()
- the modifiers flags (including ACC_ENUM) of the field that is referencedgetName()
- the simple name of the field that is referencedgetSignature()
- the type signature of the field's type (as opposed to the signature of the type in which the referenced field is declared)
- Since:
- 3.2
- See Also:
-
JAVADOC_INLINE_TAG
public static final int JAVADOC_INLINE_TAGCompletion is a javadoc inline tag. This kind of completion might occur in a context like" * Insert @l^ Object"
and complete it to" * Insert {@link Object }"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the field that is referencedgetFlags()
- the modifiers flags (including ACC_ENUM) of the field that is referencedgetName()
- the simple name of the field that is referencedgetSignature()
- the type signature of the field's type (as opposed to the signature of the type in which the referenced field is declared)
- Since:
- 3.2
- See Also:
-
FIELD_IMPORT
public static final int FIELD_IMPORTCompletion is an import of reference to a static field.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the field that is importedgetFlags()
- the modifiers flags (including ACC_ENUM) of the field that is importedgetName()
- the simple name of the field that is importedgetSignature()
- the type signature of the field's type (as opposed to the signature of the type in which the referenced field is declared)getAdditionalFlags()
- the completion flags (including ComletionFlags.StaticImport) of the proposed import
- Since:
- 3.3
- See Also:
-
METHOD_IMPORT
public static final int METHOD_IMPORTCompletion is an import of reference to a static method.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the method that is importedgetFlags()
- the modifiers flags of the method that is importedgetName()
- the simple name of the method that is importedgetSignature()
- the method signature of the method that is importedgetAdditionalFlags()
- the completion flags (including ComletionFlags.StaticImport) of the proposed import
- Since:
- 3.3
- See Also:
-
TYPE_IMPORT
public static final int TYPE_IMPORTCompletion is an import of reference to a type. Only reference to reference types are allowed.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the dot-based package name of the package that contains the type that is importedgetSignature()
- the type signature of the type that is importedgetFlags()
- the modifiers flags (including Flags.AccInterface, AccEnum, and AccAnnotation) of the type that is importedgetAdditionalFlags()
- the completion flags (including ComletionFlags.StaticImport) of the proposed import
- Since:
- 3.3
- See Also:
-
METHOD_REF_WITH_CASTED_RECEIVER
public static final int METHOD_REF_WITH_CASTED_RECEIVERCompletion is a reference to a method with a casted receiver. This kind of completion might occur in a context like"receiver.fo^();"
and complete it to""((X)receiver).foo();"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the method that is referencedgetFlags()
- the modifiers flags of the method that is referencedgetName()
- the simple name of the method that is referencedgetReceiverSignature()
- the type signature of the receiver type. It's the type of the cast expression.getSignature()
- the method signature of the method that is referenced
- Since:
- 3.4
- See Also:
-
FIELD_REF_WITH_CASTED_RECEIVER
public static final int FIELD_REF_WITH_CASTED_RECEIVERCompletion is a reference to a field with a casted receiver. This kind of completion might occur in a context like"recevier.ref^ = 0;"
and complete it to"((X)receiver).refcount = 0;"
.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the field that is referencedgetFlags()
- the modifiers flags (including ACC_ENUM) of the field that is referencedgetName()
- the simple name of the field that is referencedgetReceiverSignature()
- the type signature of the receiver type. It's the type of the cast expression.getSignature()
- the type signature of the field's type (as opposed to the signature of the type in which the referenced field is declared)
- Since:
- 3.4
- See Also:
-
CONSTRUCTOR_INVOCATION
public static final int CONSTRUCTOR_INVOCATIONCompletion is a reference to a constructor. This kind of completion might occur in a context like"new Lis"
and complete it to"new List();"
if List is a class that is not abstract.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type that declares the constructor that is referencedgetFlags()
- the modifiers flags of the constructor that is referencedgetName()
- the simple name of the constructor that is referencedgetSignature()
- the method signature of the constructor that is referenced
This kind of proposal could require a long computation, so they are computed only if completion operation is called with a
IProgressMonitor
(e.g.ICodeAssist.codeComplete(int, CompletionRequestor, IProgressMonitor)
).
This kind of proposal is always is only proposals with aTYPE_REF
required proposal, so this kind of required proposal must be allowed:requestor.setAllowsRequiredProposals(CONSTRUCTOR_INVOCATION, TYPE_REF, true)
. -
ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION
public static final int ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATIONCompletion is a reference of a constructor of an anonymous class. This kind of completion might occur in a context like"new Lis^;"
and complete it to"new List() {}"
if List is an interface or abstract class.The following additional context information is available for this kind of completion proposal at little extra cost:
getDeclarationSignature()
- the type signature of the type being implemented or subclassedgetDeclarationKey()
- the type unique key of the type being implemented or subclassedgetSignature()
- the method signature of the constructor that is referencedgetKey()
- the method unique key of the constructor that is referenced if the declaring type is not an interfacegetFlags()
- the modifiers flags of the constructor that is referenced
This kind of proposal could require a long computation, so they are computed only if completion operation is called with a
IProgressMonitor
(e.g.ICodeAssist.codeComplete(int, CompletionRequestor, IProgressMonitor)
)
This kind of proposal is always is only proposals with aTYPE_REF
required proposal, so this kind of required proposal must be allowed:requestor.setAllowsRequiredProposals(CONSTRUCTOR_INVOCATION, TYPE_REF, true)
. -
MODULE_DECLARATION
public static final int MODULE_DECLARATIONCompletion is a declaration of a module. This kind of completion might occur in a module-info.java file after the keyword"module"
as shown below:"module co^"
and complete it to"module com.greetings"
.- Since:
- 3.14
- See Also:
-
MODULE_REF
public static final int MODULE_REF/** Completion is a reference to a module. This kind of completion might occur in a context like"requires com.g^"
and complete it to"requires com.greetings"
or in"to com.g^"
to"to com.greetings
- Since:
- 3.14
- See Also:
-
LAMBDA_EXPRESSION
public static final int LAMBDA_EXPRESSION/** Completion is a lambda expression. This kind of completion might occur in a context likeConsumer consumer = ^
and complete it to"Consumer consumer = c ->"
or in"to Consumer consumer = c -> {}"
- Since:
- 3.28
- See Also:
-
FIRST_KIND
protected static final int FIRST_KINDFirst valid completion kind.- Since:
- 3.1
- See Also:
-
LAST_KIND
protected static final int LAST_KINDLast valid completion kind.- Since:
- 3.1
- See Also:
-
-
Constructor Details
-
CompletionProposal
public CompletionProposal()
-
-
Method Details
-
create
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.
- Parameters:
kind
- one of the kind constants declared on this classcompletionOffset
- original offset of code completion request- Returns:
- a new completion proposal
-
getAdditionalFlags
public int getAdditionalFlags()Returns the completion flags relevant in the context, orCompletionFlags.Default
if none.This field is available for the following kinds of completion proposals:
FIELD_IMPORT
- completion flags of the attribute that is referenced. Completion flags for this proposal kind can only includeCompletionFlags.StaticImport
METHOD_IMPORT
- completion flags of the attribute that is referenced. Completion flags for this proposal kind can only includeCompletionFlags.StaticImport
TYPE_IMPORT
- completion flags of the attribute that is referenced. Completion flags for this proposal kind can only includeCompletionFlags.StaticImport
CompletionFlags.Default
.- Returns:
- the completion flags, or
CompletionFlags.Default
if none - Since:
- 3.3
- See Also:
-
setAdditionalFlags
public void setAdditionalFlags(int 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.
- Parameters:
additionalFlags
- the completion flags, orCompletionFlags.Default
if none- Since:
- 3.3
-
getKind
public int getKind()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.
- Returns:
- the kind; one of the kind constants declared on this class, or possibly a kind unknown to the caller
-
getCompletionLocation
public int getCompletionLocation()Returns the character index in the source file buffer where source completion was requested (theoffset
parameter toICodeAssist.codeComplete
minus one).- Returns:
- character index in source file buffer
- See Also:
-
getTokenStart
public int getTokenStart()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.- Returns:
- character index of token start position (inclusive)
-
getTokenEnd
public int getTokenEnd()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()
).- Returns:
- character index of token end position (exclusive)
-
setTokenRange
public void setTokenRange(int startIndex, int endIndex) 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).
- Parameters:
startIndex
- character index of token start position (inclusive)endIndex
- character index of token end position (exclusive)
-
getCompletion
public char[] getCompletion()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.
- Returns:
- the completion string
-
setCompletion
public void setCompletion(char[] 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.
- Parameters:
completion
- the completion string
-
getReplaceStart
public int getReplaceStart()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.
- Returns:
- replacement start position (inclusive)
-
getReplaceEnd
public int getReplaceEnd()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.- Returns:
- replacement end position (exclusive)
-
setReplaceRange
public void setReplaceRange(int startIndex, int endIndex) 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.
- Parameters:
startIndex
- character index of replacement start position (inclusive)endIndex
- character index of replacement end position (exclusive)
-
getRelevance
public int getRelevance()Returns the relative relevance rating of this proposal.- Returns:
- relevance rating of this proposal; ratings are positive; higher means better
-
setRelevance
public void setRelevance(int rating) 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.
- Parameters:
rating
- relevance rating of this proposal; ratings are positive; higher means better
-
getDeclarationSignature
public char[] getDeclarationSignature()Returns the type signature or package name or module name (9) of the relevant declaration in the context, ornull
if none.This field is available for the following kinds of completion proposals:
ANNOTATION_ATTRIBUT_REF
- type signature of the annotation that declares the attribute that is referencedANONYMOUS_CLASS_DECLARATION
- type signature of the type that is being subclassed or implementedFIELD_IMPORT
- type signature of the type that declares the field that is importedFIELD_REF
- type signature of the type that declares the field that is referencedFIELD_REF_WITH_CASTED_RECEIVER
- type signature of the type that declares the field that is referencedMETHOD_IMPORT
- type signature of the type that declares the method that is importedMETHOD_REF
- type signature of the type that declares the method that is referencedMETHOD_REF_WITH_CASTED_RECEIVER
- type signature of the type that declares the method that is referencedMETHOD_DECLARATION
- type signature of the type that declares the method that is being implemented or overriddenMODULE_DECLARATION
- possible name of the module that is being declaredMODULE_REF
- name of the module that is referencedPACKAGE_REF
- dot-based package name of the package that is referencedTYPE_IMPORT
- dot-based package name of the package containing the type that is importedTYPE_REF
- dot-based package name of the package containing the type that is referencedPOTENTIAL_METHOD_DECLARATION
- type signature of the type that declares the method that is being created
null
. Clients must not modify the array returned.- Returns:
- a type signature or a package name or module name (9) (depending
on the kind of completion), or
null
if none - See Also:
-
getDeclarationKey
public char[] getDeclarationKey()Returns the key of the relevant declaration in the context, ornull
if none.This field is available for the following kinds of completion proposals:
ANONYMOUS_CLASS_DECLARATION
- key of the type that is being subclassed or implementedMETHOD_DECLARATION
- key of the type that declares the method that is being implemented or overridden
null
. Clients must not modify the array returned.- Returns:
- a key, or
null
if none - Since:
- 3.1
- See Also:
-
setDeclarationSignature
public void setDeclarationSignature(char[] signature) Sets the type or package signature or module name (9) of the relevant declaration in the context, ornull
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.
- Parameters:
signature
- the type or package signature or module name(9) , ornull
if none
-
setDeclarationKey
public void setDeclarationKey(char[] key) Sets the type or package key of the relevant declaration in the context, ornull
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.
- Parameters:
key
- the type or package key, ornull
if none- Since:
- 3.1
-
getName
public char[] getName()Returns the simple name of the method, field, member, or variable relevant in the context, ornull
if none.This field is available for the following kinds of completion proposals:
ANNOTATION_ATTRIBUT_REF
- the name of the attributeFIELD_IMPORT
- the name of the fieldFIELD_REF
- the name of the fieldFIELD_REF_WITH_CASTED_RECEIVER
- the name of the fieldKEYWORD
- the keywordLABEL_REF
- the name of the labelLOCAL_VARIABLE_REF
- the name of the local variableMETHOD_IMPORT
- the name of the methodMETHOD_REF
- the name of the method (the type simple name for constructor)METHOD_REF_WITH_CASTED_RECEIVER
- the name of the methodMETHOD_DECLARATION
- the name of the method (the type simple name for constructor)VARIABLE_DECLARATION
- the name of the variablePOTENTIAL_METHOD_DECLARATION
- the name of the method
null
. Clients must not modify the array returned.- Returns:
- the keyword, field, method, local variable, or member
name, or
null
if none
-
setName
public void setName(char[] name) Sets the simple name of the method (type simple name for constructor), field, member, or variable relevant in the context, ornull
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.
- Parameters:
name
- the keyword, field, method, local variable, or member name, ornull
if none
-
getSignature
public char[] getSignature()Returns the signature of the method or type relevant in the context, ornull
if none.This field is available for the following kinds of completion proposals:
ANNOTATION_ATTRIBUT_REF
- the type signature of the referenced attribute's typeANONYMOUS_CLASS_DECLARATION
- method signature of the constructor that is being invokedFIELD_IMPORT
- the type signature of the referenced field's typeFIELD_REF
- the type signature of the referenced field's typeFIELD_REF_WITH_CASTED_RECEIVER
- the type signature of the referenced field's typeLOCAL_VARIABLE_REF
- the type signature of the referenced local variable's typeMETHOD_IMPORT
- method signature of the method that is importedMETHOD_REF
- method signature of the method that is referencedMETHOD_REF_WITH_CASTED_RECEIVER
- method signature of the method that is referencedMETHOD_DECLARATION
- method signature of the method that is being implemented or overriddenTYPE_IMPORT
- type signature of the type that is importedTYPE_REF
- type signature of the type that is referencedVARIABLE_DECLARATION
- the type signature of the type of the variable being declaredPOTENTIAL_METHOD_DECLARATION
- method signature of the method that is being created
null
. Clients must not modify the array returned.- Returns:
- the signature, or
null
if none - See Also:
-
getKey
public char[] getKey()Returns the key relevant in the context, ornull
if none.This field is available for the following kinds of completion proposals:
ANONYMOUS_CLASS_DECLARATION
- method key of the constructor that is being invoked, ornull
if the declaring type is an interfaceMETHOD_DECLARATION
- method key of the method that is being implemented or overridden
null
. Clients must not modify the array returned.- Returns:
- the key, or
null
if none - Since:
- 3.1
- See Also:
-
setSignature
public void setSignature(char[] signature) Sets the signature of the method, field type, member type, relevant in the context, ornull
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.
- Parameters:
signature
- the signature, ornull
if none
-
setKey
public void setKey(char[] key) Sets the key of the method, field type, member type, relevant in the context, ornull
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.
- Parameters:
key
- the key, ornull
if none- Since:
- 3.1
-
getFlags
public int getFlags()Returns the modifier flags relevant in the context, orFlags.AccDefault
if none.This field is available for the following kinds of completion proposals:
ANNOTATION_ATTRIBUT_REF
- modifier flags of the attribute that is referenced;ANONYMOUS_CLASS_DECLARATION
- modifier flags of the constructor that is referencedFIELD_IMPORT
- modifier flags of the field that is imported.FIELD_REF
- modifier flags of the field that is referenced;Flags.AccEnum
can be used to recognize references to enum constantsFIELD_REF_WITH_CASTED_RECEIVER
- modifier flags of the field that is referenced.KEYWORD
- modifier flag corresponding to the modifier keywordLOCAL_VARIABLE_REF
- modifier flags of the local variable that is referencedMETHOD_IMPORT
- modifier flags of the method that is imported;METHOD_REF
- modifier flags of the method that is referenced;Flags.AccAnnotation
can be used to recognize references to annotation type membersMETHOD_REF_WITH_CASTED_RECEIVER
- modifier flags of the method that is referenced.METHOD_DECLARATION
- modifier flags for the method that is being implemented or overriddenTYPE_IMPORT
- modifier flags of the type that is imported;Flags.AccInterface
can be used to recognize references to interfaces,Flags.AccEnum
enum types, andFlags.AccAnnotation
annotation typesTYPE_REF
- modifier flags of the type that is referenced;Flags.AccInterface
can be used to recognize references to interfaces,Flags.AccEnum
enum types, andFlags.AccAnnotation
annotation typesVARIABLE_DECLARATION
- modifier flags for the variable being declaredPOTENTIAL_METHOD_DECLARATION
- modifier flags for the method that is being created
Flags.AccDefault
.- Returns:
- the modifier flags, or
Flags.AccDefault
if none - See Also:
-
setFlags
public void setFlags(int 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.
- Parameters:
flags
- the modifier flags, orFlags.AccDefault
if none
-
getRequiredProposals
Returns the required completion proposals. The proposal can be apply only if these required completion proposals are also applied. If the required proposal aren't applied the completion could create completion problems.This field is available for the following kinds of completion proposals:
FIELD_REF
- The allowed required proposals for this kind are:TYPE_REF
TYPE_IMPORT
FIELD_IMPORT
METHOD_REF
- The allowed required proposals for this kind are:TYPE_REF
TYPE_IMPORT
METHOD_IMPORT
TYPE_REF
- The allowed required proposals for this kind are:TYPE_REF
CONSTRUCTOR_INVOCATION
- The allowed required proposals for this kind are:TYPE_REF
ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION
- The allowed required proposals for this kind are:TYPE_REF
ANONYMOUS_CLASS_DECLARATION
- The allowed required proposals for this kind are:TYPE_REF
Other kinds of required proposals will be returned in the future, therefore clients of this API must allow with
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
CompletionRequestor.isIgnored(int)
returntrue
for that kind.A required completion proposal cannot have required completion proposals.
- Returns:
- the required completion proposals, or
null
if none. - Since:
- 3.3
- See Also:
-
setRequiredProposals
Sets the list of required completion proposals, ornull
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.
- Parameters:
proposals
- the list of required completion proposals, ornull
if none- Since:
- 3.3
-
findParameterNames
public char[][] findParameterNames(org.eclipse.core.runtime.IProgressMonitor monitor) Finds the method parameter names. This information is relevant to method reference (and method declaration proposals). Returnsnull
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.
- Parameters:
monitor
- the progress monitor, ornull
if none- Returns:
- the parameter names, or
null
if none or not available or not relevant
-
setParameterNames
public void setParameterNames(char[][] 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.
- Parameters:
parameterNames
- the parameter names, ornull
if none
-
getAccessibility
public int getAccessibility()Returns the accessibility of the proposal.This field is available for the following kinds of completion proposals:
TYPE_REF
- accessibility of the type
IAccessRule.K_ACCESSIBLE
orIAccessRule.K_DISCOURAGED
orIAccessRule.K_NON_ACCESSIBLE
. By default this method returnIAccessRule.K_ACCESSIBLE
.- Returns:
- the accessibility of the proposal
- Since:
- 3.1
- See Also:
-
isConstructor
public boolean isConstructor()Returns whether this proposal is a constructor.This field is available for the following kinds of completion proposals:
METHOD_REF
- returntrue
if the referenced method is a constructorMETHOD_DECLARATION
- returntrue
if the declared method is a constructor
false
.- Returns:
true
if the proposal is a constructor.- Since:
- 3.1
-
getReceiverSignature
public char[] getReceiverSignature()Returns the type signature or package name of the relevant receiver in the context, ornull
if none.This field is available for the following kinds of completion proposals:
FIELD_REF_WITH_CASTED_RECEIVER
- type signature of the type that cast the receiver of the field that is referencedMETHOD_REF_WITH_CASTED_RECEIVER
- type signature of the type that cast the receiver of the method that is referenced
null
. Clients must not modify the array returned.- Returns:
- a type signature or a package name (depending
on the kind of completion), or
null
if none - Since:
- 3.4
- See Also:
-
getReceiverStart
public int getReceiverStart()Returns the character index of the start of the subrange in the source file buffer containing the relevant receiver of the member being completed. This receiver is an expression.This field is available for the following kinds of completion proposals:
FIELD_REF_WITH_CASTED_RECEIVER
METHOD_REF_WITH_CASTED_RECEIVER
0
.- Returns:
- character index of receiver start position (inclusive)
- Since:
- 3.4
-
getReceiverEnd
public int getReceiverEnd()Returns the character index of the end (exclusive) of the subrange in the source file buffer containing the relevant receiver of the member being completed. *This field is available for the following kinds of completion proposals:
FIELD_REF_WITH_CASTED_RECEIVER
METHOD_REF_WITH_CASTED_RECEIVER
0
.- Returns:
- character index of receiver end position (exclusive)
- Since:
- 3.4
-
setReceiverSignature
public void setReceiverSignature(char[] signature) Sets the type or package signature of the relevant receiver in the context, ornull
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.
- Parameters:
signature
- the type or package signature, ornull
if none- Since:
- 3.4
-
setReceiverRange
public void setReceiverRange(int startIndex, int endIndex) 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).
- Parameters:
startIndex
- character index of receiver start position (inclusive)endIndex
- character index of receiver end position (exclusive)- Since:
- 3.4
-
canUseDiamond
Returns whether it is safe to use the'<>'
(diamond) operator in place of explicitly specifying type arguments for this proposal.This is only relevant for source level 1.7 or greater.
- Parameters:
coreContext
- the completion context associated with the proposal- Returns:
true
if it is safe to use the diamond operator for the constructor invocation,false
otherwise. Also returnsfalse
for source levels below 1.7- Since:
- 3.7.1
-
getArrayDimensions
public int getArrayDimensions()Returns the dimension count if this proposal holds a array completion.This field is available for the following kinds of completion proposals:
TYPE_REF
- return dimension count if the referenced type is an array, otherwise0
.
0
.- Returns:
- dimension count or
0
for non arrayTYPE_REF
proposals. - Since:
- 3.34
-