Code content acquisition method and device, equipment, medium and program product

By configuring the package names of code packages in batches and displaying program methods and storage paths in the search configuration interface, the problem of low statistical efficiency of code packages in the existing technology is solved, and fast and accurate code package usage statistics and intuitive result display are achieved. .

CN118796248APending Publication Date: 2024-10-18TENCENT CLOUD COMPUTING (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310389506.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-12
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

In the existing technology, counting the usage of third-party code packages in business codes is inefficient and mainly relies on manual search and positioning, resulting in low efficiency.

Method used

Provides a code content acquisition method that displays the search configuration interface, batches configures the package names of the code packages to be searched, and displays the program methods and storage paths referenced in the target code package during the code search configuration operation to achieve fast and accurate statistics.

Benefits of technology

It improves the statistical efficiency of the code package in the business system and the intuitiveness of the result display, simplifies the developer's workflow, and enhances the efficiency of human-computer interaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118796248A_ABST
    Figure CN118796248A_ABST
Patent Text Reader

Abstract

The invention discloses a code content obtaining method and device, equipment, a medium and a program product, and relates to the technical field of computers. The method comprises the following steps: displaying a search configuration interface; receiving a code search configuration operation on the first service system in the search configuration interface; displaying a program method list based on the code lookup configuration operation; and displaying a code path list in response to receiving a selection operation on a target program method in the at least one program method. Developers can count the use conditions of code packages in code files corresponding to a service system in batches through code search configuration operation on a search configuration interface, namely which program methods in the code packages are quoted and storage paths of the quoted program methods; developers can quickly and accurately count the use condition of each code package, and the working efficiency of counting the code packages in a service system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a method, device, equipment, medium and program product for obtaining code content. Background Art

[0002] During the business development process, the code files corresponding to the business contain not only the code written by the developer, but also a lot of code imported from third-party platforms. Generally, third-party code packages are configured in the code files to use certain program methods in the third-party code packages. When the code files need to be modified, it is often necessary to count the number of program methods in the third-party code packages that are referenced.

[0003] In the related art, the method for counting third-party code packages in business codes is mainly based on the search method, that is, the developer searches for the package name in the code file corresponding to the business code; if the package name of the target code package (a code package imported from a third-party platform) searched in the code file is consistent with the searched package name, the code file corresponding to the package name is found, and the usage of the program methods in the third-party code package corresponding to the package name in the code file is manually counted.

[0004] However, in the related art, the efficiency of counting code packages in code files is low. Summary of the invention

[0005] The embodiments of the present application provide a method, apparatus, device, medium and program product for obtaining code content, which can improve the efficiency of counting code packages in a code file. The technical solution is as follows:

[0006] In one aspect, a method for obtaining code content is provided, the method comprising:

[0007] Displaying a search configuration interface, wherein the search configuration interface includes a package name configuration area, wherein the package name configuration area is used to batch configure the package names of the code packages to be searched;

[0008] Receiving a code search configuration operation for a first business system in the search configuration interface, the code search configuration operation including configuration of a first package name in the package name configuration area, the first package name being the package name of a code package stored in a public code management platform, the code search configuration operation being used to search a target code package matching the first package name in a code file of the first business system, the target code package being a code package imported from the public code management platform;

[0009] Displaying a program method list based on the code search configuration operation, wherein the program method list includes at least one program method referenced in the target code package;

[0010] In response to receiving a selection operation of a target program method in the at least one program method, a code path list is displayed, the code path list including a storage path in the code file of a code that references the target program method.

[0011] On the other hand, a device for acquiring code content is provided, the device comprising:

[0012] A display module, used to display a search configuration interface, wherein the search configuration interface includes a package name configuration area, and the package name configuration area is used to batch configure the package names of the code packages to be searched;

[0013] a receiving module, configured to receive a code search configuration operation for a first business system in the search configuration interface, wherein the code search configuration operation includes configuration of a first package name in the package name configuration area, wherein the first package name is a package name of a code package stored in a public code management platform, and the code search configuration operation is used to search a code file of the first business system for a target code package that matches the first package name, wherein the target code package is a code package imported from the public code management platform;

[0014] The display module is further used to display a program method list based on the code search configuration operation, wherein the program method list includes at least one program method referenced in the target code package;

[0015] The display module is further configured to display a code path list in response to receiving a selection operation on a target program method in the at least one program method, wherein the code path list includes a storage path in the code file of a code that references the target program method.

[0016] On the other hand, a computer device is provided, comprising a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the method for obtaining code content as described in any of the above embodiments.

[0017] On the other hand, a computer-readable storage medium is provided, wherein at least one instruction, at least one program, a code set or an instruction set is stored in the storage medium, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement a method for obtaining code content as described in any of the above embodiments.

[0018] On the other hand, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method for obtaining code content described in any of the above embodiments.

[0019] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:

[0020] By receiving the code search configuration operation for the business system in the search configuration interface, the package names of the code packages to be searched are configured in batches. When the configured package name matches the target code name in the business system, at least one program method referenced in the target code package is displayed in the program method list, and based on the selection operation of the target program method, the storage path of the target program method in the code file is displayed. Developers can use the code search configuration operation in the search configuration interface to batch count the usage of code packages in the code files corresponding to the business system, that is, which program methods in the code package are referenced and the storage path of the referenced program methods, so that developers can quickly and accurately count the usage of each code package, improving the work efficiency of counting code packages in the business system; at the same time, the usage of the code package is visualized through the program method list and the code path list, which more intuitively and clearly shows the usage of each code package in the code file corresponding to the business system, improving the human-computer interaction efficiency of displaying statistical results of the code package. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0022] Figure 1 It is a schematic diagram of an implementation environment provided by an exemplary embodiment of the present application;

[0023] Figure 2 is a flowchart of a method for obtaining code content provided by an exemplary embodiment of the present application;

[0024] Figure 3 is a flowchart of a method for obtaining code content provided by another exemplary embodiment of the present application;

[0025] Figure 4 This is a schematic diagram of an operation of collecting statistics on business codes in a private cloud scenario provided by an exemplary embodiment of the present application;

[0026] Figure 5 is a schematic diagram showing a list of program methods provided by an exemplary embodiment of the present application;

[0027] Figure 6 is a flowchart of a method for obtaining code content provided by another exemplary embodiment of the present application;

[0028] Figure 7 is an interactive schematic diagram of a method for acquiring code content provided by an exemplary embodiment of the present application;

[0029] Figure 8 is a flowchart of a code checking process provided by another exemplary embodiment of the present application;

[0030] Fig. 9 is a structural block diagram of a device for acquiring code content provided by an exemplary embodiment of the present application;

[0031] Fig.10 is a structural block diagram of a device for acquiring code content provided by another exemplary embodiment of the present application;

[0032] Fig.11 It is a structural block diagram of a computer device provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0033] In order to make the purpose, technical solution and advantages of the present application clearer, the implementation mode of the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.

[0034] In the present application, the terms "first", "second", etc. are used to distinguish identical or similar items with substantially the same effects and functions. It should be understood that there is no logical or temporal dependency between "first" and "second", nor are there any limitations on quantity and execution order.

[0035] In the process of business development, the code files corresponding to the business contain not only the codes written by the developers themselves, but also a lot of codes imported from third-party platforms. Generally, third-party code packages are configured in the code files to use certain program methods in the third-party code packages. When it is necessary to modify the code files, it is often necessary to count the cases where the program methods in the third-party code packages are referenced. In the related art, the method for counting third-party code packages in business codes is mainly based on the search method, that is, the developer searches for the package name in the code file corresponding to the business code; if the package name of the target code package (a code package imported from a third-party platform) is consistent with the searched package name, the code file corresponding to the package name is located, and the method of manually counting the use of the third-party code package in the package name is used. However, in the related art, the efficiency of counting code packages in code files is low.

[0036] The embodiment of the present application provides a code content acquisition method, which can count the usage of certain code packages introduced by business codes in business and the program methods in the code packages in business codes based on configuration operations. By receiving the code search configuration operation for the business system in the search configuration interface, the package name of the code package to be searched is configured in batches. When the configured package name matches the target code name in the business system, at least one program method referenced in the target code package is displayed in the program method list, and based on the selection operation of the target program method, the storage path of the target program method in the code file is displayed. Developers can count the usage of code packages in the code files corresponding to the business system in batches through the code search configuration operation in the search configuration interface, that is, which program methods in the code package are referenced and the storage path of the referenced program methods, so that developers can quickly and accurately count the usage of each code package, and improve the work efficiency of counting code packages in the business system; at the same time, the usage of the code package is visualized through the program method list and the code path list, and the usage of each code package in the code file corresponding to the business system is more intuitively and clearly displayed, which improves the human-computer interaction efficiency of displaying statistical results of the code package.

