public class JavaPostfixTemplateProvider extends java.lang.Object implements PostfixTemplateProvider
| Constructor and Description |
|---|
JavaPostfixTemplateProvider() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterExpand(PsiFile file,
Editor editor)
Invoked after template finished (doesn't matter if it finished successfully or not).
|
PostfixTemplateEditor |
createEditor(PostfixTemplate templateToEdit)
Return the editor that it able to represent template in UI
and create the template from the settings that users set in UI.
|
java.lang.String |
getId()
Identifier of template provider.
|
java.lang.String |
getPresentableName()
Presentation name of editable template type.
|
java.util.Set<PostfixTemplate> |
getTemplates()
Returns builtin templates registered in the provider in their original state.
|
boolean |
isTerminalSymbol(char currentChar)
Check symbol can separate template keys
|
PsiFile |
preCheck(PsiFile copyFile,
Editor realEditor,
int currentOffset)
Prepare file for checking availability of templates.
|
void |
preExpand(PsiFile file,
Editor editor)
Prepare file for template expanding.
|
JavaEditablePostfixTemplate |
readExternalTemplate(java.lang.String id,
java.lang.String name,
Element template)
Instantiates the template that was serialized by the provider to XML.
|
void |
writeExternalTemplate(PostfixTemplate template,
Element parentElement)
Serialized to XML the template that was created by the provider.
|
public java.util.Set<PostfixTemplate> getTemplates()
PostfixTemplateProviderPostfixTemplatesUtils.getAvailableTemplates(PostfixTemplateProvider) for actually enabled templates.getTemplates in interface PostfixTemplateProviderpublic java.lang.String getId()
PostfixTemplateProvidergetId in interface PostfixTemplateProviderpublic java.lang.String getPresentableName()
PostfixTemplateProvidergetPresentableName in interface PostfixTemplateProviderpublic boolean isTerminalSymbol(char currentChar)
PostfixTemplateProviderisTerminalSymbol in interface PostfixTemplateProviderpublic void preExpand(PsiFile file, Editor editor)
PostfixTemplateProviderFile content doesn't contain template's key, it is deleted just before this method invocation.
Note that while postfix template is checking its availability the file parameter is a _COPY_ of the real file, so you can do with it anything that you want, but in the same time it doesn't recommended to modify editor state because it's real.
preExpand in interface PostfixTemplateProviderpublic void afterExpand(PsiFile file, Editor editor)
PostfixTemplateProviderafterExpand in interface PostfixTemplateProviderpublic PsiFile preCheck(PsiFile copyFile, Editor realEditor, int currentOffset)
PostfixTemplateProviderthis#preExpand(PsiFile, Editor) with several differences:
1. Processes copy of file. So implementations can modify it without corrupting the real file.
2. Could be invoked from anywhere (EDT, write-action, read-action, completion-thread etc.). So implementations should make
additional effort to make changes in file.
Content of file copy doesn't contain template's key, it is deleted just before this method invocation.
NOTE: editor is real (not copy) and it doesn't represents the copyFile. So it's safer to use currentOffset parameter instead of offset from editor. Do not modify text via editor.
preCheck in interface PostfixTemplateProviderpublic PostfixTemplateEditor createEditor(PostfixTemplate templateToEdit)
PostfixTemplateProviderIf templateToEdit is null, it's considered like an editor for a new template.
createEditor in interface PostfixTemplateProviderpublic JavaEditablePostfixTemplate readExternalTemplate(java.lang.String id, java.lang.String name, Element template)
PostfixTemplateProviderreadExternalTemplate in interface PostfixTemplateProviderpublic void writeExternalTemplate(PostfixTemplate template, Element parentElement)
PostfixTemplateProviderwriteExternalTemplate in interface PostfixTemplateProvider