Process generation method and device, electronic equipment, storage medium and product

By automatically generating code flowcharts, combining code statements and comments, the problem of low manual drawing efficiency is solved, efficient and multi-format code flowchart generation is realized, and the readability and understanding of code logic is improved.

CN119166151APending Publication Date: 2024-12-20MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411117688.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-14
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

During the software system development process, the code flow chart usually requires developers to draw manually, which is inefficient and difficult to meet the readability and accuracy requirements of the code logic.

Method used

By obtaining the code statements and comments in the target code, a first format code flow chart is generated, and the code comments are added to the node, and then the first format description file is converted into a second format description file to generate a second format code flow chart. , realizes automated generation and multi-format support.

Benefits of technology

It improves the generation efficiency and readability of code flow charts, supports generation in different formats, meets the needs of diverse usage scenarios, and improves the understanding and interpretation ability of code logic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166151A_ABST
    Figure CN119166151A_ABST
Patent Text Reader

Abstract

The invention provides a process generation method and device, electronic equipment, a storage medium and a product, and the method comprises the steps: obtaining a target code which comprises a code statement and a code annotation; generating nodes of a first format code flow chart and connecting edges among the nodes according to the code statements, and adding the code annotations into the corresponding nodes according to the incidence relation between the code annotations and the code statements to obtain a first format description file of the first format code flow chart, the connecting edge is used for representing a logical relationship between code statements in the node; and converting the first format description file into a second format description file, and generating a second format code flow chart according to the second format description file, so that the generation efficiency and readability of the code flow chart can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a process generation method, device, electronic device, storage medium and product. Background Art

[0002] In the process of software system development, code flowcharts are very important. They can be used to help increase the readability of the code and facilitate discussions on code logic among people in different roles. They can also be used to automatically generate test cases and reduce omissions in test scenarios. In related technologies, code flowcharts usually require developers to draw them manually based on code and business understanding, which is inefficient. Summary of the invention

[0003] The present disclosure provides a process generation method, device, electronic device, storage medium and product.

[0004] In a first aspect, the present disclosure provides a process generation method, the process generation method comprising:

[0005] Obtaining target code, wherein the target code includes code statements and code comments;

[0006] Generate nodes of a first format code flow chart and connection edges between the nodes according to the code statements, and add the code comments to corresponding nodes according to the association relationship between the code comments and the code statements, to obtain a first format description file of the first format code flow chart, wherein the connection edges are used to characterize the logical relationship between the code statements in the nodes;

[0007] The first format description file is converted into a second format description file, and a second format code flow chart is generated according to the second format description file.

[0008] In a second aspect, the present disclosure provides a process generation device, the process generation device comprising:

[0009] An acquisition module, used for acquiring target code, wherein the target code includes code statements and code comments;

[0010] A first generating module is used to generate nodes of a first format code flow chart and connection edges between the nodes according to the code statements, and add the code comments to corresponding nodes according to the association relationship between the code comments and the code statements, so as to obtain a first format description file of the first format code flow chart, wherein the connection edges are used to represent the logical relationship between the code statements in the nodes;

[0011] The second generating module is used to convert the first format description file into a second format description file, and generate a second format code flow chart according to the second format description file.

[0012] In a third aspect, the present disclosure provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, and one or more of the computer programs are executed by the at least one processor so that the at least one processor can execute the above-mentioned process generation method.

[0013] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned process generation method when executed by a processor.

[0014] In a fifth aspect, the present disclosure provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying a computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned process generation method.

[0015] In an embodiment of the present disclosure, a target code is obtained, the target code includes code statements and code comments, and a first format description file of a first format code flow chart is generated based on the code statements and code comments, and the first format description file is converted into a second format description file to generate a second format code flow chart. In this way, the code flow chart can be automatically generated, which improves efficiency. In addition, the code comments are not only generated based on the code statements, but also are generated into the code flow chart, which is more intuitive and improves the readability of the code flow chart. In addition, code flow charts of different formats can be generated, which can support more diverse usage scenarios and meet the needs of different scenarios.

[0016] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings, in which:

[0018] Figure 1 A flowchart of a process generation method provided by an embodiment of the present disclosure;

[0019] Figure 2 A flowchart of another process generation method in an embodiment of the present disclosure;

[0020] Figure 3 A process logic diagram of a process generation method in an embodiment of the present disclosure;

[0021] Figure 4 A block diagram of a process generation device provided by an embodiment of the present disclosure;

[0022] Figure 5 A block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0023] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0024] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.

[0025] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.

[0026] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "including" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. "Connected" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.

[0027] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.

[0028] In the technical solution disclosed in this disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals. The use of user data in this technical solution complies with relevant national laws and regulations (for example, the "Information Security Technology Personal Information Security Specification", etc.). For example: corresponding prescribed measures are taken for personal information access control; prescribed restrictions are imposed on the display of personal information; the purpose of using personal information does not exceed the scope of direct or reasonable association; when using personal information, clear identity orientation is eliminated to avoid precise positioning of specific individuals.

[0029] At present, in the process of software system development, code flowcharts are very important. They can be used as an aid to increase the readability of the code and facilitate discussions on code logic by people in different roles. They can also be used to automatically generate test cases and reduce omissions of test scenarios. In related technologies, code flowcharts usually require developers to manually draw them based on code and business understanding, which reduces efficiency and accuracy.

[0030] The present disclosure provides a process generation method, which obtains a target code, wherein the target code includes code statements and code comments, generates a first format description file of a first format code flow chart according to the code statements and code comments, and converts the first format description file into a second format description file to generate a second format code flow chart. In this way, the code flow chart is automatically generated according to the code statements and code comments, which improves efficiency and accuracy. The code comments are generated into the code flow chart, which increases the readability and interpretability of the code flow chart and makes it more intuitive. In addition, code flow charts of different formats can be generated to meet the needs of different scenarios, thereby supporting the viewing of code flow charts of different formats, and making the viewing and use more flexible and diverse.

[0031] To facilitate understanding of the embodiments of the present disclosure, a process generation method disclosed in the embodiments of the present disclosure is first introduced in detail. The execution subject of the process generation method provided in the embodiments of the present disclosure is generally an electronic device with certain computing capabilities. The electronic device includes, for example: a terminal device, a server or other processing device. The terminal device can be a user equipment (User Equipment, UE), a mobile device, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a wearable device, etc. The server can be an independent physical server, a server cluster composed of multiple physical servers, or a cloud server capable of cloud computing. In some possible implementations, the process generation method can be implemented by a processor calling a computer-readable instruction stored in a memory.

[0032] It should be noted that the process generation method and apparatus provided in the embodiments of the present disclosure can be executed by an electronic device, and accordingly, the process generation method and apparatus provided in the embodiments of the present disclosure can be set in an electronic device. The process generation method and apparatus provided in the embodiments of the present disclosure can also be executed by multiple different electronic devices. For example, in the embodiments of the present disclosure, the generation methods of the first format code flow chart and the second format code flow chart can be respectively deployed in one or more electronic devices for implementation, which is not limited in the embodiments of the present disclosure.

[0033] Figure 1 A flowchart of a process generation method provided by an embodiment of the present disclosure. Figure 1 , the method comprising:

[0034] S101: Obtain target code, where the target code includes code statements and code comments.

[0035] At present, in the process of code writing or modification, the code is usually annotated to facilitate code reading and interpretation. The code comments are used to explain the business functions implemented by the code statements. In this way, in the embodiment of the present disclosure, the target code containing the code comments can be directly obtained. Of course, in order to further improve the generation effect of the code flow chart, in the embodiment of the present disclosure, relevant personnel can also be supported to check and verify first. If code comments are missing, corresponding code comments can be supplemented for the code statements.

[0036] It should also be noted that in the embodiments of the present disclosure, it is not required that each code statement has a corresponding code comment. In one possible embodiment, code comments are required for key logic code statements, judgment branch code statements, or code statements with logic that are difficult to understand, while code comments may not be required for simpler code statements or code statements that do not affect the understanding of the code logic.

[0037] S102: Generate connecting edges between nodes of a first format code flow chart according to code statements, and add code comments to corresponding nodes according to the association between code comments and code statements to obtain a first format description file of the first format code flow chart, wherein the connecting edges are used to characterize the logical relationship between code statements in the nodes.

[0038] Executing step S102, the present disclosure provides possible implementations, which may include:

[0039] 1) Generate nodes and connecting edges between nodes of a first format code flow chart according to the code statements.

[0040] In an embodiment of the present disclosure, after the target code is acquired, the target code is compiled to obtain a bytecode file of the target code, and then based on the bytecode file of the target code, a first format description file of a first format code flow chart is generated, wherein the connection edges between nodes can be generated first according to the compiled code statements. In a possible embodiment, a configuration can be performed in advance to generate a line of code statements into a node, or a line of code statements can be split according to the code logic and generated into multiple nodes, etc., and then the connection edges between nodes are generated according to the code logic relationship between the code statements contained in each node, and nodes with logical relationships have connection edges.

[0041] 2) According to the association relationship between the code comments and the code statements, the code comments are added to the corresponding nodes to obtain a first format description file of the first format code flow chart.

[0042] In this way, the code flow chart generated only based on code statements has poor readability and is difficult to meet direct use requirements. It usually requires manual intervention for drawing and adjustment, and the efficiency is also low. In the embodiment of the present disclosure, the corresponding code comments are determined for the code statements in the nodes, and the code comments are also added to the nodes. The nodes in the obtained first format description file include code statements, or the nodes include code statements and code comments. Since the embodiment of the present disclosure does not require all code statements to have code comments, the nodes with corresponding code comments include code statements and code statements, and the nodes without corresponding code comments only include code statements. Compared with the code flow chart in which all nodes only include code statements, at least some of the nodes have code comments, which is more intuitive and clear, can improve the readability and effect of the code flow chart, and is easier for relevant personnel to understand.

[0043] Furthermore, in the embodiments of the present disclosure, the first format code flowchart may be displayed as required. For example, in response to a first format code flowchart generation instruction, a first format code flowchart is generated according to a first format description file, and the first format code flowchart is displayed.

[0044] S103: Convert the first format description file into a second format description file, and generate a second format code flow chart according to the second format description file.

[0045] Among them, in the embodiments of the present disclosure, the first format code flow chart and the second format code flow chart can be understood as code flow charts in different formats. In one possible embodiment, for example, the first format code flow chart is a dot format code flow chart, and the second format code flow chart is a logicflow format code flow chart.

[0046] Specifically for converting the first format description file into the second format description file in step S103, a possible implementation method is provided, which converts the first format description file into the second format description file, including: parsing the first format description file to obtain the nodes and connecting edges in the first format description file; determining the node statistical information and the node path statistical information based on the nodes and the connecting edges; obtaining the target format description information of the nodes and the connecting edges according to the target format corresponding to the second format description file, and obtaining the second format description file based on the node statistical information, the node path statistical information and the target format description information.

[0047] For example, the first format code flowchart is a dot format code flowchart, and its first format description file is a dot file. The second format code flowchart is a logicflow format code flowchart, and its second format description file uses a JSON file. By parsing the dot file, all nodes and connection edges can be parsed and converted into JSON format, that is, the JSON format is used to describe the nodes and connection edges to obtain the second format description file.

[0048] Furthermore, in the embodiments of the present disclosure, in order to improve the comprehensibility of the code flow chart, statistical analysis can also be performed to determine node statistical information and node path statistical information. For example, the node statistical information includes the end node, the number of end nodes, etc., and the node path statistical information includes the total number of node paths, the number of node paths corresponding to each end node, etc., and there is no restriction.

[0049] Furthermore, in the embodiments of the present disclosure, it is also possible to support displaying and editing a second format code flowchart, and specifically provide a possible implementation method, 1) displaying a second format code flowchart, wherein the second format code flowchart includes nodes and connecting edges, as well as node statistics information and node path statistics information.

[0050] 2) In response to a node path viewing operation of a node in the second format code flow chart, the node path to the node is highlighted.

[0051] For example, if a user wants to view all node paths to a certain node, he can click on the node or right-click to view, and all node paths to the node can be highlighted. In this way, in the disclosed embodiment, interactive viewing of the code flow chart can be supported to improve the display effect.

[0052] In the disclosed embodiment, a first format code flow chart can be generated based on code statements and code comments, and code comments can be generated into the code flow chart, which improves the readability of the code flow chart and makes it more intuitive. The first format code flow chart can also be converted into a second format code flow chart to provide more diverse usage scenario support.

[0053] The following is a detailed description of the method for determining the association relationship between the code comments and the code statements in step S102 in the above embodiment.

