Component data statistics method and device

By converting the source code into an abstract syntax tree and identifying the reference node, the accuracy of component reference statistics is solved, and more accurate component reference counting is achieved, which improves the reliability of component maintenance and reduces redundant code.

CN114492324BActive Publication Date: 2024-12-06INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210117694.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-28
Publication Date
2024-12-06
Estimated Expiration
2042-01-28

AI Technical Summary

Technical Problem

In the prior art, the statistical accuracy of component citations is low, and the code and annotations cannot be distinguished, resulting in a deviation from the actual situation.

Method used

By converting the source code into an abstract syntax tree, identifying reference nodes and uniquely identifying statistical references based on the component, distinguishing explicit and implicit reference nodes, improving statistics accuracy.

Benefits of technology

Improves the accuracy of component reference count statistics, provides an accurate data basis for subsequent component maintenance, enhances maintenance reliability, and reduces redundant code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114492324B_ABST
    Figure CN114492324B_ABST
Patent Text Reader

Abstract

The present application provides a component data statistics method and device, which can be used in the financial field or other fields, the method comprising: obtaining a target source code text, the target source code text comprising: multiple code statements, wherein there is a code statement containing a component unique identifier among the multiple code statements; converting the target source code text into an abstract syntax tree; identifying a reference node from the abstract syntax tree, wherein the reference node is provided with a corresponding component unique identifier; and obtaining a reference count statistical result of the component corresponding to the component unique identifier according to the component unique identifier corresponding to the reference node. The present application can improve the accuracy of the reference count statistics of a component, provide an accurate data basis for subsequent component maintenance, and improve the reliability of component maintenance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a component data statistics method and device. Background Art

[0002] In the front-end field of large companies, a dedicated team usually maintains a component library for use by various projects within the company, so as to reduce project maintenance costs while ensuring consistency in the style of each project.

[0003] During project maintenance, the dedicated team needs to understand the references of component libraries in various projects to facilitate the formulation of subsequent improvement and maintenance plans. The current practice is to treat the code as ordinary text for static scanning, and find characteristic code fragments through regular matching for statistics.

[0004] The regular matching method of code text has obvious disadvantages: it cannot identify the meaning of characteristic code snippets in actual projects, resulting in statistical errors. For example, the regular matching method cannot distinguish between code and comments, and will also match the characteristic snippets in the comments and count them in the final result, causing the statistical results to deviate from the actual situation. Therefore, a method that can effectively count component references is needed. Summary of the invention

[0005] In view of the problem of low accuracy in component reference statistics in the prior art, the present application proposes a component data statistics method and device.

[0006] In order to solve the above technical problems, this application provides the following technical solutions:

[0007] In a first aspect, the present application provides a component data statistics method, comprising:

[0008] Obtaining a target source code text, the target source code text comprising: a plurality of code statements, wherein a code statement including a component unique identifier exists among the plurality of code statements;

[0009] Converting the target source code text into an abstract syntax tree;

[0010] Identify a reference node from the abstract syntax tree, where the reference node is provided with a corresponding component unique identifier;

[0011] According to the component unique identifier corresponding to the reference node, a statistical result of the number of references of the component corresponding to the component unique identifier is obtained.

[0012] Furthermore, converting the target source code text into an abstract syntax tree includes:

[0013] Determine a translator of the target source code text according to a file type corresponding to the target source code text, wherein the file type corresponding to the target source code text is a vue file type or a js file type;

[0014] According to the translator of the target source code text, the target source code text is converted into the abstract syntax tree.

[0015] Furthermore, obtaining the statistical result of the number of references of the component corresponding to the component unique identifier according to the reference node includes:

[0016] Traverse each reference node and determine whether the currently traversed reference node exists in the pre-stored component dictionary. If so, add 1 to the number of references of the currently traversed reference node in the pre-stored component dictionary. Otherwise, add a new component record to the pre-stored component dictionary. The component unique identifier in the component record is the component unique identifier corresponding to the currently traversed reference node, and the number of references in the component record is 1.

[0017] The component dictionary obtained after traversing each reference node is determined as the reference count result of each component.

[0018] Furthermore, the reference node includes: an explicit reference node and / or an implicit reference node.

[0019] Further, the identifying a reference node from the abstract syntax tree includes:

[0020] An ImportDeclaration node is identified from the abstract syntax tree and determined as an explicit reference node in the abstract syntax tree.

[0021] Further, the identifying a reference node from the abstract syntax tree includes:

[0022] A page tag node is identified from the abstract syntax tree and determined as an implicit reference node in the abstract syntax tree.

[0023] Furthermore, the target source code text is multiple, which is the source code text contained in all vue files and js files; the component unique identifier includes: component library name and component name;

[0024] Correspondingly, after obtaining the reference count result of the component corresponding to the component unique identifier according to the reference node, the method further includes:

[0025] Determine whether the component name corresponding to the reference node exists in the component library corresponding to the reference node. If so, determine whether the number of references corresponding to the component unique identifier is zero. If so, delete the component corresponding to the component name in the component library corresponding to the reference node.

[0026] In a second aspect, the present application provides a component data statistics device, including:

[0027] An acquisition module is used to acquire a target source code text, the target source code text including: a plurality of code statements, wherein a code statement including a component unique identifier exists in the plurality of code statements;

[0028] A conversion module, used for converting the target source code text into an abstract syntax tree;

[0029] An identification module, used to identify a reference node from the abstract syntax tree, where the reference node is provided with a corresponding component unique identifier;

[0030] The statistical module is used to obtain the statistical result of the number of references of the component corresponding to the component unique identifier according to the component unique identifier corresponding to the reference node.

[0031] In a third aspect, the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the component data statistics method when executing the program.

[0032] In a fourth aspect, the present application provides a computer-readable storage medium having computer instructions stored thereon, which implement the component data statistics method when the instructions are executed.

[0033] It can be seen from the above technical solution that the present application provides a component data statistics method and device. The method includes: obtaining a target source code text, the target source code text includes: multiple code statements, among which there is a code statement containing a component unique identifier; converting the target source code text into an abstract syntax tree; identifying a reference node from the abstract syntax tree, the reference node is provided with a corresponding component unique identifier; according to the component unique identifier corresponding to the reference node, obtaining a reference count statistical result of the component corresponding to the component unique identifier, which can effectively count the component reference situation, improve the accuracy of the component reference count statistics, provide an accurate data basis for subsequent component maintenance, improve the reliability of component maintenance, and at the same time, reduce redundant code. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art 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 paying creative work.

[0035] Figure 1 It is a flowchart of a component data statistics method in an embodiment of the present application;

[0036] Figure 2 is a flow chart of a component data statistics method in another embodiment of the present application;

[0037] Figure 3 is a flowchart of a component data statistics method in another embodiment of the present application;

[0038] Figure 4 It is a structural diagram of a component data statistics device in an embodiment of the present application;

[0039] Figure 5 A schematic block diagram of the system structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0040] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0041] In order to facilitate the understanding of this solution, first, the technical contents related to this solution are explained.

[0042] Abstract Syntax Tree (AST) is an abstract representation of the syntax structure of source code; it represents the syntax structure of a programming language in a tree-like form, and each node on the tree represents a structure in the source code. In modern front-end engineering, front-end source code with different syntaxes can be translated into AST and processed through the transfer tool library Babel. Since the tree format of AST is easy to parse and has a unified format, it is very convenient to develop various front-end code analysis or preprocessing tools based on it. Therefore, AST is widely used in the front-end field, such as:

[0043] ①Editor's error prompts, code formatting, code highlighting and code auto-completion;

[0044] ② Check for code errors or style;

[0045] ③Translate different types of javascript syntax.

[0046] Components are simple encapsulation of data and methods.

[0047] In order to improve the accuracy of the statistics of the number of references of components, the embodiment of the present application provides a component data statistics device, which can be a server or a client device, and the client device can include a smart phone, a tablet electronic device, a network set-top box, a portable computer, a desktop computer, a personal digital assistant (PDA), a vehicle-mounted device, and a smart wearable device, etc. Among them, the smart wearable device can include smart glasses, smart watches, and smart bracelets, etc.

[0048] In practical applications, the part of performing component data statistics can be performed on the server side as described above, or all operations can be completed in the client device. The selection can be made based on the processing capability of the client device and the limitations of the user's usage scenario. This application does not limit this. If all operations are completed in the client device, the client device may also include a processor.

[0049] The client device may have a communication module (i.e., a communication unit) that can communicate with a remote server to achieve data transmission with the server. The server may include a server on the task scheduling center side, and other implementation scenarios may also include a server on an intermediate platform, such as a server on a third-party server platform that has a communication link with the task scheduling center server. The server may include a single computer device, or a server cluster consisting of multiple servers, or a server structure of a distributed device.

[0050] The server and the client device may communicate using any suitable network protocol, including network protocols that have not yet been developed on the date of filing this application. The network protocol may include, for example, TCP / IP protocol, UDP / IP protocol, HTTP protocol, HTTPS protocol, etc. Of course, the network protocol may also include, for example, RPC protocol (Remote Procedure Call Protocol) and REST protocol (Representational State Transfer) used on top of the above protocols.

[0051] It should be noted that the component data statistics method and device disclosed in the present application can be used in the field of financial technology, and can also be used in any field other than the field of financial technology. The application field of the component data statistics method and device disclosed in the present application is not limited.

[0052] The details are described through the following embodiments.

[0053] In order to improve the accuracy of the component reference count statistics, this embodiment provides a component data statistics method in which the execution subject is a component data statistics device, and the component data statistics device includes but is not limited to a server, such as Figure 1 As shown, the method specifically includes the following contents:

[0054] Step 100: Obtain a target source code text, the target source code text including: a plurality of code statements, wherein there is a code statement including a component unique identifier in the plurality of code statements.

[0055] Specifically, the target source code text may be source code text in a vue file and a js file; there may be multiple target source code texts, each target source code text corresponds to a unique vue file or js file; the component unique identifier is used to distinguish different components, and may include a component library name and a component name; the component library name may represent the name of the component library where the component referenced in the code statement is located, and the component name may represent the name of the component referenced in the code statement.

[0056] For example, a code statement is "import a from 'b'", where b is the component library name and a is the name of the component referenced from b.

[0057] Step 200: Convert the target source code text into an abstract syntax tree.

[0058] Specifically, the target source code text and the abstract syntax tree may be in a one-to-one correspondence.

[0059] Step 300: Identify a reference node from the abstract syntax tree, where the reference node is provided with a corresponding component unique identifier.

[0060] The reference nodes may include: explicit reference nodes and / or implicit reference nodes; the number of the reference nodes may be one or more; and the components referenced by different reference nodes may be the same or different.

[0061] Step 400: According to the component unique identifier corresponding to the reference node, obtain the reference count statistics result of the component corresponding to the component unique identifier.

[0062] Specifically, taking the Vue project as an example, you can traverse the vue files and js files under the project path, translate the source code text into AST and then analyze it, find the nodes representing component references in the AST tree, identify the referenced components and add the statistical results; it can be understood that the statistical result of the number of references of the component corresponding to the component unique identifier can represent the number of times the component is referenced in the target source code text.

[0063] Furthermore, after counting all reference data, detailed information on the use of component libraries within the project can be obtained, including the number of references to each component, which is convenient for subsequent processing and analysis; a component reference report can be generated in a standard format based on the statistical result set for subsequent analysis.

[0064] From the above description, it can be seen that the component data statistics method provided in this embodiment can analyze the abstract syntax tree AST after translating the code into the AST, and use the characteristics of AST with clear features and clear meanings to accurately count the usage of components (i.e., references), thereby solving the statistical error problem caused by the previous regular matching method.

[0065] In order to further improve the reliability of the abstract syntax tree, and then use the reliable abstract syntax tree to obtain accurate citation count statistics, see Figure 2 In one embodiment of the present application, step 200 includes:

[0066] Step 201: determining a translator of the target source code text according to a file type corresponding to the target source code text, wherein the file type corresponding to the target source code text is a vue file type or a js file type;

[0067] Step 202: According to the translator of the target source code text, the target source code text is converted into the abstract syntax tree.

[0068] Specifically, the source code text of the vue file type can call the vue translator, the source code text of the js file type can call the js translator, and other files are not processed and are skipped directly; the source code texts of different file types are translated into ASTs respectively using the translator.

[0069] To further improve the accuracy of citation statistics, see Figure 3 In one embodiment of the present application, step 400 includes:

[0070] Step 401: traverse each reference node and determine whether the currently traversed reference node exists in the pre-stored component dictionary. If so, increase the number of references of the currently traversed reference node in the pre-stored component dictionary by 1. Otherwise, add a new component record to the pre-stored component dictionary. The component unique identifier in the component record is the component unique identifier corresponding to the currently traversed reference node, and the number of references in the component record is 1.

[0071] Specifically, the component unique identifier and the number of references corresponding to each reference node are stored in the component dictionary; the pre-stored component dictionary is initially empty; the elements in the pre-stored component dictionary (i.e., component records) are key:value structures, where key is the component unique identifier and value is the number of references. When a reference relationship that needs to be counted is screened out (the reference relationship that needs to be counted can be equivalent to the above-mentioned reference node), check whether the component unique identifier corresponding to the reference relationship already exists in the pre-stored component dictionary. If so, the value is accumulated. If not, a new key:value is created, where key is the unique identifier of the current component and value is 1.

[0072] Step 402: The component dictionary obtained after traversing each reference node is determined as the reference count result of each component.

[0073] Furthermore, the abstract syntax tree can be output and displayed. When a user clicks a reference node of the abstract syntax tree on the front end, the number of references of the component corresponding to the reference node can be obtained from the component dictionary and output and displayed to improve the visualization of the reference count statistics.

[0074] In order to improve the reliability of identifying explicit reference nodes, in one embodiment of the present application, step 300 includes:

[0075] Step 301: Identify an ImportDeclaration node from the abstract syntax tree and determine it as an explicit reference node in the abstract syntax tree.

[0076] Specifically, identify characteristic nodes in AST; nodes in AST that contain component references are divided into two categories: explicit references and implicit references; explicit references refer to explicit declarations of component reference relationships through import statements in source code files, which correspond to ImportDeclaration nodes after being translated into AST. This node can be parsed to filter out components to be counted. For example, the statement "import a from'b'" in the target source code text, after being translated into the ImportDeclaration node of AST, contains a structure similar to {local:a, imported:b}. If b is the name of the component library to be counted, and a is a specific component referenced from b, it means that this reference needs to be counted, otherwise it is skipped and not processed.

[0077] In order to improve the reliability of identifying implicit reference nodes, in one embodiment of the present application, step 300 includes:

[0078] Step 302: Identify a page tag node from the abstract syntax tree and determine it as an implicit reference node in the abstract syntax tree.

[0079] Specifically, implicit reference refers to the situation where the target source code file is used directly without explicit declaration through the import statement. Common components are usually used in this way. In this case, it is necessary to count the AST corresponding to the page template part, traverse the page tag nodes, filter out the component unique identifiers that need to be counted and add them to the statistical results, and skip the component unique identifiers that are not in the statistical range.

[0080] In order to avoid setting useless components and reduce repeated code development, in one embodiment of the present application, the target source code text is multiple, which is the source code text contained in all vue files and js files; the component unique identifier includes: component library name and component name; correspondingly, after step 400, it also includes:

[0081] Step 500: Determine whether the component name corresponding to the reference node exists in the component library corresponding to the reference node. If so, determine whether the number of references corresponding to the component unique identifier is zero. If so, delete the component corresponding to the component name in the component library corresponding to the reference node.

[0082] Specifically, all vue files and js files can refer to all vue files and js files in a development software or project; the pre-stored component library can be set according to actual conditions, and this application does not limit this; the pre-stored component library can encapsulate multiple components; the target source code text can reference components in the pre-stored component library. It is understandable that if the component unique identifier corresponding to the reference node does not exist in the pre-stored component library, the error message corresponding to the component unique identifier can be output.

[0083] It can be understood that when the target source code text is the source code text included in all vue files and js files, the statistical result of the number of references of component A in the target source code text can represent the number of times component A is referenced in the component library to which component A belongs.

[0084] In order to avoid code redundancy caused by setting the same components in different locations, reduce redundant code in the system, and reduce repeated code development, in one embodiment of the present application, after step 400, the following is further included:

