Analysis methods, devices, equipment and storage media for project engineering documents

By directly parsing the header files of project engineering files, the high cost and low efficiency problems of existing technologies are solved, and efficient and accurate header file analysis is achieved in different development environments, making it suitable for various development environments.

CN112231278BActive Publication Date: 2024-11-22BAIDU INT TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011208298.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-03
Publication Date
2024-11-22
Estimated Expiration
2040-11-03

AI Technical Summary

Technical Problem

Existing technologies for in-depth analysis of project engineering documents suffer from high time costs, low efficiency, and limited applicability. In particular, manual or intrusive analysis is required in different development environments, resulting in high costs and poor accuracy.

Method used

By obtaining the header files in the project's project path, the system directly parses the attribute and method information in the header files without modifying the source code. It is suitable for various development environments and uses a state machine and keyword dictionary to identify classes, categories, attributes, and methods in the header files, outputting them as a linked list structure.

Benefits of technology

It enables efficient, low-cost, and accurate analysis of header files in different development environments, reduces the cost of modifying source code, improves the accuracy and universality of analysis results, and shortens analysis time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112231278B_ABST
    Figure CN112231278B_ABST
Patent Text Reader

Abstract

The present disclosure provides an analysis method for a project engineering file based on a computer language, which relates to the field of software engineering, and specifically, to the field of software testing and optimization. The project engineering file based on a computer language includes at least one header file, and the analysis method includes: obtaining at least one header file according to the engineering path of the project engineering; parsing the content of each header file in the at least one header file to obtain the attribute information and method information declared in each header file; and outputting the obtained attribute information and method information. The present disclosure also provides an analysis device, equipment and storage medium for a project engineering file based on a computer language.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of software engineering, specifically, to the field of software testing and optimization, and more specifically, to an analysis method, device, equipment and storage medium for project engineering files based on computer language. Background Art

[0002] Software is increasingly becoming a major factor affecting product quality. Software that runs fast, has reliable performance, is lightweight and low-cost can significantly enhance the value of products. As software development continues to deepen, the project engineering files of computer language-based project engineering have also increased, which has created challenges when conducting in-depth analysis of project engineering files to optimize project engineering. Summary of the invention

[0003] In view of this, the present disclosure provides a method, device, equipment and storage medium for analyzing project engineering files based on computer language.

[0004] A first aspect of the present disclosure provides a method for analyzing a project engineering file based on a computer language, wherein the project engineering file based on a computer language includes at least one header file, and the method includes:

[0005] Acquire the at least one header file according to the project path of the project;

[0006] Parsing the content of each header file in the at least one header file to obtain the attribute information and method information declared in each header file; and

[0007] Outputs the acquired attribute information and method information.

[0008] A second aspect of the present disclosure provides an analysis device for a project engineering file based on a computer language, wherein the project engineering file based on a computer language includes at least one header file, and the analysis device includes:

[0009] A file acquisition module, configured to acquire the at least one header file according to the project path of the project;

[0010] A file parsing module configured to parse the content of each header file in the at least one header file to obtain the attribute information and method information declared in each header file; and

[0011] The information output module is configured to output the acquired attribute information and method information.

[0012] A third aspect of the present disclosure provides an information delivery device, comprising:

[0013] a memory storing program instructions; and

[0014] The processor is configured to execute the program instructions to perform the computer language-based project engineering file analysis method provided in the first aspect of the present disclosure.

[0015] A fourth aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which, when executed, are used to implement the computer language-based project engineering file analysis method provided in the first aspect of the present disclosure.

[0016] A fifth aspect of the present disclosure provides a computer program product, comprising a computer program, which implements the above method when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0018] Figure 1 A flowchart of a method for analyzing a project engineering file based on a computer language according to an embodiment of the present disclosure is schematically shown;

[0019] FIG. 2A to FIG. 2C The method of obtaining the header file according to the embodiment of the present disclosure is schematically shown;

[0020] Figure 3 A state transition diagram for parsing the contents of a header file according to an embodiment of the present disclosure is schematically shown;

[0021] Figure 4 An example of a header file to be analyzed according to an embodiment of the present disclosure is schematically shown;

[0022] Figure 5 The linked list structure for storing analysis content according to an embodiment of the present disclosure is schematically shown;

[0023] Figure 6 Schematically illustrates an example of the output of the analyzed header file according to an embodiment of the present disclosure;

[0024] Figure 7 A flowchart of a method for analyzing a project engineering file based on a computer language according to another embodiment of the present disclosure is schematically shown;

