当前位置:网站首页>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 )
边栏推荐
猜你喜欢
Introduction to the implementation principle of rxjs observable filter operator
Colleagues wrote a responsibility chain model, with countless bugs
ES6新特性
2022年湖南工学院ACM集训第二次周测题解
vulnhub之pyexp
解决msvcp120d.dll和msvcr120d.dll缺失
Vulnhub geminiinc V2
Laravel time zone timezone
During FTP login, the error "530 login incorrect.login failed" is reported
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
随机推荐
Dart: about Libraries
Qt OpenGL 旋转、平移、缩放
Experience container in libvirt
vulnhub之narak
laravel 时区问题timezone
网络通讯之Socket-Tcp(一)
Notes on 32-96 questions of sword finger offer
vulnhub之Nagini
4000 word super detailed pointer
QT OpenGL rotate, pan, zoom
Vulnhub's presidential
previous permutation lintcode51
[official MySQL document] deadlock
vulnhub之tomato(西红柿)
PHP export word method (phpword)
Unicode encoding table download
AOSP ~ NTP (Network Time Protocol)
为什么我的mysql容器启动不了呢
Simple factory and factory method mode
libvirt 中体验容器