Module jump link identification method and device, storage medium and system
By using an abstract syntax tree parsing engine to identify and construct module jump links, the problem of scattered jump relationships in front-end offline packages is solved, enabling accurate restoration and visualization of jump links, thus improving engineering maintenance efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- AGRICULTURAL BANK OF CHINA
- Filing Date
- 2025-11-26
- Publication Date
- 2026-04-10
AI Technical Summary
The jump relationships between the front-end offline packages are scattered throughout the source code and lack a unified record, making it impossible to accurately grasp the actual jump links and parameter information between the offline packages, resulting in maintenance difficulties.
By acquiring the files to be parsed in the project, the abstract syntax tree parsing engine processes the code, identifies jump nodes and extracts unique identifiers, constructs jump links between modules, and generates a visual jump graph.
It enables accurate restoration of offline package jump paths, improves engineering maintenance efficiency, avoids missing or incorrect jump relationships, and enhances developers' understanding and debugging efficiency.
Smart Images

Figure CN121833036A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of financial technology, and more specifically, to a method for identifying module jump links, a device for identifying module jump links, a computer-readable storage medium, and a system for identifying module jump links. Background Technology
[0002] As front-end projects continue to expand in scale, mobile applications commonly use offline packages to split and deploy pages or business modules independently. These offline packages typically have various navigation relationships, with business logic connected via parameter passing. In actual development, this navigation logic is scattered across the source code of different offline packages, heavily reliant on developers manually maintaining documentation.
[0003] However, with frequent iterations of front-end business logic, a constantly increasing or changing number of offline packages, and high developer turnover, manually maintained redirection documentation often fails to keep pace with the actual code, sometimes resulting in omissions, gaps, or obsolescence. Over time, the actual redirection links and parameter passing methods within the system become difficult to accurately grasp. When the business needs to adjust redirection logic, troubleshoot linkage issues, or add new features, developers can only rely on manually reading large amounts of source code to deduce redirection relationships, leading to low maintenance efficiency, time-consuming problem localization, and even the potential for introducing new errors due to incomplete understanding of redirection relationships.
[0004] Therefore, accurately identifying the jump links and parameter passing methods between offline packages at the source code level, and parsing and presenting them in a unified manner, has become a key technical requirement for improving the maintainability and reliability of front-end engineering. In this application, each offline package can be regarded as a module that implements independent business functions. Summary of the Invention
[0005] The main objective of this application is to provide a method, device, computer-readable storage medium, and system for identifying module jump links, so as to at least solve the problem that in the prior art, the jump relationships of front-end offline packages are scattered in the source code and lack unified records, making it impossible to accurately grasp the actual jump links and parameter information between offline packages, resulting in maintenance difficulties.
[0006] To achieve the above objectives, according to one aspect of this application, a method for identifying module jump links is provided, comprising: obtaining a project to be parsed and determining a file to be parsed in the project to be parsed, wherein the project to be parsed is a project including at least one module, and each module includes multiple source code files; obtaining code to be parsed in the file to be parsed and processing the code to be parsed using an abstract syntax tree parsing engine to obtain a syntax tree of the code to be parsed, wherein the syntax tree of the code to be parsed represents the syntax structure of the code to be parsed; obtaining jump nodes of the syntax tree of the code to be parsed and determining a unique identifier of a jump target corresponding to the jump node, wherein the jump node is a syntax node used to implement the module jump; and determining the jump link of the module according to the unique identifier of the jump target, wherein the jump link represents the jump order relationship of the module.
[0007] Optionally, determining the file to be parsed in the project to be parsed includes: determining the file type of each source code file in the project to be parsed; and determining the source code file whose file type is a preset file type as the file to be parsed.
[0008] Optionally, after determining the jump link of the module based on the unique identifier of the jump target, the method further includes: generating a visual jump graph based on the jump link, wherein the visual jump graph is a graph of the jump relationship between the modules.
[0009] Optionally, obtaining the jump node of the code syntax tree to be parsed includes: traversing the code syntax tree to be parsed and obtaining the node field of each node in the code syntax tree to be parsed; if a preset jump field exists in the node field, determining the node as the jump node.
[0010] Optionally, the abstract syntax tree parsing engine is used to process the code to be parsed to obtain a syntax tree of the code to be parsed, including: if the abstract syntax tree parsing engine fails to process the code to be parsed, a syntax rule engine is used to process the code to be parsed to obtain corrected code to be parsed; the abstract syntax tree parsing engine is used to process the corrected code to be parsed to obtain the syntax tree of the code to be parsed.
[0011] Optionally, after determining the jump link of the module based on the unique identifier of the jump target, the method further includes: verifying the integrity of the jump link; if the jump link verification fails, marking the jump link as an abnormal jump link, and outputting the verification result containing the abnormal jump link to prompt for repair of the abnormal jump link.
[0012] Optionally, after obtaining the code to be parsed in the file to be parsed, the method further includes: preprocessing the code to be parsed to remove comments from the code to be parsed.
[0013] According to another aspect of this application, a module jump link identification device is provided, comprising: a first acquisition unit, configured to acquire a project to be parsed and determine a file to be parsed in the project to be parsed, wherein the project to be parsed is a project including at least one module, and each module includes multiple source code files; a second acquisition unit, configured to acquire code to be parsed in the file to be parsed and process the code to be parsed using an abstract syntax tree parsing engine to obtain a syntax tree of the code to be parsed, wherein the syntax tree of the code to be parsed represents the syntax structure of the code to be parsed; a third acquisition unit, configured to acquire jump nodes of the syntax tree of the code to be parsed and determine a unique identifier of a jump target corresponding to the jump node, wherein the jump node is a syntax node used to implement the module jump; and a determination unit, configured to determine the jump link of the module according to the unique identifier of the jump target, wherein the jump link represents the jump order relationship of the module.
[0014] According to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform any of the methods described.
[0015] According to another aspect of this application, a module jump link identification system is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include methods for performing any one of the methods described.
[0016] By applying the technical solution of this application, a comprehensive coverage of the code range in the offline package that may contain jump logic can be achieved by acquiring a project to be parsed, including multiple modules, and determining the files to be parsed to represent functional logic. An abstract syntax tree parsing engine is used to perform syntactic structuring on the code to be parsed, accurately identifying syntax nodes with jump semantics, thus avoiding the problem of manually searching for missed or misjudged jump statements. By extracting the unique identifier of the jump target from the jump node and recovering the jump relationship between modules based on this unique identifier, the jump link between modules can be automatically constructed, achieving accurate restoration of the jump path of the offline package. This solution can structure and link the jump information discretely distributed in the source code, enabling developers to clearly grasp the actual jump order relationship between offline packages, thereby improving project maintenance efficiency and avoiding problems such as missing, incorrect, or difficult-to-track jump relationships. It solves the problem in existing technologies where the jump relationships of front-end offline packages are scattered in the source code and lack unified records, making it impossible to accurately grasp the actual jump link and parameter information between offline packages, leading to maintenance difficulties. Attached Figure Description
[0017] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0018] Figure 1 A flowchart illustrating a method for identifying module jump links according to an embodiment of this application is shown.
[0019] Figure 2 A structural block diagram of a module jump link identification device provided according to an embodiment of this application is shown. Detailed Implementation
[0020] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0021] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0022] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0023] As described in the background section, in the prior art, the jump relationships of the front-end offline packages are scattered in the source code and lack unified records, making it impossible to accurately grasp the actual jump links and parameter information between each offline package, resulting in maintenance difficulties. To solve the above technical problems, the embodiments of this application provide a module jump link identification method, a module jump link identification device, a computer-readable storage medium, and a module jump link identification system.
[0024] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0025] Figure 1 This is a flowchart of a module jump link identification method according to an embodiment of this application. For example... Figure 1 As shown, the method includes the following steps:
[0026] Step S101: Obtain the project to be parsed and determine the files to be parsed in the project to be parsed. The project to be parsed is a project that includes at least one module, and each module includes multiple source code files.
[0027] Specifically, a module refers to a code unit within a project used to implement a specific business function or page function, consisting of one or more source code files. A module typically corresponds to a functional page, functional component, or business logic unit within the project, containing script code, logic code, or event handling code to implement that function. Different modules can jump between each other through jump statements in their code, thus forming a cross-module jump link. A module is the basic structural unit used to carry functional logic, and its boundaries can be defined based on the project's directory structure, business division method, or component configuration in the build system. The "module jump" identified in this solution refers to the navigation behavior or function switching behavior triggered by a jump statement within the code of one module, pointing to another module. It should be noted that the source code files within a module include not only the script files written by the business itself, but also external files such as public components and third-party libraries that it depends on; both together constitute the complete logic of the module. The aforementioned project can be a single-module project or composed of multiple independent or mutually calling modules.
[0028] Step S102: Obtain the code to be parsed from the above-mentioned file to be parsed, and use the abstract syntax tree parsing engine to process the code to be parsed to obtain the syntax tree of the code to be parsed. The syntax tree of the code to be parsed represents the syntax structure of the code to be parsed.
[0029] Specifically, the aforementioned abstract syntax tree parsing engine may include a parsing module for performing file scanning and code extraction using Python scripts, and a syntax analysis module for structuring the code content into an abstract syntax tree (AST).
[0030] Step S103: Obtain the jump node of the above-mentioned code syntax tree to be parsed, and determine the unique identifier of the jump target corresponding to the above-mentioned jump node. The above-mentioned jump node is a syntax node used to implement the above-mentioned module jump.
[0031] Specifically, after generating the syntax tree of the code to be parsed, each syntax node in the syntax tree is traversed to identify nodes with jump semantics. These nodes typically correspond to syntax structures in the code used to trigger page switching, module navigation, or function navigation, such as calling jump functions, triggering routing methods, or executing navigation instructions. The system matches syntax nodes using preset jump semantic rules, and when a syntax node meets the jump rules, it is identified as a jump node.
[0032] Step S104: Determine the jump link of the module based on the unique identifier of the jump target. The jump link represents the jump order relationship of the module.
[0033] Specifically, the source module containing the jump node is associated with the target module it points to, and this association is recorded in a directed manner. By parsing the unique identifiers of multiple jump nodes, the jump relationships between modules can be determined sequentially, thereby reconstructing the possible jump order of modules in the project execution flow.
[0034] Through the above embodiments, by acquiring a project to be parsed comprising multiple modules and determining the parsed file representing functional logic, the code scope that may contain jump logic in the offline package can be comprehensively covered. The abstract syntax tree parsing engine performs syntactic structuring processing on the code to be parsed, accurately identifying syntax nodes with jump semantics in the code, thereby avoiding the problem of manually searching for missed or misjudged jump statements. By extracting the unique identifier of the jump target from the jump node and recovering the jump relationship between modules based on this unique identifier, the jump link between modules can be automatically constructed, achieving accurate restoration of the jump path of the offline package. This solution can structure and link the jump information discretely distributed in the source code, enabling developers to clearly grasp the actual jump order relationship between offline packages, thereby improving project maintenance efficiency and avoiding problems such as missing, incorrect, or difficult-to-track jump relationships. It solves the problem in the prior art where the jump relationship of the front-end offline package is scattered in the source code and lacks a unified record, making it impossible to accurately grasp the actual jump link and parameter information between each offline package, leading to maintenance difficulties.
[0035] For example, the system can construct a jump link between modules based on the unique identifier of the jump target. Specifically, the system first extracts the correspondence between the source module and the target module from each jump node. For instance, when parsing the abstract syntax tree of module A, if a jump statement pointing to module B and a jump statement pointing to module C are identified, the jump relationships "A→B" and "A→C" can be recorded respectively. After obtaining the above multiple jump relationships, the system combines these directed relationships according to the calling order between modules to form a jump link between modules.
[0036] In one alternative approach, determining the file to be parsed in the aforementioned project to be parsed includes: determining the file type of each of the aforementioned source code files in the aforementioned project to be parsed; and determining the aforementioned source code file whose file type is a preset file type as the aforementioned file to be parsed.
[0037] In the above embodiments, by identifying the file types of the source code files in the project to be parsed and determining the source code files whose file types match the preset types as the files to be parsed, the scope of code analysis can be effectively narrowed, meaningless parsing operations on irrelevant files can be avoided, thereby improving the overall parsing efficiency. Specifically, since a project usually contains various types of files for building, configuration, resource management, style definition, etc., only some of these files contain script code that implements business logic or page logic, and jump semantics can only appear in such script code. By identifying the types of all source code files in the project, the system can accurately distinguish different categories such as script files, template files, style files, and resource files, and filter out code files that are truly likely to contain jump statements based on the preset set of file types, such as script file types. This not only avoids parsing files unrelated to jump analysis, such as style files, static resource files, and configuration files, thereby reducing the processing burden of the syntax analysis engine, but also reduces parsing errors or syntax construction failures caused by irrelevant files, improving the accuracy and stability of abstract syntax tree generation. Furthermore, by limiting the file type as the screening criterion for the files to be parsed, this invention can ensure that the input data for jump node identification is more concentrated and more relevant, so that subsequent jump node matching, unique identifier extraction of jump targets, and jump link construction are all based on a clear and reliable code set, thereby significantly improving the accuracy and performance of module jump relationship identification.
[0038] In another alternative, after determining the jump link of the module based on the unique identifier of the jump target, the method further includes: generating a visual jump diagram based on the jump link, wherein the visual jump diagram is a diagram of the jump relationship between the modules.
[0039] In the above embodiments, by generating a visual jump diagram based on the jump links, the present invention can intuitively display the jump relationships that were originally scattered in the source code in a graphical form, making the jump directions and relationships between modules clear at a glance. This visual jump diagram can help developers quickly understand the jump structure inside the project, facilitate the identification of missing or looping jump links, and improve the efficiency of project debugging and maintenance.
[0040] In some exemplary embodiments, obtaining the jump node of the above-mentioned code syntax tree to be parsed includes: traversing the above-mentioned code syntax tree to be parsed and obtaining the node field of each node in the above-mentioned code syntax tree to be parsed; if there is a preset jump field in the above-mentioned node field, determining the above-mentioned node as the jump node.
[0041] In the above embodiments, by traversing the syntax tree of the code to be parsed and matching preset jump fields based on node fields, the present invention can accurately locate syntax nodes with jump semantics in the structured syntax tree, thereby avoiding the misjudgment or omission problems that may occur when relying on string retrieval methods. This method can identify all potential jump statements at the syntax level, achieve accurate extraction of jump nodes, and provide a reliable data foundation for subsequent jump target identification and jump link construction.
[0042] In other exemplary embodiments, an abstract syntax tree parsing engine is used to process the code to be parsed to obtain a syntax tree of the code to be parsed, including: if the abstract syntax tree parsing engine fails to process the code to be parsed, a syntax rule engine is used to process the code to be parsed to obtain corrected code to be parsed; and the abstract syntax tree parsing engine is used to process the corrected code to be parsed to obtain the syntax tree of the code to be parsed.
[0043] In the above embodiments, by introducing a syntax rule engine to correct the code to be parsed when the abstract syntax tree (AST) parsing fails, this invention can automatically adjust abnormal code structures, non-standard code snippets, or code content that does not conform to preset syntax rules to meet the syntax requirements of the AST parsing engine. This correction process can effectively compensate for problems such as missing syntax, mismatched brackets, missing keywords, or abnormal formatting in the code, thereby preventing the parsing process from being interrupted due to syntax errors. When the code to be parsed after correction by the syntax rule engine is processed again by the AST parsing engine, a complete syntax tree structure can be successfully generated, enabling the system to continue executing subsequent steps such as jump node identification, jump target extraction, and jump link construction. Through this fault-tolerance mechanism, this invention significantly improves the success rate of syntax parsing and the stability of the overall process, and enhances its adaptability to complex projects, historical code, or non-standard code.
[0044] Specifically, the aforementioned syntax rule engine is a rule-based parsing component used for syntax-level correction and completion of source code. Based on a pre-defined set of syntax rules, the engine identifies potential syntax anomalies in the code to be parsed, including but not limited to missing parentheses, unfinished statements, missing keywords, incomplete nested structures, or non-standard formatting. It then performs automatic completion, structural adjustments, or formatting corrections according to the corresponding rules to generate corrected code that is syntactically recognizable by the abstract syntax tree parsing engine.
[0045] In some exemplary embodiments of this application, after determining the jump link of the module based on the unique identifier of the jump target, the method further includes: verifying the integrity of the jump link; if the jump link verification fails, marking the jump link as an abnormal jump link, and outputting the verification result containing the abnormal jump link to prompt for repair of the abnormal jump link.
[0046] In the above embodiments, by performing integrity checks on the generated jump links, structural problems such as missing links, broken jumps, non-existent target modules, or discontinuous paths in the module jump relationships can be detected, thereby ensuring the accuracy and availability of the jump links. If the check fails, the corresponding jump link is marked as abnormal, and a check result carrying abnormal information is output, enabling developers to promptly locate and fix abnormal jump positions. This not only improves the reliability of jump link construction but also assists developers in quickly identifying potential jump errors in large-scale projects with complex jump relationships, reducing debugging costs and improving project maintenance efficiency.
[0047] In some further exemplary embodiments of this application, after obtaining the code to be parsed in the file to be parsed, the method further includes: preprocessing the code to be parsed to delete comments from the code to be parsed.
[0048] In the above embodiments, by performing a comment removal operation on the code to be parsed before syntax parsing, the interference of comment content on syntax analysis can be effectively eliminated, preventing the abstract syntax tree parsing engine from misidentifying characters in comments as syntax elements, thus improving the accuracy and stability of syntax tree generation. Comment removal can also reduce the amount of invalid information in the code, thereby reducing the parsing burden and making subsequent jump node identification more efficient and reliable.
[0049] For example, after obtaining the code to be parsed from the file to be parsed, a preprocessing operation is performed on the code to remove comments. Specifically, the code to be parsed is first scanned line by line, and the code segment containing the comments is determined by identifying the preset format identifiers used to represent comments (such as single-line comment symbols, multi-line comment start and end symbols, etc.). For identified single-line comments, the system can directly delete the comment symbol and the entire line content following it; for identified multi-line comments, the system can delete all text from the comment start symbol to the comment end symbol. After the comment content is deleted, the system reorganizes the remaining code structure, including re-concatenating the cleaned code lines and removing blank lines or meaningless spaces caused by comment deletion, to obtain semantically complete and formatted preprocessed code. The preprocessed code does not contain any comment content that is meaningless to syntax parsing, which can significantly reduce interference factors when the abstract syntax tree parsing engine processes code, improve parsing performance and accuracy, and provide clear code input for subsequent syntax tree generation and jump node identification.
[0050] To enable those skilled in the art to better understand the technical solution of this application, the implementation process of the module jump link identification method of this application will be described in detail below with reference to specific embodiments.
[0051] This embodiment relates to a specific method for identifying module jump links, including the following steps:
[0052] Step S1: Obtain the project to be parsed and determine the file to be parsed;
[0053] The system acquires the target project and scans all source code files within it. During the scan, the system identifies the file type of each file. If the file type belongs to a preset script file type (such as code files used to implement page logic or functional logic), then that file is identified as the file to be parsed.
[0054] Step S2: Extract the code to be parsed and perform preprocessing;
[0055] The system extracts valid script code from the file to be parsed and performs preprocessing operations on the extracted code. Preprocessing includes: removing single-line and multi-line comments; cleaning up meaningless whitespace or formatting symbols; and standardizing the code structure to suit syntax parsing. The preprocessed code has clear semantics and can serve as valid input to the abstract syntax tree parsing engine.
[0056] Step S3: Generate a syntax tree based on the abstract syntax tree parsing engine;
[0057] The preprocessed code is input into the Abstract Syntax Tree (AST) parsing engine, which analyzes the code structure according to preset syntax rules and generates the corresponding syntax tree. If the parsing fails due to missing syntax, abnormal format, or incomplete structure, the syntax rule engine is invoked to correct the code, generate the corrected code, and then the AST is parsed again to ensure that a complete syntax tree structure can be generated.
[0058] Step S4: Identify the jump node from the syntax tree and extract the unique identifier of the jump target;
[0059] Traverse all nodes in the syntax tree of the code to be parsed, and extract the node fields of each node. If the node fields contain preset jump fields (such as navigation methods, jump instructions, route calls, and other key structures), then the node is determined to be a jump node. Subsequently, parse the syntax information of the jump node, extract the unique identifier used to indicate the jump target, and record the correspondence between the jump source module and the jump target module.
[0060] Step S5: Construct module jump links;
[0061] Based on the unique identifiers of the jump targets extracted from multiple jump nodes, directed jump relationships are established between modules, and module jump chains are constructed accordingly. Jump chains are used to characterize the jump order relationship between modules in the execution logic, reflecting the jump direction, jump path, and jump dependency structure between modules.
[0062] Step S6: Perform integrity verification on the jump link;
[0063] Perform integrity checks on the constructed jump links, including checking if the jump target exists, if the jump nodes are connected, and if there are structural anomalies such as breaks or loops in the link. If the check fails, the jump link is marked as an abnormal jump link, and the check result with anomaly information is output to prompt developers to fix the abnormal link.
[0064] Step S7: Generate a visual jump chart;
[0065] After constructing the jump links between modules, the system further generates a visual jump diagram to display the jump relationships between modules. Specifically, the jump relationship data generated by the parsing engine can be organized according to a preset data format to form a structured data record containing the jumper identifier, the jumpee identifier, and the jump parameter content. This structured data is then output to the data processing server in file format. After receiving the above structured data, the data processing server processes each jump record sequentially. For existing jump records, a duplicate check is performed. If the jumper identifier and the jumpee identifier are the same but the jump parameter content is different, the newly added parameter content can be recorded in a spare field to support the differentiated management of multiple parameter passing methods under the same jump path. The spare field can be stored up to a preset limit. In addition, for some target identifiers that require further transformation, a unified identifier mapping can be completed in conjunction with the server's associated data table to ensure the consistency of identifiers in the jump relationship.
[0066] After data is written to disk, the data visualization server can construct a directed graph structure between modules based on the stored jump relationship data. Each module acts as a node, and the edges between nodes represent the jump relationships between modules. The visualization server can also combine other related data tables to convert the jumper identifier and the jumpee identifier into module names or function names that are easy for business and technical personnel to understand, thereby improving the readability of the jump relationships. The front-end display interface can generate a topology view based on this directed graph structure, presenting the jump relationships between modules graphically, and supporting supplementary displays for special cases. For example, when some jump targets come from function parameter parsing, notes can be added to the graphical nodes or edges to indicate the source and parsing method of the relevant jump. In this way, the visualized jump graph can completely and accurately reflect the jump paths, jump directions, and parameter differences between modules, providing developers with a clear view of the engineering jump chain.
[0067] This application also provides a specific implementation scenario for corrective processing after syntax parsing failure. Specifically, after preprocessing the code to be parsed, the system inputs the code into an abstract syntax tree parsing engine for syntax structure analysis to generate a corresponding syntax tree. In actual engineering projects, there may be non-standard formats, unclosed structures, missing syntax symbols, residual temporary debugging comments, or non-standard code snippets generated by build tools. The abstract syntax tree parsing engine may encounter syntax errors during parsing, leading to syntax tree construction failure. To avoid interrupting the parsing process, this solution introduces a syntax rule engine to automatically correct failed parsing. Specifically, the syntax rule engine first locates the line number and syntax node where the exception occurs based on the error information returned by the abstract syntax tree parsing engine, and determines the type of error based on a preset syntax rule library, such as mismatched parentheses, incomplete object structure, unfinished statements, or the presence of unsupported characters. Subsequently, the syntax rule engine performs corresponding corrections to the code based on the error type, including automatically completing missing parentheses, deleting illegal characters, completing statement ending symbols, correcting nested structure levels, or merging unexpectedly broken statements, thereby forming corrected code that is structurally complete and conforms to syntax standards. The corrected code is then input into the abstract syntax tree parsing engine, which successfully generates the syntax tree, enabling subsequent steps such as jump node identification, jump target extraction, and module jump link construction to proceed under an effective and continuous parsing process. By introducing this fault-tolerant syntax correction rule, this invention significantly improves its adaptability to non-standard or complex engineering code, increases the success rate of syntax parsing and the stability of the overall process, and ensures that module jump relationships can be accurately identified under various engineering conditions.
[0068] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0069] This application also provides a module jump link identification device. It should be noted that the module jump link identification device of this application can be used to execute the module jump link identification method provided in this application. This device is used to implement the above embodiments and preferred embodiments, and details already described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0070] The following describes the module jump link identification device provided in the embodiments of this application.
[0071] Figure 2 This is a schematic diagram of a module jump link identification device according to an embodiment of this application. Figure 2 As shown, the device includes:
[0072] The first acquisition unit 10 is used to acquire the project to be parsed and determine the file to be parsed in the project to be parsed. The project to be parsed is a project that includes at least one module, and each module includes multiple source code files.
[0073] The second acquisition unit 20 is used to acquire the code to be parsed in the file to be parsed, and to process the code to be parsed using an abstract syntax tree parsing engine to obtain a syntax tree of the code to be parsed, wherein the syntax tree of the code to be parsed represents the syntax structure of the code to be parsed.
[0074] The third acquisition unit 30 is used to acquire the jump nodes of the above-mentioned code syntax tree to be parsed, and to determine the unique identifier of the jump target corresponding to the above-mentioned jump node. The above-mentioned jump node is a syntax node used to implement the above-mentioned module jump.
[0075] The determining unit 40 is used to determine the jump link of the module based on the unique identifier of the jump target, wherein the jump link represents the jump order relationship of the module.
[0076] In one alternative embodiment, the first acquisition unit includes: a first determining module, configured to determine the file type of each of the source code files in the project to be parsed; and a second determining module, configured to determine the source code file whose file type is a preset file type as the file to be parsed.
[0077] In another alternative embodiment, the apparatus further includes a generation unit for generating a visual jump diagram based on the jump links, wherein the visual jump diagram is a diagram of the jump relationships between the modules.
[0078] In some exemplary embodiments, the third acquisition unit includes: a traversal module, used to traverse the code syntax tree to be parsed and acquire the node fields of each node in the code syntax tree to be parsed; and a determination module, used to determine the node as the jump node if a preset jump field exists in the node field.
[0079] In other exemplary embodiments, the second acquisition unit includes: a first processing module, configured to process the code to be parsed using a syntax rule engine to obtain corrected code to be parsed when the abstract syntax tree parsing engine fails to process the code to be parsed; and a second processing module, configured to process the corrected code to be parsed using the abstract syntax tree parsing engine to obtain the syntax tree of the code to be parsed.
[0080] In some exemplary embodiments of this application, the above-mentioned device further includes: a verification module for verifying the integrity of the jump link; and a marking module for marking the jump link as an abnormal jump link when the jump link verification fails, and outputting a verification result containing the abnormal jump link to prompt the abnormal jump link to be repaired.
[0081] In some further exemplary embodiments of this application, the above-mentioned apparatus further includes: a preprocessing module, used to preprocess the code to be parsed in order to remove comments from the code to be parsed.
[0082] The aforementioned module jump link identification device includes a processor and a memory. The first acquisition unit, the second acquisition unit, the third acquisition unit, and the determination unit are all stored as program units in the memory. The processor executes the program units stored in the memory to achieve the corresponding functions. All of the aforementioned modules are located in the same processor; alternatively, the aforementioned modules may be located in different processors in any combination.
[0083] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured. By adjusting kernel parameters, at least the problem of existing technologies where front-end offline package jump relationships are scattered throughout the source code and lack unified records, making it impossible to accurately grasp the actual jump links and parameter information between offline packages, leading to maintenance difficulties, can be addressed.
[0084] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0085] This invention provides a computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device containing the computer-readable storage medium to execute the module jump link identification method.
[0086] Specifically, the methods for identifying module jump links include:
[0087] Step S101: Obtain the project to be parsed and determine the files to be parsed in the project to be parsed. The project to be parsed is a project that includes at least one module, and each module includes multiple source code files.
[0088] Specifically, a module refers to a code unit within a project used to implement a specific business function or page function, consisting of one or more source code files. A module typically corresponds to a functional page, functional component, or business logic unit within the project, containing script code, logic code, or event handling code to implement that function. Different modules can jump between each other through jump statements in their code, thus forming a cross-module jump link. A module is the basic structural unit used to carry functional logic, and its boundaries can be defined based on the project's directory structure, business division method, or component configuration in the build system. The "module jump" identified in this solution refers to the navigation behavior or function switching behavior triggered by a jump statement within the code of one module, pointing to another module. It should be noted that the source code files within a module include not only the script files written by the business itself, but also external files such as public components and third-party libraries that it depends on; both together constitute the complete logic of the module. The aforementioned project can be a single-module project or composed of multiple independent or mutually calling modules.
[0089] Step S102: Obtain the code to be parsed from the above-mentioned file to be parsed, and use the abstract syntax tree parsing engine to process the code to be parsed to obtain the syntax tree of the code to be parsed. The syntax tree of the code to be parsed represents the syntax structure of the code to be parsed.
[0090] Specifically, the aforementioned abstract syntax tree parsing engine may include a parsing module for performing file scanning and code extraction using Python scripts, and a syntax analysis module for structuring the code content into an abstract syntax tree (AST).
[0091] Step S103: Obtain the jump node of the above-mentioned code syntax tree to be parsed, and determine the unique identifier of the jump target corresponding to the above-mentioned jump node. The above-mentioned jump node is a syntax node used to implement the above-mentioned module jump.
[0092] Specifically, after generating the syntax tree of the code to be parsed, each syntax node in the syntax tree is traversed to identify nodes with jump semantics. These nodes typically correspond to syntax structures in the code used to trigger page switching, module navigation, or function navigation, such as calling jump functions, triggering routing methods, or executing navigation instructions. The system matches syntax nodes using preset jump semantic rules, and when a syntax node meets the jump rules, it is identified as a jump node.
[0093] Step S104: Determine the jump link of the module based on the unique identifier of the jump target. The jump link represents the jump order relationship of the module.
[0094] Specifically, the source module containing the jump node is associated with the target module it points to, and this association is recorded in a directed manner. By parsing the unique identifiers of multiple jump nodes, the jump relationships between modules can be determined sequentially, thereby reconstructing the possible jump order of modules in the project execution flow.
[0095] In one embodiment of this application, determining the file to be parsed in the above-mentioned project to be parsed includes: determining the file type of each of the above-mentioned source code files in the above-mentioned project to be parsed; determining the above-mentioned source code file whose file type is a preset file type as the above-mentioned file to be parsed.
[0096] In one embodiment of this application, after determining the jump link of the module based on the unique identifier of the jump target, the method further includes: generating a visual jump graph based on the jump link, wherein the visual jump graph is a graph of the jump relationship between the modules.
[0097] In one embodiment of this application, obtaining the jump node of the code syntax tree to be parsed includes: traversing the code syntax tree to be parsed and obtaining the node field of each node in the code syntax tree to be parsed; if a preset jump field exists in the node field, determining the node as the jump node.
[0098] In one embodiment of this application, an abstract syntax tree parsing engine is used to process the code to be parsed to obtain a syntax tree of the code to be parsed. This includes: if the abstract syntax tree parsing engine fails to process the code to be parsed, a syntax rule engine is used to process the code to be parsed to obtain corrected code to be parsed; and the abstract syntax tree parsing engine is used to process the corrected code to be parsed to obtain the syntax tree of the code to be parsed.
[0099] In one embodiment of this application, after determining the jump link of the module based on the unique identifier of the jump target, the method further includes: verifying the integrity of the jump link; if the jump link verification fails, marking the jump link as an abnormal jump link, and outputting the verification result containing the abnormal jump link to prompt for repair of the abnormal jump link.
[0100] In one embodiment of this application, after obtaining the code to be parsed in the file to be parsed, the method further includes: preprocessing the code to be parsed to delete comments from the code to be parsed.
[0101] This invention provides a module jump link identification system, including a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs at least the following steps:
[0102] Step S101: Obtain the project to be parsed and determine the files to be parsed in the project to be parsed. The project to be parsed is a project that includes at least one module, and each module includes multiple source code files.
[0103] Specifically, a module refers to a code unit within a project used to implement a specific business function or page function, consisting of one or more source code files. A module typically corresponds to a functional page, functional component, or business logic unit within the project, containing script code, logic code, or event handling code to implement that function. Different modules can jump between each other through jump statements in their code, thus forming a cross-module jump link. A module is the basic structural unit used to carry functional logic, and its boundaries can be defined based on the project's directory structure, business division method, or component configuration in the build system. The "module jump" identified in this solution refers to the navigation behavior or function switching behavior triggered by a jump statement within the code of one module, pointing to another module. It should be noted that the source code files within a module include not only the script files written by the business itself, but also external files such as public components and third-party libraries that it depends on; both together constitute the complete logic of the module. The aforementioned project can be a single-module project or composed of multiple independent or mutually calling modules.
[0104] Step S102: Obtain the code to be parsed from the above-mentioned file to be parsed, and use the abstract syntax tree parsing engine to process the code to be parsed to obtain the syntax tree of the code to be parsed. The syntax tree of the code to be parsed represents the syntax structure of the code to be parsed.
[0105] Specifically, the aforementioned abstract syntax tree parsing engine may include a parsing module for performing file scanning and code extraction using Python scripts, and a syntax analysis module for structuring the code content into an abstract syntax tree (AST).
[0106] Step S103: Obtain the jump node of the above-mentioned code syntax tree to be parsed, and determine the unique identifier of the jump target corresponding to the above-mentioned jump node. The above-mentioned jump node is a syntax node used to implement the above-mentioned module jump.
[0107] Specifically, after generating the syntax tree of the code to be parsed, each syntax node in the syntax tree is traversed to identify nodes with jump semantics. These nodes typically correspond to syntax structures in the code used to trigger page switching, module navigation, or function navigation, such as calling jump functions, triggering routing methods, or executing navigation instructions. The system matches syntax nodes using preset jump semantic rules, and when a syntax node meets the jump rules, it is identified as a jump node.
[0108] Step S104: Determine the jump link of the module based on the unique identifier of the jump target. The jump link represents the jump order relationship of the module.
[0109] Specifically, the source module containing the jump node is associated with the target module it points to, and this association is recorded in a directed manner. By parsing the unique identifiers of multiple jump nodes, the jump relationships between modules can be determined sequentially, thereby reconstructing the possible jump order of modules in the project execution flow.
[0110] The devices mentioned in this article can be servers, PCs, tablets, mobile phones, etc.
[0111] In one embodiment of this application, determining the file to be parsed in the above-mentioned project to be parsed includes: determining the file type of each of the above-mentioned source code files in the above-mentioned project to be parsed; determining the above-mentioned source code file whose file type is a preset file type as the above-mentioned file to be parsed.
[0112] In one embodiment of this application, after determining the jump link of the module based on the unique identifier of the jump target, the method further includes: generating a visual jump graph based on the jump link, wherein the visual jump graph is a graph of the jump relationship between the modules.
[0113] In one embodiment of this application, obtaining the jump node of the code syntax tree to be parsed includes: traversing the code syntax tree to be parsed and obtaining the node field of each node in the code syntax tree to be parsed; if a preset jump field exists in the node field, determining the node as the jump node.
[0114] In one embodiment of this application, an abstract syntax tree parsing engine is used to process the code to be parsed to obtain a syntax tree of the code to be parsed. This includes: if the abstract syntax tree parsing engine fails to process the code to be parsed, a syntax rule engine is used to process the code to be parsed to obtain corrected code to be parsed; and the abstract syntax tree parsing engine is used to process the corrected code to be parsed to obtain the syntax tree of the code to be parsed.
[0115] In one embodiment of this application, after determining the jump link of the module based on the unique identifier of the jump target, the method further includes: verifying the integrity of the jump link; if the jump link verification fails, marking the jump link as an abnormal jump link, and outputting the verification result containing the abnormal jump link to prompt for repair of the abnormal jump link.
[0116] In one embodiment of this application, after obtaining the code to be parsed in the file to be parsed, the method further includes: preprocessing the code to be parsed to delete comments from the code to be parsed.
[0117] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0118] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0119] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0120] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0121] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0122] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0123] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0124] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0125] 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 specification.
[0126] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0127] As can be seen from the above description, the embodiments of this application achieve the following technical effects:
[0128] This application's method for identifying module jump links comprehensively covers the code range in offline packages that may contain jump logic by acquiring a project containing multiple modules and identifying the files representing functional logic. It employs an abstract syntax tree parsing engine to perform syntactic structuring on the code, accurately identifying syntax nodes with jump semantics and avoiding the problems of missed or misjudged jump statements during manual searching. By extracting the unique identifier of the jump target from the jump node and recovering the jump relationship between modules based on this unique identifier, the jump link between modules can be automatically constructed, achieving accurate restoration of the jump path in the offline package. This solution can structure and link jump information distributed discretely in the source code, enabling developers to clearly understand the actual jump order relationship between offline packages, thereby improving project maintenance efficiency and avoiding problems such as missing, incorrect, or difficult-to-track jump relationships. It solves the problem in existing technologies where front-end offline package jump relationships are scattered throughout the source code and lack unified records, making it difficult to accurately grasp the actual jump link and parameter information between offline packages, leading to maintenance difficulties.
[0129] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for identifying module jump links, characterized in that, include: Obtain the project to be parsed and determine the files to be parsed in the project to be parsed. The project to be parsed is a project that includes at least one module, and each module includes multiple source code files. The code to be parsed in the file to be parsed is obtained, and the code to be parsed is processed by an abstract syntax tree parsing engine to obtain a syntax tree of the code to be parsed, wherein the syntax tree of the code to be parsed represents the syntax structure of the code to be parsed. Obtain the jump node of the syntax tree to be parsed, and determine the unique identifier of the jump target corresponding to the jump node. The jump node is a syntax node used to implement the module jump. The jump link of the module is determined based on the unique identifier of the jump target, and the jump link represents the jump order relationship of the module.
2. The method according to claim 1, characterized in that, Determining the files to be parsed in the project to be parsed includes: Determine the file type of each source code file in the project to be parsed; The source code file whose file type is a preset file type is identified as the file to be parsed.
3. The method according to claim 1, characterized in that, After determining the jump link of the module based on the unique identifier of the jump target, the method further includes: A visual jump diagram is generated based on the jump links, and the visual jump diagram is a diagram of the jump relationships between the modules.
4. The method according to claim 1, characterized in that, Obtaining the jump nodes of the syntax tree to be parsed includes: Traverse the code syntax tree to be parsed and obtain the node fields of each node in the code syntax tree to be parsed; If a preset jump field exists in the node field, the node is determined to be the jump node.
5. The method according to claim 1, characterized in that, The code to be parsed is processed using an abstract syntax tree parsing engine to obtain a syntax tree of the code to be parsed, including: If the abstract syntax tree parsing engine fails to process the code to be parsed, the syntax rule engine is used to process the code to be parsed to obtain corrected code. The abstract syntax tree parsing engine is used to process the corrected code to be parsed, and the syntax tree of the code to be parsed is obtained.
6. The method according to claim 1, characterized in that, After determining the jump link of the module based on the unique identifier of the jump target, the method further includes: Verify the integrity of the jump link; If the jump link verification fails, the jump link is marked as an abnormal jump link, and the verification result containing the abnormal jump link is output to prompt the abnormal jump link to be repaired.
7. The method according to claim 1, characterized in that, After obtaining the code to be parsed from the file to be parsed, the method further includes: The code to be parsed is preprocessed to remove comments from the code.
8. A device for identifying module jump links, characterized in that, include: The first acquisition unit is used to acquire the project to be parsed and determine the files to be parsed in the project to be parsed. The project to be parsed is a project that includes at least one module, and each module includes multiple source code files. The second acquisition unit is used to acquire the code to be parsed in the file to be parsed, and to process the code to be parsed using an abstract syntax tree parsing engine to obtain a syntax tree of the code to be parsed, wherein the syntax tree of the code to be parsed represents the syntactic structure of the code to be parsed. The third acquisition unit is used to acquire the jump nodes of the syntax tree to be parsed and determine the unique identifier of the jump target corresponding to the jump node, wherein the jump node is a syntax node used to implement the module jump; A determining unit is configured to determine the jump link of the module based on the unique identifier of the jump target, wherein the jump link represents the jump order relationship of the module.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the method according to any one of claims 1 to 7.
10. A system for identifying module jump links, characterized in that, include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs comprising methods for performing any one of claims 1 to 7.