[0025] Figure 8 Schematically shows Figure 7 The example process of the analysis method of project engineering documents based on computer language is shown;

[0026] Fig. 9A block diagram schematically shows a device for analyzing project engineering files based on computer language according to an embodiment of the present disclosure;

[0027] Fig.10 A block diagram of an electronic device suitable for performing analysis of a project engineering file based on a computer language according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0028] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0029] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0030] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0031] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0032] In the embodiments of the present disclosure described below, a project project developed using the object-oriented language Objective-C will be used as an example for explanation. Those skilled in the art should understand that these embodiments are only examples, and the methods in the embodiments of the present disclosure can be applied to project projects developed using other languages.

[0033] Figure 1 The flowchart of the method 100 for analyzing a project engineering file based on a computer language according to an embodiment of the present disclosure is schematically shown. Figure 1 As shown, the analysis method 100 comprises the following steps:

[0034] In step S110, at least one header file is obtained according to the project path of the project.

[0035] In step S120, the content of each header file in the at least one header file is parsed to obtain the attribute information and method information declared in each header file.

[0036] In step S130, the acquired attribute information and method information are output.

[0037] The analysis method 100 according to the embodiment of the present disclosure can be applied to the development environment for different computer languages, and is used to analyze the project engineering files established in the development environment. The project engineering files generally include source files and header files. Among them, the source file is a file containing source code written by developers to implement certain functions according to the development purpose and development requirements. The header file is a file containing the declaration of the function block that can be called in the source file. For example, for different computer languages, the header file may contain the declaration of function functions, the declaration of classes, the declaration of data types, the declaration of data interfaces, etc. The header file may be provided by the development environment (or development platform) of the computer language, wherein the content of the declaration generally varies according to the standards of different computer languages ​​or different development platforms. The content declared in the header file may also be written by other developers in previous development. In the embodiment of the present disclosure, in step S110, at least one header file is obtained according to the engineering path of the project engineering. Further, according to the embodiment, all files with preset suffixes under the engineering path are obtained according to the engineering path of the project engineering. For example, a header file with the suffix ".h" is obtained.

[0038] Next, in step S120, the content of each header file in the at least one header file obtained is parsed respectively. According to an embodiment, the characters included in each file or a string containing multiple characters can be obtained, and the meaning of the obtained characters or strings can be analyzed. According to an embodiment, in a header file based on the Objective-C language, a declaration of a class, a declaration of a classification, and a declaration of properties and methods in a class or classification can be included. Therefore, by parsing the content of each header file in the at least one header file obtained respectively, the property information and method information declared in each header file can be obtained respectively.

[0039] Next, in step S130, the acquired attribute information and method information may be output in a predetermined format. According to an embodiment, the attribute information may include attribute keywords, attribute types, and attribute names, and the method information may include method names, method return values, and method parameters. Developers may easily obtain the information declared in the header file by means of attribute information such as attribute keywords, attribute types, and attribute names, and method information such as method names, method return values, and method parameters.

[0040] According to the embodiments of the present disclosure, the header files referenced by the source files can be analyzed without entering the source files that reference the header files, and the attribute information and method information included in the header files can be obtained. Therefore, in the process of developing the source files, the meaning of the codes can be better understood, and all project engineering files can be deeply analyzed based on the header files, thereby improving the overall performance of the developed projects.

[0041] In the existing software development process, the declaration content in the header file can only be obtained through manual analysis or intrusive analysis. Manual analysis of header files requires developers to manually view, analyze and record the header files. The time cost of this analysis method is very high, the efficiency is low, and the recording results may be biased. Intrusive analysis of header files requires developers to embed specially written code in the source code file, and the specially written code needs to be compiled and run together with the source code, so the output cost is very high. In addition, intrusive analysis is developed on the basis of the system library, so it is necessary to reconstruct the redundant data format and clean the redundant data of the system return data, which is inefficient and costly. Further, intrusive analysis is not universally applicable to the development environment, that is, the specially written code embedded for one development environment or one device (such as a computer) is often not applicable to another development environment or another device, so the code must be written for different development environments, which further increases the cost of analysis.

[0042] According to the embodiments of the present disclosure, there is no need to modify the source code in the source file, and the header file can be directly obtained according to the project engineering path, thereby reducing the cost of modifying the source code for analysis, and it is universal for various development environments or different devices, and can automatically perform analysis of header files for various development environments and various devices, with low cost and higher accuracy of analysis results.

[0043] According to an embodiment, when obtaining at least one header file, a single header file with a suffix of ".h" under the project path can be obtained separately, multiple header files with a suffix of ".h" under the project path can be obtained one by one, or multiple header files with a suffix of ".h" under the project path can be obtained at the same time. FIG. 2A to FIG. 2CThe method of obtaining a header file according to an embodiment of the present disclosure is schematically shown. According to the embodiment, the header file based on the Objective-C language can be a header file including a single class declaration or a header file including multiple class declarations.

[0044] Figure 2A shows a header file that contains a single class declaration. Figure 2A As shown, in this header file, the category aaa of class NSSting is declared, where NSString is the name of the class and aaa is the name of the category. Next, in the aaa category, two attributes of the category are declared using the keyword @property, where NSString* and NSInteger are the attribute types, and name and age are the attribute names. Nonatomic and strong in brackets, as well as nonatomic and assign are attribute keywords. Next, in the aaa category, three object methods and three class methods are declared. Among them, the declaration of the object method starts with "-", including the object method log without parameters and without return values, the object method log1 with parameters and without return values, and the object method log2 with parameters and return values. Log, log1 and log2 are the names of the object methods. The string in brackets before the method name represents the return value of the method, where void means that the return value is empty, that is, there is no return value. The part of the method name indicated by ":" is the parameter of the method, where NSString* in brackets is the type of the method parameter, and name is the name of the method parameter. In aaa, three class methods are declared starting with "+", including class method log3 without parameters and return values, class method log4 with parameters and return values, and class method log5 with parameters and return values. log3, log4, and log5 are the names of the class methods. The definition of the method return value and method parameters of the class method can be found in the object method, which will not be repeated here. That is, in Figure 2A In the example, only one category aaa of class NSSting is declared. Figure 2B shows a header file that contains multiple class declarations. Figure 2B As shown, in this header file, the categories bbb and ccc of the class NSSting are declared at the same time.

[0045] According to the embodiment, when parsing a header file, a single classification in a single header file will be parsed, but when obtaining the header file, each header file can be obtained separately, or multiple header files can be obtained at the same time, and the header file can be a header file containing a single class declaration or a header file containing multiple class declarations. Figure 2C The list information of the obtained header files is shown. Figure 2CAs shown in the figure, obtaining multiple header files under the project at the same time can significantly shorten the analysis time and improve the analysis efficiency.

[0046] According to an embodiment, parsing the content of each header file in at least one header file may include scanning the content of each header file line by line and character by character to obtain the characters included in the header file, and matching the obtained characters with keyword characters in multiple keyword vocabularies to determine the classes, categories, and attribute information and method information of the categories declared in the header file. Figure 3 A state transition diagram for parsing the contents of a header file according to an embodiment of the present disclosure is schematically shown. Figure 4 An example of a header file to be analyzed according to an embodiment of the present disclosure is schematically shown. Figure 3 The state transition diagram shown and Figure 4 The header file example shown illustrates the above process.

[0047] According to an embodiment, a string variable is created in a memory for temporarily storing characters read from a header file. The header file is traversed line by line and character by character to obtain the content in the header file. During the reading process, the meaning of the character or string is determined by comparing the character or string with a predetermined keyword word list.

[0048] According to an embodiment, a plurality of keyword word lists may be pre-set for the identification of header files. In an embodiment of the present disclosure, the keyword word lists created include a class declaration scope start keyword list, a class declaration scope end keyword list, a class name terminator list, a classification name start symbol list, a classification name terminator list, a method start keyword list, an attribute start keyword list, and an attribute and method end keyword list.

[0049] According to an embodiment, the class declaration scope start keyword table includes the keyword string "@interface". The class declaration scope end keyword table includes the keyword string "@end". After scanning for "@interface", it indicates that a declaration about a class or classification follows. After scanning for "@end", it indicates that the declaration about a class or classification ends. According to an embodiment, the class name terminator table may include, for example, "(", "+" and "-". The classification name start symbol table includes "(", and the classification name terminator table includes ")". Among them, the "(" after the class name indicates the declaration of the classification name. It is also possible not to declare the classification name, and directly declare the method, and the declaration of class method and object method is started by "+" and "-" respectively, so it can be used to indicate the end of the class name. According to an embodiment, the method start keyword table includes "+" and "-", and the property start keyword table includes "@property".

[0050] It is easy to understand that the keyword word list used in the identification process and the specific content in each keyword word list can be set according to the relevant regulations of different computer languages. The above embodiments are only examples and do not constitute a limitation of the present disclosure.

