A kind of empty statement block search method, device and equipment and storage medium

By generating an abstract syntax tree and traversing key nodes to find empty code blocks, the problem of manual code review finding empty code blocks is solved, improving the efficiency and success rate of investigation and reducing costs.

CN115586903BActive Publication Date: 2026-01-30PING AN BANK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211379623.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-04
Publication Date
2026-01-30
Estimated Expiration
2042-11-04

AI Technical Summary

Technical Problem

In software project development, empty code blocks are difficult to detect through manual code review, resulting in high concealment, long time consumption, high cost, and easy to cause serious program problems.

Method used

By obtaining the project's source code, an abstract syntax tree is generated, and empty statement blocks are searched by traversing based on a preset list and key nodes. The abstract syntax tree is then used to quickly identify empty statement blocks.

Benefits of technology

It improves the efficiency and success rate of checking empty statement blocks, reduces labor costs, and shortens the checking time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115586903B_ABST
    Figure CN115586903B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, and storage medium for finding empty statement blocks. By obtaining the project source code, extracting the abstract syntax tree from the Java files in the project source code, and using the abstract syntax tree with a preset list and preset key nodes, it quickly finds the empty statement blocks that may exist in the project source code. This solves the technical problems of high difficulty, low success rate, high time consumption, high labor cost, and low efficiency of manual code review.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, device and storage medium for searching empty statement blocks. Background Technology

[0002] During software project development, due to differences in developers' experience and understanding of code, empty statement blocks may appear when using try, catch, and finally statements to handle potential code exceptions. However, empty statement blocks do not cause syntax errors or compilation errors; exceptions only occur when the program reaches the block. Once an exception occurs, it can lead to serious program problems. The existence of empty statement blocks is somewhat insidious, but the harm is significant. While conventional manual code review can detect such issues, it has the following limitations:

[0003] 1. Because no syntax error is triggered and the code compilation does not cause any exceptions, it is still difficult to find this type of problem through manual code review. As a result, empty statement block issues can easily be brought to the production environment and cause serious consequences.

[0004] 2. Manual code review is time-consuming: A project may have tens of thousands of lines of code. If the code is reviewed entirely by manual code review, it will take a lot of time, resulting in high labor costs and low efficiency. Summary of the Invention

[0005] This application provides a method, apparatus, device, and storage medium for finding empty statement blocks, which solves the technical problems of high difficulty, low success rate, high time consumption, high labor cost, and low efficiency of manual code review.

[0006] In view of this, the first aspect of this application provides a method for finding empty statement blocks, the method comprising:

[0007] S1. Obtain the project source code;

[0008] S2. By traversing all folders of the project's source code, store the first file with the .java extension into a file list;

[0009] S3. Parse the first file in the file list sequentially to generate an abstract syntax tree;

[0010] S4. Based on the abstract syntax tree, traverse the preset list and preset key nodes to determine whether there are empty statement blocks in the first file.

[0011] Optionally, step S1 specifically includes:

[0012] Obtain the project source code from the project source code management repository gitlab using the git clone command.

[0013] Optionally, step S4 specifically includes:

[0014] Determine if the abstract syntax tree contains a list of classdeclarations:

[0015] If it does not exist, then the first file is an interface file, and the search will be terminated;

[0016] If it exists, then search for the classbody node under the classdeclaration list;

[0017] Determine whether the classbody node contains a methoddeclaration list;

[0018] If it does not exist, then the first file is a structure file, and the search will be terminated;

[0019] If it exists, then traverse the methodbody nodes under the methoddeclaration list;

[0020] Determine if the methodbody node exists in the blockstatement list:

[0021] If it does not exist, then it is an empty method, and the search ends;

[0022] If it exists, then traverse all blockstatement nodes under the blockstatement list;

[0023] Determine whether the blockstatement node is a trystatement node, catchstatement node, or finallystatement node:

[0024] If so, determine whether the Expression / Name / Value value under the blockstatement node is empty. If so, there is an empty statement block in the first file; otherwise, skip the current blockstatement node.

[0025] Optionally, after an empty statement block exists in the first file, it further includes:

[0026] Store the path of the blockstatement node in the list of abnormal results.

[0027] A second aspect of this application provides an empty statement block search device, the device comprising:

[0028] The retrieval unit is used to retrieve the project's source code;

[0029] The file traversal unit is used to traverse all folders of the project's source code and store the first file with the .java extension into the file list;

[0030] A parsing unit is used to parse the first file in the file list sequentially to generate an abstract syntax tree;

[0031] The search unit is used to traverse a preset list and preset key nodes based on the abstract syntax tree to determine whether there is an empty statement block in the first file.

[0032] Optionally, the acquisition unit is specifically used for:

[0033] Obtain the project source code from the project source code management repository gitlab using the git clone command.

[0034] Optionally, the search unit is specifically used for:

[0035] Determine if the abstract syntax tree contains a list of classdeclarations:

[0036] If it does not exist, then the first file is an interface file, and the search will be terminated;

[0037] If it exists, then search for the classbody node under the classdeclaration list;

[0038] Determine whether the classbody node contains a methoddeclaration list;

[0039] If it does not exist, then the first file is a structure file, and the search will be terminated;

[0040] If it exists, then traverse the methodbody nodes under the methoddeclaration list;

[0041] Determine if the methodbody node exists in the blockstatement list:

[0042] If it does not exist, then it is an empty method, and the search ends;

[0043] If it exists, then traverse all blockstatement nodes under the blockstatement list;

[0044] Determine whether the blockstatement node is a trystatement node, catchstatement node, or finallystatement node:

[0045] If so, determine whether the Expression / Name / Value value under the blockstatement node is empty. If so, there is an empty statement block in the first file; otherwise, skip the current blockstatement node.

[0046] A third aspect of this application provides an empty statement block search device, the device comprising a processor and a memory:

[0047] The memory is used to store program code and transmit the program code to the processor;

[0048] The processor is configured to perform the steps of the empty statement block search method as described in the first aspect above, according to the instructions in the program code.

[0049] A fourth aspect of this application provides a computer-readable storage medium for storing program code for performing the method described in the first aspect above.

[0050] The fifth aspect of this application provides a computer program product including instructions that, when run on a computer, cause the computer to perform the method described in the first aspect above.

[0051] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:

[0052] This application provides a method, apparatus, device, and storage medium for finding empty statement blocks. By obtaining the project source code, extracting the abstract syntax tree from the Java files in the project source code, and using the abstract syntax tree with a preset list and preset key nodes, it quickly finds the empty statement blocks that may exist in the project source code. This solves the technical problems of high difficulty, low success rate, high time consumption, high labor cost, and low efficiency of manual code review. Attached Figure Description

[0053] Figure 1 This is a flowchart of the empty statement block search method in the embodiments of this application;

[0054] Figure 2 This is a flowchart illustrating the logic of step S4 in the empty statement block search method in this application embodiment.

[0055] Figure 3 This is a schematic diagram of the structure of the empty statement block search device in the embodiments of this application;

[0056] Figure 4 This is a schematic diagram of the structure of the empty statement block search device in the embodiments of this application. Detailed Implementation

[0057] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.

[0058] This application designs a method, device, equipment, and storage medium for finding empty statement blocks, which solves the technical problems of high difficulty, low success rate, high time consumption, high labor cost, and low efficiency of manual code review.

[0059] For easier understanding, please refer to Figure 1 , Figure 1 This is a flowchart of the empty statement block search method in the embodiments of this application, as follows: Figure 1 As shown, specifically:

[0060] S1. Obtain the project source code;

[0061] Specifically:

[0062] Obtain the project source code from the project source code management repository gitlab using the git clone command.

[0063] S2. By traversing all folders of the project source code, store the first file with the .java extension into the file list;

[0064] S3. Parse the first file in the file list in turn to generate an abstract syntax tree;

[0065] S4. Based on the abstract syntax tree, traverse the preset list and preset key nodes to determine whether there are empty statement blocks in the first file.

[0066] Please see Figure 2 , Figure 2 This is a flowchart illustrating the logic of step S4 in the empty statement block search method of this application embodiment, as follows: Figure 2 As shown, it includes:

[0067] Determine if the list of classdeclarations exists in the abstract syntax tree:

[0068] If it does not exist, the first file is the interface file, so the search will stop.

[0069] If it exists, then search for the classbody node under the classdeclaration list;

[0070] Check if the classbody node contains a list of methodsdeclaration;

[0071] If it does not exist, the first file is a structure file, so the search will stop.

[0072] If it exists, then traverse the methodbody nodes under the methoddeclaration list;

[0073] Determine if the methodbody node contains a list of blockstatements:

[0074] If it does not exist, then it is an empty method, and the search ends;

[0075] If it exists, then traverse all blockstatement nodes under the blockstatement list;

[0076] Determine if a blockstatement node is a trystatement node, catchstatement node, or finallystatement node:

[0077] If so, check if the Expression / Name / Value values ​​under the blockstatement node are empty. If so, there is an empty statement block in the first file; otherwise, skip the current blockstatement node.

[0078] Furthermore, after the first file contains an empty statement block, it also includes:

[0079] Store the path of the blockstatement node in the list of exception results.

[0080] It should be noted that after iterating through the first file included in the entire file list, if the exception result list is empty, it means that there is no empty statement block in the entire project source code that caused the exception; if the exception result list is not empty, then the exception result list contains the path of the empty statement block that caused the exception in the entire project source code.

[0081] Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of the empty statement block search device in the embodiments of this application, as shown below. Figure 3 As shown, specifically:

[0082] Acquisition unit 301 is used to acquire the project source code;

[0083] File traversal unit 302 is used to traverse all folders of the project source code and store the first file with the .java extension into the file list;

[0084] Parsing unit 303 is used to parse the first file in the file list in sequence to generate an abstract syntax tree;

[0085] The search unit 304 is used to traverse the preset list and preset key nodes based on the abstract syntax tree to determine whether there is an empty statement block in the first file.

[0086] Furthermore, the acquisition unit 301 is specifically used for:

[0087] Obtain the project source code from the project source code management repository gitlab using the git clone command.

[0088] Furthermore, the lookup unit 304 is specifically used for:

[0089] Determine if the list of classdeclarations exists in the abstract syntax tree:

[0090] If it does not exist, the first file is the interface file, so the search will stop.

[0091] If it exists, then search for the classbody node under the classdeclaration list;

[0092] Check if the classbody node contains a list of methodsdeclaration;

[0093] If it does not exist, the first file is a structure file, so the search will stop.

[0094] If it exists, then traverse the methodbody nodes under the methoddeclaration list;

[0095] Determine if the methodbody node contains a list of blockstatements:

[0096] If it does not exist, then it is an empty method, and the search ends;

[0097] If it exists, then traverse all blockstatement nodes under the blockstatement list;

[0098] Determine if a blockstatement node is a trystatement node, catchstatement node, or finallystatement node:

[0099] If so, check if the Expression / Name / Value values ​​under the blockstatement node are empty. If so, there is an empty statement block in the first file; otherwise, skip the current blockstatement node.

[0100] This application also provides another empty statement block search device, such as... Figure 4 As shown, for ease of explanation, only the parts related to the embodiments of this application are shown. For specific technical details not disclosed, please refer to the method section of the embodiments of this application. The terminal can be any terminal device including mobile phones, tablets, personal digital assistants (PDAs), point-of-sale (POS) terminals, in-vehicle computers, etc. Taking a mobile phone as an example:

[0101] Figure 4 This is a block diagram illustrating a portion of the structure of a mobile phone related to the terminal provided in the embodiments of this application. (Reference) Figure 4 The mobile phone includes: a radio frequency (RF) circuit 1010, a memory 1020, an input unit 1030, a display unit 1040, a sensor 1050, an audio circuit 1060, a wireless fidelity (WiFi) module 1070, a processor 1080, and a power supply 1090, etc. Those skilled in the art will understand that... Figure 4 The mobile phone structure shown does not constitute a limitation on the mobile phone and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0102] The following is combined Figure 4 A detailed introduction to each component of a mobile phone:

[0103] The RF circuit 1010 can be used for receiving and transmitting signals during information transmission or calls. Specifically, it receives downlink information from the base station and processes it with the processor 1080; additionally, it transmits uplink data to the base station. Typically, the RF circuit 1010 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, etc. Furthermore, the RF circuit 1010 can also communicate wirelessly with networks and other devices. The aforementioned wireless communications may use any communication standard or protocol, including but not limited to Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, and Short Messaging Service (SMS).

[0104] The memory 1020 can be used to store software programs and modules. The processor 1080 executes various mobile phone functions and data processing by running the software programs and modules stored in the memory 1020. The memory 1020 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory 1020 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0105] The input unit 1030 can be used to receive input numerical or character information, and to generate key signal inputs related to user settings and function control of the mobile phone. Specifically, the input unit 1030 may include a touch panel 1031 and other input devices 1032. The touch panel 1031, also known as a touch screen, can collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel 1031), and drive the corresponding connection devices according to a pre-set program. Optionally, the touch panel 1031 may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 1080, and can also receive and execute commands sent by the processor 1080. In addition, the touch panel 1031 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 1031, the input unit 1030 may also include other input devices 1032. Specifically, other input devices 1032 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.

[0106] The display unit 1040 can be used to display information input by the user or information provided to the user, as well as various menus of the mobile phone. The display unit 1040 may include a display panel 1041, which may optionally be configured as a Liquid Crystal Display (LCD), Organic Light-Emitting Diode (OLED), or similar display panel 1041. Further, a touch panel 1031 may cover the display panel 1041. When the touch panel 1031 detects a touch operation on or near it, it transmits the information to the processor 1080 to determine the type of touch event. Subsequently, the processor 1080 provides corresponding visual output on the display panel 1041 according to the type of touch event. Although in Figure 4 In this embodiment, the touch panel 1031 and the display panel 1041 are two separate components to realize the input and output functions of the mobile phone. However, in some embodiments, the touch panel 1031 and the display panel 1041 can be integrated to realize the input and output functions of the mobile phone.

[0107] The mobile phone may also include at least one sensor 1050, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor. The ambient light sensor can adjust the brightness of the display panel 1041 according to the ambient light level, and the proximity sensor can turn off the display panel 1041 and / or the backlight when the phone is moved to the ear. As a type of motion sensor, an accelerometer sensor can detect the magnitude of acceleration in various directions (generally three axes). When stationary, it can detect the magnitude and direction of gravity and can be used for applications that recognize the phone's posture (such as landscape / portrait switching, related games, magnetometer posture calibration), vibration recognition-related functions (such as pedometer, taps), etc. Other sensors that may be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, and infrared sensors, will not be described in detail here.

[0108] The audio circuit 1060, speaker 1061, and microphone 1062 provide an audio interface between the user and the mobile phone. The audio circuit 1060 converts the received audio data into electrical signals and transmits them to the speaker 1061, where the speaker 1061 converts them into sound signals for output. On the other hand, the microphone 1062 converts the collected sound signals into electrical signals, which are then received by the audio circuit 1060, converted into audio data, and then processed by the processor 1080 before being transmitted via the RF circuit 1010 to, for example, another mobile phone, or the audio data can be output to the memory 1020 for further processing.

[0109] WiFi is a short-range wireless transmission technology. Through the WiFi module 1070, mobile phones can help users send and receive emails, browse web pages, and access streaming media, providing users with wireless broadband internet access. Although Figure 4 The WiFi module 1070 is shown, but it is understood that it is not an essential component of a mobile phone and can be omitted as needed without changing the essence of the invention.

[0110] The processor 1080 is the control center of the mobile phone, connecting various parts of the phone through various interfaces and lines. It executes software programs and / or modules stored in the memory 1020 and calls data stored in the memory 1020 to perform various functions and process data, thereby providing overall monitoring of the phone. Optionally, the processor 1080 may include one or more processing units; preferably, the processor 1080 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 1080.

[0111] The mobile phone also includes a power supply 1090 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 1080 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.

[0112] Although not shown, mobile phones may also include a camera, Bluetooth module, etc., which will not be described in detail here.

[0113] In this embodiment of the application, the processor 1080 included in the terminal also has the following functions:

[0114] S1. Obtain the project source code;

[0115] S2. By traversing all folders of the project source code, store the first file with the .java extension into the file list;

[0116] S3. Parse the first file in the file list in turn to generate an abstract syntax tree;