[0085] Step 600: Obtain the corresponding unique identifier of the component to be detected whose number of citations is greater than the threshold value of the number of citations from the citation count statistics result, and determine the component position corresponding to the unique identifier of the component to be detected.

[0086] Specifically, the component position may indicate the component library to which the unique identifier of the component to be detected belongs and its position in the component library.

[0087] Step 700: Determine whether there are multiple component positions corresponding to the unique identifier of the component to be detected and the components are the same. If so, only retain the unique component corresponding to the unique identifier of the component to be detected.

[0088] Specifically, only the unique component corresponding to the unique identifier of the component to be detected may be retained, and other components corresponding to the unique identifier of the component to be detected may be deleted.

[0089] In order to improve the flexibility of component data statistics, in one embodiment of the present application, step 100 also includes: receiving the name of the component library to be counted; after step 300, it may also include: selecting a reference node to be detected whose corresponding component unique identifier contains the name of the component library to be counted from multiple reference nodes; and determining the number of times the component in the component library to be counted is referenced in the target source code text according to the component name corresponding to the reference node to be detected.

[0090] From the software level, in order to improve the accuracy of the component reference count statistics, the present application provides an embodiment of a component data statistics device for implementing all or part of the content of the component data statistics method, see Figure 4, the component data statistics device specifically includes the following contents:

[0091] The acquisition module 01 is used to acquire a target source code text, where the target source code text includes: a plurality of code statements, wherein there is a code statement including a component unique identifier among the plurality of code statements;

[0092] A conversion module 02, used for converting the target source code text into an abstract syntax tree;

[0093] An identification module 03, used to identify a reference node from the abstract syntax tree, where the reference node is provided with a corresponding component unique identifier;

[0094] The statistical module 04 is used to obtain the statistical result of the number of references of the component corresponding to the component unique identifier according to the component unique identifier corresponding to the reference node.

[0095] The embodiment of the component data statistics device provided in this specification can be specifically used to execute the processing flow of the embodiment of the above-mentioned component data statistics method. Its functions are not repeated here, and reference can be made to the detailed description of the embodiment of the above-mentioned component data statistics method.

[0096] From the above description, it can be seen that the component data statistics method and device provided in the present application can improve the accuracy of the component reference count statistics, provide an accurate data basis for subsequent component maintenance, improve the reliability of component maintenance, and at the same time, can also reduce redundant code.

[0097] Figure 5 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention is shown in FIG. Figure 5 As shown, the electronic device may include: a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402 and the memory 403 communicate with each other through the communication bus 404. The processor 401 may call the logic instructions in the memory 403 to execute the following method: receiving a cloud resource task request; according to the cloud resource task request, determining the calling interface of the cloud resource task, so that the third-party cloud platform corresponding to the calling interface executes the cloud resource task corresponding to the cloud resource task request according to the necessary task data.

[0098] In addition, the logic instructions in the above-mentioned memory 403 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0099] The present embodiment discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the methods provided by the above-mentioned method embodiments, for example, including: obtaining a target source code text, the target source code text including: a plurality of code statements, among which there is a code statement containing a component unique identifier; converting the target source code text into an abstract syntax tree; identifying a reference node from the abstract syntax tree, the reference node being provided with a corresponding component unique identifier; and obtaining a reference count statistical result of the component corresponding to the component unique identifier according to the component unique identifier corresponding to the reference node.

[0100] The present embodiment provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program enables the computer to execute the methods provided by the above-mentioned method embodiments, for example, including: obtaining a target source code text, wherein the target source code text includes: a plurality of code statements, wherein there is a code statement including a component unique identifier among the plurality of code statements; converting the target source code text into an abstract syntax tree; identifying a reference node from the abstract syntax tree, wherein the reference node is provided with a corresponding component unique identifier; and obtaining a reference count statistical result of the component corresponding to the component unique identifier according to the component unique identifier corresponding to the reference node.