[0051] According to the embodiment, the class declared in the header file is first identified, and the specific steps may include: storing the obtained characters in a temporary string variable in sequence, and matching the string accumulated by the sequential storage with the keyword characters in the keyword table at the beginning of the class declaration scope. When the match is successful, the characters stored in the temporary string variable are cleared, and the characters are continued to be read from the header file and stored in sequence in the temporary string variable. Next, the stored characters are matched with the keyword characters in the class name terminator table, and when the characters that are the same as the keyword characters in the class name terminator table are matched, the characters other than the matched characters in the temporary string variable are recorded as the name of the class, and the characters stored in the temporary string variable are cleared. The name of the class declared in the header file is thus identified. According to the embodiment, a state machine can be used to control the reading and comparison process. As Figure 3 As shown, the state machine for implementing the identification process includes states S0, S1 and S2.

[0052] exist Figure 3 In the state machine, the initial state is S0, the state of the character or string to be recognized. In this state, the characters are continuously read from the header file by traversing the header file line by line and character by character, and the read characters are stored in a temporary string variable. At the same time, the string stored in the temporary string variable is matched with the class declaration scope start keyword table ①, such as Figure 3 As shown in "Match ①" in . After the match is successful, the characters stored in the temporary string variable are cleared, and the state machine switches from the initial state S0 to the state S1 to start recognizing the class name. Next, continue to read characters from the header file and store them in the temporary string variable, and match the read characters with the class name terminator table ②, as shown in Figure 3 After the match is successful, the characters stored in the temporary string variable are cleared, and the state machine switches from the state S1 where the class name is recognized to the state S2 where the class name is to be recognized.

[0053] See also Figure 4The header file example shown reads the characters "@", "i", "n", "t" ... "e" from the header file in sequence into a temporary string variable. When the accumulated characters are the string "@interface", it is recognized that the string that follows should be the name of the class. The temporary string variable is cleared, and the characters "(space character)", "N", "S" ... "(" are read from the header file in sequence into the temporary string variable. After the character "(" is recognized, it is confirmed that the string before the character "(" is the name of the class, i.e. NSString. The temporary string variable is then cleared.

[0054] It should be noted that, in the embodiment of the present disclosure, since the classification name start symbol table (including "(")) is a subset of the class name terminator table (including, for example, "(", "+" and "-", etc.), in the process of matching the character with the class name terminator table, it is equivalent to completing the matching of the character with the classification name start symbol table. Therefore, if the character "(" is matched in the process of matching the character with the class name terminator table, the character stored in the temporary string variable is cleared, and the state machine is switched from the state S2 where the classification name is to be identified to the state S3 where the classification name is to be identified, as shown in FIG. Figure 3 As shown in “Match ③” in .

[0055] According to the embodiment, after the name of the class is identified, the classification is continued to be identified. The specific steps may include: storing the obtained characters in a temporary string variable in sequence, and matching the stored characters with the keyword characters in the classification name terminator table. When the characters that match the keyword characters in the classification name terminator table are matched, the characters other than the matched characters in the temporary string variable are recorded as the name of the classification, and the characters stored in the temporary string variable are cleared. The name of the classification declared in the header file is thus identified. Figure 3 As shown, the state machine for implementing the identification process includes states S2, S3 and S4.

[0056] exist Figure 3 In the process, characters are read from the header file and stored in a temporary string variable, and the read characters are matched with the category name terminator table ④, such as Figure 3 After the match is successful, the characters stored in the temporary string variable are cleared, and the state machine switches from the state S3 where the category name is identified to the state S4 where the method / attribute is to be identified.

[0057] See also Figure 4In the header file example shown, after switching from state S2 to state S3, the characters "d" and ")" are read from the header file in sequence into a temporary string variable. After the character ")" is recognized, the string before the character ")" is confirmed to be the name of the category, that is, the category d of the class NSString is declared. Then the temporary string variable is cleared.

[0058] According to the embodiment, after the classification name is identified, the attributes and methods of the classification continue to be identified. The specific steps may include: continuing to store the obtained characters in a temporary string variable in sequence, and matching the stored characters with the keyword characters in the method start keyword table or the attribute start keyword table, in the case of matching the same characters as the keyword characters in the method start keyword table, clearing the characters stored in the temporary string variable, and starting the method identification, and in the case of matching the same characters as the keyword characters in the attribute and method end keyword table, ending the method identification. In the case of matching the same characters as the keyword characters in the attribute start keyword table, clearing the characters stored in the temporary string variable, and starting the attribute identification, and in the case of matching the same characters as the keyword characters in the attribute and method end keyword table, ending the attribute identification. Since a class declaration may include multiple methods and multiple attributes, the method identification and attribute identification processes may be performed multiple times to obtain multiple methods and multiple attributes. All method information and all attribute information declared in the header file are thereby identified. As Figure 3 As shown, the state machine for implementing the identification process includes states S4, S5 and S6.

