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

cgroup简介

Niuniu's team competition

During FTP login, the error "530 login incorrect.login failed" is reported

QT OpenGL rotate, pan, zoom

Vulnhub's cereal

Talk about the state management mechanism in Flink framework

VS2015的下载地址和安装教程

C language improvement article (wchar_t) character type

Vulnhub narak

vulnhub之Ripper
随机推荐
Extrapolated scatter data
PHP导出word方法(一mht)
Solution to the second weekly test of ACM intensive training of Hunan Institute of technology in 2022
Solve msvcp120d DLL and msvcr120d DLL missing
MySQL union和union all区别
836. Merge sets (day 63) and search sets
OpenGL draws colored triangles
win10 上PHP artisan storage:link 出现 symlink (): Protocol error的解决办法
OpenGL 绘制彩色的三角形
Sheet1$. Output [excel source output] Error in column [xxx]. The returned column status is: "the text is truncated, or one or more characters have no matches in the target code page.".
Vulnhub geminiinc
(construction notes) learn the specific technology of how to design reusable software entities from three levels: class, API and framework
Notes on 32-96 questions of sword finger offer
Dart: view the dill compiled code file
PHP export word method (one MHT)
Talk about the state management mechanism in Flink framework
Niuniu's team competition
vulnhub之presidential
Socket TCP for network communication (I)
利用Zabbix动态监控磁盘I/O