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()
PostfixTemplateProvider
PostfixTemplatesUtils.getAvailableTemplates(PostfixTemplateProvider)
for actually enabled templates.getTemplates
in interface PostfixTemplateProvider
public java.lang.String getId()
PostfixTemplateProvider
getId
in interface PostfixTemplateProvider
public java.lang.String getPresentableName()
PostfixTemplateProvider
getPresentableName
in interface PostfixTemplateProvider
public boolean isTerminalSymbol(char currentChar)
PostfixTemplateProvider
isTerminalSymbol
in interface PostfixTemplateProvider
public void preExpand(PsiFile file, Editor editor)
PostfixTemplateProvider
File 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 PostfixTemplateProvider
public void afterExpand(PsiFile file, Editor editor)
PostfixTemplateProvider
afterExpand
in interface PostfixTemplateProvider
public PsiFile preCheck(PsiFile copyFile, Editor realEditor, int currentOffset)
PostfixTemplateProvider
this#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 PostfixTemplateProvider
public PostfixTemplateEditor createEditor(PostfixTemplate templateToEdit)
PostfixTemplateProvider
If templateToEdit is null, it's considered like an editor for a new template.
createEditor
in interface PostfixTemplateProvider
public JavaEditablePostfixTemplate readExternalTemplate(java.lang.String id, java.lang.String name, Element template)
PostfixTemplateProvider
readExternalTemplate
in interface PostfixTemplateProvider
public void writeExternalTemplate(PostfixTemplate template, Element parentElement)
PostfixTemplateProvider
writeExternalTemplate
in interface PostfixTemplateProvider