[0054] Specifically, the present disclosure provides a possible implementation manner, which includes, before adding the code comment to the corresponding node according to the association relationship between the code comment and the code statement, and obtaining the first format description file of the first format code flow chart, further comprising:

[0055] 1) Determine the location of the code comment in the target code and determine the statement type of the code statement.

[0056] The statement type includes a non-judgment branch statement type and a judgment branch statement type. For example, the code statement of the judgment branch statement type is an if statement.

[0057] 2) Determine the association between the code comment and the code statement based on the statement type of the code statement and the location of the code comment.

[0058] For example, in the embodiment of the present disclosure, for code statements of all statement types, when annotating, the code comment position requirements corresponding to the code statement all require that the code comment is located in front of the code statement it explains and is adjacent to the code statement.

[0059] In addition, the comment format can be pre-set for code comments of code statements of different statement types, which can improve parsing efficiency and enhance the accuracy of the association between code statements and code comments.

[0060] In a possible embodiment, for non-judgment branch statement types, the corresponding code comments are usually used to explain a complete code statement, that is, a code comment can be associated with a complete code statement without causing ambiguity and confusion in understanding. Therefore, for code statements of non-judgment branch statement types, the code comments do not need to be set in a special comment format, and can be written in accordance with existing text. For example, add the code comment "Create a payment order" before the code statement "A = extensionExecutor.execute".

[0061] In a possible embodiment, for a judgment branch statement type, a code statement may include multiple judgment branches. In order to more clearly express the business function of each judgment branch, a code statement of the judgment branch statement type can be set, and the comment format of the corresponding code comment can be set. For example, the comment format includes comments for each judgment branch in the code comment, and the comments for each judgment branch are connected using a preset identifier, such as the preset identifier is ||. In this way, when associating the code comment with the code statement, it can be split into multiple sub-code comments according to the identifier, and respectively associated with multiple judgment branch statements in the code statement of the judgment branch statement type.

[0062] Furthermore, based on the preset code comment location requirements and comment format requirements, the association relationship between the code comment and the code statement can be determined. Specifically, the present disclosure provides the following possible implementations:

[0063] 1) In a possible implementation, the statement type includes a non-judgment branch statement type, and the association relationship between the code comment and the code statement is determined according to the statement type of the code statement and the location of the code comment, including:

[0064] When the statement type is a non-judgment branch statement type, according to the position N where the code statement is located, determine the position M before the code statement, and determine the first code comment at position M, where position M is the position N-1, M is a positive integer greater than or equal to 1, and N is a positive integer greater than or equal to 2; determine the association relationship between the code statement and the first code comment.

[0065] For example, in an embodiment of the present disclosure, the positions of code statements and code comments in the target code are arranged in sequence. For example, if a code statement is located at position N, such as sentence 8, then the first code comment located at position N-1 before the code statement can be considered to be used to explain the code statement, and it is determined that the first code comment has an association relationship with the code statement.

[0066] 2) In a possible implementation, the statement type further includes determining a branch statement type, and determining an association relationship between the code comment and the code statement according to the statement type of the code statement and the location of the code comment, including:

[0067] When the statement type is a judgment branch statement type, according to the position N where the code statement is located, the position M before the code statement is determined, and the second code comment at position M is determined, and according to the preset comment format, the second code comment is split into sub-code comments, the position M is the position of position N-1, M is a positive integer greater than or equal to 1, and N is a positive integer greater than or equal to 2; according to the sub-code comment and the judgment branch statement contained in the code statement, the association relationship between the sub-code comment and the judgment branch statement is determined.

[0068] For example, the code statement at position N is "if(a=0)...if(b=1)...", and the second code comment at position N-1 is "determine whether the promissory note number is empty||determine whether to use a discount coupon", that is, the preset comment format is that the comment of each judgment branch is connected using a preset identifier||, and then the code statement is determined to be a judgment branch statement type. Then, according to the preset comment format, the second code comment is split to obtain multiple sub-code comments, namely "determine whether the promissory note number is empty", "determine whether to use a discount coupon", and it is determined that "determine whether the promissory note number is empty" is associated with "if(a=0)", and "determine whether to use a discount coupon" is associated with "if(b=1)".

[0069] The following uses a specific application scenario for illustration, taking the first format code flow chart as the dot format code flow chart and the second format code flow chart as the logicflow format code flow chart as an example, see Figure 2 As shown, it is a flow chart of another process generation method in an embodiment of the present disclosure.

