Eclipse Platform
Release 3.1

org.eclipse.jface.text.contentassist
Class TextContentAssistInvocationContext

java.lang.Object
  extended byorg.eclipse.jface.contentassist.ContentAssistInvocationContext
      extended byorg.eclipse.jface.text.contentassist.TextContentAssistInvocationContext

public class TextContentAssistInvocationContext
extends ContentAssistInvocationContext

A content assist invocation context for text viewers. The context knows the viewer, the invocation offset and can lazily compute the identifier prefix preceding the invocation offset.

Clients may instantiate and subclass.

XXX this API is provisional and may change anytime during the course of 3.2

Since:
3.2

Constructor Summary
TextContentAssistInvocationContext(ITextViewer viewer)
          Equivalent to TextContentAssistInvocationContext(viewer, viewer.getSelectedRange().x).
TextContentAssistInvocationContext(ITextViewer viewer, int offset)
          Creates a new context for the given viewer and offset.
 
Method Summary
 CharSequence computeIdentifierPrefix()
          Computes the identifier (as specified by Character.isJavaIdentifierPart(char)) that immediately precedes the invocation offset.
 boolean equals(Object obj)
          Invocation contexts are equal if they describe the same context and are of the same type.
 IDocument getDocument()
          Shortcut for getViewer().getDocument().
 int getInvocationOffset()
          Returns the invocation offset.
 ITextViewer getViewer()
          Returns the viewer.
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextContentAssistInvocationContext

public TextContentAssistInvocationContext(ITextViewer viewer)
Equivalent to TextContentAssistInvocationContext(viewer, viewer.getSelectedRange().x).

Parameters:
viewer - the text viewer that content assist is invoked in

TextContentAssistInvocationContext

public TextContentAssistInvocationContext(ITextViewer viewer,
                                          int offset)
Creates a new context for the given viewer and offset.

Parameters:
viewer - the text viewer that content assist is invoked in
offset - the offset into the viewer's document where content assist is invoked at
Method Detail

getInvocationOffset

public final int getInvocationOffset()
Returns the invocation offset.

Returns:
the invocation offset

getViewer

public final ITextViewer getViewer()
Returns the viewer.

Returns:
the viewer

getDocument

public IDocument getDocument()
Shortcut for getViewer().getDocument().

Returns:
the viewer's document

computeIdentifierPrefix

public CharSequence computeIdentifierPrefix()
                                     throws BadLocationException
Computes the identifier (as specified by Character.isJavaIdentifierPart(char)) that immediately precedes the invocation offset.

Returns:
the prefix preceding the content assist invocation offset
Throws:
BadLocationException - if accessing the document fails

equals

public boolean equals(Object obj)
Description copied from class: ContentAssistInvocationContext
Invocation contexts are equal if they describe the same context and are of the same type. This implementation checks for null values and class equality. Subclasses should extend this method by adding checks for their context relevant fields (but not necessarily cached values).

Example:

 class MyContext extends ContentAssistInvocationContext {
 	private final Object fState;
 	private Object fCachedInfo;
 
 	...
 
 	public boolean equals(Object obb) {
 		if (!super.equals(obj))
 			return false;
 		MyContext other= (MyContext) obj;
 		return fState.equals(other.fState);
 	}
 }
 

Subclasses should also extend Object.hashCode().

Overrides:
equals in class ContentAssistInvocationContext
Parameters:
obj -
Returns:

hashCode

public int hashCode()
Overrides:
hashCode in class ContentAssistInvocationContext

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.