Annotation-based data processing method, computer device, and readable storage medium

By using command line tools to generate service description files and automatically register open services in application development, the problem of low development efficiency caused by repeated descriptions of components is solved, and efficient reuse of components and improvement of development efficiency is achieved.

CN114721713BActive Publication Date: 2025-08-19TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110005012.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-04
Publication Date
2025-08-19
Estimated Expiration
2041-01-04

AI Technical Summary

Technical Problem

In existing application development, repeated descriptions of components lead to low development efficiency, and application developers need to manually describe the services provided by components multiple times, resulting in low development efficiency.

Method used

By calling command line tools to obtain target annotations, generate service description files, and convert them into service code, automatically integrate them into application projects, and register open services using the business framework to reduce the need for manual code writing.

Benefits of technology

It realizes efficient reuse of components, improves development efficiency, improves collaboration efficiency between components and application developers, and reduces the amount of code to manually write registration of open services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114721713B_ABST
    Figure CN114721713B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses an annotation-based data processing method, a computer device, and a readable storage medium. The annotation-based data processing method includes: calling a command line tool to obtain a target annotation, generating target service information for describing an open service provided by a target component according to the target annotation, and generating a service description file according to the target service information; when the target component is integrated into an application project, obtaining the service description file corresponding to the target component, converting the target service information in the service description file into a service code, and inserting the service code into the application project; when the application project is running, calling a business framework through the service code to register the open service. The adoption of this application can improve development efficiency and plays an important role in realizing component governance in the field of computer technology and providing an "end-to-end cloud" component ecosystem for various applications.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an annotation-based data processing method, a computer device, and a readable storage medium. Background Art

[0002] With the popularization of mobile Internet, applications (especially mobile applications) have brought great convenience to people's lives. Existing applications are continuously updated and new applications emerge to meet people's diverse needs. Among them, applications can realize the business functions they need by integrating multiple components with different functions.

[0003] In existing application development scenarios, a component is essentially a reusable encapsulation, so a component can be integrated and reused by multiple applications. However, when multiple applications integrate the same component, application developers need to manually describe the services provided by the component multiple times, resulting in low application development efficiency. Summary of the Invention

[0004] The embodiments of the present application provide an annotation-based data processing method, a computer device, and a readable storage medium, which can improve development efficiency.

[0005] On the one hand, an embodiment of the present application provides an annotation-based data processing method, including:

[0006] Calling a command line tool to obtain a target annotation, generating target service information for describing an open service provided by a target component according to the target annotation, and generating a service description file according to the target service information;

[0007] When the target component is integrated into an application project, obtaining the service description file corresponding to the target component, converting the target service information in the service description file into a service code, and inserting the service code into the application project;

[0008] When the application project is running, the service code calls the business framework to register the open service.

[0009] An embodiment of the present application provides, on one hand, an annotation-based data processing device, comprising:

[0010] A description file generation module is used to call a command line tool to obtain a target annotation, generate target service information for describing an open service provided by a target component according to the target annotation, and generate a service description file according to the target service information;

[0011] a code generation module, configured to, when the target component is integrated into an application project, obtain the service description file corresponding to the target component, convert the target service information in the service description file into a service code, and insert the service code into the application project;

[0012] The framework calling module is used to call the business framework through the service code to register the open service when the application project is running.

[0013] Wherein, the description file generation module includes:

[0014] a first generating unit, configured to call a command line tool to scan a header file, and when a target annotation exists in the header file, generate a first abstract syntax tree according to the target annotation and component code associated with the target annotation in the header file; the header file includes component code of the target component; the first abstract syntax tree includes initial service information corresponding to the target annotation;

[0015] a second generating unit, configured to generate a second abstract syntax tree according to the initial service information in the first abstract syntax tree;

[0016] The third generating unit is configured to generate target service information for describing the open service provided by the target component according to the second abstract syntax tree, and store the target service information in a service description file.

[0017] Wherein, the first generating unit includes:

[0018] A search subunit, configured to call a command line tool to search in a folder and obtain a header file in the folder; the header file includes a declaration of a class written based on the component code;

[0019] a traversal subunit, configured to traverse the header file, and when an annotation keyword is found in the header file, determine that a target annotation exists in the header file, and determine the header file containing the target annotation as a target header file;

[0020] The parsing subunit is configured to parse the target annotation in the target header file and the component code associated with the target annotation to generate a first abstract syntax tree.

[0021] The second generating unit includes:

[0022] an extraction subunit, configured to traverse the first abstract syntax tree; when an annotation keyword is found in the first abstract syntax tree, extract data related to the annotation keyword from the first abstract syntax tree as initial service information based on an association between the target annotation and the component code;

[0023] The conversion subunit is configured to convert the format of the initial service information according to a standard data format to obtain a second abstract syntax tree.

[0024] Wherein, the description file generation module includes:

[0025] A splitting unit is used to call a command line tool to scan a header file, and when a target annotation exists in the header file, the header file is split to obtain N split header files; N is an integer greater than 1;

[0026] a parallel processing unit, configured to process the N split header files in parallel to obtain N groups of sub-target service information commonly used to describe the open service provided by the target component, and store the N groups of sub-target service information in N sub-service description files respectively;

[0027] The combining unit is used to combine the N sub-service description files to obtain a service description file corresponding to the header file.

[0028] Wherein, the code generation module includes:

[0029] A file acquisition unit, configured to, when the target component is integrated into an application project, call the command line tool to acquire the service description file corresponding to the target component and the application description file in the application project;

[0030] a merging unit, configured to merge the service description file and the application description file into a resource locking file; the resource locking file includes the target service information in the service description file;

[0031] A code conversion unit is used to convert the target service information into a service code, and insert the service code into the application project.

[0032] The code conversion unit is specifically used for:

[0033] Call the command line tool to convert the target service information in the resource locking file into a service code with the same language type as the component code, and save the service code to a code file; the language type is an extended object-oriented programming language type; integrate the code file into the application project; the application project is an application project under the extended object-oriented programming language framework.

[0034] Wherein, the target annotation is the code written according to the annotation protocol in the target header file;

[0035] The device further comprises:

