Project file display method and device, storage medium and computer device
By using abstract syntax tree parsing and evaluation algorithms, the topological structure and complexity assessment of project files are established, solving the problem of unintuitive project file display and enabling clearer project file maintenance and updates.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- KANG JIAN INFORMATION TECH (SHENZHEN) CO LTD
- Filing Date
- 2022-09-14
- Publication Date
- 2026-07-24
AI Technical Summary
The existing project file display method cannot intuitively present the topology and module complexity, which is not conducive to the updating and maintenance of project files.
The abstract syntax tree is used to parse the content attributes of the project file into a file syntax tree structure, calculate the complexity of code elements, and build a topology based on reference attributes. The complexity and topology of the project file are then displayed graphically.
This makes the project documents clear in structure and relationships, reduces the time and cost of understanding and maintenance, and improves the presentation of project documents.
Smart Images

Figure CN115374315B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology and can be applied to the front-end development of project files in the field of digital healthcare. In particular, it relates to a method and apparatus for displaying project files, a storage medium, and computer equipment. Background Technology
[0002] With the popularity of standardized modular systems, more and more front-end projects are being developed modularly based on module standards. Typically, a front-end project contains many project files, and the topological relationships between these project files are relatively complex. Furthermore, the code complexity of the project files cannot be expressed intuitively.
[0003] In traditional front-end projects, technical documentation typically describes the physical structure and module functionality of the project. Each project update requires maintaining and updating the corresponding modules within the project files. However, this text-based approach fails to intuitively present the topological structure and module complexity of the project files, hindering project file updates and maintenance. Summary of the Invention
[0004] In view of this, the present invention provides a method and apparatus for displaying project files, a storage medium, and a computer device. The main purpose is to solve the problem that existing display methods cannot intuitively present the topological structure and module complexity between project files, which is not conducive to the updating and maintenance of project files.
[0005] According to one aspect of the present invention, a method for displaying project documents is provided, comprising:
[0006] For project files in the directory structure, an abstract syntax tree is used to parse the content attributes of each project file into a file syntax tree structure. Each node in the file syntax tree structure represents a line of text source code in the project file, and each line of text source code corresponds to a parsed code element.
[0007] The code elements corresponding to each line of text source code in the project file are analyzed, and the complexity of the text source code in the project file is evaluated using an evaluation algorithm set for the code elements, so as to obtain the complexity evaluation result of the project file.
[0008] Establish the topological structure between project files based on the reference attributes corresponding to the project files;
[0009] In response to the display of project files, the complexity assessment results of the project files and the topological structure between the project files are displayed according to the operation functions corresponding to the project files.
[0010] Furthermore, for project files in the directory structure, the abstract syntax tree is used to parse the content attributes of each project file into a file syntax tree structure, including:
[0011] Traverse the project files in the directory structure and record the attribute information of each project file and the directory level to which the project file belongs;
[0012] Based on the attribute information of each project file and the directory level to which the project file belongs, the content attributes of each project file are parsed into a file syntax tree structure using an abstract syntax tree.
[0013] Further, the step of parsing the content attributes of each project file into a file syntax tree structure using an abstract syntax tree based on the attribute information of each project file and the directory level to which the project file belongs includes:
[0014] The system iterates through the directory hierarchy to retrieve the attribute information of each project file, and obtains the content attributes and file type of each project file.
[0015] Determine the syntax for parsing the text source code based on the file type of each project file;
[0016] According to the syntax of the parsed text source code, each line of text source code in the content attribute of each project file is read, and lexical analysis and syntax analysis are performed on each line of text source code. The analyzed code elements are mapped to the structure corresponding to the abstract syntax tree to obtain the file syntax tree structure.
[0017] Furthermore, for each line of text source code in the statistical project file corresponding to the parsed code element, the complexity of the text source code in the project file is evaluated using an evaluation algorithm defined for the code element, resulting in a complexity evaluation result for the project file, including:
[0018] Analyze the code elements parsed from each line of text source code in the project file, and obtain the function type corresponding to the code elements;
[0019] Based on the function type corresponding to the code element, an evaluation algorithm for the complexity of code element execution analysis is determined, and the evaluation algorithm includes evaluation conditions set for the code element on different complexity dimensions;
[0020] The complexity of the project file is evaluated using the evaluation criteria set for code elements on different complexity dimensions, resulting in a complexity evaluation result for the project file.
[0021] Furthermore, the step of evaluating the complexity of the project file using the evaluation conditions set for code elements on different complexity dimensions to obtain the complexity evaluation result of the project file includes:
[0022] For each project file, the evaluation criteria set for the code elements of each functional type on different complexity dimensions are executed.
[0023] Determine whether the project file matches the evaluation criteria set on different complexity dimensions for the code elements of each functional type;
[0024] If so, the complexity assessment result of the project file is obtained based on the project file's hit assessment conditions.
[0025] The process of obtaining the complexity assessment result of the project file based on the project file hit assessment conditions includes:
[0026] Based on the evaluation criteria hit by the project files, the evaluation criteria hit by the code elements of each functional type on different complexity dimensions are summarized respectively.
[0027] For each type of function, the evaluation criteria that the code elements meet on different complexity dimensions are calculated, and the evaluation scores of the code elements of that function type are calculated accordingly.
[0028] Based on the proportion of code elements of each functional type in the analysis complexity, the evaluation scores of the corresponding complexity of the code elements of the functional type are weighted and calculated to obtain the complexity evaluation result of the project file.
[0029] Furthermore, establishing the topological structure between project files based on the reference attributes corresponding to the project files includes:
[0030] Based on the reference attributes of the project file, iterate through and query the content attributes of the project file corresponding to the reference attributes;
[0031] The content attributes of the project files corresponding to the reference attributes are assigned to the project files to obtain the reference information between project files;
[0032] The topological structure between project files is established by utilizing the reference information between the project files.
[0033] Furthermore, the step of displaying the complexity assessment results of the project files and the topological structure between the project files based on the corresponding operation functions includes:
[0034] Based on the first view operation function corresponding to the project file, the complexity evaluation result of the project file is displayed using view labels;
[0035] Based on the second view operation function corresponding to the project file, the topological structure between the project files is displayed using view lines.
[0036] According to another aspect of the present invention, a project document display device is provided, comprising:
[0037] The parsing module is used to parse the content attributes of each project file into a file syntax tree structure using an abstract syntax tree for the project files in the directory structure. Each node in the file syntax tree structure represents a line of text source code in the project file, and each line of text source code corresponds to a parsed code element.
[0038] The evaluation module is used to count the code elements parsed from each line of text source code in the project file, and to evaluate the complexity of the text source code in the project file using an evaluation algorithm set for the code elements, so as to obtain the complexity evaluation result of the project file.
[0039] Create a module to establish the topological structure between project files based on the reference attributes of the project files;
[0040] The display module is used to respond to the display of project files, and to show the complexity evaluation results of the project files and the topological structure between the project files according to the operation functions corresponding to the project files.
[0041] Furthermore, the parsing module is specifically used to traverse the project files in the directory structure, record the attribute information of each project file and the directory level to which the project file belongs; and use an abstract syntax tree to parse the content attributes of each project file into a file syntax tree structure based on the attribute information of each project file and the directory level to which the project file belongs.
[0042] Furthermore, the parsing module is specifically used to traverse and query the attribute information of each project file according to the directory hierarchy to which the project file belongs, to obtain the content attributes and file type of each project file; to determine the syntax of the parsed text source code according to the file type of each project file; to read each line of text source code in the content attributes of each project file according to the syntax of the parsed text source code, to perform lexical analysis and syntax analysis on each line of text source code, and to map the analyzed code elements to the structure corresponding to the abstract syntax tree to obtain the file syntax tree structure.
[0043] Furthermore, the evaluation module is specifically used to statistically analyze the code elements parsed from each line of text source code in the project file, and obtain the function type corresponding to the code element; based on the function type corresponding to the code element, determine the evaluation algorithm for the complexity of the code element's execution analysis, the evaluation algorithm including evaluation conditions set for the code element on different complexity dimensions; and use the evaluation conditions set for the code element on different complexity dimensions to evaluate the complexity of the project file, thereby obtaining the complexity evaluation result of the project file.
[0044] Furthermore, the evaluation module is specifically used to execute the evaluation conditions set on different complexity dimensions for the code elements of each functional type for the project file; determine whether the project file hits the evaluation conditions set on different complexity dimensions for the code elements of each functional type; if so, obtain the complexity evaluation result of the project file based on the fact that the project file hits the evaluation conditions.
[0045] The evaluation module is further configured to: summarize the evaluation conditions hit by code elements of each functional type on different complexity dimensions according to the evaluation conditions hit by the project file; calculate the evaluation score of the complexity corresponding to the code elements of each functional type for the evaluation conditions hit on different complexity dimensions; and perform a weighted calculation of the evaluation score of the complexity corresponding to the code elements of each functional type according to the proportion of the code elements of each functional type in the analysis complexity, so as to obtain the complexity evaluation result of the project file.
[0046] Furthermore, the establishment module is specifically used to traverse and query the content attributes of the project files corresponding to the reference attributes based on the reference attributes of the project files; and assign the content attributes of the project files corresponding to the reference attributes to the project files to obtain the reference information between project files;
[0047] The topological structure between project files is established by utilizing the reference information between the project files.
[0048] Furthermore, the display module is specifically used to display the complexity evaluation result of the project file using view labels according to the first view operation function corresponding to the project file; and to display the topological structure between the project files using view lines according to the second view operation function corresponding to the project file.
[0049] According to another aspect of the present invention, a storage medium is provided, wherein at least one executable instruction is stored therein, the executable instruction causing a processor to perform an operation corresponding to the presentation method of the above-described project file.
[0050] According to another aspect of the present invention, a computer device is provided, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus;
[0051] The memory is used to store at least one executable instruction, which causes the processor to perform the operation corresponding to the display method of the above-mentioned project file.
[0052] By employing the above-described technical solutions, the technical solutions provided by the embodiments of the present invention have at least the following advantages:
[0053] This invention provides a method, apparatus, storage medium, and computer device for displaying project files. Compared with the prior art, this invention, for project files in a directory structure, uses an abstract syntax tree to parse the content attributes of each project file into a file syntax tree structure. Each node in the file syntax tree structure represents a line of text source code in the project file. For each line of text source code, there is a parsed code element. Then, the parsed code elements corresponding to each line of text source code in the project file are counted. An evaluation algorithm set for the code element is used to evaluate the complexity of the text source code in the project file, and the complexity evaluation result of the project file is obtained. According to the reference attributes of the project files, a topological structure between project files is established. In response to the display of project files, the complexity evaluation result of the project files and the topological structure between project files are displayed according to the operation functions corresponding to the project files. This process uses a graphical method to display project files, making the project files structurally clear and the relationships clear. It can more intuitively display the topological structure and module complexity between project files, reduce the time cost and effort of understanding project files, and facilitate the updating and maintenance of project files.
[0054] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0055] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0056] Figure 1 A flowchart illustrating a project file display method provided by an embodiment of the present invention is shown;
[0057] Figure 2 This invention provides a flowchart of another method for displaying project files according to an embodiment of the invention.
[0058] Figure 3 This illustrates a flowchart of the syntax parsing of project files provided in an embodiment of the present invention;
[0059] Figure 4 This invention provides a flowchart of another method for displaying project files according to an embodiment of the invention.
[0060] Figure 5This invention provides a flowchart for evaluating the complexity of project documents according to an embodiment of the invention.
[0061] Figure 6 This invention provides a flowchart of another method for displaying project files according to an embodiment of the invention.
[0062] Figure 7 This invention provides a flowchart of another method for displaying project files according to an embodiment of the invention.
[0063] Figure 8 The diagram shows a display effect of the project file provided in an embodiment of the present invention;
[0064] Figure 9 This diagram illustrates a block diagram of a project file display device provided in an embodiment of the present invention.
[0065] Figure 10 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention is shown. Detailed Implementation
[0066] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0067] In existing front-end projects, technical documentation typically describes the physical structure and module functionality of a project. Each project update requires maintaining and updating the corresponding modules within the project files. However, this text-based approach fails to intuitively present the topological structure and module complexity of the project files, hindering project file updates and maintenance.
[0068] Furthermore, to intuitively present the topological structure and module complexity between project files, this embodiment of the invention provides a method for displaying project files, such as... Figure 1 As shown, the method includes:
[0069] 101. For project files in the directory structure, use an abstract syntax tree to parse the content attributes of each project file into a file syntax tree structure.
[0070] Typically, the directory structure is automatically generated when project files are created to facilitate project file management. Specifically, project files can include source code resources and content resources. Source code resources mainly refer to the text-based source code written by the developer, such as JS, HTML, CSS, and templates. Content resources mainly refer to resources intended for visitors, such as images, fonts, Flash, and PDFs. Furthermore, to help administrators understand the project file content, project files in this directory structure can be named using abbreviations based on their content. For example, `src` represents the source file directory, `js` represents JavaScript scripts, and `css` represents stylesheets. Further, to facilitate project file retrieval, the directory structure can be logically divided into multiple subdirectories, each serving as a business directory and recording project files containing relevant common business resources.
[0071] In this embodiment, the Abstract Syntax Tree (AST) can be used. An AST is a tree-like representation of the abstract syntactic structure of source code. Each node in the tree represents a structure within the source code. The AST does not represent every detail of the actual syntax; nested parentheses are implicitly embedded in the tree structure and not presented as nodes. ASTs can be applied in many fields, such as browsers, intelligent editors, and compilers. Here, each node in the file syntax tree structure represents a line of text source code in the project file. Each line of text source code corresponds to a parsed code element, which represents the specific meaning of the parsed code, such as code type, expression, syntax, method, etc. These can be specifically displayed in the file syntax tree structure using tags.
[0072] 102. Analyze the code elements obtained from parsing each line of text source code in the project file, and use the evaluation algorithm set for the code elements to evaluate the complexity of the text source code in the project file, and obtain the complexity evaluation result of the project file.
[0073] Considering that code elements in project files correspond to different functional types, and the reference standards for the complexity of code elements of different functional types are different, different complexity evaluation methods should be used. For example, using a certain number of nestings in code elements of some functional types is not a sign of complexity, and using too many statements in code of some functional types is not a sign of complexity.
[0074] The specific evaluation algorithm for code elements can use evaluation conditions set for code elements of different functional types on different complexity dimensions to judge the project file. For example, more than 100 lines of code are judged as low complexity, more than 300 lines of code are judged as high complexity, more than 20 statements of code are judged as low complexity, more than 30 statements of code are judged as high complexity, more than 15 nested elements of code are judged as low complexity, and more than 25 nested elements of code are judged as high complexity. The final complexity evaluation result of the project file can be obtained by summing the results of judging the project file using the evaluation conditions set for code elements of different functional types on different complexity dimensions. Specifically, the summed result can be the complexity level of the project file, such as slightly complex, low complex, high complex, etc., or the complexity score of the project file. Specifically, the results of judging the project file using the evaluation conditions set for code elements of different functional types on different complexity dimensions can be presented as scores, and then the complexity scores corresponding to multiple judgment results can be summarized to obtain the final complexity score of the project file.
[0075] 103. Based on the reference attributes of the project files, establish the topological structure between the project files.
[0076] The reference attributes corresponding to project files can be information about how project files import modules from other project files. Specifically, this can be represented as hyperlinks. By traversing the reference attributes of each project file, the content of the project files referenced by the reference attributes is assigned to the current project file. Based on the position of the project files referenced by the reference attributes in the file syntax tree structure, the topological relationship between project files is established.
[0077] 104. In response to the display of project files, display the complexity assessment results of the project files and the topological structure between the project files according to the operation functions corresponding to the project files.
[0078] The process can be illustrated using diagrams to render the project files in the directory structure. The topology between project files is displayed according to the corresponding operation functions of the project files. This topology can be represented by the number of modules in other project files referenced by a project file, as well as the complexity assessment result of the project file. This complexity assessment result can be represented by excessive nesting or excessively long code. Further operation functions can be used to view the module content of other project files referenced by a project file, etc.
[0079] The operation functions corresponding to the project files can be displayed through tags or directly through clicks. Considering the limited display space on the interface, the complexity assessment results and the topological structure between the project files can be enlarged here.
[0080] In one implementation, the above-mentioned project file display can be used in front-end project development scenarios in digital healthcare. Specifically, it can be used to assess the complexity of project files in the digital healthcare field and establish topological relationships between project files, making the project files structurally clear and their relationships well-defined. It can intuitively display the complexity assessment results of the project files and the topological relationships between the project files, thereby improving the display effect of project files in the digital healthcare field. Furthermore, the process of performing the complexity assessment of project files and establishing the topological relationships between project files requires maintaining the corresponding medical data and related information.
[0081] Understandably, the aforementioned publicly available medical data and related information can be obtained through a medical cloud. A medical cloud refers to a cloud platform for healthcare services created using cloud computing, mobile technology, multimedia, 4G communication, big data, and the Internet of Things, combined with medical technology. This enables the sharing of medical resources and expands the scope of medical care. Because of the application of cloud computing technology, the medical cloud improves the efficiency of medical institutions and facilitates access to medical care for residents. Features such as hospital appointment booking, electronic medical records, and medical insurance are all products of the integration of cloud computing and the medical field. The medical cloud also offers advantages such as data security, information sharing, dynamic expansion, and a global reach.
[0082] In another embodiment of the invention, for further definition and explanation, such as Figure 2 As shown, the steps, for project files in the directory structure, use an abstract syntax tree to parse the content attributes of each project file into a file syntax tree structure, including:
[0083] 201. Traverse the project files in the directory structure and record the attribute information of each project file and the directory level to which the project file belongs.
[0084] 202. Based on the attribute information of each project file and the directory level to which the project file belongs, use an abstract syntax tree to parse the content attributes of each project file into a file syntax tree structure.
[0085] Considering the hierarchical structure of directories, when traversing project files within the directory structure, we can start from the root directory. The root directory refers to the top-level directory on a logical drive, relative to subdirectories. For example, opening "My Computer," double-clicking drive C leads to the root directory of drive C, double-clicking drive D leads to the root directory of drive D, and further double-clicking a file in the root directory leads to a subdirectory. Typically, the root directory is created when the project file system is established, and its purpose is to store directory entries for subdirectories or files. Specifically, we traverse project files from the root directory to subdirectories within the directory structure, recording the attribute information of each project file during the traversal. The address of the project file is stored in the address attribute, the source code content of the project file is stored in the content attribute, and the filename of the project file is stored in the name attribute, thus generating unique object attributes. After parsing all project files at each level of the directory structure, the hierarchical relationship of the project files is stored in the directory attributes according to the corresponding hierarchical relationship of the directory structure.
[0086] Specifically, in the process of using an abstract syntax tree to parse the content attributes of each project file into a file syntax tree structure, the attribute information of each project file can be traversed and queried according to the directory hierarchy to which the project file belongs, so as to obtain the content attributes and file type of each project file. Then, based on the file type of each project file, the syntax for parsing the text source code is determined. According to the syntax for parsing the text source code, each line of text source code in the content attributes of each project file is read. Lexical analysis and syntax analysis are performed on each line of text source code, and the code elements obtained from the analysis are mapped to the corresponding structure of the abstract syntax tree to obtain the file syntax tree structure.
[0087] In practical applications, different file types use different syntaxes to parse text source code using abstract syntax trees. For example, such as... Figure 3 As shown, the abstract syntax tree is used to parse the project files. For .tsx / .js / .ts / .vue file types, each line of text source code in the project file is parsed to obtain the corresponding code element. Here, the code element can be a class, a function, or a general statement / expression. For the code element function, it is further determined whether it is a return / renderHTMLELEMEN structure. If it is, the code element is marked as component, and the import syntax is parsed to obtain the path attribute of each import property. Otherwise, the code element is marked as function, and the external source references in the syntax body are parsed. If they exist, the path attribute is obtained, and a file syntax structure tree is further generated. Similarly, other syntaxes for parsing text source code are used for .scss / .css / .less file types and .png / .jpg / .json types, which will not be described in detail here.
[0088] In another embodiment of the invention, for further definition and explanation, specifically, as shown below... Figure 4 As shown, the steps involve statistically analyzing the parsed code elements corresponding to each line of text source code in the project file, and then using an evaluation algorithm defined for each code element to evaluate the complexity of the text source code in the project file. The resulting complexity evaluation of the project file includes:
[0089] 301. Analyze the code elements obtained from parsing each line of text source code in the project file, and obtain the function type corresponding to the code element.
[0090] 302. Based on the functional type corresponding to the code element, determine the evaluation algorithm for the complexity of code element execution analysis.
[0091] 303. Use the evaluation conditions set for code elements on different complexity dimensions to evaluate the complexity of the project file and obtain the complexity evaluation result of the project file.
[0092] The evaluation algorithm includes evaluation conditions set for code elements on different complexity dimensions. These evaluation conditions can be expressed as whether the number of code obtained for different function types exceeds a preset value. For example, whether the number of lines of code exceeds 300, whether the number of code statements reaches 20, and whether the nesting of syntax exceeds 5 levels.
[0093] Specifically, for a project file, the evaluation conditions set for the code elements of each functional type on different complexity dimensions can be executed to determine whether the project file meets the evaluation conditions set for the code elements of each functional type on different complexity dimensions. If so, the complexity evaluation result of the project file can be obtained based on whether the project file meets the evaluation conditions.
[0094] In this embodiment, the evaluation result can be represented as an evaluation score for the complexity of the project file. For example, if the number of lines of code exceeds 300, the complexity evaluation score is set to 2 points; if the number of lines of code exceeds 200, the complexity evaluation score is set to 1 point; if the number of code statements exceeds 20, the complexity evaluation score is set to 1 point, and so on. Specifically, based on the evaluation conditions hit by the project file, the evaluation conditions hit by code elements of each functional type on different complexity dimensions are summarized. Then, for the evaluation conditions hit by code elements of each functional type on different complexity dimensions, the complexity evaluation score corresponding to the code elements of each functional type is calculated. Based on the proportion of code elements of each functional type in the complexity analysis, the complexity evaluation scores corresponding to the code elements of each functional type are weighted and calculated to obtain the complexity evaluation result of the project file. For example, if the code element corresponding to the project file has more than 200 lines of code, the complexity evaluation score increases by 1; if the code statement exceeds 20, the complexity evaluation score increases by 1; if the nesting level exceeds 5 levels, the complexity evaluation score increases by 2. If the ratio of code lines, code statements, and code nesting is 1:1:3, the complexity evaluation result for the corresponding project file is calculated as 0.2*1 + 0.2*1 + 0.6*2 = 1.6.
[0095] For example, the specific process for evaluating the complexity of project documents is as follows: Figure 5 As shown, Figure 5 First, the function type of the code element is determined. If the function type of the code element is a component type, the evaluation algorithm set for the code element is executed. If the function type of the code element is a function type, the evaluation algorithm set for the code element is executed. After determining the evaluation score corresponding to the complexity, the file syntax tree structure is merged and processed, and the complexity evaluation result corresponding to the project file is output.
[0096] In another embodiment of the invention, for further definition and explanation, specifically, as shown below... Figure 6 As shown, the steps for establishing the topology between project files based on their corresponding reference attributes include:
[0097] 401. Based on the reference attributes of the project file, iterate through and query the content attributes of the project file corresponding to the reference attributes.
[0098] 402. Assign the content attributes of the project files corresponding to the reference attributes to the project files to obtain the reference information between project files.
[0099] 403. Utilize the reference information between the project files to establish the topological structure between the project files.
[0100] In this embodiment, the reference information between project files may include the number of modules referenced by a project file in other project files, the content of the modules, and the location of the modules.
[0101] Understandably, if the reference relationship between current project file A and modules b1-b5 in project file B is such that current project file A can link to modules b1-b5 in project file B, then the content attributes of modules b1-b5 in the file syntax tree of project file B can be assigned to current project file A to establish a topological relationship between current project file A and project file B. If the reference attribute corresponding to current project file A is empty, it means that current project file does not have any referenced files, there is no need to add content from other project files, and there is no topological relationship between this project file and other project files.
[0102] In another embodiment of the invention, for further definition and explanation, specifically, as shown below... Figure 7 As shown, the steps, based on the corresponding operation functions of the project files, demonstrate the complexity evaluation results of the project files and the topological structure between the project files, including:
[0103] 501. Based on the first view operation function corresponding to the project file, use view tabs to display the complexity evaluation result of the project file.
[0104] 502. Based on the second view operation function corresponding to the project file, use view lines to display the topological structure between the project files.
[0105] In this embodiment, since the analysis results of the project files, such as the topological structure between project files and the complexity assessment results of project files, have already been obtained through the above steps, the analysis results of the project files can be graphically displayed using the added operation functions. Here, the first apostle operation function and the second view operation function can be legend icons set in the visualization interface. Clicking the legend icon can display the corresponding analysis results. For example, clicking the directory legend can display the file information in the directory structure, clicking the file legend can display the attribute information of the corresponding file, clicking the complexity legend can display the complexity assessment results of the project file, and clicking the structure legend can display the topological structure between project files.
[0106] For example, such as Figure 8As shown, the directory structure includes directory 1 with 3 files, directory 2 with 2 files, and directory 3 with 1 file. Taking directory 1 as an example, clicking on different project files in the directory displays the number of component reference modules and function reference modules in the project file, and clicking pops up the complexity evaluation result of the corresponding project file. Similarly, the above display effect can be achieved for project files in other directories.
[0107] Furthermore, as a specific implementation of the above method, embodiments of the present invention provide another project file display device, such as... Figure 9 As shown, the device includes:
[0108] Parsing module 61 is used to parse the content attributes of each project file into a file syntax tree structure using an abstract syntax tree for the project files in the directory structure. Each node in the file syntax tree structure represents a line of text source code in the project file, and each line of text source code corresponds to a parsed code element.
[0109] Evaluation module 62 is used to count the code elements parsed for each line of text source code in the project file, and to evaluate the complexity of the text source code in the project file using an evaluation algorithm set for the code elements, so as to obtain the complexity evaluation result of the project file.
[0110] Module 63 is created to establish the topology between project files based on the reference attributes of the project files.
[0111] The display module 64 is used to respond to the display of project files, and to display the complexity evaluation results of the project files and the topological structure between the project files according to the operation functions corresponding to the project files.
[0112] Furthermore, the parsing module 61 is specifically used to traverse the project files in the directory structure, record the attribute information of each project file and the directory level to which the project file belongs; and use an abstract syntax tree to parse the content attributes of each project file into a file syntax tree structure based on the attribute information of each project file and the directory level to which the project file belongs.
[0113] Furthermore, the parsing module 61 is specifically used to traverse and query the attribute information of each project file according to the directory hierarchy to which the project file belongs, to obtain the content attributes and file type of each project file; to determine the syntax of the parsed text source code according to the file type of each project file; to read each line of text source code in the content attributes of each project file according to the syntax of the parsed text source code, to perform lexical analysis and syntax analysis on each line of text source code, and to map the analyzed code elements to the structure corresponding to the abstract syntax tree to obtain the file syntax tree structure.
[0114] Furthermore, the evaluation module 62 is specifically used to statistically analyze the code elements parsed from each line of text source code in the project file, and obtain the function type corresponding to the code element; based on the function type corresponding to the code element, determine the evaluation algorithm for the complexity of the code element's execution analysis, the evaluation algorithm including evaluation conditions set for the code element on different complexity dimensions; and use the evaluation conditions set for the code element on different complexity dimensions to evaluate the complexity of the project file, thereby obtaining the complexity evaluation result of the project file.
[0115] Furthermore, the evaluation module 62 is specifically used to execute the evaluation conditions set on different complexity dimensions for the code elements of each functional type for the project file; determine whether the project file hits the evaluation conditions set on different complexity dimensions for the code elements of each functional type; if so, obtain the complexity evaluation result of the project file based on the fact that the project file hits the evaluation conditions.
[0116] The evaluation module 62 is further configured to: summarize the evaluation conditions hit by code elements of each functional type on different complexity dimensions according to the evaluation conditions hit by the project file; calculate the evaluation score of the complexity corresponding to the code elements of each functional type for the evaluation conditions hit on different complexity dimensions; and perform a weighted calculation of the evaluation score of the complexity corresponding to the code elements of each functional type according to the proportion of the code elements of each functional type in the analysis complexity, so as to obtain the complexity evaluation result of the project file.
[0117] Furthermore, the establishment module 63 is specifically used to traverse and query the content attributes of the project files corresponding to the reference attributes of the project files; and assign the content attributes of the project files corresponding to the reference attributes to the project files to obtain the reference information between project files;
[0118] The topological structure between project files is established by utilizing the reference information between the project files.
[0119] Furthermore, the display module 64 is specifically used to display the complexity evaluation result of the project file using view labels according to the first view operation function corresponding to the project file; and to display the topological structure between the project files using view lines according to the second view operation function corresponding to the project file.
[0120] This invention provides a project file display device. Compared with the prior art, this invention uses an abstract syntax tree to parse the content attributes of each project file into a file syntax tree structure for project files in a directory structure. Each node in the file syntax tree structure represents a line of text source code in the project file. For each line of text source code, there is a parsed code element. Then, the parsed code element corresponding to each line of text source code in the project file is counted, and the complexity of the text source code in the project file is evaluated using an evaluation algorithm set for the code element to obtain the complexity evaluation result of the project file. According to the reference attributes of the project file, a topological structure between project files is established. In response to the display of project files, the complexity evaluation result of the project file and the topological structure between project files are displayed according to the operation function corresponding to the project file. This process uses a graphical method to display project files, making the project files structurally clear and the relationships clear. It can more intuitively display the topological structure and module complexity between project files, reduce the time cost and effort of understanding project files, and facilitate the updating and maintenance of project files.
[0121] According to one embodiment of the present invention, a storage medium is provided, the storage medium storing at least one executable instruction, the computer-executable instruction being able to execute the project file display method in any of the above method embodiments.
[0122] Figure 10 The diagram illustrates a structural schematic of a computer device according to an embodiment of the present invention. The specific embodiments of the present invention do not limit the specific implementation of the computer device.
[0123] like Figure 10 As shown, the computer device may include: a processor 702, a communications interface 704, a memory 706, and a communications bus 708.
[0124] The processor 702, communication interface 704, and memory 706 communicate with each other via communication bus 708.
[0125] The communication interface 704 is used to communicate with other network elements such as clients or other servers.
[0126] The processor 702 is used to execute program 710, specifically to execute the relevant steps in the above-described project file demonstration method embodiment.
[0127] Specifically, program 710 may include program code that includes computer operation instructions.
[0128] Processor 702 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. The computer device includes one or more processors, which may be processors of the same type, such as one or more CPUs; or they may be processors of different types, such as one or more CPUs and one or more ASICs.
[0129] Memory 706 is used to store program 710. Memory 706 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0130] Specifically, program 710 can be used to cause processor 702 to perform the following operations:
[0131] For project files in the directory structure, an abstract syntax tree is used to parse the content attributes of each project file into a file syntax tree structure. Each node in the file syntax tree structure represents a line of text source code in the project file, and each line of text source code corresponds to a parsed code element.
[0132] The code elements corresponding to each line of text source code in the project file are analyzed, and the complexity of the text source code in the project file is evaluated using an evaluation algorithm set for the code elements, so as to obtain the complexity evaluation result of the project file.
[0133] Establish the topological structure between project files based on the reference attributes corresponding to the project files;
[0134] In response to the display of project files, the complexity assessment results of the project files and the topological structure between the project files are displayed according to the operation functions corresponding to the project files.
[0135] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0136] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for displaying project files, characterized in that, include: For project files in the directory structure, an abstract syntax tree is used to parse the content attributes of each project file into a file syntax tree structure. Each node in the file syntax tree structure represents a line of text source code in the project file, and each line of text source code corresponds to a parsed code element. The code elements corresponding to each line of text source code in the project file are analyzed to obtain the function type of each code element. Based on the function type of each code element, an evaluation algorithm for the complexity of the code element is determined. The evaluation algorithm includes evaluation conditions set for the code element on different complexity dimensions. The complexity of the project file is evaluated using the evaluation conditions set for the code element on different complexity dimensions to obtain the complexity evaluation result of the project file. The process of evaluating the complexity of the project file using the evaluation conditions set for the code element on different complexity dimensions to obtain the complexity evaluation result of the project file includes: for the project file, executing the evaluation conditions set for each function type of code element on different complexity dimensions; determining whether the project file is... The evaluation conditions set for code elements of each functional type in different complexity dimensions are described in the document; if so, the complexity evaluation result of the project file is obtained based on the evaluation conditions hit by the project file; obtaining the complexity evaluation result of the project file based on the evaluation conditions hit by the project file includes: summarizing the evaluation conditions hit by code elements of each functional type in different complexity dimensions according to the evaluation conditions hit by the project file; calculating the evaluation score of the complexity corresponding to the code elements of each functional type for each function type of code elements hit by evaluation conditions in different complexity dimensions; and weighting the evaluation scores of the complexity corresponding to the code elements of each functional type of code elements according to the proportion of each function type of code elements in the complexity analysis to obtain the complexity evaluation result of the project file. Based on the reference attributes corresponding to the project files, a topological structure between project files is established. The reference attributes corresponding to the project files are information about the project files importing modules from other project files, which are expressed in the form of hyperlinks. By traversing the reference attributes corresponding to each project file, the content of the project files referenced by the reference attributes is assigned to the current project file. Based on the position of the project files referenced by the reference attributes in the file syntax tree structure, a topological relationship between project files is established. In response to the display of project files, the complexity assessment results of the project files and the topological structure between the project files are displayed according to the operation functions corresponding to the project files.
2. The method according to claim 1, characterized in that, For project files in the directory structure, the abstract syntax tree is used to parse the content attributes of each project file into a file syntax tree structure, including: Traverse the project files in the directory structure and record the attribute information of each project file and the directory level to which the project file belongs; Based on the attribute information of each project file and the directory level to which the project file belongs, the content attributes of each project file are parsed into a file syntax tree structure using an abstract syntax tree.
3. The method according to claim 2, characterized in that, The step of parsing the content attributes of each project file into a file syntax tree structure using an abstract syntax tree, based on the attribute information of each project file and the directory level to which the project file belongs, includes: The system iterates through the directory hierarchy to retrieve the attribute information of each project file, and obtains the content attributes and file type of each project file. Determine the syntax for parsing the text source code based on the file type of each project file; According to the syntax of the parsed text source code, each line of text source code in the content attribute of each project file is read, and lexical analysis and syntax analysis are performed on each line of text source code. The analyzed code elements are mapped to the structure corresponding to the abstract syntax tree to obtain the file syntax tree structure.
4. The method according to any one of claims 1-3, characterized in that, The step of establishing a topological structure between project files based on their corresponding reference attributes includes: Based on the reference attributes of the project file, iterate through and query the content attributes of the project file corresponding to the reference attributes; The content attributes of the project files corresponding to the reference attributes are assigned to the project files to obtain the reference information between project files; The topological structure between project files is established by utilizing the reference information between the project files.
5. The method according to any one of claims 1-3, characterized in that, The description of displaying the complexity assessment results of the project files and the topological structure between the project files based on the corresponding operation functions includes: Based on the first view operation function corresponding to the project file, the complexity evaluation result of the project file is displayed using view labels; Based on the second view operation function corresponding to the project file, the topological structure between the project files is displayed using view lines.
6. A device for displaying project documents, characterized in that, include: The parsing module is used to parse the content attributes of each project file into a file syntax tree structure using an abstract syntax tree for the project files in the directory structure. Each node in the file syntax tree structure represents a line of text source code in the project file, and each line of text source code corresponds to a parsed code element. The evaluation module is used to analyze the code elements parsed from each line of text source code in the project file and obtain the function type corresponding to the code elements. Based on the functional type corresponding to the code element, an evaluation algorithm for the complexity of code element execution is determined. The evaluation algorithm includes evaluation conditions set for code elements on different complexity dimensions. The complexity of the project file is evaluated using the evaluation conditions set for code elements on different complexity dimensions to obtain a complexity evaluation result for the project file. The evaluation of the project file's complexity using the evaluation conditions set for code elements on different complexity dimensions to obtain a complexity evaluation result for the project file includes: for the project file, executing the evaluation conditions set for code elements of each functional type on different complexity dimensions; determining whether the project file matches the evaluation conditions set for code elements of each functional type on different complexity dimensions. The evaluation conditions are set on the dimension; if so, the complexity evaluation result of the project file is obtained based on the evaluation conditions hit by the project file; obtaining the complexity evaluation result of the project file based on the evaluation conditions hit by the project file includes: summarizing the evaluation conditions hit by code elements of each functional type on different complexity dimensions according to the evaluation conditions hit by the project file; for each functional type of code element on different complexity dimensions, calculating the evaluation score of the complexity corresponding to the code element of the functional type; and weighting the evaluation score of the complexity corresponding to the code element of the functional type according to the proportion of the code element of each functional type in the analysis complexity, to obtain the complexity evaluation result of the project file. The module is used to establish a topological structure between project files based on the reference attributes corresponding to the project files. The reference attributes corresponding to the project files are information about the project files importing modules from other project files, which are expressed in the form of hyperlinks. By traversing the reference attributes corresponding to each project file, the content of the project files referenced by the reference attributes is assigned to the current project file. The topological relationship between project files is established based on the position of the project files referenced by the reference attributes in the file syntax tree structure. The display module is used to respond to the display of project files, and to show the complexity evaluation results of the project files and the topological structure between the project files according to the operation functions corresponding to the project files.
7. A storage medium storing at least one executable instruction that causes a processor to perform an operation corresponding to the project file display method as described in any one of claims 1-5.
8. A computer device, comprising: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction, which causes the processor to perform the operation corresponding to the project file display method as described in any one of claims 1-5.