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

java.lang.Object
  extended by org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext

public class ContentAssistContext
extends java.lang.Object

Abstraction of a commonly used set of attributes related to the current content assist request.

Author:
Michael Clay - Initial contribution and API, Sebastian Zarnekow

Nested Class Summary
static class ContentAssistContext.Builder
           
static interface ContentAssistContext.Factory
           
 
Constructor Summary
protected ContentAssistContext()
          Protected contructor to allow subclassing.
 
Method Summary
 ContentAssistContext.Builder copy()
          Use this context as prototype for a new mutable builder.
 org.eclipse.emf.ecore.EObject getCurrentModel()
          The model that covers the completion offset and has a grammar element assigned that has the expected grammar element at the given offset in its call hierarchy.
 INode getCurrentNode()
          The current node which is part of the current completion offset.
 IXtextDocument getDocument()
          The actual document.
 com.google.common.collect.ImmutableList<AbstractElement> getFirstSetGrammarElements()
          The grammar elements that may occur at the given offset.
 INode getLastCompleteNode()
          The last non-hidden node before the offset that is considered to be complete.
 PrefixMatcher getMatcher()
          The matching algorithm to choose proposals according to the completion prefix.
 int getOffset()
          The completion offset in the text viewer.
 java.lang.String getPrefix()
          The prefix string that is used to match the validity of proposals.
 org.eclipse.emf.ecore.EObject getPreviousModel()
          The model element that is valid for the position left of the completion offset.
 int getReplaceContextLength()
          The length of the region left to the completion offset that is part of the replace region.
 org.eclipse.jface.text.Region getReplaceRegion()
          The region in the document that will be replaced by a new completion proposal.
 XtextResource getResource()
          The resource.
 org.eclipse.emf.ecore.EObject getRootModel()
          The root model in the resource.
 ICompositeNode getRootNode()
          The root node in the resource.
 java.lang.String getSelectedText()
          The currently selected text.
 org.eclipse.jface.text.ITextViewer getViewer()
          The actual text viewer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentAssistContext

protected ContentAssistContext()
Protected contructor to allow subclassing.

Method Detail

copy

public ContentAssistContext.Builder copy()
Use this context as prototype for a new mutable builder. The new builder is pre-populated with the current settings of this context instance.


getPrefix

public java.lang.String getPrefix()
The prefix string that is used to match the validity of proposals. By default, the complete prefix will be overridden in the document when a proposal is applied. The prefix may be empty but is never null.


getRootModel

public org.eclipse.emf.ecore.EObject getRootModel()
The root model in the resource. May be null.


getRootNode

public ICompositeNode getRootNode()
The root node in the resource. May be null.


getCurrentNode

public INode getCurrentNode()
The current node which is part of the current completion offset. The total offset of the current node may be equal to the completion offset.


getOffset

public int getOffset()
The completion offset in the text viewer. If the text viewer has a non-empty text selection, the offset will be the beginning of the selection.


getViewer

public org.eclipse.jface.text.ITextViewer getViewer()
The actual text viewer.


getDocument

public IXtextDocument getDocument()
The actual document.


getLastCompleteNode

public INode getLastCompleteNode()
The last non-hidden node before the offset that is considered to be complete.


getCurrentModel

public org.eclipse.emf.ecore.EObject getCurrentModel()
The model that covers the completion offset and has a grammar element assigned that has the expected grammar element at the given offset in its call hierarchy. Thereby it may be a parent of the actual model element at the given offset due to alternative decisions of the parser or actions.

See Also:
getPreviousModel()

getPreviousModel

public org.eclipse.emf.ecore.EObject getPreviousModel()
The model element that is valid for the position left of the completion offset. It is likely to be the same as the current model. However, as the call hierarchy of the grammar elements is ignored (in contrast to getCurrentModel(), it may provide addition information.

See Also:
getCurrentModel()

getReplaceRegion

public org.eclipse.jface.text.Region getReplaceRegion()
The region in the document that will be replaced by a new completion proposal.


getSelectedText

public java.lang.String getSelectedText()
The currently selected text.


getFirstSetGrammarElements

public com.google.common.collect.ImmutableList<AbstractElement> getFirstSetGrammarElements()
The grammar elements that may occur at the given offset.


getMatcher

public PrefixMatcher getMatcher()
The matching algorithm to choose proposals according to the completion prefix.

See Also:
FQNPrefixMatcher

getReplaceContextLength

public int getReplaceContextLength()
The length of the region left to the completion offset that is part of the replace region.


getResource

public XtextResource getResource()
The resource. Is never null.