[0036] An annotation module is used to determine that the target annotation satisfies the annotation protocol when the target annotation includes the annotation keyword, the target annotation is written in the declaration of the class in the target header file, and the target annotation is written before the corresponding declaration; or, when the target annotation includes annotation parameters and the target annotation is used to initialize the open service, obtain the parameter type returned by the initialization method associated with the target annotation, and if the returned parameter type is a service type, determine that the target annotation satisfies the annotation protocol.

[0037] On one hand, an embodiment of the present application provides a computer device, including: a processor, a memory, and a network interface;

[0038] The above-mentioned processor is connected to the above-mentioned memory and the above-mentioned network interface, wherein the above-mentioned network interface is used to provide data communication function, the above-mentioned memory is used to store computer programs, and the above-mentioned processor is used to call the above-mentioned computer program to execute the method in the embodiment of the present application.

[0039] On one hand, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. The computer program is suitable for being loaded by a processor and executing the method in the embodiment of the present application.

[0040] On the one hand, an embodiment of the present application provides a computer program product or a computer program, which includes computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method in the embodiment of the present application.

[0041] In an embodiment of the present application, the target annotation in the header file can be obtained by calling a command line tool, and the target service information for describing the open service provided by the target component can be generated according to the target annotation, and then a service description file can be generated according to the target service information. Furthermore, when the target component is integrated into the application project, the target service information in the above service description file can be converted into a service code and inserted into the above application project, so that when the application project is running, the business framework can be called through the above service code to register the open service provided by the target component. As can be seen from the above, the present application enables component developers to describe the open service provided by the target component by providing a target annotation, and automatically integrates the service information defined by the target annotation into the application project by calling a command line tool, so that application developers can directly obtain the above open service through the business framework and use it without having to worry about the initialization process and dependencies of the open service, thereby achieving efficient reuse of components. Moreover, since the service code required to register the open service is automatically generated by the command line tool, there is no need for the application developer to manually write it, which can greatly improve development efficiency and improve the collaboration efficiency between component developers and application developers. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0043] Figure 1 This is a schematic diagram of a system architecture provided by an embodiment of the present application;

[0044] Figure 2a-2c This is a schematic diagram of a scenario of annotation-based data processing provided by an embodiment of the present application;

[0045] Figure 3 This is a flowchart of an annotation-based data processing method provided in an embodiment of the present application;

[0046] Figure 4 This is a schematic diagram of the principle of generating a service description file provided in an embodiment of the present application;

[0047] Figure 5 This is a flow chart of a service information transmission process provided by an embodiment of the present application;

[0048] Figure 6 is a structural diagram of an annotation-based data processing device provided in an embodiment of the present application;

[0049] Figure 7 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0051] See Figure 1 , is a schematic diagram of a system architecture provided by an embodiment of the present application. The system architecture may include a server and multiple terminal devices, such as Figure 1 As shown, it specifically includes a server 100, a terminal device 200a, a terminal device 200b, a terminal device 200c and a terminal device 200d. The server 100 can establish a connection with the terminal device 200a, the terminal device 200b, the terminal device 200c and the terminal device 200d through the network. Each terminal device can install applications (application, in mobile terminals, application can also be referred to as App) with various functions, such as instant messaging applications, game applications, video applications, music applications, social applications, shopping applications, map applications, etc. These applications can be obtained by downloading the installation packages released by application developers to the application market. Therefore, each terminal device can transmit data with the server 100 through the client corresponding to the application. For example, the server 100 can send an application recommendation information stream to each terminal device, and each terminal device can display the application recommendation information stream in the client corresponding to the relevant application, and then respond to a series of trigger operations entered by the user, download the installation package of the recommended application through the server 100, and install it on the terminal device. The terminal device can run the successfully installed application and call the corresponding dependency framework to implement all business functions of the application, such as the video playback function, the picture download function, etc. Among them, the application recommendation information stream can be understood as a content aggregator that combines several message sources, which can help users obtain new updates on applications of interest. Among them, the "application" in this application can also be called: application, application software, software, client and other names.

[0052] An application can be understood as a software program that performs a specific function. It runs in user mode, interacts with the user, and has a visual user interface. Examples include the aforementioned communication applications, gaming applications, video applications, and other mobile applications. Applications can utilize certain services of the computer operating system, as well as services supported by other applications.

[0053] It is understandable that the method provided in this application can be performed by a computer device, which includes but is not limited to a terminal device or a server. Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud databases, cloud services, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal device can be a smart phone, tablet computer, laptop computer, desktop computer, PDA, mobile internet device (mobile internet device, MID), wearable device (such as smart watch, smart bracelet, etc.), smart TV, smart car, etc. that can run application programs. The terminal device and the server can be directly or indirectly connected by wired or wireless means, and this application is not limited here.

[0054] Before an app is officially released, developers from multiple roles typically collaborate to go through a series of processes, including preparation, discussion, development, and testing, before it can finally be launched. The following uses the development of application A1 with an image download function as an example to explain this in detail.

[0055] Please also see Figure 2a-2c , is a schematic diagram of a scenario of data processing based on annotations provided in an embodiment of the present application. Figure 2a-2c As shown, the scene graph is Figure 1 The server 100, terminal device 200a, terminal device 200b and terminal device 200c in the corresponding embodiment are taken as an example. Component developers can develop components using the development tools on the terminal device 200a. Specifically, Figure 2a As shown, a certain programming language can be used in the development tool to write the source code (or source program) of the image download component, wherein the source code is an uncompiled computer language instruction written in accordance with a certain programming language specification. For example, the source code can be written in Objective-C (i.e., an object-oriented programming language that extends C). The Objective-C language is fully compatible with the standard C language. It is a very small runtime library written in C language that can minimize the size of the application. See Figure 2aThe code 300b in the component source code is a class declaration written in Objective-C. In addition, the method provided by this application also supports adding annotations (or annotations, translated from the English word "Annotation", which is a grammatical concept in many computer languages) to the source code. The program can obtain relevant information about program elements such as classes, fields, and methods through annotations. In Objective-C, annotations can be implemented using macro definitions. For details, see Figure 2a The annotation 300a in the component source code in the source code can be used to define the class in the source code. Therefore, the component source code can include annotations and component code, and the component code refers to the code in the component source code other than the annotations. The terminal device 200a can save the written source code in the source file, and then call the command line tool to obtain the target annotation. The target annotation here refers to the annotation used to describe the image download service provided by the above-mentioned image download component, which is used to distinguish it from other annotations. Further, the command line tool can generate a service description file based on the obtained target annotation, and package the service description file and the image download component together, and publish the image download component to the component market by sending a component release request to the server 100. Among them, the command line tool can be pre-installed in the terminal device 200a, and the command line tool has no user interface. The developer can input commands through the keyboard, and the computer system can complete the corresponding work according to the input commands.

