CN112286557B - Method and device for updating code content in non-coverage mode - Google Patents

Method and device for updating code content in non-coverage mode Download PDF

Info

Publication number
CN112286557B
CN112286557B CN202011220746.5A CN202011220746A CN112286557B CN 112286557 B CN112286557 B CN 112286557B CN 202011220746 A CN202011220746 A CN 202011220746A CN 112286557 B CN112286557 B CN 112286557B
Authority
CN
China
Prior art keywords
modification
code
updated
type
code file
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.)
Active
Application number
CN202011220746.5A
Other languages
Chinese (zh)
Other versions
CN112286557A (en
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.)
Suzhou Dibo Information Technology Co ltd
Original Assignee
Suzhou Dibo Information Technology 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 Suzhou Dibo Information Technology Co ltd filed Critical Suzhou Dibo Information Technology Co ltd
Priority to CN202011220746.5A priority Critical patent/CN112286557B/en
Publication of CN112286557A publication Critical patent/CN112286557A/en
Application granted granted Critical
Publication of CN112286557B publication Critical patent/CN112286557B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Abstract

The invention provides a method and a device for updating code content in a non-coverage mode. The method comprises the following steps: obtaining attribute definition information of an object of a code file to be updated; obtaining a modification type and a modification field when the attribute definition information of the object is modified; generating a temporary new code file based on the modified object attribute definition information, the code generation tool and the code generation template; respectively obtaining grammar trees of a code to be updated and a temporary new code, extracting grammar tree nodes of a modification field of a deletion type from the grammar tree of the code to be updated, and extracting grammar tree nodes of modification fields of a new type and an update type from the grammar tree of the temporary new code; deleting the grammar tree nodes of the update type and the modification field of the deletion type from the grammar tree of the code to be updated, and adding the grammar tree nodes of the modification fields of the new addition and the update type extracted from the grammar tree of the temporary new code into the grammar tree of the code to be updated; the updated syntax tree is converted to code to update the code.

Description

