Code updating method and device, equipment and medium

By automatically updating the project's framework code and business code, the problem of difficult and cost of manually adjusting the code in the existing technology is solved, efficient and automatic code updates are achieved, and developers need to operate manually.

CN120144144APending Publication Date: 2025-06-13DOUYIN VISION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311714444.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-13
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

In the prior art, the project framework cannot adapt to business processing needs, resulting in the need to manually adjust the code, which is difficult, costly, and inconsistent code styles.

Method used

Provide a code update method, which automatically updates the original framework code file and the updated framework code file by obtaining the original code file of the project and the updated framework code file, determines the correspondence between the code content, and replaces the original business code with the updated business code.

Benefits of technology

It realizes automatic update of project framework code and business code, reduces the manual update operation of developers, reduces update costs, and improves efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144144A_ABST
    Figure CN120144144A_ABST
Patent Text Reader

Abstract

The invention discloses a code updating method, device, equipment and medium applied to the technical field of computers, in the method, an original code file of a project is obtained, the original code file comprises an original framework code file and an original business code file, and the original business code file is used for executing project business based on the original framework code file; acquiring a frame code file for updating the project, updating the original frame code file by using the frame code file for updating, and determining a corresponding relationship between the first code and the second code based on code contents included in the original frame code file and the code contents included in the frame code file for updating, and updating the first code by using the second code. In this way, automatic updating of the frame code and the service code of the existing project can be achieved, the operation of a developer for updating the project code is reduced, the cost of updating the project code is reduced, and efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and particularly to a code update method, apparatus, device, and medium. Background Art

[0002] A framework is a reusable code system, usually including functional structural codes such as code classes, methods, functions, variables, and constants. Developers of a project can edit business codes based on the framework to generate business code files for implementing specific business processes. The code files of a project include framework code files and business code files. The business code files in the project can run based on the framework code files.

[0003] With the change of business processing requirements, there may be a problem that the framework of the project cannot meet the business processing requirements, and it is necessary to adjust the framework and make corresponding adjustments to the business codes. However, there are many code files included in the project. Currently, the method of manually adjusting the codes is difficult and costly. Summary of the Invention

[0004] In view of this, this application provides a code update method, apparatus, device, and medium, aiming to automatically adjust the code files of the project and reduce the difficulty and cost of code adjustment.

[0005] Based on this, the technical solutions provided by this application are as follows:

[0006] In a first aspect, this application provides a code update method, and the method includes:

[0007] Obtain the original code files of the project, where the original code files include original framework code files and original business code files; the original business code files are used to execute project operations based on the original framework code files;

[0008] Obtain the framework code files for updating the project;

[0009] Update the original framework code files by using the framework code files for updating;

[0010] Based on the code content included in the original framework code files and the code content included in the framework code files for updating, determine the correspondence between the first code and the second code, where the first code belongs to the original business code files, and the second code is the business code for updating determined based on the framework code files for updating;

[0011] Update the first code by using the second code.

[0012] In a possible implementation manner, determining the correspondence between the first code and the second code based on the code content included in the original framework code file and the code content included in the framework code file for update includes:

[0013] Determining the correspondence between the first code and the second code based on the standard code content, the code content included in the original framework code file, and the code content included in the framework code file for update.

[0014] In a possible implementation manner, determining the correspondence between the first code and the second code based on the standard code content, the code content included in the original framework code file, and the code content included in the framework code file for update includes:

[0015] Establishing a first correspondence between the first content included in the framework code file for update and the standard code content; the standard code content includes one or more of package names, methods, and parameters;

[0016] Establishing a second correspondence between the second content included in the original framework code file and the standard code content;

[0017] Based on the first correspondence and the second correspondence, establishing the correspondence between the first content and the second content;

[0018] Based on the correspondence between the first content and the second content, establishing the correspondence between the first code and the second code, where the first code includes the first content and the second code includes the second content.

[0019] In a possible implementation manner, updating the original framework code file by using the framework code file for update includes:

[0020] Using the framework code file for update to replace the original framework code file.

[0021] In a possible implementation manner, before using the framework code file for update to replace the original framework code file, the method further includes:

[0022] Constructing a first abstract syntax tree of the framework code file for update;

[0023] Adjusting the first abstract syntax tree so that the framework code included in the framework code file for update conforms to the standard framework code format;

[0024] Using the adjusted first abstract syntax tree to regenerate the framework code file for update.

[0025] In a possible implementation, the method further includes:

[0026] Obtain a business code file for updating the project, where the second code belongs to the business code file for updating.

[0027] In a possible implementation, the obtaining of the framework code file for updating the project includes:

[0028] Based on the original framework code file, reconstruct the framework of the project to generate a framework code file for updating the project, where the code file for updating is used to adjust the business of the project.

[0029] In a possible implementation, the generating of the framework code file for updating the project includes:

[0030] Generate a framework code file for updating the project by using a preset framework generation rule.

[0031] In a possible implementation, the reconstructing of the framework of the project based on the original framework code file to generate a framework code file for updating the project includes:

[0032] Construct a second abstract syntax tree of the original framework code file;

[0033] Adjust the second abstract syntax tree so that the original framework code file conforms to the standard framework code file format;

[0034] Add at least one responsibility chain node to the second abstract syntax tree, where the responsibility chain node is used to implement an adjusted business processing method;

[0035] Generate a framework code file for updating by using the adjusted second abstract syntax tree.

[0036] In a possible implementation, the business is a log printing business, and the at least one responsibility chain node includes one or more of the following responsibility chain nodes:

[0037] A responsibility chain node for filtering logs that meet the printing conditions, a responsibility chain node for adjusting the log printing format, and a responsibility chain node for log buried point and alarm.

[0038] In a possible implementation, the updating of the first code by using the second code includes:

[0039] Construct a third abstract syntax tree of the original business code file;

[0040] Traverse the third abstract syntax tree to determine the first code including the first content;

[0041] Replace the first code with the second code;

[0042] Generate a target business code file using the replaced third abstract syntax tree, where the target business code file is used to replace the original business code file.

[0043] In a possible implementation, the framework code file for update is a reusable framework code file.

[0044] In a second aspect, the present application provides a code update device, the device includes:

[0045] A first acquisition unit, configured to acquire an original code file of a project, where the original code file includes an original framework code file and an original business code file; the original business code file is used to execute project operations based on the original framework code file;

[0046] A second acquisition unit, configured to acquire a framework code file for updating the project;

[0047] A first update unit, configured to update the original framework code file using the framework code file for update;

[0048] A determination unit, configured to determine the correspondence between a first code and a second code based on the code content included in the original framework code file and the code content included in the framework code file for update, where the first code belongs to the original business code file, and the second code is the business code for update determined based on the framework code file for update;

[0049] A second update unit, configured to update the first code using the second code.

[0050] In a possible implementation, the determination unit is specifically configured to determine the correspondence between the first code and the second code based on standard code content, the code content included in the original framework code file, and the code content included in the framework code file for update.

[0051] In a possible implementation, the determination unit is configured to determine the correspondence between the first code and the second code based on standard code content, the code content included in the original framework code file, and the code content included in the framework code file for update, including:

[0052] The determining unit is configured to establish a first correspondence between the first content included in the framework code file for update and the standard code content; the standard code content includes one or more of a package name, a device, and a parameter; establish a second correspondence between the second content included in the original framework code file and the standard code content; based on the first correspondence and the second correspondence, establish a correspondence between the first content and the second content; based on the correspondence between the first content and the second content, establish a correspondence between the first code and the second code, where the first code includes the first content and the second code includes the second content.

[0053] In a possible implementation manner, the first update unit is specifically configured to replace the original framework code file with the framework code file for update.

[0054] In a possible implementation manner, the apparatus further includes:

[0055] A constructing unit, configured to construct a first abstract syntax tree of the framework code file for update;

[0056] An adjusting unit, configured to adjust the first abstract syntax tree so that the framework code included in the framework code file for update conforms to the standard framework code format;

[0057] A regenerating unit, configured to regenerate the framework code file for update by using the adjusted first abstract syntax tree.

[0058] In a possible implementation manner, the apparatus further includes:

[0059] A third obtaining unit, configured to obtain the business code file for update of the project, where the second code belongs to the business code file for update of the project.

[0060] In a possible implementation manner, the second obtaining unit is specifically configured to reconstruct the framework of the project based on the original framework code file to generate the framework code file for update of the project, and the code file for update is used to adjust the business of the project.

[0061] In a possible implementation manner, the second obtaining unit for generating the framework code file for update of the project includes:

[0062] The second obtaining unit is configured to generate the framework code file for update of the project by using a preset framework generation rule.

[0063] In a possible implementation, the second acquisition unit is configured to reconstruct the framework of the project based on the original framework code file to generate a framework code file for updating the project, including:

[0064] The second acquisition unit is configured to construct a second abstract syntax tree of the original framework code file; adjust the second abstract syntax tree to make the original framework code file conform to the standard framework code file format; add at least one responsibility chain node to the second abstract syntax tree, where the responsibility chain node is used to implement the adjusted service processing device; and generate an updated framework code file by using the adjusted second abstract syntax tree.

[0065] In a possible implementation, the service is a log printing service, and the at least one responsibility chain node includes one or more of the following responsibility chain nodes:

[0066] A responsibility chain node for filtering logs that meet the printing conditions, a responsibility chain node for adjusting the log printing format, and a responsibility chain node for log buried point and alarm.

[0067] In a possible implementation, the second update unit is specifically configured to construct a third abstract syntax tree of the original service code file; traverse the third abstract syntax tree to determine the first code including the first content; replace the first code with the second code; and generate a target service code file by using the replaced third abstract syntax tree, where the target service code file is used to replace the original service code file.

[0068] In a possible implementation, the framework code file for updating is a reusable framework code file.

[0069] In a third aspect, the present application provides an electronic device, including:

[0070] One or more processors;

[0071] A storage device storing one or more programs thereon,

[0072] When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of the embodiments in the first aspect.

[0073] In a fourth aspect, the present application provides a computer-readable medium storing a computer program, where the program, when executed by a processor, implements the method according to the first aspect and any one of the embodiments in the first aspect.

[0074] Fifth aspect, the present application provides a computer program product, which, when running on a device, causes the device to execute the method described in the first aspect and any implementation manner of the first aspect.

[0075] Thus, the present application has the following beneficial effects:

[0076] The present application provides a code update method, apparatus, device and medium. In this method, the original code files of a project are obtained. The original code files include the original framework code files and the original business code files. The original business code files are used to execute the project business based on the original framework code files. The framework code files for updating the project are obtained. The original framework code files are updated by using the framework code files for updating. Based on the code content included in the original framework code files and the code content included in the framework code files for updating, the correspondence between the first code and the second code is determined. Herein, the first code belongs to the original business code files, and the second code is the business code for updating determined based on the framework code files for updating. The first code is updated by using the second code. In this way, the automatic update of the framework code and the business code of the existing project can be realized, the operations of developers for updating the project code are reduced, the cost of updating the project code is reduced, and the efficiency is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0077] Figure 1 It is a flowchart of a code update method provided by an embodiment of the present application;

[0078] Figure 2 It is a flowchart of another code update method provided by an embodiment of the present application;

[0079] Figure 3 It is a schematic structural diagram of a code update apparatus provided by an embodiment of the present application;

