|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext
public class ContentAssistInvocationContext
Describes the context of an invocation of content assist in a text viewer. The context knows the document, the invocation offset and can lazily compute the identifier prefix preceding the invocation offset. It may know the viewer.
Subclasses may add information to their environment. For example, source code editors may provide specific context information such as an AST.
Clients may instantiate and subclass.
Constructor Summary | |
---|---|
ContentAssistInvocationContext(org.eclipse.jface.text.IDocument document,
int offset)
Creates a new context for the given document and offset. |
|
ContentAssistInvocationContext(org.eclipse.jface.text.ITextViewer viewer)
Equivalent to ContentAssistInvocationContext(viewer, viewer.getSelectedRange().x). |
|
ContentAssistInvocationContext(org.eclipse.jface.text.ITextViewer viewer,
int offset)
Creates a new context for the given viewer and offset. |
Method Summary | |
---|---|
java.lang.CharSequence |
computeIdentifierPrefix()
Computes the identifier (as specified by Character.isJavaIdentifierPart(char) ) that
immediately precedes the invocation offset. |
void |
dispose()
Called upon completion of the content assist. |
boolean |
equals(java.lang.Object obj)
Invocation contexts are equal if they describe the same context and are of the same type. |
org.eclipse.jface.text.IDocument |
getDocument()
Returns the document that content assist is invoked on, or null if not known. |
int |
getInvocationOffset()
Returns the invocation offset. |
org.eclipse.jface.text.ITextViewer |
getViewer()
Returns the viewer, null if not available. |
int |
hashCode()
|
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ContentAssistInvocationContext(org.eclipse.jface.text.ITextViewer viewer)
viewer
- the text viewer that content assist is invoked inpublic ContentAssistInvocationContext(org.eclipse.jface.text.ITextViewer viewer, int offset)
viewer
- the text viewer that content assist is invoked inoffset
- the offset into the viewer's document where content assist is invoked atpublic ContentAssistInvocationContext(org.eclipse.jface.text.IDocument document, int offset)
document
- the document that content assist is invoked inoffset
- the offset into the document where content assist is invoked atMethod Detail |
---|
public final int getInvocationOffset()
public final org.eclipse.jface.text.ITextViewer getViewer()
null
if not available.
null
public org.eclipse.jface.text.IDocument getDocument()
null
if not known.
null
public java.lang.CharSequence computeIdentifierPrefix() throws org.eclipse.jface.text.BadLocationException
Character.isJavaIdentifierPart(char)
) that
immediately precedes the invocation offset.
null
if
there is no document
org.eclipse.jface.text.BadLocationException
- if accessing the document failspublic void dispose()
public boolean equals(java.lang.Object obj)
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 obj) { if (!super.equals(obj)) return false; MyContext other= (MyContext) obj; return fState.equals(other.fState); } }
Subclasses should also extend Object.hashCode()
.
equals
in class java.lang.Object
obj
-
public int hashCode()
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |