|
Eclipse Platform Release 3.1 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jface.text.templates.TemplateContext
org.eclipse.jface.text.templates.DocumentTemplateContext
Instances of this class describe the context of a template as a region of
a document. That region may be either specified by its offset and length, or
by a Position
which may or may not be registered with the
document.
Clients may instantiate and extend this class.
Constructor Summary | |
---|---|
DocumentTemplateContext(TemplateContextType type,
IDocument document,
int offset,
int length)
Creates a document template context. |
|
DocumentTemplateContext(TemplateContextType type,
IDocument document,
Position position)
Creates a document template context. |
Method Summary | |
---|---|
boolean |
canEvaluate(Template template)
Tests if the specified template can be evaluated in this context. |
TemplateBuffer |
evaluate(Template template)
Evaluates the template in this context and returns a template buffer. |
int |
getCompletionLength()
Returns the completion length within the string of the context. |
int |
getCompletionOffset()
Returns the completion offset within the string of the context. |
IDocument |
getDocument()
Returns the document. |
int |
getEnd()
Returns the end offset of the keyword. |
String |
getKey()
Returns the keyword which triggered template insertion. |
int |
getStart()
Returns the beginning offset of the keyword. |
protected void |
setCompletionLength(int newLength)
Sets the completion length. |
protected void |
setCompletionOffset(int newOffset)
Sets the completion offset. |
Methods inherited from class org.eclipse.jface.text.templates.TemplateContext |
---|
getContextType, getVariable, isReadOnly, setReadOnly, setVariable |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DocumentTemplateContext(TemplateContextType type, IDocument document, int offset, int length)
type
- the context typedocument
- the document this context applies tooffset
- the offset of the document regionlength
- the length of the document regionpublic DocumentTemplateContext(TemplateContextType type, IDocument document, Position position)
Position
will be queried to compute the getStart
and
getEnd
methods, which will therefore answer updated
position data if it is registered with the document.
type
- the context typedocument
- the document this context applies toposition
- the position describing the area of the document which
forms the template contextMethod Detail |
public IDocument getDocument()
public int getCompletionOffset()
protected void setCompletionOffset(int newOffset)
newOffset
- the new completion offsetpublic int getCompletionLength()
protected void setCompletionLength(int newLength)
newLength
- the new completion lengthpublic String getKey()
public int getStart()
public int getEnd()
public boolean canEvaluate(Template template)
TemplateContext
Examples are templates defined for a different context (e.g. a javadoc template cannot be evaluated in Java context).
canEvaluate
in class TemplateContext
template
- the Template
to check
true
if template
can be evaluated
in this context, false
otherwisepublic TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException
TemplateContext
Evaluation means translating the template into a TemplateBuffer
,
resolving the defined variables in this context and possibly formatting
the resolved buffer.
evaluate
in class TemplateContext
template
- the template to evaluate
null
if the buffer could not be created
TemplateException
- if the template specification is not valid
BadLocationException
- if evaluation fails due to concurrently changed documents etc.
|
Eclipse Platform Release 3.1 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.