Method and device for updating code content in non-coverage mode
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for updating code content in an uncovered mode.
Background
In the development process of a software program, a lot of repeated work is involved in writing the code, the repeated work of writing the code is a piece of tedious manual labor, and the generation of the code by means of a code generator is one of the effective modes which are commonly adopted in the industry for reducing the development intensity of the software, reducing the repeated writing of the code and improving the development efficiency. However, the existing code generator in the industry only has the code generating capability, which results in limited application range of the code generator, and the code generator is only suitable for the initial stage of starting a software project, namely unified code generation after the data structure is designed based on the existing requirements; for the middle and later stages of software project development, the requirement generates a changed scene, and since the code generator can only regenerate codes, when updating codes, the regenerated codes directly cover the old codes before, and the old codes which have been manually modified or newly added by a developer are included. This direct overlay type of regeneration of code can result in manual modification by the developer or new added content being overridden, which can result in a large number of BUGs being present and some functions not being able to function. Therefore, the code generation function of the code generator is not suitable for use in a scenario where a demand or a data structure in the software development process varies.
When the code is modified and updated due to the requirement or the change of the data structure in the software development process, the code is modified and updated completely manually by a software programmer, and the code is modified or updated with low accuracy and low working efficiency due to the large workload and easy error of the code modification.
Disclosure of Invention
It is an object of the present invention to provide a method and apparatus for non-overlapping updating of code content to ameliorate the above problems.
A first embodiment of the present invention provides a method of non-overlay updating of code content, comprising:
s1, obtaining attribute definition information of an object in a code file to be updated;
s2, when the obtained attribute definition information of the object is modified, obtaining a modification type and a corresponding modification field which are made to the current object, wherein the modification type comprises: new addition, update, and deletion;
s3, using the attribute definition information of the modified object as an input parameter, and using a code generation tool and a code generation template to generate a temporary new code file;
s4, respectively obtaining a grammar tree of a code file to be updated and a grammar tree of the temporary new code file, extracting grammar tree nodes corresponding to the modification field of the deletion type from the grammar tree of the code file to be updated, and extracting grammar tree nodes corresponding to the modification field of the new type and grammar tree nodes corresponding to the modification field of the update type from the grammar tree of the temporary new code file;
s5, deleting grammar tree nodes corresponding to the update type modification fields and grammar tree nodes corresponding to the deletion type modification fields from the grammar tree of the code file to be updated, and adding grammar tree nodes corresponding to the new type modification fields and grammar tree nodes corresponding to the update type modification fields extracted from the grammar tree of the temporary new code file into the grammar tree of the code file to be updated;
s6, converting the updated grammar tree of the code file to be updated into codes so as to update the codes to be updated.
Wherein: in step S1, attribute definition information of the object is obtained by reading the data source to which the code file to be updated is connected.
And converting the attribute definition information of the object into a JSON format before the obtained attribute definition information of the object is modified.
Wherein: the step of obtaining the type of modification made to the current object and the corresponding modification field comprises:
comparing the attribute definition information of the object before modification with the attribute definition information of the object after modification to obtain the modification type and the corresponding modification field of the current object; or (b)
The type of modification made by the record and the corresponding modification fields are directly monitored and recorded by the monitor record function.
A second embodiment of the present invention provides an apparatus for non-overlay updating of code content, comprising:
an object information acquisition module for acquiring attribute definition information of an object in a code file to be updated;
a modification content acquisition module for acquiring, when the acquired attribute definition information of the object is modified, a modification type and a corresponding modification field made to the current object, the modification type including: new addition, update, and deletion;
a code generation module for generating a temporary new code file using a code generation tool and a code generation template, using the modified attribute definition information of the object as an input parameter;
a grammar tree analysis module for respectively obtaining the grammar tree of the code file to be updated and the grammar tree of the temporary new code file;
the node extraction module is used for extracting grammar tree nodes corresponding to the modification fields of the deletion type from the grammar tree of the code file to be updated, and extracting grammar tree nodes corresponding to the modification fields of the new type and grammar tree nodes corresponding to the modification fields of the update type from the grammar tree of the temporary new code file;
a syntax tree merging module, configured to delete, from a syntax tree of the code file to be updated, a syntax tree node corresponding to the modification field of the update type and a syntax tree node corresponding to the modification field of the delete type, and add, in the syntax tree of the code file to be updated, a syntax tree node corresponding to the modification field of the add type and a syntax tree node corresponding to the modification field of the update type extracted from a syntax tree of the temporary new code file;
and the grammar tree conversion code module is used for converting the grammar tree of the updated code file to be updated into codes so as to update the codes to be updated.
Wherein: the object information acquisition module acquires the attribute definition information of the object by reading a data source connected with the code file to be updated.
The device also comprises a format conversion module which is used for converting the attribute definition information of the object into a JSON format before the obtained attribute definition information of the object is modified.
Wherein: the modified content acquisition module performs the following operations:
comparing the attribute definition information of the object before modification with the attribute definition information of the object after modification to obtain the modification type and the corresponding modification field of the current object; or alternatively
The type of modification made by the record and the corresponding modification fields are directly monitored and recorded by the monitor record function.
A third embodiment of the present invention provides a computer-readable storage medium on which a computer program that implements the method of the first embodiment and its preferred embodiments when executed by a processor is recorded.
A fourth embodiment of the present invention provides a computing device comprising a storage component and a processor, wherein the storage component has stored therein a set of computer-executable instructions that, when executed by the processor, cause the processor to perform the method of the first embodiment and its preferred embodiments.
According to the method and the device for updating the code content in the non-coverage mode, the novel method of analyzing the grammar tree of the code file to be updated and updating the grammar tree is adopted, and then the updated grammar tree is converted into the updated code content, so that the code content which is modified or added by a user can not be touched by a developer, and the code content can be reserved and not covered, namely, the code change information or the user-defined code information which is made by the developer in the previous version can be reserved and not covered or cleared, thereby realizing the non-coverage updating of the code content. Therefore, the method and the device for updating the code content without coverage can be used in a code generator, so that the code generator has the capability of providing the code without coverage, the code generator can be suitable for the whole period (the primary stage of new requirements and the middle and later stages of requirement change) of software project development, the code updating is automatically completed through the process, the development efficiency of software is improved, omission and mistakes caused by manual modification are avoided, and the code quality is improved.
Drawings
FIG. 1 is a flow chart of a method for updating code content without coverage provided by a first embodiment of the present invention;
FIG. 2 is a flow chart of a method for updating code content without coverage provided by a second embodiment of the present invention;
FIG. 3 is a schematic block diagram of an apparatus for non-overlay update code content provided by a third embodiment of the present invention;
fig. 4 is a schematic block diagram of a non-overlay update code content apparatus provided by a fourth embodiment of the present invention.
Detailed Description
The technical solutions proposed by the present invention will be clearly and completely described below with reference to specific embodiments and drawings, it being apparent that the described exemplary embodiments are only for illustrative purposes and not limiting.
Fig. 1 is a flowchart of a method for updating code content without coverage according to a first embodiment of the present invention. As shown in fig. 1, a method for updating code content without coverage according to a first embodiment of the present invention includes:
s1, obtaining attribute definition information of an object in a code file to be updated.
The code file to be updated is an old version code file with content to be updated. For example, older versions of code files that are to be modified for at least a portion of the code due to demand or data structure changes during software development.
The attribute definition information of the object in the code file to be updated may be obtained by reading a data source to which the code file to be updated is connected. A data source is where data is stored, such as a database, which is a source of data. Code normal operation is typically coupled to a data source, such as the code normal operation needs to be coupled to a database. The attribute definition information of the object is obtained by reading the save location of the attribute information of the object defined in the program code.
Different data sources have corresponding implementations. Taking a common relational database as an example, field definitions of objects (for the database, objects mapped with codes are data tables) can be obtained through query SQL of the database. For example, mySQL may get the field definition of the table by an SQL statement query of "SHOW FULL COLUMNS FROM table _name". The database query results are obtained at this time, as examples of the user table query results:
Field Type Null Key Default Extra Comment
Id bigint NO PMI auto_increment ID primary key
Realname varchar(100) NO Nickname
Age int NO Age of
S2, when the obtained attribute definition information of the object is modified, obtaining a modification type and a corresponding modification field which are made to the current object, wherein the modification type comprises: new addition, update, and deletion.
Here, the obtained attribute definition information of the object may be modified by a code generation tool, which may be any known code generator, a UI interface or command line for generating a code, or the like. The developer or the user of the code generation tool may use the code generation tool to modify the attribute definition information of the corresponding object based on the change in demand, so that the type of modification made to the current object and the corresponding modification field may be obtained. For example, based on the above example, according to a change in demand, a modification operation by a developer or a user of the code generation tool is as follows:
1 "Add type", modify field "birthdate", type is "Date", remark is "Date of birth";
1 update type, modification field "realname", remark is changed into "real name";
1 "delete type", modify field "age".
Examples of user table lookup results are as follows:
Field Type Null Key Default Extra Comment
id bigint NO PMI auto_increment ID primary key
realname varchar(100) NO Real name
birthdate Date NO Birth date
Furthermore, the step of obtaining the type of modification made to the current object and the corresponding modification field comprises:
comparing the attribute definition information of the object before modification with the attribute definition information of the object after modification to obtain the modification type and the corresponding modification field of the current object; or (b)
The type of modification made by the record is directly monitored and recorded by the monitor record function and the corresponding modification fields.
That is, the type of modification made to the current object and the corresponding modification field may be obtained in two ways. The first way is to compare the attribute definition information of the object before modification with the attribute definition information of the object after modification, so as to know which fields are modified and the type of modification, i.e. the new type, the update type or the delete type. The second way is to set a monitoring record function to directly monitor and record the modification actions made to the current object, i.e. directly monitor and record the type of modifications made and the corresponding modification fields.
S3, using the attribute definition information of the modified object as an input parameter, and generating a temporary new code file by using a code generation tool and a code generation template.
The code generation tool may be the same as the code generation tool described above. The code generation template may be a template of the code generation tool itself, or may be a custom template pre-written by a developer or user of the code generation tool using a template language such as Freemarker, velocity, thymeleaf, which is common in the industry.
S4, respectively obtaining an abstract syntax tree of the code file to be updated and an abstract syntax tree of the temporary new code file, extracting syntax tree nodes corresponding to the modification fields of the deletion type from the abstract syntax tree of the code file to be updated, and extracting syntax tree nodes corresponding to the modification fields of the new type and syntax tree nodes corresponding to the modification fields of the update type from the abstract syntax tree of the temporary new code file.
Syntax tree analysis engines such as a JavaParser and the like can be used for respectively carrying out syntax tree analysis on the code file to be updated and the temporary new code file to respectively obtain an abstract syntax tree of the code file to be updated and an abstract syntax tree of the temporary new code file, so that node definition information of a target field about the syntax tree can be obtained.
Taking javaParser as an example, this can be achieved by the following function:
CompilationUnit compilationUnit=StaticJavaParser.parse(code);
any type of node data may be obtained and the set of attribute definitions for all fields in the code may be obtained using the functions listed below.
List<FieldDeclaration>fieldDeclarationList=compilationUnit.findAll(Field Declaration.class)。
It will be appreciated by those skilled in the art that parsing a code file into a concrete syntax tree using a syntax tree parsing engine is also applicable herein and is not limited to abstract syntax trees.
Based on the field information obtained in step S2, the required syntax tree node definition information may be extracted from the abstract syntax tree of the temporary new code file. For example:
related attribute definition nodes and method definition nodes of the field birthdate are newly added;
the related attribute definition node and method definition node of the "update" field realname.
Syntax tree node definition information for the field to be deleted may also be extracted from the abstract syntax tree of the code file to be updated, for example:
the related attribute definition node and method definition node of the "delete" field age.
The above examples are only for illustrative purposes, and the requirements or the data structure changes in the software development process may be the same as the new type, the update type, and the delete type, or only some types may be present, for example, only the new type, the update type, or both the new type and the delete type, or both the new type and the update type, or both the update type and the delete type may be present, which may occur based on the actual requirements.
S5, deleting grammar tree nodes corresponding to the update type modification fields and grammar tree nodes corresponding to the deletion type modification fields from the abstract grammar tree of the code file to be updated, and adding grammar tree nodes corresponding to the new type modification fields and grammar tree nodes corresponding to the update type modification fields extracted from the abstract grammar tree of the temporary new code file into the abstract grammar tree of the code file to be updated.
Removing the relevant syntax tree node of the "delete" field (attribute definition node, method definition node, etc.) and the relevant syntax tree node of the "update" field (attribute definition node, method definition node, etc.) from the abstract syntax tree of the code file to be updated based on the syntax tree node information obtained in step S4, i.e., the syntax tree node corresponding to the delete type modification field in the abstract syntax tree of the code file to be updated, and the syntax tree node corresponding to the new type modification field and the syntax tree node corresponding to the update type modification field in the abstract syntax tree of the temporary new code file; relevant grammar tree nodes (attribute definition nodes, method definition nodes and the like) of a new field extracted from the abstract grammar tree of the temporary new code file and relevant grammar tree nodes (attribute definition nodes, method definition nodes and the like) of an updated field are respectively added in the abstract grammar tree of the code file to be updated. The specific operation method is well known to those skilled in the art, continuing to take the javaParser as an example, and the removal operation can be implemented through NodeList. The addition operation may be implemented through nodebist.
S6, converting the abstract syntax tree of the updated code file to be updated into codes so as to update the codes to be updated.
The corresponding operation of converting the updated abstract syntax tree into code content may be implemented using existing known methods. Continuing with the example of javaParser, converting the syntax tree into code content may be accomplished through compilationUnit.
The method of updating the code to be updated is usually to write new code content back to the code file to be updated, which can be implemented by a FileWriter object in e.g. the Java language or some encapsulation tool class such as fileutils.
Fig. 2 is a flowchart of a method for updating code content without coverage according to a second embodiment of the present invention. As shown in fig. 2, the method for updating code content without coverage provided by the second embodiment is that step S12 is added to the method provided by the first embodiment, that is, before the obtained attribute definition information of the object is modified, the attribute definition information of the object is converted into JSON format. The specific steps are as follows:
s1, obtaining attribute definition information of an object in a code file to be updated;
s12, converting the attribute definition information of the object into a JSON format;
s2, when the obtained attribute definition information of the object is modified, obtaining a modification type and a corresponding modification field which are made to the current object, wherein the modification type comprises: new addition, update, and deletion;
s3, using the attribute definition information of the modified object as an input parameter, and using a code generation tool and a code generation template to generate a temporary new code file;
s4, respectively obtaining an abstract syntax tree of a code file to be updated and an abstract syntax tree of the temporary new code file, extracting syntax tree nodes corresponding to the modification fields of the deletion type from the abstract syntax tree of the code file to be updated, and extracting syntax tree nodes corresponding to the modification fields of the new type and syntax tree nodes corresponding to the modification fields of the update type from the abstract syntax tree of the temporary new code file;
s5, deleting grammar tree nodes corresponding to the update type modification fields and grammar tree nodes corresponding to the deletion type modification fields from the abstract grammar tree of the code file to be updated, and adding grammar tree nodes corresponding to the new type modification fields and grammar tree nodes corresponding to the update type modification fields extracted from the abstract grammar tree of the temporary new code file into the abstract grammar tree of the code file to be updated;
s6, converting the abstract syntax tree of the updated code file to be updated into codes so as to update the codes to be updated.
Step S12 is illustrated. Examples of JSON data are as follows:
continuing with the example, in step S2, after the obtained attribute definition information of the object is modified, the new JSON data is:
continuing with this example, a custom example of the code generation template mentioned in step S3 is given here:
in addition, the explanation of the respective steps of the first embodiment also applies to the respective steps of the second embodiment, and the examples given for the second embodiment also apply to the first embodiment.
Although it is described in the first and second embodiments that the code file is parsed into abstract syntax trees using the syntax tree parsing engine, it is also applicable here to parse the code file into specific syntax trees.
Based on the first embodiment and the second embodiment, the invention adopts a novel method of analyzing and updating the abstract syntax tree of the code file to be updated and then converting the updated syntax tree into the updated code content, so that the code content which is manually modified or added by a user can not be touched by a developer, and can be reserved and not covered, namely, the code change information which is manually executed by the developer in the previous version or the code information which is user-defined can be reserved and not covered or cleared, thereby realizing the non-covered update of the code content, enabling a code generator to be suitable for the whole period (the primary stage of new requirement and the middle-late stage of requirement change) of software project development, automatically completing the code update through the process, thereby improving the development efficiency of the software, avoiding omission and error caused by manual modification and improving the code quality.
The following continues to illustrate the beneficial effects of the technical solution provided by the present invention by means of a specific routine.
Assume that the code content to be updated is as follows:
using the prior art overlay code update method, the developer manually adds the code content: private static String STATUS _a= "incumbent"; and
private String getStatus(){
…}
will be cleared by the overlay.
By using the method for updating the code content in a non-coverage manner, which is provided by the invention, the updated code content is as follows:
it follows that the developer manually adds the code content: private static String STATUS _a= "incumbent"; and
private String getStatus(){
…}
can be preserved and not covered or cleared.
Fig. 3 is a schematic block diagram of a non-overlay update code content apparatus provided by a third embodiment of the present invention. As shown in fig. 3, an apparatus for updating code content without coverage according to a third embodiment of the present invention includes:
an object information acquisition module 1 for acquiring attribute definition information of an object in a code file to be updated;
a modification content acquisition module 2 for acquiring, when the acquired attribute definition information of the object is modified, a modification type and a corresponding modification field made to the current object, the modification type including: new addition, update, and deletion;
a code generation module 3 for generating a temporary new code file using a code generation tool and a code generation template, using the attribute definition information of the modified object as an input parameter;
a syntax tree parsing module 4, configured to obtain an abstract syntax tree of a code file to be updated and an abstract syntax tree of the temporary new code file, respectively;
a node extraction module 5, configured to extract, from the abstract syntax tree of the code file to be updated, a syntax tree node corresponding to the modification field of the deletion type, and extract, from the abstract syntax tree of the temporary new code file, a syntax tree node corresponding to the modification field of the new type and a syntax tree node corresponding to the modification field of the update type;
a syntax tree merging module 6, configured to delete, from an abstract syntax tree of the code file to be updated, a syntax tree node corresponding to the modification field of the update type and a syntax tree node corresponding to the modification field of the delete type, and add, in the abstract syntax tree of the code file to be updated, a syntax tree node corresponding to the modification field of the new type and a syntax tree node corresponding to the modification field of the update type, which are extracted from an abstract syntax tree of the temporary new code file;
and a syntax tree conversion code module 7 for converting the abstract syntax tree of the updated code file to be updated into code so as to update the code to be updated.
Wherein: the object information acquisition module acquires the attribute definition information of the object by reading a data source connected with the code file to be updated.
Wherein: the modified content acquisition module performs the following operations:
comparing the attribute definition information of the object before modification with the attribute definition information of the object after modification to obtain the modification type and the corresponding modification field of the current object; or alternatively
The type of modification made by the record and the corresponding modification fields are directly monitored and recorded by the monitor record function.
Fig. 4 is a schematic block diagram of a non-overlay update code content apparatus provided by a fourth embodiment of the present invention. As shown in fig. 4, the non-overlay update code content apparatus further includes a format conversion module 11 for converting the attribute definition information of the object into JSON format before the obtained attribute definition information of the object is modified.
It will be clear to a person skilled in the art that for convenience and brevity of description, reference may be made to the corresponding procedure in the first embodiment, and the examples and related descriptions listed in the first embodiment and the corresponding preferred embodiments are equally applicable to explaining the procedure of the apparatus described in the third embodiment, and the description is not repeated here.
Likewise, the specific operation of the apparatus described in the fourth embodiment may refer to the corresponding operation in the second embodiment, and the examples and the related descriptions listed in the second embodiment and the corresponding preferred embodiments are also applicable to explaining the operation of the apparatus described in the fourth embodiment, and will not be repeated here.
Based on the third embodiment and the fourth embodiment, the non-coverage type updating code content device provided by the invention adopts a novel method of analyzing and updating the abstract syntax tree of the code file to be updated and converting the updated syntax tree into the updated code content, so that the code content which is modified or added by a developer in a self-definition way is not touched, namely, the code change information or the self-definition code information which is made by the developer in the previous version can be reserved and not covered or cleared, thereby realizing the non-coverage type updating of the code content, enabling a code generator to be suitable for the whole period (the primary stage of new requirement and the middle and later stages of requirement change) of software project development, automatically completing the code updating through the flow, thereby improving the development efficiency of software, avoiding omission and mistakes caused by man-made modification and improving the code quality.
Methods and apparatuses for non-overlapping updating of code content according to exemplary embodiments of the present application have been described above with reference to fig. 1 through 4. However, it should be understood that: the apparatus shown in fig. 3 and 4 and its unit modules may be configured as software, hardware, firmware, or any combination thereof, respectively, that performs a specific function. For example, these means or unit modules may correspond to application specific integrated circuits, to pure software code, or to modules of a combination of software and hardware. Furthermore, one or more functions implemented by these means or unit modules may also be uniformly performed by components in a physical entity device (e.g., a processor, a client, a server, or the like).
Further, the above-described method of updating code content non-overlaid may be implemented by a program recorded on a computer readable medium, for example, according to an exemplary embodiment of the present application, a computer readable storage medium may be provided, on which a computer program implementing the method according to the first embodiment or a combination of the methods with the respective preferred embodiments when executed by a processor is recorded. In addition, a computer-readable storage medium may be provided, on which a computer program implementing the method according to the second embodiment or a combination of the methods with the respective preferred embodiments is recorded when being executed by a processor.
The computer program in the above-described computer-readable storage medium may be run in an environment deployed in a computer device such as a client, a host, a proxy device, a server, etc., and it should be noted that the computer program may also be used to perform additional steps other than the above-described steps or to perform more specific processes when the above-described steps are performed, and the contents of these additional steps and further processes have been mentioned in the description of the related methods with reference to fig. 1 and 2, so that a repetition will not be repeated here.
In addition, the method for updating the code content in a non-coverage manner can be realized by a program recorded on a computing device. The computing device comprising a storage means and a processor, the storage means having stored therein a set of computer executable instructions which, when executed by the processor, perform the method steps as described in the first embodiment or a combination thereof with the respective preferred embodiments; or performing the method steps as described in the second embodiment or a combination thereof with the respective preferred embodiment.
In particular, the computing devices may be deployed in servers or clients, as well as on node devices in a distributed network environment. Further, the computing device may be a PC computer, tablet device, personal digital assistant, smart phone, web application, or other device capable of executing the above-described set of instructions.
Here, the computing device need not be a single computing device, but may be any device or collection of circuits capable of executing the above-described instructions (or instruction set) alone or in combination. The computing device may also be part of an integrated control system or system manager, or may be configured as a portable electronic device that interfaces with locally or remotely (e.g., via wireless transmission).
In the computing device, the processor may include a Central Processing Unit (CPU), a Graphics Processor (GPU), a programmable logic device, a special purpose processor system, a microcontroller, or a microprocessor. By way of example, and not limitation, processors may also include analog processors, digital processors, microprocessors, multi-core processors, processor arrays, network processors, and the like.
Some operations described in the method according to the exemplary embodiment of the present application may be implemented in software, some operations may be implemented in hardware, and furthermore, the operations may be implemented in a combination of software and hardware.
The processor may execute instructions or code stored in one of the storage components, wherein the storage component may also store data. Instructions and data may also be transmitted and received over a network via a network interface device, which may employ any known transmission protocol.
The memory component may be integrated with the processor, for example, RAM or flash memory disposed within an integrated circuit microprocessor or the like. Further, the storage component may comprise a stand-alone device, such as an external disk drive, a storage array, or any other storage device usable by a database system. The storage component and the processor may be operatively coupled or may communicate with each other, such as through an I/O port, network connection, etc., such that the processor is able to read files stored in the storage component.
In addition, the computing device may also include a video display (such as a liquid crystal display) and a user interaction interface (such as a keyboard, mouse, touch input device, etc.). All components of the computing device may be connected to each other via buses and/or networks.
Operations involved in methods according to exemplary embodiments of the present application may be described as various interconnected or coupled functional blocks or functional diagrams. However, these functional blocks or functional diagrams may be equally integrated into a single logic device or operate at non-exact boundaries.
While exemplary embodiments of the present application are described above, it should be understood that: the above description is illustrative only and is not exhaustive. The present application is not limited to the exemplary embodiments disclosed and many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the present application. The scope of the application should, therefore, be determined with reference to the appended claims.