[0080] Figure 4 It is a schematic diagram of the basic structure of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0081] To facilitate the understanding and explanation of the technical solutions provided by the embodiments of the present application, the background technology of the present application will be described first.

[0082] The files of the project may include various types of files such as code files, configuration files, directories, etc. Among them, the code files include framework code files and business code files. The framework code files include framework code written in a programming language. The business code files include code written by developers based on the framework code in a programming language to implement specific business requirements. The configuration file is a file that records the configuration parameters or user parameters required during the operation of the project. The directory records the various types of files included in the project and the hierarchical relationship between the files.

[0083] The framework of the project may need to be adjusted according to the needs of business processing. Based on the adjusted framework, the business code also needs to be adjusted accordingly. Currently, for the scenario where the framework needs to be adjusted, usually, the development of a new framework and the adjustment of the business code are carried out manually. There may be the following problems with manual code adjustment:

[0084] 1. The workload of adjustment is large, the cost of manual adjustment is high, and the probability of problems is high. It takes a long time to adjust the code, and the adjustment efficiency is low.

[0085] 2. If the original framework or the way of business processing in the project needs to be adjusted, then it is also necessary to manually rewrite the compatible or replaceable framework code and business code, and the adjustment process is relatively complex and the cost is high.

[0086] 3. For a project developed by multiple people in cooperation, there is a problem of inconsistent code styles, which is inconvenient for subsequent maintenance of the project.

[0087] Based on this, the embodiments of the present application provide a code update method, device, device and medium. In this method, the original code files of the project are obtained. The original code files include the original framework code files and the original business code files. The original business code files are used to execute the project business based on the original framework code files. The framework code files for updating the project are obtained. The original framework code files are updated using the framework code files for updating. Based on the code content included in the original framework code files and the code content included in the framework code files for updating, the corresponding relationship between the first code and the second code is determined. Among them, the first code belongs to the original business code files, and the second code is the business code for updating determined based on the framework code files for updating. The first code is updated using the second code. In this way, the automatic update of the framework code and business code of the existing project can be realized, the operation of developers for updating the project code can be reduced, the cost of updating the project code can be reduced, and the efficiency can be improved.

[0088] A code update method provided by an embodiment of this application can be applied to an electronic device. An electronic device refers to a device with data processing capabilities, such as a server or a terminal. Among them, the terminal includes but is not limited to a smart phone, a tablet computer, a laptop computer, a personal digital assistant (PDA), or a smart wearable device, etc. The server can be a cloud server, such as the central server in a central computing cluster or the edge server in an edge computing cluster. Of course, the server can also be a server in a local data center. A local data center refers to a data center directly controlled by a user.

[0089] Those skilled in the art can understand that the above application scenario is only an example in which the implementation manners of this application can be realized. The applicable scope of the implementation manners of this application is not limited by any aspect of this application scenario.

[0090] To facilitate understanding of the technical solution provided by the embodiment of this application, the code update method provided by the embodiment of this application will be described below with reference to the accompanying drawings.

[0091] See Figure 1 As shown, this figure is a schematic flowchart of a code update method provided by an embodiment of this application. As Figure 1 shown, the method may include S101 - S105:

[0092] S101: Obtain the original code file of the project.

[0093] The original code file of the project is the code file that the project includes and has not been updated. The original code file includes the original framework code file and the original business code file. The original framework code file includes framework code. The original business code file includes business code. The business code is written based on the framework code. The original business code file is used to execute the project business based on the original framework code file.

[0094] As an example, the embodiment of this application does not limit the programming language for writing the project. As an example, the project is a Go language project.

[0095] It should be noted that the project can be established based on multiple frameworks. The original framework code file can be the framework code file corresponding to the framework that needs to be adjusted. The embodiment of this application does not limit the manner of obtaining the original framework code file. The original framework code file is an original framework code package. In one possible implementation, obtain the package path of the original framework code package input by the user, and determine the original framework code package based on the package path. In another possible implementation, obtain the package name input by the user. Determine the original framework code package based on the package name. As an example, the project is a Go language project., See Figure 2As shown in the figure, this is a schematic flowchart of another code update method provided by an embodiment of this application. Using the import method and package name of go / build, the package path of the original framework code package is obtained, and then the original framework code package is obtained based on the package path.

[0096] S102: Obtain the framework code file for updating the project.

[0097] The framework code file for updating is used to update the original framework code file. The embodiments of this application do not limit the implementation manner of obtaining the framework code file for updating. In a possible implementation manner, the framework code file for updating is a framework code file that has been edited and generated, and is used to replace the original framework code file. In another possible implementation manner, the framework code file for updating is a framework code file generated by expanding the original framework on the basis of the original framework code file. For the process of expanding the original framework to generate the framework code file for updating, please refer to the specific description below.

[0098] S103: Use the framework code file for updating to update the original framework code file.

[0099] After obtaining the framework code file for updating and the original framework code file, use the framework code file for updating to update the original framework code file.

[0100] In a possible implementation manner, use the framework code file for updating to replace the original framework code file. In this way, the replacement of the framework can be realized, and the original framework can be replaced with a new framework.

[0101] In another possible implementation manner, generate the framework code file for updating in the code file of the project. In this way, the refactoring of the framework can be realized on the basis of the original framework.

[0102] S104: Determine the correspondence between the first code and the second code based on the code content included in the original framework code file and the code content included in the framework code file for updating.

[0103] After updating the framework code file, it is also necessary to update the relevant business code. The original framework code file and the framework code file for updating may include corresponding code content. The code content includes, for example, methods, input and output parameters, package names, etc. For example, if method A included in the original framework code file and method B included in the framework code file for updating have the same function, then method A and method B have a correspondence.

