Skip to content

Commit

Permalink
migrate: Migrate deprecated APIs to support hot deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
vito committed Sep 13, 2022
1 parent 3e3e2b2 commit 45bc05b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
9 changes: 6 additions & 3 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin>
<id>com.jinsihou.react.snippets</id>
<name>React snippets</name>
<version>1.1.0</version>
<version>1.1.1</version>
<vendor email="[email protected]">jinsihou</vendor>

<description><![CDATA[
Expand All @@ -10,6 +10,8 @@
]]></description>

<change-notes><![CDATA[
<strong>v1.1.1</strong> <br/>
<li>Migrate deprecated APIs to support hot deployment</li>
<strong>v1.1.0</strong> <br/>
<li> Supported react 16.8.0 hooks</li>
<li> add cref snippet</li>
Expand All @@ -22,7 +24,7 @@
</change-notes>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="145.0"/>
<idea-version since-build="202.6397.94"/>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
Expand All @@ -33,7 +35,8 @@
<depends>com.intellij.modules.platform</depends>

<extensions defaultExtensionNs="com.intellij">
<defaultLiveTemplatesProvider implementation="com.jinsihou.react.snippets.ReactTemplateProvider"/>
<defaultLiveTemplates file="/liveTemplates/React.xml"/>
<liveTemplateContext implementation="com.jinsihou.react.snippets.ReactTemplateProvider"/>
</extensions>

<actions>
Expand Down
18 changes: 9 additions & 9 deletions src/com/jinsihou/react/snippets/ReactTemplateProvider.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package com.jinsihou.react.snippets;


import com.intellij.codeInsight.template.impl.DefaultLiveTemplatesProvider;
import org.jetbrains.annotations.Nullable;
import com.intellij.codeInsight.template.TemplateActionContext;
import com.intellij.codeInsight.template.TemplateContextType;
import org.jetbrains.annotations.NotNull;

/**
* @author jinsihou
* @date 2017/10/18
*/
public class ReactTemplateProvider implements DefaultLiveTemplatesProvider {
@Override
public String[] getDefaultLiveTemplateFiles() {
return new String[]{"liveTemplates/React"};
public class ReactTemplateProvider extends TemplateContextType {
protected ReactTemplateProvider() {
super("REACT", "React");
}

@Nullable
@Override
public String[] getHiddenLiveTemplateFiles() {
return new String[0];
public boolean isInContext(@NotNull TemplateActionContext templateActionContext) {
String name = templateActionContext.getFile().getName();
return name.endsWith(".js") || name.endsWith(".jsx") || name.endsWith(".html") || name.endsWith(".ts");
}
}

0 comments on commit 45bc05b

Please sign in to comment.