|
Eclipse JDT Release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jdt.core.CompletionProposal
Completion proposal.
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
subclasses of 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; it is not intended to be used by other clients.
ICodeAssist.codeComplete(int, CompletionRequestor)
Field Summary | |
static int |
ANONYMOUS_CLASS_DECLARATION
Completion is a declaration of an anonymous class. |
static int |
FIELD_REF
Completion is a reference to a field. |
static int |
KEYWORD
Completion is a keyword. |
static int |
LABEL_REF
Completion is a reference to a label. |
static int |
LOCAL_VARIABLE_REF
Completion is a reference to a local variable. |
static int |
METHOD_DECLARATION
Completion is a declaration of a method. |
static int |
METHOD_REF
Completion is a reference to a method. |
static int |
PACKAGE_REF
Completion is a reference to a package. |
static int |
TYPE_REF
Completion is a reference to a type. |
static int |
VARIABLE_DECLARATION
Completion is a declaration of a variable (locals, parameters, fields, etc.). |
Method Summary | |
static CompletionProposal |
create(int kind,
int completionOffset)
Creates a basic completion proposal. |
char[][] |
findParameterNames(IProgressMonitor monitor)
Finds the method parameter names. |
char[] |
getCompletion()
Returns the proposed sequence of characters to insert into the source file buffer, replacing the characters at the specified source range. |
int |
getCompletionLocation()
Returns the character index in the source file buffer where source completion was requested (the offset parameter to
ICodeAssist.codeComplete . |
char[] |
getDeclarationSignature()
Returns the type or package signature of the relevant declaration in the context, or null if none.
|
int |
getFlags()
Returns the modifier flags relevant in the context, or Flags.AccDefault 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, or null if none.
|
int |
getRelevance()
Returns the relative relevance rating of this proposal. |
int |
getReplaceEnd()
Returns the character index of the end of the subrange in the source file buffer to be replaced by the completion string. |
int |
getReplaceStart()
Returns the character index of the start of the subrange in the source file buffer to be replaced by the completion string. |
char[] |
getSignature()
Returns the signature of the method or type relevant in the context, or null if none.
|
int |
getTokenEnd()
Returns the character index of the end (exclusive) of the subrange in the source file buffer containing the relevant token. |
int |
getTokenStart()
Returns the character index of the start of the subrange in the source file buffer containing the relevant token being completed. |
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 |
setDeclarationSignature(char[] signature)
Sets the type or package signature of the relevant declaration in the context, or null if none.
|
void |
setFlags(int flags)
Sets the modifier flags relevant in the context. |
void |
setName(char[] name)
Sets the simple name of the method, field, member, or variable relevant in the context, or null if none.
|
void |
setParameterNames(char[][] parameterNames)
Sets the method parameter names. |
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 |
setSignature(char[] signature)
Sets the signature of the method, field type, member type, relevant in the context, or null 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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int ANONYMOUS_CLASS_DECLARATION
"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 subclassed
getSignature()
-
the method signature of the constructor that is referenced
getFlags()
-
the modifiers flags of the constructor that is referenced
getKind()
,
Constant Field Valuespublic static final int FIELD_REF
"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 referenced
getFlags()
-
the modifiers flags (including ACC_ENUM) of the field that is referenced
getName()
-
the simple name of the field that is referenced
getSignature()
-
the type signature of the field's type (as opposed to the
signature of the type in which the referenced field
is declared)
getKind()
,
Constant Field Valuespublic static final int KEYWORD
"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 token
getFlags()
-
the corresponding modifier flags if the keyword is a modifier
getKind()
,
Constant Field Valuespublic static final int LABEL_REF
"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
getKind()
,
Constant Field Valuespublic static final int LOCAL_VARIABLE_REF
"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 referenced
getName()
-
the simple name of the local variable that is referenced
getSignature()
-
the type signature of the local variable's type
getKind()
,
Constant Field Valuespublic static final int METHOD_REF
"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 referenced
getFlags()
-
the modifiers flags of the method that is referenced
getName()
-
the simple name of the method that is referenced
getSignature()
-
the method signature of the method that is referenced
getKind()
,
Constant Field Valuespublic static final int METHOD_DECLARATION
"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 implemented
getName()
-
the simple name of the method that is being overridden
or implemented
getSignature()
-
the method signature of the method that is being
overridden or implemented
getFlags()
-
the modifiers flags of the method that is being
overridden or implemented
getKind()
,
Constant Field Valuespublic static final int PACKAGE_REF
"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 signature of the package that is referenced
getKind()
,
Constant Field Valuespublic static final int TYPE_REF
"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 signature of the package that contains
the type that is referenced
getSignature()
-
the type signature of the type that is referenced
getFlags()
-
the modifiers flags (including Flags.AccInterface, AccEnum,
and AccAnnotation) of the type that is referenced
getKind()
,
Constant Field Valuespublic static final int VARIABLE_DECLARATION
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 declared
getSignature()
-
the type signature of the type of the variable
being declared
getFlags()
-
the modifiers flags of the variable being declared
getKind()
,
Constant Field ValuesMethod Detail |
public static CompletionProposal create(int kind, int completionOffset)
Note that the constructors for this class are internal to the Java model implementation. Clients cannot directly create CompletionProposal objects.
kind
- one of the kind constants declared on this classcompletionOffset
- original offset of code completion request
public int getKind()
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.
public int getCompletionLocation()
offset
parameter to
ICodeAssist.codeComplete
.
ICodeAssist.codeComplete(int,CompletionRequestor)
public int getTokenStart()
public int getTokenEnd()
getEndToken() == getStartToken()
).
public void setTokenRange(int startIndex, int endIndex)
If not set, defaults to empty subrange at [0,0).
startIndex
- character index of token start position (inclusive)endIndex
- character index of token end position (exclusive)public char[] getCompletion()
The client must not modify the array returned.
public void setCompletion(char[] completion)
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.
completion
- the completion stringpublic int getReplaceStart()
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, a 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.
public int getReplaceEnd()
getReplaceEnd() == getReplaceStart()
),
the completion string is to be inserted at this
index.
public void setReplaceRange(int startIndex, int endIndex)
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.
startIndex
- character index of replacement start position (inclusive)endIndex
- character index of replacement end position (exclusive)public int getRelevance()
public void setRelevance(int rating)
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.
rating
- relevance rating of this proposal; ratings are positive; higher means betterpublic char[] getDeclarationSignature()
null
if none.
This field is available for the following kinds of completion proposals:
ANONYMOUS_CLASS_DECLARATION
- type signature
of the type that is being subclassed or implementedFIELD_REF
- type signature
of the type that declares the field that is referencedMETHOD_REF
- type signature
of the type that declares the method that is referencedMETHOD_DECLARATION
- type signature
of the type that declares the method that is being
implemented or overriddenPACKAGE_REF
- dot-based package
signature of the package that is referencedTYPE_REF
- dot-based package
signature of the package containing the type that is referencednull
. Clients must not modify the array
returned.
null
if noneSignature
public void setDeclarationSignature(char[] signature)
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.
signature
- the type or package signature, or
null
if nonepublic char[] getName()
null
if none.
This field is available for the following kinds of completion proposals:
FIELD_REF
- the name of the fieldKEYWORD
- the keywordLABEL_REF
- the name of the labelLOCAL_VARIABLE_REF
- the name of the local variableMETHOD_REF
- the name of the methodMETHOD_DECLARATION
- the name of the methodVARIABLE_DECLARATION
- the name of the variablenull
. Clients must not modify the array
returned.
null
if nonepublic void setName(char[] name)
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.
name
- the keyword, field, method, local variable,
or member name, or null
if nonepublic char[] getSignature()
null
if none.
This field is available for the following kinds of completion proposals:
ANONYMOUS_CLASS_DECLARATION
- method signature
of the constructor that is being invokedFIELD_REF
- the type signature
of the referenced field's typeLOCAL_VARIABLE_REF
- the type signature
of the referenced local variable's typeMETHOD_REF
- method signature
of the method that is referencedMETHOD_DECLARATION
- method signature
of the method that is being implemented or overriddenTYPE_REF
- type signature
of the type that is referencedVARIABLE_DECLARATION
- the type signature
of the type of the variable being declarednull
. Clients must not modify the array
returned.
null
if noneSignature
public void setSignature(char[] signature)
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.
signature
- the signature, or null
if nonepublic int getFlags()
Flags.AccDefault
if none.
This field is available for the following kinds of completion proposals:
ANONYMOUS_CLASS_DECLARATION
- modifier flags
of the constructor that is referencedFIELD_REF
- modifier flags
of the field that is referenced;
Flags.AccEnum
can be used to recognize
references to enum constants
KEYWORD
- modifier flag
corrresponding to the modifier keywordLOCAL_VARIABLE_REF
- modifier flags
of the local variable that is referencedMETHOD_REF
- modifier flags
of the method that is referenced;
Flags.AccAnnotation
can be used to recognize
references to annotation type members
METHOD_DECLARATION
- modifier flags
for the method that is being implemented or overriddenTYPE_REF
- modifier flags
of the type that is referenced; Flags.AccInterface
can be used to recognize references to interfaces,
Flags.AccEnum
enum types,
and Flags.AccAnnotation
annotation types
VARIABLE_DECLARATION
- modifier flags
for the variable being declaredFlags.AccDefault
.
Flags.AccDefault
if noneFlags
public void setFlags(int flags)
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.
flags
- the modifier flags, or
Flags.AccDefault
if nonepublic char[][] findParameterNames(IProgressMonitor monitor)
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.
monitor
- the progress monitor, or null
if none
null
if none
or not available or not relevantpublic void setParameterNames(char[][] parameterNames)
The completion engine creates instances of this class and sets its properties; this method is not intended to be used by other clients.
parameterNames
- the parameter names, or null
if none
|
Eclipse JDT Release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |