CN110659063A - Software project reconstruction method and device, computer device and storage medium - Google Patents

Software project reconstruction method and device, computer device and storage medium Download PDF

Info

Publication number
CN110659063A
CN110659063A CN201910728484.4A CN201910728484A CN110659063A CN 110659063 A CN110659063 A CN 110659063A CN 201910728484 A CN201910728484 A CN 201910728484A CN 110659063 A CN110659063 A CN 110659063A
Authority
CN
China
Prior art keywords
software project
new software
name
file
hierarchical structure
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910728484.4A
Other languages
Chinese (zh)
Inventor
王保军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201910728484.4A priority Critical patent/CN110659063A/en
Priority to PCT/CN2019/117238 priority patent/WO2021022703A1/en
Publication of CN110659063A publication Critical patent/CN110659063A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/72Code refactoring
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a software project reconstruction method, a software project reconstruction device, a computer device and a storage medium. The method comprises the following steps: copying the original software project to a target path to obtain a new software project; extracting all folders in the new software project to generate a hierarchical structure diagram of the folders; modifying the name of the specified folder and the packet path of the preset file under the specified folder according to the name modification command of the specified folder in the hierarchical structure diagram; parsing a predetermined file into an abstract syntax tree; traversing the abstract syntax tree to obtain all functions in a preset file; and if the entrusted quantity in all the functions is greater than or equal to a preset threshold value, sending out early warning information. The invention realizes the construction of the new software project according to the original software project and can detect the software defects in the new software project.

Description

Software project reconstruction method and device, computer device and storage medium
Technical Field
The invention relates to the technical field of software, in particular to a software project reconstruction method, a software project reconstruction device, a computer device and a computer storage medium.
Background
In software development, it is often involved in the reconstruction of a software project, i.e. the migration of code from a software project or the reconstruction of a new system by means of an existing system. The software project reconstruction usually needs to modify the folder name according to actual needs, and after the folder name is modified, the package path needs to be modified correspondingly. When the size of the software project is large, modification of the packet path is easily incomplete, software operation errors are caused, and software defects are easily generated.
Disclosure of Invention
In view of the foregoing, there is a need for a method, an apparatus, a computer apparatus, and a computer storage medium for reconstructing a software project, which can quickly construct a new software project from an original software project and can detect software defects in the new software project.
A first aspect of the application provides a method of reconstructing a software project, the method comprising:
copying the original software project to a target path to obtain a new software project;
extracting all folders in the new software project, and generating a hierarchical structure diagram of the folders;
receiving a name modification command for a specified folder in the hierarchical structure diagram, modifying the name of the specified folder according to the name modification command, and modifying a packet path of a predetermined file under the specified folder according to the hierarchical structure diagram;
parsing the predetermined file into an abstract syntax tree;
traversing the abstract syntax tree to obtain all functions in the preset file, and detecting the entrusted quantity in all the functions;
and if the entrusted quantity in all the functions is greater than or equal to a preset threshold value, sending out early warning information.
In another possible implementation manner, the receiving a name modification command for a specified folder in the hierarchical structure diagram, and modifying the name of the specified folder according to the name modification command includes:
generating a folder setting interface of the new software project according to the hierarchical structure diagram;
receiving a name modification instruction of a user to a specified folder in the hierarchical structure in the folder setting interface;
and modifying the name of the specified folder into a target name set by the user.
In another possible implementation manner, the detecting the number of delegates in all the functions includes:
detecting whether each function in all the functions calls other interfaces or classes;
and calculating the times of calling other interfaces or classes by all the functions.
In another possible implementation manner, the method further includes:
judging whether the SQL file of the new software item contains a self-defined class or not;
and if the SQL file of the new software project comprises the custom class, correspondingly modifying the path of the custom class in the SQL file according to the modification of the specified folder.
In another possible implementation manner, the determining whether the SQL file of the new software item contains the custom class includes:
acquiring SQL sentences in the SQL files;
and judging whether the input parameters and the output parameters of the SQL statements contain the custom classes.
In another possible implementation manner, the method further includes:
receiving a data source modification command for the new software project;
and modifying the data source information of the new software project according to the data source modification command.
In another possible implementation manner, the method further includes:
compiling and packaging the new software project;
and verifying whether the compiled and packaged new software project can be started normally.
A second aspect of the present application provides a software item reconstruction device, the device comprising:
the acquisition module is used for copying the original software project to a target path to obtain a new software project;
the extraction module is used for generating a hierarchical structure diagram of all folders in the new software project;
the first modification module is used for receiving a name modification command of a specified folder in the hierarchical structure diagram, modifying the name of the specified folder according to the name modification command, and modifying a packet path of a preset file under the specified folder according to the hierarchical structure diagram;
the analysis module is used for analyzing the preset file into an abstract syntax tree;
the detection module is used for traversing the abstract syntax tree to obtain all functions in the preset file and detecting the entrusted quantity in all the functions;
and the early warning module is used for sending out early warning information if the entrusted number in all the functions is greater than or equal to a preset threshold value.
A third aspect of the application provides a computer apparatus comprising a processor for implementing the software item reconstruction method when executing a computer program stored in a memory.
A fourth aspect of the present application provides a computer storage medium having stored thereon a computer program which, when executed by a processor, implements the software project reconstruction method.
Copying an original software project to a target path to obtain a new software project; extracting all folders in the new software project, and generating a hierarchical structure diagram of the folders; receiving a name modification command for a specified folder in the hierarchical structure diagram, modifying the name of the specified folder according to the name modification command, and modifying a packet path of a predetermined file under the specified folder according to the hierarchical structure diagram; parsing the predetermined file into an abstract syntax tree; traversing the abstract syntax tree to obtain all functions in the preset file, and detecting the entrusted quantity in all the functions; and if the entrusted quantity in all the functions is greater than or equal to a preset threshold value, sending out early warning information. The invention realizes the construction of a new software project according to the original software project and can detect the software defects in the new software project.
Drawings
Fig. 1 is a flowchart of a method for reconstructing a software project according to an embodiment of the present invention.
Fig. 2 is a block diagram of a software project reconstruction apparatus according to an embodiment of the present invention.
Fig. 3 is a schematic diagram of a computer device according to an embodiment of the present invention.
Detailed Description
In order that the above objects, features and advantages of the present invention can be more clearly understood, a detailed description of the present invention will be given below with reference to the accompanying drawings and specific embodiments. It should be noted that the embodiments and features of the embodiments of the present application may be combined with each other without conflict.
In the following description, numerous specific details are set forth to provide a thorough understanding of the present invention, and the described embodiments are merely a subset of the embodiments of the present invention, rather than a complete embodiment. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
Preferably, the software project reconstruction method of the present invention is applied in one or more computer devices. The computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing equipment. The computer device can be in man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
Example one
Fig. 1 is a flowchart of a method for reconstructing a software project according to an embodiment of the present invention. The software project reconstruction method is applied to a computer device, is used for quickly constructing a new software project according to an original software project and can detect software defects in the new software project.
As shown in fig. 1, the software project reconstruction method includes:
and S101, copying the original software project to a target path to obtain a new software project.
A software project path setting interface may be generated, a source path (i.e., a root path of an original software project) and a target path (i.e., a root path of a new software project) set on the software project path setting interface by a user are received, the original software project is obtained from the source path, and the original software project is copied to the target path to obtain the new software project.
For example, the source path is D: \ com \ project1, the target path is D: \ com \ project2, the original software project is obtained from the source path D: \ com \ project1, and the original software project is copied to the target path D: \ com \ project2 to obtain a new software project.
A software item list may be displayed on the software item path setting interface, the software item list including existing respective software items, and the original software item may be determined according to a selection operation of a user.
S102, extracting all folders in the new software project, and generating a hierarchical structure diagram of the folders.
The folders of different levels of the software project comprise packages of software projects. And extracting all folders in the new software project, and generating a hierarchical structure diagram of the folders, namely extracting all packages in the new software project and generating the hierarchical structure diagram of the packages.
The package (package) is a characteristic that is used to manage the directory structure of the organization files conveniently and to prevent naming conflicts between different files. The names of classes in different packages may be the same, only the package path needs to be distinguished when used.
In the software project, a class is defined by using a predetermined file (for example, a java file), and the predetermined file contains a package statement which is used for specifying a package path. The predetermined file is the file below its package path. For example, the content of a certain predetermined file test.java is "package com.test; public class Test { } ", wherein" packagecom.test "is a package statement," com.test "is a package path, and the path of the predetermined file is com/Test. If the path of the predetermined file is changed, the packet path in the predetermined file needs to be changed correspondingly, otherwise, an error will occur.
The hierarchical structure diagram is a tree diagram and visually shows the hierarchical structure of the new software project so as to visualize the new software project. Each node in the hierarchy diagram represents a folder.
In a specific embodiment, the extracting all folders in the new software project, and generating the hierarchical structure diagram of the folders includes: and traversing all folders of the new software project from the root path of the new software project, extracting each traversed folder, and taking each extracted folder as a node in the hierarchical structure diagram. All folders of the new software project may be traversed using a recursive traversal method. Each folder of the new software project may contain sub-folders and/or files; if the folder contains a subfolder, then the traversal continues.
S103, receiving a name modification command for a specified folder in the hierarchical structure diagram, modifying the name of the specified folder according to the name modification command, and modifying a package path of a predetermined file in the specified folder according to the hierarchical structure diagram.
The folder setting interface of the new software project can be generated according to the hierarchical structure diagram, a name modification instruction of a user to a specified folder in the hierarchical structure in the folder setting interface is received, and the name of the specified folder is modified into a target name set by the user.
For example, the folder setting interface includes the hierarchical structure diagram, the hierarchical structure diagram includes all folders in the new software project, a selection box is set for each folder, and a name setting window of the folder pops up after the folder is selected, so that a user can set a target name of the folder.
Name modification commands for a plurality of specified folders in the hierarchical structure diagram can be received one by one, and the names of the specified folders and the package paths of the preset files under the specified folders can be modified in batches according to the name modification commands for the specified folders.
And when the package path of the preset file in the specified folder is modified according to the hierarchical structure diagram, traversing all the preset files in the specified folder, and modifying the package path of the preset file according to the target name of the specified folder. Each folder comprises sub-folders and/or files, and if the folder is a folder, the traversal is continued; if the file is the predetermined file, whether the file is the predetermined file is judged, and if the file is the predetermined file, the package path of the predetermined file is modified. A package statement may be read from the predetermined file, and the name of the specified folder in the package statement may be modified to the target name.
A name modification command for a specified hierarchy in the hierarchical structure diagram may be received, and the name of the folder of the specified hierarchy and the package path of the predetermined file under the folder of the specified hierarchy may be uniformly modified according to the name modification command for the specified hierarchy in the hierarchical structure diagram. For example, a name modification command for a second hierarchy in the hierarchy structure diagram is received, the names of folders of the second hierarchy are uniformly modified into names set by a user according to the name modification command, and a package path of a predetermined file under the folders of the second hierarchy is modified.
A selection box may be set on the folder setting interface for each level in the hierarchical structure diagram, and when a certain level is selected, the name of the folder in the level and the package path of the predetermined file in the folder in the level are modified in a unified manner.
And S104, analyzing the preset file into an abstract syntax tree.
When the predetermined file is analyzed into an abstract syntax tree, a root node of the abstract syntax tree is the predetermined file, and child nodes of the root node (namely the predetermined file) are class declarations and correspond to classes in the predetermined file; the child node of the class declaration is a function declaration and represents a function in the predetermined file; and the child node of the function declaration is a data declaration and represents data in the predetermined file. The class declaration, the function declaration and the data declaration can be obtained according to preset keywords. For example, in java software, a class declaration may be obtained by a keyword "class", a function declaration may be obtained by a keyword "static void", and a data declaration may be obtained by a keyword for defining a data type.
S105, traversing the abstract syntax tree to obtain all functions in the preset file, and detecting the entrusted quantity in all the functions.
Delegation is a mechanism that implements a portion of the functionality of a class by another interface or another class. Whether each function in all the functions calls other interfaces or classes can be detected, and the times of calling other interfaces or classes by all the functions are calculated. Each time a function calls another interface or class, the function contains a delegate.
And S106, if the entrusted number in all the functions is greater than or equal to a preset threshold value, sending out early warning information.
In software development, entrusted use can bring certain advantages, but as the number of entrusts increases, the functions of the class are reduced, and the software quality is reduced. And the entrustment quantity of the functions in the preset file is greater than or equal to a preset threshold value, and the entrustment overuse in the preset file is represented. The method sends out early warning information when the entrusted number of the functions in the preset file is greater than or equal to a preset threshold value so as to prompt developers to modify correspondingly, thereby improving the software quality.
The software project reconstruction method in the first embodiment copies the original software project to a target path to obtain a new software project; extracting all folders in the new software project, and generating a hierarchical structure diagram of the folders; receiving a name modification command for a specified folder in the hierarchical structure diagram, modifying the name of the specified folder according to the name modification command, and modifying a packet path of a predetermined file under the specified folder according to the hierarchical structure diagram; parsing the predetermined file into an abstract syntax tree; traversing the abstract syntax tree to obtain all functions in the preset file, and detecting the entrusted quantity in all the functions; and if the entrusted quantity in all the functions is greater than or equal to a preset threshold value, sending out early warning information. The first embodiment realizes that a new software project is quickly constructed according to the original software project, improves the efficiency of software project reconstruction, and can detect software defects in the new software project, thereby improving the software quality.
In another embodiment, the method may further include: judging whether the SQL (Structured Query Language) file of the new software item contains a self-defined class or not; and if the SQL file of the new software project comprises the custom class, correspondingly modifying the path of the custom class in the SQL file according to the modification of the specified folder.
In this embodiment, a class is an abstract data type. The classes include system-native classes and custom classes. The custom class is a class that is user-defined.
The judging whether the SQL file of the new software item contains the self-defining class comprises the following steps: acquiring SQL sentences in the SQL files; and judging whether the input parameters and the output parameters of the SQL statements contain the custom classes.
SQL statements are statements used to perform operations on a database, such as adding, deleting, modifying, querying, etc.
Preset keywords (such as "CREATE", "REPLACE", "select", "insert", "delete", "update", and the like) in the SQL file may be queried, and a statement including the preset keywords is identified as the SQL statement.
All the custom classes can be recorded in a preset file, whether the input parameters and the output parameters of the SQL statements are matched with the custom classes in the preset file or not is judged, and if the input parameters or the output parameters of the SQL statements are matched with the custom classes in the preset file, the input parameters and the output parameters of the SQL statements comprise the custom classes.
Whether the path of the self-defined class contains the specified folder or not can be judged, and if the path of the self-defined class contains the specified folder, the name of the specified folder in the path of the self-defined class is modified into the target name.
In another embodiment, the method may further include: receiving a data source modification command for the new software project; and modifying the data source information of the new software project according to the data source modification command.
In this embodiment, the data source information is stored in an XML (Extensible markup language) file. A bean tag with a preset tag name (e.g., bean id ═ dataSource ") can be extracted from the XML file, and the data source information is obtained according to the bean tag. Each bean label includes a label name and a label class. The label names are used for distinguishing different bean labels, and the function of positioning and searching is achieved. A label class (e.g., calls ═ com.
The data source information may represent different data sources, such as a DBCP data source, a C3P0 data source, or a JNDI data source.
A data source setting interface may be generated, target data source information set in the data source setting interface by a user is received, and the data source information is modified into the target data source information.
The data source information is related information of the database and is used for establishing connection with the database. The data source information may include a database user name, a database login password, a link string, a driver class, and the like. For example, the database username is denoted as "username", the database login password is denoted as "password", the driver class is denoted as "oracle. jdbc. driver. oracledriver", and the link string is denoted as "jdbc: oracle: thin: @127.0.0.1: DEV".
In another embodiment, the method may further include: compiling and packaging the new software project; and verifying whether the compiled and packaged new software project can be started normally. And if the compiled and packaged new software project can be started normally, the new software project passes the verification. The new software project may be compiled, packaged using a management tool (e.g., meaven or ant), and it may be verified whether the compiled, packaged new software project can be started normally.
In a specific embodiment, the verifying whether the compiled and packaged new software project can be started normally includes: verifying whether the new software project can be normally connected with a database; and verifying whether the XML file of the new software item can be normally loaded.
Example two
Fig. 2 is a block diagram of a software project reconstruction apparatus according to a second embodiment of the present invention. The software item reconstruction device 20 is applied to a computer device. The software project reconstruction of the device is to rapidly construct a new software project according to the original software project and detect software defects in the new software project. As shown in fig. 2, the software project reconstructing apparatus 20 may include an obtaining module 201, an extracting module 202, a first modifying module 203, a parsing module 204, a detecting module 205, and an early warning module 206.
The obtaining module 201 is configured to copy the original software project to the target path to obtain a new software project.
A software project path setting interface may be generated, a source path (i.e., a root path of an original software project) and a target path (i.e., a root path of a new software project) set on the software project path setting interface by a user are received, the original software project is obtained from the source path, and the original software project is copied to the target path to obtain the new software project.
For example, the source path is D: \ com \ project1, the target path is D: \ com \ project2, the original software project is obtained from the source path D: \ com \ project1, and the original software project is copied to the target path D: \ com \ project2 to obtain a new software project.
A software item list may be displayed on the software item path setting interface, the software item list including existing respective software items, and the original software item may be determined according to a selection operation of a user.
An extracting module 202, configured to extract all folders in the new software project, and generate a hierarchical structure diagram of the folders.
The folders of different levels of the software project comprise packages of software projects. And extracting all folders in the new software project, and generating a hierarchical structure diagram of the folders, namely extracting all packages in the new software project and generating the hierarchical structure diagram of the packages.
The package (package) is a characteristic that is used to manage the directory structure of the organization files conveniently and to prevent naming conflicts between different files. The names of classes in different packages may be the same, only the package path needs to be distinguished when used.
In the software project, a class is defined by using a predetermined file (for example, a java file), and the predetermined file contains a package statement which is used for specifying a package path. The predetermined file is the file below its package path. For example, the content of a certain predetermined file test.java is "package com.test; public class Test { } ", wherein" packagecom.test "is a package statement," com.test "is a package path, and the path of the predetermined file is com/Test. If the path of the predetermined file is changed, the packet path in the predetermined file needs to be changed correspondingly, otherwise, an error will occur.
The hierarchical structure diagram is a tree diagram and visually shows the hierarchical structure of the new software project so as to visualize the new software project. Each node in the hierarchy diagram represents a folder.
In a specific embodiment, the extracting all folders in the new software project, and generating the hierarchical structure diagram of the folders includes: and traversing all folders of the new software project from the root path of the new software project, extracting each traversed folder, and taking each extracted folder as a node in the hierarchical structure diagram. All folders of the new software project may be traversed using a recursive traversal method. Each folder of the new software project may contain sub-folders and/or files; if the folder contains a subfolder, then the traversal continues.
The first modification module 203 is configured to receive a name modification command for a specified folder in the hierarchical structure diagram, modify the name of the specified folder according to the name modification command, and modify a package path of a predetermined file in the specified folder according to the hierarchical structure diagram.
The folder setting interface of the new software project can be generated according to the hierarchical structure diagram, a name modification instruction of a user to a specified folder in the hierarchical structure in the folder setting interface is received, and the name of the specified folder is modified into a target name set by the user.
For example, the folder setting interface includes the hierarchical structure diagram, the hierarchical structure diagram includes all folders in the new software project, a selection box is set for each folder, and a name setting window of the folder pops up after the folder is selected, so that a user can set a target name of the folder.
Name modification commands for a plurality of specified folders in the hierarchical structure diagram can be received one by one, and the names of the specified folders and the package paths of the preset files under the specified folders can be modified in batches according to the name modification commands for the specified folders.
And when the package path of the preset file in the specified folder is modified according to the hierarchical structure diagram, traversing all the preset files in the specified folder, and modifying the package path of the preset file according to the target name of the specified folder. Each folder comprises sub-folders and/or files, and if the folder is a folder, the traversal is continued; if the file is the predetermined file, whether the file is the predetermined file is judged, and if the file is the predetermined file, the package path of the predetermined file is modified. A package statement may be read from the predetermined file, and the name of the specified folder in the package statement may be modified to the target name.
A name modification command for a specified hierarchy in the hierarchical structure diagram may be received, and the name of the folder of the specified hierarchy and the package path of the predetermined file under the folder of the specified hierarchy may be uniformly modified according to the name modification command for the specified hierarchy in the hierarchical structure diagram. For example, a name modification command for a second hierarchy in the hierarchy structure diagram is received, the names of folders of the second hierarchy are uniformly modified into names set by a user according to the name modification command, and a package path of a predetermined file under the folders of the second hierarchy is modified.
A selection box may be set on the folder setting interface for each level in the hierarchical structure diagram, and when a certain level is selected, the name of the folder in the level and the package path of the predetermined file in the folder in the level are modified in a unified manner.
And the parsing module 204 is configured to parse the predetermined file into an abstract syntax tree.
When the predetermined file is analyzed into an abstract syntax tree, a root node of the abstract syntax tree is the predetermined file, and child nodes of the root node (namely the predetermined file) are class declarations and correspond to classes in the predetermined file; the child node of the class declaration is a function declaration and represents a function in the predetermined file; and the child node of the function declaration is a data declaration and represents data in the predetermined file. The class declaration, the function declaration and the data declaration can be obtained according to preset keywords. For example, in java software, a class declaration may be obtained by a keyword "class", a function declaration may be obtained by a keyword "static void", and a data declaration may be obtained by a keyword for defining a data type.
A detecting module 205, configured to traverse the abstract syntax tree to obtain all functions in the predetermined file, and detect the number of delegates in all the functions.
Delegation is a mechanism that implements a portion of the functionality of a class by another interface or another class. Whether each function in all the functions calls other interfaces or classes can be detected, and the times of calling other interfaces or classes by all the functions are calculated. Each time a function calls another interface or class, the function contains a delegate.
The early warning module 206 is configured to send out early warning information if the number of delegates in all the functions is greater than or equal to a preset threshold.
In software development, entrusted use can bring certain advantages, but as the number of entrusts increases, the functions of the class are reduced, and the software quality is reduced. And the entrustment quantity of the functions in the preset file is greater than or equal to a preset threshold value, and the entrustment overuse in the preset file is represented. The method sends out early warning information when the entrusted number of the functions in the preset file is greater than or equal to a preset threshold value so as to prompt developers to modify correspondingly, thereby improving the software quality.
The software project reconstruction device 20 of the second embodiment copies the original software project to the target path to obtain a new software project; extracting all folders in the new software project, and generating a hierarchical structure diagram of the folders; receiving a name modification command for a specified folder in the hierarchical structure diagram, modifying the name of the specified folder according to the name modification command, and modifying a packet path of a predetermined file under the specified folder according to the hierarchical structure diagram; parsing the predetermined file into an abstract syntax tree; traversing the abstract syntax tree to obtain all functions in the preset file, and detecting the entrusted quantity in all the functions; and if the entrusted quantity in all the functions is greater than or equal to a preset threshold value, sending out early warning information. The second embodiment realizes that a new software project is quickly constructed according to the original software project, improves the efficiency of software project reconstruction, and can detect software defects in the new software project, thereby improving the software quality.
In another embodiment, the software item reconstruction device 20 may further include: a second modification module, configured to determine whether an SQL (Structured Query Language) file of the new software item contains a self-defined class; and if the SQL file of the new software project comprises the custom class, correspondingly modifying the path of the custom class in the SQL file according to the modification of the specified folder.
In this embodiment, a class is an abstract data type. The classes include system-native classes and custom classes. The custom class is a class that is user-defined.
The second modification module determining whether a Structured Query Language (SQL) file of the new software item contains a custom class includes: acquiring SQL sentences in the SQL files; and judging whether the input parameters and the output parameters of the SQL statements contain the custom classes.
SQL statements are statements used to perform operations on a database, such as adding, deleting, modifying, querying, etc.
Preset keywords (such as "CREATE", "REPLACE", "select", "insert", "delete", "update", and the like) in the SQL file may be queried, and a statement including the preset keywords is identified as the SQL statement.
All the custom classes can be recorded in a preset file, whether the input parameters and the output parameters of the SQL statements are matched with the custom classes in the preset file or not is judged, and if the input parameters or the output parameters of the SQL statements are matched with the custom classes in the preset file, the input parameters and the output parameters of the SQL statements comprise the custom classes.
Whether the path of the self-defined class contains the specified folder or not can be judged, and if the path of the self-defined class contains the specified folder, the name of the specified folder in the path of the self-defined class is modified into the target name.
In another embodiment, the software item reconstruction device 20 may further include: a third modification module for receiving a data source modification command for the new software project; and modifying the data source information of the new software project according to the data source modification command.
In this embodiment, the data source information is stored in an XML (Extensible Markup Language) file. A bean tag with a preset tag name (e.g., bean id ═ dataSource ") can be extracted from the XML file, and the data source information is obtained according to the bean tag. Each bean label includes a label name and a label class. The label names are used for distinguishing different bean labels, and the function of positioning and searching is achieved. A label class (e.g., calls ═ com.
The data source information may represent different data sources, such as a DBCP data source, a C3P0 data source, or a JNDI data source.
A data source setting interface may be generated, target data source information set in the data source setting interface by a user is received, and the data source information is modified into the target data source information.
The data source information is related information of the database and is used for establishing connection with the database. The data source information may include a database user name, a database login password, a link string, a driver class, and the like. For example, the database username is denoted as "username", the database login password is denoted as "password", the driver class is denoted as "oracle. jdbc. driver. oracledriver", and the link string is denoted as "jdbc: oracle: thin: @127.0.0.1: DEV".
In another embodiment, the software item reconstruction device 20 may further include: and the verification module is used for compiling and packaging the new software project and verifying whether the compiled and packaged new software project can be normally started. And if the compiled and packaged new software project can be started normally, the new software project passes the verification. The new software project may be compiled, packaged using a management tool (e.g., meaven or ant), and it may be verified whether the compiled, packaged new software project can be started normally.
In a specific embodiment, the verifying whether the compiled and packaged new software project can be started normally includes: verifying whether the new software project can be normally connected with a database; and verifying whether the XML file of the new software item can be normally loaded.
EXAMPLE III
The present embodiment provides a computer storage medium having stored thereon a computer program that, when executed by a processor, implements the steps in the above-described software project reconfiguration method embodiments, such as steps S101-S106 shown in fig. 1:
s101, copying an original software project to a target path to obtain a new software project;
s102, extracting all folders in the new software project, and generating a hierarchical structure diagram of the folders;
s103, receiving a name modification command for a specified folder in the hierarchical structure diagram, modifying the name of the specified folder according to the name modification command, and modifying a package path of a predetermined file in the specified folder according to the hierarchical structure diagram;
s104, analyzing the preset file into an abstract syntax tree;
s105, traversing the abstract syntax tree to obtain all functions in the preset file, and detecting the entrusted quantity in all the functions;
and S106, if the entrusted number in all the functions is greater than or equal to a preset threshold value, sending out early warning information.
Alternatively, the computer program, when executed by the processor, implements the functions of the modules in the above device embodiments, such as the module 201 and 206 in fig. 2:
an obtaining module 201, configured to obtain a training sample set, where each training sample in the training sample set is an acceleration time sequence of walking of a user, and each training sample has a tag, and the tag marks an emotion category corresponding to the training sample;
an extracting module 202, configured to extract all folders in the new software project, and generate a hierarchical structure diagram of the folders;
a first modification module 203, configured to receive a name modification command for a specified folder in the hierarchical structure diagram, modify the name of the specified folder according to the name modification command, and modify a package path of a predetermined file in the specified folder according to the hierarchical structure diagram;
the parsing module 204 is configured to parse the predetermined file into an abstract syntax tree;
a detecting module 205, configured to traverse the abstract syntax tree to obtain all functions in the predetermined file, and detect the number of delegates in all the functions.
The early warning module 206 is configured to send out early warning information if the number of delegates in all the functions is greater than or equal to a preset threshold.
Example four
Fig. 3 is a schematic diagram of a computer device according to a fourth embodiment of the present invention. The computer arrangement 30 comprises a memory 301, a processor 302 and a computer program 303, such as a software item reconstruction program, stored in the memory 301 and executable on the processor 302. The processor 302, when executing the computer program 303, implements the steps in the above-described software item reconstruction method embodiments, such as the steps S101-S106 shown in fig. 1:
s101, copying an original software project to a target path to obtain a new software project;
s102, extracting all folders in the new software project, and generating a hierarchical structure diagram of the folders;
s103, receiving a name modification command for a specified folder in the hierarchical structure diagram, modifying the name of the specified folder according to the name modification command, and modifying a package path of a predetermined file in the specified folder according to the hierarchical structure diagram;
s104, analyzing the preset file into an abstract syntax tree;
s105, traversing the abstract syntax tree to obtain all functions in the preset file, and detecting the entrusted quantity in all the functions;
and S106, if the entrusted number in all the functions is greater than or equal to a preset threshold value, sending out early warning information.
Alternatively, the computer program, when executed by the processor, implements the functions of the modules in the above device embodiments, such as the module 201 and 206 in fig. 2:
an obtaining module 201, configured to obtain a training sample set, where each training sample in the training sample set is an acceleration time sequence of walking of a user, and each training sample has a tag, and the tag marks an emotion category corresponding to the training sample;
an extracting module 202, configured to extract all folders in the new software project, and generate a hierarchical structure diagram of the folders;
a first modification module 203, configured to receive a name modification command for a specified folder in the hierarchical structure diagram, modify the name of the specified folder according to the name modification command, and modify a package path of a predetermined file in the specified folder according to the hierarchical structure diagram;
the parsing module 204 is configured to parse the predetermined file into an abstract syntax tree;
a detecting module 205, configured to traverse the abstract syntax tree to obtain all functions in the predetermined file, and detect the number of delegates in all the functions.
The early warning module 206 is configured to send out early warning information if the number of delegates in all the functions is greater than or equal to a preset threshold.
Illustratively, the computer program 303 may be partitioned into one or more modules that are stored in the memory 301 and executed by the processor 302 to perform the present method. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 303 in the computer device 30. For example, the computer program 303 may be divided into the acquisition module 201, the extraction module 202, the first modification module 203, the analysis module 204, the detection module 205, and the early warning module 206 in fig. 2, and specific functions of each module are described in embodiment two.
The computer device 30 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. It will be understood by those skilled in the art that the schematic diagram 3 is merely an example of the computer apparatus 30, and does not constitute a limitation to the computer apparatus 30, and may include more or less components than those shown, or combine some components, or different components, for example, the computer apparatus 30 may further include an input and output device, a network access device, a bus, and the like.
The Processor 302 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor 302 may be any conventional processor or the like, the processor 302 being the control center of the computer device 30 and connecting the various parts of the overall computer device 30 using various interfaces and lines.
The memory 301 may be used to store the computer program 303, and the processor 302 may implement various functions of the computer device 30 by running or executing the computer program or module stored in the memory 301 and calling data stored in the memory 301. The memory 301 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data) created according to the use of the computer device 30, and the like. In addition, the memory 301 may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
The modules integrated by the computer device 30 may be stored in a computer-readable storage medium if they are implemented in the form of software functional modules and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer storage medium and used by a processor to implement the steps of the embodiments of the method. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware form, and can also be realized in a form of hardware and a software functional module.
The integrated module implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned. Furthermore, it is to be understood that the word "comprising" does not exclude other modules or steps, and the singular does not exclude the plural. A plurality of modules or means recited in the system claims may also be implemented by one module or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A method of reconstructing a software project, the method comprising:
copying the original software project to a target path to obtain a new software project;
extracting all folders in the new software project, and generating a hierarchical structure diagram of the folders;
receiving a name modification command for a specified folder in the hierarchical structure diagram, modifying the name of the specified folder according to the name modification command, and modifying a packet path of a predetermined file under the specified folder according to the hierarchical structure diagram;
parsing the predetermined file into an abstract syntax tree;
traversing the abstract syntax tree to obtain all functions in the preset file, and detecting the entrusted quantity in all the functions;
and if the entrusted quantity in all the functions is greater than or equal to a preset threshold value, sending out early warning information.
2. The method of claim 1, wherein receiving a name modification command for a specified folder in the hierarchy map, modifying the name of the specified folder according to the name modification command comprises:
generating a folder setting interface of the new software project according to the hierarchical structure diagram;
receiving a name modification instruction of a user to a specified folder in the hierarchical structure in the folder setting interface;
and modifying the name of the specified folder into a target name set by the user.
3. The method of claim 1, wherein the detecting the number of delegates in the all functions comprises:
detecting whether each function in all the functions calls other interfaces or classes;
and calculating the times of calling other interfaces or classes by all the functions.
4. The method of any one of claims 1-3, further comprising:
judging whether the SQL file of the new software item contains a self-defined class or not;
and if the SQL file of the new software project comprises the custom class, correspondingly modifying the path of the custom class in the SQL file according to the modification of the specified folder.
5. The method of claim 4, wherein said determining whether the SQL file of the new software item contains a custom class comprises:
acquiring SQL sentences in the SQL files;
and judging whether the input parameters and the output parameters of the SQL statements contain the custom classes.
6. The method of any one of claims 1-3, further comprising:
receiving a data source modification command for the new software project;
and modifying the data source information of the new software project according to the data source modification command.
7. The method of any one of claims 1-3, further comprising:
compiling and packaging the new software project;
and verifying whether the compiled and packaged new software project can be started normally.
8. An apparatus for reconstructing a software item, the apparatus comprising:
the acquisition module is used for copying the original software project to a target path to obtain a new software project;
the extraction module is used for extracting all folders in the new software project and generating a hierarchical structure diagram of the folders;
the first modification module is used for receiving a name modification command of a specified folder in the hierarchical structure diagram, modifying the name of the specified folder according to the name modification command, and modifying a packet path of a preset file under the specified folder according to the hierarchical structure diagram;
the analysis module is used for analyzing the preset file into an abstract syntax tree;
the detection module is used for traversing the abstract syntax tree to obtain all functions in the preset file and detecting the entrusted quantity in all the functions;
and the early warning module is used for sending out early warning information if the entrusted number in all the functions is greater than or equal to a preset threshold value.
9. A computer device, characterized by: the computer arrangement comprises a processor for executing a computer program stored in a memory for implementing the method of reconstructing a software item according to any of claims 1-7.
10. A computer storage medium having a computer program stored thereon, characterized in that: the computer program, when executed by a processor, implements a method of reconstructing a software project as claimed in any one of claims 1 to 7.
CN201910728484.4A 2019-08-08 2019-08-08 Software project reconstruction method and device, computer device and storage medium Pending CN110659063A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910728484.4A CN110659063A (en) 2019-08-08 2019-08-08 Software project reconstruction method and device, computer device and storage medium
PCT/CN2019/117238 WO2021022703A1 (en) 2019-08-08 2019-11-11 Software project reconstruction method and device, and computer device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910728484.4A CN110659063A (en) 2019-08-08 2019-08-08 Software project reconstruction method and device, computer device and storage medium

Publications (1)

Publication Number Publication Date
CN110659063A true CN110659063A (en) 2020-01-07

Family

ID=69036442

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910728484.4A Pending CN110659063A (en) 2019-08-08 2019-08-08 Software project reconstruction method and device, computer device and storage medium

Country Status (2)

Country Link
CN (1) CN110659063A (en)
WO (1) WO2021022703A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111984300A (en) * 2020-09-08 2020-11-24 网易(杭州)网络有限公司 Code copying method and device, electronic equipment and computer readable storage medium
CN112015431A (en) * 2020-08-27 2020-12-01 深圳忆联信息系统有限公司 Method and device for modifying firmware information by one key, computer equipment and storage medium

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113050935A (en) * 2021-03-17 2021-06-29 平安普惠企业管理有限公司 Method and device for generating mixed object, computing equipment and computer readable storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103559025A (en) * 2013-10-21 2014-02-05 沈阳建筑大学 Software refactoring method through clustering
CN103593182A (en) * 2013-10-27 2014-02-19 沈阳建筑大学 Method for reconfiguring software by using clustering mode
CN103645986A (en) * 2013-11-29 2014-03-19 北京广利核系统工程有限公司 Generation method and reconstruction method of visualization syntax tree of compiler
CN107678971A (en) * 2017-10-19 2018-02-09 扬州大学 The aacode defect Forecasting Methodology based on clone and coupling detection of code smell driving
CN107704278A (en) * 2016-08-08 2018-02-16 北京京东尚科信息技术有限公司 Application upgrade method and apparatus
CN109901873A (en) * 2019-02-26 2019-06-18 北京真知科技有限公司 Software function reconstructing method and device based on syntax tree

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070239762A1 (en) * 2006-03-30 2007-10-11 International Business Machines Corporation Automated interactive visual mapping utility and method for transformation and storage of XML data
CN108647010B (en) * 2018-04-27 2021-11-26 武汉斗鱼网络科技有限公司 Project engineering initialization method, terminal equipment and storage medium
CN109408057B (en) * 2018-10-23 2022-03-04 网易传媒科技(北京)有限公司 Method, device, medium and computing equipment for automatically generating codes
CN109885299B (en) * 2019-01-23 2024-05-03 平安科技(深圳)有限公司 Template processing method, device, computer equipment and storage medium in model development

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103559025A (en) * 2013-10-21 2014-02-05 沈阳建筑大学 Software refactoring method through clustering
CN103593182A (en) * 2013-10-27 2014-02-19 沈阳建筑大学 Method for reconfiguring software by using clustering mode
CN103645986A (en) * 2013-11-29 2014-03-19 北京广利核系统工程有限公司 Generation method and reconstruction method of visualization syntax tree of compiler
CN107704278A (en) * 2016-08-08 2018-02-16 北京京东尚科信息技术有限公司 Application upgrade method and apparatus
CN107678971A (en) * 2017-10-19 2018-02-09 扬州大学 The aacode defect Forecasting Methodology based on clone and coupling detection of code smell driving
CN109901873A (en) * 2019-02-26 2019-06-18 北京真知科技有限公司 Software function reconstructing method and device based on syntax tree

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
不详: ""IntelliJ IDEA重命名Package(包)", 《百度经验:HTTPS://JINGYAN.BAIDU.COM/ARTICLE/0A52E3F4ED1B59BF63ED727D.HTML》 *
朱同学: "[idea] idea中maven项目复制模块的步骤", 《CSDN:HTTPS://BLOG.CSDN.NET/A755199443/ARTICLE/DETAILS/93325908》 *
胡芸等: "嵌入式软件缺陷的自动定位技术实现", 《现代电子技术》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112015431A (en) * 2020-08-27 2020-12-01 深圳忆联信息系统有限公司 Method and device for modifying firmware information by one key, computer equipment and storage medium
CN112015431B (en) * 2020-08-27 2023-12-05 深圳忆联信息系统有限公司 Method, device, computer equipment and storage medium for modifying firmware information by one key
CN111984300A (en) * 2020-09-08 2020-11-24 网易(杭州)网络有限公司 Code copying method and device, electronic equipment and computer readable storage medium
CN111984300B (en) * 2020-09-08 2024-01-23 网易(杭州)网络有限公司 Code copying method and device, electronic equipment and computer readable storage medium

Also Published As

Publication number Publication date
WO2021022703A1 (en) 2021-02-11

Similar Documents

Publication Publication Date Title
Szárnyas et al. The Train Benchmark: cross-technology performance evaluation of continuous model queries
US10162612B2 (en) Method and apparatus for inventory analysis
EP3433732B1 (en) Converting visual diagrams into code
US20220413998A1 (en) Testing software and/or computing hardware design through test fragmentation into one or more discrete computing environments
CN109117164B (en) Micro-service updating method and system based on difference analysis of key elements
US10885087B2 (en) Cognitive automation tool
CN110659063A (en) Software project reconstruction method and device, computer device and storage medium
US7975247B2 (en) Method and system for organizing data generated by electronic design automation tools
US20160124795A1 (en) Evaluation method and apparatus
EP2951748A1 (en) Systems and methods for determining compatibility between software licenses
JP7119096B2 (en) license verification device
US10823782B2 (en) Ensuring completeness of interface signal checking in functional verification
CN108427580B (en) Configuration pair naming repetition detection method, storage medium and intelligent device
CN114138748A (en) Database mapping file generation method, device, equipment and storage medium
US11977473B2 (en) Providing a pseudo language for manipulating complex variables of an orchestration flow
CN109582347B (en) Method and device for acquiring front-end codes
CN109254774A (en) The management method and device of code in software development system
CN113608955B (en) Log recording method, device, equipment and storage medium
CN114968817A (en) Method, device, equipment and storage medium for evaluating code change influence range
CN115757174A (en) Database difference detection method and device
CN112699042B (en) Unit test case generation method and device
Dyer et al. Boa: An enabling language and infrastructure for ultra-large-scale msr studies
CN110737642B (en) Database information analysis method, database information analysis device, computer device and storage medium
Zhong et al. Burner: Recipe automatic generation for HPC container based on domain knowledge graph
CN114556238A (en) Method and system for generating digital representation of asset information in cloud computing environment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20200107

RJ01 Rejection of invention patent application after publication