From 9c6f9f06bb78b87f8e56f3e3414dc1c1f0e7673f Mon Sep 17 00:00:00 2001 From: breandan Date: Tue, 12 Jan 2016 00:39:50 -0800 Subject: [PATCH] Live template tutorial pt. 2 --- live_templates/resources/META-INF/plugin.xml | 8 +++++--- live_templates/src/MarkdownContext.java | 16 +++++++++++++--- live_templates/src/MarkdownTemplateProvider.java | 15 ++++++++++++--- .../resources/META-INF/plugin.xml | 2 +- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/live_templates/resources/META-INF/plugin.xml b/live_templates/resources/META-INF/plugin.xml index 68ae2627b..1e2935c91 100644 --- a/live_templates/resources/META-INF/plugin.xml +++ b/live_templates/resources/META-INF/plugin.xml @@ -1,6 +1,6 @@ - com.your.company.unique.plugin.id - Plugin display name here + live_templates + live_templates 1.0 YourCompany @@ -25,7 +25,9 @@ --> - + + + diff --git a/live_templates/src/MarkdownContext.java b/live_templates/src/MarkdownContext.java index 4daf4df1a..1c1c05a6d 100644 --- a/live_templates/src/MarkdownContext.java +++ b/live_templates/src/MarkdownContext.java @@ -1,7 +1,17 @@ +import com.intellij.codeInsight.template.EverywhereContextType; import com.intellij.codeInsight.template.TemplateContextType; +import com.intellij.psi.PsiFile; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -/** - * Created by breandan on 1/11/2016. - */ public class MarkdownContext extends TemplateContextType { + protected MarkdownContext() { + super("MARKDOWN", "Markdown"); + } + + @Override + public boolean isInContext(@NotNull PsiFile file, int offset) { + return file.getName().endsWith(".md"); + } } diff --git a/live_templates/src/MarkdownTemplateProvider.java b/live_templates/src/MarkdownTemplateProvider.java index 8926db4b1..c113accb3 100644 --- a/live_templates/src/MarkdownTemplateProvider.java +++ b/live_templates/src/MarkdownTemplateProvider.java @@ -1,7 +1,16 @@ import com.intellij.codeInsight.template.impl.DefaultLiveTemplatesProvider; +import org.jetbrains.annotations.Nullable; -/** - * Created by breandan on 1/11/2016. - */ public class MarkdownTemplateProvider implements DefaultLiveTemplatesProvider { + @Override + public String[] getDefaultLiveTemplateFiles() + { + return new String[] {"liveTemplates/Markdown"}; + } + + @Nullable + @Override + public String[] getHiddenLiveTemplateFiles() { + return new String[0]; + } } diff --git a/max_opened_projects/resources/META-INF/plugin.xml b/max_opened_projects/resources/META-INF/plugin.xml index 3e3ce844c..d844bd01e 100644 --- a/max_opened_projects/resources/META-INF/plugin.xml +++ b/max_opened_projects/resources/META-INF/plugin.xml @@ -1,5 +1,5 @@ - Plugin name here + max_opened_projects short description of the plugin 1.0 YourCompany