Reverse architecture method and device based on javaparser and storage medium
Through the reverse architecture method based on Javaparser, the API interface of the tiptopJava toolkit is used to decompose and modify the code, and the problem of inefficiency of traditional manual analysis methods is solved, fast and automated code inspection and modification are achieved, and code quality and development efficiency are improved.
Patent Information
- Application Number
- CN202510019402.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-07
- Publication Date
- 2025-04-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional manual analysis methods are difficult to efficiently understand and manage software architectures, especially in fast iterative environments such as agile development, continuous integration and continuous deployment, and automation tools are needed to assist in code analysis and architecture evaluation.
Using the reverse architecture method based on Javaparser, by introducing the tiptop Java toolkit, the first API interface is encapsulated for code inspection and the second API interface is used for code modification, the code file is decomposed into a syntax tree, and the code is viewed and modified through the checkCode and reWrite interfaces.
It realizes rapid and automated code inspection and modification, improves code quality and development efficiency, and can play an important role in multiple links of software development.
Smart Images

Figure CN119847487A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network security technology, and in particular to a javaparser-based reverse architecture method, device and storage medium. Background Art
[0002] As software systems continue to expand in size and become more complex, it becomes increasingly difficult to understand and manage software architecture. Traditional manual analysis methods are inefficient and error-prone, and there is an urgent need for automated tools and technologies to assist.
[0003] The popularity of modern software development methods such as agile development, continuous integration and continuous deployment requires faster and more efficient code analysis and architecture evaluation methods to adapt to frequent code changes and rapid iterative development. Enterprises and organizations are increasingly concerned about the quality, maintainability and scalability of software, so they need a reverse architecture method, device and storage medium based on javaparser that can solve the above problems. Summary of the invention
[0004] The main purpose of this application is to provide a reverse architecture method, device and storage medium based on javaparser, aiming to solve the problems mentioned in the background technology.
[0005] The present invention provides a reverse architecture method based on javaparser, the method comprising: Introducing the tiptopJava toolkit, wherein the tiptopJava toolkit encapsulates a first API interface and a second API interface, wherein the first API interface is used to inspect the code, and the second API interface is used to modify the code; Call the tiptopJava toolkit in the code file to be processed; Decomposing the code file to be processed into a syntax tree by using the tiptopJava toolkit; Call the checkCode and the first API interface in the tiptopJava toolkit to check at least one parameter of the code annotation rate, command rule and annotation method.
[0006] Furthermore, after the “at least one parameter of the code annotation rate, command rules and annotation method”, it also includes: The reWrite and the second API interface in the tiptopJava toolkit are called to modify and / or supplement the source code of the inspected unqualified code module.
[0007] Furthermore, the “modifying and / or supplementing the source code of the inspected unqualified code module” specifically includes: modifying and / or supplementing the source code by introducing different parameters through reconstruction.
[0008] Furthermore, after inspecting at least one parameter of the code annotation rate, command rules and annotation method, an inspection report is generated, and unqualified code modules are determined based on the inspection report.
[0009] Furthermore, a file type parsing method is also included, the method comprising the following steps: When the tiptopJava toolkit is called in the code file to be processed, the file type is parsed by the tiptopJava toolkit. If the code file to be processed is a java file, the tiptopJava toolkit continues to be called; if the code file to be processed is not a java file, the calling step is directly exited.
[0010] Furthermore, the tiptopJava toolkit uses the built-in API deconstruction of Javaparser, and forms the reconstruction of checkCode and reWrite by calling the JavaparserAPI and the pre-configured processing logic.
[0011] Furthermore, the “decomposing the code file to be processed into a syntax tree by using the tiptopJava toolkit” specifically includes: referencing and loading the syntax tree API interface of the javaparser framework in the tiptopJava toolkit.
[0012] The present invention also provides a reverse architecture device based on javaparser, the device comprising: An import module, used to import the tiptopJava toolkit, wherein the tiptopJava toolkit encapsulates a first API interface and a second API interface, wherein the first API interface is used to inspect the code, and the second API interface is used to modify the code; A calling module is used to call the tiptopJava toolkit in the code file to be processed, and the tiptopJava toolkit can be used to decompose the code file to be processed into a syntax tree, call the checkCode and the first API interface in the tiptopJava toolkit, and check at least one parameter of the code annotation rate, command rules and annotation method.
[0013] The present invention also provides a storage medium, including a stored program, which controls the device where the computer-readable storage medium is located to execute the above-mentioned reverse architecture method based on javaparser when the program is running.
[0014] In the present invention, a small framework is designed through the JavaParser library, through encapsulation and expansion, and the proxy mode of the design pattern. It can intuitively and quickly reconstruct the basic structure of the code to achieve the purpose of modifying and viewing the source code. It can play an important role in multiple links of software development and improve development efficiency and code quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0016] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0017] Figure 1 It is a logic timing diagram of a reverse architecture method based on javaparser according to an embodiment of the present invention.
[0018] Figure 2 It is a schematic diagram of the javaparser decomposition syntax tree.
[0019] Figure 3 yes Figure 1 The specific implementation of the tiptopJava toolkit in the embodiment.
[0020] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0021] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention.
[0022] See also Figure 1-3 The present invention provides a reverse architecture method based on javaparser, the method comprising: S10: Introduced the tiptopJava toolkit.
[0023] Specifically, the user needs to introduce the jar package (tiptopJava.jar) in the development environment through pom or other methods, wherein the tiptopJava tool package encapsulates a first API interface and a second API interface, wherein the first API interface is used to inspect the code, and the second API is used to modify the code.
[0024] S20: calling the tiptopJava toolkit in the code file to be processed.
[0025] S30 decomposes the code file to be processed into a syntax tree by using the tiptopJava toolkit.
[0026] The present invention relies on the JavaParser library, an open source project on GitHub. Its bottom layer is to decompose the code into a syntax tree structure, search on the specified tree, and finally call a specific callback according to the type of node encountered. The tiptopJava toolkit is encapsulated and implemented on the basis of JavaParser, and its syntax tree API interface is called at the bottom layer.
[0027] S40: calling the checkCode and the first API interface in the tiptopJava toolkit to check at least one parameter of the code annotation rate, command rule and annotation method.
[0028] In the present invention, the comment rate of the code can be checked by inspection, such as the comment mode on variables and / or methods and the camel case rules of various commands.
[0029] In the present invention, a small framework is designed through the JavaParser library, through encapsulation and expansion, and the proxy mode of the design pattern. It can intuitively and quickly reconstruct the basic structure of the code to achieve the purpose of modifying and viewing the source code. It can play an important role in multiple links of software development and improve development efficiency and code quality.
[0030] In the present invention, after the "at least one parameter of the code annotation rate, command rules and annotation method" is checked, it also includes: The reWrite and the second API interface in the tiptopJava toolkit are called to modify and / or supplement the source code of the inspected unqualified code module.
[0031] In a preferred implementation manner, the "modifying and / or supplementing the source code of the inspected unqualified code module" specifically includes: modifying and / or supplementing the source code by introducing different parameters through reconstruction.
[0032] In the present invention, during use, only the upper layer call and the configuration of each API deconstruction and reconstruction parameter need to be paid attention to, and no attention needs to be paid to how the syntax tree parses some specific classes, so that fast code reconstruction can be achieved.
[0033] In a preferred embodiment, an inspection report is generated after inspecting at least one parameter of the code's annotation rate, command rules, and annotation method, and unqualified code modules are determined based on the inspection report.
[0034] The present invention also includes a file type parsing method, which includes the following steps: When the tiptopJava toolkit is called in the code file to be processed, the file type is parsed by the tiptopJava toolkit. If the code file to be processed is a java file, the tiptopJava toolkit continues to be called; if the code file to be processed is not a java file, the calling step is directly exited.
[0035] In the present invention, the tiptopJava toolkit relies on Javaparser and is deconstructed by using the built-in API of Javaparser. After calling the JavaparserAPI and the pre-configured processing logic, the reconstruction of checkCode and reWrite is formed.
[0036] It should be noted that the present invention relies on the open source JavaParser library of GitHub, such as Figure 2 As shown, its underlying structure is to decompose the code into a syntax tree structure, search on the specified tree, and finally call a specific callback according to the type of node encountered.
[0037] Preferably, the "decomposing the code file to be processed into a syntax tree by using the tiptopJava toolkit" specifically includes: referencing and loading the syntax tree API interface of the javaparser framework in the tiptopJava toolkit.
[0038] The present invention also provides a reverse architecture device based on javaparser, the device comprising: An import module, used to import the tiptopJava toolkit, wherein the tiptopJava toolkit encapsulates a first API interface and a second API interface, wherein the first API interface is used to inspect the code, and the second API interface is used to modify the code; A calling module is used to call the tiptopJava toolkit in the code file to be processed, and the tiptopJava toolkit can be used to decompose the code file to be processed into a syntax tree, call the checkCode and the first API interface in the tiptopJava toolkit, and check at least one parameter of the code annotation rate, command rules and annotation method.
[0039] The present invention also provides a storage medium, including a stored program, which controls the device where the computer-readable storage medium is located to execute the above-mentioned reverse architecture method based on javaparser when the program is running.
[0040] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.
Claims
1. A reverse architecture method based on javaparser, characterized in that: The method comprises: Introducing the tiptopJava toolkit, wherein the tiptopJava toolkit encapsulates a first API interface and a second API interface, wherein the first API interface is used to inspect the code, and the second API interface is used to modify the code; Call the tiptopJava toolkit in the code file to be processed; Decomposing the code file to be processed into a syntax tree by using the tiptopJava toolkit; Call the checkCode and the first API interface in the tiptopJava toolkit to check at least one parameter of the code annotation rate, command rule and annotation method.
2. The reverse architecture method based on javaparser according to claim 1, characterized in that: After the "at least one parameter of the code annotation rate, command rules and annotation method", it also includes: The reWrite and the second API interface in the tiptopJava toolkit are called to modify and / or supplement the source code of the inspected unqualified code module.
3. The reverse architecture method based on javaparser according to claim 2, characterized in that: The "modifying and / or supplementing the source code of the inspected unqualified code module" specifically includes: modifying and / or supplementing the source code by introducing different parameters through reconstruction.
4. The reverse architecture method based on javaparser according to claim 2, characterized in that: After checking at least one parameter of the code annotation rate, command rules and annotation method, an inspection report is generated, and unqualified code modules are determined according to the inspection report.
5. The reverse architecture method based on javaparser according to claim 1, characterized in that: Also included is a file type parsing method, the method comprising the following steps: When the tiptopJava toolkit is called in the code file to be processed, the file type is parsed by the tiptopJava toolkit. If the code file to be processed is a java file, the tiptopJava toolkit continues to be called; if the code file to be processed is not a java file, the calling step is directly exited.
6. The reverse architecture method based on javaparser according to claim 1, characterized in that: The tiptopJava toolkit uses the built-in API deconstruction of Javaparser, and forms the reconstruction of checkCode and reWrite by calling the JavaparserAPI and the pre-configured processing logic.
7. The reverse architecture method based on javaparser according to claim 1, characterized in that: The "decomposing the code file to be processed into a syntax tree by the tiptopJava toolkit" specifically includes: referencing and loading the syntax tree API interface of the javaparser framework in the tiptopJava toolkit.
8. A reverse architecture device based on javaparser, characterized in that: The device comprises: An import module, used to import the tiptopJava toolkit, wherein the tiptopJava toolkit encapsulates a first API interface and a second API interface, wherein the first API interface is used to inspect the code, and the second API interface is used to modify the code; A calling module is used to call the tiptopJava toolkit in the code file to be processed, and the tiptopJava toolkit can be used to decompose the code file to be processed into a syntax tree, call the checkCode and the first API interface in the tiptopJava toolkit, and check at least one parameter of the code annotation rate, command rules and annotation method.
9. A storage medium, characterized in that: It includes a stored program, which controls the device where the computer-readable storage medium is located to execute the reverse architecture method based on javaparser according to any one of claims 1 to 7 when the program is running.
Citation Information
Patent Citations
Code framework identification method and device, electronic equipment and storage medium
CN115357228A
Software toolkit development method and device, computer equipment and storage medium
CN119127285A
Software refactoring systems and methods
US10534604B1