当前位置:网站首页>Develop plug-ins for idea
Develop plug-ins for idea
2022-07-03 12:06:00 【J_ D_ Chi】
Write it at the front
In the use of Android Studio When , In order to improve efficiency , We will use some plug-ins to expand IDE Use . Sometimes, because some function plug-ins are not provided , Or the author did not maintain it for a long time, resulting in failure , We can also try to develop a plug-in by ourselves , Such as Android Studio,PhpStorm Things like that belong to JetBrains, In other words, a plug-in we develop may be common in many different editors .
Development plugin The tools used are Intelij IDEA.
Besides, I also wrote right Android Of strings.xml Plug in for multilingual translation , To learn accordingly .GitHub Address
step
1. newly build InteliJ Platform Plugin engineering

After new creation , What we should pay attention to is plugin.xml And used to write code src There are two places in the folder .
2. Introduce
2.1 plugin.xml
This file is a registration file , If developed Android Words , Is similar to the Android Inside AndroidManifest.xml file , Contains some registration information . stay Android To develop an interface in, we say create a new Activity, That's in plugin This is called Action, It is used to develop the operations to be performed after clicking our plug-in .
We Activity After writing, it will be in AndroidManifest.xml Registered in the , So here Action We are going to plugin.xml Registered in the . So just look plugin.xml The content in is easy to understand .
<idea-plugin>
<id>com.your.company.unique.plugin.id</id>
<name>Plugin display name here</name>
<version>1.0</version>
<vendor email="[email protected]" url="http://www.yourcompany.com">YourCompany</vendor>
<description><![CDATA[ Enter short description for your plugin here.<br> <em>most HTML tags may be used</em> ]]></description>
<change-notes><![CDATA[ Add change notes here.<br> <em>most HTML tags may be used</em> ]]>
</change-notes>
<!-- Please check out http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html The introduction in -->
<idea-version since-build="173.0"/>
<!-- Please check out http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html About positioning different products -->
<!-- uncomment to enable plugin in all products <depends>com.intellij.modules.lang</depends> -->
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
</extensions>
<actions>
<!-- Add your... Here Action -->
</actions>
</idea-plugin>
2. Action
I said before. , To develop a plugin The main thing is Action, This is our entrance , stay Action Write our code in , Achieve what we want .
2.1 newly build Action

Fill in some basic information here :
Name Indicates the title displayed in the menu at that time ;
Description Just write some introductions ;
Groups Where you want this plug-in to appear in the menu , Here we try to choose EditMenu, Then on the right is first, In other words, this plug-in will appear in Edit The first position under the menu ;
Keyboard Shortcuts Indicates that some shortcut keys can be defined ;
After new creation :
public class ClickAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
// Write your logic code here
Messages.showErrorDialog("Error message" , "Error Title");
}
}
Let's take a look at plugin.xml Change in :
<actions>
<!-- Add your actions here -->
<action id="Test.Test" class="ClickAction" text="MyIdeaPlugin" description="This is my first plugin test">
<add-to-group group-id="EditMenu" anchor="first"/>
</action>
</actions>
####2.2 function Action
We directly run, It will open a new plug-in IDE window , And then we can go in Edit The menu sees what we defined Action The entrance to . Click to pop up the window we just wrote .

notes : I have a question here , I'm in the process of developing , Click on this. action No response , Instead, it is the shortcut keys defined during initialization that are useful , I don't know what the problem is . And other options in the menu are , Need to use shortcut keys , And clicking is invalid . But looking at other people's articles, I didn't find such a situation .
3. Release plug-ins
After our development, we can package the plug-ins , Generate a jar package , Then we can install it into our Android Studio And so on. IDE Yes .
stay Build Choose Prepare Plugin Module ‘ name ’ For Deployment , IDE It will be automatically generated in the project directory jar It's packed .
This is the general process .
Other
Necessary knowledge
- Because here we will involve the operation of some interfaces , Then we have to learn swing, use Jpanel,JButton Do some simple interface implementation , This is related to development Android The process is similar ;
Problems encountered
1. Compatibility
After writing a plug-in and generating jar After package , I am here Android Studio There was an incompatible error when installing in , Cause unable to install , The main problem here is the version . Although these IDE All are JetBrains Of , But there are version differences between them .
What we need to revise is plugin.xml Inside
<idea-version since-build="173.0"/>
So how to modify the version number to match what we want IDE Well ? You can check it here :
http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html
So I'm here now Android Studio The latest version of is 1.3, Then we'll change it to 141:
<idea-version since-build="141"/>
Reference resources
AndroidStudio Plug-in development ( Advanced chapter of Action Mechanism )
边栏推荐
猜你喜欢

Xiaopeng P7 hit the guardrail and the airbag did not pop up. The official responded that the impact strength did not meet the ejection requirements

Basic knowledge of OpenGL (sort it out according to your own understanding)

vulnhub之momentum

shardingSphere分库分表<3>

ArcGIS应用(二十一)Arcmap删除图层指定要素的方法

C language improvement article (wchar_t) character type

STL Tutorial 9 deep copy and shallow copy of container elements

Solve msvcp120d DLL and msvcr120d DLL missing

Ripper of vulnhub

win10 上PHP artisan storage:link 出现 symlink (): Protocol error的解决办法
随机推荐
4000字超详解指针
Niuniu's team competition
(构造笔记)从类、API、框架三个层面学习如何设计可复用软件实体的具体技术
PHP导出word方法(一mht)
vulnhub之tomato(西红柿)
Vulnhub narak
Simple factory and factory method mode
vulnhub之pyexp
vulnhub之Ripper
Vulnhub's cereal
Symlink(): solution to protocol error in PHP artisan storage:link on win10
Go language to realize static server
SLF4J 日志门面
OpenGL 绘制彩色的三角形
OpenGL 着色器使用
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
优化接口性能
MCDF Experiment 1
Qt OpenGL 纹理贴图
During FTP login, the error "530 login incorrect.login failed" is reported