[0117] S4. Based on the abstract syntax tree, traverse the preset list and preset key nodes to determine whether there are empty statement blocks in the first file.

[0118] This application also provides a computer-readable storage medium for storing program code that executes any one of the implementation methods for finding empty statement blocks described in the foregoing embodiments.

[0119] This application also provides a computer program product including instructions that, when run on a computer, cause the computer to execute any one of the implementation methods of the empty statement block search method described in the foregoing embodiments.

[0120] This application provides a method, apparatus, device, and storage medium for finding empty statement blocks. By obtaining the project source code, extracting the abstract syntax tree from the Java files in the project source code, and using the abstract syntax tree with a preset list and preset key nodes, the method quickly finds possible empty statement blocks in the project source code. This solves the technical problems of high difficulty, low success rate, high time consumption, high labor cost, and low efficiency of manual code review.

[0121] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0122] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0123] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0124] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.

[0125] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0126] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0127] If the integrated unit is implemented as 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 this application, 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. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.

[0128] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A null statement block search method, characterized by, The method comprises the following steps: S1, obtaining project source code, specifically comprising: Obtaining project source code from a project source code management warehouse gitlab through a git clone instruction; S2, storing a first file with a suffix of.java in a file list by traversing all folders of the project source code; S3, sequentially parsing the first file in the file list to generate an abstract syntax tree; S4, traversing a preset list and a preset key node based on the abstract syntax tree to determine whether there is an empty statement block in the first file; The step S4 specifically comprises: Determine whether there is a classdeclaration list in the abstract syntax tree: If not, the first file is an interface file, and the search is exited; If yes, find the classbody node under the classdeclaration list; Determine whether the classbody node has a methoddeclaration list; If not, the first file is a structure file, and the search is exited; If yes, traverse the methodbody node under the methoddeclaration list; Determine whether the methodbody node has a blockstatement list: If not, it is an empty method, and the search is exited; If yes, traverse all blockstatement nodes under the blockstatement list; Determine whether the blockstatement node is a trystatement node or a catchstatement node or a finallystatement node: If yes, determine whether the Expression / Name / Value value under the blockstatement node is empty, if yes, there is an empty statement block in the first file, otherwise, skip the current blockstatement node.

2. The null statement block search method of claim 1, wherein, After the first file has the empty statement block, it further comprises: Store the path of the blockstatement node in an exception result list.

3. A null statement block finding apparatus characterized by comprising: The method comprises the following steps: An acquisition unit is configured to obtain project source code, specifically configured to obtain project source code from a project source code management warehouse gitlab through a git clone instruction; A file traversal unit is configured to store a first file with a suffix of.java in a file list by traversing all folders of the project source code; A parsing unit is configured to sequentially parse the first file in the file list to generate an abstract syntax tree; A search unit is configured to traverse a preset list and a preset key node based on the abstract syntax tree to determine whether there is an empty statement block in the first file; The search unit is specifically configured to: Determine whether there is a classdeclaration list in the abstract syntax tree: If not, the first file is an interface file, and the search is exited; If exists, find the classbody node under the classdeclaration list; Judge whether the classbody node has a methoddeclaration list; If not, the first file is a structure file, and the finding is exited; If exists, traverse the methodbody node under the methoddeclaration list; Judge whether the methodbody node has a blockstatement list: If not, it is an empty method, and the finding is exited; If exists, traverse all the blockstatement nodes under the blockstatement list; Judge whether the blockstatement node is a trystatement node or a catchstatement node or a finallystatement node: If yes, judge whether the Expression / Name / Value value under the blockstatement node is empty, if yes, there is an empty statement block in the first file, otherwise, the current blockstatement node is skipped.

4. A null statement block finding apparatus characterized by comprising: The device comprises a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is used to execute the empty statement block finding method according to the instructions in the program code.

5. A computer readable storage medium, characterized in that, The computer readable storage medium is used to store program code, and the program code is used to execute the empty statement block finding method.

6. A computer program product comprising instructions, characterized in that, When it runs on a computer, it makes the computer execute the empty statement block finding method.

Citation Information

Patent Citations

  • Code standardization method and device, computer equipment and storage medium

    CN111078568A

  • Code processing method and device, server and readable storage medium

    CN111352649A