[0101] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0102] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0103] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0104] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0105] In the description of this specification, the description with reference to the terms "one embodiment", "a specific embodiment", "some embodiments", "for example", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0106] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A component data statistics method, characterized in that: include: Obtaining a target source code text, the target source code text comprising: a plurality of code statements, wherein there is a code statement containing a component unique identifier among the plurality of code statements, the component unique identifier is used to distinguish different components, and comprises: a component library name and a component name; Converting the target source code text into an abstract syntax tree; Identify a reference node from the abstract syntax tree, where the reference node is provided with a corresponding component unique identifier; According to the component unique identifier corresponding to the reference node, a statistical result of the number of references of the component corresponding to the component unique identifier is obtained to obtain detailed information on the use of the component library, including: the number of references of each component; After the statistical result of the number of references to the component corresponding to the component unique identifier, the following is also included: Obtaining a corresponding unique identifier of a component to be detected whose number of citations is greater than a threshold number of citations from the citation count statistics result, and determining a component position corresponding to the unique identifier of the component to be detected; Determine whether there are multiple component positions corresponding to the unique identifier of the component to be detected and the components are the same. If so, only retain the unique component corresponding to the unique identifier of the component to be detected.

2. The component data statistics method according to claim 1, characterized in that: The step of converting the target source code text into an abstract syntax tree comprises: Determine a translator of the target source code text according to a file type corresponding to the target source code text, wherein the file type corresponding to the target source code text is a vue file type or a js file type; According to the translator of the target source code text, the target source code text is converted into the abstract syntax tree.

3. The component data statistics method according to claim 1, characterized in that: The obtaining, according to the component unique identifier corresponding to the reference node, a statistical result of the number of references of the component corresponding to the component unique identifier, includes: Traverse each reference node and determine whether the currently traversed reference node exists in the pre-stored component dictionary. If so, add 1 to the number of references of the currently traversed reference node in the pre-stored component dictionary. Otherwise, add a new component record to the pre-stored component dictionary. The component unique identifier in the component record is the component unique identifier corresponding to the currently traversed reference node, and the number of references in the component record is 1. The component dictionary obtained after traversing each reference node is determined as the reference count result of each component.

4. The component data statistics method according to claim 1, characterized in that: The reference node includes: an explicit reference node and / or an implicit reference node.

5. The component data statistics method according to claim 4, characterized in that: The step of identifying a reference node from the abstract syntax tree comprises: An ImportDeclaration node is identified from the abstract syntax tree and determined as an explicit reference node in the abstract syntax tree.

6. The component data statistics method according to claim 4, characterized in that: The step of identifying a reference node from the abstract syntax tree comprises: A page tag node is identified from the abstract syntax tree and determined as an implicit reference node in the abstract syntax tree.

7. The component data statistics method according to claim 1, characterized in that: The target source code text is multiple, which is the source code text contained in all vue files and js files; The component unique identifier includes: component library name and component name; Correspondingly, after obtaining the reference count result of the component corresponding to the component unique identifier according to the reference node, the method further includes: Determine whether the component name corresponding to the reference node exists in the component library corresponding to the reference node. If so, determine whether the number of references corresponding to the component unique identifier is zero. If so, delete the component corresponding to the component name in the component library corresponding to the reference node.

8. A component data statistics device, characterized in that: include: An acquisition module is used to acquire a target source code text, the target source code text includes: a plurality of code statements, among which there is a code statement containing a component unique identifier, the component unique identifier is used to distinguish different components, and includes: a component library name and a component name; A conversion module, used for converting the target source code text into an abstract syntax tree; An identification module, used to identify a reference node from the abstract syntax tree, where the reference node is provided with a corresponding component unique identifier; A statistical module, used to obtain the statistical result of the number of references of the component corresponding to the component unique identifier according to the component unique identifier corresponding to the reference node, so as to obtain the detailed situation of the use of the component library, including: the number of references of each component; The component data statistics device is also used for: Obtaining a corresponding unique identifier of a component to be detected whose number of citations is greater than a threshold number of citations from the citation count statistics result, and determining a component position corresponding to the unique identifier of the component to be detected; Determine whether there are multiple component positions corresponding to the unique identifier of the component to be detected and the components are the same. If so, only retain the unique component corresponding to the unique identifier of the component to be detected.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the component data statistics method described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the instructions are executed, the component data statistics method described in any one of claims 1 to 7 is implemented.