Component routing association analysis method, device, equipment and medium
By employing a Rust-Node.js dual-language architecture and a recursive tracing algorithm, the problem of complex component dependencies in large-scale Vue projects is solved, enabling efficient and accurate component route association analysis that adapts to various Vue project configurations.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-07
- Publication Date
- 2026-03-27
AI Technical Summary
In large-scale Vue projects, the dependencies between components are complex. Existing analysis methods are inefficient and prone to errors, unable to accurately handle complex dynamic imports, conditional rendering, and path aliases, and lack recursive tracing capabilities, resulting in incomplete analysis results.
It adopts a Rust-Node.js dual-language architecture, combining abstract syntax tree parsing and recursive tracing algorithms. It parses the route configuration file by scanning the script module, uses regular expressions to obtain component files, recursively traces the source to build the mapping relationship between components and routes, and generates a component route association analysis report.
It significantly improves the accuracy, completeness, and adaptability of component analysis, increases analysis speed, improves memory usage efficiency, can handle larger-scale Vue projects, and reduces human error and maintenance costs.
Smart Images

Figure CN121742828A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of software development, in particular to a component route association analysis method, device, equipment and medium. BACKGROUND
[0002] With the rapid development of front-end technology, Vue projects have become one of the mainstream front-end frameworks. In large Vue projects, the number of components often reaches hundreds or even thousands, the dependency relationship between components is complex, and the association analysis of components and routes becomes extremely difficult. Related analysis methods mainly rely on manual tracking by developers, which is not only inefficient but also prone to errors. Existing code analysis tools mainly use regular expression matching methods, which have obvious limitations in handling complex dynamic imports and conditional rendering scenarios. At the same time, improper handling of path aliases in Vue projects leads to inaccurate analysis results. SUMMARY
[0003] In order to overcome the above technical defects, the purpose of the present application is to provide a component route association analysis method, device, equipment and medium, the method comprising: creating a project and a component to be analyzed in the project, setting the component to be analyzed as a target component; receiving an instruction for route association analysis of the target component; parsing the route configuration file of the project through a scanning script module to obtain all route configuration files of the project, and converting all route configuration files of the project into a first format; traversing all component files in the project, and obtaining all files using the target component through a regular expression; comparing the path of any file using the target component with the rendering field of the first format route configuration file; determining whether the file path using the target component is referenced in the first format route configuration file according to the comparison result; in response to the file path using the target component not being referenced in the first format route configuration file, determining the route information of the file using the target component through a recursive tracing algorithm, and adding the route information to the use chain of the target component; in response to all files using the target component being processed, establishing a mapping relationship between the target component, the target component file and the corresponding route information, and generating a component route association analysis report according to the mapping relationship. The present application combines a recursive upward tracing component dependency tracking mechanism, and fully utilizes the high-performance algorithm capability of Rust programs and the rich ecosystem of scanning scripts, significantly improving the accuracy, completeness and adaptability of component analysis.
[0004] The specific technical solutions provided by the embodiments of the present application are as follows: In a first aspect, the present application provides a component route association analysis method, the method comprising: create a project and a component to be analyzed in the project, and set the component to be analyzed as a target component; receive an instruction for route association analysis of the target component; parse route configuration files of the project through a scanning script module, obtain all route configuration files of the project, and convert the route configuration files of the project into a first format; traverse all component files in the project, and obtain all files using the target component through a regular expression; compare a file path of any one file using the target component with a rendering field of the first format route configuration file; determine, according to a comparison result, whether the file path of the file using the target component is referenced in the first format route configuration file; in response to the file path of the file using the target component not being referenced in the first format route configuration file, determine route information of the file using the target component through a recursive tracing algorithm, and add the route information to a use chain of the target component; in response to all files using the target component being processed, establish a mapping relationship among the target component, a target component file, and corresponding route information, and generate a component route association analysis report according to the mapping relationship.
[0005] In a second aspect, the application further provides a component route association analysis device, which comprises: a creating module configured to create a project and a component to be analyzed in the project, and set the component to be analyzed as a target component; a receiving module configured to receive an instruction for route association analysis of the target component; a parsing module configured to parse route configuration files of the project through a scanning script module, obtain all route configuration files of the project, and convert the route configuration files of the project into a first format; an obtaining module configured to traverse all component files in the project, and obtain all files using the target component through a regular expression; a comparing module configured to compare a file path of any one file using the target component with a rendering field of the first format route configuration file; a judging module configured to determine, according to a comparison result, whether the file path of the file using the target component is referenced in the first format route configuration file; a determining module configured to, in response to the file path of the file using the target component not being referenced in the first format route configuration file, determine route information of the file using the target component through a recursive tracing algorithm, and add the route information to a use chain of the target component; The analysis module is configured to, in response to all files using the target component being processed, establish a mapping relationship between the target component, a target component file, and corresponding routing information, and generate a component routing association analysis report according to the mapping relationship.
[0006] In a third aspect, a component routing association analysis apparatus is also provided, comprising: one or more processors; a storage device configured to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the component routing association analysis method according to any one of the first aspect.
[0007] In a fourth aspect, a computer device is also provided, comprising: a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the component routing association analysis method according to any one of the first aspect.
[0008] In a fifth aspect, a computer program product is also provided, comprising a computer program which, when executed by a processor, implements the steps of the component routing association analysis method according to any one of the first aspect.
[0009] In a sixth aspect, a computer storage medium is also provided, comprising: a computer program stored thereon, which, when executed by a processor, implements the steps of the component routing association analysis method according to any one of the first aspect.
[0010] Compared with the prior art, the technical scheme provided by the embodiment of the application comprises: creating a project and a component to be analyzed in the project, setting the component to be analyzed as a target component; receiving an instruction for route association analysis of the target component; parsing route configuration files of the project through a scanning script module to obtain all route configuration files of the project, and converting the all route configuration files of the project into a first format; traversing all component files in the project, and obtaining all files using the target component through a regular expression; comparing a file path of any one of the files using the target component with a rendering field of the first format route configuration file; judging whether the file path of the file using the target component is referenced in the first format route configuration file according to a comparison result; in response to the file path of the file using the target component not being referenced in the first format route configuration file, determining route information of the file using the target component through a recursive tracing algorithm, and adding the route information to a use chain of the target component; in response to all the files using the target component being processed, establishing a mapping relationship among the target component, a target component file and corresponding route information, and generating a component route association analysis report according to the mapping relationship. The application combines a recursive upward tracing component dependency tracking mechanism, and fully utilizes high-performance algorithm capability of a Rust program and a rich ecological system of a scanning script, thereby significantly improving accuracy, integrity and adaptability of component analysis.
[0011] Compared with a traditional manual analysis method, the technical scheme provided by the embodiment of the application significantly improves analysis speed; 1000 components are only required to be analyzed for 2-3 hours; a memory management mechanism of a Rust program significantly improves memory use efficiency; efficient memory management can support larger-scale project analysis; and multi-thread parallel processing significantly improves CPU utilization.
[0012] Compared with a traditional manual analysis method, the technical scheme provided by the embodiment of the application significantly improves analysis speed; 1000 components are only required to be analyzed for 2-3 hours; a memory management mechanism of a Rust program significantly improves memory use efficiency; efficient memory management can support larger-scale project analysis; and multi-thread parallel processing significantly improves CPU utilization.
[0013] The technical scheme provided by the embodiment of the application can process larger-scale Vue projects; through efficient memory management and multi-thread processing of the Rust program, projects containing thousands of components can be stably processed; a plurality of Vue project structures and configuration modes are supported; through AST analysis and intelligent path matching, various different Vue project configurations can be adapted; deeper component nesting relationships can be analyzed; through a recursive tracing algorithm, deeper component dependency relationships can be analyzed.
[0014] The technical scheme provided by the embodiment of the application shortens the development time: the component routing association analysis time is shortened from 2-3 workdays to 2-3 hours; automatic analysis reduces human errors and reduces maintenance costs; new team members can quickly understand the project structure and shorten the learning time; through the bilingual architecture, the best balance between performance and development efficiency is achieved; the recursive tracing algorithm is pioneering in the field of Vue component analysis; and a replicable technical scheme is provided for architecture analysis of large front-end projects. BRIEF DESCRIPTION OF DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative labor.
[0016] Figure 1 The first flowchart of the component routing association analysis method provided for the embodiment one of the application; Figure 2 The second flowchart of the component routing association analysis method provided for the embodiment two of the application; Figure 3 The project component association schematic diagram provided for the embodiment two of the application; Figure 4 The component usage link schematic diagram provided for the embodiment two of the application; Figure 5 The specific flowchart of the component routing association analysis method provided for the embodiment two of the application; Figure 6 The structural diagram of the component routing association analysis device provided for the embodiment three of the application; Figure 7 The exemplary system provided for the embodiment seven of the application can be used to implement various embodiments described in the application. DETAILED DESCRIPTION
[0017] In order to make the purposes, technical solutions and advantages of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only 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 a person of ordinary skill in the art without creative labor fall within the scope of protection of the present application.
[0018] It should be noted that, unless the context clearly requires otherwise, throughout the description and the claims, "comprise", "comprising", and the like, are to be construed in an inclusive sense as opposed to an exclusive or exhaustive sense; that is to say, in the sense of "including, but not limited to".
[0019] In addition, in the description of the present application, the meaning of "multiple" is two or more, unless otherwise specified.
[0020] The closest related technology is a Vue component finding tool based on regular expressions and static analysis, represented by the open source project vue-find-component on GitHub.
[0021] Technical solution characteristics of the vue-find-component project: Regular expression matching: use predefined regular expression patterns to find component references in Vue files, such as import statements, components configuration, etc.; Static file scanning: scan all Vue files in the project through file system traversal, and analyze the file content one by one; Component reference identification: identify component registration, component usage, etc. in Vue files, including component tags in templates and component imports in JavaScript; Simple path processing: basic string matching on file paths, lacking handling of complex cases such as path aliases, dynamic imports, etc.; Single-layer dependency analysis: mainly focuses on direct component reference relationships, unable to analyze deep-nested component dependency chains; Single output format: usually outputs simple text lists or JSON formats, lacking structured dependency relationship display.
[0022] Related technology implementation: Use a scanning script module (Node.js module) as the running environment; use the fs module for file system operations; use regular expressions for text pattern matching; use string operations for path comparison and component name extraction; The main application scenarios of vue-find-component and similar tools are: component search in small Vue projects; simple component reference relationship analysis; preliminary screening before manual analysis by developers; component usage investigation during project refactoring; This technical solution provides basic tool support for Vue component search and analysis, but has obvious limitations in handling large projects, complex syntax structures, and deep dependency relationships.
[0023] Based on the above existing technologies, there are the following technical defects and deficiencies: Low analysis accuracy: the matching method based on regular expressions has insufficient accuracy in handling complex syntax structures, especially in handling ES6+ syntax, dynamic import, and other scenarios, with serious false positives and false negatives; Limited processing capacity: existing technologies cannot effectively handle path aliases, dynamic component loading, conditional rendering, and other complex situations in Vue projects, resulting in incomplete analysis results; Lack of recursive tracing capability: unable to build a complete component dependency chain, unable to analyze the routing association of deeply nested components; Low performance efficiency: regular matching requires multiple iterations of file content, with poor performance in large projects and slow analysis speed; Insufficient adaptability: lack of adaptability to different Vue project structures and routing configuration methods, requiring adjustment of matching rules for different projects; Improper language selection: single language implementation cannot achieve the best balance between performance, ecology, and development efficiency; The main technical problems to be solved are low analysis accuracy, lack of recursive tracing capability, and improper language selection, which directly affect the practicality, reliability, and performance of Vue component routing association analysis.
[0024] Embodiment one The embodiment of the present application provides a component routing association analysis method, as shown in Figure 1 The method comprises the following steps: Creating a project and a component to be analyzed in the project, and setting the component to be analyzed as a target component; Receiving an instruction for routing association analysis of the target component; Analyzing the routing configuration file of the project by scanning the script module, obtaining all routing configuration files of the project, and converting all routing configuration files of the project into a first format; Iterating through all component files in the project, and obtaining all files using the target component through a regular expression; Compare the file path of any component usage target with the rendering field of the first format routing configuration file; Determine whether the file path of the component usage target is referenced in the first format routing configuration file according to the comparison result; In response to the file path of the component usage target not being referenced in the first format routing configuration file, determine the routing information of the file of the component usage target through a recursive tracing algorithm, and add the routing information to the usage chain of the target component; In response to all files using the target component being processed, establish a mapping relationship between the target component, the target component file, and the corresponding routing information, and generate a component routing association analysis report according to the mapping relationship.
[0025] Specifically, the innovation of the technical scheme of the present application lies in adopting a Rust-Node.js dual-language architecture, combining AST parsing technology and a recursive tracing algorithm, to realize intelligent association analysis of Vue components and routing configurations; by upgrading the traditional regular matching method to precise parsing based on abstract syntax trees, combining a recursive upward tracing component dependency tracking mechanism, and fully utilizing the high-performance algorithm capabilities of Rust programs and the rich ecosystem of Node.js modules, the accuracy, completeness, adaptability, and performance of the analysis are significantly improved.
[0026] Among them, Rust program is a system-level programming language with memory safety, zero-cost abstraction, and concurrent safety, which is particularly suitable for high-performance algorithm implementation.
[0027] Node.js script is a JavaScript runtime environment based on Chrome V8 engine, which is good at handling file I / O, network requests, and rich npm packages.
[0028] Dual-language architecture (Dual-Language Architecture): combines the advantages of two different programming languages to achieve optimal performance of different modules of the system.
[0029] Prior art process: input component name → regular matching routing file → simple path comparison → output result; Technical process of the present application: input component name → Node.js AST parsing routing configuration → Rust recursive tracing algorithm → Rust intelligent path matching → Rust usage chain construction → output complete analysis result; The component usage chain (Component Usage Chain) can describe the hierarchical structure of the dependency relationship between components and record the link information of which parent components the component is used by; The innovative features of this solution are reflected in the bilingual architecture design: Node.js module: responsible for scanning and AST parsing of the routing configuration file, making full use of mature toolkits such as Babel and fast-glob in the npm ecosystem; AST parsing stage: use Node.js script to call Babel AST parser instead of regular expressions, which can accurately identify various complex JavaScript syntax structures; Babel is a JavaScript compiler that can convert ES6+ code into backward compatible JavaScript versions and provide AST parsing functions; Abstract Syntax Tree (AST) is an abstract representation of the syntax structure of source code, used for code analysis and conversion; Rust program module: responsible for core algorithm implementation, including recursive tracing, path matching, and use chain construction, etc. computationally intensive operations; Rust program algorithm advantages: Memory safety: Rust's ownership system ensures that there is no memory leak or dangling pointer during algorithm execution; Zero-cost abstraction: the performance overhead of the recursive tracing algorithm is minimized, suitable for handling complex dependency relationships in large projects; Concurrent safety: supports multi-threaded parallel processing, improving the processing speed of large-scale component analysis; Type safety: strong type system reduces runtime errors and improves algorithm reliability; Recursive tracing stage: use Rust to implement efficient recursive algorithms to find parent components from target components, and build complete dependency links; Recursive tracing is an algorithm strategy that recursively calls to find parent components and build complete component dependency links; Intelligent matching stage: Rust implements path alias resolution and multiple matching strategies to improve matching accuracy and adaptability; Path alias (Path Alias): a short name set for long paths in the module system, such as the commonly used @ / in Vue projects, which represents the src / directory; Use chain construction stage: Rust dynamically constructs component use links to provide complete context information for subsequent analysis; This dual-language architecture design takes full advantage of the strengths of both languages: the Node.js program is responsible for the rich file processing and AST parsing of the ecological system, and the Rust program is responsible for high-performance algorithm calculation, achieving the best balance between performance and development efficiency. These innovative features enable the technical solution to effectively solve key technical problems such as low analysis accuracy, limited processing capacity, lack of recursive tracing capability, and low performance efficiency in the prior art.
[0030] The technical solution provided by the embodiments of the present application has the following beneficial effects: The embodiments of the present application combine the component dependency tracking mechanism of recursive upward tracing, and fully utilize the high-performance algorithm capability of the Rust program and the rich ecological system of the scanning script, significantly improving the accuracy, completeness and adaptability of component analysis.
[0031] Compared with the traditional manual analysis method, the technical solution provided by the embodiments of the present application significantly improves the analysis speed; it only takes 2-3 hours to analyze 1000 components; the memory management mechanism of the Rust program significantly improves the efficiency of memory use; efficient memory management can support larger-scale project analysis; and multi-threaded parallel processing significantly improves the utilization rate of the processor CPU.
[0032] Embodiment two The embodiments of the present application provide a component routing association analysis method, as shown in Figure 2 The method comprises: For the technical process of the component routing association analysis method before improvement (single language implementation): Developers manually analyze → view files one by one → search by regular matching → record results → organize analysis report; The innovative process of the technical solution (through dual-language architecture): Input component name → Node.js scans routing configuration → Rust recursive tracing analysis → intelligent path matching → build usage link → output complete analysis report; The creative features are embodied in: Dual-language architecture design: Node.js is responsible for rich file processing and AST parsing of the ecological system, and the Rust program is responsible for high-performance algorithm calculation; AST parsing instead of regular matching: use Babel AST parser to realize accurate syntax analysis; Recursive tracing algorithm: Rust implements an efficient recursive upward search mechanism; Intelligent path matching: supports path alias resolution and multiple matching strategies; Dynamic usage link construction: real-time construction of component dependency relationship link.
[0033] Step S01, create a project and a component to be analyzed in the project, and set the component to be analyzed as a target component; receive an instruction for route association analysis of the target component.
[0034] Specifically, as shown in the figure, an Internet company is carrying out standardization reform of a Vue project, and the development team needs to analyze the usage of "Z component" in the project, so as to formulate component reuse strategy and route optimization scheme. Figure 3
[0035] The R&D member receives a task and needs to analyze the usage of "Z component" in the company system; the component is used in multiple pages, but the team does not know where it is cited specifically, and how to optimize the route configuration; the R&D member needs to quickly find all places where the component is used and analyze the association between the component and the route.
[0036] System initialization process: The R&D member inputs the project path and component name in the command line, and the system automatically creates an analyzer instance, configures necessary parameters, and prepares to start analysis work; Here, configuration can also be made through a graphical interface, and the user selects the project folder through drag-and-drop and selects the component to be analyzed through a drop-down menu, the focus being on the friendliness of the user interface and the convenience of operation.
[0037] Among them, the route configuration file (Route Configuration) defines the configuration information of the page route in the application, including path, component, metadata, etc.
[0038] Step S02, parse the route configuration file of the project through the scanning script module, obtain all route configuration files of the project, and convert all route configuration files of the project into a first format (JSON format).
[0039] Step S021, start the component analyzer; Call the scanning script module through the component analyzer, analyze the route configuration file of the project through the abstract syntax tree parser of the scanning script module; Obtain all route configuration files of the project, and convert all route configuration files of the project into a first format through the scanning script module; Each route configuration file includes file path, file name, file rendering field, and metadata field.
[0040] Specifically, the system automatically scans the project's routing configuration files, including the main routing file, modular routing files, and other specific scenario descriptions: systems developed with vue2 mostly use modular routing design, the main routing file is located at src / router / index.js, and the routing configurations of each business module are scattered in multiple files under the src / router / modules / directory; the system needs to scan these files to extract all routing configuration information, including page paths, component references, route names, etc. Scanning process: the system starts a Node.js process and calls a dedicated routing scanning script, which can automatically identify routing configuration files in the project, use an AST parser to parse JavaScript code, extract key information from routing configuration files, and convert the results into standardized JSON format.
[0041] Here, a Python script can also be used for routing scanning. The difference from the best solution is that Python scripts have advantages in data processing and scientific computing, but the JavaScript ecosystem has more mature and stable support for Vue projects with tools such as Babel and fast-glob. The Python solution may require additional dependency installation and configuration, while the Node.js solution is more compatible with the Vue project's technology stack.
[0042] Step S03, traverse all component files in the project, and use regular expressions to get all files using the target component.
[0043] Step S031, traverse all component files in the project; Use regular expressions to import target component name import statements to match the target component; Extract all files using the target component from all component files in the project.
[0044] Step S04, compare any file path using the target component with the rendering field of the first format routing configuration file; Determine whether the file path using the target component is referenced in the first format routing configuration file based on the comparison result; In response to the file path using the target component not being referenced in the first format routing configuration file, determine the routing information of the file using the target component through a recursive tracing algorithm, and add the routing information to the usage chain of the target component.
[0045] Specifically, as Figure 4As shown, starting from the Z component, recursively find its parent components upwards, build the complete component usage chain. Specific scenario description: Z component itself is not a page-level component, but a child component referenced by other components; the system needs to find all parent components that use Z, and then continue to find upwards until the final routing page component is found.
[0046] Z is used by O component, and O is used by e1 component; Z is only used by g1 component; And B and C pages are page components configured directly in the route.
[0047] Start recursive tracing, the system uses a recursive algorithm starting from the Z component: 1. Find all Vue files that reference the Z component; 2. Analyze the component definitions in these files to find the parent component name; 3. Repeat the above process for each parent component; 4. Until the page component configured directly in the route is found; 5. Finally, record the complete component usage chain; Here, an iterative approach can also be used instead of recursion to avoid the depth limit of recursive calls through loop and queue management. However, the iterative approach is more controllable in memory usage, avoiding the risk of stack overflow, but the code logic is relatively complex; while the recursive approach has a clearer code structure and more intuitive logic, but may have depth limit problems when dealing with large projects.
[0048] Step S041, set the file using the target component as the first file; Get the parent component name corresponding to the first file; Determine whether the parent component name corresponding to the first file exists; In response to the existence of the parent component name corresponding to the first file, determine the routing information of the first file through a recursive tracing algorithm, and add the routing information of the first file to the usage chain of the target component; In response to the non-existence of the parent component name corresponding to the first file, continue to analyze the component routing association of other files using the target component.
[0049] Step S042, determine whether there is a page component corresponding to the first file through a recursive tracing algorithm; In response to the existence of a page component corresponding to the first file, add the routing information corresponding to the first file to the usage chain of the target component, and continue to analyze the component routing association of other files using the target component; In response to the first file not having a corresponding page component, recursively tracing the routing information of the first file upwards, and in response to reaching the root directory of the project, ending the tracing process.
[0050] Specifically, the path alias in the Vue project, such as @ / dir, is converted to the actual src / dir path. Specific scenario description: the vue2 project uses the standard configuration of Vue CLI, where the @ symbol is configured as an alias pointing to the src directory; in the routing configuration, the component path is usually written in the form of "@ / dir", while the actual file path is "src / dir" or "src / dir / index.vue"; the system needs to be able to recognize this alias and convert it to the actual path for matching; Intelligent matching strategy: the system uses multiple matching strategies to improve the accuracy of matching: Alias path matching: convert @ / dir to src / dir for matching; File name matching: check if the index.vue file is in the component path of the routing configuration; Directory structure matching: check if the file is in the corresponding position under the dir directory; Component name matching: check if the component name matches the component name in the routing configuration; Here, alias mapping rules can also be defined through configuration files. Users can customize alias resolution rules according to the specific configuration of the project. The configuration file method provides greater flexibility and can adapt to various project configurations, but requires manual configuration and maintenance; the hard-coded method, although less flexible, is simple to configure and suitable for standardized project structures.
[0051] Step S05, in response to all files using the target component being processed, establishing a mapping relationship between the target component, the target component file, and the corresponding routing information, and generating a component routing association analysis report based on the mapping relationship.
[0052] Specifically, as shown in Figure 4 , the complete usage link of component Z→g1→C is constructed, and an analysis report is generated. Specific scenario description: the system has found the complete usage link of the Z component; it is necessary to organize this information into a structured report to help the development team understand the usage of the component and develop appropriate optimization strategies; the usage link construction process: the system organizes the collected information into a complete component usage link: First layer: Z component (target component); Second layer: g1 component (parent component using Z); Third layer: C component (page component using g1); Route information: / dic (Z component corresponding route path); Result output format: the system provides multiple output formats for users to choose from: Tree structure: the dependency relationship between components is displayed in a tree diagram form; JSON format: structured data, easy for other tool programs to process; HTML report: visual display, including charts and detailed explanations; Markdown format: convenient for document management and version control.
[0053] Step S051, associate the file using the target component with the route information corresponding to the file, add all route information corresponding to the file using the target component to the usage chain of the target component, and establish a mapping relationship between the target component, the target component file and the route information corresponding to the file. According to the mapping relationship, the usage chain of the target component is obtained, the component route association analysis report is generated according to the usage chain of the target component, and the component route association analysis report is output; The component route association analysis report is output, including: The component route association analysis report is output through tree structure and / or JSON format and / or HTML report and / or Markdown format.
[0054] Here, the results can also be output through Web API, supporting real-time query and dynamic update; Web API provides better real-time and interactivity, supports multi-user concurrent access, but requires additional Web server and network configuration; Although the file output method has relatively simple functions, it is simple to deploy and suitable for single machine use and offline analysis scenarios.
[0055] Step S06, in response to the file path using the target component being referenced in the first format route configuration file, the route information of the file using the target component is obtained, and the route information of the file using the target component is added to the usage chain of the target component; Determine whether all files using the target component have determined corresponding route information; In response to all files using the target component having determined corresponding route information, a mapping relationship between the target component, the target component file and the route information corresponding to the file is established, and a component route association analysis report is generated according to the mapping relationship; in response to there being other files using the target component without determining corresponding route information, the corresponding route information of the other files using the target component is determined again through the recursive tracing algorithm.
[0056] As Figure 5As shown, step 1: start the search application; the user starts the Vue component analyzer through the command line or GUI interface; the system initializes the Rust application, loads the necessary modules and dependencies; prepares the analysis environment and configuration parameters; Step 2: User input component name and project path; the user specifies the target component name to be analyzed (such as: Z component); the user provides the root directory path of the Vue project; the system verifies the validity of the input parameters; Step 3: Create Analyzer instance; create VueAnalyzer instance in Rust code; initialize regular expression patterns (component import, component use, component definition); set project path and target component name; Step 4: Call scan script (nodejs) to scan routes; Rust program calls Node.js script; Node.js script uses Babel parser to analyze Vue project route configuration file; supports multiple route configuration formats: ES6 export, CommonJS, array format, etc.; scan all route configuration files under src / router / directory; Step 5: Parse route JSON to array; Node.js script outputs the parsed route configuration file information in JSON format; Rust program receives JSON data and parses it into Vec <routeinfo>Structure (routing information); each routing information contains: path, name, component, metadata meta, etc. field; Step 6: Build component usage chain; Start building the usage chain of the target component; Prepare the data structure and access record for recursive tracing; Step 7: Find files using the target component; Traverse all.vue files (project component files) in the project; Match component import statements using regular expressions: import ComponentName from; Match component usage in the template using regular expressions: <componentname>; Extract all file paths that use the target component Step 8: Check if the queried file matches the json format route configuration file; Check if the current file is directly referenced in the route configuration; Compare the file path with the component field in the json format route configuration file, which specifies the component reference or loading method associated with the route path; Support path alias resolution (such as @ / views / ); Step 9: Directly return route information and add to the usage chain; If the file matches the route configuration, directly obtain the corresponding route information; Create a ComponentUsageInfo object (component usage chain information); Add route information to the component usage chain; Mark as a route page (is_route_page: true); Step 10: Get the parent component name; If the file does not match the route configuration, it needs to be traced upwards; Extract the component name from the current file (through the name attribute or file name); Prepare for recursive trace analysis; Step 11: Check if the parent component exists; Check if the extracted parent component name is valid; Verify if the parent component has a corresponding file in the project; Step 12: Call the recursive trace algorithm (rust); Use the Rust implementation of the recursive trace algorithm; From the parent component, continue to find the page file that uses the component upwards; Maintain access records to avoid circular references; Limit the recursion depth to prevent infinite loops; Step 13: Check if the recursion found a route; Check if a matching route page is found during the recursive trace process; Determine if the component has reached the route level; Step 14: Add the current component to the usage chain; If the recursion finds a route, add the current component route to the usage chain of the target component; Create a ComponentUsageInfo object; Set the correct level information; Step 15: Return the route information and add it to the usage chain; Add the found route information to the component usage chain; Establish the association between the component and the route information; Step 16: Continue tracing upwards; If the recursion does not find a route, continue to find upwards; Repeat the recursive process of steps 12-13; Until a route page is found or the project root directory is reached; Step 17: Return "no usage" and continue to find other files; If the parent component does not exist, mark it as no usage; Continue to process other files that use the target component, each of which has corresponding route information; Step 18: Check if there are other usage files; Check if there are other files that use the target component to be processed; Decide whether to continue the loop processing; Step 19: Complete the use chain construction; all files using target components have been processed; component use chain construction is complete; prepare for route association analysis; Step 20: Associate the route use chain; associate the constructed component use chain with route information; create RouteConnection objects (route connection information); establish a mapping relationship between target components, files, and route information; Step 21: Generate analysis report; generate analysis report according to user specified format; support multiple output formats: tree, json, html; include complete dependency tree and route association information; Step 22: Output results; output analysis results to console or file; provide user-friendly formatted display; complete the entire analysis process.
[0057] Rust core functions: efficiently traverse project files using the walkdir library; regular expression matching: use the regex library for component import and use pattern matching; recursive tracing algorithm: implement component dependency analysis using depth-first search; JSON serialization: use the serde library to handle data structure serialization; Node.js auxiliary functions: use Babel parser to analyze JavaScript / TypeScript route configuration; extract route information through abstract syntax tree (AST) traversal; support multiple module formats such as ES6 and CommonJS.
[0058] The component route association analysis method provided by the embodiments of the present application can be improved and optimized without deviating from the technical solutions of the present application, and these improvements and optimizations should also be considered within the scope of protection of the present application.
[0059] The technical solutions provided by the embodiments of the present application have the following beneficial effects: The present application combines the recursive upward tracing component dependency tracking mechanism, and fully utilizes the high-performance algorithm capabilities of Rust programs and the rich ecosystem of scanning scripts, significantly improving the accuracy, completeness, and adaptability of component analysis.
[0060] The technical solutions provided by the embodiments of the present application can handle larger-scale Vue projects; through efficient memory management and multi-threading processing of Rust programs, it can stably handle projects containing thousands of components; support multiple Vue project structures and configuration methods; through AST analysis and intelligent path matching, it can adapt to various Vue project configurations; it can analyze deeper component nesting relationships; through the recursive tracing algorithm, it can analyze deeper component dependency relationships.
[0061] The technical scheme provided by the embodiment of the application shortens development time: the component route association analysis time is shortened from 2-3 workdays to 2-3 hours; the automatic analysis reduces manual errors and reduces maintenance cost; new team members can quickly understand the project structure and shorten the learning time; the best balance between performance and development efficiency is achieved through the bilingual architecture; the recursive traceability algorithm is pioneering in the field of Vue component analysis; and a replicable technical scheme is provided for architecture analysis of a large front-end project.
[0062] Embodiment three The application provides a component route association analysis device, as shown in the accompanying drawings, the device comprises a creating module, a receiving module, an analyzing module, an obtaining module, a comparing module, a judging module, a determining module and an analyzing module. Figure 6
[0063] In this embodiment, the creating module is configured to create a project and a component to be analyzed in the project, and set the component to be analyzed as a target component; The receiving module is configured to receive an instruction for route association analysis of the target component; The analyzing module is configured to analyze the route configuration file of the project by using a scanning script module, obtain all route configuration files of the project, and convert the route configuration files of the project into a first format; The obtaining module is configured to traverse all component files in the project, and obtain all files using the target component by using a regular expression; The comparing module is configured to compare a file path of any file using the target component with a rendering field of the first format route configuration file; The judging module is configured to determine, according to a comparison result, whether the file path of the file using the target component is referenced in the first format route configuration file; The determining module is configured to, in response to the file path of the file using the target component not being referenced in the first format route configuration file, determine route information of the file using the target component by using a recursive traceability algorithm, and add the route information to a use chain of the target component; The analyzing module is configured to, in response to all files using the target component being processed, establish a mapping relationship among the target component, a target component file and corresponding route information, and generate a component route association analysis report according to the mapping relationship.
[0064] In this embodiment, the analyzing module is configured to start a component analyzer; The scanning script module is called by the component analyzer, and the route configuration file of the project is analyzed by using an abstract syntax tree parser of the scanning script module; obtain all the route configuration files of the project, and convert all the route configuration files of the project into a first format through a scanning script module; Each route configuration file includes a file path, a file name, a file rendering field, and a metadata field.
[0065] In one embodiment, the obtaining module is configured to traverse all component files in the project. The target component name import statement is imported by using a regular expression to match the target component. All files using the target component are extracted from all the component files in the project.
[0066] In one embodiment, the determining module is configured to set the file using the target component as a first file. The parent component name corresponding to the first file is obtained. It is determined whether the parent component name corresponding to the first file exists. In response to the parent component name corresponding to the first file existing, the route information of the first file is determined through a recursive tracing algorithm, and the route information of the first file is added to the use chain of the target component. In response to the parent component name corresponding to the first file not existing, other files using the target component are continuously subjected to component route association analysis.
[0067] In one embodiment, the determining module is configured to determine whether the page component corresponding to the first file exists through a recursive tracing algorithm. In response to the first file corresponding to the page component existing, the route information corresponding to the first file is added to the use chain of the target component, and other files using the target component are continuously subjected to component route association analysis. In response to the first file corresponding to the page component not existing, the route information of the first file is continuously determined through a recursive tracing algorithm, and in response to the tracing reaching the root directory of the project, the tracing process is ended.
[0068] In one embodiment, the analysis module is configured to associate the file using the target component with the route information corresponding to the file, add the route information corresponding to all the files using the target component to the use chain of the target component, establish a mapping relationship among the target component, the target component file, and the route information corresponding to the file, obtain the use chain of the target component according to the mapping relationship, generate a component route association analysis report according to the use chain of the target component, and output the component route association analysis report. The outputting of the component route association analysis report includes: output the component routing correlation analysis report in a tree structure and / or JSON format and / or HTML report and / or Markdown format.
[0069] In one of the embodiments, the analysis module is configured to, in response to the file path using the target component being referenced in the first format routing configuration file, acquire routing information of the file using the target component, and add the routing information of the file using the target component to the usage chain of the target component. determine whether all files using the target component have determined corresponding routing information; In response to all files using the target component having determined corresponding routing information, a mapping relationship between the target component, the target component file and the corresponding routing information of the file is established, and a component routing correlation analysis report is generated according to the mapping relationship. In response to other files using the target component not having determined corresponding routing information, the recursive tracing algorithm is used to determine the corresponding routing information of the other files using the target component.
[0070] The technical scheme provided by the embodiments of the present application has the following beneficial effects: The present application combines the recursive upward tracing component dependency tracking mechanism, and fully utilizes the high-performance algorithm capability of the Rust program and the rich ecological system of the scanning script, thereby significantly improving the accuracy, completeness and adaptability of the component analysis.
[0071] Compared with the traditional manual analysis method, the technical scheme provided by the embodiments of the present application significantly improves the analysis speed; it only takes 2-3 hours to analyze 1000 components; the memory management mechanism of the Rust program significantly improves the memory usage efficiency; efficient memory management can support larger-scale project analysis; and multi-thread parallel processing significantly improves the CPU utilization rate.
[0072] Compared with the traditional manual analysis method, the technical scheme provided by the embodiments of the present application significantly improves the analysis speed; it only takes 2-3 hours to analyze 1000 components; the memory management mechanism of the Rust program significantly improves the memory usage efficiency; efficient memory management can support larger-scale project analysis; and multi-thread parallel processing significantly improves the CPU utilization rate.
[0073] Embodiment Four The present application also provides a component routing correlation analysis device, comprising: one or more processors; a storage device configured to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors perform the following component routing association analysis method: creating a project and a component to be analyzed in the project, and setting the component to be analyzed as a target component; receiving an instruction for routing association analysis of the target component; parsing routing configuration files of the project through a scanning script module, obtaining all routing configuration files of the project, and converting the all routing configuration files of the project into a first format; traversing all component files in the project, and obtaining all files using the target component through a regular expression; comparing any one file path using the target component with a rendering field of the first format routing configuration file; determining whether the file path using the target component is referenced in the first format routing configuration file according to a comparison result; in response to the file path using the target component not being referenced in the first format routing configuration file, determining routing information of the file using the target component through a recursive tracing algorithm, and adding the routing information to a use chain of the target component; in response to all files using the target component being processed, establishing a mapping relationship among the target component, a target component file, and corresponding routing information, and generating a component routing association analysis report according to the mapping relationship.
[0074] The technical scheme provided by the embodiments of the present application has the following beneficial effects: The embodiments of the present application combine a recursive upward tracing component dependency tracking mechanism, and fully utilize the high-performance algorithm capability of a Rust program and the rich ecological system of a scanning script, thereby significantly improving the accuracy, completeness and adaptability of component analysis.
[0075] Compared with a traditional manual analysis method, the technical scheme provided by the embodiments of the present application significantly improves the analysis speed; it only takes 2-3 hours to analyze 1000 components; the memory management mechanism of the Rust program significantly improves the memory usage efficiency; efficient memory management can support larger-scale project analysis; and multi-thread parallel processing significantly improves the CPU utilization of the processor.
[0076] Embodiment five The present application provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following component routing association analysis method can be performed: create a project and a component to be analyzed in the project, and set the component to be analyzed as a target component; receive an instruction for route association analysis of the target component; parse route configuration files of the project through a scanning script module, obtain all route configuration files of the project, and convert the route configuration files of the project into a first format; traverse all component files in the project, and obtain all files using the target component through a regular expression; compare a file path of any file using the target component with a rendering field of the first format route configuration file; determine whether the file path of the file using the target component is referenced in the first format route configuration file according to a comparison result; in response to the file path of the file using the target component not being referenced in the first format route configuration file, determine route information of the file using the target component through a recursive tracing algorithm, and add the route information to a use chain of the target component; in response to all files using the target component being processed, establish a mapping relationship among the target component, a target component file, and corresponding route information, and generate a component route association analysis report according to the mapping relationship.
[0077] The technical scheme provided by the embodiment of the application has the following beneficial effects: The technical scheme provided by the embodiment of the application shortens the development time: the component route association analysis time is shortened from 2-3 workdays to 2-3 hours; the automatic analysis reduces manual errors and reduces maintenance costs; new team members can quickly understand the project structure and shorten the learning time; the best balance between performance and development efficiency is achieved through the bilingual architecture; the recursive tracing algorithm is original in the field of Vue component analysis; and a replicable technical scheme is provided for architecture analysis of a large front-end project.
[0078] Embodiment six The application further provides a computer program product, which comprises a computer program that can implement the following component route association analysis method when executed by a processor: create a project and a component to be analyzed in the project, and set the component to be analyzed as a target component; receive an instruction for route association analysis of the target component; parse route configuration files of the project through a scanning script module, obtain all route configuration files of the project, and convert the route configuration files of the project into a first format; traverse all component files in the project, and obtain all files using the target component through a regular expression; comparing any one file path using the target component with a rendering field of the first format routing configuration file; determining whether the file path using the target component is referenced in the first format routing configuration file according to the comparison result; in response to the file path using the target component not being referenced in the first format routing configuration file, determining routing information of the file using the target component through a recursive tracing algorithm, and adding the routing information to a use chain of the target component; in response to all files using the target component being processed, establishing a mapping relationship between the target component, the target component file and the corresponding routing information, and generating a component routing association analysis report according to the mapping relationship.
[0079] The technical scheme provided by the embodiments of the present application has the following beneficial effects: The embodiments of the present application combine the recursive upward tracing component dependency tracking mechanism, and fully utilize the high-performance algorithm capability of the Rust program and the rich ecological system of the scanning script, thereby significantly improving the accuracy, completeness and adaptability of component analysis.
[0080] Compared with the traditional manual analysis method, the technical scheme provided by the embodiments of the present application significantly improves the analysis speed; it only takes 2-3 hours to analyze 1000 components; the memory management mechanism of the Rust program significantly improves the memory usage efficiency; efficient memory management can support larger-scale project analysis; and multi-thread parallel processing significantly improves the CPU utilization.
[0081] Compared with the traditional manual search method, the technical scheme provided by the embodiments of the present application has high analysis accuracy; the use of Abstract Syntax Tree (AST) parsing technology can accurately identify various JavaScript syntax structures, greatly reducing false negatives and omissions; an intelligent matching strategy effectively reduces false positive results; through AST parsing and various matching strategies, the code and comments can be accurately distinguished, significantly reducing the false positive rate; the recursive tracing algorithm ensures that no deep component association is missed; through recursive upward tracing, the complete component dependency link can be found, effectively reducing the false negative rate.
[0082] Embodiment seven The present application provides a computer storage medium, including a memory, a processor and a computer program stored on the memory and executable on the processor, and the processor executes the computer program to implement the following steps: creating a project and a component to be analyzed in the project, and setting the component to be analyzed as a target component; receiving an instruction for routing association analysis of the target component; The route configuration files of the project are parsed by a scanning script module to obtain all route configuration files of the project, and the route configuration files of the project are converted into a first format; All component files in the project are traversed, and all files using the target component are obtained through a regular expression; Any file path using the target component is compared with a rendering field of the first format route configuration file; It is determined whether the file path using the target component is referenced in the first format route configuration file according to a comparison result; In response to the file path using the target component not being referenced in the first format route configuration file, route information of the file using the target component is determined through a recursive tracing algorithm, and the route information is added to a use chain of the target component; In response to all files using the target component being processed, a mapping relationship between the target component, the target component file and corresponding route information is established, and a component route association analysis report is generated according to the mapping relationship.
[0083] In one embodiment, the route configuration files of the project are parsed by a scanning script module to obtain all route configuration files of the project, and the route configuration files of the project are converted into a first format, including: Starting a component analyzer; A scanning script module is called through the component analyzer, and a route configuration file of the project is analyzed through an abstract syntax tree parser of the scanning script module; All route configuration files of the project are obtained, and the route configuration files of the project are converted into a first format through a scanning script module; Each route configuration file includes a file path, a file name, a file rendering field and a metadata field.
[0084] In one embodiment, all component files in the project are traversed, and all files using the target component are obtained through a regular expression, including: All component files in the project are traversed; The target component is matched by importing a target component name import statement using a regular expression; All files using the target component are extracted from all component files in the project.
[0085] In one embodiment, the route information of the file using the target component is determined through a recursive tracing algorithm, and the route information is added to the use chain of the target component, including: Set the file using the target component as a first file; Obtain the parent component name corresponding to the first file; Determine whether the parent component name corresponding to the first file exists; In response to the parent component name corresponding to the first file existing, determine the routing information of the first file through a recursive tracing algorithm, and add the routing information of the first file to the use chain of the target component; In response to the parent component name corresponding to the first file not existing, continue to perform component routing association analysis on other files using the target component.
[0086] In one of the embodiments, the determination of the routing information of the first file through the recursive tracing algorithm and the addition of the routing information of the first file to the use chain of the target component include: Determine whether there is a page component corresponding to the first file through the recursive tracing algorithm; In response to the first file having a corresponding page component, add the routing information corresponding to the first file to the use chain of the target component, and continue to perform component routing association analysis on other files using the target component; In response to the first file not having a corresponding page component, continue to determine the routing information of the first file through the recursive tracing algorithm, and in response to the upward tracing reaching the root directory of the project, end the tracing process.
[0087] In one of the embodiments, the establishment of the mapping relationship among the target component, the target component file, and the corresponding routing information, and the generation of a component routing association analysis report according to the mapping relationship include: Associate the file using the target component with the routing information corresponding to the file, add the routing information corresponding to all files using the target component to the use chain of the target component, establish the mapping relationship among the target component, the target component file, and the corresponding routing information, obtain the use chain of the target component according to the mapping relationship, generate a component routing association analysis report according to the use chain of the target component, and output the component routing association analysis report; The output of the component routing association analysis report includes: Output the component routing association analysis report in a tree structure and / or JSON format and / or HTML report and / or Markdown format.
[0088] In one of the embodiments, the method includes: In response to the file path of the use target component being referenced in the first format routing configuration file, the routing information of the file of the use target component is obtained, and the routing information of the file of the use target component is added to the use chain of the target component; determining whether all files using the target component have determined corresponding routing information; In response to all files using the target component having determined corresponding routing information, a mapping relationship between the target component, the file of the target component, and the corresponding routing information of the file is established, and a component routing association analysis report is generated according to the mapping relationship; and in response to there being other files using the target component that have not determined corresponding routing information, the recursive tracing algorithm is used again to determine the corresponding routing information of the other files using the target component.
[0089] The technical scheme provided in the embodiments of the present application significantly improves the accuracy, completeness, and adaptability of component analysis by combining the recursive upward tracing component dependency tracking mechanism, and fully utilizing the high-performance algorithm capability of the Rust program and the rich ecological system of the scanning script.
[0090] Compared with the traditional manual analysis method, the technical scheme provided in the embodiments of the present application significantly improves the analysis speed; it only takes 2-3 hours to analyze 1000 components; the memory management mechanism of the Rust program significantly improves the memory usage efficiency; efficient memory management can support larger-scale project analysis; and multi-thread parallel processing significantly improves the utilization rate of the processor CPU.
[0091] Compared with the traditional manual search method, the technical scheme provided in the embodiments of the present application is less prone to errors in terms of analysis accuracy; the use of Abstract Syntax Tree (AST) parsing technology can accurately identify various JavaScript syntax structures, significantly reducing false positives and omissions; intelligent matching strategies effectively reduce false positive results; through AST parsing and various matching strategies, the code and comments can be accurately distinguished, significantly reducing the false positive rate; the recursive tracing algorithm ensures that no deep component associations are missed; through recursive upward tracing, the complete component dependency chain can be found, effectively reducing the false negative rate.
[0092] The technical scheme provided in the embodiments of the present application can handle larger-scale Vue projects; through efficient memory management and multi-thread processing of the Rust program, projects containing thousands of components can be stably processed; various Vue project structures and configuration methods are supported; through AST parsing and intelligent path matching, various different Vue project configurations can be adapted; deeper component nesting relationships can be analyzed; through the recursive tracing algorithm, deeper component dependency relationships can be analyzed.
[0093] The technical scheme provided by the embodiment of the application shortens the development time: the component route association analysis time is shortened from 2-3 workdays to 2-3 hours; the automatic analysis reduces manual errors and reduces maintenance costs; new team members can quickly understand the project structure and shorten the learning time; the best balance between performance and development efficiency is achieved through the bilingual architecture; the recursive traceability algorithm is pioneering in the field of Vue component analysis; and a replicable technical scheme is provided for architecture analysis of a large front-end project.
[0094] Figure 7 The exemplary system provided by the seventh embodiment of the application can be used to implement various embodiments described in the application. As Figure 7 shown, in some embodiments, the system can be used as the above-mentioned device for component route association analysis in any of the described embodiments. In some embodiments, the system can include one or more computer-readable media (for example, system memory or NVM / storage device) having results and one or more processors (for example, processor(s)) coupled to the one or more computer-readable media and configured to execute the results to implement modules to perform the actions described in the application.
[0095] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments. Any reference to memory, storage, database or other medium used in the embodiments provided by the application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM) and memory bus dynamic RAM (RDRAM).
[0096] Any combination of the technical features in the above embodiments can be made, and for the sake of brevity, not all possible combinations are described above, however, as long as the combination of the technical features does not exist in contradiction, it shall be considered within the scope of the present disclosure.
[0097] The above embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it shall not be understood as a limitation on the patent scope of the present application. It shall be pointed out that, for ordinary skilled persons in the art, several modifications and improvements can be made without departing from the concept of the present application, and these shall be within the protection scope of the present application. Therefore, the patent protection scope of the present application shall be subject to the appended claims.< / componentname> < / routeinfo>
Claims
1. An assembly routing correlation analysis method, characterized by, The method comprises: creating a project and a component to be analyzed in the project, and setting the component to be analyzed as a target component; receiving an instruction for route association analysis of the target component; parsing route configuration files of the project through a scanning script module, obtaining all route configuration files of the project, and converting all route configuration files of the project into a first format; traversing all component files in the project, and obtaining all files using the target component through a regular expression; comparing a file path of any file using the target component with a rendering field of the first format route configuration file; judging whether the file path of the file using the target component is referenced in the first format route configuration file according to a comparison result; in response to the file path of the file using the target component not being referenced in the first format route configuration file, determining route information of the file using the target component through a recursive tracing algorithm, and adding the route information to a use chain of the target component; in response to all files using the target component being processed, establishing a mapping relationship among the target component, a target component file, and corresponding route information, and generating a component route association analysis report according to the mapping relationship.
2. The component route association analysis method according to claim 1, wherein, The parsing of the route configuration files of the project through the scanning script module, the obtaining of all route configuration files of the project, and the conversion of all route configuration files of the project into the first format comprise: starting a component analyzer; calling the scanning script module through the component analyzer, and analyzing the route configuration files of the project through an abstract syntax tree parser of the scanning script module; obtaining all route configuration files of the project, and converting all route configuration files of the project into the first format through the scanning script module; wherein each route configuration file comprises a file path, a file name, a file rendering field, and a metadata field.
3. The component route association analysis method of claim 1, wherein, The traversing of all component files in the project and the obtaining of all files using the target component through the regular expression comprise: traversing all component files in the project; matching the target component by importing a target component name import statement through the regular expression; extracting all files using the target component from all component files in the project.
4. The method of claim 1, wherein, The determination of the route information of the file using the target component through the recursive tracing algorithm and the addition of the route information to the use chain of the target component comprise: setting the file using the target component as a first file; obtaining a parent component name corresponding to the first file; judging whether the parent component name corresponding to the first file exists; in response to the parent component name corresponding to the first file existing, determining route information of the first file through the recursive tracing algorithm, and adding the route information of the first file to the use chain of the target component; in response to the parent component name corresponding to the first file not existing, continuing component route association analysis on other files using the target component.
5. The component route association analysis method according to claim 4, wherein, The determination of the route information of the first file through the recursive tracing algorithm and the addition of the route information to the use chain of the target component comprise: determining whether the first file corresponds to a page component through a recursive tracing algorithm; in response to the first file corresponding to a page component, adding route information corresponding to the first file to a use chain of the target component, and continuing component route association analysis on other files using the target component; in response to the first file not corresponding to a page component, continuing to trace upwards to determine route information of the first file through a recursive tracing algorithm, and ending the tracing process in response to reaching a root directory of the project.
6. The method of claim 1, wherein, The mapping relationship between the target component, the target component file, and the corresponding route information is established, and a component route association analysis report is generated according to the mapping relationship, including: correlating the file using the target component with route information corresponding to the file, adding route information corresponding to all files using the target component to the use chain of the target component, establishing a mapping relationship between the target component, the target component file, and the route information corresponding to the file, obtaining a use chain of the target component according to the mapping relationship, generating a component route association analysis report according to the use chain of the target component, and outputting the component route association analysis report; The component route association analysis report is outputted, including: The component route association analysis report is outputted through a tree structure and / or JSON format and / or HTML report and / or Markdown format.
7. The method of claim 1, wherein, The method includes: in response to the file path using the target component being referenced in the first format route configuration file, obtaining route information of the file using the target component, and adding the route information of the file using the target component to the use chain of the target component; determining whether all files using the target component have determined corresponding route information; in response to all files using the target component having determined corresponding route information, establishing a mapping relationship between the target component, the target component file, and the route information corresponding to the file, and generating a component route association analysis report according to the mapping relationship; in response to there being other files using the target component that have not determined corresponding route information, re-determining corresponding route information of the other files using the target component through a recursive tracing algorithm.
8. An assembly routing correlation analysis apparatus, characterized by, The device includes: a creation module configured to create a project and a component to be analyzed in the project, and set the component to be analyzed as a target component; a receiving module configured to receive an instruction for route association analysis of the target component; a parsing module configured to parse route configuration files of the project through a scanning script module, obtain all route configuration files of the project, and convert the route configuration files of the project into a first format; an obtaining module configured to traverse all component files in the project, and obtain files using the target component through a regular expression; a comparison module configured to compare any one file path using the target component with a rendering field of the first format route configuration file; A judging module is configured to judge whether the file path of the target component is referenced in the first format routing configuration file according to the comparison result; A determining module is configured to, in response to the file path of the target component not being referenced in the first format routing configuration file, determine routing information of a file of the target component by a recursive tracing algorithm, and add the routing information to a use chain of the target component; An analyzing module is configured to, in response to all files of the target component being processed, establish a mapping relationship among the target component, a file of the target component, and corresponding routing information, and generate a component routing correlation analysis report according to the mapping relationship.
9. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the steps of the component routing correlation analysis method in any one of claims 1 to 7.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the component routing correlation analysis method in any one of claims 1 to 7.