Programming language extension method, system, computing device, and storage medium
Patent Information
- Application Number
- CN202310737375.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-20
- Publication Date
- 2026-10-20
- Estimated Expiration
- 2043-06-20
AI Technical Summary
[0006]为此,本发明提供一种编程语言扩展方法及编程语言扩展系统,以解决或至少缓解上面存在的问题
[0020]根据本发明的技术方案,提供了一种编程语言扩展方法及系统,通过在前端接入与新编程语言相对应的新语言插件,在前端使用新编程语言时,可以通过业务插件从新编程语言对应的新语言插件中获取新语言功能参数,基于新语言功能参数向后端的对应中间协议适配器发送功能服务调用请求,中间协议适配器可以根据新语言功能参数加载对应的语言功能服务插件,以便与语言功能服务插件建立通信连接,实现调用语言功能服务插件提供的功能服务。这样,根据本发明的技术方案,在需要扩展新编程语言时,只需要在前后端分别接入与新编程语言对应的插件,便能实现与新编程语言相适配的功能服务,前后端均无需修改代码,从而增强了语言的扩展性,解耦了插件之间的依赖关系,并且,实现各编程语言之间相互隔离。
Smart Images

Figure CN116737273B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of application development technology, and in particular to a programming language extension method, a programming language extension system, a computing device, and a storage medium. Background Technology
[0002] An IDE (Integrated Development Environment) is an application that provides a program development environment, typically including tools such as a code editor, compiler, debugger, and graphical user interface.
[0003] Currently, with the proliferation of programming languages, the demands on IDEs' language extensibility are increasing. In existing technologies, IDEs like Qt Creator and PyCharm, which are highly specialized, support relatively fixed languages and have limited extensibility. VSCode, as a universal editor and development tool, possesses strong extensibility; however, its implementation based on the Electron and TypeScript technology stack, while simplifying IDE development complexity, sacrifices performance due to the interpreter. Furthermore, VSCode's architecture is not well-suited for compiled language development. Qt Creator is a widely used IDE tool on the Linux platform, primarily designed for C / C++ language development.
[0004] Qt Creator's language-related functionalities are implemented by loading different plugins. Compilation-related functions are implemented in the `cmakeprojectmanager` plugin, while debugging-related functions are implemented in the `debugger` plugin. The `debugger` plugin directly depends on the logic in the `projectexplorer` plugin, resulting in a lack of decoupling within the plugins. Furthermore, while Qt Creator is based on plugins, it doesn't consider extensibility. The internal logic of plugins is overly heavy; language-related code is written into the core business plugin 211 (compile and debug), meaning that extending to a new language requires modifying the code within the core business plugin, which clearly violates the open / closed principle. Moreover, the toolchain is implemented using direct calls. Since language and debugging services are resource-intensive, direct calls within the IDE consume IDE resources and impact efficiency. Therefore, Qt Creator suffers from weak extensibility, strong dependencies between plugins, and a lack of business decoupling.
[0005] Therefore, a programming language extension method is needed to solve the problems existing in the above technical solutions. Summary of the Invention
[0006] Therefore, the present invention provides a programming language extension method and a programming language extension system to solve or at least alleviate the problems mentioned above.
[0007] According to one aspect of the present invention, a programming language extension method is provided, adapted to be executed on a front end to extend a new programming language, the front end including a business plugin and adapted to access a new language plugin corresponding to the new programming language; the method includes: loading the business plugin based on the new programming language; obtaining new language function parameters from the new language plugin corresponding to the new programming language through the business plugin; and sending a function service call request to a corresponding intermediate protocol adapter in the back end based on the new language function parameters through the business plugin, so as to request the intermediate protocol adapter to load a corresponding language function service plugin according to the new language function parameters, so as to communicate with the language function service plugin and call the function services provided by the language function service plugin.
[0008] Optionally, according to the programming language extension method of the present invention, the intermediate protocol adapter is adapted to obtain a port number corresponding to the new programming language from the language function service plugin; the method further includes: obtaining the port number returned by the intermediate protocol adapter through the service plugin; requesting the establishment of a language connection to the intermediate protocol adapter according to the port number, so as to communicate with the language function service plugin through the intermediate protocol adapter and call the function services provided by the language function service plugin.
[0009] Optionally, according to the programming language extension method of the present invention, the intermediate protocol adapter is adapted to: determine the programming language as a new programming language according to the new language function parameters, and load the corresponding language function service plugin according to the new programming language.
[0010] Optionally, according to the programming language extension method of the present invention, the front end is adapted to provide one or more service interfaces through independent plugins, so that the new language plugins can call the service interfaces to implement service logic corresponding to the service interfaces.
[0011] Optionally, according to the programming language extension method of the present invention, each service interface corresponds to multiple service plugins; the method further includes: calling the service interface through the new language plugin to load multiple service plugins corresponding to the service interface.
[0012] Optionally, according to the programming language extension method of the present invention, the service interface includes a window service interface, and the method further includes: calling the window service interface through the new language plugin to embed a programming page corresponding to the new programming language into the front end.
[0013] Optionally, according to the programming language extension method of the present invention, the service interface includes a language service interface, and the new language plugin is adapted to actively register with the language service interface so as to provide the basic class to be implemented by the new language plugin through the language service interface.
[0014] Optionally, according to the programming language extension method of the present invention, the business plugin includes a debugging plugin and a compilation plugin.
[0015] Optionally, according to the programming language extension method of the present invention, the backend is adapted to access a language function service plugin corresponding to the new programming language; the intermediate protocol adapter includes: a debug protocol adapter and a language service protocol adapter; the language function service plugin includes: a debug service plugin and a language service plugin.
[0016] Optionally, according to the programming language extension method of the present invention, the language connection is a TCP connection based on the new programming language.
[0017] According to one aspect of the present invention, a programming language extension system is provided, comprising: a front end, including a business plugin and adapted to access a new language plugin corresponding to a new programming language; a back end, including an intermediate protocol adapter and adapted to access a language function service plugin corresponding to the new programming language; wherein the front end is adapted to perform the method described above to extend the new programming language.
[0018] According to one aspect of the present invention, a computing device is provided, comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions including instructions for performing the programming language extension method as described above.
[0019] According to one aspect of the present invention, a readable storage medium storing program instructions is provided, which, when read and executed by a computing device, causes the computing device to perform the programming language extension method as described above.
[0020] According to the technical solution of the present invention, a method and system for extending a programming language are provided. By integrating a new language plugin corresponding to the new programming language into the front end, when the new programming language is used on the front end, the business plugin can obtain new language function parameters from the corresponding new language plugin. Based on the new language function parameters, a function service call request is sent to the corresponding intermediate protocol adapter on the back end. The intermediate protocol adapter can load the corresponding language function service plugin according to the new language function parameters to establish a communication connection with the language function service plugin, thereby enabling the invocation of the function services provided by the language function service plugin. Thus, according to the technical solution of the present invention, when it is necessary to extend a new programming language, it is only necessary to integrate the corresponding plugin into the front end and back end respectively to achieve function services adapted to the new programming language. Neither the front end nor the back end needs to modify the code, thereby enhancing the extensibility of the language, decoupling the dependencies between plugins, and achieving isolation between different programming languages.
[0021] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0022] To achieve the foregoing and related objectives, certain illustrative aspects are described herein in conjunction with the following description and accompanying drawings. These aspects indicate various ways in which the principles disclosed herein may be practiced, and all aspects and their equivalents are intended to fall within the scope of the claimed subject matter. The foregoing and other objectives, features, and advantages of this disclosure will become more apparent from the following detailed description, taken in conjunction with the accompanying drawings. Throughout this disclosure, the same reference numerals generally refer to the same parts or elements.
[0023] Figure 1 A schematic diagram of a computing device 100 according to an embodiment of the present invention is shown;
[0024] Figure 2 A schematic diagram of a programming language extension system 200 according to an embodiment of the present invention is shown;
[0025] Figure 3 A flowchart illustrating a programming language extension method 300 according to an embodiment of the present invention is shown;
[0026] Figure 4 A timing diagram showing the interaction between a service plugin 211, a new language plugin, an intermediate protocol adapter 221, and a language function service plugin 222 according to an embodiment of the present invention is shown.
[0027] Figure 5A schematic diagram illustrating the relationship between a service interface and a service plugin according to an embodiment of the present invention is shown.
[0028] Figure 6 A schematic diagram illustrating the relationship between a language plugin 212, a service interface, and a business plugin 211 according to an embodiment of the present invention is shown. Detailed Implementation
[0029] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0030] Figure 1 A schematic diagram of a computing device 100 according to an embodiment of the present invention is shown. Figure 1 As shown, in a basic configuration, computing device 100 includes at least one processing unit 102 and system memory 104. According to one aspect, depending on the configuration and type of the computing device, the processing unit 102 may be implemented as a processor. System memory 104 includes, but is not limited to, volatile memory (e.g., random access memory), non-volatile memory (e.g., read-only memory), flash memory, or any combination of such memories. According to one aspect, system memory 104 includes an operating system 105.
[0031] According to one aspect, operating system 105 is, for example, suitable for controlling the operation of computing device 100. Furthermore, examples are practiced in conjunction with graphics libraries, other operating systems, or any other applications, and are not limited to any particular application or system. Figure 1 The basic configuration is illustrated by the components within the dashed lines. According to one aspect, the computing device 100 has additional features or functions. For example, according to one aspect, the computing device 100 includes additional data storage devices (removable and / or non-removable), such as disks, optical discs, or magnetic tapes. This additional storage... Figure 1 The middle part is shown by removable storage device 109 and non-removable storage device 110.
[0032] As stated above, according to one aspect, program module 103 is stored in system memory 104. According to one aspect, program module 103 may include one or more applications. The present invention does not limit the type of application; for example, applications may include: email and contact applications, word processing applications, spreadsheet applications, database applications, slideshow applications, drawing or computer-aided applications, web browser applications, etc.
[0033] According to one aspect, program module 103 may further include multiple program instructions for executing the programming language extension method 300 of the present invention, so that the programming language extension method 300 of the present invention is executed in computing device 100.
[0034] According to one aspect, examples can be practiced on circuits including discrete electronic components, packaged or integrated electronic chips containing logic gates, circuits utilizing microprocessors, or on a single chip containing electronic components or a microprocessor. For example, it can be practiced via wherein... Figure 1 Each or many of the components shown can be implemented as an example by integrating a System-on-a-Chip (SOC) on a single integrated circuit. According to one aspect, such an SOC device may include one or more processing units, graphics units, communication units, system virtualization units, and various application functions, all integrated (or “burned in”) as a single integrated circuit onto a chip substrate. When operating via the SOC, the functions described herein can be operated via dedicated logic integrated on a single integrated circuit (chip) with other components of the computing device 100. Embodiments of the invention can also be implemented using other techniques capable of performing logical operations (e.g., AND, OR, and NOT), including but not limited to mechanical, optical, fluid, and quantum technologies. Additionally, embodiments of the invention can be implemented within a general-purpose computer or in any other circuit or system.
[0035] According to one aspect, computing device 100 may also have one or more input devices 112, such as a keyboard, mouse, pen, voice input device, touch input device, etc. It may also include output devices 114, such as a display, speaker, printer, etc. The foregoing devices are examples and other devices may also be used. Computing device 100 may include one or more communication connections 116 that allow communication with other computing devices 118. Examples of suitable communication connections 116 include, but are not limited to: RF transmitter, receiver and / or transceiver circuitry; Universal Serial Bus (USB), parallel and / or serial ports.
[0036] As used herein, the term computer-readable medium includes computer storage medium. Computer storage medium can include volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information (e.g., computer-readable instructions, data structures, or program module 103). System memory 104, removable storage device 109, and non-removable storage device 110 are examples of computer storage media (i.e., memory storage). Computer storage media can include random access memory (RAM), read-only memory (ROM), electrically erasable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical storage, magnetic tape, magnetic tape, disk storage or other magnetic storage devices, or any other article of manufacture that can be used to store information and is accessible by computer device 100. According to one aspect, any such computer storage medium can be part of computing device 100. Computer storage media does not include carrier waves or other transmitted data signals.
[0037] According to one aspect, the communication medium is implemented by computer-readable instructions, data structures, program modules 103, or other data in a modulated data signal (e.g., a carrier wave or other transmission mechanism), and includes any information transmission medium. According to one aspect, the term "modulated data signal" describes a signal having one or more sets of characteristics or altered in a manner that encodes information in the signal. By way of example and not limitation, the communication medium includes wired media such as wired networks or direct wired connections, and wireless media such as acoustic, radio frequency (RF), infrared, and other wireless media.
[0038] In an embodiment of the invention, a computing device 100 is configured to execute a programming language extension method 300 according to the invention. The computing device 100 includes one or more processors and one or more readable storage media storing program instructions that, when configured to be executed by the one or more processors, cause the computing device to execute the programming language extension method 300 according to the embodiment of the invention.
[0039] Figure 2 A schematic diagram of a programming language extension system 200 according to an embodiment of the present invention is shown. Figure 2 As shown, the programming language extension system 200 includes a front-end 210 and a back-end 220, and the front-end 210 can establish a communication connection with the back-end 220.
[0040] The front-end 210 can be configured to execute the programming language extension method 300 of the present invention. The programming language extension method 300 of the present invention will be described in detail below.
[0041] In one embodiment, the front end 210 can be implemented as an application in the computing device 100, for example, as an integrated development application (IDE) and deployed in the program modules of the computing device 100. When the front end 210 (IDE) is configured to execute the programming language extension method 300 of the present invention, it can extend the IDE with a new programming language so as to develop programs using the new programming language.
[0042] In one embodiment, such as Figure 2 As shown, the front-end 210 and the back-end 220 can respectively include a business layer, a plugin layer, and a tool layer.
[0043] In embodiments of the present invention, the front-end 210 (e.g., an integrated development application) includes one or more business plugins 211. Furthermore, the front-end 210 can access language plugins 212 corresponding to each programming language, with one language plugin 212 corresponding to each programming language. Specifically, each business plugin 211 is deployed in the business layer of the front-end 210.
[0044] In one embodiment, business plugin 211 may include, for example, a debugging plugin and a compilation plugin.
[0045] For example, in one embodiment, the plugin layer of the front-end 210 may include one or more language plugins 212 corresponding to one or more programming languages. It should be noted that each language plugin 212 is used to encapsulate special processing logic related to the corresponding programming language, such as debugging, project tree generation, and other processing logic.
[0046] The front-end 210 tool layer may include language toolchains corresponding to each of the above language plugins. For example, a language toolchain may include: language engineering tools (for project organization and generating database data, such as CMake) and language compilation tools (for language compilation and generating binary files, such as GCC and Maven).
[0047] In some embodiments, programming languages include, for example, C / C++, Java, Python, etc., and for each programming language, a language plugin 212 corresponding to the programming language can be connected to the front end 210.
[0048] It should be noted that the business plugin 211 of this invention does not contain any code related to the programming language. In embodiments of this invention, when a new programming language needs to be extended in the front-end 210 (integrated development application), a new language plugin corresponding to the new programming language can be integrated into the front-end 210 without modifying the business plugin 211. It can be understood that the new language plugin is used to encapsulate special processing logic related to the new programming language, such as debugging and project tree generation.
[0049] In embodiments of the present invention, the backend 220 may include an intermediate protocol adapter 221 corresponding to each service plugin 211, such as a debug protocol adapter (DAP adapter) corresponding to a debug plugin and a language service protocol adapter (LSP adapter) corresponding to a compile plugin. The debug plugin can communicate with the debug protocol adapter via the debug adapter (DAP), and the compile plugin can communicate with the language service protocol adapter via the language service protocol (LSP).
[0050] It should be noted that, based on the LSP language service protocol, functions such as syntax highlighting, symbol trees, and syntax trees can be implemented. Based on the DAP debugging adaptation protocol, common debugging functions such as starting, running, breakingpoint hitting, stepping in, and stepping out of the debugged program can be implemented. Through the adaptation of the intermediate protocol, the dependency between business plugins and actual functional service providers can be decoupled, which facilitates the extension of programming languages.
[0051] The backend 220 may also include language function service plugins 222 corresponding to one or more programming languages, which provide corresponding function services to the frontend (business plugin). Furthermore, the backend 220 can connect to a language function service plugin 222 (new language function service plugin 222) corresponding to a new programming language to provide function services adapted to the new programming language. Here, the language function service plugin 222 may include multiple types, each corresponding to a business plugin 211. For example, the language function service plugin 222 may include a debugging service plugin (DAP plugin) corresponding to a debugging plugin and a language service plugin (LSP plugin) corresponding to a compilation plugin.
[0052] Here, the Debugging Service Plugin (DAP plugin) can encapsulate debugging functions related to the corresponding programming language to provide debugging services. The Language Service Plugin (LSP plugin) can encapsulate syntax and semantic functions related to the corresponding programming language to provide syntax services.
[0053] It should be noted that the backend intermediate protocol adapter is mainly used to distinguish and forward data from different programming languages. The specific logic can be implemented in the corresponding language function service plugin.
[0054] In one embodiment, the tool layer of the backend 220 may include a language service toolchain corresponding to each of the language function service plugins 222 described above. For example, the language service toolchain may include: debugging service tools (encapsulations of debugging service providers, such as gdb, jdb, pdb) and language service tools (encapsulations of syntax service providers, such as clangd).
[0055] Figure 3 A flowchart illustrating a programming language extension method 300 according to an embodiment of the present invention is shown. Method 300 is adapted to be executed at a front end 210 (in computing device 100).
[0056] like Figure 3 As shown, method 300 begins with step 310.
[0057] First, in step 310, the business plugin 211 is loaded based on the new programming language.
[0058] Specifically, when a new programming language is used in the front-end 210 (integrated development application), for example, when developing a program using a new programming language, the corresponding business plugin 211 (debugging plugin / compilation plugin) can be loaded according to the required functions (e.g., debugging function / compilation function). It can be understood that the business plugin 211 loaded in step 310 can be a debugging plugin or a compilation plugin.
[0059] Subsequently, in step 320, the new language function parameters are obtained from the new language plugin corresponding to the new programming language through the business plugin 211. Here, the new language function parameters may include relevant data from the intermediate protocol adapter 221.
[0060] It should be noted that by loading business plugin 211, a business process corresponding to that plugin can be implemented. For example, by loading a debugging plugin, a debugging-related business process can be implemented. However, the functional parameters (which are debugging parameters for the debugging plugin) are different for each programming language and are related to the programming language. Based on this, business plugin 211 can load a corresponding new language plugin according to the new programming language, so as to obtain the new language functional parameters (related to the new programming language) from the new language plugin. Here, the new language functional parameters may include relevant data of the intermediate protocol adapter 221. For example, when business plugin 211 is a debugging plugin, the new language functional parameters may include relevant data of the debugging protocol adapter (DAPadapter).
[0061] Next, in step 330, the business plugin 211 sends a function service call request (which includes the new language function parameters) to the corresponding intermediate protocol adapter 221 of the backend 220 based on the new language function parameters. This requests the intermediate protocol adapter 221 to load the corresponding language function service plugin 222 according to the new language function parameters, so as to communicate with the language function service plugin 222 and call the function service provided by the language function service plugin 222 (e.g., the debugging service provided by the debugging service plugin, or the syntax service provided by the language service plugin).
[0062] Specifically, after receiving a function service call request from the business plugin 211, the intermediate protocol adapter 221 can determine the programming language used by the front end 210 as the new programming language based on the new language function parameters in the function service call request. Then, it can load the language function service plugin 222 corresponding to the new programming language based on the determined new programming language.
[0063] For example, in one embodiment, when the business plugin 211 is a debugging plugin, the new language function parameters may include relevant data of the debugging protocol adapter (DAP adapter). Thus, the debugging plugin can send a debugging request to the debugging protocol adapter of the backend 220 based on the new language function parameters to request the debugging protocol adapter to load the corresponding debugging service plugin (DAP plugin) according to the new language function parameters. This allows the plugin to communicate with the debugging service plugin and call the debugging services provided by the debugging service plugin.
[0064] In one implementation, the service plugin 211 can send a function service call request to the corresponding intermediate protocol adapter 221 via the D-Bus bus.
[0065] It should be noted that the language function service plugin 222 can be adapted for different programming languages to enable the access of function services compatible with the new programming language. Thus, when a new programming language needs to be added, by connecting the corresponding new language plugin to the front-end 210 and the corresponding language function service plugin 222 to the back-end 220, the front-end 210 can use the new programming language while the back-end 220 provides the corresponding function services. Both the front-end and back-end 220 only need to connect the plugin; no code modification is required.
[0066] Figure 4 An interaction timing diagram is shown between a service plugin 211, a new language plugin, an intermediate protocol adapter 221, and a language function service plugin 222 according to an embodiment of the present invention.
[0067] like Figure 4 As shown, in one embodiment, after the intermediate protocol adapter 221 loads the language function service plugin 222 corresponding to the new programming language according to the new language function parameters, it can obtain the port number corresponding to the new programming language from the language function service plugin 222 and return the port number to the service plugin 211.
[0068] After obtaining the port number corresponding to the new programming language returned by the intermediate protocol adapter 221, the business plugin 211 can request to establish a language connection (a language connection based on the new programming language) based on the port number. Subsequently, the intermediate protocol adapter 221 can return the connection status to the business plugin 211. After the business plugin 211 determines that the language connection is successful based on the connection status, the front-end 210 can transmit data (send requests and responses) with the back-end 220. Specifically, after the connection is successful, the business plugin 211 can communicate with the language function service plugin 222 through the intermediate protocol adapter 221 to call the function services provided by the language function service plugin 222. Here, the language connection can specifically be a TCP connection based on the new programming language. By establishing the above language connection, a client / server architecture is formed between the front-end and the back-end, weakening the concept of caller and callee.
[0069] like Figure 4 As shown, after a successful language connection is established, business plugin 211 can send a request to intermediate protocol adapter 221 based on the language connection. Intermediate protocol adapter 221 then sends the request to language function service plugin 222. Language function service plugin 222 can return a response to intermediate protocol adapter 221, which then sends the response to business plugin 211. In this way, business plugin 211 can communicate with language function service plugin 222, send request and response data, and thus invoke the functional services provided by language function service plugin 222 via intermediate protocol adapter 221.
[0070] It should be noted that each programming language corresponds to a different port number. Therefore, the TCP connection established between the intermediate protocol adapter 221 and the port number corresponding to the new programming language is based on the new programming language.
[0071] For example, in one embodiment, when the business plugin 211 is a debugging plugin, the debugging plugin can send a debugging request to the debugging protocol adapter of the backend 220 based on the new language feature parameters. The debugging protocol adapter can load the corresponding debugging service plugin (for the new programming language) according to the new language feature parameters, obtain the port number corresponding to the new programming language from the debugging service plugin, and then return the port number to the business plugin 211. In this way, the business plugin 211 of the frontend 210 can request to establish a language connection (a TCP connection based on the new programming language) with the corresponding debugging protocol adapter based on the port number, so that the frontend 210 and the backend 220 can transmit data (send requests and responses) based on the TCP connection. Specifically, after the connection is successful, the business plugin 211 can communicate with the debugging service plugin (send requests and responses) through the debugging protocol adapter to call the debugging service provided by the debugging service plugin.
[0072] Figure 5 A schematic diagram illustrating the relationship between a service interface and a service plugin according to an embodiment of the present invention is shown.
[0073] like Figure 5 As shown, in one embodiment of the present invention, the front-end 210 can independently create a plugin based on the plugin framework, and provide one or more service interfaces through this independent plugin for each language plugin 212 to call. Here, the service interfaces include, for example, Service1, Service2, Service3, etc. Each language plugin 212 can obtain these service interfaces through the context and call them. In this way, new language plugins can also call the above-mentioned service interfaces to implement the service logic corresponding to the service interface. It should be noted that each language plugin 212 can use either an active or passive calling method to call the service interfaces.
[0074] In one embodiment, each service interface can correspond to multiple service plugins (e.g., Plugin1 to PluginN). In method 300 of the present invention, when the front end 210 uses a new programming language (e.g., when an integrated development application uses a new programming language to develop programs), it can call the above-mentioned service interface through the new language plugin corresponding to the new programming language to load multiple service plugins corresponding to the service interface.
[0075] In this way, the service logic corresponding to a service interface can be implemented through multiple service plugins. This allows a complete service logic to be distributed across multiple service plugins corresponding to the service interface, reducing the granularity of the service plugins.
[0076] In one embodiment, each service plugin (Plugin1 to PluginN) can be dynamically bound to a service interface. Specifically, each service plugin can obtain the service interface through the service context and register the methods it needs to implement, thereby enabling multiple service plugins to be dynamically bound to the service interface. This allows one service interface to correspond to multiple service plugins (implementers), distributing a complete service logic across multiple service plugins and reducing the granularity of the service plugins.
[0077] Figure 6 A schematic diagram illustrating the relationship between a language plugin 212, a service interface, and a business plugin 211 according to an embodiment of the present invention is shown.
[0078] In one embodiment, the service logic corresponding to the service interface can be customized. For example, the service interface may include a window service interface, and the service logic corresponding to the window service interface can be to embed a programming page corresponding to a programming language into a predetermined location on the front end 210. Thus, in this embodiment, the window service interface can be called through the new language plugin to embed the programming page corresponding to the new programming language into the front end 210.
[0079] In one embodiment, the service interface may further include a language service interface, which can be used to provide the basic classes required for implementation by each language plugin 212. Furthermore, the language plugin 212 can proactively register with the language service interface. Thus, when a new language plugin corresponding to a new programming language is integrated into the front-end 210, the new language plugin can proactively register with the language service interface, thereby providing the basic classes required for implementation by the new language plugin through the language service interface.
[0080] In addition, some business plugins 211 (such as debugging plugins) can call the language service interface to perform corresponding operations when running to a specified location, so as to complete specific business processes.
[0081] Furthermore, it's important to note that front-end business plugins can be implemented within the corresponding business base classes, taking into account the language characteristics, toolchain parameters, and runtime environment differences of new programming languages. For example, while debugging functionality is based on the DAP protocol and most request packet formats are fixed, some parameters can be flexibly defined. For instance, the startup request might differ across programming languages, and handling these differences requires processing within the business subclass. This principle can be extended to other business functions. Additionally, tool encapsulation for different programming languages can also be implemented within business plugins. For example, for C++, CMake is needed to organize the project structure, while gcc can be used for compilation. The business processes for these tools already exist within the integrated development application, while the business logic for each programming language can be implemented within the business plugin.
[0082] According to the programming language extension method 300 and system 200 of the present invention, by connecting a new language plugin corresponding to the new programming language to the front end, when the new programming language is used on the front end, the new language function parameters can be obtained from the new language plugin corresponding to the new programming language through the business plugin. Based on the new language function parameters, a function service call request is sent to the corresponding intermediate protocol adapter on the back end. The intermediate protocol adapter can load the corresponding language function service plugin according to the new language function parameters, so as to establish a communication connection with the language function service plugin and realize the function service provided by the language function service plugin. In this way, according to the technical solution of the present invention, when it is necessary to extend a new programming language, it is only necessary to connect the plugin corresponding to the new programming language to the front end and the back end respectively to realize the function service adapted to the new programming language. Neither the front end nor the back end needs to modify the code, which enhances the extensibility of the language, decouples the dependencies between plugins, and realizes the isolation between different programming languages.
[0083] In addition, according to the technical solution of the present invention, the language plugin can actively call the service plugin bound to the service interface to implement the corresponding service logic, thereby improving the flexibility of the language plugin.
[0084] The various techniques described herein can be implemented in combination with hardware or software, or a combination thereof. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, can take the form of program code (i.e., instructions) embedded in a tangible medium, such as a removable hard disk, USB flash drive, floppy disk, CD-ROM, or any other machine-readable storage medium, wherein when the program is loaded into and executed by a machine such as a computer, the machine becomes an apparatus for practicing the present invention.
[0085] When the program code is executed on a programmable computer, the mobile terminal generally includes a processor, a processor-readable storage medium (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The memory is configured to store program code; the processor is configured to execute the programming language extension method of the present invention according to instructions in the program code stored in the memory.
[0086] By way of example, and not limitation, readable media include readable storage media and communication media. Readable storage media stores information such as computer-readable instructions, data structures, program modules, or other data. Communication media generally embodies computer-readable instructions, data structures, program modules, or other data in the form of modulated data signals such as carrier waves or other transmission mechanisms, and includes any information delivery medium. Any combination of the above is also included within the scope of readable media.
[0087] In the specification provided herein, the algorithms and displays are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used with the examples of this invention. The required structure for constructing such systems is apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of the invention.
[0088] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0089] Similarly, it should be understood that, in order to streamline this disclosure and aid in understanding one or more aspects of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof in the above description of exemplary embodiments of the invention. However, this method of disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Therefore, the claims following the detailed description are hereby expressly incorporated into that detailed description, wherein each claim itself is a separate embodiment of the invention.
[0090] Those skilled in the art will understand that modules, units, or components of the devices disclosed in the examples herein can be arranged in the devices described in this embodiment, or alternatively, can be located in one or more devices different from the devices in this example. The modules in the foregoing examples can be combined into a single module or, in addition, can be divided into multiple sub-modules.
[0091] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0092] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features included in other embodiments but not others, combinations of features from different embodiments are meant to be within the scope of the invention and form different embodiments.
[0093] Furthermore, some of the embodiments described herein are methods or combinations of method elements that can be implemented by a processor of a computer system or by other means of performing the functions. Therefore, a processor having the necessary instructions for implementing the methods or method elements forms means for implementing the methods or method elements. Furthermore, the elements described herein in the apparatus embodiments are examples of means for implementing the functions performed by elements for the purposes of carrying out the invention.
[0094] As used herein, unless otherwise specified, the use of ordinal numbers such as “first,” “second,” “third,” etc., to describe ordinary objects merely indicates different instances of similar objects and is not intended to imply that the objects being described must have a given order in time, space, ordering, or any other manner.
[0095] Although the invention has been described with respect to a limited number of embodiments, those skilled in the art will understand from the foregoing description that other embodiments are conceivable within the scope of the invention described herein. Furthermore, it should be noted that the language used in this specification has been chosen primarily for readability and edibility purposes, and not for the purpose of interpreting or limiting the subject matter of the invention. Therefore, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the invention is illustrative rather than restrictive, and the scope of the invention is defined by the appended claims.
Claims
1. A programming language extension method, suitable for execution on a front-end to extend a new programming language, said front-end including a business plugin and adapted to access a new language plugin corresponding to the new programming language; the method includes: Load business plugins based on a new programming language; The new language function parameters are obtained from the new language plugin corresponding to the new programming language through the business plugin; Through the business plugin, a function service call request is sent to the corresponding intermediate protocol adapter in the backend based on the new language function parameters, so as to request the intermediate protocol adapter to load the corresponding language function service plugin according to the new language function parameters, so as to communicate with the language function service plugin and call the function service provided by the language function service plugin. The intermediate protocol adapter is adapted to obtain the port number corresponding to the new programming language from the language function service plugin. The port number returned by the intermediate protocol adapter is obtained through the business plugin; The system requests the establishment of a language connection from the intermediate protocol adapter based on the port number, so as to communicate with the language function service plugin via the intermediate protocol adapter and invoke the function services provided by the language function service plugin.
2. The method as described in claim 1, wherein, The intermediate protocol adapter is adapted to: determine the programming language as a new programming language based on the new language function parameters, and load the corresponding language function service plugin according to the new programming language.
3. The method as described in claim 1, wherein, The front end is adapted to provide one or more service interfaces through independent plugins, so that the new language plugin can call the service interfaces to implement the service logic corresponding to the service interfaces.
4. The method of claim 3, wherein, Each of the service interfaces corresponds to multiple service plugins; the method further includes: The new language plugin is used to call the service interface to load multiple service plugins corresponding to the service interface.
5. The method of claim 3, wherein, The service interface includes a window service interface, and the method further includes: The new language plugin calls the window service interface to embed the programming page corresponding to the new programming language into the front end.
6. The method of claim 3, wherein, The service interface includes a language service interface, and the new language plugin is adapted to actively register with the language service interface so that the language service interface can provide the basic classes that the new language plugin needs to implement.
7. The method according to any one of claims 1-6, wherein, The business plugins include debugging plugins and compilation plugins.
8. The method according to any one of claims 1-6, wherein, The backend is adapted to access language function service plugins corresponding to the new programming language; The intermediate protocol adapter includes: a debug protocol adapter and a language service protocol adapter; The language function service plugins include: debugging service plugin and language service plugin.
9. The method according to any one of claims 1-6, wherein, The language connection is a TCP connection based on the new programming language.
10. A programming language extension system, comprising: The front end includes business plugins and is suitable for integrating new language plugins corresponding to new programming languages; The backend includes an intermediate protocol adapter and is adapted to access language function service plugins corresponding to the new programming language; The front end is adapted to perform the method as described in any one of claims 1-9 to extend the new programming language.
11. A computing device, comprising: At least one processor; as well as A memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions including instructions for performing the method as described in any one of claims 1-9.
12. A readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform the method as described in any one of claims 1-9.
Citation Information
Patent Citations
Optimal incremental workflow execution allowing meta-programming
CN102193823A
Adaptation method and device for realizing space programming and programming system
CN111696408A