[0104] Based on the code content included in the original framework code file and the code content included in the framework code file for update, the corresponding code content can be determined. Furthermore, the first code that needs to be replaced in the original business code file and the second code for replacement can be determined. The second code is the code for update determined based on the framework code file for update. In one possible implementation, the second code is pre-written based on the framework code file for update and belongs to the business code file for update used to replace the original business code file. In another possible implementation, the second code is the code generated based on the framework code file for update.

[0105] Taking the example that the above method A and method B have a corresponding relationship, in the original business code file, the code including method A is the first code, and the code including method B determined based on the framework code file for update is the second code.

[0106] The embodiments of the present application do not limit the possible implementation manners for determining the first code and the second code having a corresponding relationship. In one possible implementation, standard code content is established in advance. The standard code content can be defined based on the functions of the code content. The corresponding relationship between the standard code content and the code content included in the code file is determined. Furthermore, based on the corresponding code content, the corresponding first code and second code are determined. For the specific process of determining the corresponding first code and second code, please refer to the following specific description. In another possible implementation, the code content included in the original framework code file and the code content included in the framework code file for update have a corresponding relationship. For example, the developer edits the code content included in the corresponding framework code file for update based on the code content included in the original framework code file. In this way, the corresponding first code and second code can be determined based on the corresponding code content.

[0107] S105: Update the first code using the second code.

[0108] The embodiments of the present application do not limit the possible implementation manners for updating the first code using the second code. As an example, an abstract syntax tree of the business code file is constructed, and the abstract syntax tree is used to implement the update of the first code using the second code.

[0109] The embodiments of the present application provide a possible implementation manner for updating the first code using the second code, including the following steps:

[0110] A1: Construct the third abstract syntax tree of the original business code file.

[0111] Parse the original business code file to construct the third abstract syntax tree of the original business code file.

[0112] In a possible implementation, the original business code file is written in the Go language. The ParseDir method in go / parser is used to parse the original business code file to generate a third abstract syntax tree.

[0113] A2: Traverse the third abstract syntax tree to determine the first code including the first content.

[0114] By traversing the third abstract syntax tree, the business code included in the original business code files included in the project is scanned. The scanning determines the first code including the first content.

[0115] As an example, the original business code file is written in the Go language. Define the required visitor, that is, the interface (Visitor). The input parameter of Visitor is a node on the third abstract syntax tree. Then use the Walk method provided by the AST package of Go to traverse the entire third abstract syntax tree according to the depth-first search method to determine the first code including the first content. In Visitor, the methods that need to be updated included in the original business code file are captured and located according to the method names and input / output parameter types of the original business code file.

[0116] The embodiments of the present application do not limit the way to determine the first code including the first content. In a possible implementation, the first content is written into a configuration file. For example, the method name, package name, input / output parameters, etc. are written into the configuration file, and at the specified package path, the specified interface is implemented. This interface is used for replacing old and new parameters and can be called machMethod. When traversing the third abstract syntax tree, read the first content in the configuration file. If the code including the first content is traversed, then regard this code as the first code. For example, read the configuration file to automatically parse the original business code file. When the matching first code is traversed, determine whether the second code has been imported. The second code is, for example, a method package. If the second code has not been imported, then import the second code; if the second code has been imported, then do not import it repeatedly. Based on the correspondence between the first code and the second code, replace the first code with the second code.

[0117] A3: Use the second code to replace the first code.

[0118] In a possible implementation, after determining the first code, replace the first code with the second code corresponding to the first code.

[0119] A4: Use the replaced third abstract syntax tree to generate a target business code file, and the target business code file is used to replace the original business code file.

[0120] After completing the replacement of the first code, use the replaced third abstract syntax tree to generate a target business code file.

[0121] In a possible implementation, the business code files included in the project are written in the Go language. The third abstract syntax tree is output in the format of gofmt using format.node to generate the target business code file.

[0122] The target business code file is the updated business code file. The generated target business code file replaces the stored original business code file to implement the corresponding update of the business code.

[0123] After updating the first code in the original business code file, the code file of the adjusted project is obtained.

[0124] Based on the relevant content of the above S101 - S105, updating the framework code file and the business code file can achieve the automatic update of the framework code and the business code of the project, improve the efficiency of updating the project code, reduce the manual update operations of developers, and lower the cost of manual update.

[0125] In a possible implementation, standard code content is established in advance. The standard code content can be defined based on the functions of the code content. This facilitates determining the correspondence between the standard code content and the code content included in the code file.

[0126] Based on the standard code content, the code content included in the original framework code file, and the code content included in the framework code file for update, determine the correspondence between the first code and the second code. As an example, use the standard code content to determine the corresponding code content in the code content included in the original framework code file and the code content included in the framework code file for update, and then determine the correspondence between the first code and the second code.

[0127] In a possible implementation, an embodiment of the present application provides a specific implementation for determining the correspondence between the first code and the second code based on the standard code content, the code content included in the original framework code file, and the code content included in the framework code file for update, including the following four steps:

[0128] B1: Establish the first correspondence between the first content included in the framework code file for update and the standard code content.

[0129] B2: Establish the second correspondence between the second content included in the original framework code file and the standard code content.

[0130] The first content included in the framework code file for update and the second content included in the original framework code file can be determined based on the functions of the code content defined in the standard code content. As an example, based on the functions of the code content defined in the standard code content, query for the code content used to implement the function in the framework code file for update and the original framework code file, and respectively determine the first content included in the framework code file for update and the second content included in the original framework code file.

[0131] Establish a first correspondence between the first content and the standard code content, and a second correspondence between the second content and the standard code content.

[0132] B3: Based on the first correspondence and the second correspondence, establish a correspondence between the first content and the second content.

[0133] Determine the correspondence between the first content and the second content according to the first correspondence between the first content and the standard code content, and the second correspondence between the second content and the standard code content.