Claims (10)

1. A method of non-overlaid updating code content, comprising:
s1, obtaining attribute definition information of an object in a code file to be updated;
s2, when the obtained attribute definition information of the object is modified, obtaining a modification type and a corresponding modification field which are made to the current object, wherein the modification type comprises: new addition, update, and deletion;
s3, using the attribute definition information of the modified object as an input parameter, and using a code generation tool and a code generation template to generate a temporary new code file;
s4, respectively obtaining a grammar tree of a code file to be updated and a grammar tree of the temporary new code file, extracting grammar tree nodes corresponding to the modification field of the deletion type from the grammar tree of the code file to be updated, and extracting grammar tree nodes corresponding to the modification field of the new type and grammar tree nodes corresponding to the modification field of the update type from the grammar tree of the temporary new code file;
s5, deleting grammar tree nodes corresponding to the update type modification fields and grammar tree nodes corresponding to the deletion type modification fields from the grammar tree of the code file to be updated, and adding grammar tree nodes corresponding to the new type modification fields and grammar tree nodes corresponding to the update type modification fields extracted from the grammar tree of the temporary new code file into the grammar tree of the code file to be updated;
s6, converting the updated grammar tree of the code file to be updated into codes so as to update the codes to be updated.
2. The method according to claim 1, wherein: in step S1, attribute definition information of the object is obtained by reading the data source to which the code file to be updated is connected.
3. The method of claim 1, wherein the obtained attribute definition information of the object is converted into JSON format before being modified.
4. The method according to claim 1, wherein: the step of obtaining the type of modification made to the current object and the corresponding modification field comprises:
comparing the attribute definition information of the object before modification with the attribute definition information of the object after modification to obtain the modification type and the corresponding modification field of the current object; or (b)
The type of modification made by the record and the corresponding modification fields are directly monitored and recorded by the monitor record function.
5. An apparatus for non-overlaid updating of code content, comprising:
an object information acquisition module for acquiring attribute definition information of an object in a code file to be updated;
a modification content acquisition module for acquiring, when the acquired attribute definition information of the object is modified, a modification type and a corresponding modification field made to the current object, the modification type including: new addition, update, and deletion;
a code generation module for generating a temporary new code file using a code generation tool and a code generation template, using the modified attribute definition information of the object as an input parameter;
a grammar tree analysis module for respectively obtaining the grammar tree of the code file to be updated and the grammar tree of the temporary new code file;
the node extraction module is used for extracting grammar tree nodes corresponding to the modification fields of the deletion type from the grammar tree of the code file to be updated, and extracting grammar tree nodes corresponding to the modification fields of the new type and grammar tree nodes corresponding to the modification fields of the update type from the grammar tree of the temporary new code file;
a syntax tree merging module, configured to delete, from a syntax tree of the code file to be updated, a syntax tree node corresponding to the modification field of the update type and a syntax tree node corresponding to the modification field of the delete type, and add, in the syntax tree of the code file to be updated, a syntax tree node corresponding to the modification field of the add type and a syntax tree node corresponding to the modification field of the update type extracted from a syntax tree of the temporary new code file;
and the grammar tree conversion code module is used for converting the grammar tree of the updated code file to be updated into codes so as to update the codes to be updated.
6. The apparatus of claim 5, wherein: the object information acquisition module acquires the attribute definition information of the object by reading a data source connected with the code file to be updated.
7. The apparatus of claim 5, further comprising a format conversion module for converting the attribute definition information of the object into JSON format before the obtained attribute definition information of the object is modified.
8. The apparatus of claim 5, wherein: the modified content acquisition module performs the following operations:
comparing the attribute definition information of the object before modification with the attribute definition information of the object after modification to obtain the modification type and the corresponding modification field of the current object; or alternatively
The type of modification made by the record and the corresponding modification fields are directly monitored and recorded by the monitor record function.
9. A computer readable storage medium having recorded thereon a computer program which, when executed by a processor, implements the method of any of claims 1 to 4.
10. A computing device comprising a storage component and a processor, wherein the storage component has stored therein a set of computer-executable instructions that, when executed by the processor, cause the processor to perform the method of any of claims 1-4.
CN202011220746.5A 2020-11-05 2020-11-05 Method and device for updating code content in non-coverage mode Active CN112286557B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011220746.5A CN112286557B (en) 2020-11-05 2020-11-05 Method and device for updating code content in non-coverage mode

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011220746.5A CN112286557B (en) 2020-11-05 2020-11-05 Method and device for updating code content in non-coverage mode

