org.eclipse.xtext.ui.editor.contentassist
Class ConfigurableCompletionProposal

java.lang.Object
  extended by org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal
All Implemented Interfaces:
java.lang.Comparable<ConfigurableCompletionProposal>, org.eclipse.jface.text.contentassist.ICompletionProposal, org.eclipse.jface.text.contentassist.ICompletionProposalExtension, org.eclipse.jface.text.contentassist.ICompletionProposalExtension2, org.eclipse.jface.text.contentassist.ICompletionProposalExtension3, org.eclipse.jface.text.contentassist.ICompletionProposalExtension4, org.eclipse.jface.text.contentassist.ICompletionProposalExtension5, org.eclipse.jface.text.contentassist.ICompletionProposalExtension6
Direct Known Subclasses:
ImportOrganizingProposal

public class ConfigurableCompletionProposal
extends java.lang.Object
implements java.lang.Comparable<ConfigurableCompletionProposal>, org.eclipse.jface.text.contentassist.ICompletionProposal, org.eclipse.jface.text.contentassist.ICompletionProposalExtension, org.eclipse.jface.text.contentassist.ICompletionProposalExtension2, org.eclipse.jface.text.contentassist.ICompletionProposalExtension3, org.eclipse.jface.text.contentassist.ICompletionProposalExtension4, org.eclipse.jface.text.contentassist.ICompletionProposalExtension5, org.eclipse.jface.text.contentassist.ICompletionProposalExtension6

Author:
Sebastian Zarnekow - Initial contribution and API, Michael Clay, Christoph Kulla - Added support for hovers

Nested Class Summary
protected static class ConfigurableCompletionProposal.ExitPolicy
           
static interface ConfigurableCompletionProposal.IReplacementTextApplier
           
 
Constructor Summary
ConfigurableCompletionProposal(java.lang.String replacementString, int replacementOffset, int replacementLength, int cursorPosition)
          Creates a new completion proposal based on the provided information.
ConfigurableCompletionProposal(java.lang.String replacementString, int replacementOffset, int replacementLength, int cursorPosition, org.eclipse.swt.graphics.Image image, org.eclipse.jface.viewers.StyledString displayString, org.eclipse.jface.text.contentassist.IContextInformation contextInformation, java.lang.String additionalProposalInfo)
          Creates a new completion proposal.
 
Method Summary
 void apply(org.eclipse.jface.text.IDocument document)
           
 void apply(org.eclipse.jface.text.IDocument document, char trigger, int offset)
           
 void apply(org.eclipse.jface.text.ITextViewer viewer, char trigger, int stateMask, int offset)
           
 int compareTo(ConfigurableCompletionProposal other)
           
 boolean equals(java.lang.Object obj)
           
 java.lang.String getAdditionalProposalInfo()
           
 java.lang.Object getAdditionalProposalInfo(org.eclipse.core.runtime.IProgressMonitor monitor)
           
 org.eclipse.jface.text.contentassist.IContextInformation getContextInformation()
           
 int getContextInformationPosition()
           
 int getCursorPosition()
           
 java.lang.String getDisplayString()
           
 org.eclipse.swt.graphics.Image getImage()
           
 org.eclipse.jface.text.IInformationControlCreator getInformationControlCreator()
           
 PrefixMatcher getMatcher()
           
 int getPrefixCompletionStart(org.eclipse.jface.text.IDocument document, int completionOffset)
           
 java.lang.CharSequence getPrefixCompletionText(org.eclipse.jface.text.IDocument document, int completionOffset)
           
 int getPriority()
           
 int getReplaceContextLength()
           
 int getReplacementLength()
           
 int getReplacementOffset()
           
 java.lang.String getReplacementString()
           
 org.eclipse.swt.graphics.Point getSelection(org.eclipse.jface.text.IDocument document)
           
 int getSelectionLength()
           
 int getSelectionStart()
           
 org.eclipse.jface.viewers.StyledString getStyledDisplayString()
           
 ConfigurableCompletionProposal.IReplacementTextApplier getTextApplier()
           
 char[] getTriggerCharacters()
           
 int hashCode()
           
 boolean isAutoInsertable()
           