[0059] exist Figure 3 In the process, characters are continuously read from the header file by traversing the header file line by line and character by character, and the read characters are stored in a temporary string variable. At the same time, the string stored in the temporary string variable is matched with the method start keyword table ⑤ and the attribute start keyword table ⑦ respectively. After the match with the method start keyword table ⑤ is successful, the characters stored in the temporary string variable are cleared, and the state machine switches from the state S4 of the method / attribute to be recognized to the state S5 of the method recognition start state, such as Figure 3 After the match with the attribute start keyword table ⑦ is successfully completed, the characters stored in the temporary string variable are cleared, and the state machine switches from the state S4 to be recognized method / attribute to the state S7 to start recognizing attribute, as shown in FIG. Figure 3After entering the state of identifying the method or the state of identifying the attribute, at state S5 or state S7, the characters stored in the temporary string variable are matched with the attribute and method end keyword table ⑥. If the match is successful, the state of identifying the method or the state of identifying the attribute is exited, the characters stored in the temporary string variable are cleared, and the state machine switches from the state of identifying the method starting from state S5 or the state of identifying the attribute starting from state S7 to the state of the method / attribute to be identified in state S4, as shown in "Match ⑥" in 3.

[0060] According to an embodiment, in attribute identification, the closure type (Block) attribute of the attribute is first screened based on a regular expression, and whether the attribute is in a closure state is recorded according to the screening result. Then continue to traverse the header file line by line and character by character to continuously read characters from the header file and store the read characters in a temporary string variable, while identifying the attribute keyword through the attribute keyword start character "(" and terminator ")" and the attribute keyword table, identifying the attribute type through the attribute type separator "(space character)", and identifying the attribute name by matching the characters in the attribute and method end keyword table. After each step of identification above, the temporary string variable needs to be cleared. According to an embodiment, the attribute keyword table may include "nonatomic", "atomic", "assign", "weak", "strong", "copy", "readonly", "readwrite", etc.

[0061] According to an embodiment, in method identification, first identify whether the method is a class method ("+") or an object method ("-") based on whether "+" or "-" is matched. Clear the temporary string variable and continue to read characters into the temporary string variable, identify the return value of the method by matching the return value start character "(" and the terminator ")" and record the return value. Clear the temporary string variable and continue to read characters into the temporary string variable, and identify the method name based on the method name terminator ":". Clear the temporary string variable and continue to read characters into the temporary string variable, and identify the method parameters based on the type start character "(" and the terminator ")" of the method parameters and the bracket matching detection algorithm. According to an embodiment, the bracket matching detection algorithm first creates a temporary stack variable in memory, and when the left bracket "(" is obtained, the characters after the "(" including the "(" in the stack are popped out. Then, when the content of the stack is not empty, record the content of the stack, and when the content of the stack is empty, stop recording. The recorded content is the name of the type of the method parameter. In this way, any custom parameter type can be detected.

[0062] See also Figure 4The header file example shown continues to read characters "@", "p", "r", "o" ... "y" from the header file into a temporary string variable. When the accumulated characters are the string "@property", it is recognized that the string that follows should be a property, so the property identification begins. Continue to read characters "(space character)" and "(" from the header file into a temporary string variable. When "(" is identified, it is determined that the declaration of the property keyword follows. Clear the temporary string variable, continue to read characters "n", "o", "a" ... "c" from the header file, and obtain the property keyword "nonatomic" by matching the property keyword table, and identify the property keyword "strong" in the same way. Then, by matching the property type separator "(space character)", it is recognized that the space character is the property type, and the property type NSString* and the property name name are identified. After matching the character "; ", the temporary string variable is cleared, and the state machine switches from state S6 back to state S4. The character "-" continues to be read from the header file into the temporary string variable, and by matching the "-", it is identified that it is followed by the declaration of the object method, the temporary string variable is cleared, and the state machine switches from state S4 to state S5. Next, the method name, method return value (if any) and method parameters (if any) of the method are identified according to the method in the aforementioned embodiment. After matching the character ";", the temporary string variable is cleared, and the state machine switches from state S5 back to state S4. Then, by executing the above operation method multiple times, methods log2 and log3 are identified in turn.

[0063] like Figure 4 As shown, after the recognition of "+(void)log3;" is completed, characters "@", "e", "n" and "d" are read from the header file. By matching the class declaration scope end keyword table, it can be seen that the class (classification) declaration ends, as shown in FIG. Figure 3 As shown in “Match⑧” in .