[0056] like Figure 2b As shown, in a project for developing an application A1 with a picture download function, the application developer can send a component download request to the server 100 through the terminal device 200b. After receiving the request, the server 100 can send the picture download component in the component market to the terminal device 200b. The terminal device 200b can then call the pre-installed command line tool to integrate all components including the picture download component. Furthermore, the command line tool can generate a resource locking file based on the service description file, and convert the target service information in the resource locking file into a service code, which can then be inserted into the application project. After the source code corresponding to the application A1 has been compiled, linked, tested, and other steps, the application A1 can be packaged into an installation package and published to the application market through the server 100 for users to download. Figure 2cAs shown, after the relevant platform has passed the review, the user can download the application A1 from the application market through the terminal device 200c and install it on the terminal device 200c. When the user opens the application A1, the application A1 can run on the terminal device 200c. At this time, the application A1 can directly call the business box through the above-mentioned service code to register the picture download service provided by the picture download component. After successful registration, the terminal device 200c can obtain pictures on the network through the server 100 and display them in the user interface. It can also respond to the user's trigger operation on the save button in the user interface and save the picture selected by the user to the corresponding storage area of the terminal device 200c. It should be noted that the application A1 can integrate multiple components. The embodiment of this application only takes the picture download component as an example for explanation. Among them, the essence of the service is the interface provided by the component that is open to the outside (which can be referred to as API, i.e., Application Programming Interface). The component developer can define part of the public API as a service exposed to the outside. A component can expose multiple services to external use.

[0057] It can be seen that the embodiments of the present application can support the addition of target annotations in the source code, so that component developers can describe the open services provided by the target component, and automatically integrate the service information defined by the target annotations into the application project by calling the command line tool, so that application developers can directly obtain and use the above-mentioned open services through the business framework without having to worry about the initialization process and dependencies of the open service, thereby achieving efficient reuse of components. Moreover, since the service code required to register the open service is automatically generated by the command line tool and does not need to be manually written by the application developer, it can greatly improve development efficiency and at the same time improve the collaboration efficiency between component developers and application developers.

[0058] See Figure 3 , is a flow chart of a data processing method based on annotations provided in an embodiment of the present application. Figure 3 As shown, the method may include the following steps:

[0059] Step S101: calling a command line tool to obtain a target annotation, generating target service information for describing an open service provided by a target component according to the target annotation, and generating a service description file according to the target service information;

[0060] Specifically, you can call a command line tool (also called a CLI tool, CLI is the abbreviation of command-line interface) to search in the current folder or other related folders to obtain the header file in the folder. The header file can include the declaration of the class written based on the component code, wherein the component code is the code other than the annotations in the header file. For example, in a scenario where component developers use the Objective-C language for development, two main types of files will be generated, namely header files and source files (or source code files). The header file will have a ".h" suffix, and the source file will have a ".m" or ".mm" suffix. Among them, the header file can include declarations of some classes (i.e., Class) written based on the Objective-C language, type declarations, function declarations, and constant declarations, etc. The source file can mainly include the specific implementation code of those functions that have been declared in the header file. Therefore, the command line tool can search for files with a ".h" suffix as header files in the current folder. Furthermore, the command line tool can traverse the header file obtained above. When the annotation keyword is traversed in the header file, it can be determined that the target annotation exists in the header file. At the same time, the header file with the target annotation can also be determined as the target header file. It should be noted that the above header file may also include other annotations to explain or annotate certain program elements (such as classes, fields, methods, variables, parameters, etc.). Since these annotations do not include annotation keywords, the name "target annotation" will be used in the embodiment of this application to distinguish it from other annotations. The target annotation refers to the code in the target header file used to describe the open services provided by the target component, where the open service refers to the open interface exposed by the target component.

[0061] After determining the target header file, the command line tool can parse all the codes in the target header file (including target annotations and component codes). The implementation process of the parsing can be achieved by using a third-party compilation framework, or it can be achieved by using the compilation framework that comes with the computer device. This is not specifically limited in the embodiments of the present application. Using the compilation framework, all the codes in the target header file can be first subjected to lexical analysis (also known as scanning, scanner). Specifically, the command line tool calls the compilation framework to read the code in the target header file, and merges the read code into individual identification tokens (Tokens) according to predetermined rules. At the same time, blank characters and comments in the code can be removed, and then the entire code will be divided into a Tokens list (or a syntax fragment array, which is a one-dimensional array). Further, a syntax analysis (also called a parser) can be performed, that is, the Tokens list obtained by the lexical analysis is converted into a tree form to generate a first abstract syntax tree. The first abstract syntax tree contains data for describing the entire syntax structure of the target header file. At the same time, the data corresponding to the target annotation in the first abstract syntax tree and the data corresponding to the component code associated with the target annotation can be determined as initial service information. For example, according to Figure 2a In the first syntax tree generated from the component source code shown, the data corresponding to the annotation 300a and the code 300b is the initial service information corresponding to the component source code.