[0134] B4: Based on the correspondence between the first content and the second content, establish a correspondence between the first code and the second code, where the first code includes the first content and the second code includes the second content.

[0135] Establish a correspondence between the first code including the first content and the second code including the second content. This facilitates updating the first code with the second code to achieve the update of the business code.

[0136] In a possible implementation, the framework code file for update is used to replace the original framework code file. For example, the framework code file for update is a pre-written existing framework code file. By using the framework code file for update to replace the original framework code file, it is possible to replace the original framework with an existing framework.

[0137] See Figure 2 As shown, in a possible implementation, after determining the log printing entry method, determine whether the framework needs to be refactored. If the framework does not need to be refactored, then perform replacement based on the pre-obtained framework code file for update.

[0138] An embodiment of the present application provides a possible implementation of using a framework code file for update to update an original framework code file, including:

[0139] Use the framework code file for update to replace the original framework code file.

[0140] In this way, the replacement of the original framework can be achieved, facilitating the replacement of the original framework with an existing or newly created framework.

[0141] Optionally, to facilitate subsequent adjustment and maintenance of business code files, before replacing the original framework code file with the framework code file for update, it is also necessary to adjust the framework code file for update to a framework code file that conforms to the standard framework code file format. The embodiments of the present application provide possible implementation manners for adjusting the framework code file for update, including the following steps:

[0142] C1: Construct a first abstract syntax tree of the framework code file for update.

[0143] Parse the framework code file for update to construct a first abstract syntax tree (Abstract Syntax Tree, AST) of the framework code file for update. AST is an abstract representation of the code syntax structure, which presents the syntax structure of a programming language in a tree-like form, and each node on the tree represents a structure in the code.

[0144] In a possible implementation manner, the original framework code file is written in the Go language. Use the ParseDir method in go / parser to parse the framework code file for update to generate the first abstract syntax tree.

[0145] C2: Adjust the first abstract syntax tree so that the framework code included in the framework code file for update conforms to the standard framework code format.

[0146] The standard framework code format is a pre-defined code format. As an example, the standard framework code format includes parameter order, methods, etc. Using the standard framework code format can unify the format of framework code and facilitate unified processing of framework code generated in various development styles.

[0147] Use the standard framework code format to adjust the format of the framework code included in the framework code file for update. See Figure 2 As shown, map the framework code included in the framework code file for update to the standard framework code format.

[0148] In a possible implementation manner, first match the framework code included in the framework code file for update with the standard framework code format. For example, match the parameters, methods, etc. included in the framework code included in the framework code file for update with the parameters, methods, etc. included in the standard framework code format to determine the matching parameters and code contents such as matching methods.

[0149] Based on the standard framework code format, adjust the first abstract syntax tree so that the framework code included in the updated framework code file after adjustment conforms to the standard framework code format. As an example, based on determining the matching relationship between the code content of the framework code included in the updated framework code file and the code content of the standard framework code format, adjust the first abstract syntax tree, and convert the code content of the framework code included in the updated framework code file into the code content of the matching standard framework code format.

[0150] C3: Use the adjusted first abstract syntax tree to regenerate the updated framework code file.

[0151] In a possible implementation, the updated framework code file is a framework code file written and generated in the Go language. Use format.node to output the first abstract syntax tree in the format of gofmt, and regenerate the updated framework code file.

[0152] The framework code included in the regenerated updated framework code file conforms to the standard framework code format. The regenerated updated framework code file is used to replace the original framework code file. This facilitates subsequent unified management of the framework code of the replaced project.

[0153] The above is the relevant introduction to the replacement method of the framework code file. Next, the update method of the business code file in the scenario of framework replacement will be introduced.

[0154] In the scenario of framework replacement, the updated business code file is pre-written and generated based on the updated framework code file. As an example, the updated framework code file and the updated business code file can be pre-written code files.

[0155] In addition to the above steps, the embodiments of the present application further provide a code update method, including the following steps:

[0156] Obtain the updated business code file of the project, and the second code belongs to the updated business code file.

[0157] In another possible implementation, on the basis of the original framework, the framework can be refactored to implement the adjustment of business processing.

[0158] A possible implementation of obtaining the updated framework code file of the project provided by the embodiments of the present application includes:

[0159] Based on the original framework code file of the project, refactor the framework of the project to generate the updated framework code file of the project, and the updated code file is used to adjust the business of the project.

[0160] The framework of the refactored project is, for example, to adjust the methods of the original framework.

[0161] Based on the original framework code file, a framework code file for update is generated. In one possible implementation, the framework code file for update is written by the developer based on the original framework code file. Obtain the framework code file for update input by the developer. In another possible implementation, the developer adjusts the original framework of the project. Based on the adjusted framework, a framework code file for update is automatically generated. For example, see Figure 2 As shown, for the scenario of refactoring the framework, based on the pre-configured framework generation rules, a framework code file for update is automatically generated. For example, the second abstract syntax tree of the original framework code file is pre-constructed, and the framework is refactored and adjusted based on the second abstract syntax tree, and then the adjusted second abstract syntax tree is used to automatically generate the framework code file for update.

[0162] As an example, a framework code file for update is automatically generated in the directory of the project.

[0163] It should be noted that during the process of refactoring the framework, the original framework is encapsulated, and the Caller method of the runtime scheduler is used for stack backtracking to implement the second-level encapsulation of the framework hidden from the outside by the stack control, making the encapsulation operation imperceptible to the user.

[0164] In addition, when refactoring the framework, the framework can also be expanded. The embodiments of the present application provide a possible implementation of refactoring the framework of the project based on the original framework code file, including the following steps:

[0165] D1: Construct the second abstract syntax tree of the original framework code file.

[0166] Parse the original framework code file to construct the second abstract syntax tree of the original framework code file.