[0064] According to the method for parsing a header file according to the embodiment of the present disclosure, the header file can be parsed according to the content characteristics of the header file, with fast execution speed and high reliability.

[0065] According to an embodiment, the step of outputting the acquired attribute information and method information further includes: storing the attribute information and method information as a linked list structure, wherein each node in the linked list structure is a classification, and outputting the acquired attribute information and method information based on the linked list structure.

[0066] Figure 5The schematic diagram shows a linked list structure for storing analysis content according to an embodiment of the present disclosure. After a class (classification) is identified, a node variable can be created according to the content of the identified class (classification), and then the parsed variable nodes are aggregated into a linked list. Figure 5 As shown, the linked list structure for storing the analysis content includes multiple node variables, such as the identified class name, classification name, method variable node, and attribute variable node. Among them, the method variable node can further include method return value, method name, method parameter name list, method parameter type list, whether it is a class method, etc. The attribute variable node can further include attribute keywords, attribute names, attribute types, etc. Each node variable forms a linked list by pointing to the next node variable through a pointer.

[0067] Figure 6 An example of the output of the analyzed header file according to an embodiment of the present disclosure is schematically shown. Figure 6 The following is an analysis result of an example of a header file to be analyzed according to the above embodiment. Figure 6 The analysis results shown can help you better understand the contents declared in the header file, and you can understand the specific information of the header file without having to read and understand the contents of the header file.

[0068] On the basis of fully understanding the specific information of the header file, the project engineering file based on the computer language can be optimized according to the attribute information and method information obtained about the header file. Figure 7 The flowchart of the method 700 for analyzing a project engineering file based on a computer language according to another embodiment of the present disclosure is schematically shown. Figure 7 As shown, the analysis method 700 includes the following steps:

[0069] In step S710, at least one header file is obtained according to the project path of the project.

[0070] In step S720, the content of each header file in the at least one header file is parsed to obtain the attribute information and method information declared in each header file.

[0071] In step S730, the acquired attribute information and method information are output.

[0072] In step S740, repeated attributes and repeated methods in the header file are determined according to the attribute information and the method information.

[0073] In step S750, the determined repeated property names and repeated method names are modified so that the property names and method names are different from each other.

[0074] In the above analysis method 700, the operations of step S710, step S720 and step S730 can refer to the operations of step S110, step S120 and step S130 of the analysis method 100 in the above embodiment, and will not be repeated here.

[0075] In step S740, the repeated attributes and repeated methods in the header file are detected and determined. In a project engineering based on a computer language, different attributes and different methods are generally required to use different names. If the same name is used, it will not pass during compilation, thereby ensuring the uniqueness of the naming. However, there is a situation where exactly the same attributes or methods are declared in different header files or different classes (categories). For example, for attributes, the attribute keywords, attribute types and attribute names are exactly the same. For methods, the method names, method return values ​​and method parameters are exactly the same. In this case, no error will be reported during compilation, that is, exactly the same named attributes and methods cannot be found. In this way, if one of the attributes or methods with the same name is changed during the program running process. For example, if the return value of one of the two methods with the same name is modified, it will cause the problem that different methods have the same name. In this case, the error cannot be found through compilation.

[0076] According to an embodiment of the present disclosure, such identical attributes and methods can be found by obtaining the attribute information and method information declared in the header file. Next, in step S750, the above error can be avoided by modifying the names of the repeated attributes and the names of the repeated methods to be different from each other.

[0077] According to an embodiment, after determining the repeated attributes and repeated methods in the header file based on the attribute information and method information, the obtained repeated attributes and repeated methods can be output and displayed, and the developer can evaluate whether the naming needs to be modified, or the source code can be modified to avoid errors during the operation of the program.

[0078] According to an embodiment, determining repeated attributes and repeated methods in a header file according to attribute information and method information may also include: constructing a hash table according to a combination of attribute keywords, attribute types and attribute names, and a combination of method names, method return values ​​and method parameters, and using the hash table to filter the attribute information and method information to determine repeated attributes and repeated methods in the header file. By using a hash table for filtering, the filtering speed can be significantly improved, and in large-scale project engineering, the time cost can be significantly reduced.

