mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-29 17:57:53 +08:00
Live template tutorial pt. 2
This commit is contained in:
parent
c1bd6fa8e6
commit
9c6f9f06bb
@ -1,6 +1,6 @@
|
|||||||
<idea-plugin version="2">
|
<idea-plugin version="2">
|
||||||
<id>com.your.company.unique.plugin.id</id>
|
<id>live_templates</id>
|
||||||
<name>Plugin display name here</name>
|
<name>live_templates</name>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<vendor email="support@yourcompany.com" url="http://www.yourcompany.com">YourCompany</vendor>
|
<vendor email="support@yourcompany.com" url="http://www.yourcompany.com">YourCompany</vendor>
|
||||||
|
|
||||||
@ -25,7 +25,9 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
<!-- Add your extensions here -->
|
<defaultLiveTemplatesProvider implementation="MarkdownTemplateProvider"/>
|
||||||
|
<liveTemplateContext implementation="MarkdownContext"/>
|
||||||
|
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|
||||||
<actions>
|
<actions>
|
||||||
|
@ -1,7 +1,17 @@
|
|||||||
|
import com.intellij.codeInsight.template.EverywhereContextType;
|
||||||
import com.intellij.codeInsight.template.TemplateContextType;
|
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 {
|
public class MarkdownContext extends TemplateContextType {
|
||||||
|
protected MarkdownContext() {
|
||||||
|
super("MARKDOWN", "Markdown");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInContext(@NotNull PsiFile file, int offset) {
|
||||||
|
return file.getName().endsWith(".md");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
import com.intellij.codeInsight.template.impl.DefaultLiveTemplatesProvider;
|
import com.intellij.codeInsight.template.impl.DefaultLiveTemplatesProvider;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by breandan on 1/11/2016.
|
|
||||||
*/
|
|
||||||
public class MarkdownTemplateProvider implements DefaultLiveTemplatesProvider {
|
public class MarkdownTemplateProvider implements DefaultLiveTemplatesProvider {
|
||||||
|
@Override
|
||||||
|
public String[] getDefaultLiveTemplateFiles()
|
||||||
|
{
|
||||||
|
return new String[] {"liveTemplates/Markdown"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public String[] getHiddenLiveTemplateFiles() {
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<idea-plugin version="2">
|
<idea-plugin version="2">
|
||||||
<name>Plugin name here</name>
|
<name>max_opened_projects</name>
|
||||||
<description>short description of the plugin</description>
|
<description>short description of the plugin</description>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<vendor>YourCompany</vendor>
|
<vendor>YourCompany</vendor>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user