[0037] The method provided in the embodiment of the present application is applicable to any scenario where code content needs to be counted, such as: code design scenarios, business upgrade scenarios, code modification scenarios, code testing scenarios, code risk assessment scenarios, etc., and the embodiment of the present application is not limited to this.

[0038] Please refer to Figure 1 , which shows a schematic diagram of a solution implementation environment provided by an embodiment of the present application. The solution implementation environment may include: a terminal 110.

[0039] The terminal device 110 may be an electronic device such as a mobile phone, a tablet computer, a game console, a multimedia player, a personal computer, a vehicle-mounted terminal, an intelligent robot, etc. The terminal device 110 has a target application installed and running.

[0040] Among them, the target application can be implemented as an application with a code search function, and can also be implemented as a module with a code search function installed in a business system, which is not limited in the embodiments of the present application.

[0041] When the target application is implemented as an application with a code search function, the target application can be at least one of a code statistics application, a code compilation application, a code modification application, a code testing application, a code evaluation application, etc., which is not limited to the embodiments of the present application.

[0042] Schematically, the code statistics application is used as an example for explanation. The code statistics application can be used to check the system code files corresponding to the business system, so as to count certain codes in the system code files. When the developer logs in to the main interface of the code statistics application, the search configuration interface can be triggered to display, and the search configuration interface includes a package name configuration area, and the package name configuration area is used to batch configure the package names of the code packages to be searched; when the code search configuration operation in the search configuration interface is received on the terminal 110, the terminal 110 will search for the target code package matching the first package name in the code file of the first business system according to the first package name configured in the code search configuration operation; when the target code package is found, the terminal 110 will display the program method list based on the code search configuration operation, and the program method list includes at least one program method referenced in the target code package; when the terminal 110 receives a selection operation for the target program method in at least one program method, the code path list is displayed, and the code path list includes the storage path of the code that references the target program method in the code file.

[0043] In some embodiments, the implementation environment of the above solution also includes a server 120. The server 120 and the terminal 110 are connected via a communication network 130. The communication network 130 can be a wired network or a wireless network, which is not limited in the embodiments of the present application.

[0044] Optionally, the server 120 is used to provide background services for the target application installed in the terminal 110. Schematically, the server 120 stores the code files of the first business system. After receiving the code search configuration in the search configuration interface, the terminal 110 sends a code search request to the server 120. The server 120 searches for the code files of the first business system according to the configured first package name based on the code search request; after searching for the target code package matching the first package name, the server 120 returns the search result to the terminal 110, which is at least one program method referenced by the target code package and a code path list corresponding to the at least one program method.

[0045] It is worth noting that server 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network) and big data and artificial intelligence platforms.

[0046] Among them, cloud technology refers to a hosting technology that unifies hardware, software, network and other series of resources in a wide area network or local area network to realize data calculation, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model application, which can form a resource pool, which is used on demand and flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, each item may have its own identification mark in the future, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately, and all kinds of industry data require strong system backing support, which can only be achieved through cloud computing. Optionally, the server 120 can also be implemented as a node in the blockchain system.

[0047] It should be noted that before collecting relevant data of the user (for example, the code file of the first business system) and during the process of collecting relevant data of the user, the present application can display a prompt interface, a pop-up window or output a voice prompt information, and the prompt interface, pop-up window or voice prompt information is used to prompt the user that its relevant data is currently being collected, so that the present application only starts to execute the relevant steps of obtaining relevant data of the user after obtaining the confirmation operation issued by the user to the prompt interface or pop-up window, otherwise (that is, when the confirmation operation issued by the user to the prompt interface or pop-up window is not obtained), the relevant steps of obtaining relevant data of the user are terminated, that is, the relevant data of the user is not obtained. In other words, all user data collected by the present application are collected with the consent and authorization of the user, and the collection, use and processing of relevant user data need to comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0048] Combined with the above introduction and implementation environment, Figure 2 is a flowchart of a method for obtaining code content provided by an embodiment of the present application, and the method is applied to Figure 1 Taking the terminal shown in FIG. 1 as an example, the method includes:

[0049] Step 201, displaying a search configuration interface.

[0050] Optionally, the search configuration interface refers to the interface displayed when the target application is running. The target application provides a code search function. The target application can be used to check the system code files corresponding to the business system, thereby performing statistics on certain codes in the system code files, for example: performing statistics on program methods referenced in code packages imported from a public code management platform in the system code files.

[0051] Among them, the target application can be implemented as an application with a code search function, and can also be implemented as a module with a code search function installed in a business system, which is not limited in the embodiments of the present application.

[0052] The above search configuration interface includes a package name configuration area, which is used to batch configure the package names of the code packages to be searched.

[0053] Optionally, the package name configuration area can be implemented as at least one of a package name input box, a package name selection box, etc., which is not limited in the present embodiment. Schematically, by batch configuring the package names of multiple code packages in the package name configuration area, the program methods referenced by each of the multiple code packages in the system code file can be counted.

[0054] Step 202: receiving a code search configuration operation for the first business system in the search configuration interface.

[0055] Optionally, the first business system includes at least one of a business system in a private cloud scenario, a business system in a public cloud scenario, a business system in a proprietary cloud scenario, etc., which is not limited in the embodiments of the present application.

[0056] Schematically, taking the first business system implemented as a business system in a private cloud scenario as an example, the first business system can be implemented as an electronic library system of a university, and the electronic library system is only for students and teachers in the university to query and read books.

[0057] The code search configuration operation includes configuring a first package name in a package name configuration area, where the first package name is the package name of a code package stored in a public code management platform.

[0058] Optionally, the public code management platform includes a Node Package Manager (NPM), which is a package management tool for Node.JavaScript (abbreviated as Node.js, a development tool-based package management tool); NPM stores multiple code packages, and the code package downloaded and imported into the code file through NPM is called an NPM package.

[0059] Illustratively, when the first business system is developed through Node.js, some code packages can be imported from NPM (the code packages in NPM can be regarded as third-party code packages, that is, they are not codes written by developers themselves. The third-party code packages will encapsulate some program methods. The functions implemented by these program methods are generally universal, such as: login function), and all or part of the program methods in these code packages are referenced.

[0060] Optionally, developers can download code packages uploaded by others on NPM and use them locally, or upload their own code packages to NPM for others to use.

[0061] In some embodiments, if the package name configuration area is implemented as a package name input box, receiving an input operation on the first package name in the package name input box is regarded as a configuration operation on the first package name.

[0062] Optionally, after the developer enters the package name in the package name input box, the background of the target application will check the package name in the package name input box. When it is checked that the input package name meets the package name conditions, the package name can be confirmed as the package name to be searched, that is: in response to receiving the input operation of a candidate package name in the package name input box, when the candidate package name meets the package name conditions, the input candidate package name is determined to be the first package name.

[0063] Schematically, the public code management platform is implemented as NPM as an example for explanation. The background of the target application stores the NPM package name library, which includes the package names of all code packages stored in NPM. After the developer enters the candidate package name in the package name input box, the background of the target application will check whether the candidate package name belongs to the package name in the NPM package name library. If it does, the candidate package name meets the package name condition and the candidate package name is determined as the first package name; if it does not, the candidate package name does not meet the package name condition, and the search configuration interface will display a prompt message to remind the developer that the candidate package name entered does not meet the condition and needs to modify the candidate package name entered.

[0064] In some embodiments, if the package name configuration area is implemented as a package name selection box, in response to receiving a drop-down operation on the package name selection box, a package name selection list is displayed, and the package name selection list includes the package names of multiple code packages; a selection operation on the first package name in the package name selection list is received as a configuration operation on the first package name.

[0065] Optionally, multiple package names can also be configured in the package name configuration area. If the package name configuration area is implemented as a package name input box, input operations for multiple package names in the package name input box are received as configuration operations for multiple package names. A single package name input box can input multiple package names, or a single package name input box can input a single package name.

[0066] If the package name configuration area is implemented as a package name selection box, a selection operation of multiple package names in the package name selection list is received as a configuration operation for the multiple package names.

[0067] The above code search configuration operation is used to search for a target code package matching the first package name in the code file of the first business system, where the target code package is a code package imported from a public code management platform.