protected  boolean isLinkedMode()
           
 boolean isValidFor(org.eclipse.jface.text.IDocument document, int offset)
           
 void selected(org.eclipse.jface.text.ITextViewer viewer, boolean smartToggle)
           
 void setAdditionalProposalInfo(java.lang.Object additionalProposalInfo)
           
 void setAutoInsertable(boolean autoInsertable)
           
 void setContextInformation(org.eclipse.jface.text.contentassist.IContextInformation contextInformation)
           
 void setCursorPosition(int cursorPosition)
           
 void setDisplayString(java.lang.String displayString)
           
 void setDisplayString(org.eclipse.jface.viewers.StyledString displayString)
           
 void setHover(IEObjectHover hover)
           
 void setImage(org.eclipse.swt.graphics.Image image)
           
 void setMatcher(PrefixMatcher matcher)
           
 void setPriority(int priority)
           
 void setReplaceContextLength(int replaceContextLength)
           
 void setReplacementLength(int replacementLength)
           
 void setReplacementOffset(int replacementOffset)
           
 void setReplacementString(java.lang.String replacementString)
           
 void setSelectionLength(int selectionLength)
           
 void setSelectionStart(int selectionStart)
           
 void setSimpleLinkedMode(org.eclipse.jface.text.ITextViewer viewer, char... exitChars)
           
 void setTextApplier(ConfigurableCompletionProposal.IReplacementTextApplier textApplier)
           
 void setTriggerCharacters(char[] triggerChars)
           
protected  void setUpLinkedMode(org.eclipse.jface.text.IDocument document)
          Sets up a simple linked mode at getCursorPosition() and an exit policy that will exit the mode when closingCharacter is typed and an exit position at getCursorPosition() + 1.
 java.lang.String toString()
           
 void unselected(org.eclipse.jface.text.ITextViewer viewer)
           
 boolean validate(org.eclipse.jface.text.IDocument document, int offset, org.eclipse.jface.text.DocumentEvent event)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConfigurableCompletionProposal

public ConfigurableCompletionProposal(java.lang.String replacementString,
                                      int replacementOffset,
                                      int replacementLength,
                                      int cursorPosition)
Creates a new completion proposal based on the provided information. The replacement string is considered being the display string too. All remaining fields are set to null.

Parameters:
replacementString - the actual string to be inserted into the document
replacementOffset - the offset of the text to be replaced
replacementLength - the length of the text to be replaced
cursorPosition - the position of the cursor following the insert relative to replacementOffset

ConfigurableCompletionProposal

public ConfigurableCompletionProposal(java.lang.String replacementString,
                                      int replacementOffset,
                                      int replacementLength,
                                      int cursorPosition,
                                      org.eclipse.swt.graphics.Image image,
                                      org.eclipse.jface.viewers.StyledString displayString,
                                      org.eclipse.jface.text.contentassist.IContextInformation contextInformation,
                                      java.lang.String additionalProposalInfo)
Creates a new completion proposal. All fields are initialized based on the provided information.

Parameters:
replacementString - the actual string to be inserted into the document
replacementOffset - the offset of the text to be replaced
replacementLength - the length of the text to be replaced
cursorPosition - the position of the cursor following the insert relative to replacementOffset
image - the image to display for this proposal
displayString - the string to be displayed for the proposal
contextInformation - the context information associated with this proposal
additionalProposalInfo - the additional information associated with this proposal
Method Detail

apply

public void apply(org.eclipse.jface.text.IDocument document)
Specified by:
apply in interface org.eclipse.jface.text.contentassist.ICompletionProposal

getSelection

public org.eclipse.swt.graphics.Point getSelection(org.eclipse.jface.text.IDocument document)
Specified by:
getSelection in interface org.eclipse.jface.text.contentassist.ICompletionProposal

getContextInformation

public org.eclipse.jface.text.contentassist.IContextInformation getContextInformation()
Specified by:
getContextInformation in interface org.eclipse.jface.text.contentassist.ICompletionProposal

getImage

public org.eclipse.swt.graphics.Image getImage()
Specified by:
getImage in interface org.eclipse.jface.text.contentassist.ICompletionProposal

getDisplayString

public java.lang.String getDisplayString()
Specified by:
getDisplayString in interface org.eclipse.jface.text.contentassist.ICompletionProposal

getStyledDisplayString

public org.eclipse.jface.viewers.StyledString getStyledDisplayString()
Specified by:
getStyledDisplayString in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension6

getAdditionalProposalInfo

public java.lang.String getAdditionalProposalInfo()
Specified by:
getAdditionalProposalInfo in interface org.eclipse.jface.text.contentassist.ICompletionProposal

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isAutoInsertable

public boolean isAutoInsertable()
Specified by:
isAutoInsertable in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension4

setAutoInsertable

public void setAutoInsertable(boolean autoInsertable)

getReplacementString

public java.lang.String getReplacementString()

getReplacementOffset