[0167] In one possible implementation, the original framework code file is written in the Go language. Use the ParseDir method in go / parser to parse the original framework code file to generate the second abstract syntax tree.

[0168] The embodiments of the present application do not limit the triggering method for constructing the second abstract syntax tree of the original framework code file. As an example, after obtaining the original code file of the project, the second abstract syntax tree of the original framework code file is constructed. In some possible implementations, the framework for implementing a specific function is adjusted. After generating the second abstract syntax tree, traverse the nodes of the second abstract syntax tree to determine the entry code of the function for subsequent update of the code implementing the function. For example, see Figure 2As shown in the figure, this is a schematic flowchart of another code update method provided by an embodiment of the present application.

[0169] As an example, the original framework code file is written in the Go language. Using the Walk method provided by the AST package of Go, traverse the entire second abstract syntax tree according to the depth-first search method to determine the entry code including this function. For example, for code updates related to log printing operations, determine the entry code for log printing operations.

[0170] D2: Adjust the second abstract syntax tree so that the original framework code file conforms to the standard framework code file format.

[0171] Using the standard framework code format can unify the format of framework code, facilitating unified processing of framework code generated in various development styles.

[0172] Use the standard framework code format to adjust the format of the framework code included in the original framework code file.

[0173] In a possible implementation, first match the framework code included in the original framework code file with the standard framework code format. For example, match the parameters, methods, etc. included in the framework code included in the original framework code file with the parameters, methods, etc. included in the standard framework code format to determine the matching parameters and code content such as matching methods.

[0174] Based on the standard framework code format, adjust the second abstract syntax tree so that the framework code included in the adjusted original framework code file conforms to the standard framework code format. As an example, based on determining the matching relationship between the code content of the framework code included in the original framework code file and the code content of the standard framework code format, adjust the second abstract syntax tree to convert the code content of the framework code included in the original framework code file into the code content of the matching standard framework code format.

[0175] D3: Add at least one responsibility chain node in the second abstract syntax tree, and the responsibility chain node is used to implement the adjusted business processing method.

[0176] The responsibility chain is a behavioral design pattern. The responsibility chain is a task chain formed by connecting many responsibility chain nodes in series, and each responsibility chain node corresponds to a business processing method.

[0177] Adding a responsibility chain node in the second abstract syntax tree can adjust the processing logic of the original framework and achieve framework expansion.

[0178] D4: Use the adjusted second abstract syntax tree to generate a framework code file for update.

[0179] In a possible implementation, the original framework code file is a framework code file written in the Go language. The second abstract syntax tree is output in the format of gofmt using format.node to generate a framework code file for update. The generated framework code file for update is the framework code file after framework refactoring.

[0180] The generated framework code file for update can also be a reusable framework code file. The framework code file for update can be used as a util tool independently by other projects.

[0181] The embodiments of the present application do not limit the specific business processing methods corresponding to the responsibility chain nodes. In a possible implementation, the business is a log printing business. At least one responsibility chain node includes one or more of the following responsibility chain nodes: a responsibility chain node for filtering logs that meet the printing conditions, a responsibility chain node for adjusting the log printing format, and a responsibility chain node for log burying points and alarms.

[0182] As an example, the embodiments of the present application provide the following three responsibility chain nodes, and the functions of the responsibility chain nodes are introduced respectively.

[0183] The first type: a responsibility chain node for filtering logs that meet the printing conditions.

[0184] In the business scenario of log printing, common errors include system errors and business errors. If error logs are printed without discrimination, the magnitude of error logs will be very large, which will hinder problem troubleshooting and increase the system burden. The responsibility chain node for filtering logs that meet the printing conditions is used to identify valid errors and print valid error logs. For example, by identifying error codes or log keywords, the error logs of valid errors are judged and filtered. As an implementation, filtering rules such as error codes and log keywords are written into the local configuration file. As another implementation, the configuration of filtering rules can be achieved by combining local configuration and remote configuration. Further, warning-level logs are printed at a reduced level. This printing policy can be configured through a switch. In this way, the problem of missing log printing can be avoided.

[0185] The second type: a responsibility chain node for adjusting the log printing format.

[0186] The responsibility chain node for adjusting the log printing format is used to configure unified log printing rules. As an example, the upper-layer call methods of log printing, Go files, etc. are all made into options and freely combined into the log information to restrict the format of the log printing content, realize the unity of the log printing style in the project, and achieve automatic compatibility with multiple printing formats.

[0187] The third type: a responsibility chain node for log burying points and alarms.

[0188] The responsibility chain nodes for log embedding and alarm are used to add embeddings of different log types in the custom callback function and add tags (Tags) to the embeddings. The ratio and frequency of different logs can be obtained based on the log embeddings, and aggregated analysis can be performed in different dimensions such as interfaces and methods to perform targeted optimization of logs and identification of system problems. In this way, log governance can be achieved, as well as the identification of system problems.

[0189] In addition, an alarm policy is added to the custom callback function. After identifying the error logs and rules of the specified type, the alarm operation is directly triggered to implement the prompt for the problematic logs.

[0190] It should be noted that the above three types of responsibility chain nodes are only examples for implementing different functions. In addition to the above three types of responsibility chain nodes, custom responsibility chain nodes can also be added. The custom responsibility chain nodes can implement business processing based on the defined business processing logic. This facilitates developers to freely add business processing logic, implement adjustments to the framework, and expand business processing.

[0191] It should be noted that for projects edited in the Go language, the code of the project cannot be updated during runtime. Add go generate at the main method to automatically trigger the execution of the above update method to achieve automatic log transformation and daily maintenance of the project. In this way, there is no need to use operations such as reflection for code update, ensuring the performance of the project during runtime.

[0192] In addition, the above update method can be encapsulated into the running logic of a tool so that developers can use the tool to automatically update the code.