[0062] Furthermore, a second abstract syntax tree can be generated based on the initial service information in the first abstract syntax tree. Specifically, the initial service information can be extracted first: the command line tool can traverse the first abstract syntax tree. When the annotation keyword is traversed in the first abstract syntax tree, the data related to the annotation keyword can be extracted from the first abstract syntax tree based on the association between the target annotation and the component code in the target header file to obtain the initial service information. The extracted initial service information can then be formatted to obtain a second abstract syntax tree with a standard data format. The specific form of the standard data format can be defined according to the actual situation of the development project plan, and the embodiment of the present application does not impose any restrictions. Finally, the command line tool can convert the data with a standard data format in the second abstract syntax tree into a YAML format to obtain the target service information, thereby generating a service description file and storing the target service information in the service description file. Among them, the target service information corresponds to the target annotation in the above-mentioned target header file, and can also be used to describe the open services provided by the target component. For example, it can describe which specific protocol a certain open service needs to implement, and can also specify the initialization method and property injection of the open service, etc. The service description file can be a file in YAML format. YAML is a recursive abbreviation of "YAML Ain't a Markup Language". It is a highly readable format used to express data serialization. The file has a ".yaml" or ".yml" suffix. It should be noted that the service description file can include target service information and other information required for development, such as basic information of the target component (such as the file name, version number, description summary, etc. of the target component), dependency information (the target component may depend on other components), etc., but these other information do not participate in the process of the method provided in the embodiment of the present application, and therefore will not be further elaborated here.

[0063] See also Figure 4 , is a schematic diagram of the principle of generating a service description file provided by an embodiment of the present application. Figure 4As shown, in the scenario where Objective-C is used for development, the command line tool scans the header file containing the target annotation in the Objective-C code, parses the target annotation and the related information attached to the target annotation (for example, if the target annotation is attached before the method declaration or property declaration written in the component code, an association is established between the target annotation and the attached component code), and other component code, and generates a first abstract syntax tree. The first abstract syntax tree includes all the code information in the target header file, including the initial service information. Further, after traversing the first abstract syntax tree and converting the initial service information in the first abstract syntax tree into a second abstract syntax tree with a standard data format, the command line tool can generate a description information in YAML format (i.e., converting the second abstract syntax tree into YAML format). In fact, for the same target component, there can be two YAML-formatted service description files, which are essentially configuration files, namely com_raft.yaml and com_config.yaml. However, the target service information is ultimately written to the com_raft.yaml file. Optionally, the service description file can also be manually generated by the component developer.

[0064] From the above, it can be seen that the implementation process of step S101 can extract the target annotation from the target header file and then convert it into target service information in YAML format. For example, if the command line tool recognizes that the target annotation A is attached to the attribute a, then both the target annotation A and the attribute a can be extracted and converted, and other data not related to the target annotation A will be eliminated. After the conversion process as described in the above step S101, the generated target service information can describe how to implement the injection of attribute a.

[0065] Among them, command-line tools are CLI (command-line interface) tools. Developers enter commands through the keyboard, and the computer device executes the commands after receiving them. Command-line tools save computer system resources compared to graphical user interfaces (GUIs). As long as the commands are memorized, using command-line tools is usually faster than using GUIs. Developers can install command-line tools on their computers before development. Among them, the Abstract Syntax Tree (AST) is a tree representation of the abstract syntax structure of the source code. Each node in the tree represents a structure in the source code. It is abstract because the AST does not represent every detail of the actual syntax. For example, nested brackets are implicit in the tree structure and are not presented in the form of nodes. The AST does not depend on the syntax of the programming language used in the source code. Therefore, it has been widely used in many fields such as compilers, browsers, and intelligent editors.

[0066] It should be noted that in order to improve the efficiency of automatic file generation, the command line tool can process multiple header files in parallel using multiple threads. When encountering a header file with too long content, the file content can be automatically split and processed in parallel. Finally, the command line tool will aggregate and process all the data to generate a service description file in YAML format. The specific implementation process is as follows: The command line tool can scan multiple header files in the current folder in parallel, and determine the header file containing the target annotation as the target header file. If the number of target header files is M (M is an integer greater than 1), the M target header files can also be processed in parallel. For a single target header file, the command line tool can split the single target header file according to the splitting rules. For example, since each header file may contain several classes, it can be split according to the class structure to obtain N split header files, where N is an integer greater than 1. The splitting rules can also be set according to actual conditions, which is not limited in this application. Then, the command line tool can process the above-mentioned N split header files in parallel to obtain N groups of sub-target service information that are commonly used to describe the open services provided by the target component, so that the N groups of sub-target service information can be stored in N sub-service description files respectively, wherein the process of generating a sub-service description file from a split header file is the same as the process of generating a service description file from the above-mentioned single target header file, and will not be repeated here. Furthermore, the command line tool can combine the above-mentioned N sub-service description files according to the combination logic to obtain the service description file corresponding to the single target header file. The combination logic can be set according to the above-mentioned splitting rules.

[0067] The method provided by this application can support adding target annotations to the source code of the target component to define the open services that need to be exposed. The target service information corresponding to the target annotation will automatically generate a service description file and be published to the component market along with the target component. Among them, the target annotation is implemented using a macro, and its concept draws on the traditional IoC (Inversion of Control) framework. The target annotation can only be added to the declaration of the class in the public header file. The position of the target annotation is attached above the corresponding syntax declaration (that is, written in front of the corresponding syntax declaration). When multiple target annotations need to be attached to the same position, there is no requirement for the order. Therefore, the target annotation can be understood as the code written in the target header file according to the annotation protocol. Each target annotation needs to meet the general annotation protocol, that is: when the target annotation includes the annotation keyword, and the target annotation is written in the declaration of the class in the target header file, and the target header file is a public header file (as opposed to a private header file), and the target annotation is written before the corresponding syntax declaration, it can be determined that the target annotation meets the annotation protocol. In addition, if the annotation protocol is not met during the writing of the target annotation, an error or warning can be reported, and the corresponding prompt information can be displayed on the editing interface to prompt the component developer to make modifications. In addition, in addition to the general annotation protocols mentioned above, component developers can also define the required annotation protocols according to actual conditions, that is, they can define different annotation protocols for each target annotation. For example, in the Objective-C language, there are 7 annotation keywords that can be supported, including: RAFT_SERVICE, RAFT_INTERFACE, RAFT_PROPERTY, RAFT_METHOD, RAFT_INITMETHOD, RAFT_FACTORYCLASS and RAFT_FACTORYMETHOD. Their corresponding usage and annotation protocols are as follows:

[0068] (1) RAFT_SERVICE: Use RAFT_SERVICE to declare a class as an open service. RAFT_SERVICE can only be added to public class declarations. It is invalid when added to categories or extensions. In other words, although a class can extend categories and extensions, they cannot be declared as open services. RAFT_SERVICE is added above @interface.

[0069] (2) RAFT_INTERFACE: RAFT_INTERFACE can be used to specify the interface (interface, referring to an informal protocol) implemented by an open service. It can only be added in the declaration of a public class and is invalid when added in Category and Extension. RAFT_INTERFACE is added above @interface, and the premise of its use is that the current class has been attached with RAFT_SERVICE. The RAFT_INTERFACE annotation requires the interface to be passed in as a parameter, for example: RAFT_INTERFACE(interface1, interface2). The business framework supports obtaining open services through interfaces, so when two open services declare that they implement the same interface, the business framework will only retain a reference to one of the open services. For example, when reading the target annotations in sequence, the last interface read can be retained.

[0070] (3)RAFT_PROPERTY: Use RAFT_PROPERTY to inject instance properties of a class. The addition position is above @property.

[0071] (4)RAFT_METHOD: Use RAFT_METHOD to inject instance methods into a class. The addition position is above the instance method declaration.

[0072] (5) RAFT_INITMETHOD: You can use RAFT_INITMETHOD to specify an instance method for initializing an open service. It should be added above the initialization method. Objective-C initialization methods have a naming convention. Their return value is either instancetype (used to represent an unknown Objective-C object) or the current type. The method prefix is init.

[0073] (6) RAFT_FACTORYCLASS and RAFT_FACTORYMETHOD: When an open service needs to be initialized through a class method, the factory class (RAFT_FACTORYCLASS) and the factory method (RAFT_FACTORYMETHOD) need to be specified. RAFT_FACTORYCLASS is attached above the factory class @interface, and RAFT_FACTORYMETHOD is attached above the class method. RAFT_FACTORYCLASS can be used simultaneously with RAFT_SERVICE on the same class. The RAFT_FACTORYMETHOD parameter is optional. When the parameter is not filled in, the return type of the class method is used as the class name of the open service by default. The compiler can be used to parse the RAFT_FACTORYMETHOD annotation to obtain information such as which method the factory method is attached to and what parameters the attached method has, thereby obtaining the return type. However, when the return parameter type of a class method cannot accurately match a specific open service class (that is, it will only be considered legal when the parameter type returned by the class method is an open service class. The legality can be determined by searching a global table that records information that the class is described as an open service), it needs to be specified through parameters. The parameter can be the name of the Class (class) or Protocol (formal protocol). When using class method initialization, the method specified through parameters has the highest priority. Among them, factory classes and factory methods are a concept in design patterns that are used to declare how to create open services, rather than to declare classes as open services. Because they mark a class or method as the place where open services are produced, they are called "factories."

[0074] See also the following code snippet, which uses the target annotation to declare a class called RAFTBasicService as an open service and specifies the interface that this open service implements.

[0075]

[0076]

[0077] In this code snippet, in addition to the target code composed of annotation keywords mentioned above, it also includes component code written in Objective-C language, among which @interface, @property, instancetype, etc. are all keywords provided by Objective-C language. As can be seen from the above code, the RAFTBasicService class inherits from the base class NSObject, and at the same time specifies the implementation of the interface named RABasicProtocol (or called protocol), and implements property injection through the RAFT_PROPERTY annotation, and specifies a custom initialization method through the RAFT_INITMETHOD annotation. Through the RAFT_METHOD annotation, the business framework will automatically call the startup method during subsequent runtime. Among them, if the RAFT_PROPERTY annotation is not added, when the RAFTBasicService class is initialized, the properties without annotations are empty, resulting in no valid information being read.

[0078] Step S102, when the target component is integrated into the application project, obtaining the service description file corresponding to the target component, converting the target service information in the service description file into a service code, and inserting the service code into the application project;

[0079] Specifically, an application may need to use multiple components, so multiple components can be integrated. When the target component is integrated into the application project, the application developer can use a computer device to call a command line tool to obtain the service description file corresponding to the target component, the service description file corresponding to other components, and the application description file in the application project (which can be written by the application developer). These description files can then be merged to obtain a resource lock file. The resource lock file can include the target service information in the service description file corresponding to the target component mentioned in step S101 above, as well as the service information corresponding to other components. That is, the command line tool can merge the service information of all required components into the resource lock file. In the scenario where Objective-C language is used for development, the resource lock file can also include two files, namely, raft.lock file and raft_config.lock file, and the raft.lock file corresponds to the com_raft.yaml file, and the raft_config.lock file corresponds to the com_config.yaml file.

[0080] Furthermore, the command line tool can be called to convert the target service information in the resource lock file (including the raft.lock file and the raft_config.lock file) into service code. The converted service code can have the same language type as the above-mentioned component code. For example, in the scenario where the Objective-C language is used for development, the target service information can be converted into Objective-C language type code, and the service code can be saved in a code file. The code file can be a file independent of the header file and the source file. Furthermore, the code file can be inserted into the above-mentioned application project. Accordingly, the application project can be an application project under the Objective-C language framework. In addition, if the application developer needs to browse the code file, he can open it directly for browsing, or open it for browsing in the application project.

[0081] Step S103: When the application project is running, the service code calls the business framework to register the open service.

[0082] Specifically, when the above-mentioned application project is running, the service code generated in step S102 can automatically call the business framework to register the open services provided by the above-mentioned target component, thereby avoiding the application developer from manually writing the code to register the open services. Among them, the business framework can specifically be an IoC (Inversion of Control) framework. The IoC framework is a runtime framework and can be understood as the basic operating logic. Inversion of Control is an important design principle of object-oriented programming. It can be used to reduce the coupling between codes, facilitate function reuse, and make the entire architecture of the program very flexible. During runtime, the external container dynamically injects the dependent objects into the component. When the external container is started, the external container will be initialized without the application developer having to worry about this part of the work.

[0083] Please refer to the table below. Taking the RAFTBasicService class in the code snippet in step S101 above as an example, the number of lines of code required by developers to manually write when registering open services in the method provided by this application compared to the Typhoon framework is as follows:

[0084] Component developers Application developers The method provided by this application 6 lines 0 lines Typhoon Framework 0 lines About 15 lines

[0085] As can be seen from the above, in existing methods (such as the Typhoon framework), component developers cannot perceive the IoC framework and only provide APIs. Therefore, application developers need to manually describe the open services provided by the component when integrating the component, and repeated descriptions lead to low development efficiency. In the method provided in this application, both component developers and application developers need to pay attention to the IoC framework, but from different perspectives. Component developers use annotations to describe what capabilities the component can provide, and application developers do not need to describe it again, thereby transferring development costs from application developers to component developers. As can be seen from the above table, it is equivalent to a command line tool that can reduce 6 lines of code to about 15 lines of code required by the existing method. Overall, the number of lines of code that developers need to write by hand is significantly reduced. It can be understood that when multiple components are integrated, the beneficial effects produced by the method provided in this application will be more significant.

[0086] In addition, in order to realize the function of automatic backfilling of background parameters in the end-cloud integration, the existing Objective-C annotation solution only focuses on the IoC implementation of the client itself, and does not care about the injection of background parameters. Therefore, the efficiency of the existing solution is lower than the solution provided by this application. For example, in the scenario where the target component has its own background function, such as using third-party authorized login of certain social applications, before authorized login access, developers need to go through many steps such as registering a developer account, qualification certification, filling in information, submitting and waiting for review, creating a website application, etc. to apply for and obtain the required AppID, and finally paste the AppID into the code. The whole process is not only complicated, but also costly. However, using the method provided by this application, the above process can be solved in an automated way. For example, the target annotation can be added to the attribute corresponding to the AppID in the code. Then, the AppID generated by the target component background can be automatically injected through the business framework (which is the IoC framework), and then the AppID can be automatically backfilled.

[0087] Please also see Figure 5 , is a flow chart of a service information transmission process provided by an embodiment of the present application. Figure 5 As shown, the transfer process may include the following steps:

[0088] Step S201, using annotations in source code to define open services provided by the target component;

[0089] Specifically, component developers can add annotations to the source code of the target component and use annotations to define the open services provided by the target component. The target component will then depend on the added annotations. The annotations at this time are the above Figure 3 Target annotation in the corresponding embodiment.

[0090] Step S202, writing annotation information into the service description file;

[0091] Specifically, component developers can enter the command to write the service description file in the command line tool, and then the command line tool can execute the command to write the target service information generated according to the target annotation and its related information into the service description file. The command to write the service description file can be specifically "fef updateyaml", where the service description file includes the com_raft.yaml file and the com_config.yaml file.

[0092] Step S203, publishing the target component to the component market;

[0093] Specifically, the component developer can input a command for publishing the component in the command line tool, and then the command line tool can execute the command to publish the target component to the component market, wherein the command for publishing the component can be specifically "fefpublish".

[0094] Step S204, integrating all components required for the application project;

[0095] Specifically, when an application project needs to integrate multiple components, the application developer can enter the command to import the component in the command line tool. The command can be specifically "fef import", and then the command line tool will automatically integrate all the required components (including the above-mentioned target components), and merge the service description files corresponding to all components and the application description files in the application project into a resource locking file. At the same time, the target service information in the above step S202 will also be integrated into the resource locking file. Among them, the resource locking file includes a raft.lock file and a raft_config.lock file. The application description file can also include two files: an app_raft.yaml file and an app_config.yaml file, and the raft.lock file corresponds to the app_raft.yaml file, and the raft_config.lock file corresponds to the app_config.yaml file. It can be understood that components with target annotations added to the source code can be called target components. In the embodiment of this application, only one target component is used as an example. When there are multiple target components, the command line tool can process the target annotations in the source code corresponding to the multiple target components in parallel. The specific process of generating a service description file based on the target annotation is the same as the above. Figure 3 Step S101 in the corresponding embodiment is the same and will not be described again here.

[0096] Step S205, generating a service code through the resource locking file;

[0097] Specifically, the command line tool can convert the target service information in the resource lock file into code, and insert the code into the application project.

[0098] Step S206: calling the business framework interface to register an open service.

[0099] Specifically, the application project will depend on the business framework, so that the above-generated code can call the interface provided by the business framework (ie, the inversion of control framework) to register the corresponding open service when the application project is running.

[0100] In an embodiment of the present application, a target annotation for describing an open service can be obtained by calling a command line tool, and a service description file can be generated based on the target annotation. Furthermore, when the target component is integrated into an application project, a resource lock file containing target service information can be generated based on the above service description file, and the target service information can be converted into a service code and inserted into the above application project. Thus, when the application project is running, the business framework can be called through the above service code to register the open service provided by the target component. As can be seen from the above, the present application enables component developers to describe the open service provided by the target component by providing a target annotation, and automatically integrates the service information defined by the target annotation into the application project by calling a command line tool, so that application developers can directly obtain the above open service through the business framework and use it without having to worry about the initialization process and dependencies of the open service, thereby achieving efficient reuse of components, and the service code required to register the open service can be automatically generated by the command line tool without the need for application developers to manually write it. In addition, the command line tool can process multiple header files in parallel using multiple threads, thereby greatly improving development efficiency and improving the collaboration efficiency between component developers and application developers.

[0101] See Figure 6 , is a structural diagram of an annotation-based data processing device provided in an embodiment of the present application. Figure 6 As shown, the annotation-based data processing device 1 may include a description file generation module 11, a code generation module 12, and a framework calling module 13;

[0102] A description file generation module 11 is configured to call a command line tool to obtain a target annotation, generate target service information for describing an open service provided by a target component according to the target annotation, and generate a service description file according to the target service information;

[0103] a code generation module 12, configured to, when the target component is integrated into an application project, obtain the service description file corresponding to the target component, convert the target service information in the service description file into a service code, and insert the service code into the application project;

[0104] The framework calling module 13 is used to call the business framework through the service code to register the open service when the application project is running.

[0105] The specific function implementation of the description file generation module 11 can be found in the above Figure 3 The specific functional implementation of the code generation module 12 in the corresponding embodiment of step S101 can be found in the above Figure 3 The specific function implementation of the framework calling module 13 in step S102 of the corresponding embodiment can be found in the above Figure 3 Step S103 in the corresponding embodiment will not be described again here.