public int getReplacementOffset()

getReplacementLength

public int getReplacementLength()

getCursorPosition

public int getCursorPosition()

setDisplayString

public void setDisplayString(java.lang.String displayString)

setDisplayString

public void setDisplayString(org.eclipse.jface.viewers.StyledString displayString)

setReplacementString

public void setReplacementString(java.lang.String replacementString)

setReplacementOffset

public void setReplacementOffset(int replacementOffset)

setReplacementLength

public void setReplacementLength(int replacementLength)

setCursorPosition

public void setCursorPosition(int cursorPosition)

setImage

public void setImage(org.eclipse.swt.graphics.Image image)

setContextInformation

public void setContextInformation(org.eclipse.jface.text.contentassist.IContextInformation contextInformation)

setAdditionalProposalInfo

public void setAdditionalProposalInfo(java.lang.Object additionalProposalInfo)

getSelectionStart

public int getSelectionStart()

getSelectionLength

public int getSelectionLength()

setSelectionLength

public void setSelectionLength(int selectionLength)

setSelectionStart

public void setSelectionStart(int selectionStart)

setSimpleLinkedMode

public void setSimpleLinkedMode(org.eclipse.jface.text.ITextViewer viewer,
                                char... exitChars)

isLinkedMode

protected boolean isLinkedMode()
Since:
2.2

apply

public void apply(org.eclipse.jface.text.ITextViewer viewer,
                  char trigger,
                  int stateMask,
                  int offset)
Specified by:
apply in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension2

apply

public void apply(org.eclipse.jface.text.IDocument document,
                  char trigger,
                  int offset)
Specified by:
apply in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension
Since:
2.3

isValidFor

public boolean isValidFor(org.eclipse.jface.text.IDocument document,
                          int offset)
Specified by:
isValidFor in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension
Since:
2.3

getContextInformationPosition

public int getContextInformationPosition()
Specified by:
getContextInformationPosition in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension
Since:
2.3

getTriggerCharacters

public char[] getTriggerCharacters()
Specified by:
getTriggerCharacters in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension
Since:
2.3

setTriggerCharacters

public void setTriggerCharacters(char[] triggerChars)
Since:
2.3

selected

public void selected(org.eclipse.jface.text.ITextViewer viewer,
                     boolean smartToggle)
Specified by:
selected in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension2

unselected

public void unselected(org.eclipse.jface.text.ITextViewer viewer)
Specified by:
unselected in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension2

validate

public boolean validate(org.eclipse.jface.text.IDocument document,
                        int offset,
                        org.eclipse.jface.text.DocumentEvent event)
Specified by:
validate in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension2

setMatcher

public void setMatcher(PrefixMatcher matcher)

getMatcher

public PrefixMatcher getMatcher()

setReplaceContextLength

public void setReplaceContextLength(int replaceContextLength)

getReplaceContextLength

public int getReplaceContextLength()

setPriority

public void setPriority(int priority)

getPriority

public int getPriority()

compareTo

public int compareTo(ConfigurableCompletionProposal other)
Specified by:
compareTo in interface java.lang.Comparable<ConfigurableCompletionProposal>

setUpLinkedMode

protected void setUpLinkedMode(org.eclipse.jface.text.IDocument document)
Sets up a simple linked mode at getCursorPosition() and an exit policy that will exit the mode when closingCharacter is typed and an exit position at getCursorPosition() + 1.

Parameters:
document - the document

setTextApplier

public void setTextApplier(ConfigurableCompletionProposal.IReplacementTextApplier textApplier)

getTextApplier

public ConfigurableCompletionProposal.IReplacementTextApplier getTextApplier()

getInformationControlCreator

public org.eclipse.jface.text.IInformationControlCreator getInformationControlCreator()
Specified by:
getInformationControlCreator in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension3

getPrefixCompletionText

public java.lang.CharSequence getPrefixCompletionText(org.eclipse.jface.text.IDocument document,
                                                      int completionOffset)
Specified by:
getPrefixCompletionText in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension3

getPrefixCompletionStart

public int getPrefixCompletionStart(org.eclipse.jface.text.IDocument document,
                                    int completionOffset)
Specified by:
getPrefixCompletionStart in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension3

setHover

public void setHover(IEObjectHover hover)

getAdditionalProposalInfo

public java.lang.Object getAdditionalProposalInfo(org.eclipse.core.runtime.IProgressMonitor monitor)
Specified by:
getAdditionalProposalInfo in interface org.eclipse.jface.text.contentassist.ICompletionProposalExtension5

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object