[0068] Illustratively, when a code search configuration operation is received in the search configuration interface, the background of the target application will search in the code file of the first business system according to the first package name configured by the developer. If a package name consistent with the first package name is found, the code package corresponding to the package name is the target code package. It should be noted that when searching in the code file of the first business system, the code in the code file is traversed, that is, the first package name is "DateSegment", and the code in the code file includes "npm install DateSegment", indicating that the code package corresponding to "DateSegment" is the target code package, and the target code package is the code package imported from NPM into the code file of the first business system.

[0069] Step 203, displaying a program method list based on the code search configuration operation.

[0070] Optionally, in response to receiving a confirmation operation on the first package name, a program method list is displayed.

[0071] The program method list includes at least one program method referenced in the target code package, that is, at least one program method referenced from the target code package in the code file corresponding to the first business system.

[0072] Optionally, a program method refers to a method encapsulated in a code package. Schematically, a program method can be understood as a function for a certain object. Assuming that the object is "xiaohong", a function is bound to "xiaohong", then this function is the method of "xiaohong". If the functions bound to "xiaohong" are "name" and "age", the variable in "name" is defined as "xiaohong", and the variable in "age" is defined as 18, and "name" and "age" are returned, it means that the name of the object "xiaohong" is Xiaohong and the age is 18.

[0073] Optionally, when a confirmation operation for the first package name is received, the background of the target application will search the code file of the first business system according to the first package name configured by the developer. If a package name consistent with the first package name is found, the code package corresponding to the package name is the target code package.

[0074] Optionally, when searching in the code file of the first business system according to the first package name configured by the developer, the search scope is all the codes in the code file; or, the search scope is the import statement code in the code file, and the import statement code is used to import the code package in the public code management platform in the code file. Schematically, the public code management platform is implemented as NPM as an example, and the import statement in the code file is in the form of "require('package name')".

[0075] When the target code package is found, the background of the target application program will display the method names of the program methods in all the target code packages referenced (ie used) in the code file in the program method list.

[0076] Step 204 , in response to receiving a selection operation on a target program method in at least one program method, displaying a code path list.

[0077] The code path list includes the storage path of the code that references the target program method in the code file.

[0078] Illustratively, the program method list includes at least one program method, and by selecting one of the program methods, the storage path of the code corresponding to the program method in the target file can be viewed.

[0079] Optionally, in response to receiving a selection operation on a target program method in at least one program method, the code path list is displayed in a pop-up window.

[0080] Alternatively, based on the code search configuration operation, a program method list is displayed on the left side of the search result interface; in response to receiving a selection operation for a target program method in at least one program method, a code path list is displayed on the right side of the search result interface.

[0081] It should be noted that the embodiment of the present application does not limit the display format of the program method list and the code path list.

[0082] In some embodiments, the code path list also provides a code detail viewing function, that is, in response to receiving a trigger operation on a path stored in the code path list, a code snippet corresponding to at least one program method is displayed.

[0083] Among them, the trigger operation can be implemented as at least one of a single-click operation, a double-click operation, a gesture operation, a voice operation, etc. The embodiment of the present application does not limit the specific form of the trigger operation.

[0084] Illustratively, the code path list includes multiple storage paths corresponding to at least one program method. When one of the storage paths is selected and double-clicked, a pop-up window will be displayed on the code path list, which will display the code snippet stored in the storage path of at least one program method.

[0085] Optionally, the pop-up window is a pop-up window with a code editing function, and the developer can also edit the code snippet corresponding to at least one program method in the pop-up window, for example, modify the variables therein.

[0086] In summary, the method for obtaining code content provided by the embodiment of the present application receives the code search configuration operation for the business system in the search configuration interface, batch configures the package name of the code package to be searched, and when the configured package name matches the target code name in the business system, displays at least one program method referenced in the target code package in the program method list, and based on the selection operation of the target program method, displays the storage path of the target program method in the code file. Developers can use the code search configuration operation in the search configuration interface to batch count the usage of code packages in the code files corresponding to the business system, that is, which program methods in the code package are referenced and the storage path of the referenced program methods, so that developers can quickly and accurately count the usage of each code package, and improve the work efficiency of counting code packages in the business system; at the same time, the usage of the code package is visualized through the program method list and the code path list, and the usage of each code package in the code file corresponding to the business system is more intuitively and clearly displayed, which improves the human-computer interaction efficiency of displaying statistical results of the code package.

[0087] The method provided in the embodiment of the present application can trigger the storage path in the code path list, thereby displaying the code snippet corresponding to at least one program method, providing developers with a way to quickly view the code snippet, reducing the operation steps for developers to view the code snippet, and improving the efficiency of human-computer interaction.

[0088] In some optional embodiments, the above-mentioned search configuration interface includes a method name configuration area, which is used to batch configure the method names of the program methods to be searched, and the code search configuration operation also includes the configuration of at least one method name corresponding to the first package name in the method name configuration area; the search configuration interface also includes a business scope configuration area, which is used to configure the business system to be searched. Figure 3 is a flowchart of a method for obtaining code content provided by an embodiment of the present application, and the method is applied to Figure 1 Taking the terminal shown in FIG. 1 as an example, the method includes:

[0089] Step 301, display the search configuration interface.

[0090] The above search configuration interface includes a business scope configuration area, a package name configuration area, and a method name configuration area.

[0091] Among them, the business scope configuration area is used to configure the business system to be searched; the package name configuration area is used to batch configure the package names of the code packages to be searched; and the method name configuration area is used to batch configure the method names of the program methods to be searched.

[0092] Step 302: Receive a business scope configuration operation in a business scope configuration area.

[0093] The business scope configuration operation is used to determine that the business system to be found is the first business system.

[0094] Optionally, the business scope configuration operation includes at least one of the following situations:

[0095] 1. Configure the business component name corresponding to the business system.

[0096] A configuration operation on a business component name in a business scope configuration area is received, and the configuration operation on the business component name is used as a business scope configuration operation.

[0097] Illustratively, if the business scope configuration area implements a business component name input box, then directly enter the target business component name in the business component name input box to complete the configuration operation of the business scope; or, if the business scope configuration area implements a business component name selection box, then select the target business component name in the business component name selection box to complete the configuration operation of the business scope.

[0098] The target business component corresponding to the target business component name is the first business system.

[0099] 2. Configure the private cloud version of the business system.

[0100] In the case where the first business system is a business system in a private cloud, a configuration operation on the private cloud version is received in the business scope configuration area, and the configuration operation on the private cloud version is used as the business scope configuration operation.

[0101] Illustratively, if the business scope configuration area is implemented as a private cloud version input box, then directly enter the private cloud version number in the private cloud version input box to complete the configuration operation on the business scope; or, if the business scope configuration area implements a private cloud version number selection box, then select the target private cloud version number in the business component name selection box to complete the configuration operation on the business scope.

[0102] Among them, all business systems corresponding to the private cloud version are the first business systems.

[0103] 3. Configure the private cloud platform to which the business system belongs.

[0104] In the case where the first business system is a business system in a private cloud, a configuration operation on the private cloud platform in the business scope configuration area is received, and the configuration operation on the private cloud platform is used as the business scope configuration operation.

[0105] Among them, the private cloud platform refers to the platform in the private cloud system, such as the employee management platform.

[0106] Illustratively, if the business scope configuration area is implemented as a private cloud platform input box, directly enter the platform name of the private cloud in the private cloud version input box to complete the configuration operation of the business scope; or, if the business scope configuration area implements a private cloud platform name selection box, select the target private cloud platform name in the business component name selection box to complete the configuration operation of the business scope.

[0107] The business system corresponding to the private cloud platform is the first business system. If the private cloud platform is implemented as an employee management platform, the first business system can be implemented as the employee management platform in the private cloud.

[0108] It should be noted that the above examples of business scope configuration operations are only for illustrative purposes, and the embodiments of the present application do not limit the specific methods of business scope configuration operations. Optionally, the above private cloud version, private cloud platform and business component name can be randomly combined to configure the business scope to be searched, that is, different business components of different private cloud versions and different private cloud platforms can be specified. For example: the business scope configuration operation can also be simultaneously implemented as a configuration operation on the private cloud version and a configuration operation on the business component name, that is, the first business system is implemented as a specified business component under a specified private cloud version. Alternatively, the business scope configuration operation can also be simultaneously implemented as a configuration operation on the private cloud version and a configuration operation on the private cloud platform, that is, the first business system is implemented as a specified private cloud platform under a specified private cloud version.