[0079] Figure 8 Schematically shows Figure 7 The example process of the analysis method of project engineering files based on computer language is shown in the figure. Figure 8 As shown in FIG, the example analysis method is implemented by multiple different functional modules, and can be packaged together to form an independent plug-in, which can be applied to various software development environments. Figure 8 As shown, the example analysis method specifically includes an input module 81, a data reading module 82, a lexical analysis module 83, an output display module 84 and a data detection module 85. Among them, the input module 81 can input the project path and obtain the header file through the project path. The data reading module 82 can be used to read the obtained header file into the memory, and can perform single-file single-type reading, single-file multi-type reading and multi-file joint reading. The lexical analysis module 83 can be used to implement various lexical analysis functions. Figure 8 As shown, the attributes and methods declared in the class (classification) can be analyzed separately. When performing attribute analysis, the attribute keyword, whether it is a closure attribute, the attribute type and the name of the attribute can be analyzed. When performing method analysis, whether it is a class method or an object method, the return value of the method, the type of method parameters, the parameter name and the method name can be analyzed. The output display module 84 can be used to format and store the results obtained by the analysis, and output and display the formatted stored results. The data detection module can be used to retrieve according to the output attribute information and method information, such as determining repeated attributes and methods, and can rename repeated attributes and methods according to pre-set operations or according to received instructions.

[0080] In this embodiment, each functional module is independent of each other and realizes different functions. The analysis capability can be easily increased by expanding each functional module. For example, further analysis of custom data types can be added to the lexical analysis module 83. The analysis method according to the embodiment of the present disclosure is easy to expand and has a wide range of applications.

[0081] Fig. 9 The block diagram of the project engineering file analysis device 900 based on computer language according to an embodiment of the present disclosure is schematically shown. Fig. 9 As shown, the analysis device 900 for project engineering files based on computer language includes a file acquisition module 910 , a file parsing module 920 and an information output module 930 .

[0082] According to an embodiment, the file acquisition module 910 is configured to acquire at least one header file according to the project path of the project. The file parsing module 920 is configured to parse the content of each header file in the at least one header file to obtain the attribute information and method information declared in each header file. The information output module 930 is configured to output the acquired attribute information and method information.

[0083] The specific operations of the above functional modules can be obtained by referring to the operation steps of the project engineering file analysis method 100 based on computer language in the aforementioned embodiment, which will not be repeated here.

[0084] Fig.10 The block diagram of the electronic device 1000 according to the embodiment of the present disclosure is schematically shown, which is suitable for performing the analysis of the project engineering file based on the computer language. Fig.10 The electronic device 1000 shown is used to execute the method for analyzing project engineering files based on computer language according to an embodiment of the present disclosure.

[0085] like Fig.10 As shown, the electronic device 1000 according to an embodiment of the present disclosure includes a processor 1001 and a memory 1002. The processor 1001 can perform various appropriate actions and processes according to the program or instructions stored in the memory 1002. The processor 1001 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 1001 may also include an onboard memory for caching purposes. The processor 1001 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

[0086] The processor 1001 and the memory 1002 are connected to each other via a bus. The processor 1001 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in the memory 1002. It should be noted that the program may also be stored in one or more storage devices other than the memory 1002. The processor 1001 may also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more storage devices.

[0087] According to an embodiment of the present disclosure, the electronic device 1000 may further include an input device 1003 and an output device 1004, which are also connected to the bus. In addition, the electronic device 1000 may further include one or more of the following components: an input part including a keyboard, a mouse, etc.; an output part including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage part including a hard disk, etc.; and a communication part including a network interface card such as a LAN card, a modem, etc.

[0088] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part, and / or installed from a removable medium. When the computer program is executed by the processor 1001, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.

[0089] The present disclosure also provides a computer-readable storage medium and a computer program product. The computer-readable storage medium may be included in the device / apparatus / system described in the above embodiments; or it may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed by the processor 1001, the method according to the embodiment of the present disclosure is implemented. The computer program product includes a computer program, and the computer program can implement the method of any of the above embodiments when executed by the processor.

[0090] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, such as, but not limited to, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0091] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0092] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0093] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A method for analyzing a project engineering file based on a computer language, wherein the project engineering file based on a computer language includes at least one header file, and the method include: Acquire the at least one header file according to the project path of the project; Parsing the content of each header file in the at least one header file to obtain the attribute information and method information declared in each header file; as well as Output the acquired attribute information and method information; The parsing of the content of each header file in the at least one header file to obtain the attribute information and method information declared in each header file includes: Scanning the content of each header file line by line and character by character to read the characters included in the header file; matching the obtained characters with keyword characters in a plurality of keyword lexicons to determine the classes, categories, and attribute information and method information of the categories declared in the header file; A state machine is used to control the reading and matching process, wherein the state machine includes S0 a state of a character or string to be recognized, S1 a state of starting to recognize a class name, S2 a state of a classification name to be recognized, S3 a state of starting to recognize a classification name, S4 a state of a method / attribute to be recognized, S5 a state of starting to recognize a method, and S6 a state of starting to recognize an attribute; The process of controlling the reading and the matching by using a state machine includes: In each state, the read characters are stored in a temporary string variable, a keyword table corresponding to the state is determined, and the temporary string variable is matched with the determined keyword table; In response to the temporary string variable successfully matching the determined keyword table, the characters stored in the temporary string variable are cleared, and the state switching is performed, returning to the step of storing the read characters in the temporary string variable in each state, determining the keyword table corresponding to the state, and matching the temporary string variable with the keyword table in the state, until the declaration of the class is determined to be completed by matching the class declaration scope to end the keyword table.

