Project file analysis method and device, storage medium and electronic equipment
Analyzing project code files through automatic point-burying technology solves the problem of low manual debugging efficiency and achieves rapid analysis and efficiency improvement.
Patent Information
- Application Number
- CN202410682723.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2024-09-13
AI Technical Summary
In the existing technology, when analyzing project code files, manual debugging is inefficient and lacks effective solutions.
By automatically inserting hidden code into the code file, the programming language type is obtained and determined, the location of the function is located, and the target buried code is generated, and the buried code file is run to obtain analysis information.
It improves analysis efficiency, saves time and labor costs, and facilitates technicians to quickly take over projects and observe the execution of programs and functions.
Smart Images

Figure CN118642947A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of financial technology or other related fields, and in particular, to a method, device, storage medium and electronic device for analyzing project files. Background Art
[0002] When technicians take over a large and complex project, they often face problems such as not knowing where to start, where the program entry is, and which program functions will be called when operating certain functions on the interface. At present, the existing technology mainly uses manual debugging to analyze the project's code files. However, the debugging process is usually cumbersome and the analysis efficiency is low.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present invention provide a method, device, storage medium and electronic device for analyzing a project file, so as to at least solve the technical problem that the code files of a project are analyzed by manual debugging in the prior art, and the analysis efficiency is low.
[0005] According to one aspect of an embodiment of the present invention, a method for analyzing a project file is provided, comprising: obtaining multiple code files in a project folder and determining a programming language type of each code file; performing embedding processing on each code file according to the programming language type and a target embedding code to obtain a post-embedded code file corresponding to each code file, wherein the target embedding code is used to indicate the running information of the program in the acquisition and output code file during the running process; running each post-embedded code file to obtain analysis information of each code file.
[0006] Furthermore, each code file is subjected to point-embedding processing according to the programming language type and the target point-embedding code to obtain a code file after point-embedding corresponding to each code file, including: determining a point-embedding output statement corresponding to each code file according to the programming language type, and generating a target point-embedding code corresponding to each code file according to the point-embedding output statement and preset point-embedding information; locating the occurrence positions of multiple functions in each code file according to the programming language type, and determining the point-embedding position of each function according to the programming language type and the occurrence position of each function; performing point-embedding processing on each code file according to the target point-embedding code corresponding to each code file and the point-embedding position of each function in each code file to obtain a code file after point-embedding corresponding to each code file.
[0007] Furthermore, the occurrence positions of multiple functions in each code file are located according to the programming language type, including: scanning the programs in each code file respectively; if the programming language type of the code file is a target type, then when the first keyword in the program is scanned, the position of the first symbol combination after the first keyword is located, and the position of the first symbol combination is used as the occurrence position of the function, wherein the first keyword is used to define the function, and the first symbol combination consists of a closing parenthesis and a colon; if the programming language type of the code file is a type other than the target type, then when the second symbol combination is scanned, the occurrence position of the function is determined according to the position of the second symbol combination, wherein the second symbol combination consists of a closing parenthesis and an opening curly brace.
[0008] Furthermore, the appearance position of the function is determined based on the position of the second symbol combination, including: locating the position of the opening parenthesis paired with the closing parenthesis in the second symbol combination; judging whether there is a target keyword before the position of the opening parenthesis to obtain a judgment result; if the judgment result indicates that there is no target keyword before the position of the opening parenthesis, the position of the second symbol combination is used as the appearance position of the function.
[0009] Furthermore, the location of each function is determined based on the programming language type and the location of each function, including: if the programming language type of the code file is the target type, the position after the colon in the first symbol combination is used as the location of the function; if the programming language type of the code file is a type other than the target type, the position after the opening brace in the second symbol combination is used as the location of the function.
[0010] Furthermore, each code file is processed according to the target embedding code corresponding to each code file and the embedding position of each function in each code file to obtain the embedded code file corresponding to each code file, including: inserting the target embedding code corresponding to each code file into the embedding position of each function to obtain the embedded code file corresponding to each code file.
[0011] Furthermore, the code files after each embedding are run to obtain analysis information of each code file, including: when running to the target embedding code in the code files after each embedding, the running information is output; and the analysis information of each code file is determined based on the running information.
[0012] According to another aspect of an embodiment of the present invention, a device for analyzing project files is also provided, including: an acquisition module, used to acquire multiple code files in a project folder and determine the programming language type of each code file; a first processing module, used to perform embedding processing on each code file according to the programming language type and the target embedding code, and obtain the embedded code file corresponding to each code file, wherein the target embedding code is used to indicate the running information of the program in the acquisition and output code file during the running process; a second processing module, used to run each embedded code file to obtain analysis information of each code file.
[0013] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the above-mentioned project file analysis method is implemented.
[0014] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned project file analysis method when running.
[0015] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, which includes one or more processors; a memory for storing one or more programs, which, when the one or more programs are executed by the one or more processors, enables the one or more processors to run the programs, wherein the programs are configured to execute the above-mentioned project file analysis method when running.
[0016] In an embodiment of the present invention, a method of automatically inserting tracking code into a code file is adopted. First, multiple code files in a project folder are obtained, and the programming language type of each code file is determined; tracking processing is performed on each code file according to the programming language type and the target tracking code to obtain a tracking code file corresponding to each code file, wherein the target tracking code is used to indicate the running information of the program in the acquisition and output code file during the running process; each tracking code file is run to obtain analysis information of each code file.
[0017] In the above process, each code file is processed according to the programming language type and the target embedded code to obtain the embedded code file corresponding to each code file, which saves time and labor costs and provides a basis for project file analysis. By running each embedded code file, analysis information of each code file can be obtained. That is, when the project is running, the execution status of programs and functions in the project can be directly and conveniently observed, which improves the analysis efficiency.
[0018] It can be seen that the technical solution of the present invention achieves the purpose of providing convenience for technical personnel to quickly take over the project, thereby achieving the technical effect of improving analysis efficiency, and further solving the technical problem of low analysis efficiency in the prior art of analyzing the code files of the project by manual debugging. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0020] Figure 1 is a flow chart of an optional project file analysis method according to an embodiment of the present invention;
[0021] Figure 2 is a flow chart of an optional method for determining the occurrence position of a function according to an embodiment of the present invention;
[0022] Figure 3 is a schematic diagram of an optional project file analysis device according to an embodiment of the present invention;
[0023] Figure 4 is a schematic diagram of an optional electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0026] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in the present invention are all information and data authorized by the user or fully authorized by all parties. For example, an interface is set between the system and the relevant user or organization. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.
[0027] Example 1
[0028] According to an embodiment of the present invention, an embodiment of a method for analyzing a project file is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0029] Figure 1 is a flowchart of an optional project file analysis method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:
[0030] Step S101, obtaining multiple code files in a project folder, and determining the programming language type of each code file.
[0031] In the above steps, multiple code files in the project folder can be obtained through application systems, processors, electronic devices and other devices. Optionally, multiple code files in the project folder can be obtained through a project file analysis system. There will be multiple code files in a project. The programming language type of each code file can be determined based on the suffix of each code file. The programming language types include at least C language, C#, C++, Java, Python, JavaScript, Golang, PHP, etc. For example, there will be multiple files with the suffix .java in the project. All files with the suffix .java in the project folder are scanned. Whenever a .java file is found, it will be scanned line by line and character by character.
[0032] Optionally, avoid strings and comments in the program during scanning. A string in a program represents a string of text or a paragraph, and is enclosed in single or double quotes in almost all languages, such as "abcde". Therefore, if a function is written in a string, it is not considered a function, such as "main(){}". In this case, ignore it and continue scanning. The comments in the program are to explain the function of a certain section of the program, which is convenient for the technicians who take over to read. The content of the comments will be ignored when the program is running. Therefore, when identifying functions, avoid the interference of comments.
[0033] Among the eight programming languages mentioned above, except Python, the commenting methods are basically the same, which are divided into two types: single-line comments and block comments. Single-line comments use the symbol / / , and the content after / / in any line is a comment. Block comments use the symbol / ** / to enclose the code block. Python programming language single-line comments use the symbol #, and multi-line comments use triple single quotes "' or triple double quotes """ to enclose multiple lines of text. Therefore, the symbol / / , the symbol #, the symbol "" or the symbol """ can all be comment keywords. It should be noted that if the comment keyword is placed in a string, for example, a Java string "text / / text", then it cannot be used as a comment at this time.
[0034] Optionally, in the process of scanning the comment keyword, first determine whether the comment keyword is in the string. If the comment keyword is outside the string, for the symbol / / or the symbol #, ignore the code after the symbol / / or the symbol #, and directly jump to the next line to continue scanning; for the block comment keyword / *, continue to search backward to * / , and ignore any code before finding * / until * / is found.
[0035] Step S102, perform embedding processing on each code file according to the programming language type and the target embedding code to obtain the embedded code file corresponding to each code file, wherein the target embedding code is used to indicate the running information of the program in the acquisition and output code file during the running process.
[0036] Optionally, the writing methods of output statements corresponding to different programming language types are different, and thus the corresponding embedding codes are also different. By embedding each code file according to the programming language type and the target embedding code, a code file after embedding corresponding to each code file can be obtained.
[0037] In an optional embodiment, in the process of performing point embedding processing on each code file according to the programming language type and the target point embedding code to obtain the code file after point embedding corresponding to each code file, the point embedding output statement corresponding to each code file is determined according to the programming language type, and the target point embedding code corresponding to each code file is generated according to the point embedding output statement and preset point embedding information; the appearance positions of multiple functions in each code file are located according to the programming language type, and the point embedding position of each function is determined according to the programming language type and the appearance position of each function; the point embedding processing is performed on each code file according to the target point embedding code corresponding to each code file and the point embedding position of each function in each code file to obtain the code file after point embedding corresponding to each code file.
[0038] Optionally, since different programming languages have different ways of outputting content to the console, first determine the embedded output statement corresponding to each code file based on the programming language type. For example, the output statement of C language is printf(""); the output statement of C++ is cout<<""; the output statement of C# is Console.WriteLine(""); the output statement of Java is System.out.println(""); the output statement of Python is print""; the output statement of JavaScript is console.log(""); the output statement of Golang is fmt.Printf(""); and the output statement of PHP is echo"".
[0039] Optionally, the target embedding code corresponding to each code file can be generated according to the embedding output statement and the preset embedding information. Among them, the preset embedding information can be set according to the needs. For example, the preset embedding information is: xxx (such as the initials of the name, etc.), the file name and the serial number. For example, the current file name is aaa.c, for the code file whose programming language type is C language, the embedding output statement is printf(""), then the target embedding code corresponding to the code file is printf("xxx:aaa.c1").
[0040] Optionally, after eliminating interference from strings and comments, the positions where functions appear in the code files are located. Thus, the positions where multiple functions appear in each code file are located according to the programming language type. For example, for languages other than Python, the processing method is basically the same, and Python is processed separately.
[0041] Optionally, the location of each function can be determined based on the programming language type and the location of each function, and then each code file is processed based on the target location code corresponding to each code file and the location of each function in each code file, so that the code file after the location of each code file can be obtained. For example, for a code file whose programming language type is C language, the location of each function is the symbol combination consisting of the closing parenthesis and the opening curly brace, that is, the location after { in ){, as shown in the following example:
[0042]
[0043] Step S103, running each code file after embedding, and obtaining analysis information of each code file.
[0044] Optionally, after tracking each function in the code file, analysis information of each code file can be obtained by running each code file after tracking. For example, when the project is running, the execution status of the programs and functions in the project (such as the execution order, etc.) can be observed through tracking. That is, when the program runs to the tracking code, by outputting the tracking content to the console, you can know which functions the current program has executed. For example, if it is the first function of the current file aaa.java, the output of the tracking is xxx:aaa.java1, and the output of the tracking of the second function is xxx:aaa.java2.
[0045] Based on the scheme defined by the above steps S101 to S103, it can be known that in an embodiment of the present invention, a method of automatically inserting embedding codes into code files is adopted. First, multiple code files in the project folder are obtained, and the programming language type of each code file is determined; embedding processing is performed on each code file according to the programming language type and the target embedding code to obtain a code file after embedding corresponding to each code file, wherein the target embedding code is used to indicate the running information of the program in the acquisition and output code file during the running process; each code file after embedding is run to obtain analysis information of each code file.
[0046] It is easy to notice that in the above process, each code file is processed according to the programming language type and the target embedded code to obtain the embedded code file corresponding to each code file, which saves time and labor costs and provides a basis for project file analysis. By running each embedded code file, analysis information of each code file can be obtained, that is, when the project is running, the execution status of programs and functions in the project can be directly and conveniently observed, thereby improving analysis efficiency.
[0047] It can be seen that the technical solution of the present invention achieves the purpose of providing convenience for technical personnel to quickly take over the project, thereby achieving the technical effect of improving analysis efficiency, and further solving the technical problem of low analysis efficiency in the prior art of analyzing the code files of the project by manual debugging.
[0048] In an optional embodiment, the occurrence positions of multiple functions in each code file are located according to the programming language type, including: scanning the programs in each code file respectively; if the programming language type of the code file is a target type, then when the first keyword in the program is scanned, the position of the first symbol combination after the first keyword is located, and the position of the first symbol combination is used as the occurrence position of the function, wherein the first keyword is used to define the function, and the first symbol combination consists of a closing parenthesis and a colon; if the programming language type of the code file is a type other than the target type, then when the second symbol combination is scanned, the occurrence position of the function is determined according to the position of the second symbol combination, wherein the second symbol combination consists of a closing parenthesis and an opening curly brace.
[0049] Alternatively, the function writing method of programming languages is similar. For example, the function writing method of C language, C# and C++ is: return value type function name (parameter type parameter name) {method body}, such as int max(int num1, int num2) {......}, where the first int is the return value type, indicating that this function will return an integer, max is the function name, and then the parameters passed in are written in a pair of parentheses. In this example, there are two parameters, both of int type, that is, integer type, and the parameter names are num1 and num2. The closing parenthesis is followed by a pair of curly braces, and what the function is going to do is written in the curly braces. Therefore, if you want to identify where a function is in a program file, you can use parentheses and curly braces as judgment marks.
[0050] For example, a Java function can be written as int max(int num1, int num2){......}. The slight difference between Java and C is that sometimes a Java function needs to throw an exception, and a section about throwing the exception will be added after the function name. The example is as follows: int max(int num1, int num2) throws Exception{......}.
[0051] For example, a JavaScript function can be written as function function name (parameters) {......}; a PHP function can be written as function function name ($parameters) {......}; a Golang function can be written as func function name (parameters parameter type) return value type {......}. Therefore, the common feature of languages other than Python is that they all use parentheses to wrap parameters, and there will be a pair of curly braces after the parentheses. The code included in the curly braces is the code segment that implements the function.
[0052] For example, a Python function can be written as def function name (parameters):, where the def keyword is used to define a function. The following is an example:
[0053] def printme(str):
[0054] "Print the passed string to the standard display device"
[0055] print str
[0056] return
[0057] It can be seen that compared with other programming languages, Python does not have curly braces, but has colons, so the Python language is treated separately.
[0058] Optionally, in the process of locating the occurrence positions of multiple functions in each code file according to the programming language type, the programs in each code file are scanned respectively. If the programming language type of the code file is the target type (i.e., Python language), when the first keyword (i.e., def) in the program is scanned, the first symbol combination after the first keyword (i.e., the closing parenthesis and colon, i.e., ):) is located, and the position of the first symbol combination is used as the occurrence position of the function. For example, during the scanning process, the occurrence position of def is scanned, and then it is scanned backward to ): (i.e., the first symbol combination), so that a buried point is added after the colon, that is, the buried point code is inserted.
[0059] Optionally, if the programming language type of the code file is a type other than the target type, for example, C language, C#, C++, Java, JavaScript, Golang, PHP, etc., then when the second symbol combination is scanned, the appearance position of the function is determined according to the position of the second symbol combination.
[0060] Figure 2 is an optional flow chart of determining the occurrence position of a function according to an embodiment of the present invention, such as Figure 2 As shown, determining the occurrence position of the function according to the position of the second symbol combination includes the following steps:
[0061] Step S201, locating the position of the opening bracket paired with the closing bracket in the second symbol combination;
[0062] Step S202, determining whether there is a target keyword before the position of the opening bracket, and obtaining a determination result;
[0063] Step S203: If the judgment result indicates that there is no target keyword before the position of the opening parenthesis, the position of the second symbol combination is used as the appearance position of the function.
[0064] Optionally, for programming languages other than Python, locate the position where ){ appears, that is, the position of the combination of the closing parenthesis and the opening curly brace. Since logical judgment statements such as if and switch, and statements representing loops such as while and for also involve the writing of the combination of parentheses and opening curly braces, the examples are as follows:
[0065]
[0066] Therefore, after scanning ){, it is necessary to determine whether the opening parenthesis (paired with the closing parenthesis) is immediately after the target keyword such as if or switch or for or while, that is, to determine whether there is a target keyword before the position of the opening parenthesis. If there is a target keyword before the position of the opening parenthesis, it means that this is the code for judgment logic or the code for representing a loop, and this position will not be recognized as a function; if there is no target keyword before the position of the opening parenthesis, the position of the second symbol combination will be regarded as the appearance position of the function.
[0067] Optionally, since Java language functions sometimes need to throw exceptions, the writing method is: function name (parameters) throwsException{......}, where throws is the keyword for throwing exceptions. Therefore, for Java language, one more judgment is required, that is, for Java language programs, first scan whether there is {, if found, determine whether the throws keyword appears before the curly braces, and whether the throws keyword is immediately preceded by a small bracket), and comprehensively determine whether the code segment is a function.
[0068] It should be noted that by locating the occurrence positions of multiple functions in each code file according to the programming language type, automatic identification of function positions is achieved, which provides a basis for subsequent tracking, saves time and labor costs, and thus improves analysis efficiency.
[0069] In an optional embodiment, the location of each function is determined based on the programming language type and the location of each function, including: if the programming language type of the code file is the target type, the position after the colon in the first symbol combination is used as the location of the function; if the programming language type of the code file is a type other than the target type, the position after the opening brace in the second symbol combination is used as the location of the function.
[0070] Optionally, for the Python language, the position after the colon in the first symbol combination is used as the function's embedding position, that is, the embedding code is inserted after the colon; for languages other than Python, the position after the opening curly brace in the second symbol combination is used as the function's embedding position, that is, the embedding code is inserted after the opening curly brace.
[0071] It should be noted that the tracking point location of each function is determined based on the programming language type and the location where each function appears, which realizes automatic identification of the tracking point location, provides a basis for automatic tracking point location, saves time and labor costs, and thus improves analysis efficiency.
[0072] In an optional embodiment, each code file is processed based on the target embedding code corresponding to each code file and the embedding position of each function in each code file to obtain the embedded code file corresponding to each code file, including: inserting the target embedding code corresponding to each code file into the embedding position of each function to obtain the embedded code file corresponding to each code file.
[0073] Optionally, after determining the embedding position of each function, the target embedding code corresponding to each code file may be inserted into the embedding position of each function to obtain the embedding code file corresponding to each code file.
[0074] For example, some code examples of a code file whose programming language type is C language are as follows:
[0075]
[0076] After determining that the embedding position of the function is the position after the opening curly brace, insert the target embedding code (such as printf("xxx:aaa.c1")) into the embedding position of the function. The following is a partial code example of the code file after embedding:
[0077]
[0078] Alternatively, for the Java language, if you encounter a constructor, the writing method is that there will be super() or this() in the function, as shown below:
[0079] public function name(){
[0080] super();
[0081] }
[0082] Since the constructor stipulates that no statement can be inserted before super(), when inserting the embedding point, for the constructor, put the embedding point code after super(); and the program will run without error, as shown below:
[0083] public function name(){
[0084] super();System.out.println("xxx:aaa.java1");
[0085] }
[0086] In an optional embodiment, the code file after each embedding point is run to obtain analysis information of each code file, including: when running to the target embedding point code in the code file after each embedding point, outputting the running information; determining the analysis information of each code file based on the running information.
[0087] Optionally, after tracking each function in the code file, analysis information of each code file can be obtained by running each code file after tracking. When running to the target tracking code in each code file after tracking, the running information is output, that is, the tracking content is output to the console, and then the analysis information of each code file is determined based on the running information, that is, which functions are executed by the current program. For example, if it is the first function of the current file aaa.java, the output of the tracking is xxx:aaa.java1, and the output of the tracking of the second function is xxx:aaa.java2.
[0088] It should be noted that by automatically inserting tracking code into the code file, when the project is running, the execution status of the program and functions in the project can be directly and conveniently observed, which improves the analysis efficiency and provides convenience for technical personnel to quickly take over the project.
[0089] In an embodiment of the present invention, a method of automatically inserting tracking code into a code file is adopted. First, multiple code files in a project folder are obtained, and the programming language type of each code file is determined; tracking processing is performed on each code file according to the programming language type and the target tracking code to obtain a tracking code file corresponding to each code file, wherein the target tracking code is used to indicate the running information of the program in the acquisition and output code file during the running process; each tracking code file is run to obtain analysis information of each code file.
[0090] In the above process, each code file is processed according to the programming language type and the target embedded code to obtain the embedded code file corresponding to each code file, which saves time and labor costs and provides a basis for project file analysis. By running each embedded code file, analysis information of each code file can be obtained. That is, when the project is running, the execution status of programs and functions in the project can be directly and conveniently observed, which improves the analysis efficiency.
[0091] It can be seen that the technical solution of the present invention achieves the purpose of providing convenience for technical personnel to quickly take over the project, thereby achieving the technical effect of improving analysis efficiency, and further solving the technical problem of low analysis efficiency in the prior art of analyzing the code files of the project by manual debugging.
[0092] Example 2
[0093] According to an embodiment of the present invention, an embodiment of a device for analyzing a project file is provided, wherein: Figure 3 is a schematic diagram of an optional project file analysis device according to an embodiment of the present invention, such as Figure 3 As shown, the device includes: an acquisition module 301, which is used to acquire multiple code files in a project folder and determine the programming language type of each code file; a first processing module 302, which is used to perform embedding processing on each code file according to the programming language type and the target embedding code, and obtain the embedded code file corresponding to each code file, wherein the target embedding code is used to indicate the running information of the program in the acquisition and output code file during the running process; a second processing module 303, which is used to run each embedded code file to obtain analysis information of each code file.
[0094] In the project file analysis device provided by the embodiment of the present invention, multiple code files in the project folder are obtained by the acquisition module 301, and the programming language type of each code file is determined; the first processing module 302 performs point-embedding processing on each code file according to the programming language type and the target point-embedding code, and obtains the code file after the point-embedding corresponding to each code file, wherein the target point-embedding code is used to indicate the running information of the program in the acquisition and output code file during the running process; the second processing module 303 runs each code file after the point-embedding, and obtains the analysis information of each code file. According to the programming language type and the target point-embedding code, each code file is subjected to point-embedding processing, and the code file after the point-embedding corresponding to each code file is obtained, which saves time cost and manpower cost, and provides a basis for project file analysis, so that the analysis information of each code file can be obtained by running each code file after the point-embedding, that is, when the project is running, the execution of the program and function in the project can be directly and conveniently observed, and the analysis efficiency is improved. The purpose of providing convenience for technical personnel to quickly take over the project is achieved, thereby achieving the technical effect of improving the analysis efficiency, and then solving the technical problem of low analysis efficiency in the prior art of analyzing the code file of the project by manual debugging.
[0095] It should be noted that the above-mentioned acquisition module 301, first processing module 302 and second processing module 303 correspond to steps S101 to S103 in the above-mentioned embodiment, and the examples and application scenarios implemented by the three modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned embodiment 1.
[0096] Optionally, the first processing module includes: a first determination module, used to determine the point-embedding output statement corresponding to each code file according to the programming language type, and generate the target point-embedding code corresponding to each code file according to the point-embedding output statement and preset point-embedding information; a second determination module, used to locate the appearance positions of multiple functions in each code file according to the programming language type, and determine the point-embedding position of each function according to the programming language type and the appearance position of each function; a third processing module, used to perform point-embedding processing on each code file according to the target point-embedding code corresponding to each code file and the point-embedding position of each function in each code file, to obtain the code file after point-embedding corresponding to each code file.
[0097] Optionally, the second determination module includes: a fourth processing module, used to scan the programs in each code file respectively; a third determination module, used to locate the position of the first symbol combination after the first keyword when the first keyword in the program is scanned if the programming language type of the code file is the target type, and use the position of the first symbol combination as the appearance position of the function, wherein the first keyword is used to define the function, and the first symbol combination consists of a closing parenthesis and a colon; a fourth determination module, used to determine the appearance position of the function according to the position of the second symbol combination when the second symbol combination is scanned if the programming language type of the code file is a type other than the target type, wherein the second symbol combination consists of a closing parenthesis and an opening curly brace.
[0098] Optionally, the fourth determination module includes: a fifth processing module, used to locate the position of the opening bracket paired with the closing bracket in the second symbol combination; a sixth processing module, used to determine whether there is a target keyword before the position of the opening bracket to obtain a determination result; and a fifth determination module, used to use the position of the second symbol combination as the occurrence position of the function if the determination result indicates that there is no target keyword before the position of the opening bracket.
[0099] Optionally, the second determination module also includes: a sixth determination module, which is used to use the position after the colon in the first symbol combination as the function's embedding position if the programming language type of the code file is the target type; and a seventh determination module, which is used to use the position after the opening curly brace in the second symbol combination as the function's embedding position if the programming language type of the code file is a type other than the target type.
[0100] Optionally, the third processing module includes: a seventh processing module, which is used to insert the target embedding code corresponding to each code file into the embedding position of each function respectively, to obtain the embedded code file corresponding to each code file.
[0101] Optionally, the second processing module includes: an output module, which is used to output running information when running to the target embedding code in the code file after each embedding; and an eighth determination module, which is used to determine the analysis information of each code file based on the running information.
[0102] Example 3
[0103] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the above-mentioned project file analysis method is implemented.
[0104] Example 4
[0105] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned project file analysis method when running.
[0106] Example 5
[0107] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, wherein: Figure 4 is a schematic diagram of an optional electronic device according to an embodiment of the present invention, such as Figure 4 As shown, the electronic device includes one or more processors; a memory for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors are implemented to run the programs, wherein the programs are set to execute the above-mentioned project file analysis method when running. When the processor executes the program, the following steps are implemented: obtaining multiple code files in the project folder and determining the programming language type of each code file; performing point embedding processing on each code file according to the programming language type and the target point embedding code to obtain the code file after the point embedding corresponding to each code file, wherein the target point embedding code is used to indicate the running information of the program in the acquisition and output code file during the running process; running each code file after the point embedding to obtain the analysis information of each code file.
[0108] Optionally, the processor also implements the following steps when executing the program: determining the point-embedding output statement corresponding to each code file based on the programming language type, and generating the target point-embedding code corresponding to each code file based on the point-embedding output statement and preset point-embedding information; locating the appearance positions of multiple functions in each code file based on the programming language type, and determining the point-embedding position of each function based on the programming language type and the appearance position of each function; performing point-embedding processing on each code file based on the target point-embedding code corresponding to each code file and the point-embedding position of each function in each code file, to obtain the code file after point-embedding corresponding to each code file.
[0109] Optionally, when executing the program, the processor also implements the following steps: scanning the programs in each code file respectively; if the programming language type of the code file is a target type, then when the first keyword in the program is scanned, locating the position of the first symbol combination after the first keyword, and using the position of the first symbol combination as the appearance position of the function, wherein the first keyword is used to define the function, and the first symbol combination consists of a closing parenthesis and a colon; if the programming language type of the code file is a type other than the target type, then when the second symbol combination is scanned, determining the appearance position of the function according to the position of the second symbol combination, wherein the second symbol combination consists of a closing parenthesis and an opening curly brace.
[0110] Optionally, when executing the program, the processor also implements the following steps: locating the position of the opening parenthesis that is paired with the closing parenthesis in the second symbol combination; determining whether there is a target keyword before the position of the opening parenthesis to obtain a determination result; if the determination result indicates that there is no target keyword before the position of the opening parenthesis, taking the position of the second symbol combination as the occurrence position of the function.
[0111] Optionally, the processor also implements the following steps when executing the program: if the programming language type of the code file is the target type, the position after the colon in the first symbol combination is used as the function's embedding position; if the programming language type of the code file is a type other than the target type, the position after the opening curly brace in the second symbol combination is used as the function's embedding position.
[0112] Optionally, when the processor executes the program, the following steps are also implemented: inserting the target embedding code corresponding to each code file into the embedding position of each function respectively, and obtaining the embedded code file corresponding to each code file.
[0113] Optionally, when executing the program, the processor further implements the following steps: when running to the target embedded code in the code file after each embedded point, outputting running information; and determining analysis information for each code file based on the running information.
[0114] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0115] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0116] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0117] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0118] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0119] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0120] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0121] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for analyzing project files, characterized in that: include: Get multiple code files in a project folder and determine the programming language type of each code file; Performing point embedding processing on each code file according to the programming language type and the target point embedding code to obtain a code file after the point embedding corresponding to each code file, wherein the target point embedding code is used to indicate the running information of the program in the acquisition and output code file during the running process; Run each code file after embedding to obtain analysis information of each code file.
2. The method according to claim 1, characterized in that: Performing point embedding processing on each of the code files according to the programming language type and the target point embedding code to obtain a code file after the point embedding corresponding to each of the code files, including: Determine the tracking point output statement corresponding to each code file according to the programming language type, and generate the target tracking point code corresponding to each code file according to the tracking point output statement and preset tracking point information; Locating the occurrence positions of multiple functions in each code file according to the programming language type, and determining the tracking position of each function according to the programming language type and the occurrence position of each function; Each code file is subjected to embedding processing according to the target embedding code corresponding to each code file and the embedding position of each function in each code file to obtain the embedded code file corresponding to each code file.
3. The method according to claim 2, characterized in that Locating the occurrence positions of the multiple functions in each code file according to the programming language type, including: Scanning the programs in each code file respectively; If the programming language type of the code file is a target type, then in the case of scanning a first keyword in the program, locating a position of a first symbol combination after the first keyword, and taking the position of the first symbol combination as an appearance position of a function, wherein the first keyword is used to define a function, and the first symbol combination consists of a closing parenthesis and a colon; If the programming language type of the code file is a type other than the target type, then when a second symbol combination is scanned, the appearance position of the function is determined according to the position of the second symbol combination, wherein the second symbol combination consists of a closing parenthesis and an opening curly brace.
4. The method according to claim 3, characterized in that Determining the appearance position of the function according to the position of the second symbol combination includes: Locate the opening parenthesis that pairs with the closing parenthesis in the second symbol combination; Determine whether there is a target keyword before the position of the start bracket, and obtain a determination result; If the judgment result indicates that the target keyword does not exist before the position of the opening parenthesis, the position of the second symbol combination is used as the appearance position of the function.
5. The method according to claim 3, characterized in that: Determining the location of each function according to the programming language type and the location where each function appears, including: If the programming language type of the code file is the target type, the position after the colon in the first symbol combination is used as the function embedding position; If the programming language type of the code file is a type other than the target type, the position after the opening brace in the second symbol combination is used as the function's embedded point position.
6. The method according to claim 2, characterized in that Performing point embedding processing on each code file according to the target point embedding code corresponding to each code file and the point embedding position of each function in each code file to obtain a code file after point embedding corresponding to each code file, including: The target embedding code corresponding to each code file is respectively inserted into the embedding position of each function to obtain the embedded code file corresponding to each code file.
7. The method according to claim 1, characterized in that Run each code file after the tracking point to obtain analysis information of each code file, including: When the target embedded point code in the code file after each embedded point is run, the running information is output; Determine analysis information for each code file according to the running information.
8. A project file analysis device, characterized in that: include: The acquisition module is used to obtain multiple code files in the project folder and determine the programming language type of each code file; A first processing module is used to perform a point embedding process on each of the code files according to the programming language type and the target point embedding code to obtain a code file after the point embedding corresponding to each of the code files, wherein the target point embedding code is used to indicate the operation information of the program in the acquisition and output code file during the operation process; The second processing module is used to run each code file after the embedding point to obtain analysis information of each code file.
9. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the project file analysis method described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the project file analysis method described in any one of claims 1 to 7 when running.
11. An electronic device, characterized in that: The electronic device includes one or more processors; A memory for storing one or more programs, which, when executed by the one or more processors, enables the one or more processors to run the programs, wherein the programs are configured to execute the method for analyzing the project files described in any one of claims 1 to 7 when run.
