Code logic display method and device, computer equipment, medium and product
By receiving code query commands, querying and displaying code logic diagrams, marking the source of node data, generating and storing call relationships, the problem of low efficiency and accuracy in code understanding is solved, and fast and accurate code logic understanding is achieved.
Patent Information
- Application Number
- CN202511749611.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-02-17
AI Technical Summary
Existing technologies suffer from low efficiency and accuracy in code comprehension, especially when newcomers take over the maintenance of the original code, making it difficult to quickly and accurately understand the code logic.
By receiving code query commands, the system queries the code database to obtain the target code logic diagram, displays it on a visual interactive page, annotates the data source information of nodes, and generates and stores the code logic diagram, including the call relationships of methods, external systems, and data tables.
It allows for quick and accurate understanding of code logic without relying on source code, improving understanding efficiency and accuracy, ensuring the accuracy and reliability of logic diagrams, and supporting long-term storage and multiple queries.
Smart Images

Figure CN121542331A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, medium, and product for displaying code logic. Background Technology
[0002] Understanding the original business code is extremely important during the development of business code. For example, when a new person takes over the maintenance of the original code, such as when a new employee joins the company or when the code is being modified for IT innovation, one of the problems that often arises is how to quickly and accurately understand the original execution logic of the code. Whether it is to meet new business requirements or to rewrite the original logic for IT innovation, it is all based on an accurate understanding of the original code.
[0003] In related technologies, methods for understanding code typically include reviewing existing business documentation, reading code comments, and reading the code itself. However, documentation and comments are not directly equivalent to code logic and can be misleading to developers; due to the complexity of the logic, obtaining existing logic by reading the code is not very efficient.
[0004] Therefore, understanding code logic in related technologies suffers from low efficiency and low accuracy. Summary of the Invention
[0005] Therefore, it is necessary to provide a method, apparatus, computer device, medium, and product for displaying code logic to facilitate quick and accurate understanding of the above-mentioned technical problems.
[0006] Firstly, this application provides a method for displaying code logic, including:
[0007] Receive a code query instruction; the code query instruction includes an identifier of the business code to be queried;
[0008] The code database is queried based on the identifier of the business code to be queried to obtain the target code logic graph corresponding to the identifier of the business code to be queried; the target code logic graph includes nodes and edges, the nodes include at least one type of method, external system and data table, and the edges represent the calling relationship between the nodes;
[0009] The target code logic diagram is displayed on a visual interactive page;
[0010] At the decision node in the target code logic diagram, at least one data source information on which the decision depends is marked; the data source information includes data table fields or external system interfaces.
[0011] In one embodiment, the method for displaying code logic further includes:
[0012] Determine the entry method corresponding to each business identifier in the business code to be analyzed;
[0013] The call relationships of the business code to be analyzed are determined based on the jump instructions of the business code to be analyzed. The call relationships include the call relationships between various methods, between methods and external systems, and between methods and data tables.
[0014] Based on the entry method and the calling relationship, determine the code logic diagram corresponding to each business identifier.
[0015] In one embodiment, determining the code logic diagram corresponding to each business identifier based on the entry method and the calling relationship includes:
[0016] For each business identifier, with the corresponding entry method as the root node, traverse the call relationships between each node in the business code to be analyzed;
[0017] Based on each node and the calling relationships between nodes, a code logic graph corresponding to the business identifier is established.
[0018] In one embodiment, the method for displaying code logic further includes:
[0019] The code logic diagrams corresponding to each business identifier are serialized into XML data, and the XML data is stored in the target database.
[0020] In one embodiment, the step of querying the code database based on the identifier of the business code to be queried to obtain the target code logic diagram corresponding to the identifier of the business code to be queried includes:
[0021] The target database is queried based on the identifier of the business code to be queried, and the target XML data is obtained.
[0022] The target XML data is deserialized into a target code logic graph.
[0023] In one embodiment, the method for displaying code logic further includes:
[0024] The packaged artifacts of the business code to be analyzed are parsed to obtain multiple bytecode files and configuration files;
[0025] Based on the configuration file, determine the entry method corresponding to each business identifier in the business code to be analyzed;
[0026] The call relationships of the business code to be analyzed are determined based on the bytecode file.
[0027] Secondly, this application also provides a device for displaying code logic, including:
[0028] A receiving module is used to receive code query instructions; the code query instructions include an identifier of the business code to be queried;
[0029] The query module is used to query the code database based on the identifier of the business code to be queried, and obtain the target code logic graph corresponding to the identifier of the business code to be queried; the target code logic graph includes nodes and edges, the nodes include at least one type of method, external system and data table, and the edges represent the calling relationship between the nodes;
[0030] The display module is used to display the target code logic diagram on a visual interactive page;
[0031] The annotation module is used to annotate at least one data source information on which the judgment of the target code logic diagram depends for the judgment of the node; the data source information includes data table fields or external system interfaces.
[0032] In one embodiment, the code logic display device further includes:
[0033] The first determination module is used to determine the entry method corresponding to each business identifier in the business code to be analyzed;
[0034] The second determining module is used to determine the calling relationship of the business code to be analyzed based on the jump instructions of the business code to be analyzed. The calling relationship includes the calling relationship between various methods, between methods and external systems, and between methods and data tables.
[0035] The third determining module is used to determine the code logic diagram corresponding to each business identifier based on the entry method and the calling relationship.
[0036] In one embodiment, the third determining module includes:
[0037] The traversal unit is used to traverse the call relationships between various nodes in the business code to be analyzed, with the corresponding entry method as the root node, for each business identifier;
[0038] A unit is established to create a code logic graph corresponding to the business identifier based on each node and the calling relationship between each node.
[0039] In one embodiment, the code logic display device further includes:
[0040] The serialization module is used to serialize the code logic diagram corresponding to each business identifier into XML data and store the XML data in the target database.
[0041] In one embodiment, the query module includes:
[0042] The query unit is used to query the target database based on the identifier of the business code to be queried, and obtain the target XML data;
[0043] The deserialization unit is used to deserialize the target XML data into a target code logic graph.
[0044] In one embodiment, the code logic display device further includes:
[0045] The parsing module is used to parse the packaged artifacts of the business code to be analyzed to obtain multiple bytecode files and configuration files;
[0046] The fourth determination module is used to determine the entry method corresponding to each business identifier of the business code to be analyzed based on the configuration file.
[0047] The fifth determining module is used to determine the calling relationship of the business code to be analyzed based on the bytecode file.
[0048] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the code logic display method proposed in the first aspect embodiment of this application.
[0049] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the code logic display method proposed in the first aspect embodiment of this application.
[0050] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the code logic presentation method proposed in the first aspect of the embodiments of this application.
[0051] The above-mentioned code logic display method, device, computer equipment, medium, and product receive a code query instruction; the code query instruction includes an identifier of the business code to be queried; the code database is queried according to the identifier of the business code to be queried to obtain the target code logic graph corresponding to the identifier of the business code to be queried; the target code logic graph includes nodes and edges, the nodes include at least one of methods, external systems, and data tables, and the edges represent the calling relationship between the nodes; the target code logic graph is displayed on a visual interactive page; at the judgment node in the target code logic graph, at least one data source information on which the judgment of the node depends is marked; the data source information includes data table fields or external system interfaces. This application embodiment can visualize the corresponding target code logic diagram based on the identifier of the business code to be queried, directly displaying the logic diagram to the user. At the judgment nodes in the target code logic diagram, at least one data source information is marked as required for the judgment of that node, facilitating the user's quick understanding of the business code to be queried. Users can understand the business code to be queried without reading the source code, improving efficiency. Furthermore, the logic diagram includes specific nodes and edges. Nodes include at least one type of method, external system, and data table, and edges represent the call relationships between nodes, ensuring the accuracy of the logic diagram. This improves the user's understanding of the business code to be queried and reduces misunderstandings. Therefore, displaying the target code logic diagram helps users quickly and accurately understand the code logic. In addition, this application embodiment does not rely on the source code; that is, it can still provide a complete code logic diagram without directly displaying the original code, further improving query efficiency. Furthermore, generating a code logic diagram for each business identifier based on the entry method and call relationship corresponding to the business identifier and displaying the code logic diagram to the user ensures the accuracy of the code logic diagram and facilitates the user's quick and accurate understanding of the code logic. Using the entry method as the root node and combining the call relationships, a code logic diagram for each business identifier is generated, ensuring the accuracy and reliability of the code logic diagram and facilitating users' correct understanding of the code logic. Furthermore, converting the code logic diagram into XML data and storing it enables persistent and permanent storage of the logic diagram, facilitating subsequent retrieval and achieving the effect of generating once and using multiple times. After persistent storage of the diagram, when it needs to be displayed, only the corresponding XML data needs to be retrieved and visualized, realizing long-term storage of the panoramic view. Displaying the logic diagram based on this improves efficiency while ensuring accuracy and reliability. Finally, this embodiment does not rely on source code, but determines the entry method and call relationships through the packaged code artifacts, ensuring the accuracy of the call relationships and entry method, thereby further improving the accuracy of the code logic diagram and facilitating users' quick and accurate understanding of the code logic. Attached Figure Description
[0052] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0053] Figure 1 This is an application environment diagram illustrating the code logic method in one embodiment;
[0054] Figure 2 This is a flowchart illustrating the code logic of one embodiment;
[0055] Figure 3 This is a flowchart illustrating the determination of the code logic diagram in another embodiment;
[0056] Figure 4 for Figure 3 A flowchart illustrating step 301 in the middle section;
[0057] Figure 5 This is a flowchart illustrating the code logic in yet another embodiment;
[0058] Figure 6 This is a flowchart illustrating the process of determining the entry method and the calling relationship in one embodiment;
[0059] Figure 7 This is a flowchart illustrating the code logic in a specific example.
[0060] Figure 8 This is a structural block diagram of a device for displaying code logic in one embodiment;
[0061] Figure 9 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0062] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. It should be noted that existing industry solutions such as software, components, and models may be mentioned in the embodiments of this application. These should be considered exemplary and are intended only to illustrate the feasibility of implementing the technical solutions of this application, but do not imply that the applicant has already used or necessarily used such solutions.
[0063] It should be noted that the acquisition, storage, use, and processing of data in the technical solution of this application all comply with the relevant provisions of national laws and regulations.
[0064] The terms "first," "second," etc., used in this application may be used to describe various elements, but these elements are not limited by these terms. These terms are used only to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0065] The code logic display method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or located on the cloud or other network servers. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, drones, low-altitude aircraft, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Head-mounted devices can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. Server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0066] In one exemplary embodiment, such as Figure 2 As shown, a method for displaying code logic is provided, which can be applied to... Figure 1 Taking terminal 102 as an example, the explanation includes the following steps 201 to 204. Wherein:
[0067] Step 201: Receive code query instruction; the code query instruction includes the identifier of the business code to be queried.
[0068] The code query command refers to the instruction entered by the user in any feasible way to query business code. The business code to be queried refers to at least one branch of a complete code block. For example, a complete code block Q may include multiple independent code branches Q1, Q2, and Q3, etc., each representing a piece of code logic. The code query command includes the identifier of the business code to be queried. The identifier is a unique identifier for the business code to be queried, which can be a business identifier or an entry method. The identifier is a unique identifier for the business code to be queried, and can be a string of numbers and / or letters. The entry method is the first method called among all methods in the business code to be queried when it is started and run; it is also called the starting point method.
[0069] For example, the terminal provides an interactive interface, such as a search box or a click button. When a user needs to understand a piece of code, they can input at least one code query command through this interface so that the terminal can parse and execute the corresponding query action. Each command includes an identifier of the business code to be queried.
[0070] Step 202: Query the code database based on the identifier of the business code to be queried to obtain the target code logic diagram corresponding to the identifier of the business code to be queried.
[0071] The target code logic graph includes nodes and edges. Nodes include at least one of the following: methods, external systems, and data tables. Edges represent the calling relationships between nodes.
[0072] The code database is a pre-built database that stores code logic graphs of all business code to be analyzed. Each type of business code corresponds to a code logic graph. The code logic graph can be a directed graph including nodes and directed edges. Nodes include at least one of the following: methods, external systems, and data tables. Each edge connects two nodes, representing the call relationship or data flow between them. Methods refer to the methods in the code to be queried; external systems refer to databases, caches, third-party interfaces, etc., called by the code; and data tables refer to tables in the database accessed by the code. For example, when method A of the business code to be queried calls method B, method B queries data table W, and method B sends a request to the external system payment gateway N, the nodes in the code logic graph are A, B, W, and N. There is a directed edge between A and B, between B and W, and between B and N, forming the code logic graph of the business code.
[0073] For example, upon receiving a code query instruction, the system retrieves the code logic diagram corresponding to the identifier of the business code to be queried, as included in the instruction, from a pre-built code database to obtain the target code logic diagram. Each code logic diagram is uniquely associated with an identifier, and the name of the code logic diagram can include the identifier. Therefore, the corresponding code logic diagram can be found by searching and matching the diagram names. Optionally, the system traverses the names of each code logic diagram based on the identifier of the business code to be queried until a name matches an identifier, at which point the traversal ends, and the code logic diagram corresponding to that name is taken as the target code logic diagram.
[0074] Step 203: Display the target code logic diagram on the visual interactive page.
[0075] Among them, the visual interactive page refers to the page used by users to interact with the terminal.
[0076] For example, after the target code logic diagram is located, it is rendered and displayed on a visual interactive page for users to browse. This page also has a user interface, allowing users to annotate, zoom, drag, collapse, and enlarge the target code logic diagram.
[0077] Step 204: At the decision node in the target code logic diagram, mark at least one data source information on which the decision depends.
[0078] The data source information includes data table fields or external system interfaces. A judgment node refers to a node with judgment functionality.
[0079] For example, in the visualization of the target code logic diagram, it not only shows the branching structure at the decision node M (e.g., if A is true, execute B; otherwise, execute C), but also annotates the data source information upon which the decision logic of node M is based. When the decision condition depends on a specific field retrieved from the database, the annotated data source information could be: Data source: a field in the data table, etc.; when the decision condition depends on the result returned by an interface of an external system (not the program itself), the annotated data source information could be: Data source: an interface in the external system, etc. By annotating the data source information, users can directly see a row of data source annotations next to the decision nodes in the diagram, improving the efficiency of users' understanding of the code logic.
[0080] For example, a single code segment M for a specific business function might comprise multiple independent sub-business codes M1, M2, and M3. When a user needs to understand sub-business code M1, they input a code query command including an identifier for M1. The terminal then traverses the code logic diagrams in the code database based on this identifier until it finds the corresponding code logic diagram X1. This code logic diagram X1 is then displayed on a visual interactive interface for the user to browse. A brief overview allows the user to accurately understand the call relationships or data flow within methods, external systems, and data tables of sub-business code M1, thereby comprehending its logic. Furthermore, data source information can be annotated at the decision nodes in code logic diagram X1, allowing the user to understand the data sources upon which the decision logic relies.
[0081] In the above method for displaying code logic, a code query instruction is received; the code query instruction includes an identifier of the business code to be queried; the code database is queried based on the identifier of the business code to be queried to obtain the target code logic graph corresponding to the identifier of the business code to be queried; the target code logic graph includes nodes and edges, the nodes include at least one of the following: methods, external systems, and data tables, and the edges represent the calling relationships between the nodes; the target code logic graph is displayed on a visual interactive page; at the judgment node in the target code logic graph, at least one data source information on which the judgment of the node depends is marked; the data source information includes data table fields or external system interfaces. This application embodiment can visualize the corresponding target code logic diagram based on the identifier of the business code to be queried, directly displaying the logic diagram to the user. At the decision nodes in the target code logic diagram, at least one data source information is marked as required for the decision, facilitating the user's quick understanding of the business code to be queried. Users can understand the business code without reading the source code, improving efficiency. Furthermore, the logic diagram includes specific nodes and edges. Nodes include at least one type: methods, external systems, and data tables, while edges represent the call relationships between nodes, ensuring the accuracy of the logic diagram and improving the user's understanding of the business code to be queried, reducing misunderstandings. Therefore, displaying the target code logic diagram helps users quickly and accurately understand the code logic. In addition, this application embodiment does not rely on the source code; that is, it can still provide a complete code logic diagram without directly displaying the original code, further improving query efficiency.
[0082] The following example illustrates how to construct the code logic diagram corresponding to each business identifier in a complete piece of business code.
[0083] In one exemplary embodiment, such as Figure 3 As shown, the method for demonstrating the code logic also includes steps 301 to 303. Wherein:
[0084] Step 301: Determine the entry method corresponding to each business identifier of the business code to be analyzed.
[0085] The business code to be analyzed refers to a complete block of code corresponding to a single business. This business includes multiple sub-businesses, each with its own business identifier, thus each sub-business corresponds to a code branch. The business code to be queried in step 201 above is this code branch. A business may have multiple business identifiers; for example, a payment business may include identifiers for sub-businesses such as access and settlement. The entry method refers to the first method called among all methods in the code corresponding to each business identifier when it is started and executed; it is also called the starting point method.
[0086] For example, an entry method resolver can be configured to first obtain the configuration file of the business code to be analyzed, parse the configuration file to obtain the entry method corresponding to each business identifier, and traverse the bytecode starting from the entry method.
[0087] Step 302: Determine the calling relationships of the business code to be analyzed based on the jump instructions of the business code to be analyzed. The calling relationships include the calling relationships between various methods, between methods and external systems, and between methods and data tables.
[0088] Jump instructions are used to characterize the jump logic between methods, external systems, and / or data tables in the code.
[0089] Optionally, a call relationship resolver can be configured to specifically handle bytecode jump instructions. For different jump instructions, the call relationships of the business code to be analyzed can be determined, including between methods, between methods and external systems, and between methods and data tables.
[0090] Step 303: Determine the code logic diagram corresponding to each business identifier based on the entry method and the calling relationship.
[0091] Optionally, starting from the entry method, the bytecode is traversed, and the call relationships are determined based on the jump instructions of the business code to be analyzed. When the bytecode traversal is complete, the code branch logic structure corresponding to the business identifier is obtained, representing the call relationships or data flow between methods, between methods and external systems, and between methods and data tables. Then, the call relationships are displayed as edges, and methods, external systems, and data tables are displayed as nodes, generating multiple directed graphs including nodes and edges, which are the code logic graphs corresponding to each business identifier. The logic graphs can also be named after the identifiers and / or entry methods of the business code to facilitate quick retrieval of the target code logic graph during querying.
[0092] It should be noted that, following the example above, if a user needs to understand an entire piece of code M, they can input the identifier of code M. The terminal will then display a panoramic view of the code logic on the visual interactive interface based on the identifier, so that the user can quickly understand the business meaning of code M.
[0093] This example generates a code logic diagram for each business identifier based on the entry method corresponding to the business identifier, the call relationship obtained by parsing the bytecode jump instructions, and the tracing of the source of the code data. Finally, when the user queries, the code logic diagram is displayed to the user, which can ensure the accuracy of the code logic diagram and facilitate the user's quick understanding of the code logic.
[0094] Furthermore, such as Figure 4 As shown, step 301 above includes steps 401 and 402, wherein:
[0095] Step 401: For each business identifier, take the corresponding entry method as the root node and traverse the call relationship between each node in the business code to be analyzed.
[0096] Step 402: Based on each node and the call relationship between each node as the edge, establish the code logic diagram corresponding to the business identifier.
[0097] The business identifier can be a transaction code, which is a string of numbers and / or letters.
[0098] For example, for a transaction code J, with the corresponding entry method J1 as the root node, starting from the root node, analyze the code of the entry method. Based on the jump instructions, determine that it calls methods J2 and J3. Then create two edges, pointing from J1 to J2 and J3 respectively. Then move to J2 and J3, determine that J2 calls the external system J4 and J3 queries the data table J5. Then create two more edges, pointing from J2 to J4 and from J3 to J5. Continue this process until all call relationships have been traversed, and a code logic graph corresponding to transaction code J can be obtained, where the nodes are J1 to J5 and the edges are the directed connections between the nodes.
[0099] This example uses the entry method as the root node and combines the call relationships to generate a code logic diagram for each business identifier, ensuring the accuracy and reliability of the code logic diagram and making it easier for users to correctly understand the code logic.
[0100] After constructing all the code logic diagrams, they can be permanently stored by performing a persistence transformation. That is, in an exemplary embodiment, such as... Figure 5 As shown, the method for demonstrating the code logic also includes step 501:
[0101] Step 501: Serialize the code logic diagram corresponding to each business identifier into XML data, and store the XML data in the target database.
[0102] For example, a format converter can be configured to serialize each code logic diagram into XML data in XML format and store it in a target database, which is a database specifically for storing XML data of code logic diagrams.
[0103] Therefore, converting the code logic diagram into XML data and storing it enables persistent and permanent storage of the logic diagram, facilitating subsequent queries and achieving the effect of generating once and using multiple times.
[0104] Furthermore, referring to Figure 5 Based on step 501, step 202 may include steps 502 and 503:
[0105] Step 502: Query the target database based on the identifier of the business code to be queried to obtain the target XML data.
[0106] Step 503: Deserialize the target XML data into a target code logic diagram.
[0107] For example, if a user needs to understand the logic of a specific business code to be queried, they only need to enter the entry method name or identifier through the method or identifier retriever. After receiving the input, the terminal retrieves XML data from the target database based on the entry method name or identifier. The target XML data is obtained by matching the name of the XML data, which includes the entry method name or business identifier (such as a transaction code). A displayer is configured to restore the target XML data into visual node edge data, i.e., the target code logic diagram, and display the target code logic diagram on a visualization page to facilitate developers' quick understanding of the code logic.
[0108] This example demonstrates how persistently storing a panoramic image allows for easy visualization by simply retrieving the corresponding XML data when needed. This enables the display of a logical diagram, improving efficiency while ensuring accuracy and reliability.
[0109] The following describes how to obtain the entry method and call relationships.
[0110] In one exemplary embodiment, such as Figure 6 As shown, the code logic method also includes steps 601 to 603. Wherein:
[0111] Step 601: Parse the packaged artifacts of the business code to be analyzed to obtain multiple bytecode files and configuration files.
[0112] The packaged artifacts can be deployable files such as JAR or WAR. Each bytecode file (.class file) contains multiple bytecode snippets, and the configuration file can be a Spring configuration file.
[0113] Optionally, a bytecode parser can be configured. The input to the parser is the packaged artifact of the business code to be analyzed. After obtaining the file path, the packaged artifact is decompressed and parsed to obtain the Spring configuration file and multiple bytecode files of the business code to be analyzed.
[0114] Step 602: Based on the configuration file, determine the entry method corresponding to each business identifier of the business code to be analyzed.
[0115] Optionally, the business identifier can be a transaction code, and the entry method corresponding to each transaction code can be obtained by parsing the Spring configuration file.
[0116] Step 603: Determine the call relationships of the business code to be analyzed based on the bytecode file.
[0117] For example, based on bytecode files, the call relationships or data flows between methods, between methods and external systems, and between methods and data tables are obtained according to bytecode logical jump instructions. Starting from the entry method, all methods called by the entry method are found, and then these called methods are analyzed, and so on, until all call relationships have been traversed.
[0118] This example determines the entry method and call relationships by packaging the code artifacts without relying on the source code, ensuring the accuracy of the call relationships and entry methods, thereby further improving the accuracy of the code logic diagram.
[0119] The following example illustrates how the code logic of this application is presented.
[0120] like Figure 7As shown, the terminal is configured with an entry method parser 701, a call relationship parser 702, a code logic diagram generator 703, a format converter 704, a target database 705, a retrieval device 706, and a display device 707. In the backend logic processing layer, the packaged artifacts of the business code to be analyzed are parsed and stored in the database. The entry method parser 701 parses the Spring configuration file to obtain the entry methods corresponding to each transaction code in the business code to be analyzed. The call relationship parser 702 parses the .class file according to the bytecode logic jump instructions to obtain the call relationships between methods, between methods and external systems, and between methods and data tables. The code logic diagram generator 703 generates the code logic diagram for each transaction code based on the entry methods and call relationships. The format converter 704 serializes the code logic diagram into XML data and writes it to the target database 705. In the front-end page display layer, the retrieval unit 706 receives the code query command (including a specific transaction code) input by the user, retrieves the target XML data corresponding to the specific transaction code from the target database 705, and restores the target XML data into a target code logic diagram through a format converter. The display unit 707 displays the target code logic diagram on the terminal's visual interactive page, making it easy for users to quickly understand the code logic corresponding to the transaction code.
[0121] In summary, the embodiments of this application do not rely on program source code. Based on bytecode technology, the packaged artifacts of the code can be parsed; a logic diagram is generated based on the parsing of bytecode jump instructions; the data source of the judgment basis at the logic branch point is identified by tracing the source of program variable data; and finally, the code logic diagram is displayed to the user in units of program interfaces, so that the user can quickly understand the business meaning of the code, thereby improving the efficiency and accuracy of the user's understanding of the code logic.
[0122] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0123] Based on the same inventive concept, this application also provides a device for displaying code logic to implement the code logic display method described above. The solution provided by this device is similar to the implementation described in the above method. Therefore, the specific limitations of one or more code logic display device embodiments provided below can be found in the limitations of the code logic display method described above, and will not be repeated here.
[0124] In one exemplary embodiment, such as Figure 8 As shown, a code logic display device is provided, including: a receiving module 801, a query module 802, a display module 803, and an annotation module 804, wherein:
[0125] The receiving module 801 is used to receive a code query instruction; the code query instruction includes an identifier of the business code to be queried;
[0126] The query module 802 is used to query the code database according to the identifier of the business code to be queried, and obtain the target code logic graph corresponding to the identifier of the business code to be queried; the target code logic graph includes nodes and edges, the nodes include at least one type of method, external system and data table, and the edges represent the calling relationship between the nodes;
[0127] The display module 803 is used to display the target code logic diagram on a visual interactive page;
[0128] The annotation module 804 is used to annotate at least one data source information on which the judgment of the target code logic node depends for the judgment; the data source information includes data table fields or external system interfaces.
[0129] In one embodiment, the apparatus further includes a first determining module, a second determining module, and a third determining module, wherein:
[0130] The first determination module is used to determine the entry method corresponding to each business identifier in the business code to be analyzed;
[0131] The second determining module is used to determine the calling relationship of the business code to be analyzed based on the jump instructions of the business code to be analyzed. The calling relationship includes the calling relationship between various methods, between methods and external systems, and between methods and data tables.
[0132] The third determining module is used to determine the code logic diagram corresponding to each business identifier based on the entry method and the calling relationship.
[0133] In one embodiment, the third determining module includes a traversal unit and a building unit, wherein:
[0134] The traversal unit is used to traverse the call relationships between various nodes in the business code to be analyzed, with the corresponding entry method as the root node, for each business identifier;
[0135] A unit is established to create a code logic graph corresponding to the business identifier based on each node and the calling relationship between each node.
[0136] In one embodiment, the apparatus further includes a serialization module, configured to serialize the code logic diagram corresponding to each business identifier into XML data, and store the XML data in a target database.
[0137] Furthermore, the query module includes a query unit and a deserialization unit, wherein:
[0138] The query unit is used to query the target database based on the identifier of the business code to be queried, and obtain the target XML data;
[0139] The deserialization unit is used to deserialize the target XML data into a target code logic graph.
[0140] In one embodiment, the apparatus further includes a parsing module, a fourth determining module, and a fifth determining module, wherein:
[0141] The parsing module is used to parse the packaged artifacts of the business code to be analyzed to obtain multiple bytecode files and configuration files;
[0142] The fourth determination module is used to determine the entry method corresponding to each business identifier of the business code to be analyzed based on the configuration file.
[0143] The fifth determining module is used to determine the calling relationship of the business code to be analyzed based on the bytecode file.
[0144] The modules in the above-described code logic demonstration device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0145] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 9As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data for methods used to display code logic. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for displaying code logic.
[0146] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0147] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement a method for demonstrating the code logic of embodiments of this application.
[0148] In one embodiment, a computer-readable storage medium is provided that stores a computer program thereon, wherein the computer program, when executed by a processor, implements the code logic of the embodiments of this application.
[0149] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements a method for demonstrating the code logic of embodiments of this application.
[0150] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, graphics processors, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0151] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0152] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method of presenting code logic, the method comprising: The method comprises: receiving a code query instruction; the code query instruction comprises an identifier of a business code to be queried; querying a code database according to the identifier of the business code to be queried to obtain a target code logic diagram corresponding to the identifier of the business code to be queried; the target code logic diagram comprises nodes and edges, the nodes comprise at least one of a method, an external system and a data table, and the edges represent calling relationships between the nodes; displaying the target code logic diagram on a visual interactive page; at a judgment node in the target code logic diagram, marking at least one data source information on which the node depends for judgment; the data source information comprises a data table field or an external system interface.
2. The method of claim 1, wherein, The method further comprises: determining an entry method corresponding to each business identifier of the business code to be analyzed; determining a calling relationship of the business code to be analyzed according to a jump instruction of the business code to be analyzed; the calling relationship comprises calling relationships between methods, between a method and an external system, and between a method and a data table; determining a code logic diagram corresponding to each business identifier according to the entry method and the calling relationship.
3. The method of claim 2, wherein, The determination of the code logic diagram corresponding to each business identifier according to the entry method and the calling relationship comprises: for each business identifier, taking the corresponding entry method as a root node and traversing the calling relationship between each node in the business code to be analyzed; based on each node and the calling relationship between the nodes, establishing the code logic diagram corresponding to the business identifier.
4. The method of claim 2, wherein, Further comprising: serializing the code logic diagrams corresponding to each business identifier into XML data and storing the XML data into a target database.
5. The method of claim 4, wherein, The determination of the target code logic diagram corresponding to the identifier of the business code to be queried according to the identifier of the business code to be queried comprises: querying the target database according to the identifier of the business code to be queried to obtain target XML data; deserializing the target XML data into a target code logic diagram.
6. The method according to any one of claims 2-5, characterized in that, The method further comprises: parsing a packaging product of the business code to be analyzed to obtain a plurality of bytecode files and configuration files; determining an entry method corresponding to each business identifier of the business code to be analyzed according to the configuration files; determining a calling relationship of the business code to be analyzed according to the bytecode files.
7. A presentation device for code logic, characterized by The apparatus comprises: a receiving module configured to receive a code query instruction; the code query instruction comprises an identifier of a business code to be queried; a querying module configured to query a code database according to the identifier of the business code to be queried to obtain a target code logic diagram corresponding to the identifier of the business code to be queried; the target code logic diagram comprises nodes and edges, the nodes comprise at least one of a method, an external system and a data table, and the edges represent calling relationships between the nodes; a display module configured to display the target code logic diagram on a visual interactive page; a marking module configured to, at a judgment node in the target code logic diagram, mark at least one data source information on which the node depends for judgment; the data source information comprises a data table field or an external system interface.
8. The apparatus of claim 7, wherein, The apparatus further comprises: A first determining module configured to determine an entry method corresponding to each business identifier of the business code to be analyzed; A second determining module configured to determine a calling relationship of the business code to be analyzed according to a jump instruction of the business code to be analyzed, the calling relationship comprising a calling relationship between each method, between a method and an external system, and between a method and a data table; A third determining module configured to determine a code logic diagram corresponding to each business identifier according to the entry method and the calling relationship.
9. The apparatus of claim 8, wherein, The third determining module comprises: A traversal unit configured to, for each business identifier, take the corresponding entry method as a root node, and traverse the calling relationship between each node in the business code to be analyzed; An establishing unit configured to establish the code logic diagram corresponding to each business identifier based on each node and the calling relationship between each node.
10. The apparatus of claim 8, wherein, The apparatus further comprises: A serialization module configured to serialize the code logic diagram corresponding to each business identifier into XML data, and store the XML data into a target database.
11. The apparatus of claim 10, wherein, The query module comprises: A query unit configured to query the target database according to an identifier of the business code to be queried, and obtain target XML data; A deserialization unit configured to deserialize the target XML data into a target code logic diagram.
12. The device of any one of claims 8-11, wherein, The apparatus further comprises: An analysis module configured to analyze a packaging product of the business code to be analyzed to obtain a plurality of bytecode files and configuration files; A fourth determining module configured to determine an entry method corresponding to each business identifier of the business code to be analyzed according to the configuration files; A fifth determining module configured to determine a calling relationship of the business code to be analyzed according to the bytecode files.
13. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor executes the computer program to implement the steps of the method in any one of claims 1 to 6.
14. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.
15. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.