├── LICENSE.txt ├── LiveTempletePreview.iml ├── META-INF └── plugin.xml ├── README.md ├── images └── help.png └── src └── main └── java └── siosio ├── LiveTemplateDocumentProvider.java └── LiveTemplateElement.java /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 siosio 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /LiveTempletePreview.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /META-INF/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | LiveTemplatePreview 3 | LiveTemplatePreview 4 | 0.3 5 | siosio 8 | 9 | 12 | 13 | 15 | 16 | 17 | 18 | com.intellij.modules.lang 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | By displaying the Quick Documentation list of Live Template, it can be confirmed template. 2 | 3 | Starting with version 13, this feature has been added to the IntelliJ. 4 | Below refer to the help of IntelliJ. 5 | 6 | [IntelliJ help page](https://www.jetbrains.com/idea/help/creating-code-constructs-by-live-templates.html) 7 | 8 | How to use 9 | ----------- 10 | 11 | 1.Display a list of Live Template. 12 | 13 | `` 14 | Control + J(Mac:command + j) or menu -> Code -> Insert Live Template 15 | `` 16 | 17 | 2.Select template. 18 | 19 | 3.Open Quick Documentation. 20 | 21 | `` 22 | Control + Q(Mac:F1) 23 | `` 24 | 25 | `` 26 | In Quick Documentation, I can preview the information of the template. 27 | For example, as shown in the following image. 28 | `` 29 | 30 | 31 | 32 | Plugin Download page 33 | ----------------------- 34 | 35 | [https://plugins.jetbrains.com/plugin/7189](https://plugins.jetbrains.com/plugin/7189) 36 | 37 | License 38 | ------------ 39 | 40 | This software is released under the MIT License, see LICENSE.txt. 41 | -------------------------------------------------------------------------------- /images/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siosio/LiveTempletePreview/7d97734c76247474972b99c9d8acaad68f3b4845/images/help.png -------------------------------------------------------------------------------- /src/main/java/siosio/LiveTemplateDocumentProvider.java: -------------------------------------------------------------------------------- 1 | package siosio; 2 | 3 | import java.util.List; 4 | 5 | import com.intellij.codeInsight.template.impl.LiveTemplateLookupElement; 6 | import com.intellij.codeInsight.template.impl.LiveTemplateLookupElementImpl; 7 | import com.intellij.codeInsight.template.impl.TemplateImpl; 8 | import com.intellij.lang.documentation.AbstractDocumentationProvider; 9 | import com.intellij.lang.documentation.ExternalDocumentationProvider; 10 | import com.intellij.openapi.project.Project; 11 | import com.intellij.openapi.util.text.StringUtil; 12 | import com.intellij.psi.PsiElement; 13 | import com.intellij.psi.PsiManager; 14 | import org.jetbrains.annotations.Nullable; 15 | 16 | public class LiveTemplateDocumentProvider extends AbstractDocumentationProvider implements ExternalDocumentationProvider { 17 | 18 | @Nullable 19 | @Override 20 | public PsiElement getDocumentationElementForLookupItem( 21 | PsiManager psiManager, Object object, PsiElement element) { 22 | if (!(object instanceof LiveTemplateLookupElementImpl)) { 23 | return null; 24 | } 25 | 26 | LiveTemplateLookupElementImpl lookupElement = (LiveTemplateLookupElementImpl) object; 27 | if (lookupElement.getTemplate() != null) { 28 | return new LiveTemplateElement(psiManager, lookupElement); 29 | } 30 | return null; 31 | } 32 | 33 | @Override 34 | public String generateDoc(PsiElement element, 35 | @Nullable PsiElement originalElement) { 36 | if (!(element instanceof LiveTemplateElement)) { 37 | return null; 38 | } 39 | LiveTemplateLookupElementImpl liveTemplateLookupElement = 40 | (LiveTemplateLookupElementImpl) ((LiveTemplateElement) element).getElement(); 41 | TemplateImpl template = liveTemplateLookupElement.getTemplate(); 42 | 43 | StringBuilder result = new StringBuilder(); 44 | result.append(""); 45 | result.append("

description

"); 46 | result.append("
");
47 |         result.append(StringUtil.escapeXml(template.getDescription()));
48 |         result.append("
"); 49 | result.append("

template text

"); 50 | result.append("
");
51 |         result.append(StringUtil.escapeXml(template.getString()));
52 |         result.append("
"); 53 | result.append(""); 54 | return result.toString(); 55 | } 56 | 57 | @Nullable 58 | public String fetchExternalDocumentation(Project project, 59 | PsiElement element, List strings) { 60 | return null; 61 | } 62 | 63 | public boolean hasDocumentationFor(PsiElement element, 64 | PsiElement element2) { 65 | return element instanceof LiveTemplateLookupElement; 66 | } 67 | 68 | public boolean canPromptToConfigureDocumentation(PsiElement element) { 69 | return false; 70 | } 71 | 72 | public void promptToConfigureDocumentation(PsiElement element) { 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/main/java/siosio/LiveTemplateElement.java: -------------------------------------------------------------------------------- 1 | package siosio; 2 | 3 | import com.intellij.codeInsight.template.impl.LiveTemplateLookupElement; 4 | import com.intellij.openapi.fileTypes.FileTypes; 5 | import com.intellij.psi.PsiElement; 6 | import com.intellij.psi.PsiFile; 7 | import com.intellij.psi.PsiFileFactory; 8 | import com.intellij.psi.PsiManager; 9 | import com.intellij.psi.impl.FakePsiElement; 10 | 11 | public class LiveTemplateElement extends FakePsiElement { 12 | 13 | private LiveTemplateLookupElement element; 14 | private PsiManager manager; 15 | 16 | public LiveTemplateElement( 17 | PsiManager manager, LiveTemplateLookupElement element) { 18 | this.manager = manager; 19 | this.element = element; 20 | } 21 | 22 | public PsiElement getParent() { 23 | return null; 24 | } 25 | 26 | public LiveTemplateLookupElement getElement() { 27 | return element; 28 | } 29 | 30 | @Override 31 | public boolean isValid() { 32 | return true; 33 | } 34 | 35 | @Override 36 | public PsiFile getContainingFile() { 37 | return PsiFileFactory.getInstance(getProject()).createFileFromText( 38 | "hoge.txt", FileTypes.PLAIN_TEXT, ""); 39 | } 40 | 41 | @Override 42 | public PsiManager getManager() { 43 | return manager; 44 | } 45 | 46 | @Override 47 | public String getName() { 48 | return element.getLookupString(); 49 | } 50 | } 51 | --------------------------------------------------------------------------------