public interface PostfixTemplateProvider
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).
|
default 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.
|
default java.lang.String |
getId()
Identifier of template provider.
|
default 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.
|
default PostfixTemplate |
readExternalTemplate(java.lang.String id,
java.lang.String name,
Element template)
Instantiates the template that was serialized by the provider to XML.
|
default void |
writeExternalTemplate(PostfixTemplate template,
Element parentElement)
Serialized to XML the template that was created by the provider.
|
default java.lang.String getId()
default java.lang.String getPresentableName()
java.util.Set<PostfixTemplate> getTemplates()
PostfixTemplatesUtils.getAvailableTemplates(PostfixTemplateProvider)
for actually enabled templates.boolean isTerminalSymbol(char currentChar)
void preExpand(PsiFile file, Editor editor)
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.
void afterExpand(PsiFile file, Editor editor)
PsiFile preCheck(PsiFile copyFile, Editor realEditor, int currentOffset)
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.
default PostfixTemplateEditor createEditor(PostfixTemplate templateToEdit)
If templateToEdit is null, it's considered like an editor for a new template.
default PostfixTemplate readExternalTemplate(java.lang.String id, java.lang.String name, Element template)
default void writeExternalTemplate(PostfixTemplate template, Element parentElement)