public abstract class TemplateCompletionProcessor extends Object implements IContentAssistProcessor
getTemplates(String)
,
getContextType(ITextViewer, IRegion)
and getImage(Template)
.Constructor and Description |
---|
TemplateCompletionProcessor() |
Modifier and Type | Method and Description |
---|---|
ICompletionProposal[] |
computeCompletionProposals(ITextViewer viewer,
int offset)
Returns a list of completion proposals based on the
specified location within the document that corresponds
to the current cursor position within the text viewer.
|
IContextInformation[] |
computeContextInformation(ITextViewer viewer,
int documentOffset)
Returns information about possible contexts based on the
specified location within the document that corresponds
to the current cursor position within the text viewer.
|
protected TemplateContext |
createContext(ITextViewer viewer,
IRegion region)
Creates a concrete template context for the given region in the document.
|
protected ICompletionProposal |
createProposal(Template template,
TemplateContext context,
IRegion region,
int relevance)
Creates a new proposal.
|
protected ICompletionProposal |
createProposal(Template template,
TemplateContext context,
Region region,
int relevance)
Deprecated.
use the version specifying
IRegion as third parameter |
protected String |
extractPrefix(ITextViewer viewer,
int offset)
Heuristically extracts the prefix used for determining template relevance
from the viewer's document.
|
char[] |
getCompletionProposalAutoActivationCharacters()
Returns the characters which when entered by the user should
automatically trigger the presentation of possible completions.
|
char[] |
getContextInformationAutoActivationCharacters()
Returns the characters which when entered by the user should
automatically trigger the presentation of context information.
|
IContextInformationValidator |
getContextInformationValidator()
Returns a validator used to determine when displayed context information
should be dismissed.
|
protected abstract TemplateContextType |
getContextType(ITextViewer viewer,
IRegion region)
Returns the context type that can handle template insertion at the given region
in the viewer's document.
|
String |
getErrorMessage()
Returns the reason why this content assist processor
was unable to produce any completion proposals or context information.
|
protected abstract Image |
getImage(Template template)
Returns the image to be used for the proposal for
template . |
protected int |
getRelevance(Template template,
String prefix)
Returns the relevance of a template given a prefix.
|
protected abstract Template[] |
getTemplates(String contextTypeId)
Returns the templates valid for the context type specified by
contextTypeId . |
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset)
IContentAssistProcessor
computeCompletionProposals
in interface IContentAssistProcessor
viewer
- the viewer whose document is used to compute the proposalsoffset
- an offset within the document for which completions should be computednull
if no proposals are possibleprotected ICompletionProposal createProposal(Template template, TemplateContext context, Region region, int relevance)
IRegion
as third parameter
Forwards to createProposal(Template, TemplateContext, IRegion, int)
.
Do neither call nor override.
template
- the template to be applied by the proposalcontext
- the context for the proposalregion
- the region the proposal applies torelevance
- the relevance of the proposalICompletionProposal
for
template
protected ICompletionProposal createProposal(Template template, TemplateContext context, IRegion region, int relevance)
The default implementation returns an instance of
TemplateProposal
. Subclasses may replace this method to provide
their own implementations.
template
- the template to be applied by the proposalcontext
- the context for the proposalregion
- the region the proposal applies torelevance
- the relevance of the proposalICompletionProposal
for
template
protected abstract Template[] getTemplates(String contextTypeId)
contextTypeId
.contextTypeId
- the context type idprotected TemplateContext createContext(ITextViewer viewer, IRegion region)
DocumentTemplateContext
for the context type at the given location.viewer
- the viewer for which the context is createdregion
- the region into document
for which the context is creatednull
protected abstract TemplateContextType getContextType(ITextViewer viewer, IRegion region)
viewer
- the text viewerregion
- the region into the document displayed by viewernull
if none existsprotected int getRelevance(Template template, String prefix)
template
- the template to compute the relevance forprefix
- the prefix after which content assist was requestedtemplate
extractPrefix(ITextViewer, int)
protected String extractPrefix(ITextViewer viewer, int offset)
viewer
- the vieweroffset
- offset into documentgetRelevance(Template, String)
protected abstract Image getImage(Template template)
template
.template
- the template for which an image should be returnedtemplate
public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset)
IContentAssistProcessor
computeContextInformation
in interface IContentAssistProcessor
viewer
- the viewer whose document is used to compute the possible contextsdocumentOffset
- an offset within the document for which context information should be computednull
if no context could be foundpublic char[] getCompletionProposalAutoActivationCharacters()
IContentAssistProcessor
getCompletionProposalAutoActivationCharacters
in interface IContentAssistProcessor
null
if no auto activation is desiredpublic char[] getContextInformationAutoActivationCharacters()
IContentAssistProcessor
getContextInformationAutoActivationCharacters
in interface IContentAssistProcessor
null
if no auto activation is desiredpublic String getErrorMessage()
IContentAssistProcessor
getErrorMessage
in interface IContentAssistProcessor
null
if no error occurredpublic IContextInformationValidator getContextInformationValidator()
IContentAssistProcessor
null
if the processor is
incapable of computing context information. getContextInformationValidator
in interface IContentAssistProcessor
null
if the processor
is incapable of computing context information
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.