public class ContentAssistInvocationContext extends Object
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.
Modifier | Constructor and Description |
---|---|
protected |
ContentAssistInvocationContext()
Creates a new context with no viewer or invocation offset set.
|
|
ContentAssistInvocationContext(IDocument document,
int offset)
Creates a new context for the given document and offset.
|
|
ContentAssistInvocationContext(ITextViewer viewer)
|
|
ContentAssistInvocationContext(ITextViewer viewer,
int offset)
Creates a new context for the given viewer and offset.
|
Modifier and Type | Method and Description |
---|---|
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()
Returns the document that content assist is invoked on, or
null if not known. |
int |
getInvocationOffset()
Returns the invocation offset.
|
ITextViewer |
getViewer()
Returns the viewer,
null if not available. |
int |
hashCode() |
public ContentAssistInvocationContext(ITextViewer viewer)
viewer
- the text viewer that content assist is invoked inpublic ContentAssistInvocationContext(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 atprotected ContentAssistInvocationContext()
public ContentAssistInvocationContext(IDocument document, int offset)
document
- the document that content assist is invoked inoffset
- the offset into the document where content assist is invoked atpublic final int getInvocationOffset()
public final ITextViewer getViewer()
null
if not available.null
public IDocument getDocument()
null
if not known.null
public CharSequence computeIdentifierPrefix() throws BadLocationException
Character.isJavaIdentifierPart(char)
) that
immediately precedes the invocation offset.null
if
there is no documentBadLocationException
- if accessing the document failspublic boolean equals(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()
.
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.