├── 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 |
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("
"); 47 | result.append(StringUtil.escapeXml(template.getDescription())); 48 | result.append(""); 49 | 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