Publications (2)

Publication Number Publication Date
CN112286557A CN112286557A (en) 2021-01-29
CN112286557B true CN112286557B (en) 2024-03-22

Family

ID=74351489

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011220746.5A Active CN112286557B (en) 2020-11-05 2020-11-05 Method and device for updating code content in non-coverage mode

Country Status (1)

Country Link
CN (1) CN112286557B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113110832A (en) * 2021-04-08 2021-07-13 北京联创新天科技有限公司 Intelligent efficient code generation method and device and storage medium
CN114168119B (en) * 2021-12-07 2024-04-05 北京百度网讯科技有限公司 Code file editing method, device, electronic equipment and storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU2001294531A1 (en) * 2000-09-25 2002-04-08 Acuabiotec Llc Method, system and computer program product for technical management and biocontrol of disease in animal production systems
CN103645986A (en) * 2013-11-29 2014-03-19 北京广利核系统工程有限公司 Generation method and reconstruction method of visualization syntax tree of compiler
CN104657140A (en) * 2015-02-10 2015-05-27 广州华多网络科技有限公司 Code generating method and device
CN107015813A (en) * 2017-04-19 2017-08-04 网易(杭州)网络有限公司 Method, device and electronic equipment that code is repaired
CN107402746A (en) * 2016-05-20 2017-11-28 阿里巴巴集团控股有限公司 A kind of method and device of automatic code generating file
CN109032662A (en) * 2018-06-19 2018-12-18 上海陆家嘴国际金融资产交易市场股份有限公司 Code file generation method, device, computer equipment and storage medium
CN111142862A (en) * 2019-11-20 2020-05-12 苏州帝博信息技术有限公司 System and method for automatically generating code
CN111209022A (en) * 2020-01-03 2020-05-29 支付宝(杭州)信息技术有限公司 Resource publishing and acquiring method, device and equipment
CN111625230A (en) * 2020-05-19 2020-09-04 北京计算机技术及应用研究所 System for unifying front-end JavaScript coding specifications

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9317408B2 (en) * 2011-12-15 2016-04-19 The Mathworks, Inc. System and method for systematic error injection in generated code

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU2001294531A1 (en) * 2000-09-25 2002-04-08 Acuabiotec Llc Method, system and computer program product for technical management and biocontrol of disease in animal production systems
CN103645986A (en) * 2013-11-29 2014-03-19 北京广利核系统工程有限公司 Generation method and reconstruction method of visualization syntax tree of compiler
CN104657140A (en) * 2015-02-10 2015-05-27 广州华多网络科技有限公司 Code generating method and device
CN107402746A (en) * 2016-05-20 2017-11-28 阿里巴巴集团控股有限公司 A kind of method and device of automatic code generating file
CN107015813A (en) * 2017-04-19 2017-08-04 网易(杭州)网络有限公司 Method, device and electronic equipment that code is repaired
CN109032662A (en) * 2018-06-19 2018-12-18 上海陆家嘴国际金融资产交易市场股份有限公司 Code file generation method, device, computer equipment and storage medium
CN111142862A (en) * 2019-11-20 2020-05-12 苏州帝博信息技术有限公司 System and method for automatically generating code
CN111209022A (en) * 2020-01-03 2020-05-29 支付宝(杭州)信息技术有限公司 Resource publishing and acquiring method, device and equipment
CN111625230A (en) * 2020-05-19 2020-09-04 北京计算机技术及应用研究所 System for unifying front-end JavaScript coding specifications

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Common Statement Kind Changes to Inform Automatic Program Repair;Mauricio Soto等;《2018 IEEE/ACM 15th International Conference on Mining Software Repositories (MSR)》;20181230;第102 - 105页 *
一种融合代码依赖关系的基于信息检索的需求更新方法;聂佳;《cnki优秀硕士学位论文全文库 信息科技辑》;20190415(第04期);第I138-1180页 *

