public abstract class CompletionRequestor
extends java.lang.Object
This class is intended to be subclassed by clients.
The code assist engine normally invokes methods on completion requestor in the following sequence:
requestor.beginReporting(); requestor.acceptContext(context); requestor.accept(proposal_1); requestor.accept(proposal_2); ... requestor.endReporting();If, however, the engine is unable to offer completion proposals for whatever reason,
completionFailure
is called
with a problem object describing why completions were unavailable.
In this case, the sequence of calls is:
requestor.beginReporting(); requestor.acceptContext(context); requestor.completionFailure(problem); requestor.endReporting();In either case, the bracketing
beginReporting
endReporting
calls are always made as well as
acceptContext
call.
Constructor and Description |
---|
CompletionRequestor()
Creates a new completion requestor.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
accept(CompletionProposal proposal)
Proposes a completion.
|
void |
acceptContext(CompletionContext context)
Propose the context in which the completion occurs.
|
void |
beginReporting()
Pro forma notification sent before reporting a batch of
completion proposals.
|
void |
completionFailure(IProblem problem)
Notification of failure to produce any completions.
|
void |
endReporting()
Pro forma notification sent after reporting a batch of
completion proposals.
|
java.lang.String[] |
getFavoriteReferences()
Returns the favorite references which are used to compute some completion proposals.
|
boolean |
isAllowingRequiredProposals(int proposalKind,
int requiredProposalKind)
Returns whether a proposal of a given kind with a required proposal
of the given kind is allowed.
|
boolean |
isIgnored(int completionProposalKind)
Returns whether the given kind of completion proposal is ignored.
|
void |
setAllowsRequiredProposals(int proposalKind,
int requiredProposalKind,
boolean allow)
Sets whether a proposal of a given kind with a required proposal
of the given kind is allowed.
|
void |
setFavoriteReferences(java.lang.String[] favoriteImports)
Set the favorite references which will be used to compute some completion proposals.
|
void |
setIgnored(int completionProposalKind,
boolean ignore)
Sets whether the given kind of completion proposal is ignored.
|
public CompletionRequestor()
public boolean isIgnored(int completionProposalKind)
completionProposalKind
- one of the kind constants declared
on CompletionProposal
true
if the given kind of completion proposal
is ignored by this requestor, and false
if it is of
interestsetIgnored(int, boolean)
,
CompletionProposal.getKind()
public void setIgnored(int completionProposalKind, boolean ignore)
completionProposalKind
- one of the kind constants declared
on CompletionProposal
ignore
- true
if the given kind of completion proposal
is ignored by this requestor, and false
if it is of
interestisIgnored(int)
,
CompletionProposal.getKind()
public boolean isAllowingRequiredProposals(int proposalKind, int requiredProposalKind)
proposalKind
- one of the kind constants declaredrequiredProposalKind
- one of the kind constants declared
on CompletionProposal
true
if a proposal of a given kind with a required proposal
of the given kind is allowed by this requestor, and false
if it isn't of interest.
By default, all kinds of required proposals aren't allowed.
setAllowsRequiredProposals(int, int, boolean)
,
CompletionProposal.getKind()
,
CompletionProposal.getRequiredProposals()
public void setAllowsRequiredProposals(int proposalKind, int requiredProposalKind, boolean allow)
CompletionProposal.getRequiredProposals()
documentation.proposalKind
- one of the kind constants declaredrequiredProposalKind
- one of the kind constants declared
on CompletionProposal
allow
- true
if a proposal of a given kind with a required proposal
of the given kind is allowed by this requestor, and false
if it isn't of interestisAllowingRequiredProposals(int, int)
,
CompletionProposal.getKind()
,
CompletionProposal.getRequiredProposals()
public java.lang.String[] getFavoriteReferences()
Currently only on demand type references ("java.util.Arrays.*"
),
references to a static method or a static field are used to compute completion proposals.
Other kind of reference could be used in the future.
Note: This Method only applies to ECMAScript 4 which is not yet supported
public void setFavoriteReferences(java.lang.String[] favoriteImports)
Note: This Method only applies to ECMAScript 4 which is not yet supported
favoriteImports
- getFavoriteReferences()
public void beginReporting()
The default implementation of this method does nothing. Clients may override.
public void endReporting()
The default implementation of this method does nothing. Clients may override.
public void completionFailure(IProblem problem)
The default implementation of this method does nothing. Clients may override to receive this kind of notice.
problem
- the problem objectpublic abstract void accept(CompletionProposal proposal)
isIgnored(int)
before avoid creating proposal
objects that would only be ignored.
Similarly, implementers should check
isIgnored(proposal.getKind())
and ignore proposals that have been declared as uninteresting.
The proposal object passed is only valid for the duration of
completion operation.
proposal
- the completion proposaljava.lang.IllegalArgumentException
- if the proposal is nullpublic void acceptContext(CompletionContext context)
This method is called one and only one time before any call to
accept(CompletionProposal)
.
The default implementation of this method does nothing.
Clients may override.
context
- the completion contextCopyright (c) IBM Corp. and others 2000, 2010. All Rights Reserved.