Method and device for generating call chain of front-end and back-end codes, and storage medium
By using multi-threaded parallel parsing and correlation to generate front-end and back-end code call chains, the problem of low efficiency in existing technologies is solved, achieving efficient and accurate call chain generation, thus improving system performance and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING UFC CO LTD
- Filing Date
- 2026-01-27
- Publication Date
- 2026-05-29
AI Technical Summary
In existing technologies, the generation efficiency of front-end and back-end code call chains is low, relying on manual analysis and operation, which is time-consuming.
By receiving the code directory of the target project, the front-end and back-end code files are parsed in parallel using a multi-threaded approach using the target model to generate call chain association results. These results are then associated based on service names, and finally, a call chain is generated through mind map rendering.
It improves the efficiency and accuracy of generating front-end and back-end code call chains, reduces manual intervention, and enhances system performance optimization and user experience.
Smart Images

Figure CN122111537A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence, and more specifically, to a method, apparatus, and storage medium for generating call chains of front-end and back-end code. Background Technology
[0002] In software development, the front-end is responsible for building and interacting with the user interface, while the back-end handles business logic and data management. In this architecture, analyzing the front-end and back-end code call chain is crucial for understanding and optimizing system performance. The front-end and back-end code call chain refers to the series of calls that occur when a user interacts with the front-end page: how the front-end code triggers back-end services, and how the back-end services respond and affect the front-end display. Accurately understanding the call chain helps to quickly locate problems, optimize system response speed, and improve user experience.
[0003] However, in existing technologies, the generation of call chain scripts typically involves manually analyzing source code, outlining call chain logic, and drawing call chain diagrams. Alternatively, it requires manual intervention on the front-end page to trigger front-end and back-end interactions, and the use of developer tools to capture back-end service response logs. Both of these methods rely on manual analysis or operation, resulting in a large workload and high time consumption in generating call chains for both front-end and back-end code.
[0004] There is currently no effective solution to the problem of low efficiency in generating front-end and back-end code call chains in related technologies. Summary of the Invention
[0005] The main objective of this application is to provide a method, apparatus, and storage medium for generating call chains of front-end and back-end code, so as to solve the problem of low efficiency in generating call chains of front-end and back-end code in related technologies.
[0006] To achieve the above objectives, according to one aspect of this application, a method for generating a call chain between front-end and back-end code is provided. The method includes: receiving a code directory corresponding to a target project from which a call chain is to be generated, and extracting front-end code files and back-end code files from the code directory, wherein the front-end code files include a webpage structure file and a front-end logic file; performing multi-threaded parallel parsing on the webpage structure file, the front-end logic file, and the back-end code file using a target model to obtain a webpage structure parsing result corresponding to the webpage structure file, a front-end logic parsing result corresponding to the front-end logic file, and a back-end code parsing result corresponding to the back-end code file; determining front-end interface call information based on the webpage structure parsing result and the front-end logic parsing result; associating the front-end interface call information with the back-end code parsing result based on the service name to obtain a call chain association result, and rendering a mind map based on the call chain association result to obtain the front-end and back-end code call chain.
[0007] Furthermore, the target model is used to perform multi-threaded parallel parsing of the webpage structure file, front-end logic file, and back-end code file to obtain the webpage structure parsing result corresponding to the webpage structure file, the front-end logic parsing result corresponding to the front-end logic file, and the back-end code parsing result corresponding to the back-end code file. This includes: determining the first input data based on the first prompt word and the webpage structure file; determining the second input data based on the second prompt word and the front-end logic file; determining the third input data based on the third prompt word and the back-end code file; determining the multi-threaded executor and creating a concurrent processing environment based on the multi-threaded executor; and calling the target model's program interface in the concurrent processing environment based on the first input data, the second input data, and the third input data to obtain the webpage structure parsing result corresponding to the first input data, the front-end logic parsing result corresponding to the second input data, and the back-end code parsing result corresponding to the third input data.
[0008] Furthermore, determining the front-end interface call information based on the webpage structure parsing results and the front-end logic parsing results includes: creating a call chain object based on the webpage structure parsing results, and encapsulating multiple program interface lists in the call chain object. Each program interface list stores the first type of interface information from the webpage structure parsing results, along with the corresponding filename, front-end code summary, and front-end programming reference information. Based on the front-end programming reference information, the program interface call items from the front-end logic parsing results are merged into the program interface list to obtain a merged program interface list. The program interface call items include the second type of interface information and the corresponding front-end function name and service name. The front-end interface call information is determined based on the merged program interface list.
[0009] Furthermore, the call chain association result is obtained by associating the front-end interface call information with the back-end code parsing result based on the service name. This includes: generating a back-end service mapping table based on the back-end code parsing result, where the back-end service mapping table stores the hash mapping relationship between the storage name and the back-end implementation information, and the back-end implementation information includes the back-end file path, back-end code summary, back-end function definition, and back-end service description; traversing the back-end service mapping table based on the front-end interface call information to obtain the target back-end information, where the target back-end information is the back-end implementation information in the back-end service mapping table that has the same service name as the front-end interface call information; and adding the target back-end information to the program interface list in the call chain object to obtain the call chain association result.
[0010] Furthermore, after rendering a mind map based on the call chain association results to obtain the front-end and back-end code call chain, the method also includes: obtaining the development documentation of the target project and extracting code chain information based on the front-end and back-end code call chain; inputting the development documentation and code chain information into the code chain verification model and outputting the verification result based on the code chain verification model, wherein the code chain verification model is used to verify the front-end and back-end code call chain based on the development documentation.
[0011] Furthermore, the code chain verification model includes a statement segmentation module, an encoder, a statement-level feature extraction module, a feature vector order rearrangement module, a decoder, and a classifier. The verification results output by the code chain verification model include: determining multiple first statements corresponding to the code chain information based on the statement segmentation module, and determining multiple second statements corresponding to the development documentation based on the statement segmentation module; inputting the code chain information and development documentation into the encoder, and using the encoder to output a feature tensor, wherein the feature tensor includes multiple feature vectors arranged in order; extracting the first statement-level tensor corresponding to each first statement based on the multiple feature vectors, and extracting the first statement-level tensor corresponding to each second statement based on the multiple feature vectors. The second sentence-level tensor is used; mean pooling is performed on each first sentence-level tensor and each second sentence-level tensor using the sentence-level feature extraction module to obtain multiple first sentence-level features and multiple second sentence-level features. The sentence alignment matrix is determined based on the feature similarity between the first sentence-level features and the second sentence-level features; the feature vector order rearrangement module rearranges the feature vector order in the feature tensor based on the sentence alignment matrix to obtain rearranged tensors, wherein each pair of corresponding first sentence-level tensors and second sentence-level tensors in the rearranged tensors are arranged adjacently; the rearranged tensors are sequentially input into the decoder to obtain global features, and the global features are input into the classifier to obtain the verification results.
[0012] To achieve the above objectives, according to another aspect of this application, a device for generating a call chain for front-end and back-end code is provided. The device includes: a file extraction unit, configured to receive a code directory corresponding to a target project from which a call chain is to be generated, and extract front-end code files and back-end code files from the code directory, wherein the front-end code files include a webpage structure file and a front-end logic file; a file parsing unit, configured to perform multi-threaded parallel parsing of the webpage structure file, the front-end logic file, and the back-end code file using a target model, to obtain a webpage structure parsing result corresponding to the webpage structure file, a front-end logic parsing result corresponding to the front-end logic file, and a back-end code parsing result corresponding to the back-end code file; an information determination unit, configured to determine front-end interface call information based on the webpage structure parsing result and the front-end logic parsing result; and an association generation unit, configured to associate the front-end interface call information with the back-end code parsing result based on a service name, to obtain a call chain association result, and to perform mind map rendering based on the call chain association result to obtain the front-end and back-end code call chain.
[0013] Furthermore, the file parsing unit includes: a data determination module, used to determine first input data based on a first prompt word and a webpage structure file, second input data based on a second prompt word and a front-end logic file, and third input data based on a third prompt word and a back-end code file; an environment creation module, used to determine a multi-threaded executor and create a concurrent processing environment based on the multi-threaded executor; and a parsing result module, used to call the program interface of the target model in the concurrent processing environment based on the first input data, the second input data, and the third input data to obtain the webpage structure parsing result corresponding to the first input data, the front-end logic parsing result corresponding to the second input data, and the back-end code parsing result corresponding to the third input data.
[0014] Furthermore, the information determination unit includes: a call chain object creation module, used to create a call chain object based on the webpage structure parsing result, and encapsulate multiple program interface lists in the call chain object, wherein each program interface list stores the first type of interface information in the webpage structure parsing result and the corresponding file name, front-end code summary, and front-end programming reference information; a call item merging module, used to merge the program interface call items in the front-end logic parsing result into the program interface list based on the front-end programming reference information, to obtain a merged program interface list, wherein the program interface call items include the second type of interface information and the corresponding front-end function name and service name; and a front-end interface call information determination module, used to determine the front-end interface call information based on the merged program interface list.
[0015] Furthermore, the association generation unit includes: a mapping table generation module, used to generate a backend service mapping table based on the backend code parsing results, wherein the backend service mapping table stores the hash mapping relationship between the storage name and the backend implementation information, and the backend implementation information includes the backend file path, backend code summary, backend function definition, and backend service description; a backend implementation information determination module, used to traverse the backend service mapping table based on the frontend interface call information to obtain the target backend information, wherein the target backend information is the backend implementation information in the backend service mapping table that has the same service name as the frontend interface call information; and an information adding module, used to add the target backend information to the program interface list in the call chain object to obtain the call chain association result.
[0016] Furthermore, the device also includes: a document acquisition unit, used to obtain the development document of the target project after rendering a mind map based on the call chain association result and obtaining the front-end and back-end code call chain, and extracting code chain information based on the front-end and back-end code call chain; and a call chain verification unit, used to input the development document and code chain information into the code chain verification model, and output the verification result based on the code chain verification model, wherein the code chain verification model is used to verify the front-end and back-end code call chain based on the development document.
[0017] Furthermore, the code chain verification model includes a statement segmentation module, an encoder, a statement-level feature extraction module, a feature vector order rearrangement module, a decoder, and a classifier. The call chain verification unit includes: an information extraction module, used to determine multiple first statements corresponding to the code chain information based on the statement segmentation module, and to determine multiple second statements corresponding to the development documentation based on the statement segmentation module; a feature tensor extraction module, used to input the code chain information and development documentation into the encoder, and use the encoder to output a feature tensor, wherein the feature tensor includes multiple feature vectors arranged in order; and a statement-level tensor extraction module, used to extract the first statement-level tensor corresponding to each first statement based on the multiple feature vectors, and to extract the first statement-level tensor corresponding to each second statement based on the multiple feature vectors. The second sentence-level tensor; the alignment matrix determination module, which uses the sentence-level feature extraction module to perform mean pooling on each first sentence-level tensor and each second sentence-level tensor to obtain multiple first sentence-level features and multiple second sentence-level features, and determines the sentence alignment matrix based on the feature similarity between the first sentence-level features and the second sentence-level features; the rearrangement module, which rearranges the feature vector order in the feature tensor based on the sentence alignment matrix, to obtain a rearranged tensor, wherein each pair of corresponding first sentence-level tensors and second sentence-level tensors in the rearranged tensor are arranged adjacently; the result output module, which inputs the rearranged tensors sequentially into the decoder to obtain global features, and inputs the global features into the classifier to obtain the verification result.
[0018] 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 running, it controls the device where the computer-readable storage medium is located to execute any kind of front-end and back-end code call chain generation method.
[0019] According to another aspect of this application, an electronic device 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 a call chain generation method for executing any kind of front-end and back-end code.
[0020] According to another aspect of this application, a computer program product is provided, including computer instructions, wherein when the computer instructions are executed by a processor, the steps of a call chain generation method for front-end and back-end code implementing any of the above are provided.
[0021] In this embodiment, the code directory corresponding to the target project from which the call chain is to be generated is received, and front-end code files and back-end code files are extracted from the code directory. The front-end code files include web page structure files and front-end logic files. The target model is used to perform multi-threaded parallel parsing on the web page structure files, front-end logic files, and back-end code files to obtain the web page structure parsing result corresponding to the web page structure file, the front-end logic parsing result corresponding to the front-end logic file, and the back-end code parsing result corresponding to the back-end code file. The front-end interface call information is determined based on the web page structure parsing result and the front-end logic parsing result. The front-end interface call information is associated with the back-end code parsing result based on the service name to obtain the call chain association result. The mind map is rendered based on the call chain association result to obtain the front-end and back-end code call chain. This solves the technical problem of low generation efficiency of front-end and back-end code call chains in the prior art. Attached Figure Description
[0022] 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:
[0023] Figure 1 A hardware structure block diagram of a computer terminal for implementing a method for generating call chains for front-end and back-end code is shown.
[0024] Figure 2 This is a flowchart of a method for generating a call chain for front-end and back-end code according to an embodiment of this application;
[0025] Figure 3 This is a network architecture diagram of the code chain verification model in the method for generating call chains of front-end and back-end code according to the embodiments of this application;
[0026] Figure 4 This is a schematic diagram of a call chain generation device for front-end and back-end code provided in the embodiments of this application;
[0027] Figure 5 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0028] 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.
[0029] 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 so that the embodiments of this application described herein can be implemented in orders other than those illustrated or 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.
[0030] It should be noted that the information collected in this application (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) are information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of this data all comply with relevant laws, regulations, and standards, necessary confidentiality measures have been taken, and they do not violate public order and good morals. Corresponding access points are provided for users to choose to authorize or refuse. For example, interfaces are set up between this system and relevant users or organizations, providing users with corresponding access points to choose to agree to or refuse automated decision-making results; if the user chooses to refuse, the process proceeds to the expert decision-making stage.
[0031] Example 1
[0032] According to an embodiment of this application, a method embodiment for generating a call chain of front-end and back-end code is also provided. 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. 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.
[0033] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1A hardware structure block diagram of a computer terminal (or mobile device) for implementing a call chain generation method for front-end and back-end code is shown. Figure 1 As shown, the computer terminal 10 (or mobile device) may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0034] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0035] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the front-end and back-end code call chain generation method in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the aforementioned front-end and back-end code call chain generation method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0036] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0037] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or mobile device).
[0038] Under the aforementioned operating environment, this application provides the following: Figure 2 The method for generating the call chain of the front-end and back-end code is shown. Figure 2 This is a flowchart of the method for generating the call chain of the front-end and back-end code according to Embodiment 1 of this application.
[0039] Step S201: Receive the code directory corresponding to the target project for which the call chain is to be generated, and extract the front-end code file and back-end code file from the code directory.
[0040] Optionally, the system can receive the code directory corresponding to the target project for which the call chain to be generated, uploaded by the developer via a program interface. It then systematically scans all subdirectories and files starting from the root directory of the code directory using a depth-first recursive traversal algorithm. For example, during traversal, the `os.walk()` function can be used to obtain the complete path of each file; `os.path.normpath()` can be used to standardize the paths to ensure cross-platform compatibility; and the currently scanned directory can be dynamically tracked to provide a basis for the exclusion mechanism. During traversal, exclusion filtering can also be performed in the following ways: for example, target directories to be excluded can be read from a configuration file, and path prefix matching can be used to immediately terminate the traversal of the corresponding branch in the current directory if the current directory begins with any target directory. Furthermore, the system can precisely filter code files based on file extensions; for example, backend code files must have the extension `.java`, and frontend code files must have the extension `.html` or `.js`.
[0041] It should be noted that front-end code files include webpage structure files and front-end logic files. Webpage structure files are also known as HTML files, and front-end logic files are also known as JS files. There can be multiple webpage structure files, front-end logic files, and back-end code files.
[0042] Step S202: Use the target model to perform multi-threaded parallel parsing of the web page structure file, front-end logic file, and back-end code file to obtain the web page structure parsing result corresponding to the web page structure file, the front-end logic parsing result corresponding to the front-end logic file, and the back-end code parsing result corresponding to the back-end code file.
[0043] Optionally, the target model can be a large language model. Code parsing hints can be pre-stored in a configuration file. These hints include parsing requirements and output format specifications to ensure structural consistency of the target model's output. The output format specification can specify JSON format for outputting the parsed results. The code parsing hints and the parsed objects (i.e., webpage structure files, front-end logic files, or back-end code files) can be integrated to obtain the input data for the target model. The target model is then used to obtain the output results, which include the webpage structure parsing results for the webpage structure files, the front-end logic parsing results for the front-end logic files, and the back-end code parsing results for the back-end code files. The code parsing hints can use placeholders, supporting dynamic replacement of specific code content and filename parameters.
[0044] Step S203: Determine the front-end interface call information based on the webpage structure parsing results and the front-end logic parsing results.
[0045] Optionally, the webpage structure parsing result includes multiple webpage structure parsing sub-results, each corresponding to a webpage structure file or front-end logic file. Before implementing step S203, the webpage structure parsing result can be filtered to remove webpage structure parsing sub-results without API (i.e., program interface) calls, retaining only those containing API calls. Front-end webpage structure API call information can be extracted based on the webpage structure parsing result. This information includes the first type of interface information in the webpage structure parsing result, along with the corresponding filename, front-end code summary, and front-end programming reference information. Furthermore, program interface call items can be extracted from the front-end logic parsing result. These program interface call items include the second type of interface information and the corresponding front-end function name and service name. Front-end interface call information is determined based on the front-end webpage structure API call information and program interface call items. This information is used to characterize the API call information in the front-end code.
[0046] Step S204: Associate the front-end interface call information with the back-end code parsing results based on the service name to obtain the call chain association result, and render a mind map based on the call chain association result to obtain the front-end and back-end code call chain.
[0047] Optionally, the backend implementation information and the corresponding service name can be determined based on the backend code parsing results. The backend implementation information includes the backend file path, backend code summary, backend function definition, and backend service description. Using the service name as an index, frontend interface call information and backend implementation information belonging to the same service name are associated to obtain the call chain association result. The call chain association result can be displayed using mind mapping, resulting in the frontend and backend code call chain. A portion of the frontend and backend code call chain can be shown below:
[0048] Front-end and back-end code call chain - mind map
[0049] ## .\codesource\web-master\src\main\webapp\pc\pages\ai_assistant\aippt\aippt.html
[0050] ### file name
[0051] - .\codesource\web-master\src\main\webapp\pc\pages\ai_assistant\aippt\aippt.html
[0052] ### Code Analysis Summary
[0053] This is an AI PPT assistant page that offers two PPT generation methods: theme generation and document generation. Users can choose to input a theme or upload a document, and the system uses AI to generate a PPT outline and content. The page includes recommended themes, a user input box, and file upload functionality, supporting real-time interactive dialogue. It calls multiple API services for file upload, parsing, and large-scale model dialogue, ultimately generating an editable PPT outline and redirecting the user to a template selection page.
[0054] ### Referencing JS files
[0055] - .. / .. / .. / .. / common / js / commen.js
[0056] - .. / .. / .. / .. / resource / js / layui / dist / layui.js
[0057] - .. / .. / .. / .. / resource / js / jquery / jquery.min.js
[0058] ### API Services
[0059] #### assistant.promptQuery: / / service / assistant / promptQuery
[0060] - Java file name: .\codesource\src\main\java\assistant\service\AssistantServiceAP.java
[0061] - Function name: promptTemplate
[0062] - REST service name: / service / assistant / promptQuery
[0063] - Service Description: Prompt Keyword Search
[0064] #### assistant.submit: / / service / assistant / chat / completions
[0065] #### assistant.save: / / service / assistant / updateSava
[0066] - Java file name: .\codesource\src\main\java\assistant\service\AssistantServiceAP.java
[0067] - Function name: updateSava
[0068] - REST service name: / service / assistant / updateSava
[0069] Service Description: Editing PPT outline
[0070] #### assistant.storageprompt: / / service / assistant / contentSave
[0071] - Java file name: .\codesource\src\main\java\assistant\service\AssistantServiceAP.java
[0072] - Function name: contentSave
[0073] - REST service name: / service / assistant / contentSave
[0074] - Service Description: PPT Outline Saving
[0075] In summary, by extracting front-end and back-end code files and using the target model to obtain webpage structure parsing results, front-end logic parsing results, and back-end code parsing results, and then associating front-end interface call information with back-end code parsing results through service names, the efficiency of generating front-end and back-end code call chains is improved.
[0076] To improve the efficiency of generating front-end and back-end code call chains, optionally, the target model is used to perform multi-threaded parallel parsing of the webpage structure file, front-end logic file, and back-end code file to obtain the webpage structure parsing result corresponding to the webpage structure file, the front-end logic parsing result corresponding to the front-end logic file, and the back-end code parsing result corresponding to the back-end code file. This includes: determining the first input data based on the first prompt word and the webpage structure file; determining the second input data based on the second prompt word and the front-end logic file; determining the third input data based on the third prompt word and the back-end code file; determining a multi-threaded executor and creating a concurrent processing environment based on the multi-threaded executor; and calling the target model's program interface in the concurrent processing environment based on the first input data, the second input data, and the third input data to obtain the webpage structure parsing result corresponding to the first input data, the front-end logic parsing result corresponding to the second input data, and the back-end code parsing result corresponding to the third input data.
[0077] Optionally, the code parsing prompt words can be of three types: a first prompt word, a second prompt word, and a third prompt word. Depending on the object being parsed, the input data for the target model can be the first input data, the second input data, or the third input data. The first input data is determined by concatenating the first prompt word with the webpage structure file; the second input data is determined by concatenating the second prompt word with the frontend logic file; and the third input data is determined by concatenating the third prompt word with the backend code file. The first prompt word could be something like: "You are a frontend HTML code analysis expert. Analyze the input code according to the following requirements:"
[0078] 1. Code Analysis Requirements - Code Interpretation Requirements: Interpret the HTML code logic, generate a code interpretation summary, and describe the page's interaction flow and the names of the API services called in no more than 300 words. Note that the specific API service names must be output. JS File Analysis Requirements: Analyze all JS files referenced in the HTML code and output the JS file names. API Service Analysis Requirements: Analyze all RESTful API services called in the HTML code, and output the JS function names and the RESTful API service names called by the JS functions. Note that only the JS function names and RESTful API service names should be output; no additional descriptions are required.
[0079] 2. Output Requirements - Output in JSON format, strictly following the example format below: {'filename':'filename','summary':'code interpretation','jslist':['.. / resource / js / finedo.config.js'],'apilist':[{'func':'examin.latest','api':' / examin / querylatest'}]}. The meanings of the JSON attributes are as follows: filename: the filename of the code file (note the path); summary: a summary of the code interpretation; jslist: a list of referenced JS filenames; apilist: a list of RESTful API service names called; func: the name of the JS function that calls the RESTful API service; api: the RESTful API service name.
[0080] 3. Input file name: {filename}, code as follows: {code_content}.
[0081] It should be noted that the output format requirements and the input file name format for the second and third prompt words can be the same as those for the first prompt word.
[0082] The code analysis requirements for the second prompt word can be as follows:
[0083] You are a front-end JavaScript code analysis expert. Analyze the input code according to the following requirements: 1. Code Analysis Requirements - Code Interpretation Requirements: Interpret the JavaScript code logic, generate a code interpretation summary, and describe the JavaScript code logic in no more than 300 words, as well as the names of the API services called. Note that you must output the specific API service names. 2. JS File Analysis Requirements: Analyze all JS files referenced in the JavaScript code and output the JS file names. 3. API Service Analysis Requirements: Analyze all RESTful API services called in the JavaScript code, and output the JavaScript function name and the RESTful API service name called by the JS function. Note that you only need to output the JavaScript function name and the RESTful API service name; no additional description is required.
[0084] The code analysis requirements for third-party prompt words can be as follows:
[0085] You are a backend Java code analysis expert. Analyze the input code according to the following requirements:
[0086] 1. Code analysis requirements.
[0087] Code Interpretation Requirements: Analyze the Java code logic, generate a code interpretation summary, and describe the Java code logic and exposed RESTful APIs in no more than 300 words. Note that the specific API service names must be output. RESTful API Analysis Requirements: Analyze all defined RESTful API services in the Java code, and output the Java function names, RESTful API service names, and service descriptions.
[0088] Optionally, a multi-threaded executor can be constructed, and a concurrent processing environment can be created based on the multi-threaded executor. In this concurrent processing environment, a producer-consumer pattern is adopted, with code files serving as production tasks and large model analysis as consumption processing. A task distribution mechanism is implemented to evenly distribute different code files across various threads. During the process of calling the target model's program interface to obtain the corresponding parsing results, a code segmentation inference mechanism can also be used to process the input data to address the issue of some code files exceeding the maximum term limit for large model inference.
[0089] In summary, by calling the program interface of the target model in a concurrent processing environment, the results of web page structure parsing, front-end logic parsing, and back-end code parsing were obtained, achieving efficient parsing of front-end and back-end code and improving the generation efficiency of front-end and back-end code call chains.
[0090] To improve the efficiency of generating front-end and back-end code call chains, optionally, determining the front-end interface call information based on the webpage structure parsing result and the front-end logic parsing result includes: creating a call chain object based on the webpage structure parsing result, and encapsulating multiple program interface lists in the call chain object. Each program interface list stores the first type of interface information from the webpage structure parsing result, along with the corresponding filename, front-end code summary, and front-end programming reference information. Based on the front-end programming reference information, the program interface call items from the front-end logic parsing result are merged into the program interface list to obtain a merged program interface list. The program interface call items include the second type of interface information and the corresponding front-end function name and service name. The front-end interface call information is determined based on the merged program interface list.
[0091] Optionally, a call chain can be initialized based on the webpage structure parsing results. This involves creating a call chain object to encapsulate the front-end webpage structure API call information related to each webpage structure file. For example, multiple program interface lists can be encapsulated in the call chain object. These program interface lists store the first type of interface information from the webpage structure parsing results, along with the corresponding filename, front-end code summary, and front-end programming reference information (i.e., the referenced JS filenames). The target JS filename can be extracted from the front-end programming reference information, and all front-end logic parsing results can be traversed to obtain front-end logic parsing results containing the target JS filename. Program interface call items (e.g., JS function names, API service names) can be extracted from these results, and the program interface call items from the front-end logic parsing results can be merged into the program interface list to obtain the merged program interface list. This merged program interface list is then identified as the front-end interface call information, which represents the API call information in the front-end code.
[0092] In summary, by determining the front-end interface call information based on the webpage structure parsing results and the front-end logic parsing results, the API call information in the front-end code was extracted, laying the foundation for subsequent association and improving the efficiency of generating front-end and back-end code call chains.
[0093] To improve the efficiency of generating front-end and back-end code call chains, optionally, the front-end interface call information and back-end code parsing results are associated based on the service name to obtain the call chain association result. This includes: generating a back-end service mapping table based on the back-end code parsing result, wherein the back-end service mapping table stores the hash mapping relationship between the storage name and the back-end implementation information, and the back-end implementation information includes the back-end file path, back-end code summary, back-end function definition, and back-end service description; traversing the back-end service mapping table based on the front-end interface call information to obtain the target back-end information, wherein the target back-end information is the back-end implementation information in the back-end service mapping table that has the same service name as the front-end interface call information; and adding the target back-end information to the program interface list in the call chain object to obtain the call chain association result.
[0094] Optionally, an empty hash map can be created, and the service name (i.e., the RESTful API service name) and backend implementation information corresponding to each backend code parsing result can be obtained. The service name and backend implementation information are inserted into the hash map as key-value pairs to obtain the backend service map. Multiple service names can be determined based on the frontend interface call information, and the backend service map can be traversed according to each service name to achieve a search with O(1) complexity, thereby obtaining the target backend information. The target backend information is the backend implementation information in the backend service map that has the same service name as the frontend interface call information. The target backend information is added to the program interface list in the call chain object according to the service name as the index, and the added program interface list is determined as the call chain association result.
[0095] In summary, by obtaining the backend service mapping table and traversing it based on the frontend interface call information to obtain the target backend information, and adding the target backend information to the program interface list in the call chain object, the call chain association result is obtained, which improves the accuracy of generating the frontend and backend code call chain.
[0096] To improve the accuracy of generating front-end and back-end code call chains, optionally, after rendering a mind map based on the call chain association results to obtain the front-end and back-end code call chains, the method further includes: obtaining the development documentation of the target project and extracting code chain information based on the front-end and back-end code call chains; inputting the development documentation and code chain information into a code chain verification model and outputting verification results based on the code chain verification model, wherein the code chain verification model is used to verify the front-end and back-end code call chains based on the development documentation.
[0097] For example, the development documentation for the target project can be supporting documents such as system architecture specifications and interface deployment specifications. The development documentation represents the functional information of all code implementations in the target project. It can include multiple functional requirements and the corresponding code logic and interface descriptions for each requirement. The code chain information can be obtained by traversing the mind map according to the front-end and back-end code call chains, using all call chain paths from front-end to back-end as code chain information. This code chain information includes multiple code chain sub-information, each corresponding to a complete call chain path in the mind map. The development documentation can be used as the target to verify the accuracy of the code chain information. The development documentation and code chain information can be input into a code chain verification model, which outputs the verification result. The verification result can be a match or a non-match. If the verification result is a non-match, steps 202-204 can be repeated to generate a new front-end and back-end code call chain, or the existing front-end and back-end code call chain can be sent to the target server for manual review and modification to generate a new front-end and back-end code call chain.
[0098] In summary, by obtaining the development documentation and utilizing the code chain verification model and the development documentation, the accuracy of generating front-end and back-end code call chains was improved.
[0099] To improve the accuracy of the code chain verification model, optionally, the code chain verification model includes a statement segmentation module, an encoder, a statement-level feature extraction module, a feature vector order rearrangement module, a decoder, and a classifier. The verification results output by the code chain verification model include: determining multiple first statements corresponding to the code chain information based on the statement segmentation module; determining multiple second statements corresponding to the development documentation based on the statement segmentation module; inputting the code chain information and development documentation into the encoder, and using the encoder to output a feature tensor, wherein the feature tensor includes multiple feature vectors arranged in order; extracting the first statement-level tensor corresponding to each first statement based on the multiple feature vectors, and extracting... The second sentence corresponds to a second sentence-level tensor. The sentence-level feature extraction module performs mean pooling on each first sentence-level tensor and each second sentence-level tensor to obtain multiple first sentence-level features and multiple second sentence-level features. The sentence alignment matrix is determined based on the feature similarity between the first and second sentence-level features. The feature vector order rearrangement module rearranges the feature vectors in the feature tensor based on the sentence alignment matrix to obtain rearranged tensors. In the rearranged tensors, each pair of corresponding first and second sentence-level tensors is arranged adjacently. The rearranged tensors are sequentially input into the decoder to obtain global features, and the global features are input into the classifier to obtain the verification results.
[0100] Optionally, Figure 3This is a network architecture diagram of the code chain verification model in the method for generating call chains of front-end and back-end code according to embodiments of this application. The code chain information includes multiple code chain sub-information, each corresponding to a complete call chain path in the mind map. During the extraction of code chain information based on the front-end and back-end code call chains, different code chain sub-information can be connected using a first separator (e.g., ...). The code chain information can be segmented according to the first delimiter by the statement segmentation module to obtain multiple first statements (e.g., multiple first statements can be a1, a2, ..., am, each first statement corresponds to a code chain sub-information). The development document can be segmented according to preset level headings (e.g., it can be a level 3 paragraph heading, such as 3.1.1) by the statement segmentation module to obtain multiple second statements (e.g., multiple second statements can be b1, b2, ..., bn, each second statement is used to represent the development requirements of a function). The encoder in this embodiment can be a transformer (a sequence model based on an attention mechanism) encoder, which can directly concatenate the code chain information and the development document to input them into the encoder (e.g., after concatenation, a1, a2, ..., am, b1, b2, ..., bn), thereby using the encoder to extract feature tensors based on the overall contextual relationship between the code chain information and the development document (the encoder can include M encoder layers from A1 to AM, and the output of the 5th encoder layer can be obtained to obtain the above feature tensors). Since the sentence segmentation module identifies multiple first and second sentences (used to provide a basis for the sentence attribution of subsequent feature vectors; both first and second sentences consist of multiple tokens), and the feature tensor consists of multiple feature vectors arranged in sequence (each feature vector corresponds to a word, which is also a token), we can extract the first-sentence level tensor corresponding to each first sentence based on the multiple feature vectors, and extract the second-sentence level tensor corresponding to each second sentence based on the multiple feature vectors (for example, tokens 1-4 belong to first sentence a1, tokens 5-8 belong to first sentence a2, ..., the se-th token belongs to second sentence bn). The feature vectors of all tokens belonging to any first sentence are grouped together to obtain the first-sentence level tensor corresponding to that first sentence, and the feature vectors of all tokens belonging to any second sentence are grouped together to obtain the second-sentence level tensor corresponding to that second sentence. For any first-sentence-level tensor (or second-sentence-level tensor), mean pooling can be performed on all its corresponding tokens to obtain the first-sentence-level features (or second-sentence-level features) of that first-sentence-level tensor (or second-sentence-level tensor). For any first-sentence-level feature (e.g., a1), the cosine similarity between the first-sentence-level feature and each second-sentence-level feature is calculated, thereby determining the second-sentence-level feature (e.g., b3) with the highest cosine similarity to the first-sentence-level feature (e.g., a1). a1 and b3 are the corresponding relationships. The statement alignment matrix is used to store the cosine similarity between any first-sentence-level tensor and second-sentence-level tensor. The correspondence between first-sentence-level tensors and second-sentence-level tensors can be determined based on the statement alignment matrix.For example, the order of statements corresponding to the feature vectors in the original feature tensor could be a1, a2, ..., am, b1, b2, ..., bn. However, after the feature vector order reordering module reorders the tensors based on the statement alignment matrix, the order of statements corresponding to the feature vectors in the reordered tensors could be a1, b3, a2, b1, a3, b2, ..., am, b9. It should be noted that during the reordering process, the order of the token feature vectors within a single statement remains unchanged; only the adjacency relationship between the first-statement and second-statement tensors is adjusted. Each pair of first-statement and second-statement tensors with a corresponding relationship is arranged adjacently (e.g., a1 and b3, a2 and b1, a3 and b2, etc.). It should be noted that the number of second statements, n, can be greater than the number of first statements, m. After determining the second-statement tensor corresponding to each first-statement tensor, the first-statement tensors and second-statement tensors with corresponding relationships can be arranged adjacently (in the order of the first-statement tensors, e.g., a1 and b3, a2 and b1, a3 and b2, etc.). Then, the remaining second-statement tensors without corresponding relationships (e.g., b11, b12, b13, etc.) are added to the end of the rearranged tensor. Furthermore, a new positional encoding can be generated based on the rearranged tensor, and the positional encoding is superimposed on the rearranged tensor. Since this embodiment arranges the feature vectors of the tokens corresponding to ab adjacently and reorganizes the order of token representation, the decoder can more easily capture the relationship between the first and second statements. The rearranged tensor is input into the decoder (e.g., a transformer decoder) to obtain global features, and the global features are input into the classifier (e.g., a fully connected layer and a softmax layer) to obtain the verification result, which can be a match or a non-match. In summary, the encoder accurately extracted the code chain information and feature tensors from the development documentation. The sentence segmentation module and feature tensors were used to determine the relationship between sentences and terms, thus obtaining first-sentence-level features and second-sentence-level features. Furthermore, even without knowing the alignment relationship between the first and second sentences, the feature tensors output by the encoder were used to discover this alignment, achieving self-supervised alignment. This led to the adjacent arrangement of the feature vectors of tokens corresponding to 'ab', reorganizing the order of the token feature vectors. This made it easier for the decoder to capture the association between the first and second sentences, improving the accuracy of the code chain verification model.
[0101] 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.
[0102] Example 2
[0103] This application also provides a call chain generation device for front-end and back-end code. It should be noted that the call chain generation device for front-end and back-end code in this application can be used to execute the call chain generation method for front-end and back-end code provided in this application. The call chain generation device for front-end and back-end code provided in this application will be described below.
[0104] According to embodiments of this application, an apparatus for implementing the above-described method for generating call chains for front-end and back-end code is also provided, such as... Figure 4 As shown, the device includes:
[0105] The file extraction unit 401 is used to receive the code directory corresponding to the target project to generate the call chain, and extract the front-end code file and the back-end code file from the code directory, wherein the front-end code file includes a web page structure file and a front-end logic file.
[0106] The file parsing unit 402 is used to perform multi-threaded parallel parsing on the web page structure file, the front-end logic file and the back-end code file using the target model, so as to obtain the web page structure parsing result corresponding to the web page structure file, the front-end logic parsing result corresponding to the front-end logic file and the back-end code parsing result corresponding to the back-end code file;
[0107] Information determination unit 403 is used to determine front-end interface call information based on the webpage structure parsing result and the front-end logic parsing result;
[0108] The association generation unit 404 is used to associate the front-end interface call information with the back-end code parsing result based on the service name to obtain the call chain association result, and to render a mind map based on the call chain association result to obtain the front-end and back-end code call chain.
[0109] The front-end and back-end code call chain generation device provided in this application embodiment receives the code directory corresponding to the target project from which the call chain is to be generated through a file extraction unit 401, and extracts front-end code files and back-end code files from the code directory. The front-end code files include web page structure files and front-end logic files. A file parsing unit 402 performs multi-threaded parallel parsing on the web page structure files, the front-end logic files, and the back-end code files using a target model to obtain web page structure parsing results, front-end logic parsing results, and back-end code parsing results. An information determination unit 403 determines front-end interface call information based on the web page structure parsing results and the front-end logic parsing results. An association generation unit 404 associates the front-end interface call information with the back-end code parsing results based on the service name to obtain a call chain association result. A mind map is then rendered based on the call chain association result to obtain the front-end and back-end code call chain. This solves the problem of low generation efficiency of front-end and back-end code call chains in related technologies, thereby improving the generation efficiency of front-end and back-end code call chains.
[0110] Optionally, in the front-end and back-end code call chain generation device provided in this application embodiment, the file parsing unit 402 includes: a data determination module, used to determine first input data based on a first prompt word and a webpage structure file, determine second input data based on a second prompt word and a front-end logic file, and determine third input data based on a third prompt word and a back-end code file; an environment creation module, used to determine a multi-threaded executor and create a concurrent processing environment based on the multi-threaded executor; and a parsing result module, used to call the program interface of the target model in the concurrent processing environment based on the first input data, the second input data, and the third input data to obtain the webpage structure parsing result corresponding to the first input data, the front-end logic parsing result corresponding to the second input data, and the back-end code parsing result corresponding to the third input data.
[0111] Optionally, in the front-end and back-end code call chain generation device provided in this application embodiment, the information determination unit 403 includes: a call chain object creation module, used to create a call chain object based on the webpage structure parsing result, and encapsulate multiple program interface lists in the call chain object, wherein each program interface list stores the first type of interface information in the webpage structure parsing result and the file name, front-end code summary, and front-end programming reference information corresponding to the first type of interface information; a call item merging module, used to merge the program interface call items in the front-end logic parsing result into the program interface list based on the front-end programming reference information, to obtain a merged program interface list, wherein the program interface call item includes the second type of interface information and the front-end function name and service name corresponding to the second type of interface information; and a front-end interface call information determination module, used to determine the front-end interface call information based on the merged program interface list.
[0112] Optionally, in the call chain generation device for front-end and back-end code provided in this application embodiment, the association generation unit 404 includes: a mapping table generation module, used to generate a back-end service mapping table based on the back-end code parsing result, wherein the back-end service mapping table is used to store the hash mapping relationship between the storage name and the back-end implementation information, and the back-end implementation information includes the back-end file path, the back-end code digest, the back-end function definition, and the back-end service description; a back-end implementation information determination module, used to traverse the back-end service mapping table based on the front-end interface call information to obtain the target back-end information, wherein the target back-end information is the back-end implementation information in the back-end service mapping table that has the same service name as the front-end interface call information; and an information adding module, used to add the target back-end information to the program interface list in the call chain object to obtain the call chain association result.
[0113] Optionally, in the front-end and back-end code call chain generation device provided in the embodiments of this application, the device further includes: a document acquisition unit, used to acquire the development document of the target project and extract code chain information based on the front-end and back-end code call chain after rendering a mind map based on the call chain association result; and a call chain verification unit, used to input the development document and code chain information into a code chain verification model and output verification results based on the code chain verification model, wherein the code chain verification model is used to verify the front-end and back-end code call chain based on the development document.
[0114] Optionally, in the call chain generation device for front-end and back-end code provided in this application embodiment, the code chain verification model includes a statement segmentation module, an encoder, a statement-level feature extraction module, a feature vector order rearrangement module, a decoder, and a classifier. The call chain verification unit includes: an information extraction module, used to determine multiple first statements corresponding to the code chain information based on the statement segmentation module, and to determine multiple second statements corresponding to the development document based on the statement segmentation module; a feature tensor extraction module, used to input the code chain information and the development document into the encoder, and to output a feature tensor using the encoder, wherein the feature tensor includes multiple feature vectors arranged in order; and a statement-level tensor extraction module, used to extract the first statement-level tensor corresponding to each first statement based on the multiple feature vectors, and to extract the first statement-level tensor based on the multiple feature vectors. The module extracts the second-sentence-level tensor corresponding to each second sentence; the alignment matrix determination module uses the sentence-level feature extraction module to perform mean pooling on each first-sentence-level tensor and each second-sentence-level tensor to obtain multiple first-sentence-level features and multiple second-sentence-level features, and determines the sentence alignment matrix based on the feature similarity between the first-sentence-level features and the second-sentence-level features; the rearrangement module rearranges the feature vector order in the feature tensor based on the sentence alignment matrix to obtain rearranged tensors, wherein each pair of corresponding first-sentence-level tensors and second-sentence-level tensors in the rearranged tensors are arranged adjacently; the result output module inputs the rearranged tensors sequentially into the decoder to obtain global features, and inputs the global features into the classifier to obtain the verification results.
[0115] It should be noted that the file extraction unit 401, file parsing unit 402, information determination unit 403, and association generation unit 404 mentioned above correspond to steps S201 to S204 in Embodiment 1. The instances and application scenarios implemented by the units and corresponding steps are the same, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above modules or units can be hardware or software components stored in memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above modules can also be part of a device and run in the computer terminal 10 provided in Embodiment 1.
[0116] Example 3
[0117] Embodiments of this application may provide an electronic device. Figure 5 This is a structural block diagram of an electronic device according to an embodiment of this application. Figure 5 As shown, the electronic device may include: one or more ( Figure 5 (Only one is shown) processor 502, memory 504, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0118] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the methods and apparatus in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby implementing the above-described methods. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0119] The processor can access information and applications stored in memory via a transmission device to perform the following steps: receiving the code directory corresponding to the target project from which the call chain is to be generated, and extracting front-end code files and back-end code files from the code directory, wherein the front-end code files include web page structure files and front-end logic files; using the target model to perform multi-threaded parallel parsing of the web page structure files, front-end logic files, and back-end code files to obtain the web page structure parsing results corresponding to the web page structure files, the front-end logic parsing results corresponding to the front-end logic files, and the back-end code parsing results corresponding to the back-end code files; determining the front-end interface call information based on the web page structure parsing results and the front-end logic parsing results; associating the front-end interface call information with the back-end code parsing results based on the service name to obtain the call chain association results, and rendering a mind map based on the call chain association results to obtain the front-end and back-end code call chain.
[0120] The processor can also invoke information and applications stored in the memory via a transmission device to perform the following steps: determining first input data based on a first prompt word and a webpage structure file; determining second input data based on a second prompt word and a front-end logic file; determining third input data based on a third prompt word and a back-end code file; determining a multi-threaded executor and creating a concurrent processing environment based on the multi-threaded executor; and in the concurrent processing environment, invoking the program interface of the target model based on the first input data, the second input data, and the third input data to obtain the webpage structure parsing result corresponding to the first input data, the front-end logic parsing result corresponding to the second input data, and the back-end code parsing result corresponding to the third input data.
[0121] The processor can also invoke information and applications stored in memory via a transmission device to perform the following steps: Create a call chain object based on the webpage structure parsing results, and encapsulate multiple program interface lists within the call chain object. Each program interface list stores the first type of interface information from the webpage structure parsing results, along with the corresponding filename, front-end code summary, and front-end programming reference information. Merge the program interface call items from the front-end logic parsing results into the program interface list based on the front-end programming reference information, resulting in a merged program interface list. The program interface call items include the second type of interface information and the corresponding front-end function name and service name. Determine the front-end interface call information based on the merged program interface list.
[0122] The processor can also invoke information and applications stored in memory via a transmission device to perform the following steps: generating a backend service mapping table based on the backend code parsing results, wherein the backend service mapping table is used to store the hash mapping relationship between the storage name and the backend implementation information, and the backend implementation information includes the backend file path, backend code digest, backend function definition and backend service description; traversing the backend service mapping table based on the frontend interface call information to obtain the target backend information, wherein the target backend information is the backend implementation information in the backend service mapping table that has the same service name as the frontend interface call information; adding the target backend information to the program interface list in the call chain object to obtain the call chain association result.
[0123] The processor can also access information and applications stored in the memory via a transmission device to perform the following steps: obtain the development documentation of the target project and extract code chain information based on the front-end and back-end code call chain; input the development documentation and code chain information into the code chain verification model and output the verification result based on the code chain verification model, wherein the code chain verification model is used to verify the front-end and back-end code call chain based on the development documentation.
[0124] The processor can also invoke information and applications stored in the memory via a transmission device to perform the following steps: Based on the statement segmentation module, determine multiple first statements corresponding to the code chain information; based on the statement segmentation module, determine multiple second statements corresponding to the development documentation; input the code chain information and development documentation into the encoder, and use the encoder to output a feature tensor, wherein the feature tensor includes multiple feature vectors arranged in sequence; extract the first sentence-level tensor corresponding to each first statement based on the multiple feature vectors, and extract the second sentence-level tensor corresponding to each second statement based on the multiple feature vectors; use the sentence-level feature extraction module to perform mean pooling on each first sentence-level tensor and each second sentence-level tensor to obtain multiple first sentence-level features and multiple second sentence-level features, and determine the statement alignment matrix based on the feature similarity between the first sentence-level features and the second sentence-level features; based on the feature vector order rearrangement module, rearrange the feature vector order in the feature tensor according to the statement alignment matrix to obtain a rearranged tensor, wherein each pair of corresponding first sentence-level tensors and second sentence-level tensors in the rearranged tensor are arranged adjacently; input the rearranged tensor sequentially into the decoder to obtain global features, and input the global features into the classifier to obtain verification results.
[0125] This application provides a scheme for generating a call chain between front-end and back-end code. It receives the code directory corresponding to the target project from which the call chain is to be generated, and extracts front-end and back-end code files from the code directory. The front-end code files include webpage structure files and front-end logic files. A target model is used to perform multi-threaded parallel parsing of the webpage structure files, front-end logic files, and back-end code files, obtaining the webpage structure parsing result, the front-end logic parsing result, and the back-end code parsing result. Front-end interface call information is determined based on the webpage structure parsing result and the front-end logic parsing result. The front-end interface call information is associated with the back-end code parsing result based on the service name to obtain the call chain association result. A mind map is then rendered based on the call chain association result to obtain the front-end and back-end code call chain. This solves the technical problem of low generation efficiency of front-end and back-end code call chains in existing technologies.
[0126] Those skilled in the art will understand that Figure 5 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones, tablets, handheld computers, mobile internet devices (MIDs), PADs, and other terminal devices. Figure 5 This does not limit the structure of the aforementioned electronic device. For example, electronic devices may also include components that are more... Figure 5 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 5 The different configurations shown.
[0127] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0128] Example 4
[0129] Embodiments of this application also provide a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the call chain generation method for front-end and back-end code provided in Embodiment 1.
[0130] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0131] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: receiving the code directory corresponding to the target project to be generated with a call chain, and extracting front-end code files and back-end code files from the code directory, wherein the front-end code files include web page structure files and front-end logic files; using the target model to perform multi-threaded parallel parsing of the web page structure files, front-end logic files, and back-end code files to obtain the web page structure parsing result corresponding to the web page structure file, the front-end logic parsing result corresponding to the front-end logic file, and the back-end code parsing result corresponding to the back-end code file; determining the front-end interface call information based on the web page structure parsing result and the front-end logic parsing result; associating the front-end interface call information with the back-end code parsing result based on the service name to obtain the call chain association result, and performing mind map rendering based on the call chain association result to obtain the front-end and back-end code call chain.
[0132] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: determining first input data based on a first prompt word and a webpage structure file; determining second input data based on a second prompt word and a front-end logic file; determining third input data based on a third prompt word and a back-end code file; determining a multi-threaded executor and creating a concurrent processing environment based on the multi-threaded executor; and in the concurrent processing environment, calling the program interface of the target model based on the first input data, the second input data, and the third input data to obtain the webpage structure parsing result corresponding to the first input data, the front-end logic parsing result corresponding to the second input data, and the back-end code parsing result corresponding to the third input data.
[0133] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: creating a call chain object based on the webpage structure parsing result, and encapsulating multiple program interface lists in the call chain object, wherein each program interface list stores the first type of interface information in the webpage structure parsing result and the file name, front-end code summary, and front-end programming reference information corresponding to the first type of interface information; merging the program interface call items in the front-end logic parsing result into the program interface list based on the front-end programming reference information to obtain a merged program interface list, wherein the program interface call items include the second type of interface information and the front-end function name and service name corresponding to the second type of interface information; and determining the front-end interface call information based on the merged program interface list.
[0134] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: generating a backend service mapping table based on the backend code parsing result, wherein the backend service mapping table is used to store the hash mapping relationship between the storage name and the backend implementation information, and the backend implementation information includes the backend file path, backend code digest, backend function definition and backend service description; traversing the backend service mapping table based on the frontend interface call information to obtain the target backend information, wherein the target backend information is the backend implementation information in the backend service mapping table that has the same service name as the frontend interface call information; adding the target backend information to the program interface list in the call chain object to obtain the call chain association result.
[0135] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: obtaining the development documentation of the target project, extracting code chain information based on the front-end and back-end code call chain; inputting the development documentation and code chain information into the code chain verification model, and outputting verification results based on the code chain verification model, wherein the code chain verification model is used to verify the front-end and back-end code call chain based on the development documentation.
[0136] Optionally, in this embodiment, the computer-readable storage medium is further configured to store program code for performing the following steps: determining multiple first statements corresponding to code chain information based on the statement segmentation module, and determining multiple second statements corresponding to development documents based on the statement segmentation module; inputting the code chain information and development documents into an encoder, and outputting a feature tensor using the encoder, wherein the feature tensor includes multiple feature vectors arranged in sequence; extracting a first sentence-level tensor corresponding to each first statement based on the multiple feature vectors, and extracting a second sentence-level tensor corresponding to each second statement based on the multiple feature vectors; performing mean pooling on each first sentence-level tensor and each second sentence-level tensor using a sentence-level feature extraction module to obtain multiple first sentence-level features and multiple second sentence-level features, and determining a statement alignment matrix based on the feature similarity between the first sentence-level features and the second sentence-level features; rearranging the feature vector order based on the statement alignment matrix using a feature vector order rearrangement module to obtain a rearranged tensor, wherein each pair of corresponding first sentence-level tensors and second sentence-level tensors in the rearranged tensor are arranged adjacently; inputting the rearranged tensor sequentially into a decoder to obtain global features, and inputting the global features into a classifier to obtain verification results.
[0137] This application also provides a computer program product that, when executed on a data processing device, is adapted to perform method steps for generating a call chain of front-end and back-end code.
[0138] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0139] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0140] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0141] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0142] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0143] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0144] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for generating call chains for front-end and back-end code, characterized in that, include: Receive the code directory corresponding to the target project to generate the call chain, and extract the front-end code file and back-end code file from the code directory, wherein the front-end code file includes a web page structure file and a front-end logic file; The target model is used to perform multi-threaded parallel parsing on the web page structure file, the front-end logic file, and the back-end code file to obtain the web page structure parsing result corresponding to the web page structure file, the front-end logic parsing result corresponding to the front-end logic file, and the back-end code parsing result corresponding to the back-end code file. The front-end interface call information is determined based on the webpage structure parsing results and the front-end logic parsing results; The front-end interface call information is associated with the back-end code parsing result based on the service name to obtain the call chain association result. A mind map is then rendered based on the call chain association result to obtain the front-end and back-end code call chain.
2. The method according to claim 1, characterized in that, The target model is used to perform multi-threaded parallel parsing on the webpage structure file, the front-end logic file, and the back-end code file, resulting in the following parsing results: webpage structure parsing result corresponding to the webpage structure file, front-end logic parsing result corresponding to the front-end logic file, and back-end code parsing result corresponding to the back-end code file. The first input data is determined based on the first prompt word and the webpage structure file; the second input data is determined based on the second prompt word and the front-end logic file; and the third input data is determined based on the third prompt word and the back-end code file. Determine the multi-threaded executor and create a concurrent processing environment based on the multi-threaded executor; In the concurrent processing environment, the program interface of the target model is called based on the first input data, the second input data, and the third input data to obtain the webpage structure parsing result corresponding to the first input data, the front-end logic parsing result corresponding to the second input data, and the back-end code parsing result corresponding to the third input data.
3. The method according to claim 1, characterized in that, Based on the webpage structure parsing results and the frontend logic parsing results, the frontend interface call information is determined as follows: A call chain object is created based on the webpage structure parsing result, and multiple program interface lists are encapsulated in the call chain object. Each program interface list stores the first type of interface information in the webpage structure parsing result and the file name, front-end code summary, and front-end programming reference information corresponding to the first type of interface information. Based on the front-end programming reference information, the program interface call items in the front-end logic parsing result are merged into the program interface list to obtain the merged program interface list. The program interface call items include second type interface information and the front-end function name and service name corresponding to the second type interface information. The front-end interface call information is determined based on the merged program interface list.
4. The method according to claim 3, characterized in that, The call chain association results obtained by associating the front-end interface call information with the back-end code parsing results based on the service name include: A backend service mapping table is generated based on the backend code parsing results. The backend service mapping table is used to store the hash mapping relationship between the storage name and the backend implementation information. The backend implementation information includes the backend file path, backend code summary, backend function definition and backend service description. The backend service mapping table is traversed based on the frontend interface call information to obtain target backend information, wherein the target backend information is the backend implementation information in the backend service mapping table that has the same service name as the frontend interface call information; The target backend information is added to the program interface list in the call chain object to obtain the call chain association result.
5. The method according to claim 1, characterized in that, After rendering a mind map based on the call chain association results to obtain the front-end and back-end code call chain, the method further includes: Obtain the development documentation of the target project and extract code chain information based on the front-end and back-end code call chain; The development documentation and the code chain information are input into the code chain verification model, and the verification result is output based on the code chain verification model. The code chain verification model is used to verify the front-end and back-end code call chain based on the development documentation.
6. The method according to claim 5, characterized in that, The code chain verification model includes a statement segmentation module, an encoder, a statement-level feature extraction module, a feature vector order rearrangement module, a decoder, and a classifier. The verification results output by the code chain verification model include: Based on the statement segmentation module, multiple first statements corresponding to the code chain information are determined, and multiple second statements corresponding to the development document are determined based on the statement segmentation module. The code chain information and the development documentation are input into the encoder, and the encoder outputs a feature tensor, wherein the feature tensor includes multiple feature vectors arranged in order. Based on the multiple feature vectors, extract the first sentence-level tensor corresponding to each first statement, and extract the second sentence-level tensor corresponding to each second statement based on the multiple feature vectors; The sentence-level feature extraction module is used to perform mean pooling on each first sentence-level tensor and each second sentence-level tensor to obtain multiple first sentence-level features and multiple second sentence-level features. The sentence alignment matrix is determined based on the feature similarity between the first sentence-level features and the second sentence-level features. The feature vector order rearrangement module rearranges the feature vector order in the feature tensor based on the sentence alignment matrix to obtain a rearranged tensor, wherein each pair of corresponding first sentence-level tensors and second sentence-level tensors in the rearranged tensor are arranged adjacent to each other. The rearranged tensors are sequentially input into the decoder to obtain global features, and the global features are input into the classifier to obtain verification results.
7. A device for generating a call chain for front-end and back-end code, characterized in that, include: The file extraction unit is used to receive the code directory corresponding to the target project to generate the call chain, and extract the front-end code file and the back-end code file from the code directory, wherein the front-end code file includes the web page structure file and the front-end logic file; The file parsing unit is used to perform multi-threaded parallel parsing of the web page structure file, the front-end logic file, and the back-end code file using the target model, so as to obtain the web page structure parsing result corresponding to the web page structure file, the front-end logic parsing result corresponding to the front-end logic file, and the back-end code parsing result corresponding to the back-end code file. An information determination unit is used to determine front-end interface call information based on the webpage structure parsing result and the front-end logic parsing result; The association generation unit is used to associate the front-end interface call information with the back-end code parsing result based on the service name to obtain the call chain association result, and to render a mind map based on the call chain association result to obtain the front-end and back-end code call chain.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored executable program, wherein, when the executable program is executed, it controls the device where the computer-readable storage medium is located to execute the call chain generation method for front-end and back-end code as described in any one of claims 1 to 6.
9. An electronic device, characterized in that, include: Memory, which stores executable programs; A processor for running the program, wherein the program executes the call chain generation method for front-end and back-end code according to any one of claims 1 to 6 when it runs.
10. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the steps of the method for generating the call chain of front-end and back-end code as described in any one of claims 1 to 6.