[0070] S201: Obtain target code, where the target code includes code statements and code comments.

[0071] S202: Compile the target code.

[0072] S203: Customizing a first generation tool for a first format code flow chart.

[0073] For example, the first format code flow chart is a dot format code flow chart, and its first format description file is a dot file. In order to further improve the development efficiency, it can be extended and improved based on the soot tool in the related technology. The soot tool can be used to generate dot files, but the nodes generated by the soot tool in the related technology only contain code statements. Therefore, in the embodiment of the present disclosure, the soot tool in the related technology is improved, and an extension plug-in for generating code comments in nodes is developed. The functions implemented by the extension plug-in are mainly to obtain the code comments included in the target code according to the code abstract syntax tree parsed by soot, identify the code comments of code statements of different statement types, determine the association relationship between code statements and code comments, and add the code comments to the corresponding nodes.

[0074] S204: Using a first generation tool, generate a first format description file of a first format code flow chart.

[0075] For example, by running the soot tool and specifying the extension plug-in, and executing the generate dot command, the compiled target code can be generated into a dot file of a dot code flow chart, wherein the dot file includes generated nodes and connecting edges, and the nodes include code statements and code comments.

[0076] Furthermore, in the embodiment of the present disclosure, according to the needs, the dot file can be selected and the image generation function can be executed to generate a dot code flowchart. The dot code flowchart is in image format, and the generated dot code flowchart can be downloaded for use and viewing by relevant personnel.

[0077] S205: Customizing a second generation tool for converting a first format description file into a second format description file.

[0078] For example, the second format code flow chart is a logicflow format code flow chart, and the second format description file of the logicflow format code flow chart is a JSON file. In the embodiment of the present disclosure, a second generation tool can be developed to convert the dot file into a JSON file. The functions implemented by the second generation tool are mainly to read the dot file, parse the nodes and connection edges in the dot file, and convert them into a JSON description format. In addition, functions such as determining node statistical information and node path statistical information are added.

[0079] S206: Using a second generation tool, convert the first format description file into a second format description file, and generate a second format code flow chart.

[0080] For example, run the second generation tool, input the dot file, generate a JSON file, which may include node content, connection edge content, node coordinates, node style, node statistics, node path statistics, etc., and render the JSON file on the browser page to generate a logicflow format code flow chart.

[0081] S207: Display the second format code flow chart and support interactive viewing.

[0082] It should also be noted that in the embodiments of the present disclosure, it is not necessary to customize the development of the first generation tool and the second generation tool every time a code flow chart is generated. After the tools are developed, if a code statement change or a code comment change occurs, the first generation tool and the second generation tool developed in the embodiments of the present disclosure can be directly used to update the first format code flow chart and the second format code flow chart.

[0083] Based on the first generation tool and the second generation tool customized in the above embodiment, the data flow and conversion of the process generation method in the embodiment of the present disclosure are described. Figure 3 The figure is a process logic diagram of the process generation method in the embodiment of the present disclosure.

[0084] like Figure 3 As shown, 1) obtain the source code, that is, the target code containing code statements and code comments, for example, when developing a system, complete the source code of the gateway payment interface business logic.

[0085] 2) Use the compilation tool to compile the target code and obtain the compiled bytecode file.

[0086] 3) Using the first generation tool, a first format code flow chart is generated according to the bytecode file.

[0087] 4) Using a second generation tool, convert the first format code flow chart into a second format code flow chart.

[0088] 5) Display the second format code flow chart on the page through the code flow chart management system.

[0089] For example, in an embodiment of the present disclosure, the code flow chart may be integrated into a code flow chart management system to facilitate management and flexible display of the code flow chart.

[0090] In the disclosed embodiment, the soot tool is extended and developed, a first generation tool is customized, and code comments are generated into a first format code flow chart through the first generation tool, and a second generation tool is customized to convert the first format code flow chart into a second format code flow chart for display and support interactive viewing. In this way, through the development of the tool, the generation efficiency of the code flow chart can be improved, and the code flow chart contains code comments, so that the semantics and business functions of the nodes in the code flow chart are more intuitive, and the readability is improved. In addition, code flow charts in different formats can be generated, which can be applicable to more diverse and flexible usage scenarios.

