Live template tutorial pt. 2

This commit is contained in:
breandan 2016-01-12 00:39:50 -08:00
parent c1bd6fa8e6
commit 9c6f9f06bb
4 changed files with 31 additions and 10 deletions

View File

@ -1,6 +1,6 @@
<idea-plugin version="2">
<id>com.your.company.unique.plugin.id</id>
<name>Plugin display name here</name>
<id>live_templates</id>
<name>live_templates</name>
<version>1.0</version>
<vendor email="support@yourcompany.com" url="http://www.yourcompany.com">YourCompany</vendor>
@ -25,7 +25,9 @@
-->
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<defaultLiveTemplatesProvider implementation="MarkdownTemplateProvider"/>
<liveTemplateContext implementation="MarkdownContext"/>
</extensions>
<actions>

View File

@ -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");
}
}

View File

@ -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];
}
}

View File

@ -1,5 +1,5 @@
<idea-plugin version="2">
<name>Plugin name here</name>
<name>max_opened_projects</name>
<description>short description of the plugin</description>
<version>1.0</version>
<vendor>YourCompany</vendor>