Eclipse JDT
Release 3.0

org.eclipse.jdt.core
Class CompletionRequestor

java.lang.Object
  extended byorg.eclipse.jdt.core.CompletionRequestor

public abstract class CompletionRequestor
extends Object

Abstract base class for a completion requestor which is passed completion proposals as they are generated in response to a code assist request.

This class is intended to be subclassed by clients.

The code assist engine normally invokes methods on completion requestors in the following sequence:

 requestor.beginReporting();
 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.completionFailure(problem);
 requestor.endReporting();
 
In either case, the bracketing beginReporting endReporting calls are always made.

The class was introduced in 3.0 as a more evolvable replacement for the ICompletionRequestor interface.

Since:
3.0
See Also:
ICodeAssist

Constructor Summary
CompletionRequestor()
          Creates a new completion requestor.
 
Method Summary
abstract  void accept(CompletionProposal proposal)
          Proposes a completion.
 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.
 boolean isIgnored(int completionProposalKind)
          Returns whether the given kind of completion proposal is ignored.
 void setIgnored(int completionProposalKind, boolean ignore)
          Sets whether the given kind of completion proposal is ignored.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompletionRequestor

public CompletionRequestor()
Creates a new completion requestor. The requestor is interested in all kinds of completion proposals; none will be ignored.

Method Detail

isIgnored

public final boolean isIgnored(int completionProposalKind)
Returns whether the given kind of completion proposal is ignored.

Parameters:
completionProposalKind - one of the kind constants declared on CompletionProposal
Returns:
true if the given kind of completion proposal is ignored by this requestor, and false if it is of interest
See Also:
setIgnored(int, boolean), CompletionProposal.getKind()

setIgnored

public final void setIgnored(int completionProposalKind,
                             boolean ignore)
Sets whether the given kind of completion proposal is ignored.

Parameters:
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 interest
See Also:
isIgnored(int), CompletionProposal.getKind()

beginReporting

public void beginReporting()
Pro forma notification sent before reporting a batch of completion proposals.

The default implementation of this method does nothing. Clients may override.


endReporting

public void endReporting()
Pro forma notification sent after reporting a batch of completion proposals.

The default implementation of this method does nothing. Clients may override.


completionFailure

public void completionFailure(IProblem problem)
Notification of failure to produce any completions. The problem object explains what prevented completing.

The default implementation of this method does nothing. Clients may override to receive this kind of notice.

Parameters:
problem - the problem object

accept

public abstract void accept(CompletionProposal proposal)
Proposes a completion. Has no effect if the kind of proposal is being ignored by this requestor. Callers should consider checking 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 in only valid for the duration of this call; implementors must not hang on to these objects.

Parameters:
proposal - the completion proposal
Throws:
IllegalArgumentException - if the proposal is null

Eclipse JDT
Release 3.0

Copyright (c) IBM Corp. and others 2000, 2004. All Rights Reserved.