2. The method according to claim 1, in, The attribute information includes at least one of an attribute keyword, an attribute type, and an attribute name, and the method information includes at least one of a method name, a method return value, and a method parameter.

3. The method according to claim 2, further comprising: include: Determine repeated attributes and repeated methods in the header file according to the attribute information and the method information; as well as Outputs the obtained repeated attributes and repeated methods.

4. The method according to claim 3, in, Determining the repeated attributes and repeated methods in the header file according to the attribute information and the method information includes: Constructing a hash table according to the combination of the attribute keyword, attribute type and attribute name and the combination of the method name, method return value and method parameter; and The attribute information and the method information are screened using the hash table to determine repeated attributes and repeated methods in the header file.

5. The method according to claim 3 or 4, further comprising: include: Modifying the names of the determined duplicate attributes so that the names of the attributes are different from each other; as well as The names of the determined duplicate methods are modified so that the names of the methods are different from each other.

6. The method according to claim 1, in, The multiple keyword word lists include a class declaration scope start keyword list, a class declaration scope end keyword list, a class name terminator list, a category name start keyword list, a category name terminator list, a method start keyword list, an attribute start keyword list, an attribute and method end keyword list, and an attribute keyword list.

7. The method according to claim 1, in, The acquiring of the at least one header file according to the project path of the project includes: A plurality of header files with a preset suffix under the project path are acquired one by one or a plurality of header files with a preset suffix under the project path are acquired simultaneously.

8. The method according to claim 1, in, The attribute information and method information obtained by output include: storing the attribute information and method information as a linked list structure, wherein each node in the linked list structure is a classification; and The acquired attribute information and method information are output based on the linked list structure.

9. The method according to any one of claims 1 to 8, in, The project engineering file is a project engineering file based on Objective-C language.

10. The method according to any one of claims 1 to 8, in, The project engineering file also includes at least one source file.

11. An analysis device for a project engineering file based on a computer language, wherein the project engineering file based on a computer language includes at least one header file, wherein the analysis device include: A file acquisition module, configured to acquire the at least one header file according to the project path of the project; A file parsing module, configured to parse the content of each header file in the at least one header file to obtain the attribute information and method information declared in each header file; as well as an information output module configured to output the acquired attribute information and method information; The file parsing module includes a reading and matching processing unit and a state control unit; The reading and matching processing unit is used to scan the content of each header file line by line and character by character to read the characters included in the header file; match the obtained characters with the keyword characters in multiple keyword vocabulary to determine the class, classification and attribute information and method information of the classification declared in the header file; The state control unit is used to control the reading and matching process by using a state machine, wherein the state machine includes S0 a state of a character or string to be recognized, S1 a state of starting to recognize a class name, S2 a state of a classification name to be recognized, S3 a state of starting to recognize a classification name, S4 a state of a method / attribute to be recognized, S5 a state of starting to recognize a method, and S6 a state of starting to recognize an attribute; The state control unit is specifically used to store the read characters in a temporary string variable in each state, determine the keyword table corresponding to the state, and match the temporary string variable with the determined keyword table; in response to the temporary string variable successfully matching the determined keyword table, clear the characters stored in the temporary string variable, execute the state switching, and return to the step of storing the read characters in a temporary string variable in each state, determining the keyword table corresponding to the state, and matching the temporary string variable with the keyword table in the state, until the declaration acquisition of the class is determined to end by matching the class declaration scope to end the keyword table.

12. An analysis device for project engineering documents based on computer language, include: A memory storing program instructions; as well as A processor is configured to execute the program instructions to perform the project engineering file analysis method based on computer language according to any one of claims 1 to 10.

13. A computer-readable storage medium storing computer-executable instructions, wherein the instructions are used to implement the computer language-based project engineering file analysis method according to any one of claims 1 to 10 when executed.

14. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 10.