[0106] Please also see Figure 6 , the annotation-based data processing device 1 may further include an annotation module 14;

[0107] The annotation module 14 is used to determine that the target annotation satisfies the annotation protocol when the target annotation includes the annotation keyword, the target annotation is written in the declaration of the class in the target header file, and the target annotation is written before the corresponding declaration; or, when the target annotation includes annotation parameters and the target annotation is used to initialize the open service, obtain the parameter type returned by the initialization method associated with the target annotation, and if the returned parameter type is a service type, determine that the target annotation satisfies the annotation protocol.

[0108] The specific function implementation of the annotation module 14 can be found in the above Figure 3 Step S101 in the corresponding embodiment will not be described in detail here.

[0109] Please also see Figure 6 , the description file generating module 11 may include: a first generating unit 111, a second generating unit 112, and a third generating unit 113;

[0110] The first generating unit 111 is configured to call a command line tool to scan a header file, and when a target annotation exists in the header file, generate a first abstract syntax tree according to the target annotation and the component code associated with the target annotation in the header file; the header file includes the component code of the target component; and the first abstract syntax tree includes initial service information corresponding to the target annotation;

[0111] A second generating unit 112 is configured to generate a second abstract syntax tree according to the initial service information in the first abstract syntax tree;

[0112] The third generating unit 113 is configured to generate target service information for describing the open service provided by the target component according to the second abstract syntax tree, and store the target service information in a service description file.

[0113] The specific functional implementation of the first generation unit 111, the second generation unit 112, and the third generation unit 113 can be found in the above Figure 3 Step S101 in the corresponding embodiment will not be described in detail here.

[0114] Please also see Figure 6 , the description file generation module 11 may include: a splitting unit 114, a parallel processing unit 115, and a combining unit 116;

[0115] The splitting unit 114 is configured to call a command line tool to scan the header file, and when the target annotation exists in the header file, split the header file to obtain N split header files, where N is an integer greater than 1;

[0116] A parallel processing unit 115 is configured to process the N split header files in parallel to obtain N groups of sub-target service information commonly used to describe the open services provided by the target component, and store the N groups of sub-target service information in N sub-service description files respectively;

[0117] The combining unit 116 is configured to combine the N sub-service description files to obtain a service description file corresponding to the header file.

[0118] The specific functional implementation of the splitting unit 114, the parallel processing unit 115, and the combining unit 116 can be found in the above Figure 3 Step S101 in the corresponding embodiment will not be described in detail here.

[0119] Please also see Figure 6 , the code generation module 12 may include: a file acquisition unit 121, a merging unit 122, and a code conversion unit 123;

[0120] A file acquisition unit 121 is configured to, when the target component is integrated into an application project, call the command line tool to acquire the service description file corresponding to the target component and the application description file in the application project;

[0121] A merging unit 122 is configured to merge the service description file and the application description file into a resource locking file; the resource locking file includes the target service information in the service description file;

[0122] A code conversion unit 123, configured to convert the target service information into a service code, and insert the service code into the application project;

[0123] The code conversion unit 123 is specifically used to call the command line tool to convert the target service information in the resource locking file into a service code with the same language type as the component code, and save the service code to a code file; the language type is an extended object-oriented programming language type; the code file is integrated into the application project; the application project is an application project under the extended object-oriented programming language framework.

[0124] The specific functional implementation of the file acquisition unit 121, the merging unit 122, and the code conversion unit 123 can be found in the above Figure 3 Step S102 in the corresponding embodiment will not be described in detail here.

[0125] Please also see Figure 6 , the first generating unit 111 may include: a searching subunit 1111, a traversing subunit 1112, and a parsing subunit 1113;

[0126] The search subunit 1111 is used to call a command line tool to search in a folder and obtain a header file in the folder; the header file includes a declaration of a class written based on the component code;

[0127] The traversal subunit 1112 is configured to traverse the header file, and when an annotation keyword is found in the header file, determine that a target annotation exists in the header file, and determine the header file containing the target annotation as a target header file;

[0128] The parsing subunit 1113 is configured to parse the target annotation in the target header file and the component code associated with the target annotation to generate a first abstract syntax tree.

[0129] The specific functional implementation of the search subunit 1111, the traversal subunit 1112, and the parsing subunit 1113 can be found in the above Figure 3 Step S101 in the corresponding embodiment will not be described in detail here.

[0130] Please also see Figure 6 , the second generation unit 112 may include: an extraction subunit 1121 and a conversion subunit 1122;

[0131] The extraction subunit 1121 is configured to traverse the first abstract syntax tree; when an annotation keyword is found in the first abstract syntax tree, extract data related to the annotation keyword from the first abstract syntax tree as initial service information based on the association between the target annotation and the component code;

[0132] The conversion subunit 1122 is configured to convert the format of the initial service information according to a standard data format to obtain a second abstract syntax tree.

[0133] The specific functional implementation of the extraction subunit 1121 and the conversion subunit 1122 can be found in the above Figure 3 Step S101 in the corresponding embodiment will not be described in detail here.

[0134] In an embodiment of the present application, a target annotation for describing an open service can be obtained by calling a command line tool, and a service description file can be generated based on the target annotation. Furthermore, when the target component is integrated into an application project, a resource lock file containing target service information can be generated based on the above service description file, and the target service information can be converted into a service code and inserted into the above application project. Thus, when the application project is running, the business framework can be called through the above service code to register the open service provided by the target component. As can be seen from the above, the present application enables component developers to describe the open service provided by the target component by providing a target annotation, and automatically integrates the service information defined by the target annotation into the application project by calling a command line tool, so that application developers can directly obtain the above open service through the business framework and use it without having to worry about the initialization process and dependencies of the open service, thereby achieving efficient reuse of components, and the service code required to register the open service can be automatically generated by the command line tool without the need for application developers to manually write it. In addition, the command line tool can process multiple header files in parallel using multiple threads, thereby greatly improving development efficiency and improving the collaboration efficiency between component developers and application developers.