Also Published As

Publication number Publication date
CN112286557A (en) 2021-01-29

Similar Documents

Publication Publication Date Title
US9646041B2 (en) Testing of inactive design-time artifacts
US9659012B2 (en) Debugging framework for distributed ETL process with multi-language support
US8321450B2 (en) Standardized database connectivity support for an event processing server in an embedded context
US9009183B2 (en) Transformation of a system change set from machine-consumable form to a form that is readily consumable by a human
CN112286557B (en) Method and device for updating code content in non-coverage mode
CN111414350B (en) Service generation method and device
US8918766B2 (en) Analysis of propagated information using annotated forests
US20120323940A1 (en) Selection mapping between fetched files and source files
EP3279816A1 (en) Data analysis processing method, apparatus, computer device, and storage medium
US20200026790A1 (en) Generation and graphical display of data transform provenance metadata
CN104598570A (en) Resource fetching method and device
JP2018060570A (en) Reference data segmentation from single to multiple tables
CN111177113A (en) Data migration method and device, computer equipment and storage medium
CN114036183A (en) Data ETL processing method, device, equipment and medium
WO2023103432A1 (en) Code file editing method and apparatus, electronic device, and storage medium
US9785659B2 (en) Protecting storage data during system migration
CN115544089A (en) Data processing method, device, equipment and storage medium
US11681721B2 (en) Systems and methods for spark lineage data capture
CN115295109A (en) Medical data tracing method and device, storage medium and terminal equipment
WO2021259290A1 (en) Stored procedure conversion method and apparatus, and device and storage medium
US10853366B2 (en) Cooperative expression visitors
US9916154B2 (en) File-based transport of table content
US11521089B2 (en) In-database predictive pipeline incremental engine
CN112685435A (en) Table query method and system based on Vue and Mybatis
CN107506299B (en) Code analysis method and terminal equipment

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
GR01 Patent grant
GR01 Patent grant