[0109] Step 303, receiving a first configuration operation for a first package name in a package name configuration area; receiving a second configuration operation for at least one method name corresponding to the first package name in a method name configuration area, and using the first configuration operation and the second configuration operation as code search configuration operations.

[0110] The code search configuration operation is used to search the code file of the first business system for at least one program method that matches at least one method name corresponding to the first package name when a target code package matching the first package name is found in the code file of the first business system.

[0111] Optionally, the method name configuration area can be implemented as at least one of a method name input box, a method name selection box, etc., which is not limited in the embodiment of the present application.

[0112] Among them, the package name configuration area and the method name configuration area correspond one to one. Schematically, the first package name input box corresponds to the first method name input box. After entering the first package name in the first package name input box, you need to enter the method name corresponding to the first package name in the first method name input box.

[0113] The first configuration operation on the first package name (ie, the input operation or selection operation on the first package name) has been described in detail in step 202 and will not be repeated here.

[0114] In some embodiments, if the method name configuration area is implemented as a method name input box, an input operation of at least one method name corresponding to the first package name in the method name input box is received as the second configuration operation.

[0115] Optionally, after the developer enters at least one method name in the method name input box, the background of the target application will check the at least one method name in the input box. When it is checked that the at least one method name entered meets the method name condition, the at least one method name can be confirmed as the method name to be searched, that is: in response to receiving an input operation for at least one candidate method name in the method name input box, when the at least one candidate method name meets the method name condition, the at least one candidate method name entered is determined to be at least one method name.

[0116] Optionally, at least one candidate method name meeting the method name condition means that at least one candidate method name belongs to the method name of a program method encapsulated in the code package corresponding to the first package name.

[0117] In some embodiments, if the method name configuration area is implemented as a method name selection box, in response to receiving a drop-down operation on the method name selection box, a method name selection list is displayed, the method name selection list including the method names of the program methods encapsulated in the first package name; and a selection operation on at least one method name in the method name selection list is received as a second configuration operation on the at least one method name.

[0118] Optionally, multiple method names can be configured in the method name configuration area. If the method name configuration area is implemented as a method name input box, input operations for multiple method names in the method name input box are received as configuration operations for multiple method names. A single method name input box can input multiple method names, or a single method name input box can input a single method name.

[0119] If the method name configuration area is implemented as a method name selection box, a selection operation of multiple method names in the method name selection list is received as a second configuration operation for the multiple method names.

[0120] Illustratively, when a code search configuration operation is received in the search configuration interface, the background of the target application will search the code file of the first business system according to the first package name and at least one method name configured by the developer. If a package name consistent with the first package name is found, the code package corresponding to the package name is the target code package.

[0121] When the target code package is found, the background of the target application will search in the code file of the first business system according to at least one method name configured by the developer. If a method name consistent with at least one method name is found in the code related to the target code package, the program method corresponding to the method name is the program method.

[0122] Step 304, displaying a program method list based on the code search configuration operation.

[0123] The program methods displayed in the program method list are program methods configured in the package name configuration area and referenced in the target code package, that is, the program method list includes at least one program method.

[0124] Optionally, when a confirmation operation for the first package name and at least one program method is received, the background of the target application will search the code file of the first business system according to the first package name configured by the developer. If a package name consistent with the first package name is found, the code package corresponding to the package name is the target code package.

[0125] When the target code package is found, the background of the target application will search in the code file of the first business system according to at least one method name configured by the developer. If a target method name consistent with at least one method name is found in the code related to the target code package, the target method name will be displayed in the program method list.

[0126] Optionally, if a target method name consistent with at least one method name cannot be found in the code related to the target code package, a search prompt message is displayed in the search configuration interface. The search prompt message is used to prompt the developer that at least one method name referenced from the target code package cannot be found in the code file, that is, the program method corresponding to at least one method name referenced from the target code package is not used in the code file.

[0127] Optionally, in response to receiving a code search configuration operation, a search result overview interface is displayed.

[0128] The search result overview interface is used to display the statistical results of the code files corresponding to the first business system. The search result overview interface at least includes a warehouse quantity display area, a configuration information display area, and a statistical result display area.

[0129] The above-mentioned warehouse quantity display area is used to display the total number of warehouses to which the code packages found after searching for the code files corresponding to the first business system belong. The warehouse refers to a distributed version control system (Git), and one Git can include multiple version warehouses.

[0130] The configuration statistics result display area is used to display the first package name configured in the search configuration interface and at least one method name corresponding to the first package name.

[0131] The above-mentioned statistical result display area is used to display the result data obtained after searching the code file corresponding to the first business system based on the configuration corresponding to the code search configuration operation. The result data shows the code search result of a certain business component on a certain code package. The result data includes: the business component name, the searched code package name (i.e., the target code package name), the storage path of the code package, the warehouse corresponding to the code package, the inspection result of the code package, etc.

[0132] The code package inspection result can be implemented as a preview list of a program method list. Optionally, in response to a trigger operation on the code package inspection result, the program method list is displayed. The program method list is a complete list.

[0133] Step 305 , in response to receiving a selection operation on a target program method in at least one program method, displaying a code path list.

[0134] The code path list includes the storage path of the code that references the target program method in the code file.

[0135] Illustratively, the program method list includes at least one program method, and by selecting one of the program methods, the storage path of the code corresponding to the program method in the target file can be viewed.

[0136] Optionally, in response to receiving a selection operation on a target program method in at least one program method, the code path list is displayed in a pop-up window.

[0137] Alternatively, based on the code search configuration operation, a program method list is displayed on the left side of the search result interface; in response to receiving a selection operation for a target program method in at least one program method, a code path list is displayed on the right side of the search result interface.

[0138] It should be noted that the embodiment of the present application does not limit the display format of the program method list and the code path list.

[0139] Optionally, the code path list may display multiple paths corresponding to a single program method, that is, a program method in a certain code package is referenced by code files corresponding to multiple business components.

[0140] In summary, the method for obtaining code content provided by the embodiment of the present application receives the code search configuration operation for the business system in the search configuration interface, batch configures the package name of the code package to be searched, and when the configured package name matches the target code name in the business system, displays at least one program method referenced in the target code package in the program method list, and based on the selection operation of the target program method, displays the storage path of the target program method in the code file. Developers can use the code search configuration operation in the search configuration interface to batch count the usage of code packages in the code files corresponding to the business system, that is, which program methods in the code package are referenced and the storage path of the referenced program methods, so that developers can quickly and accurately count the usage of each code package, and improve the work efficiency of counting code packages in the business system; at the same time, the usage of the code package is visualized through the program method list and the code path list, and the usage of each code package in the code file corresponding to the business system is more intuitively and clearly displayed, which improves the human-computer interaction efficiency of displaying statistical results of the code package.

[0141] The method provided in the embodiment of the present application can configure the search scope corresponding to the code search configuration operation in the search configuration interface, that is, the target application can perform code search within the business scope specified by the business personnel, and can increase the flexibility in the code search process for business codes by configuring the business scope with different conditional information.

[0142] The method provided in the embodiment of the present application can batch configure the package names and corresponding method names of the code packages to be searched in the search configuration interface, that is, the developer can freely configure the code packages and methods that need to be counted, thereby reducing the scope of the final code path list and providing the developer with a more targeted statistical result.

[0143] For illustration, please refer to Figure 4 , which shows a schematic diagram of an operation for counting business codes in a private cloud scenario, such as Figure 4 As shown, the search configuration interface 410 includes a business scope configuration area, including: a private cloud version selection box 411, a private cloud platform selection box 412, and a business component input box 413. Optionally, the private cloud version selection box 411 is a required item, and the private cloud platform selection box 412 and the business component input box 413 are optional items, that is, the code statistics scope can be limited by only filling in the private cloud version. Schematically, the version number "TCE3.8.0" is selected in the private cloud version selection box 411, that is, the code of the business system included in the private cloud with the version number "TCE3.8.0" is counted.

[0144] The search configuration interface 410 also includes multiple package name input boxes and multiple method name input boxes, wherein the package name input box 414 corresponds to the method name input box 415, that is, the package name "tce-sdk" is entered in the package name input box 414, and the method name "Language" of the program method encapsulated in the code package with the package name "tce-sdk" is entered in the method name input box 415.

[0145] After configuring the business scope, package name and method name, click the "Initiate Check" control 416. The background will check the code files within the business scope. After the check, the search result overview interface 420 will be displayed. The search result overview interface 420 includes: NPM package repository quantity display area 421, NPM package configuration information display area 422 and statistical result display list 423.

[0146] Among them, 2 warehouses are displayed in the NPM package warehouse quantity display area 421, indicating that the total number of warehouses to which the found code package belongs is 2; the NPM package configuration information display area 422 displays the package name and method name configured in the search configuration interface 410; the statistical result display list 423 displays the result data obtained after searching the code files within the business scope in the form of a list.

[0147] Each row in the statistical result display list 423 represents the code search result of a code package in a component. The result data includes: component name, check configuration (i.e., the name of the code package found), NPM package check result, Git (i.e., the Git repository version), creation time (i.e., the time of downloading the NPM package to the business system), update time (i.e., the time of updating the content in the NPM package), etc.

[0148] Among them, the NPM package check result is used to preview the first few found method names (i.e. the preview interface of the program method list). Schematically, clicking the NPM package check result will expand the complete and detailed program method list.

[0149] For illustration, please refer to Figure 5 , which shows a schematic diagram of displaying a program method list, such as Figure 5 As shown, the left area of ​​the result details interface 500 displays the program method list 510 of the code package “tce-component”, and the right area is used to display the code path list corresponding to the selected program method “Modal” in the program method list 510 .

[0150] In some optional embodiments, the background service of the code search function is implemented through the terminal. Figure 6 is a flowchart of a method for obtaining code content provided by an embodiment of the present application, and the method is applied to Figure 1Taking the terminal shown in FIG. 1 as an example, the method includes:

[0151] Step 601, display the search configuration interface.

[0152] The above search configuration interface includes a business scope configuration area, a package name configuration area, and a method name configuration area.

[0153] Among them, the business scope configuration area is used to configure the business system to be searched; the package name configuration area is used to batch configure the package names of the code packages to be searched; and the method name configuration area is used to batch configure the method names of the program methods to be searched.

[0154] Step 602: Receive a business scope configuration operation in a business scope configuration area.

[0155] The business scope configuration operation is used to determine that the business system to be found is the first business system.

[0156] In an illustrative example, the business system to be found is implemented as a business system in a private cloud, and the private cloud version and business component name are configured, that is, the first business system is implemented as a specified business component under a specified private cloud version. Alternatively, the private cloud version and private cloud platform are configured, that is, the first business system is implemented as a specified private cloud platform under a specified private cloud version.

[0157] Step 603, receiving a first configuration operation for a first package name in a package name configuration area; receiving a second configuration operation for at least one method name corresponding to the first package name in a method name configuration area, and using the first configuration operation and the second configuration operation as code search configuration operations.

[0158] The code search configuration operation is used to search the code file of the first business system for at least one program method that matches at least one method name corresponding to the first package name when a target code package matching the first package name is found in the code file of the first business system.

[0159] Step 604: In response to the code search configuration operation, an abstract syntax tree corresponding to the code file is generated according to the code syntax structure corresponding to the code file.

[0160] Optionally, the code content corresponding to the code file is analyzed by a preset algorithm or model such as a lexical analyzer, a syntax analyzer, a syntax tree generator, etc., and an abstract syntax tree corresponding to the code file is generated.

[0161] The abstract syntax tree is an abstract representation of the code structure, which shows the grammatical structure of the code in the form of a tree. Each node in the tree represents a structure in the code.

[0162] Schematically, the code content corresponding to the code file is analyzed through the ESLint plug-in, and an abstract syntax tree corresponding to the code file is generated. The ESLint plug-in is a customizable Lint tool. Specific syntax rules are set in the ESLint plug-in to perform syntax checking on the business code of the target business. The code file can be parsed according to the code syntax structure corresponding to the code file through the syntax analyzer to obtain the abstract syntax tree corresponding to the code file.

[0163] Optionally, in response to the code search configuration operation, a code file corresponding to the first business system is obtained from a code repository, the code repository being used to store codes related to the first business system; and an abstract syntax tree corresponding to the code file is generated according to a code syntax structure corresponding to the code file.

[0164] Illustratively, after receiving a configuration operation on the business scope, the first package name, and at least one method name corresponding to the first package name in the search configuration interface, a search request for the code file of the first business system is triggered; or, after receiving a configuration operation on the business scope, the first package name, and at least one method name corresponding to the first package name in the search configuration interface, a search request for the code file of the first business system is triggered by triggering a request search control.

[0165] Optionally, the search request includes configuration information, which is the business scope, the first package name, and at least one method name corresponding to the first package name. Schematically, after the terminal detects the search request, it first determines that the business system to be searched is the first business system based on the business scope corresponding to the search request; secondly, the terminal obtains the code file corresponding to the first business system from the Git repository; then, the terminal calls the ESLint plug-in to convert the code file into an abstract syntax tree corresponding to the code file.

[0166] Step 605: traverse the abstract syntax tree, and in the traversal process, obtain the package name contained in the import statement corresponding to the import statement node in the abstract syntax tree.

[0167] The import statement is used to import the code package in the public code management platform into the code file.

[0168] Indicatively, the nodes of the abstract syntax tree are traversed, and if the node represents an import statement in a code file, the package name variable in the node is obtained, that is, the package name contained in the import statement corresponding to the import statement node is obtained.

[0169] Step 606: In response to the first package name successfully matching the package name of the target code package in the import statement, obtaining at least one program method referenced by the code file from the target code package.

[0170] Indicatively, after the traversal of the abstract syntax tree is completed, multiple package names can be obtained. If the package name of the target code package is exactly the same as the first package name among the multiple package names, it means that the first package name matches the package name of the target code package in the import statement successfully.

[0171] After the first package name successfully matches the package name of the target code package in the import statement, it is also necessary to obtain the usage of at least one program method applied in the target code package in the code file.

[0172] Optionally, perform syntax analysis on the abstract syntax tree to determine multiple syntax scopes corresponding to the code file, where the syntax scope refers to the code range in which a specified code element in the code file is effective; convert the code file into a target string based on the multiple syntax scopes corresponding to the code file; perform regular expression matching on the target string to obtain at least one program method referenced by the code file from the target code package.

[0173] In JavaScript, a specified code element can be an expression, statement, batch statement, function, etc., and multiple grammatical scopes include expression scope, statement scope, batch statement scope, function scope, etc. Wherein, an expression is a formula composed of at least one operator, for example: "typeof()", then the expression scope is the code block in "()"; statements are in the form of "for()", "while()", etc., and the statement scope is the code block in "()"; batch statements are in the form of "catch{}", "catch{}", etc., and the batch statement scope is the code block in "{}"; the code block declared by a function is the function scope.

[0174] Optionally, according to the multiple grammar scopes corresponding to the code file, the method of converting the code file into a target string includes at least one of the following situations:

[0175] 1. Convert all codes in the code file into target strings.

[0176] Optionally, according to multiple grammatical scopes corresponding to the code file, the code content corresponding to the code file is segmented to obtain code snippets corresponding to the multiple grammatical scopes respectively; and the code snippets corresponding to the multiple grammatical scopes respectively are converted into target strings.

[0177] Optionally, the target string is implemented as substrings corresponding to multiple grammatical scopes respectively; based on the first package name and at least one method name, regular matching is performed on the substrings corresponding to the multiple grammatical scopes respectively; if a substring contains both the package name of the target code package and a specified method name in at least one method name, the program method corresponding to the specified method name belongs to at least one program method referenced from the target code package; optionally, combined data of the specified method name + the package name of the target code package + the file storage path corresponding to the substring is obtained.

[0178] 2. Convert the code containing the target code package name in the code file into a target string.

[0179] Optionally, according to multiple syntax scopes corresponding to the code file, the code content corresponding to the code file is segmented to obtain code snippets corresponding to the multiple syntax scopes respectively; and the code snippet containing the package name of the target code package is converted into a target string.

[0180] Optionally, a regular expression match is performed on the target string based on at least one method name. If the target string contains a specified method name among at least one method name, the program method corresponding to the specified method name belongs to at least one program method referenced from the target code package. Optionally, combined data of the specified method name + the package name of the target code package + the file storage path corresponding to the target string is obtained.

[0181] 3. Convert the code in the code file containing the method names of all methods exported from the target code package to the target String.

[0182] Optionally, according to multiple syntax scopes corresponding to the code file, the code content corresponding to the code file is segmented to obtain code snippets corresponding to the multiple syntax scopes respectively; and the code snippet containing the method names of all methods exported from the target code package is converted into a target string.

[0183] Optionally, a regular expression match is performed on the target string based on at least one method name. If the target string contains a specified method name among at least one method name, the program method corresponding to the specified method name belongs to at least one program method referenced from the target code package. Optionally, combined data of the specified method name + the package name of the target code package + the file storage path corresponding to the target string is obtained.

[0184] 4. Convert the code in the code file containing the method name of the configuration method exported from the target code package to the target String.

[0185] Optionally, according to multiple syntax scopes corresponding to the code file, the code content corresponding to the code file is segmented to obtain code snippets corresponding to the multiple syntax scopes respectively; and the code snippet containing the method name of the configuration method exported from the target code package is converted into a target string.

[0186] The configuration method is a method included in at least one method name configured through a code search configuration operation.

[0187] Optionally, a regular expression match is performed on the target string based on at least one method name to obtain a specified method name in the target string that matches at least one method name, and the program method corresponding to the specified method name belongs to at least one program method referenced from the target code package; optionally, combined data of the specified method name + the package name of the target code package + the file storage path corresponding to the target string is obtained.

[0188] 5. Convert the code containing the target code package name in the code file into a target string.

[0189] Optionally, the target code package corresponds to a key method library, which includes method names of multiple key program methods. The key program method refers to a program method whose number of citations reaches a preset number threshold.

[0190] Illustratively, the public code management platform records the number of times each method in each code package is cited within a specified historical time period. If the number of times a program method in a code package is cited reaches a preset threshold, the program method is added to the key method library of the code package.

[0191] Alternatively, the business system records the number of times each method in the code package configured therein is referenced. If the number of times a program method in a code package is referenced within the business system reaches a preset threshold, the program method is added to the key method library of the code package.

[0192] Optionally, according to multiple syntax scopes corresponding to the code file, the code content corresponding to the code file is segmented to obtain code snippets corresponding to the multiple syntax scopes respectively; and the code snippet containing the method name of the key program method is converted into a target string.

[0193] Optionally, a regular expression match is performed on the target string based on at least one method name. If the target string contains a specified method name among at least one method name, the program method corresponding to the specified method name belongs to at least one program method referenced from the target code package. Optionally, combined data of the specified method name + the package name of the target code package + the file storage path corresponding to the target string is obtained.

[0194] Step 607: Display a list of program methods based on at least one program method.

[0195] Illustratively, a method name corresponding to at least one program method is displayed in a program method list corresponding to the target code package.

[0196] Step 608 , in response to receiving a selection operation on a target program method in at least one program method, displaying a code path list.

[0197] The code path list includes the storage path of the code that references the target program method in the code file.

[0198] Illustratively, the program method list includes at least one program method, and by selecting one of the program methods, the storage path of the code corresponding to the program method in the target file can be viewed.

[0199] Optionally, in response to receiving a selection operation on a target program method in at least one program method, the code path list is displayed in a pop-up window.

[0200] Alternatively, based on the code search configuration operation, a program method list is displayed on the left side of the search result interface; in response to receiving a selection operation for a target program method in at least one program method, a code path list is displayed on the right side of the search result interface.

[0201] It should be noted that the embodiment of the present application does not limit the display format of the program method list and the code path list.

[0202] The code path list corresponding to the target program method includes the file storage path in the combined data corresponding to the target program method.

[0203] Optionally, the code path list may display multiple paths corresponding to a single program method, that is, a program method in a certain code package is referenced by code files corresponding to multiple business components.

[0204] In some embodiments, after obtaining the usage of the program methods in the target code package in the first business system, redundancy analysis, full transformation, code migration, etc. can be performed on the code files of the first business system.

[0205] Optionally, taking redundancy analysis of a code file of a first business system as an example, obtaining code corresponding to at least one program method in the code file; performing code redundancy analysis on the code corresponding to at least one program method to determine redundant code segments of the code corresponding to at least one program method; and deleting the redundant code segments from the code file.

[0206] In summary, the method for obtaining code content provided by the embodiment of the present application receives the code search configuration operation for the business system in the search configuration interface, batch configures the package name of the code package to be searched, and when the configured package name matches the target code name in the business system, displays at least one program method referenced in the target code package in the program method list, and based on the selection operation of the target program method, displays the storage path of the target program method in the code file. Developers can use the code search configuration operation in the search configuration interface to batch count the usage of code packages in the code files corresponding to the business system, that is, which program methods in the code package are referenced and the storage path of the referenced program methods, so that developers can quickly and accurately count the usage of each code package, and improve the work efficiency of counting code packages in the business system; at the same time, the usage of the code package is visualized through the program method list and the code path list, and the usage of each code package in the code file corresponding to the business system is more intuitively and clearly displayed, which improves the human-computer interaction efficiency of displaying statistical results of the code package.

[0207] The method provided in the embodiment of the present application traverses the abstract syntax tree composed of the code files corresponding to the business system, determines the target code package that matches the first package name, and thus obtains the usage of the target code package in the business system; wherein, by accurately locating the import statement of the code package, the usage of the code package in the business system is accurately counted.

[0208] The method provided in the embodiment of the present application, after finding and obtaining the target code package, also performs syntax analysis on the abstract syntax tree, and counts the program methods introduced by the target code package in the syntax scope corresponding to the code file, thereby improving the accuracy of the statistics on the target code package.

[0209] The method provided in the embodiment of the present application segments the code content corresponding to the code file according to the multiple grammatical scopes corresponding to the code file, obtains the code fragments corresponding to the multiple grammatical scopes, and converts the code fragment containing the package name of the target code package into a target string. By performing method search on the target string, the efficiency of statistics on the target code package is improved.

[0210] The method provided in the embodiment of the present application segments the code content corresponding to the code file according to the multiple grammatical scopes corresponding to the code file, and obtains code fragments corresponding to the multiple grammatical scopes respectively; converts the code fragment containing the method name of the key program method into a target string, and further improves the efficiency of statistics on the target code package by performing method search on the string containing only the key program method.

[0211] For illustration, please refer to Figure 7, which shows an interactive schematic diagram of a method for obtaining code content, such as Figure 7 As shown:

[0212] The execution subject of the code content acquisition method provided in the embodiment of the present application can be implemented as a target terminal, on which a detection platform 701 (that is, the target application mentioned above) is installed, and the detection platform 701 provides a code search function; the target terminal is also equipped with a private cloud system 702 and a continuous integration (CI) / continuous delivery, continuous deployment (CD / Continuous Deployment, CD) platform 703; the target terminal is also installed with a detection script 704.

[0213] Among them, CI / CD refers to the transformation of manual intervention in a series of processes such as code building, testing, deployment, and infrastructure configuration in the traditional business development process into automation. With CI / CD, after the code is changed by the developer, it can be automatically tested and delivered and deployed. The appropriate CI / CD pipeline (CI / CD pipeline is a series of steps) can minimize computer downtime and release code faster. Optionally, the CI / CD platform 703 can trigger automated code checking of the code files corresponding to the business system.

[0214] In schematic form, the public code management platform is implemented as NPM as an example. When a developer needs to find the usage of some NPM packages in a certain business, the method for obtaining the usage of NPM packages in the business code of the specified business mainly includes the following steps:

[0215] The first step is to configure the business scope on the search configuration interface in the detection platform 701.

[0216] Optionally, after configuring the private cloud version in the detection platform 701, the business to be tested can be screened by configuring the private cloud platform or directly specifying a specific business component name; at the same time, the package name of the NPM package to be tested and the method name of the internal method of the package can also be configured in the detection platform 701 for checking within the specified range of business. Optionally, after the developer has configured the package name of the NPM package to be tested and the method name of the internal method of the package, the scanning configuration can be saved for subsequent use, or the inspection can be directly initiated.

[0217] In the second step, after the developer initiates the inspection, the detection platform 701 initiates a request to the private cloud system 702. After receiving the request, the private cloud system 702 will screen the business according to the business scope configured by the developer in the detection platform 701, determine the target business, and trigger the CI / CD platform 703 bound to the target business to perform the inspection.

[0218] In the third step, when the CI / CD platform 703 receives the request, it will pull the business code of the target business according to the Git repository address corresponding to the target business, and inject the environment variables corresponding to the business code into the detection script 704 after pulling.

[0219] In the fourth step, the detection script 704 performs detection.

[0220] In the fifth step, the detection script 704 encapsulates the output data (ie, the inspection result data of the target business) and sends it to the backend server 705 . The backend server 705 counts the inspection result data in real time and returns the inspection result data to the detection platform 701 .

[0221] Optionally, the backend server 705 will integrate the currently received data in real time (i.e., the backend server 705 will receive the inspection result data sent by multiple terminals, or the backend server 705 will receive the inspection result data of different services from the same terminal), and store the overall situation after the inspection and the specific data of each service of the detected package in the database. Among them, the corresponding query interface can be called on the detection platform 701 to query the usage of the NPM package in the service code that has been inspected in real time.

[0222] For the fourth step above, the specific steps of the detection script 704 to perform the detection are as follows: Figure 8 As shown:

[0223] S801: The CI / CD platform 703 calls the detection script 704.

[0224] Illustratively, after the test process corresponding to the CI / CD platform 703 is triggered, the detection script 704 corresponding to the target business is called, wherein the script is an executable file written in a certain format using a specific descriptive language, and the detection script 704 is an executable file used to detect the usage of the NPM package in the target business.

[0225] S802: Assemble a scan catalog of the target business according to the information transmitted by the private cloud system 702.

[0226] Since the business code directory of each business is customized by the developer, it is necessary to obtain business-related information transmitted from the private cloud system 702 from the CI / CD platform 703, such as: business component information (business component name, component corresponding code, etc.), assembly environment information (hardware parameters, software parameters, etc.), and assemble the directory to be scanned according to the business-related information; after assembling the directory to be scanned, call the ESLint plug-in customized by the developer to scan the business code of the target business.

[0227] S803: Request the backend interface to obtain the configured package name according to the service ID and version of the target service.

[0228] Illustratively, the detection script 704 obtains the name of the business component in the business code of the target business (i.e., the business ID of the target business) and the private cloud version (i.e., version) corresponding to the business component based on the environment variables injected from the CI / CD platform 703; calls the back-end interface through the business ID and version of the target business, and obtains the package name of the NPM package to be detected currently configured in the business code and the method name of the internal method of the package through the back-end interface.

[0229] Optionally, after obtaining the package name of the NPM package to be detected and the method name of the internal method of the package, this part of data is stored in a configuration file for subsequent scanning.

[0230] S804: Call the plug-in, read the scanning configuration through the plug-in and scan the import statements of all js files and ts (typescript) files.

[0231] Schematically, the ESLint plug-in is called. The ESLint plug-in first reads the scanning configuration in the first step, obtains the package name of the NPM package to be detected in the scanning configuration and the method name of the internal method of the package; then, the ESLint plug-in scans the import statements of the NPM packages of all js and ts files, and converts the js and ts files into an abstract syntax tree through the ESLint plug-in; then, traverses the abstract syntax tree to obtain the package name in the import statement of the NPM package.

[0232] S805: Determine whether the package name in the import statement is in the configuration file.

[0233] Illustratively, it is determined whether the package names in the import statements of all NPM packages obtained by traversal are in the configuration file obtained in S803.

[0234] S806: If the package name in the import statement is not in the configuration file, skip it.

[0235] Illustratively, if the package names in the import statements of all traversed NPM packages are not in the configuration file obtained in S803, it means that the business code of the target business does not use the NPM package that the developer needs to detect, and the target business can be skipped.

[0236] S807: If the package name in the import statement is in the configuration file, the formatted string is output to the process stdout.

[0237] Illustratively, if the target package name in the import statement of the traversed NPM package is in the configuration file obtained in S803, it means that the target NPM package corresponding to the target package name that the developer needs to detect is used in the business code of the target business. Then the abstract syntax tree can be traversed again to parse and obtain multiple grammatical scopes of the business code of the target business.

[0238] After obtaining multiple syntax scopes, search for methods exported from the target NPM package in each syntax scope (each syntax scope corresponds to a syntax fragment). If a syntax scope contains a method exported from the target NPM package, the code fragment corresponding to the syntax scope is output to the standard output of this ESLint plug-in scanning process in the form of a string.

[0239] S808: The detection script 704 obtains the process output and parses the relevant information.

[0240] Illustratively, after the detection script 704 obtains the standard output of the process in S807, it performs regular matching on the string in the standard output according to the target package name, obtains the output package name, method name and the file storage path of the code corresponding to the method name, and assembles the parsed results.

[0241] S809: After the detection script 704 is parsed, it is sent to the backend server 705.

[0242] Illustratively, after the detection script 704 parses and assembles the output package name, method name, and the file storage path of the code corresponding to the method name, the assembled information is sent to the backend server 705 .

[0243] Please refer to Fig. 9 , which shows a structural block diagram of a device for acquiring code content provided by an exemplary embodiment of the present application, the device includes the following modules:

[0244] A display module 900 is used to display a search configuration interface, wherein the search configuration interface includes a package name configuration area, and the package name configuration area is used to batch configure the package names of the code packages to be searched;

[0245] A receiving module 910 is used to receive a code search configuration operation for a first business system in the search configuration interface, wherein the code search configuration operation includes configuring a first package name in the package name configuration area, wherein the first package name is a package name of a code package stored in a public code management platform, and the code search configuration operation is used to search a code file of the first business system for a target code package that matches the first package name, wherein the target code package is a code package imported from the public code management platform;

[0246] The display module 900 is further configured to display a program method list based on the code search configuration operation, wherein the program method list includes at least one program method referenced in the target code package;

[0247] The display module 900 is further configured to display a code path list in response to receiving a selection operation on a target program method in the at least one program method, wherein the code path list includes a storage path in the code file of the code that references the target program method.

[0248] For illustration, please refer to Fig.10 In some embodiments, the search configuration interface includes a method name configuration area, and the method name configuration area is used to batch configure the method names of the program methods to be searched, and the code search configuration operation also includes the configuration of at least one method name corresponding to the first package name in the method name configuration area; the receiving module 910 is also used to receive a first configuration operation on the first package name in the package name configuration area; the receiving module 910 is also used to receive a second configuration operation on at least one method name corresponding to the first package name in the method name configuration area, and use the first configuration operation and the second configuration operation as the code search configuration operation; wherein, the code search configuration operation is used to search for at least one program method that matches at least one method name corresponding to the first package name in the code file of the first business system when a target code package matching the first package name is found in the code file of the first business system.

[0249] In some embodiments, the search configuration interface also includes a business scope configuration area, which is used to configure the business system to be searched; the receiving module 910 is also used to receive a business scope configuration operation in the business scope configuration area, and the business scope configuration operation is used to determine that the business system to be searched is the first business system.

[0250] In some embodiments, the first business system is a business system in a private cloud; the receiving module 910 is further used to receive configuration operations on the private cloud version in the business scope configuration area, and use the configuration operations on the private cloud version as the business scope configuration operations.

[0251] In some embodiments, the display module 900 is further configured to display a code snippet corresponding to the at least one program method in response to receiving a trigger operation on the storage path in the code path list.

[0252] In some embodiments, the display module 900 includes:

[0253] A generating unit 901 is used to generate an abstract syntax tree corresponding to the code file according to a code syntax structure corresponding to the code file in response to the code search configuration operation;

[0254] A traversal unit 902, configured to traverse the abstract syntax tree;

[0255] An acquisition unit 903 is used to acquire, during the traversal process, a package name contained in an import statement in the code file corresponding to an import statement node in the abstract syntax tree, wherein the import statement is used to import a code package in the public code management platform in the code file;

[0256] The acquiring unit 903 is configured to acquire at least one program method referenced from the target code package in response to the first package name successfully matching the package name of the target code package in the import statement;

[0257] The display module 900 is further configured to display at least one program method referenced from the target code package in the program method list.

[0258] In some embodiments, the acquisition unit 903 is used to perform syntax analysis on the abstract syntax tree to determine multiple syntax scopes corresponding to the code file, where the syntax scope refers to the code range in which a specified code element in the code file is effective; the acquisition unit 903 is used to convert the code file into a target string according to the multiple syntax scopes corresponding to the code file; the acquisition unit 903 is used to perform regular matching on the target string to obtain at least one program method referenced by the code file from the target code package, where the regular matching is used to determine a string segment in the target string that matches the target code package.

[0259] In some embodiments, the acquisition unit 903 is used to segment the code content corresponding to the code file according to the multiple grammatical scopes corresponding to the code file, and obtain code fragments corresponding to the multiple grammatical scopes respectively; the acquisition unit 903 is used to convert the code fragment containing the package name of the target code package into the target string.

[0260] In some embodiments, the target code package corresponds to a key method library, which includes method names of multiple key program methods, and the key program method refers to a program method whose number of citations reaches a preset threshold; the acquisition unit 903 is used to segment the code content corresponding to the code file according to multiple grammatical scopes corresponding to the code file, and obtain code snippets corresponding to the multiple grammatical scopes respectively; the acquisition unit 903 is used to convert the code snippet containing the method name of the key program method into the target string.

[0261] In summary, the code content acquisition device provided by the embodiment of the present application receives the code search configuration operation for the business system in the search configuration interface, batch configures the package name of the code package to be searched, and when the configured package name matches the target code name in the business system, displays at least one program method referenced in the target code package in the program method list, and based on the selection operation of the target program method, displays the storage path of the target program method in the code file. Developers can use the code search configuration operation in the search configuration interface to batch count the usage of code packages in the code files corresponding to the business system, that is, which program methods in the code package are referenced and the storage path of the referenced program methods, so that developers can quickly and accurately count the usage of each code package, and improve the work efficiency of counting code packages in the business system; at the same time, the usage of the code package is visualized through the program method list and the code path list, and the usage of each code package in the code file corresponding to the business system is more intuitively and clearly displayed, which improves the human-computer interaction efficiency of displaying statistical results of the code package.

[0262] It should be noted that the device for acquiring code content provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device for acquiring code content and the method for acquiring code content provided in the above embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0263] Fig.11 The block diagram of a computer device 1100 provided by an exemplary embodiment of the present application is shown. The computer device 1100 may be: a smart phone, a tablet computer, a Moving Picture Experts Group Audio Layer III (MP3) player, a Moving Picture Experts Group Audio Layer IV (MP4) player, a laptop computer or a desktop computer. The computer device 1100 may also be called a user device, a portable computer device, a laptop computer device, a desktop computer device, or other names.

[0264] Typically, the computer device 1100 includes a processor 1101 and a memory 1102 .

[0265] The processor 1101 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1101 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 1101 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1101 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1101 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.

[0266] The memory 1102 may include one or more computer-readable storage media, which may be non-transitory. The memory 1102 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1102 is used to store at least one instruction, which is used to be executed by the processor 1101 to implement the method for obtaining code content provided in the method embodiment of the present application.

[0267] Illustratively, the computer device 1100 also includes other components, which can be understood by those skilled in the art. Fig.11 The structure shown in the figure does not constitute a limitation on the computer device 1100, and the computer device 1100 may include more or less components than shown in the figure, or combine some components, or adopt a different component arrangement.

[0268] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the relevant hardware through a program, and the program can be stored in a computer-readable storage medium, which can be a computer-readable storage medium contained in the memory in the above embodiments; or a computer-readable storage medium that exists independently and is not assembled into a computer device. The computer-readable storage medium stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, the at least one program, the code set or instruction set is loaded and executed by the processor to implement the method for obtaining the code content described in any of the above embodiments.

[0269] Optionally, the computer readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a solid state drive (SSD), or an optical disk. Among them, the random access memory may include a resistance random access memory (ReRAM) and a dynamic random access memory (DRAM). The serial numbers of the above embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.

[0270] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0271] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for obtaining code content, characterized in that: The method comprises: Displaying a search configuration interface, wherein the search configuration interface includes a package name configuration area, wherein the package name configuration area is used to batch configure the package names of the code packages to be searched; Receiving a code search configuration operation for a first business system in the search configuration interface, the code search configuration operation including configuration of a first package name in the package name configuration area, the first package name being the package name of a code package stored in a public code management platform, the code search configuration operation being used to search a target code package matching the first package name in a code file of the first business system, the target code package being a code package imported from the public code management platform; Displaying a program method list based on the code search configuration operation, wherein the program method list includes at least one program method referenced in the target code package; In response to receiving a selection operation of a target program method in the at least one program method, a code path list is displayed, the code path list including a storage path in the code file of a code that references the target program method.

2. The method according to claim 1, characterized in that The search configuration interface includes a method name configuration area, the method name configuration area is used to batch configure the method names of the program methods to be searched, and the code search configuration operation also includes configuring at least one method name corresponding to the first package name in the method name configuration area; The receiving of a code search configuration operation for the first business system in the search configuration interface includes: receiving a first configuration operation on a first package name in the package name configuration area; receiving a second configuration operation for at least one method name corresponding to the first package name in the method name configuration area, and using the first configuration operation and the second configuration operation as the code search configuration operation; Among them, the code search configuration operation is used to search for at least one program method matching at least one method name corresponding to the first package name in the code file of the first business system when a target code package matching the first package name is found in the code file of the first business system.

3. The method according to claim 1, characterized in that: The search configuration interface also includes a business scope configuration area, and the business scope configuration area is used to configure the business system to be searched; Before receiving the code search configuration operation for the first business system in the search configuration interface, the method further includes: A business scope configuration operation is received in the business scope configuration area, where the business scope configuration operation is used to determine that the business system to be found is the first business system.

4. The method according to claim 3, characterized in that The first business system is a business system in a private cloud; The receiving of a service scope configuration operation in the service scope configuration area includes: A configuration operation on a private cloud version is received in the business scope configuration area, and the configuration operation on the private cloud version is used as the business scope configuration operation.

5. The method according to any one of claims 1 to 4, characterized in that: After the code path list is displayed in response to receiving a selection operation of a target program method in the at least one program method, the method further includes: In response to receiving a trigger operation on the storage path in the code path list, a code snippet corresponding to the at least one program method is displayed.

6. The method according to any one of claims 1 to 4, characterized in that: The method of displaying a program method list based on the code search configuration operation includes: In response to the code search configuration operation, generating an abstract syntax tree corresponding to the code file according to a code syntax structure corresponding to the code file; Traversing the abstract syntax tree; During the traversal process, obtaining a package name contained in an import statement corresponding to an import statement node in the abstract syntax tree, wherein the import statement is used to import a code package in the public code management platform into the code file; In response to the first package name successfully matching the package name of the target code package in the import statement, obtaining at least one program method referenced from the target code package; At least one program method referenced from the object code package is displayed in the program method list.

7. The method according to claim 6, characterized in that The obtaining of at least one program method referenced by the code file from the target code package comprises: Performing syntax analysis on the abstract syntax tree to determine a plurality of syntax scopes corresponding to the code file, wherein the syntax scope refers to a code range in which a specified code element in the code file is effective; According to a plurality of grammatical scopes corresponding to the code file, converting the code file into a target string; Regular matching is performed on the target string to obtain at least one program method referenced by the code file from the target code package, wherein the regular matching is used to determine a string segment in the target string that matches the target code package.

8. The method according to claim 7, characterized in that The converting the code file into a target string according to the multiple grammar scopes corresponding to the code file includes: According to the multiple grammatical scopes corresponding to the code file, the code content corresponding to the code file is segmented to obtain code snippets corresponding to the multiple grammatical scopes respectively; The code fragment including the package name of the target code package is converted into the target string.

9. The method according to claim 7, characterized in that: The target code package corresponds to a key method library, the key package library includes method names of multiple key program methods, and the key program method refers to a program method whose number of citations reaches a preset number threshold; According to the multiple grammar scopes corresponding to the code file, the code file is converted into a target string, including: According to the multiple grammatical scopes corresponding to the code file, the code content corresponding to the code file is segmented to obtain code snippets corresponding to the multiple grammatical scopes respectively; A code snippet including the method name of the key program method is converted into the target string.

10. A device for acquiring code content, characterized in that: The device comprises: A display module, used to display a search configuration interface, wherein the search configuration interface includes a package name configuration area, and the package name configuration area is used to batch configure the package names of the code packages to be searched; a receiving module, configured to receive a code search configuration operation for a first business system in the search configuration interface, wherein the code search configuration operation includes configuration of a first package name in the package name configuration area, wherein the first package name is a package name of a code package stored in a public code management platform, and the code search configuration operation is used to search a code file of the first business system for a target code package that matches the first package name, wherein the target code package is a code package imported from the public code management platform; The display module is further used to display a program method list based on the code search configuration operation, wherein the program method list includes at least one program method referenced in the target code package; The display module is further configured to display a code path list in response to receiving a selection operation on a target program method in the at least one program method, wherein the code path list includes a storage path in the code file of a code that references the target program method.

11. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the method for obtaining code content as described in any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the method for obtaining code content as described in any one of claims 1 to 9.

13. A computer program product, characterized in that It comprises computer instructions, which, when executed by a processor, implement the method for obtaining code content as described in any one of claims 1 to 9.