[0091] It can be understood that the above-mentioned various method embodiments mentioned in the present disclosure can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, the present disclosure will not repeat them. It can be understood by those skilled in the art that in the above-mentioned method of the specific implementation method, the specific execution order of each step should be determined according to its function and possible internal logic.

[0092] In addition, the present disclosure also provides a process generation device, an electronic device, and a computer-readable storage medium, all of which can be used to implement any process generation method provided by the present disclosure. The corresponding technical solutions and descriptions are referred to the corresponding records in the method part and will not be repeated here.

[0093] Figure 4 A block diagram of a process generation device provided in an embodiment of the present disclosure.

[0094] Reference Figure 4 , the present disclosure embodiment provides a process generation device, the process generation device comprising:

[0095] An acquisition module 41 is used to acquire a target code, wherein the target code includes code statements and code comments;

[0096] A first generating module 42 is used to generate nodes of a first format code flow chart and connection edges between the nodes according to the code statements, and add the code comments to corresponding nodes according to the association relationship between the code comments and the code statements, so as to obtain a first format description file of the first format code flow chart, wherein the connection edges are used to represent the logical relationship between the code statements in the nodes;

[0097] The second generating module 43 is used to convert the first format description file into a second format description file, and generate a second format code flow chart according to the second format description file.

[0098] In a possible embodiment, before adding the code comment to the corresponding node according to the association relationship between the code comment and the code statement to obtain the first format description file of the first format code flow chart, the first generating module 42 is further used to:

[0099] Determine the position of the code comment in the target code, and determine the statement type of the code statement;

[0100] According to the statement type of the code statement and the location of the code comment, an association relationship between the code comment and the code statement is determined.

[0101] In a possible embodiment, the statement type includes a non-judgment branch statement type, and when determining the association relationship between the code comment and the code statement according to the statement type of the code statement and the location of the code comment, the first generating module 42 is used to:

[0102] In the case where the statement type is the non-judgment branch statement type, according to the position N where the code statement is located, determine the position M before the code statement, and determine the first code comment located at the position M, where the position M is the position N-1, M is a positive integer greater than or equal to 1, and N is a positive integer greater than or equal to 2;

[0103] An association relationship between the code statement and the first code comment is determined.

[0104] In a possible embodiment, the statement type further includes determining a branch statement type, and when determining the association relationship between the code comment and the code statement according to the statement type of the code statement and the location of the code comment, the first generating module 42 is used to:

[0105] In the case where the statement type is the judgment branch statement type, according to the position N where the code statement is located, determine the position M before the code statement, and determine the second code comment located at the position M, and split the second code comment into sub-code comments according to a preset comment format, the position M is the position of the position N-1, M is a positive integer greater than or equal to 1, and N is a positive integer greater than or equal to 2;

[0106] According to the sub-code annotation and the judgment branch statement contained in the code statement, the association relationship between the sub-code annotation and the judgment branch statement is determined.

[0107] In a possible embodiment, the node in the first format description file includes a code statement, or the node includes a code statement and a code comment, and when converting the first format description file into the second format description file, the second generating module 43 is used to:

[0108] Parsing the first format description file to obtain the nodes and the connection edges in the first format description file;

[0109] Determine node statistics and node path statistics according to the nodes and the connecting edges;

[0110] According to the target format corresponding to the second format description file, the target format description information of the node and the connection edge is obtained, and the second format description file is obtained according to the node statistical information, the node path statistical information and the target format description information.

[0111] A possible embodiment further includes a display module 44, which is used to:

[0112] Displaying the second format code flow chart, wherein the second format code flow chart includes the nodes and the connecting edges, as well as the node statistics information and the node path statistics information;

[0113] In response to a node path viewing operation of the node in the second format code flow graph, a node path leading to the node is highlighted.

[0114] Each module in the above-mentioned process generation device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.

[0115] Figure 5 A block diagram of an electronic device provided in an embodiment of the present disclosure.

[0116] Reference Figure 5 An embodiment of the present disclosure provides an electronic device, which includes: at least one processor 501; at least one memory 502, and one or more I / O interfaces 503, connected between the processor 501 and the memory 502; wherein the memory 502 stores one or more computer programs that can be executed by the at least one processor 501, and the one or more computer programs are executed by the at least one processor 501 so that the at least one processor 501 can execute the above-mentioned process generation method.