[0193] Based on a code update method provided by the above method embodiment, an embodiment of the present application also provides a code update device. The code update device will be described below with reference to the accompanying drawings.

[0194] See Figure 3 As shown, this figure is a schematic structural diagram of a code update device provided by an embodiment of the present application. As Figure 3 As shown, the code update device includes:

[0195] A first acquisition unit 301, configured to acquire the original code file of the project, where the original code file includes an original framework code file and an original business code file; the original business code file is used to execute project operations based on the original framework code file;

[0196] A second acquisition unit 302, configured to acquire the framework code file for updating the project;

[0197] The first update unit 303 is configured to update the original framework code file by using the framework code file for update;

[0198] The determination unit 304 is configured to determine the correspondence between the first code and the second code based on the code content included in the original framework code file and the code content included in the framework code file for update, where the first code belongs to the original service code file, and the second code is the service code for update determined based on the framework code file for update;

[0199] The second update unit 305 is configured to update the first code by using the second code.

[0200] In a possible implementation manner, the determination unit 304 is specifically configured to determine the correspondence between the first code and the second code based on the standard code content, the code content included in the original framework code file, and the code content included in the framework code file for update.

[0201] In a possible implementation manner, the determination unit 304 is configured to determine the correspondence between the first code and the second code based on the standard code content, the code content included in the original framework code file, and the code content included in the framework code file for update, including:

[0202] The determination unit 304 is configured to establish a first correspondence between the first content included in the framework code file for update and the standard code content; the standard code content includes one or more of a package name, a device, and a parameter; establish a second correspondence between the second content included in the original framework code file and the standard code content; based on the first correspondence and the second correspondence, establish a correspondence between the first content and the second content; based on the correspondence between the first content and the second content, establish a correspondence between the first code and the second code, where the first code includes the first content and the second code includes the second content.

[0203] In a possible implementation manner, the first update unit 303 is specifically configured to replace the original framework code file with the framework code file for update.

[0204] In a possible implementation manner, the apparatus further includes:

[0205] The construction unit is configured to construct a first abstract syntax tree of the framework code file for update;

[0206] The adjustment unit is configured to adjust the first abstract syntax tree so that the framework code included in the framework code file for update conforms to the standard framework code format;

[0207] A regeneration unit, configured to regenerate a framework code file for update by using the adjusted first abstract syntax tree.

[0208] In a possible implementation, the apparatus further includes:

[0209] A third acquisition unit, configured to acquire a business code file for updating the project, where the second code belongs to the business code file for updating.

[0210] In a possible implementation, the second acquisition unit 302 is specifically configured to reconstruct the framework of the project based on the original framework code file, and generate a framework code file for updating the project, where the code file for updating is used to adjust the business of the project.

[0211] In a possible implementation, the second acquisition unit 302 for generating a framework code file for updating the project includes:

[0212] The second acquisition unit 302 is configured to generate a framework code file for updating the project by using a preset framework generation rule.

[0213] In a possible implementation, the second acquisition unit 302 for reconstructing the framework of the project based on the original framework code file and generating a framework code file for updating the project includes:

[0214] The second acquisition unit 302 is configured to construct a second abstract syntax tree of the original framework code file; adjust the second abstract syntax tree to make the original framework code file conform to the standard framework code file format; add at least one responsibility chain node in the second abstract syntax tree, where the responsibility chain node is used to implement an adjusted service processing device; and generate a framework code file for updating by using the adjusted second abstract syntax tree.

[0215] In a possible implementation, the service is a log printing service, and the at least one responsibility chain node includes one or more of the following responsibility chain nodes:

[0216] A responsibility chain node for filtering logs that meet the printing conditions, a responsibility chain node for adjusting the log printing format, and a responsibility chain node for log embedding and alarm.

[0217] In a possible implementation, the second update unit is specifically configured to construct a third abstract syntax tree of the original business code file; traverse the third abstract syntax tree to determine the first code including the first content; replace the first code with the second code; and generate a target business code file by using the replaced third abstract syntax tree, where the target business code file is used to replace the original business code file.

[0218] In a possible implementation, the framework code file for update is a reusable framework code file.

[0219] Based on the code update method provided in the foregoing method embodiments, the present application further provides an electronic device, including: one or more processors; a storage device storing one or more programs thereon, and when the one or more programs are executed by the one or more processors, enabling the one or more processors to implement the code update method as described in any of the foregoing embodiments.

[0220] Reference is made below Figure 4 , which shows a schematic structural diagram of an electronic device 400 suitable for implementing embodiments of the present application. The terminal device in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (portable android devices, tablet computers), PMPs (Portable Media Players), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs (televisions), desktop computers, etc. Figure 4 The electronic device shown is only an example and should not impose any limitation on the functions and usage scope of the embodiments of the present application.

[0221] As Figure 4 shown, the electronic device 400 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 401, which may perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other through a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0222] Typically, the following devices can be connected to the I / O interface 405: an input device 408 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 can allow the electronic device 400 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 4 an electronic device 400 with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. More or fewer devices can be alternatively implemented or had.

[0223] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program codes for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication device 409, or installed from the storage device 408, or installed from the ROM 402. When the computer program is executed by the processing device 401, the above functions defined in the method of the embodiment of the present application are executed.

[0224] The electronic device provided by the embodiment of the present application and the code update method provided by the above embodiment belong to the same inventive concept. Technical details not described in detail in this embodiment can be seen in the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0225] Based on the code update method provided by the above method embodiment, an embodiment of the present application provides a computer storage medium, on which a computer program is stored, wherein when the program is executed by a processor, the code update method as described in any of the above embodiments is implemented.