[0135] See Figure 7 , is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 7As shown, the computer device 1000 may include: a processor 1001, a network interface 1004 and a memory 1005. In addition, the above-mentioned computer device 1000 may also include: a user interface 1003, and at least one communication bus 1002. The communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), a keyboard (Keyboard), and the user interface 1003 may optionally include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1004 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 1005 may optionally be at least one storage device located away from the aforementioned processor 1001. As Figure 7 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application.

[0136] In such Figure 7 In the computer device 1000 shown, the network interface 1004 can provide network communication functions; the user interface 1003 is mainly used to provide an interface for user input; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:

[0137] Call the command line tool to obtain the target annotation, generate target service information for describing the open services provided by the target component based on the target annotation, and generate a service description file based on the target service information;

[0138] When the target component is integrated into the application project, a service description file corresponding to the target component is obtained, the target service information in the service description file is converted into a service code, and the service code is inserted into the application project;

[0139] When the application project is running, the business framework is called through the service code to register the open service.

[0140] It should be understood that the computer device 1000 described in the embodiment of the present application can execute the above Figure 3 The description of the annotation-based data processing method in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated here either.

[0141] In addition, it should be pointed out here that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores the computer program executed by the annotation-based data processing device 1 mentioned above, and the computer program includes program instructions. When the processor loads and executes the program instructions, it can execute the above-mentioned Figure 3 The description of the above-mentioned annotation-based data processing method in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated here. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application.

[0142] The above-mentioned computer-readable storage medium can be the annotation-based data processing device provided in any of the aforementioned embodiments or the internal storage unit of the above-mentioned computer device, such as the hard disk or memory of the computer device. The computer-readable storage medium can also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Furthermore, the computer-readable storage medium can also include both the internal storage unit of the computer device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium can also be used to temporarily store data that has been output or is to be output.

[0143] In addition, it should be noted that the present application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the above-mentioned Figure 3 The method provided by the corresponding embodiment.

[0144] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0145] The methods and related devices provided by the embodiments of the present application are described with reference to the method flow charts and / or structural diagrams provided by the embodiments of the present application. Specifically, each process and / or block in the method flow charts and / or structural diagrams, as well as the combination of processes and / or blocks in the flow charts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 Schematic diagram of one or more processes and / or structures Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including the instruction device, which implements the function specified in the process. Figure 1 Schematic diagram of one or more processes and / or structures Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the process. Figure 1 The flow or flows and / or structures illustrate the steps of the functions specified in one block or multiple blocks.

[0146] The above disclosure is only a preferred embodiment of the present application, and certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. A data processing method based on annotation, characterized in that: include: Invoking a command line tool to scan a header file, and when a target annotation exists in the header file, generating a first abstract syntax tree according to the target annotation in the header file and component code associated with the target annotation; the header file includes component code of the target component; The first abstract syntax tree includes initial service information corresponding to the target annotation; generating a second abstract syntax tree according to the initial service information in the first abstract syntax tree; generating target service information for describing the open service provided by the target component according to the second abstract syntax tree, and storing the target service information in a service description file; When the target component is integrated into an application project, calling a command line tool to obtain the service description file corresponding to the target component and the application description file in the application project; Merging the service description file and the application description file into a resource locking file; The resource locking file includes the target service information in the service description file; Calling the command line tool to convert the target service information in the resource locking file into a service code, and inserting the service code into the application project; When the application project is running, the service code calls the business framework to register the open service provided by the target component.

2. The method according to claim 1, characterized in that The calling of the command line tool to scan the header file, and when a target annotation exists in the header file, generating a first abstract syntax tree according to the target annotation in the header file and the component code associated with the target annotation, includes: Invoke a command line tool to search in a folder and obtain a header file in the folder; the header file includes a declaration of a class written based on the component code; Traversing the header file, and when an annotation keyword is found in the header file, determining that a target annotation exists in the header file, and determining the header file containing the target annotation as a target header file; The target annotation in the target header file and the component code associated with the target annotation are parsed to generate a first abstract syntax tree.

3. The method according to claim 1, characterized in that Generating a second abstract syntax tree according to the initial service information in the first abstract syntax tree includes: Traversing the first abstract syntax tree; When an annotation keyword is traversed in the first abstract syntax tree, extracting data related to the annotation keyword from the first abstract syntax tree as initial service information according to the association relationship between the target annotation and the component code; The initial service information is format-converted according to a standard data format to obtain a second abstract syntax tree.

4. The method according to claim 1, wherein The calling of a command line tool to obtain a target annotation, generating target service information for describing an open service provided by a target component according to the target annotation, and generating a service description file according to the target service information include: Calling a command line tool to scan a header file, and when a target annotation exists in the header file, splitting the header file to obtain N split header files; N is an integer greater than 1; Processing the N split header files in parallel to obtain N groups of sub-target service information commonly used to describe the open services provided by the target component, and storing the N groups of sub-target service information in N sub-service description files respectively; The N sub-service description files are combined to obtain a service description file corresponding to the header file.

5. The method according to claim 1, wherein The converting the target service information into a service code and inserting the service code into the application project comprises: Calling the command line tool to convert the target service information in the resource locking file into a service code of the same language type as the component code, and saving the service code to a code file; the language type is an extended object-oriented programming language type; The code file is integrated into the application project; the application project is an application project under the expanded object-oriented programming language framework.

6. The method according to claim 2, characterized in that The target annotation is the code written in the target header file according to the annotation protocol; The method further comprises: When the target annotation includes the annotation keyword, and the target annotation is written in the declaration of the class in the target header file, and the target annotation is written before the corresponding declaration, it is determined that the target annotation satisfies the annotation protocol; or, When the target annotation includes annotation parameters and the target annotation is used to initialize the open service, the parameter type returned by the initialization method associated with the target annotation is obtained. If the returned parameter type is a service type, it is determined that the target annotation satisfies the annotation protocol.

7. A computer device, characterized in that: include: processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide a data communication function, the memory is used to store program code, and the processor is used to call the program code to execute the method according to any one of claims 1 to 6.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Establishing method of member and function library with description information

    CN101655797A

  • Interface document generation method and device, electronic equipment and medium

    CN111638908A

  • Compiler-based data processing method and device and readable storage medium

    CN114489653A