[0117] Each module in the above electronic device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0118] The present disclosure also provides a computer-readable storage medium on which a computer program is stored, wherein the computer program implements the above-mentioned process generation method when executed by a processor. The computer-readable storage medium may be a volatile or non-volatile computer-readable storage medium.

[0119] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned process generation method.

[0120] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium).

[0121] As is known to those of ordinary skill in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable program instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technology, portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. In addition, it is known to those of ordinary skill in the art that communication media typically contain computer-readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium.

[0122] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0123] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0124] The computer program product described herein may be implemented in hardware, software, or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK), etc.

[0125] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.

[0126] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0127] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0128] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.

[0129] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.

Claims

1. A process generation method, characterized in that: include: Obtaining target code, wherein the target code includes code statements and code comments; Generate nodes of a first format code flow chart and connection edges between the nodes according to the code statements, and add the code comments to corresponding nodes according to the association relationship between the code comments and the code statements, to obtain a first format description file of the first format code flow chart, wherein the connection edges are used to characterize the logical relationship between the code statements in the nodes; The first format description file is converted into a second format description file, and a second format code flow chart is generated according to the second format description file.

2. The process generation method according to claim 1, characterized in that: Before adding the code comment to the corresponding node according to the association relationship between the code comment and the code statement to obtain the first format description file of the first format code flow chart, the method further includes: Determine the position of the code comment in the target code, and determine the statement type of the code statement; According to the statement type of the code statement and the location of the code comment, an association relationship between the code comment and the code statement is determined.

3. The process generation method according to claim 2, characterized in that: The statement type includes a non-judgment branch statement type, and determining the association relationship between the code comment and the code statement according to the statement type of the code statement and the location of the code comment includes: In the case where the statement type is the non-judgment branch statement type, according to the position N where the code statement is located, determine the position M before the code statement, and determine the first code comment located at the position M, where the position M is the position N-1, M is a positive integer greater than or equal to 1, and N is a positive integer greater than or equal to 2; An association relationship between the code statement and the first code comment is determined.

4. The process generation method according to claim 2, characterized in that: The statement type also includes determining a branch statement type, and determining the association relationship between the code comment and the code statement according to the statement type of the code statement and the location of the code comment, including: In the case where the statement type is the judgment branch statement type, according to the position N where the code statement is located, determine the position M before the code statement, and determine the second code comment located at the position M, and split the second code comment into sub-code comments according to a preset comment format, the position M is the position of the position N-1, M is a positive integer greater than or equal to 1, and N is a positive integer greater than or equal to 2; According to the sub-code annotation and the judgment branch statement contained in the code statement, the association relationship between the sub-code annotation and the judgment branch statement is determined.

5. The process generation method according to any one of claims 1 to 4, characterized in that: The node in the first format description file includes a code statement, or the node includes a code statement and a code comment, and converting the first format description file into a second format description file includes: Parsing the first format description file to obtain the nodes and the connection edges in the first format description file; Determine node statistics and node path statistics according to the nodes and the connecting edges; According to the target format corresponding to the second format description file, the target format description information of the node and the connection edge is obtained, and the second format description file is obtained according to the node statistical information, the node path statistical information and the target format description information.

6. The process generation method according to claim 5, characterized in that: The method further comprises: Displaying the second format code flow chart, wherein the second format code flow chart includes the nodes and the connecting edges, as well as the node statistics information and the node path statistics information; In response to a node path viewing operation of the node in the second format code flow graph, a node path leading to the node is highlighted.

7. A process generation device, characterized in that: include: An acquisition module, used for acquiring target code, wherein the target code includes code statements and code comments; A first generating module is used to generate nodes of a first format code flow chart and connection edges between the nodes according to the code statements, and add the code comments to corresponding nodes according to the association relationship between the code comments and the code statements, so as to obtain a first format description file of the first format code flow chart, wherein the connection edges are used to represent the logical relationship between the code statements in the nodes; The second generating module is used to convert the first format description file into a second format description file, and generate a second format code flow chart according to the second format description file.

8. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs that can be executed by the at least one processor, and the one or more computer programs are executed by the at least one processor to enable the at least one processor to perform the process generation method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the process generation method according to any one of claims 1 to 6 is implemented.

10. A computer program product, characterized in that It includes a computer-readable code, or a non-volatile computer-readable storage medium carrying a computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the process generation method as described in any one of claims 1 to 6.