[0226] It should be noted that the computer-readable medium described above in this application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this application, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. In this application, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and this computer-readable signal medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0227] In some embodiments, the client and the server can communicate using any currently known or future-developed network protocol such as HTTP (Hyper Text Transfer Protocol), and can be interconnected with digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet (e.g., the Internet), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or future-developed networks.

[0228] The above computer-readable medium can be included in the above electronic device; or it can exist separately without being assembled into the electronic device.

[0229] The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by the electronic device, the electronic device is caused to execute the above code update method.

[0230] Computer program code for performing the operations of this application can be written in one or more programming languages or combinations thereof. The above-mentioned programming languages include, but are not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0231] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0232] The units involved in the embodiments described in this application can be implemented in software or in hardware. Among them, the name of the unit / module does not constitute a limitation on the unit itself in some cases. For example, the voice data acquisition module can also be described as the "data acquisition module".

[0233] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), systems on a chip (SOC), complex programmable logic devices (CPLD), and so on.

[0234] In the context of the present application, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0235] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other. For the systems or apparatuses disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and reference can be made to the description in the method part for relevant parts.

[0236] It should be understood that in the present application, "at least one (item)" means one or more, and "a plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist. For example, "A and / or B" can mean: only A exists, only B exists, and both A and B exist simultaneously. Here, A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one (one) of the following" or its similar expressions refer to any combination of these items, including any combination of single items (ones) or plural items (ones). For example, at least one (one) of a, b, or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0237] It should also be noted that, in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.

[0238] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A code update method, characterized in that, the method includes: Obtain the original code files of the project, where the original code files include the original framework code files and the original business code files; the original business code files are used to execute project operations based on the original framework code files; Obtain the framework code files for updating the project; Use the framework code files for updating to update the original framework code files; Based on the code content included in the original framework code files and the code content included in the framework code files for updating, determine the correspondence between the first code and the second code, where the first code belongs to the original business code files, and the second code is the business code for updating determined based on the framework code files for updating; Use the second code to update the first code.

2. The method according to claim 1, characterized in that, the determining the correspondence between the first code and the second code based on the code content included in the original framework code files and the code content included in the framework code files for updating includes: Determine the correspondence between the first code and the second code based on the standard code content, the code content included in the original framework code files, and the code content included in the framework code files for updating.

3. The method according to claim 2, characterized in that, the determining the correspondence between the first code and the second code based on the standard code content, the code content included in the original framework code files, and the code content included in the framework code files for updating includes: Establish a first correspondence between the first content included in the framework code files for updating and the standard code content; the standard code content includes one or more of package names, methods, and parameters; Establish a second correspondence between the second content included in the original framework code files and the standard code content; Based on the first correspondence and the second correspondence, establish the correspondence between the first content and the second content; Based on the correspondence between the first content and the second content, establish the correspondence between the first code and the second code, where the first code includes the first content and the second code includes the second content.

4. The method according to claim 1, characterized in that, the using the framework code files for updating to update the original framework code files includes: Use the framework code files for updating to replace the original framework code files.

5. The method according to claim 4, characterized in that, before using the framework code files for updating to replace the original framework code files, the method further includes: Construct a first abstract syntax tree of the framework code files for updating; Adjust the first abstract syntax tree so that the framework code included in the framework code files for updating conforms to the standard framework code format; Use the adjusted first abstract syntax tree to regenerate the framework code files for updating.

6. The method according to claim 4, characterized in that, the method further includes: Obtain the business code file for updating the project, and the second code belongs to the business code file for updating.

7. The method according to claim 1, wherein, the obtaining of the framework code file for updating the project includes: Based on the original framework code file, reconstruct the framework of the project to generate a framework code file for updating the project, and the code file for updating is used to adjust the business of the project.

8. The method according to claim 7, wherein, the generating of the framework code file for updating the project includes: Generate the framework code file for updating the project by using a preset framework generation rule.

9. The method according to claim 7, wherein, the reconstructing the framework of the project based on the original framework code file to generate a framework code file for updating the project includes: Construct a second abstract syntax tree of the original framework code file; Adjust the second abstract syntax tree so that the original framework code file conforms to the standard framework code file format; Add at least one responsibility chain node to the second abstract syntax tree, and the responsibility chain node is used to implement an adjusted business processing method; Generate a framework code file for updating by using the adjusted second abstract syntax tree.

10. The method according to claim 9, wherein, the business is a log printing business, and the at least one responsibility chain node includes one or more of the following responsibility chain nodes: A responsibility chain node for filtering logs that meet the printing conditions, a responsibility chain node for adjusting the log printing format, and a responsibility chain node for log buried point and alarm.

11. The method according to any one of claims 1-10, wherein, the updating the first code by using the second code includes: Construct a third abstract syntax tree of the original business code file; Traverse the third abstract syntax tree to determine the first code including the first content; Replace the first code by using the second code; Generate a target business code file by using the replaced third abstract syntax tree, and the target business code file is used to replace the original business code file.

12. The method according to any one of claims 1-10, wherein, the framework code file for updating is a reusable framework code file.

13. A code updating device, wherein, the device includes: A first obtaining unit for obtaining an original code file of a project, and the original code file includes an original framework code file and an original business code file; the original business code file is used to execute project business based on the original framework code file; A second obtaining unit for obtaining a framework code file for updating the project; A first updating unit for updating the original framework code file by using the framework code file for updating; A determination unit, configured to determine the correspondence between the first code and the second code based on the code content included in the original framework code file and the code content included in the framework code file for update, where the first code belongs to the original business code file, and the second code is the business code for update determined based on the framework code file for update; A second update unit, configured to update the first code with the second code.

14. An electronic device, characterized in that, it includes: one or more processors; a storage device, on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-12.

15. A computer-readable medium, characterized in that, a computer program is stored thereon, where when the program is executed by a processor, the method according to any one of claims 1-12 is implemented.