Method and device for multiplexing VScode plug-in code in IDEA plug-in package, storage medium and terminal equipment
By replacing the communication method and protocol of VSCode plug-in code in the IDEA plug-in package, the problem of code duplication in VSCode and IDEA plug-in development is solved, and code reuse and efficiency improvement is achieved.
Patent Information
- Application Number
- CN202510566557.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2025-07-18
AI Technical Summary
In the prior art, two sets of codes are required to be written separately when developing VSCode and IDEA plug-ins, which makes it difficult to guarantee the accuracy and completeness of logic rewriting, which increases the development cycle and cost.
By obtaining the page-side code of the VSCode plug-in package, replacing the communication method is JBCefClient, and replacing the communication protocol of the front-end page and node server code with the websocket protocol to generate the IDEA plug-in package.
It realizes the direct reuse of VSCode plug-in code in IDEA plug-in, which reduces duplicate writing, shortens R&D cycle, reduces maintenance complexity and cost, and improves functional implementation efficiency.
Smart Images

Figure CN120335797A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of plugin development, and particularly to a method, apparatus, storage medium, and terminal device for reusing VScode plugin code in an IDEA plugin package. Background Art
[0002] As an indispensable tool in developers' daily work, the types of integrated development environments (IDEs) are becoming increasingly rich. Different IDEs attract different groups of developers with their unique features and advantages. For example, VisualStudio Code (abbreviated as VSCode), with its lightweight, highly extensible, and rich plugin ecosystem, is widely popular in fields such as front-end development and lightweight project development; while IntelliJ IDEA (Intelligent Integrated Development Environment) has become the first choice for many Java developers and enterprise-level project development teams due to its powerful code analysis, intelligent code completion, and good support for enterprise-level project development.
[0003] As the complexity of software projects continues to increase, in order to meet specific project requirements, developers often need to develop plugins with the same functions for different IDEs. These plugins are designed to provide additional function support for developers, such as code generation, automated testing, project management assistance, etc., to improve development efficiency, ensure code quality, or simplify the development process.
[0004] However, under the existing technical framework, when developers need to develop plugins with the same functions for VSCode and IDEA respectively, they often need to write two completely independent sets of code. This is because although both VSCode and IDEA are powerful integrated development environments, they have significant differences in underlying architecture, plugin development interfaces, operating mechanisms, etc.
[0005] VSCode is built on the Electron framework, and its plugin development mainly uses TypeScript or JavaScript languages, interacting with the VSCode core through specific APIs to achieve various function extensions. While IDEA is developed based on the Java platform, and its plugin development usually uses Java or Kotlin languages, following the plugin development specifications and API interfaces provided by JetBrains.
[0006] This development mode brings many problems. First, in terms of the accuracy of logic rewriting, since the same functional logic needs to be implemented for two different IDEs respectively, it is very easy for developers to make deviations during the code writing process. For example, when dealing with complex business logics or algorithms, due to insufficient understanding of the API features of different IDEs, or negligence during the code conversion process, there may be subtle but critical differences in the function implementation of the two plugins. These differences may affect the normal operation of the plugins in the corresponding IDEs, and even lead to function failures or incorrect results.
[0007] Secondly, in terms of logical integrity, developers need to ensure that both plugins can fully implement all the functions specified by the project requirements. However, due to the separate development of the code, it is very difficult to ensure that no function points are missed during the development process. Moreover, when the project requirements change, corresponding modifications and updates need to be made in both code libraries simultaneously, which further increases the risk of missing functions or inconsistent updates, thus affecting the logical integrity of the plugins.
[0008] Finally, this way of developing two sets of code separately greatly extends the development cycle of the plugins. Developers need to invest a large amount of time and effort to familiarize themselves with the development specifications and APIs of the two different plugins, write and maintain two sets of code, and conduct multiple tests and debugging. This not only increases the development cost but also may cause project delivery delays and fail to meet market demands in a timely manner. Summary of the Invention
[0009] The embodiments of the present application provide a method, device, storage medium, and terminal device for reusing VScode plugin code in an IDEA plugin package, which can solve the problem of low efficiency in developing IEDA plugins in the prior art. The technical solutions are as follows:
[0010] In a first aspect, the embodiments of the present application provide a method for reusing VScode plugin code in an IDEA plugin package, the method including:
[0011] Obtain the page-end code of the VSCode plugin package;
[0012] Replace the communication method of the page-end code with communication using JBCefClient;
[0013] Obtain the node server-side code of the VSCode plugin;
[0014] Replace the communication protocol between the front-end page and the node server-side code with the websocket protocol;
[0015] Generate an IDEA plugin package based on the replaced front-end page code and node server-side code.
[0016] In a second aspect, an embodiment of the present application provides a device for reusing VSCode plugin code in an IDEA plugin package. The device includes:
[0017] An acquisition unit, configured to acquire the page-side code of the VSCode plugin package;
[0018] A replacement unit, configured to replace the communication method of the page-side code with communication using JBCefClient;
[0019] The acquisition unit is further configured to acquire the node server-side code of the VSCode plugin;
[0020] The replacement unit is further configured to replace the communication protocol between the front-end page and the node server-side code with the websocket protocol;
[0021] A generation unit, configured to generate an IDEA plugin package based on the replaced front-end page code and node server-side code.
[0022] In a third aspect, an embodiment of the present application provides a computer storage medium storing multiple instructions suitable for being loaded and executed by a processor to perform the above method steps.
[0023] In a fourth aspect, an embodiment of the present application provides a terminal device, which may include: a processor and a memory; wherein, the memory stores a computer program suitable for being loaded and executed by the processor to perform the above method steps.
[0024] The beneficial effects brought by the technical solutions provided by some embodiments of the present application at least include:
[0025] When developing an IDEA plugin, the VSCode plugin code can be directly reused to enable the same set of code to run in different developer tools (VSCode and IDEA), avoiding the duplicate writing of two sets of code. Through code reuse, the time investment in re-developing the same function in different developer tool environments is reduced, significantly shortening the R & D cycle and accelerating the product iteration speed. Since the business-side and page-side codes are reused, subsequent maintenance work only needs to be carried out for a set of codes, without separately processing the codes corresponding to different developer tools, reducing the complexity and cost of maintenance. For the same functional requirement, only one piece of code needs to be written to implement it in different developer tools, without the need to repeatedly develop according to tool differences, improving the efficiency of function implementation. Description of the Drawings
[0026] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0027] Figure 1 is a schematic diagram of the network architecture provided by an embodiment of the present application;
[0028] Figure 2 is a schematic flowchart of a method for reusing VScode plug-in code in an IDEA plug-in package provided by an embodiment of the present application;
[0029] Figure 3 is a schematic diagram of the software architecture of the plug-in provided by an embodiment of the present application;
[0030] Figure 4 is a schematic diagram of the structure of a device for reusing VScode plug-in code in an IDEA plug-in package provided by the present application;
[0031] Figure 5 is a schematic diagram of the structure of a terminal device provided by the present application. Detailed implementation manners
[0032] To make the objectives, technical solutions and advantages of the present application clearer, the following will further describe the embodiments of the present application in detail with reference to the accompanying drawings.
[0033] It should be noted that the method for reusing VScode plug-in code in the IDEA plug-in package provided by the present application is generally executed by a terminal device. Correspondingly, the device for reusing VScode plug-in code in the IDEA plug-in package is generally set in the terminal device.
[0034] Figure 1 shows an exemplary system architecture that can be applied to the method for reusing VScode plug-in code in the IDEA plug-in package or the device for reusing VScode plug-in code in the IDEA plug-in package of the present application.
[0035] As Figure 1 shown, the system architecture may include: a terminal device 101 and a server 102. The terminal device 101 and the server 102 can communicate with each other through a network. The network is a medium for providing a communication link between the above-mentioned various units. The network may include various types of wired communication links or wireless communication links. For example, the wired communication link includes optical fiber, twisted pair or coaxial cable, etc., and the wireless communication link includes Bluetooth communication link, Wireless-Fidelity (Wi-Fi) communication link or microwave communication link, etc.
[0036] Among them, an IDEA plug-in is installed in the terminal device 101, and the front-end page is displayed by loading the IDEA plug-in. Then, the user performs interactive operations through the front-end page to communicate with the large model deployed on the server.
[0037] It should be noted that the terminal device 101 and the server 102 can be hardware or software. When the terminal device 101 and the server 102 are hardware, they can be implemented as a distributed server cluster composed of multiple servers or as a single server. When the terminal device 101 and the server 102 are software, they can be implemented as multiple software or software modules (for example, used to provide distributed services) or as a single software or software module, and specific limitations are not made here.
[0038] Various communication client applications can be installed on the terminal device of the present application, such as: video recording applications, video playback applications, voice interaction applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0039] The terminal device can be hardware or software. When the terminal device is hardware, it can be various terminal devices with a display screen, including but not limited to smartphones, tablets, laptop portable computers, desktop computers, etc. When the terminal device is software, it can be installed in the terminal devices listed above. It can be implemented as multiple software or software modules (for example, used to provide distributed services) or as a single software or software module, and specific limitations are not made here.
[0040] When the terminal device is hardware, a display device and a camera can also be installed on it. The display device can be various devices that can implement the display function, and the camera is used to collect video streams; for example: the display device can be a cathode ray tube display (CR for short), a light-emitting diode display (LED for short), an electronic ink screen, a liquid crystal display (LCD for short), a plasma display panel (PDP for short), etc. The user can use the display device on the terminal device to view information such as text, pictures, and videos displayed.
[0041] It should be understood that Figure 1 the numbers of the terminal devices, networks, and servers in
[0042] Below will be combined with the appendix Figure 2, a method for reusing VScode plugin code in an IDEA plugin package provided by an embodiment of the present application will be introduced in detail. Among them, the device for reusing VScode plugin code in the IDEA plugin package in the embodiment of the present application may be Figure 1 the terminal device shown.
[0043] Please refer to Figure 2 , which is a schematic flowchart of a method for reusing VScode plugin code in an IDEA plugin package provided by an embodiment of the present application. As Figure 2 shown, the method in the embodiment of the present application may include the following steps:
[0044] S201. Obtain the page-end code of the VSCode plugin package.
[0045] Among them, the terminal device determines the source of the VSCode plugin to be obtained, such as the official VSCode plugin market, open source platforms such as GitHub. Access the corresponding page through a browser, search for the plugin in the plugin market to enter the details page, or enter the plugin code repository on the open source platform. Locate and download the page-end code: In the plugin page or repository, locate the location of the page-end code. Usually, files such as HTML (Hyper Text Markup Language), CSS (Cascading Style Sheets), JavaScript, pictures, icons, fonts, and configuration files can be included in the webview directory. If the page provides a download link, directly download and decompress it to a specified local directory; if it is on an open source platform, use Git to clone the repository to the local to obtain the complete code.
[0046] Further, in some embodiments of the present application, the terminal device obtains the VSCode plugin package from the local project directory of the VSCode plugin. The specific process includes:
[0047] The terminal device first identifies the directory location where the VSCode plugin project is locally stored. This can be a specific folder specified by the user when downloading or developing VSCode plugins previously. The user can look for this directory on the local disk through the file explorer, or use the cd command in the command-line tool (such as cmd for Windows or Terminal for macOS / Linux) to switch to the corresponding directory. After entering the local project directory, the terminal device needs to identify the VSCode plugin package. Usually, the VSCode plugin package is a file in a specific format, such as a.vsix file. The user can search for files in this format in the project directory, or look for subdirectories where the plugin package can be stored according to the project structure, such as common directories like dist, release, etc. After finding the plugin package, the user can directly copy this file to the specified location through the file explorer, or use the command-line tool (such as the cp command on macOS / Linux or the copy command on Windows) to copy the plugin package to the required directory for subsequent processing and analysis.
[0048] In another embodiment, obtaining the page front-end code associated with the VSCode plugin in the code repository specifically includes:
[0049] The terminal device needs to obtain the code repository address associated with the target VSCode plugin, which can be obtained through various channels, such as looking for it in the official documentation of the plugin, developer communities, project home pages, etc. The code repository address is usually an address based on a version control system (such as Git), for example, the repository address on GitHub has the format https: / / github.com / username / repositoryname.git. Use a version control tool (such as Git) to clone the code repository on the terminal device. In the command-line tool, the user navigates to the local directory where they want to store the code, and then uses the git clone command plus the code repository address to clone the repository. For example, in GitBash (Windows) or Terminal (macOS / Linux), enter git clone https: / / github.com / username / repositoryname.git, and Git will automatically download all the contents of the code repository to the local. After cloning is complete, the terminal device enters the directory of the cloned code repository. According to the project structure and naming convention, look for the page front-end code associated with the VSCode plugin. Usually, the front-end code can be located in directories such as webview, frontend, client, etc., and the file types can include HTML, CSS, JavaScript, etc. The user can quickly locate these front-end code files by browsing the directory structure or using a file search tool.
[0050] In summary, by providing two ways to obtain the front-end page code, namely from the local project directory and the code repository, the flexibility of developers and users in obtaining code is increased. If the user already has a VSCode plugin project locally, they can directly obtain the plugin package from the local, saving download time and network resources. If the user does not have a local project or needs to obtain the latest version of the front-end code, they can obtain it from the code repository to ensure getting the latest development results.
[0051] Obtaining the front-end page code from the code repository enables developers to conveniently manage the code versions. Version control systems (such as Git) can record the modification history of each code change, facilitating developers to trace back to previous versions and view the code changes. Meanwhile, the code repository also supports collaborative development by multiple developers. Different developers can perform code commits, merges, and branch management in the same code repository, improving development efficiency and code quality.
[0052] Whether obtaining the front-end page code from the local project directory or the code repository, the consistency and traceability of the code can be ensured. The plugin package obtained from the local project directory is a complete set of packaged code, ensuring code integrity. The code obtained from the code repository can clearly track the code source and change process through the version control system, facilitating developers to troubleshoot problems and maintain the code.
[0053] S202. Replace the communication method of the page-side code with communication using JBCefClient.
[0054] Among them, conduct a detailed analysis of the obtained page-side code to find all parts related to communication with VSCode. Identify the functions and methods in the original JavaScript code for interacting with VSCode, such as code that may call VSCode native APIs. In the front-end page code, replace all parts related to communication with VSCode with code using JBCefClient for communication. Redesign the message sending and receiving logic to ensure that messages can be correctly transmitted to the Java application of IDEA through JBCefClient and that messages returned from IDEA can be correctly processed. At the same time, considering the compatibility with the IDEA environment, appropriately adjust the message format and content. Set up a test environment locally and run the modified front-end page code. Simulate various message sending and receiving scenarios to check whether the JBCefClient communication function is normal. Verify whether messages can be accurately transmitted between the front-end page and the Java application of IDEA and whether the page can make correct responses based on the received messages.
[0055] For example, see Figure 3Schematic diagram of the software architecture of the plugin shown. In the original VSCode plugin, the communication method for the dist static page (i.e., the front-end page code) is vscode.webview. When developing the IDEA plugin, the communication method is replaced with JBCefClient.
[0056] S203. Obtain the node server-side code of the VSCode plugin.
[0057] Among them, in the obtained VSCode plugin code, locate the position of the node server-side code. Usually, it can be in the server directory or exist in the project root directory or other subdirectories with a specific file name (such as server.js). Confirm the code integrity, check whether the dependencies in the package.json file are complete, and install the dependencies locally using npm install.
[0058] S204. Replace the communication protocol between the front-end page and the node server-side code with the websocket protocol.
[0059] Among them, in the front-end page code, find the part that communicates with the node server-side and replace it with the code that uses the websocket protocol for communication. For example: See Figure 3 As shown, configure the websocket module in the IDEA plugin and use the websocket module to implement the communication between the front-end page and the back-end server node.js. Use the WebSocket object in JavaScript to create a connection with the node server-side, and define the processing logic for sending and receiving messages. Ensure that the front-end page can make correct responses when different events such as connection establishment, message reception, and connection closure occur, and perform corresponding operations according to the message content.
[0060] Since the IDEA side cannot directly load the plugin to execute the node server-side, the terminal device needs to mount the node server-side using ProcessBuilder after loading the IDEA plugin. In the startup logic of the plugin, create a new process through ProcessBuilder to start the node server-side code. At the same time, a reasonable mechanism needs to be designed to manage the startup and destruction of the node server-side. For example, when the plugin is uninstalled or closed, terminate the node server-side process through corresponding signals or commands.
[0061] After completing the modification of the front-end and back-end code, set up a complete test environment. Run the front-end page and the node server simultaneously. Send various types of messages through the front-end page, and check whether the node server can correctly receive and process these messages, and whether it can return the processing results to the front-end page through the websocket connection. Verify whether the websocket communication is stable and reliable under different conditions (such as network fluctuations, message concurrency, etc.).
[0062] S205. Generate an IDEA plugin package based on the replaced front-end page code and node server code.
[0063] Among them, ensure that the terminal device has installed development tools and environments suitable for developing IDEA plugins, such as IntelliJ IDEA IDE and related plugin development plugins (such as IntelliJ Platform Plugin SDK). Configure the development environment, including setting the JDK version, specifying relevant paths for plugin development, etc.
[0064] Create an IDEA plugin project structure and integrate the code: Create a new IDEA plugin project in IntelliJ IDEA, and create the corresponding project directory structure according to the development specifications of IDEA plugins. Copy the replaced front-end page code to the specified directory, make appropriate adjustments and packaging to the node server code to adapt to the running environment of the IDEA plugin, and place it in the appropriate directory. At the same time, create a plugin description file (such as plugin.xml) to define the basic information and function entry points of the plugin.
[0065] Adjust the right-click operation execution of the node server in vscode: In the node server, the right-click operation was originally implemented by registering functions through vscode.commands.registerCommand, which needs to be adjusted to other methods in the IDEA environment. The node server only needs to focus on the actual business logic processing, such as obtaining the offset of each method of the Java file and the code snippet selected by the current user. For operations related to IDEA, instead of directly using VSCode's utility classes (such as vscode.window or vscode.workspace), relevant information is passed to the IDEA side through websocket communication.
[0066] On the IDEA side, the functions originally registered through vscode.commands.registerCommand in VSCode are adjusted to use AnAction to register actions. The creation of right-click menu items and the triggering of corresponding operations are achieved through AnAction. When the user right-clicks in IDEA, the corresponding AnAction is triggered. This action interacts with the node server through websocket communication to obtain the processed business data from the node server, and then uses the APIs provided by IDEA (such as using the Editor operator of OpenAPI) to display the results or perform corresponding operations on the IDEA interface.
[0067] Use the packaging function provided by IntelliJ IDEA to package the entire plugin project into a distributable plugin package (usually a.zip file). Install the generated plugin package into IDEA for testing to verify whether the functions of the plugin meet the expectations. Check whether the front-end page can be displayed normally, whether the node server can run correctly and interact with the front-end and IDEA side through websocket communication, and whether the right-click operation can be triggered normally on the IDEA side and execute the corresponding business logic. If problems are found, return to the previous steps in time for debugging and modification until the plugin can run stably and correctly.
[0068] In some embodiments of the present application, the generated IDEA plugin package is verified, and the verification process includes:
[0069] Export the generated IDEA plugin package;
[0070] Perform integrity verification on the IDEA plugin package;
[0071] After the verification passes, determine whether the version number of the IDEA plugin package is the preset version number;
[0072] If so, display the IDEA interaction interface and the UI elements included in the IDEA interaction interface after loading the IDEA plugin package;
[0073] Detect that the IDEA plugin package connects to the node server through a preset port based on the websocket protocol;
[0074] If so, perform functional tests on each UI element on the IDEA interaction interface.
[0075] Among them, the terminal device first needs to clarify the output directory after the IDEA plugin project is built. When developing an IDEA plugin, specific build tools (such as Gradle or Maven) or the built-in build function of IDEA are usually used. After the build is completed, the generated plugin package will be stored in the specified directory. Users can determine the directory path where the plugin package is located by viewing the project's build configuration file (such as build.gradle or pom.xml) or the build output settings of IDEA.
[0076] After entering the build output directory, the terminal device searches for the generated plugin package file according to the naming rules and file type of the IDEA plugin package (usually in.zip format). The plugin package file name can contain information such as the name and version number of the plugin, and users can quickly identify the target plugin package through the file name.
[0077] After finding the plugin package file, users can directly copy the file to other specified locations through the file explorer, such as external storage devices (such as USB flash drives, external hard drives) or network storage locations (such as cloud disks) for distribution or backup. You can also use command-line tools (such as the cp command on macOS / Linux or the copy command on Windows) to copy the plugin package to the target directory.
[0078] The terminal device needs to obtain the rules for verifying the integrity of the IDEA plugin package. These rules can be defined by the plugin developer and usually include information such as verifying the file size and hash value (such as MD5, SHA-256, etc.) of the plugin package. The developer may record these rules in the documentation or integrate them into the plugin's installation or verification script. Use the corresponding verification tools (such as command-line tools like md5sum, sha256sum, or use the corresponding hash algorithm library in the code) to calculate the verification value of the IDEA plugin package. For example, in the Linux or macOS terminal, you can use the md5sum plugin_package_name.zip command to calculate the MD5 hash value of the plugin package. Compare the calculated verification value of the plugin package with the verification value in the pre-defined integrity verification rules. If the two are consistent, it means that the plugin package has not been damaged or tampered with during transmission or storage, and the integrity verification passes; if the two are inconsistent, it means that there may be a problem with the plugin package and it needs to be re-obtained or processed.
[0079] The terminal device needs to parse the version number information from the IDEA plugin package. For a plugin package in.zip format, an extraction tool can be used (such as the unzip command on Linux / macOS or tools like WinRAR, 7-Zip on Windows) to extract the plugin package, and then view the metadata file in the plugin package (such as the plugin.xml file), which usually contains the version number information of the plugin. The version number can also be automatically extracted by writing a script or using a dedicated plugin parsing tool. The preset version number can be set in advance by the developer or system administrator and stored in a configuration file, database, or code constant. The terminal device needs to obtain the preset version number from the corresponding location. Compare the parsed plugin package version number with the preset version number. String comparison functions or dedicated version number comparison tools can be used to determine whether the two are the same. If the version numbers are the same, it means that the plugin package meets the preset requirements; if the version numbers are different, the user may need to be prompted to update the plugin package or other corresponding handling measures may be taken.
[0080] When the plugin package version number meets the preset requirements, the terminal device loads the plugin package through the plugin loading mechanism provided by IDEA. In IDEA, usually through the "Settings" or "Preferences" option under the "File" menu, enter the plugin management interface, and then select the "Install Plugin from Disk" option, browse and select the previously exported IDEA plugin package for loading. IDEA will automatically parse the content in the plugin package and integrate it into the development environment. After the plugin is loaded, IDEA initializes the interaction interface according to the configuration and code of the plugin. This includes creating basic interface elements such as the main window, menu bar, and toolbar, and adding corresponding interface components according to the functional requirements of the plugin. After initialization, IDEA will display the complete interaction interface, including the UI elements added by the plugin. These UI elements can include buttons, drop-down menus, text boxes, dialog boxes, etc., to implement various functions of the plugin. Users can interact with the plugin through the interface and trigger corresponding operations.
[0081] The terminal device needs to configure the corresponding network detection tool to monitor the WebSocket connection between the IDEA plugin package and the node server. The command-line tools (such as netstat, ss, etc.) can be used to view the network connection status, or a custom network detection script can be written to implement more complex detection logic using the network programming libraries in programming languages (such as Python, Java, etc.). Determine the preset port number used by the node server for WebSocket communication. This port number is usually specified by the developer of the node server in the code and recorded in the relevant documentation or configuration file. The terminal device needs to configure this port number into the network detection tool to accurately detect the connection to this port. Start the network detection tool and begin to monitor whether the IDEA plugin package connects to the node server through the preset port based on the WebSocket protocol. The detection tool will scan the network connections in real time to check whether there is a WebSocket connection from the host where the IDEA plugin is located to the preset port of the node server. If the connection is detected, it means the connection is successful; if the connection is not detected within a certain period of time, the connection may fail and further troubleshooting is required.
[0082] The terminal device determines the corresponding test cases according to the functional requirements of the IDEA plugin and the design of the UI elements. The test cases should cover different operation scenarios and expected results of each UI element. For example, for the button UI element, the test cases can include whether the corresponding function is triggered after clicking the button and whether the display status of the button is correct. Use automated testing tools (such as Selenium, Appium, etc., if the IDEA plugin has a corresponding Web or mobile interface) or manual operation to perform functional tests on each UI element on the IDEA interaction interface. In automated testing, write test scripts to simulate user operations and verify whether the responses of the UI elements and the outputs of the system meet the expectations. In manual testing, the tester operates each UI element step by step according to the test cases and records the test results.
[0083] During the testing process, record the test results of each UI element, including the cases where the tests pass and the problems that occur. For the cases where the tests fail, record the error information, operation steps, and expected results in detail so that the developers can conduct troubleshooting and repairs. After the testing is completed, analyze the test results, count the test pass rate and failure rate, and evaluate the functional integrity and stability of the plugin.
[0084] In summary, by exporting the plugin package and performing integrity verification and version number judgment, it is possible to ensure that the IDEA plugin package used is complete and meets the preset requirements. This helps to avoid problems such as plugin installation failures and functional abnormalities caused by damaged plugin packages or version mismatches, improves the quality and compatibility of the plugins, and ensures that the plugins can run stably in the IDEA environment.
[0085] Further, on a terminal device running the Windows operating system, search for "cmd" in the "Start" menu or directly press the "Win+R" key combination. In the pop-up Run dialog box, enter "cmd" and press the Enter key to open the CMD command line window. The terminal device needs to know the preset port number used by the node server to be queried. This port number is usually specified by the developer of the node server in the code and recorded in relevant documents or configuration files.
[0086] In the CMD (Command Prompt) command line window, enter the command "netstat -ano | findstr "preset port number", replacing "preset port number" with the actual port number value. For example, if the preset port number is 12036, enter "netstat -ano | findstr "12036". After pressing the Enter key, the CMD command line window will execute this command and display network connection information related to the specified port number, including local address, external address, status, and process ID (PID), etc. Through this information, the terminal device can initially determine whether a node server is mounted on this port.
[0087] Since the CMD command itself cannot directly detect the communication protocol, the terminal device needs to rely on other tools or methods to analyze network traffic or process information to determine the communication protocol. The terminal device can install and run a network packet capture tool such as Wireshark. In Wireshark, select the network interface related to the node server for packet capture, and then analyze the protocol type of the network packets based on the capture results. Locate the packets related to the preset port number and check whether the protocol field is the websocket protocol (the identification of the websocket protocol is usually a specific format after the HTTP protocol upgrade, such as starting with GET / HTTP / 1.1 and including headers such as Upgrade: websocket). If the terminal device has permission to access the detailed information of the relevant process, it can judge whether the process uses the websocket protocol by viewing the modules, loaded libraries, or startup parameters of the process. For example, some websocket libraries or frameworks will load specific dynamic link libraries (DLLs) when the process starts. By checking the DLL list loaded by the process, it can be speculated whether the process uses the websocket protocol.
[0088] The terminal device can determine whether a communication connection has been established with the node server by checking the network connection status of local processes. In the CMD command-line window, use the netstat -ano command again to view all network connection information. Combine the process ID (PID) related to the preset port number queried previously to find the corresponding local address and external address. If there is a connection with the "ESTABLISHED" status between the local address and the address of the node server (obtained from the previous query results), it indicates that a communication connection has been established between the local process and the node server.
[0089] In summary, the terminal device can effectively query the node server mounted on the preset port, accurately detect whether its communication protocol is the websocket protocol, and at the same time determine whether a communication connection has been established with the node server. This series of operations helps developers or operators to timely understand the running status and communication situation of the node server. During the development process, it can ensure normal communication between the plugin and the node server, improving development efficiency and system stability; during the operation and maintenance process, it can quickly locate and solve problems caused by network connection or protocol mismatch, ensuring the normal operation of the system.
[0090] Furthermore, the terminal device can also verify the original VSCode plugin package. The verification process includes:
[0091] The terminal device first determines the output directory after the VSCode plugin project is built. If the built-in build function or build tool of VSCode (such as the vsce tool package) is used, the plugin package will be stored in a specified location after building. The output directory path can be determined by viewing the project configuration file (such as the relevant build configuration in package.json) or the build log. Enter the build output directory and search for the generated plugin package file according to the naming rule of the VSCode plugin package (usually in the.vsix format). The search function of the file explorer can be used to quickly locate by entering the.vsix suffix.
[0092] After finding the plugin package, copy the file to the target location through the file explorer, such as an external storage device or a network storage location. The command-line tool (such as the cp command on macOS / Linux and the copy command on Windows) can also be used to copy it to the specified directory.
[0093] The terminal device needs to obtain the rules for verifying the integrity of the plugin package, which can include file size, hash values (such as MD5, SHA-256, etc.). These rules are usually defined by the plugin developer and recorded in a document or configuration file. Use the corresponding verification tools (such as the md5sum, sha256sum command-line tools, or use a hash algorithm library in the code) to calculate the verification value of the plugin package. For example, in the Linux or macOS terminal, use md5sum plugin_package_name.vsix to calculate the MD5 hash value. Compare the calculated verification value with the verification value in the predefined integrity verification rules. If they are the same, it means the plugin package is complete; if they are different, the plugin package may be damaged or tampered with, and it needs to be retrieved or processed again.
[0094] In VSCode, through the "Extensions" view (shortcut Ctrl+Shift+X or Cmd+Shift+X), click the "..." menu and select "Install from VSIX", browse and select the verified plugin package for loading. VSCode will automatically parse and integrate the plugin. After the plugin is loaded, VSCode initializes the interactive interface according to the plugin configuration and code, creates basic elements such as the main window, menu bar, toolbar, etc., and adds the interface components required by the plugin. After initialization is complete, VSCode displays the complete interactive interface, including the UI elements added by the plugin, such as buttons, dropdown menus, text boxes, etc., and users can interact with the plugin through the interface.
[0095] According to the functional requirements and UI element design of the VSCode plugin, determine the test cases to cover different operation scenarios and expected results of each UI element. For example, test whether the corresponding function is triggered after a button is clicked and whether the display status of the button is correct. Use an automated testing tool (such as the VSCode extension testing framework) or manual operation to perform functional tests on the UI elements. The automated test writes scripts to simulate user operations and verify the responses and outputs; the manual test operates according to the test case steps and records the results. Record the test results of each UI element during the test, including the pass and problem situations. For the failure situations, record the error information, operation steps, and expected results in detail to facilitate the developers to troubleshoot and fix. After the test is completed, analyze the results, count the pass rate and failure rate, and evaluate the functional integrity and stability of the plugin.
[0096] In summary, the terminal device can ensure the correct export and integrity of the VSCode plugin package, avoiding installation failures or functional abnormalities caused by plugin package problems. Load the plugin package and display the interactive interface and UI elements, enabling users to intuitively use the plugin functions. Performing functional tests on the UI elements can timely discover and fix the functional defects in the plugin, improve the quality and stability of the plugin, and ensure a good experience for users when using the plugin in the VSCode environment.
[0097] In the embodiments of the present application, when the terminal device is dealing with issues related to the VSCode source code toolkit involving the front-end dist directory, considering that if the HTML page can be loaded through VSCode, the acquireVsCodeApi method can be used to obtain the VSCode API. When using JBCefClient to load the HTML page of IDEA, a specific identifier is set for it to indicate the IDEA-side environment. In this way, in the IDEA environment, the communication method between the static page and the outside can be switched from the conventional method to the method based on the JBCefClient client, and then a connection is established with the Java application of IDEA. On the VSCode side, whether interacting with the static page or communicating with the node server, the VSCode source code toolkit is uniformly used to ensure the consistency and stability of communication.
[0098] Since the node server needs to adjust the original communication method based on the VSCode toolkit to use the websocket protocol for communication in the IDEA environment, the terminal device can adopt a flexible architecture design. Specifically, at the code level, different implementation classes are used for message distribution and processing according to whether the currently connected client is the VSCode side or the IDEA side. This design method can effectively decouple the communication logics of different clients, improve the maintainability and extensibility of the code, and enable the system to adaptively select the appropriate communication method according to different client environments.
[0099] Since the plugin cannot be directly loaded on the IDEA side to execute the relevant operations of the node server, the terminal device needs to adopt an indirect method to implement this function. After successfully loading the IDEA plugin, the ProcessBuilder class is used to mount the startup and destruction processes of the node server. In this way, the IDEA side can establish a websocket communication connection with the node server, so as to achieve data interaction and functional collaboration between the two. When starting the node server, relevant parameters and configurations can be specified to ensure that the server can run as expected; when the server needs to be destroyed, it can also be gracefully shut down through ProcessBuilder to release system resources.
[0100] When it is necessary to execute the functions corresponding to the right - click operations on the VSCode side on the node server - side, in the node server - side code of the terminal device, the vscode.commands.registerCommand method is used to register the corresponding functions. While on the IDEA side, to achieve similar functions, it needs to be adjusted to use AnAction to register the corresponding actions. There are certain differences in the specific business logic processing. For example, on the VSCode side, tools provided by VSCode such as vscode.window or vscode.workspace can be directly used to obtain information about each method in a Java file and data such as the offset of the code snippet currently selected by the user. While on the IDEA side, APIs such as Editor operators provided by IDEA need to be used to handle these business logics. Through this differential processing method, it can be ensured that the right - click operation functions can be correctly implemented in different development environments.
[0101] After completing the above - mentioned various configurations and code implementations, the terminal device ensures that the IDEA side can normally execute the corresponding operations through the right - click menu. When the user right - clicks on an element in the IDEA interface, the system can trigger the corresponding business logic processing according to the previously registered AnAction. For example, obtaining detailed information about each method in the current Java file or determining the specific offset of the code snippet selected by the user in the file. After these business logic processes are completed, corresponding feedback can be given according to actual needs, such as displaying the processing results on the interface or passing the data to other modules for further processing, so as to provide users with a complete and smooth functional experience.
[0102] The present application has the following beneficial effects:
[0103] A communication and function implementation framework spanning the VSCode and IDEA environments is constructed. In terms of communication, a flexible and stable communication method between different clients and the node server - side is realized, which can automatically select the appropriate communication protocol according to the client environment, improving the compatibility and scalability of the system. In terms of function implementation, according to the characteristics of different development environments, a differential code implementation method is adopted to ensure that functions such as right - click operations can be correctly and efficiently executed in different environments. This design not only improves development efficiency and reduces duplicate code writing, but also provides users with a consistent and high - quality functional experience in different development tools, enhancing the practicality and competitiveness of the entire development system.
[0104] The following is the device embodiment of the present application, which can be used to execute the method embodiment of the present application. For details not disclosed in the device embodiment of the present application, please refer to the method embodiment of the present application.
[0105] Please refer to Figure 4 , which shows a schematic structural diagram of a device for reusing VScode plug-in code in an IDEA plug-in package provided by an exemplary embodiment of the present application, hereinafter referred to as device 4. The device 4 can be implemented as all or part of a terminal device through software, hardware, or a combination of both. The device 4 includes: an acquisition unit 401, a replacement unit 402, and a generation unit 403.
[0106] The acquisition unit 401 is configured to acquire the page-end code of the VSCode plug-in package;
[0107] The replacement unit 402 is configured to replace the communication method of the page-end code with communication using JBCefClient;
[0108] The acquisition unit 401 is further configured to acquire the node server-side code of the VSCode plug-in;
[0109] The replacement unit 402 is further configured to replace the communication protocol between the front-end page and the node server-side code with the websocket protocol;
[0110] The generation unit 403 is configured to generate an IDEA plug-in package based on the replaced front-end page code and node server-side code.
[0111] In one or more possible embodiments, acquiring the front-end page code of the VSCode plug-in includes:
[0112] Acquiring the VSCode plug-in package in the local project directory of the VSCode plug-in; or
[0113] Acquiring the page front-end code associated with the VSCode plug-in in the code repository.
[0114] In one or more possible embodiments, it further includes:
[0115] The IDEA verification unit is configured to export the generated IDEA plug-in package;
[0116] Performing integrity verification on the IDEA plug-in package;
[0117] After the verification passes, determining whether the version number of the IDEA plug-in package is a preset version number;
[0118] If so, after loading the IDEA plug-in package, display the IDEA interaction interface and the UI elements included in the IDEA interaction interface;
[0119] Detect whether the IDEA plug-in package is connected to the node server through a preset port based on the websocket protocol;
[0120] If it is, perform functional tests on each UI element on the IDEA interaction interface.
[0121] In one or more possible embodiments, detecting whether the IDEA plugin package is connected to the node server through a preset port based on the websocket protocol includes:
[0122] Based on the CMD command: netstat - ano | findstr "preset port number", query the mounted node server;
[0123] Detect whether the communication protocol of the node server is the websocket protocol;
[0124] If it is, determine whether the terminal device has established a communication connection with the node server.
[0125] In one or more possible embodiments, it further includes:
[0126] A VSCode verification unit for exporting the VSCode plugin package;
[0127] Perform integrity verification on the VSCode plugin package;
[0128] After the verification passes, load the VSCode plugin package and display the VSCode interaction interface and the UI elements included in the VSCode interaction interface;
[0129] Perform functional tests on each UI element on the VSCode interaction interface.
[0130] In one or more possible embodiments, the format of the VSCode plugin package is vsix, and the format of the IDEA plugin package is jar.
[0131] In one or more possible embodiments, the page - end code includes: HTML, CSS, JavaScript, pictures, icons, fonts, and configuration files.
[0132] It should be noted that when the device 4 provided in the above embodiments executes the method of reusing VScode plug-in code in the IDEA plug-in package, only the division of the above functional modules is used for illustration. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above functions. In addition, the device for reusing VScode plug-in code in the IDEA plug-in package provided in the above embodiments and the method embodiments for reusing VScode plug-in code in the IDEA plug-in package belong to the same concept. The implementation process is detailed in the method embodiments and will not be elaborated here.
[0133] The serial numbers of the embodiments of the present application above are only for description and do not represent the advantages or disadvantages of the embodiments.
[0134] The embodiments of the present application also provide a computer storage medium. The computer storage medium can store multiple instructions, and the instructions are suitable for being loaded and executed by a processor to perform the method steps of the embodiments as described above Figure 2 The specific execution process can be referred to Figure 2 the specific description of the embodiments shown, and will not be elaborated here.
[0135] The present application also provides a computer program product. The computer program product stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the method of reusing VScode plug-in code in the IDEA plug-in package as described in the above embodiments.
[0136] Please refer to Figure 5 which is a schematic structural diagram of a terminal device provided by an embodiment of the present application. As Figure 5 shown, the terminal device 500 may include: at least one processor 501, at least one network interface 504, a user interface 503, a memory 505, and at least one communication bus 502.
[0137] Among them, the communication bus 502 is used to realize the connection and communication between these components.
[0138] Among them, the user interface 503 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 503 may further include a standard wired interface and a wireless interface.
[0139] Among them, the network interface 504 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
[0140] Among them, the processor 501 may include one or more processing cores. The processor 501 connects various parts within the entire terminal device 500 through various interfaces and circuits. By running or executing instructions, programs, code sets, or instruction sets stored in the memory 505, and by calling the data stored in the memory 505, it performs various functions of the terminal device 500 and processes data. Optionally, the processor 501 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 501 may integrate a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, user interface, application programs, etc.; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 501 and may be implemented separately by a single chip.
[0141] Among them, the memory 505 may include random access memory (RAM) and may also include read-only memory. Optionally, the memory 505 includes a non-transitory computer-readable storage medium. The memory 505 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 505 may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing the operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store the data involved in the above-mentioned various method embodiments. Optionally, the memory 505 may further be at least one storage device located away from the aforementioned processor 501. As Figure 5 shown, the memory 505, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and application programs.
[0142] In Figure 5In the terminal device 500 shown, the user interface 503 is mainly used to provide an interface for the user to input data and obtain the data input by the user; while the processor 501 can be used to call the application programs stored in the memory 505 and specifically execute as Figure 2 shown in the method, and the specific process can be referred to Figure 2 shown, which will not be elaborated here.
[0143] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory, or a random access memory, etc.
[0144] The above-disclosed are only the preferred embodiments of the present application. Of course, the scope of the rights of the present application cannot be limited by this. Therefore, equivalent changes made according to the claims of the present application still fall within the scope covered by the present application.
Claims
1. A method for reusing VScode plugin code in an IDEA plugin package, characterized in that, Including: Obtain the page - end code of the VSCode plugin package; Replace the communication method of the page - end code with communication using JBCefClient; Obtain the node server - end code of the VSCode plugin; Replace the communication protocol between the front - end page and the node server - end code with the websocket protocol; Generate an IDEA plugin package based on the replaced front - end page code and node server - end code.
2. The method according to claim 1, wherein The obtaining of the front - end page code of the VSCode plugin includes: Obtain the VSCode plugin package in the local project directory of the VSCode plugin; or Obtain the front - end page code associated with the VSCode plugin in the code repository.
3. The method according to claim 1 or 2, characterized in that, Also including: Export the generated IDEA plugin package; Perform integrity verification on the IDEA plugin package; After the verification passes, determine whether the version number of the IDEA plugin package is the preset version number; If so, display the IDEA interaction interface and the UI elements included in the IDEA interaction interface after loading the IDEA plugin package; Detect that the IDEA plugin package connects to the node server through the preset port based on the websocket protocol; If so, perform functional tests on each UI element on the IDEA interaction interface.
4. The method according to claim 3, wherein Including: Based on the CMD command: netstat - ano|findstr "preset port number”, query the mounted node server; Detect whether the communication protocol of the node server is the websocket protocol; If so, determine whether the terminal device has established a communication connection with the node server.
5. The method according to claim 1 or 2 or 4, characterized in that, Also including: Export the VSCode plugin package; Perform integrity verification on the VSCode plugin package; After the verification passes, display the VSCode interaction interface and the UI elements included in the VSCode interaction interface after loading the VSCode plugin package; Perform functional tests on each UI element on the VSCode interaction interface.
6. The method according to claim 5, characterized in that, The format of the VSCode plugin package is vsix, and the format of the IDEA plugin package is jar.
7. The method according to claim 6, characterized in that, The page - end code includes: HTML, CSS, JavaScript, pictures, icons, fonts, and configuration files.
8. A device for reusing VScode plugin code in an IDEA plugin package, characterized in that, Including: An obtaining unit for obtaining the page - end code of the VSCode plugin package; A replacement unit for replacing the communication method of the page - end code with communication using JBCefClient; The obtaining unit is also used for obtaining the node server - end code of the VSCode plugin; The replacement unit is also used for replacing the communication protocol between the front - end page and the node server - end code with the websocket protocol; A generating unit for generating an IDEA plugin package based on the replaced front - end page code and node server - end code.
9. A computer storage medium, characterized in that, The computer storage medium stores multiple instructions, and the instructions are suitable for being loaded and executed by a processor to perform the method steps of any one of claims 1 - 7.
10. A terminal device, characterized in that, Including: A processor and a memory; wherein, the memory stores a computer program, and the computer program is adapted to be loaded and executed by the processor to perform the method steps of any one of claims 1 to 7.
Citation Information
Cited By
Business system plug-in method and device and electronic equipment
CN121614194A