当前位置:网站首页>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 )
边栏推荐
猜你喜欢

Qt OpenGL 旋转、平移、缩放

vulnhub之pyexp

Unicode encoding table download

牛牛的组队竞赛

Colleagues wrote a responsibility chain model, with countless bugs

Momentum of vulnhub

STL Tutorial 9 deep copy and shallow copy of container elements

VS2015的下载地址和安装教程

Socket TCP for network communication (I)

ArcGIS应用(二十一)Arcmap删除图层指定要素的方法
随机推荐
Shutter: about inheritedwidget
Unity3D学习笔记5——创建子Mesh
4000 word super detailed pointer
STL tutorial 8-map
Raven2 of vulnhub
Extrapolated scatter data
(构造笔记)GRASP学习心得
【mysql专项】读锁和写锁
AOSP ~ NTP (Network Time Protocol)
shardingSphere分库分表<3>
SLF4J 日志门面
错排问题 (抽奖,发邮件)
OpenGL 着色器使用
(构造笔记)ADT与OOP
MySQL uses the method of updating linked tables with update
win10 上PHP artisan storage:link 出现 symlink (): Protocol error的解决办法
Apprendre à concevoir des entités logicielles réutilisables à partir de la classe, de l'API et du cadre
Solution to the second weekly test of ACM intensive training of Hunan Institute of technology in 2022
Groovy test class and JUnit test
(database authorization - redis) summary of unauthorized access vulnerabilities in redis