WO2021037050A1 - 一种代码变更方法及装置 - Google Patents
一种代码变更方法及装置 Download PDFInfo
- Publication number
- WO2021037050A1 WO2021037050A1 PCT/CN2020/111326 CN2020111326W WO2021037050A1 WO 2021037050 A1 WO2021037050 A1 WO 2021037050A1 CN 2020111326 W CN2020111326 W CN 2020111326W WO 2021037050 A1 WO2021037050 A1 WO 2021037050A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- changer
- change
- software code
- changed
- changers
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/72—Code refactoring
Definitions
- This application relates to the field of computer technology, and in particular to a code modification method and device.
- the current method of changing software code only supports a single change, that is, when changing the software code, only one type of change can be made. At present, there is no change method that can make multiple types of changes to the software code at the same time.
- the present application provides a code modification method to provide an efficient modification method for simultaneously making multiple types of changes to the software code.
- the present application provides a code modification method, which can be executed by a modification device, and the modification device can obtain the software code input by the user and the modification configuration information of the software code, wherein the modification configuration information includes the to-be-changed configuration information.
- the changing device can select multiple changers to be called from the saved changers according to the change configuration information, and determine the calling sequence of the multiple changers.
- the changing device can sequentially call the multiple changers according to the calling sequence to change the software code, wherein each changer can change a kind of code element to be changed in the software code, and the first of the multiple changers
- the input of a called changer is the software code, and the software code changed by the first called changer is input to another changer of the plurality of changers.
- the change device can flexibly call multiple different changers according to the needs of the user, and can make multiple different changes to the software code at the same time.
- the change device when the change device first determines whether there is a conflicting changer among the selected multiple changers, the conflicting changer means that one of the changers makes the change first, causing the subsequent changer to make the change
- the change device can adopt a parallel change mode, call the multiple changers at the same time to change the software code, and then merge the changed content of each changer.
- the change device determines that the multiple changers adopt a serial change mode or a partial serial and partial parallel change mode to change the software code.
- the change device can flexibly select different change modes to change the software code, so that the selected change mode is more suitable for the software code, and the change method is more efficient.
- the change device calls the multiple changers in sequence according to the calling sequence of the multiple changers, and the software
- the direct change content can be applied to the software code input to the at least one changer; the delayed change content is called to the last changer in the plurality of changers. After application.
- attributes can also be set for each changer, and the attributes of the changer are used to describe whether the changer keeps or deletes changes to some lines in the software code.
- the change device when calling each changer, the change device distinguishes the direct change content of each changer's change content and the delayed change content that may have change conflicts, and unifies the delayed change content generated by multiple changers at the end. Applied to the software code, it can effectively avoid conflicts caused by different changers directly making changes during the invocation process.
- the change device may determine the attributes of each changer based on the calling sequence of the multiple changers before calling the multiple changers in turn, and the attributes of each changer are used for Describe each changer's handling of changes to the target line in the software code.
- the change device may also not determine the attributes of each changer.
- the change device can set attributes for the changer, so that when the changer is subsequently called, it can more accurately determine whether the changes to some target lines in the software code are retained or deleted.
- the change configuration information may further include the attribute of each changer, and the attribute of each changer is used to describe the processing of each changer to change the target line in the software code.
- the user can configure the attributes of the changer by himself, giving the user more initiative, which is conducive to improving the flexibility of software code changes.
- the change device may directly determine the direct change content of the at least one changer based on the change operation of the at least one changer. It is also possible to determine the direct change content of the at least one changer based on the attribute of the at least one changer.
- the change device can more accurately determine whether the changes to some target lines in the software code are retained or deleted based on the attributes of the changer, and further determine the direct change content of the changer.
- the change device determines the direct change content of at least one changer based on the attribute of the at least one changer, it needs to determine the first attribute of the at least one changer, such as merging the change attribute and overwriting the change attribute.
- the first attribute describes that at least one changer keeps or deletes the change to the first target line of the software code, and the first target behavior is the same line or more changes made to the software code by the at least one changer and the at least one changer previously called by the changer. Row.
- the change that needs to be retained by the at least one changer is determined, and then the direct change content of the at least one changer is determined.
- the change device can conveniently determine the change that needs to be deleted or retained based on the attribute of the changer, and can then determine the final actual direct change content.
- the changing device when the changing device determines the direct change content of the at least one changer based on the attribute of the at least one changer, it may determine the direct change content of the at least one changer only based on the first attribute of the at least one changer .
- the direct change content of the at least one changer can also be determined by referring to the first attribute and the second attribute of the at least one changer, or the direct change content of the at least one changer can be determined only based on the second attribute of the at least one changer ,
- the second attribute of at least one changer (such as ignore change attribute) describes that at least one changer keeps or deletes changes to the second target line of the software code, and the second target line is at least one changer and at least one changer before A different line or multiple lines of software code changed by the called changer.
- the change device can conveniently determine the change that needs to be deleted or retained based on the attribute of the changer, and can then determine the final actual direct change content.
- one or more delayed change content can be preset, based on the preset delay
- the change content determines the delayed change content from the change content when the changer executes the change on the software code input to the changer.
- the change device can determine the delayed change content based on the preset information, and can quickly determine the delayed change content that needs to be retained until the last change is made.
- the change device when the change device calls the first changer, the first called changer can analyze the software code and generate an analysis result.
- the analysis result can include the existing software code
- the change device can save the analysis result, so that when other changers are subsequently called, other changers can call the analysis result to change the software code input to other changers.
- the analysis operation of the software code only needs to be performed once, and the subsequent changer only needs to call the analysis result generated by the previous changer without repeated analysis, which can effectively save time and improve the efficiency of software code change.
- the change device after the change device changes the software code, it can also display the final changed software code, and display the change location and content of the software code changes made by multiple changers.
- the change device can display the changed software code more intuitively, and can also display the changes made, which is convenient for users to view.
- the embodiments of the present application also provide a modification device, and the beneficial effects can be referred to the description of the first aspect and will not be repeated here.
- the device has the function of realizing the behavior in the method example of the first aspect described above.
- the function can be realized by hardware, or by hardware executing corresponding software.
- the hardware or software includes one or more modules corresponding to the above-mentioned functions.
- the structure of the device includes an import module, a configuration module, a changer library, and a change module. These modules can perform the corresponding functions in the method example of the first aspect. For details, please refer to the detailed description in the method example. , Do not repeat it here.
- an embodiment of the present application also provides a computing device.
- the computing device includes a processor and a memory, and may also include a communication interface.
- Optional also includes a display screen.
- the processor executes the program instructions in the memory to execute the foregoing first aspect or the method provided in any possible implementation manner of the first aspect.
- the memory is coupled with the processor, and it stores program instructions and data necessary in the process of determining the traffic flow.
- the communication interface is used to communicate with other devices, such as receiving software codes and changing configuration information.
- the display screen is used to display information to the user under the trigger of the processor.
- the present application provides a computing device cluster, which includes at least one computing device.
- Each computing device includes a memory and a processor.
- the processor of at least one computing device is configured to access the code in the memory to execute the first aspect or the method provided in any one of the possible implementation manners of the first aspect.
- the present application provides a non-transitory readable storage medium.
- the non-transitory readable storage medium executes the foregoing first aspect or any of the first aspects.
- the storage medium stores the program.
- the storage medium includes, but is not limited to, volatile memory, such as random access memory, non-volatile memory, such as flash memory, hard disk drive (HDD), and solid state drive (SSD).
- the present application provides a computer program product.
- the computer program product includes computer instructions. When executed by a computing device, the computing device executes the foregoing first aspect or any possible implementation of the first aspect Provided method.
- the computer program product may be a software installation package. In the case where the method provided in the foregoing first aspect or any possible implementation of the first aspect needs to be used, the computer program product may be downloaded and executed on a computing device. Program product.
- the present application also provides a computer chip, which is connected to a memory, and the chip is used to read and execute a software program stored in the memory, and execute the aforementioned first aspect or any possible implementation of the first aspect. method.
- FIG. 1A is a schematic diagram of a relationship between code elements provided by this application.
- FIG. 1B is a schematic diagram of a partial serial and partial parallel mode provided by this application.
- FIG. 1C is a schematic diagram of another partial serial and partial parallel mode provided by this application.
- FIG. 2A is a schematic structural diagram of a modification device provided by this application.
- FIG. 2B is a schematic structural diagram of a computing device cluster provided by this application.
- FIG. 2C is a schematic diagram of a system architecture provided by this application.
- Figure 3 is a schematic diagram of a method for supporting multiple changes of software code changes provided by this application.
- FIG. 4 is a schematic diagram of a display interface that prompts the user to input the software code to be changed provided by this application;
- FIG. 5 is a schematic diagram of a method for changing the software code to be changed by the change module 140 in the serial change mode provided by this application;
- FIG. 6 is a schematic diagram of the process of changing the software code to be changed by the change module 140 in the serial change mode provided by this application;
- FIG. 7 is a schematic diagram of a set of intermediate change instances for generating a changer provided by this application.
- FIG. 8 is a schematic diagram of an intermediate change instance set of an update changer provided by this application.
- FIG. 9 is a schematic diagram of an interface for displaying the changed software code provided by this application.
- FIG. 10 is a schematic diagram of another interface for displaying the changed software code provided by this application.
- the software code is written by the programmer using the language supported by the development tool.
- the software code is composed of a set of numbers or letters with directional meaning.
- the software code includes multiple lines of code, each line is set with a line number, and the line of code is identified by the line number.
- the software code cannot be directly executed on the computer.
- the build system needs to call a compiler according to the configuration information recorded in the build file to convert the software code into a binary code that can be recognized by the machine.
- the binary code is also called executable code.
- a library is a collection of callable codes used to write software codes.
- the library includes multiple fixed-configuration codes, and the codes in the library can be directly called when writing software programs.
- the library can be provided by a third party and embedded in the software code by reference (calling) to improve code reuse and development efficiency.
- a build system is a tool used to generate machine-recognized executable programs from software code.
- the build system needs to know some configuration information, such as the location of the toolchain component, the location of the software code, library dependencies, the location of the library, the version of the library, etc. This configuration information is usually recorded in a build file that can be read by the build system.
- the software code needs to meet certain writing specifications during the writing process, such as object-oriented programming (OOP), procedure-oriented programming (POP) and so on.
- object-oriented programming OOP
- procedure-oriented programming POP
- the programming languages for object-oriented programming include C++, Java, C#, etc.
- the programming languages for procedural programming include fortran, C, etc.
- the software code written with a certain writing specification can include code elements such as classes, packages, functions/methods, domains/variables, etc.
- code elements such as classes, packages, functions/methods, domains/variables, etc.
- the package can include one or more classes, each class can include internal classes, functions/methods; functions/methods can call domains/variables.
- Inner classes are similar to classes, and functions/methods can also be included in inner classes.
- Class is a construction of object-oriented computer programming language in object-oriented programming, which describes the common methods and domains of the created objects.
- Function/method refers to a kind of subroutine in a class.
- a method usually consists of a series of sentences and can complete a function. It is called method in the writing specification of object-oriented programming, and called function in the writing specification of process-oriented programming.
- Field/variable stores some data, such as integers and characters, strings, hash tables, pointers, etc.
- Package is used to describe the path structure of a certain section of the program.
- a package usually contains multiple classes, and the complete package path needs to be filled in the package import area when the class is referenced.
- the inner class is the class contained in the class.
- Parallel change mode means that multiple changers make changes to the software code to be changed at the same time, and then merge the changed software codes generated by each changer to change the software code to be changed to produce the final changed software code .
- Serial change mode means that multiple changers sequentially change the software code to be changed, the input of each changer is the output of the previous changer, and the input of the first called changer is the software code to be changed.
- Partial serial or partial parallel mode is a combination of parallel change mode and serial change mode.
- multiple changers there are changers that require serialization, and there are also changers that require parallelism.
- Partial serial or partial parallel mode can be divided into serial-parallel mode based on parallel mode and serial-parallel mode based on serial mode.
- the serial-parallel mode based on the parallel mode can be divided into multiple changer combinations, and each changer combination has one or more changers. Multiple changer combinations simultaneously change the software code to be changed, and then merge the changed software codes generated by each changer combination to change the software code to be changed.
- the multiple changers in the multiple changer combination can adopt the parallel change mode or the serial change mode.
- the serial-parallel mode based on the serial mode can be divided into multiple changer combinations, and each changer combination has one or more changers. Multiple changer combinations sequentially change the software code to be changed, the input of each changer combination is the output of the previous changer combination, and the input of the first called changer combination is the software code to be changed.
- the multiple changers in the multiple changer combination can adopt the parallel change mode or the serial change mode.
- Each changer is used to perform one type of change in the software code to be changed. It can change a code element (such as class, method, domain, etc.) in the software code to be changed.
- the code elements changed by different changers are different. .
- a. Class name changer In the library upgrade scenario, when the class name of a certain class needs to be changed, the changer can change the class name of the class in the software code to the class name of another class.
- Method name changer In the library upgrade scenario, the method name of a method in a certain class needs to be changed.
- the changer can change the method name of the method under the class to the method name of another method in the class in the software code.
- c. Domain name changer In a library upgrade scenario, the name of a certain domain in a certain class needs to be changed, and the changer can change the name of the domain in the class to the name of another domain in the class in the software code.
- d Library version changer.
- the version of the library needs to be changed, and the changer can change the version of the library in the build file to another version of the library in the software code.
- Package name changer In the library upgrade scenario, when the package name of a package needs to be changed, the changer can change the package name of all referenced packages in the software code to the package name of another package.
- k. Domain delete changer In the library upgrade scenario, when a domain needs to be deleted, the changer finds all the reference locations of the domain in the software code, and outputs all the reference locations of the domain.
- the three name changers include two sub-changeers, each of which is used to change a specific area of the software code (such as the reference area and the package import area) .
- the class name changer can be divided into the class reference sub-changer and the package application changer.
- the class references sub-changeers In the library upgrade scenario, when the class name of a certain class needs to be changed, the sub-modifier can change all referenced class names of the class in the software code (that is, the class name of the class in the reference area) to another The class name of a class.
- Package import child changer In the library upgrade scenario, when the class name of a certain class needs to be changed, the sub-modifier can change the class name of the class in the package import area to the class name of another class in the software code.
- the changer or sub-changer can be understood as a software device that includes input and output.
- the input is the software code that needs to be changed, and the output is the changed software code.
- the change content of the changer may include direct change content and delayed change content.
- the change content of the changer may also include only the direct change content or the delayed change content.
- the direct change content refers to the part of the software code that can be changed directly, and the change of this part will not affect the change of the subsequent changer.
- delayed change content refers to the part that will affect the subsequent changer changes if the software code is directly changed. In other words, if this part of the content is changed, when the subsequent changer executes the change based on the software code changed by the current changer, the subsequent changer will not be able to perform normal change operations.
- the type of delayed change content can be preset. When a changer is called to make changes to the software code, the changer can be determined based on the preset type of delayed change content and the type of change made by the changer. Whether there is a delayed change in the content of changes.
- the changer changes the first type of the package lead-in area to the second type, and changes the content of one or more internal classes in the first type of the package lead-in area to other types. Both can be used as the internal class change content of the changer.
- inner class A when there are multiple inner classes in class A, namely inner class B, inner class C, and inner class D, when it is necessary to change class A to class ZZ, and change inner class B, inner class C, and inner class One or more of D is changed to other classes, for example, internal class B is changed to class ZZ, internal class C is changed to class F, and internal class D is changed to class Q.
- changer 1 is used to change class A to class ZZ
- changer 2 is used to change internal class B to class ZZ
- changer 3 is used to change internal class C to class F
- changer 4 is used Change the internal class D to class Q.
- changer 1 If any one of the changer 1, the changer 2, the changer 3, and the changer 4 in the software code to be changed is changed to the internal class or class A involved in the import statement, it will lead to When other changers make subsequent changes, they cannot detect the information of the internal class that needs to be changed. For example, when changer 1 first changes the class A involved in all import statements in the software code to be changed to class ZZ, then changer 2, changer 3, and changer 4 change the software code of changer 1 When the change is continued, because the class A cannot be found in the package import area of the software code after the changer 1, the internal class in the class A cannot be queried, and the change cannot be made.
- the change content of the changer 1, the changer 2, the changer 3, and the changer 4 for the package lead-in area all belong to the internal type of change content.
- the content of the changes produced by changing the first type of the package lead-in area to the second type, and the changes produced by changing the functions, methods, or domains of the first type of the package lead-in area to other types can all be regarded as Class splitting changes.
- the changer 5 is used to change the class A to the class X
- the changer 6 is used to change the domain E to the class Y
- the changer 7 is used to change the method F to the class X.
- any one of the changer 5, the changer 6, and the changer 7 imports all the packages in the software code to be changed into the function E, method F, or class A involved in the import statement to make changes, other changes will result When subsequent changes are made to the device, it cannot detect the information of the internal class that needs to be changed. For example, when the changer 5 first changes the class A involved in all import statements in the software code to be changed to class X, when the changer 6 and the changer 7 continue to change the software code after the changer 1 , Because the class A cannot be found in the package lead-in area of the software code after the changer 5 is changed, the domain E and the method F in the class A cannot be queried, and the change cannot be made.
- the change content of the changer 5, the changer 6, and the changer 7 for the package lead-in area all belong to the category split change content.
- the change device may be pre-configured with a changer set.
- the changer set includes one or more changers. There is no conflict between any two changers in the changer set.
- the change device calls When the changer in the change set changes the software code to be changed, the parallel change mode can be used to call the changer in the change set to change the software code to be changed.
- the embodiment of the present application does not limit the configuration mode of the changer set, it can be manually configured, or after simulation, the changer that can be called in parallel is placed in the changer set.
- the original change instance set of the changer includes one or more change instances, and each original change instance in the original change instance set records the software code input by the changer (that is, the software code output by the previous changer of the changer ) The line that needs to be changed and the content of the line after the change.
- the set of intermediate change instances of the changer includes one or more change instances, and each change instance in the set of intermediate change instances records a line of the software code to be changed by the changer that needs to be changed and the content of the line after the change.
- the difference between the original change instance set and the intermediate change instance set is that the software code used as the benchmark is different.
- the original change instance set is based on the software code input by the changer, and the intermediate change instance set is based on the software code to be changed. , Is based on the software code to be changed initially determined by the changing device.
- the original change instance set of the first called changer and the intermediate change instance set are the same, and the original changer of the second called The change instance set is based on the software code output by the first called changer, and the intermediate change instance set of the second called changer is based on the software code to be changed.
- a change instance in the set of intermediate change instances of the changer corresponds to a change instance of the set of original change instances of the changer, and a change instance in the set of intermediate change instances of the changer is a corresponding one based on the set of original change instances of the changer
- the generation of the change instance is determined according to the set of intermediate change instances of the changer called before the changer.
- the target change instance set of the changer is generated after the conflict between the changers is eliminated.
- the target change instance includes one or more change instances.
- Each change instance in the target change instance set records the software code input by the changer. (That is, the software code output by the previous changer of the changer) the line that needs to be changed and the content of the line after the change.
- the original change instance set and the change instances included in the target change instance set may be the same, and the target change instance set may also include only part of the change instances in the original change instance set.
- the change instance in the set of target change instance of the changer records the direct change content produced when the changer changes the input software code and actually executes the change.
- the change instance in the original change instance set of the changer records the change content that the changer is expected to produce when the change is expected to be performed when the input software code is changed. Because in the process of eliminating the conflict between the changers, Some change instances will be deleted, so that the target change instance set can only include some of the change instances in the original change instance set.
- the change device needs to maintain an intermediate change instance set for each changer. Based on the intermediate change instance set of the changer, the change device can use the properties of the changer to eliminate the conflict between the changers and determine the change.
- the change instance that needs to be deleted in the set of intermediate change instances of the changer the change device can eliminate the conflict between the changers and the set of intermediate change instances that need to be called (if there is a change instance that needs to be deleted, the changer is eliminated)
- the intermediate change instance set of the changer is the intermediate change instance set of the deleted change instance), and the aggregated intermediate change instance set (it can be referred to as the total change instance set for convenience of explanation) is saved, and Show it to the user through the display.
- the total change instance set includes multiple change instances, which is based on the software code to be changed, and records that when the change device uses the serial change mode to call multiple changers, the software code to be changed actually executes the changes. The content of the changes made at the time.
- the change device uses the properties of the changer to eliminate the conflicts between the changers.
- the corresponding change can also be deleted from the set of original change instances of the changer.
- the embodiment of the present application provides a method for changing software code that supports multiple changes.
- the changing device can select the changer and set the calling sequence of the changer according to the change configuration information of the software code to be changed by the user. And the attributes of each changer. After that, the change device will call each changer in turn according to the set calling sequence to make changes.
- the input of the first called changer is the software code to be changed, except for the first called
- the input of any changer other than the changer is the output of the previous changer.
- the change device can call multiple different changers according to the user's change configuration information, realize multiple different types of changes on the software code to be changed, and can flexibly construct multiple different changes
- the change of the software code to be changed by the device helps to improve the efficiency of software code change.
- the method for changing software code supporting multiple changes provided by the embodiment of the present application is executed by the change device.
- the embodiment of the present application does not limit the deployment location of the change device.
- the change device can be deployed in the cloud, for example, the change device can be a cloud server;
- the device can also be a virtual machine created in a cloud server;
- the change device can also be a software device deployed on a cloud server or a virtual machine.
- the software device is used to make many different types of changes to the software code to be changed.
- the device may be distributed on multiple servers, or distributed on multiple virtual machines, or distributed on virtual machines and servers.
- a change device 100 provided by an embodiment of the present application includes an import module 110, a changer library 120, a configuration module 130, and a change module 140.
- the import module 110 is used to determine the software code to be changed and the configuration information of the user to change the software code to be changed.
- a plurality of changers are stored in the changer library 120.
- Some of the changers (for example, name changers) include one or more sub-changeers, and each changer can perform a change of a code element.
- the configuration module 130 can select the changer from the changer library 120 according to the change configuration information, and configure the calling mode, such as selecting the serial change mode or the parallel change mode, and can also configure the attributes of each changer.
- the change module 140 may call the changer selected by the configuration module 130 based on the call mode selected by the configuration module 130 to change the software code to be changed.
- each changer can change the software code input to the changer.
- Each module included in the changing device 100 may be a software module.
- a computer cluster provided by the embodiment of the present application includes at least one computing device 100, and each computing device 100 passes through The communication network establishes a communication path.
- Each computing device 100 includes a bus 101, a processor 102, a communication interface 103, and a memory 104.
- the computing device 10 may also include a display screen 105.
- the processor 102, the memory 104, and the communication interface 103 communicate through a bus 101.
- the processor 102 may be composed of one or more general-purpose processors, such as a central processing unit (CPU), or a combination of a CPU and a hardware chip.
- the aforementioned hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof.
- ASIC application-specific integrated circuit
- PLD programmable logic device
- the above-mentioned PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a general array logic (generic array logic, GAL), or any combination thereof.
- the memory 104 may include a volatile memory (volatile memory), such as a random access memory (random access memory, RAM).
- volatile memory such as a random access memory (random access memory, RAM).
- the memory 104 may also include non-volatile memory (NVM), such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (solid-disk drive, HDD). state drive, SSD).
- NVM non-volatile memory
- ROM read-only memory
- HDD hard disk drive
- solid-state drive solid-disk drive
- state drive SSD
- the memory 104 may also include a combination of the above-mentioned types.
- the memory 104 stores executable codes.
- the processor 102 can read the executable codes in the memory 104 to realize functions. It can also communicate with other computing devices through the communication interface 103.
- the processor 102 can also trigger the display 105 to report to the user. Display information, such as the information included in the interface as shown in Figures 4, 9, and 10 in the embodiment of the present application.
- the processor 102 may implement the function of one or more modules of the change device 100 (such as one or more of the import module 110, the changer library 120, the configuration module 130, and the change module 140).
- the memory 104 stores one or more modules of the change device 100 (such as one or more of the import module 110, the changer library 120, the configuration module 130, and the change module 140).
- the processors 101 in the multiple computing devices 10 may coordinate work to execute the software code modification method supporting multiple changes provided in the embodiment of the present application.
- the change module 140 when the change module 140 is stored in the memory 104, the change module 140 also includes a cache space.
- the cache space is located in the memory 104.
- the cache space can be used to store the first called changer to treat The analysis result obtained by analyzing the changed software code, and the delayed change content of each called changer.
- a system architecture provided by this embodiment of the present application includes a client 200 and a cloud device 300 deployed with a change device.
- the client 200 and the cloud device 300 are connected via a network, and the cloud device 300 is located in a cloud environment and can be a server or a virtual machine deployed in a cloud data center.
- the changing device is deployed on a cloud device 300 as an example.
- the changing device It can be deployed on multiple cloud devices 300 in a distributed manner.
- the client 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204.
- the client 200 may also include a display screen 205.
- the processor 202, the memory 204, and the communication interface 203 communicate through a bus 201.
- the memory 204 stores executable code, and the processor 202 can read the executable code in the memory 204 to implement functions.
- the processor 202 may also trigger the display screen 205 to display information to the user, such as the information included in the interface shown in Figures 4, 9, and 10 in the embodiment of the present application.
- the processor 202 may also communicate with the cloud device through the communication interface 203.
- the processor 202 can be used to input the software code to be changed and the configuration information to be changed through the display screen, and under the trigger of the user, determine the software code to be changed and the configuration information to be changed; And the configuration change information is fed back to the cloud device 300.
- the cloud device 300 includes a bus 301, a processor 302, a communication interface 303, and a memory 304.
- the processor 302, the memory 304, and the communication interface 303 communicate through a bus 301.
- Executable code is stored in the memory 304, and the processor 302 can read the executable code in the memory 304 to implement functions, and can also communicate with the client 200 through the communication interface 303.
- the processor 302 of multiple cloud devices 300 can cooperate to realize the function of the change device 300.
- the memory 304 stores the import module 130 and the changer of the change device 300 One or more modules of the library 120, the configuration module 130, and the change module 140.
- the change module 140 when the change module 140 is stored in the memory 304, the change module 140 also includes a cache space.
- the cache space is located in the memory 304.
- the cache space can be used to store the first called changer to treat The analysis result obtained by analyzing the changed software code, and the delayed change content of each called changer.
- the processor 302 After the processor 302 receives the software code to be changed and the changed configuration information from the client 200 through the communication interface 303, it can call the module stored in the memory 304 to implement the code change method provided by the embodiment of the present application, and generate the changed software code.
- the processor 302 may send the changed software code to the client 200 through the communication interface 303.
- the processor 302 may also determine the direct change content and delayed change content of all the called changers, and send the direct change content and delayed change content of all the called changers to the client 200 through the communication interface 303.
- the processor 202 in the client 200 After the processor 202 in the client 200 receives the changed software code and the direct change content and delayed change content of all the called changers through the communication interface 203, the processor 202 can trigger the display screen 205 to display the changed content to the user.
- the method includes:
- Step 301 The import module 110 determines the software code to be changed and the change configuration information of the software code to be changed by the user.
- the change configuration information includes the code element to be changed, the change method (such as modification or deletion) of the code element to be changed, and the changed code element corresponding to the code element to be changed.
- the changed code element corresponding to the code element to be changed is a null value.
- the embodiments of the present application do not limit the number of code elements to be changed, and there may be one or more.
- the configuration change information may be configured by the user or fixed, which is not limited in the embodiment of the present application.
- the modified configuration information includes multiple code elements to be changed as an example.
- the configuration module 130 only needs to change from The changer that can perform corresponding changes to the code element to be changed is selected from the library 120, and the change module 140 only needs to call the changer to change the software code to be changed.
- the import module 110 determines the software code to be changed or the configuration information to be changed.
- the user can trigger the terminal device to send a request message carrying the software code to be changed and the configuration information to the import module 110, and also request the message. It is used to request the change device 100 to perform changes to the software code to be changed.
- the user can import the software code to be changed into the import module 110, and set the changed configuration information under the reminder of the import module 110.
- the software code to be changed can be the code of the entire software (all files in multiple directories), or the code used to implement a specific function in the code of the entire software (all files in a specific directory) , It can also be a specific code file in the entire software code.
- the user can import the code file of the entire software into the import module 110, and the user can select the software code that does not need to be changed from the entire code file under the reminder of the import module 110, and import the remaining software
- the code is the software code to be changed.
- the user inputs the storage path of the software code that does not need to be changed, so that the import module 110 can determine the code to be changed from part of the code in the entire software code file.
- the change configuration information may also include other information, and the other information includes some or all of the following: the identity (ID) of the changer that needs to be called, and the change mode (such as string) of the software code to be changed. Row change mode, parallel change mode or partial serial and partial parallel mode).
- the change configuration information may also include the calling sequence of the changers and the attributes of each changer.
- the user when determining that the software code to be changed needs to be changed, the user can select the changer that needs to be invoked when the software code to be changed is changed.
- This embodiment of the application does not limit the number of changers that need to be invoked selected by the user.
- the changer selected by the user can only perform changes to some of the code elements to be changed in the changed configuration information, and target the rest of the changed configuration information.
- the changer required to perform the change of the code element to be changed can be handed over to the configuration module 130 for selection, and the selection method can be referred to step 302.
- the user can also select the change mode of the software code to be changed. For example, when the user determines that there is no conflict between the changes of multiple software elements to be changed in the software code to be changed, the parallel change mode can be selected. When the user determines that there is a conflict between the changes of multiple software elements to be changed in the software code to be changed, the serial change mode can be selected.
- the user can also set the calling sequence and the attributes of each changer for the selected multiple changers.
- attributes can be set for each changer, and the available options of the attributes are merge change attributes, ignore change attributes, and overwrite change attributes.
- the merge change attribute is used to express whether the changer and the changer called before the changer merge the changes of a specific line, and the same line or lines of the software code to be changed by the two changers are referred to as the specific line for short .
- the merge change attribute of the changer can be set to true (true) or false (false).
- true true
- false false
- the ignore change attribute is used to describe whether to ignore the change of other lines of the software code to be changed by the changer. Other lines refer to lines other than specific lines in the software code to be changed.
- the ignore change attribute of the changer can be set to true (true) or false (false). When the ignore change attribute is true, it means that the change of the changer to other rows will be ignored; when the ignore change attribute is false (false) ) Means that the changes made by the changer to other rows will not be ignored.
- the overwrite change attribute is used to describe whether to overwrite the change of a specific line of the software code to be changed by the changer called before the changer.
- the overwrite change attribute of the changer can be set to true (true) or false (false).
- true it means that the changer called before the changer overwrites the changes of a specific row, that is to say ,
- the changer previously called by the changer is invalid for the change of a specific row, and only the changes made by the changer to the specific row are retained;
- the overwrite change attribute is false (false)
- the changes are not overwritten. In this case, you need to check the merged change properties.
- each changer By setting the attributes of each changer, the user can change the same line or multiple lines of the software code to be changed by multiple changers in advance to avoid conflicts that may occur, so that the change module 140 can call each changer later. When the time, each changer can make changes more quickly.
- Step 302 The configuration module 130 selects a changer from the changer library 120 according to the change configuration information.
- the configuration module 130 can select a changer from the changer library 120 that can change the code element to be changed to the corresponding changed code element according to the code element to be changed.
- the embodiment of the present application does not limit the number of changers selected by the configuration module 130, and the number of changers is related to the configuration information of the changer.
- the configuration module 130 can select the changer that needs to be called from the changer library 120 according to the ID of the changer. If the changer corresponding to the ID of the changer to be called included in the change configuration information can only change part of the code elements to be changed, the configuration module 130 also needs to select from the changer library 120 that can change the remaining to be changed The code element is changed to the changer of the corresponding changed code element.
- the embodiment of the present application does not limit the number of changers selected by the configuration module 130, and the number of changers is related to the number of remaining code elements to be changed in the configuration information of the changer.
- Step 303 The configuration module 130 determines the modification mode of the software code to be modified according to the modification configuration information, such as selecting a serial modification mode, a parallel modification mode, or a partial serial or partial parallel mode.
- the configuration module 130 may directly determine the change mode of the software code to be changed according to the change configuration information.
- the configuration module 130 may determine the change mode of the software code to be changed according to the selected changer.
- the configuration module 130 determines whether there are two conflicting changers among the selected multiple changers. If there are no conflicting modifiers, the configuration module 130 can adopt the parallel modification mode. Otherwise, the serial modification mode or the partial serial partial parallel mode is adopted (the conflicting modifier adopts the serial mode, and there is no conflicting modification.
- the device uses a parallel mode).
- the configuration module 130 can also set the calling sequence of the changers and the attributes of each changer.
- the configuration module 130 can directly set the calling sequence of the changers and the attributes of each changer according to the change configuration information.
- the configuration module 130 may first set the calling sequence of the multiple changers, and then configure the attributes of each changer based on the calling sequence .
- the configuration module 130 may set priorities for multiple changers in the changer library 120, the changer with a higher priority needs to be called first, and the changer with a lower priority is called after.
- the configuration module 130 may determine the calling sequence according to the priority of the multiple changers.
- each calling plan may include all changers or some changers.
- the configuration module 130 may match multiple changers with multiple calling plans to obtain a target calling plan.
- the target calling plan includes the multiple changers, and the target calling plan may also include other changers other than the multiple changers. .
- the configuration module 130 may determine the calling sequence of the multiple changers according to the sequence of the multiple changers in the target calling plan.
- changers For example, for example, five different changers are pre-stored in the changer library 120, namely, changer A, changer B, changer C, changer D, and changer E.
- the configuration module 130 pre-configures three types of changers.
- a kind of calling scheme among them, scheme one: A->B->D->E->C; scheme two: A->B->D->E; scheme three: A->D->E->C .
- the changers selected by the configuration module 130 are the changer A, the changer B, and the changer C. Only if the plan one includes the changer A, the changer B, and the changer C, the plan one is the target calling plan. Since the changer D and the changer E are not selected, the solution one can be converted to A->B->C, and the calling sequence of the configuration module 130 configuration is A->B->C.
- the foregoing method of determining the calling sequence is only an example.
- the embodiment of the present application does not limit the manner in which the configuration module 130 determines the calling sequence.
- the configuration module 130 may also use a random method to determine the multiple The calling sequence of each changer.
- the configuration module 130 may set the attributes of the changers other than the first called changer based on the calling sequence (and the change configuration information).
- the configuration module 130 may pre-store the attribute configuration scheme of the changer, and the attribute configuration scheme of a changer records the invocation of the changer and other changers (the other changers are the changers that may conflict with the changer) The order of the, and the attributes of the changer in that order.
- the configuration module 130 sets the attributes of the changer according to the attribute configuration scheme of the changer based on the invocation attributes of the multiple changers.
- changer A, changer B, and changer C and the attribute configuration scheme of changer B is as follows: when the calling sequence of changer B is before changer A, the three attributes of changer B are all set to false, if The calling sequence of the changer A is before the changer B, then the merged change attribute of the changer B is true, the change attribute is ignored and the change attribute is overwritten is false.
- the attribute configuration scheme of the changer C is as follows: when the calling sequence of the changer C is before the changer B, the three attributes of the changer C are all set to false, if the calling sequence of the changer B is before the changer C, the change The merge change attribute and the ignore change attribute of the device C are false, and the overwrite change attribute is true.
- the configuration module 130 may not set the attribute of the changer A.
- Step 304 Based on the change mode of the software code to be changed, the change module 140 calls the multiple changers to change the software code to be changed.
- the following describes the manner in which the change module 140 calls the multiple changers to change the software code to be changed in the parallel change mode and the serial change mode.
- the change module 140 calls the multiple changers to change the software code to be changed. Refer to the descriptions of Mode 1 and Mode 2 below.
- the change module 140 adopts Mode 1, invoking the multiple changers, and responds to the software input to the multiple changers.
- the code is changed; for multiple modifiers (or modifier combinations) serially in partial serial and partial parallel modes, the modifier module 140 adopts method one, calling the multiple modifiers (or modifier combinations), and responding to the input to the
- the software code of multiple changers (or combination of changers) is changed. For details, please refer to the following description, which will not be repeated here.
- Method 1 Based on the parallel change mode, call the multiple changers at the same time to change the software code to be changed.
- the change module 140 can call multiple changers to change the software code to be changed at the same time. After the change of each changer in the multiple changers is completed, the change generated by each changer can be changed. After the software code is merged, the merged software code is the final changed software code.
- the change module 140 may determine the change content of each changer, for example, determine one or more lines of code to be changed when each changer changes the software code to be changed. Replace the software code corresponding to the changed content of each changer in the software code to be changed with the changed content of each changer, and obtain the final changed software code.
- Method 2 Based on the serial change mode, the multiple changers are sequentially called to change the software code to be changed.
- the formal parameters of the function P are changed, and the formal parameters of the function P call in the software code to be changed are changed, and the changed software code 1 is generated.
- the function P is changed, the function P in the software code to be changed is changed to the function Q, and the changed software code 2 is generated. Since the function P does not exist in the changed software code 2, it is impossible to simply merge the changed software code 1 and the changed software code 2. That is to say, if different types of changes are made to the software code, the resulting changes are prone to conflicts and cannot be simply merged. It should be understood that the above example is only a relatively simplified situation. When the software code is actually changed, the software code is changed with different types of changes. The conflicts between the resulting changes are more obvious and the merger is more difficult. Big.
- the change module 140 calls any changer to change the software code input to the changer, it determines whether the changer directly changes the content or delays the change content, and if so, the changer The direct change content of the changer is directly applied to the software code to be changed, and the delayed change content of the changer is retained until all the changers are called. The delayed change content of the called multiple changers is uniformly applied to the last changer. On the output software code, the changed software code is obtained.
- invoking each changer distinguish between the direct change content of each changer's change content and the delayed change content that may have change conflicts, and unify the delayed change content generated by multiple changers in the final application to the software to be changed. In terms of code, it can effectively avoid conflicts caused by different changers directly making changes during the invocation process.
- FIG. 5 it is a schematic diagram of a method for the change module 140 to change the software code to be changed by adopting the serial change mode.
- the method includes:
- Step 501 The change module 140 sequentially calls the multiple changers to change the software code to be changed according to the calling sequence of the multiple changers, the input of each changer is the output of the previous changer, and the software code to be changed is The input of the first changer called.
- Step 502 When calling a changer to change the software code input to the changer, the change module 140 determines whether there are direct change content and delayed change content in the change content of the changer.
- Step 503 The change module 140 directly applies the directly changed content of the changer to the software code input by the changer.
- Step 504 If the changer has delayed change content, the change module 140 retains the delayed change content of the changer. For example, the delayed change content of the changer can be saved.
- Step 505 Until all the changers are called, the change module 140 uniformly applies the delayed change content of the multiple changers to the software code output by the last changer, and generates the changed software code.
- FIG. 6 is a flowchart of the change module 140 using the serial change mode to change the software code to be changed.
- the change module 140 sequentially calls the changer A, the changer B, and the changer according to the calling sequence of A->B->C.
- the change module 140 inputs the software code to be changed into the changer A. When the changer A is called, it determines whether there are direct changes and delayed changes in the change content of the changer A. If there are direct changes, the change module 140 Apply the direct change content to the software code to be changed (1), and the changed software code is the software code output by the changer A. If there is a delayed change content, the change module 140 retains the delayed change content (2). When the changer A changes the software code to be changed, it can also save the analysis result (3) of the software code to be changed.
- the analysis result includes the position of all code elements in the software code to be changed (the description of the analysis result can be (See the description below, which will not be repeated here).
- the change module 140 inputs the output software code of the changer A to the changer B.
- the change module 140 calls the changer B, it determines whether there are direct changes and delayed changes in the change content of the changer B. If there are direct changes, , The change module 140 applies the direct change content to the software code input to the changer B (5), and the changed software code is the software code output by the changer B. If there is a delayed change content, the change module 140 retains the delayed change content (6).
- the changer B can also call the analysis result (3) saved by the changer A, and based on the analysis result, determine the change position of the software code input to the changer B.
- the change module 140 inputs the output software code of the changer B to the changer C.
- the change module 140 calls the changer C, it determines whether there are direct changes and delayed changes in the change content of the changer C. If there are direct changes, , The change module 140 applies the direct change content to the software code input to the changer C (8), and the changed software code is the software code output by the changer C. If there is a delayed change content, the change module 140 retains the delayed change content (9).
- the changer C can also call the analysis result (7) saved by the changer A, and based on the analysis result, determine the change position of the software code input to the changer C.
- the change module 140 uniformly applies the delayed change content of the multiple changers to the software code output by the changer C, and generates the changed software code.
- step 502 when the change module 140 calls any one of the multiple changers to change the software code input to the changer, the change module 140 can change the content according to the preset delay (such as internal class change).
- Content and class split change content determine whether there is a delayed change in the change content of the changer, if there is a delayed change content, the delayed change content is retained, if there is no delayed change content, the change module 140 determines the changer Directly change the content.
- the delayed change content of the changer is retained from the change content of the changer, there may still be some potential conflicts between the changers, and these potential conflicts may cause the change content of the changer Except for the delayed change content, only a part of the content can be applied to the software code input to the changer (this part is the direct change content), and the software code that cannot be applied to the input changer will be deleted.
- the change module 140 determines the direct change content in the changer content of the changer, it needs to use the attributes of the called changer to determine the inter-change content of the changer based on part or all of the attributes of the changer.
- the method of determining the direct change content of the changer is explained:
- Step 1 Each time the change module 140 calls a changer, it determines the original change instance set of the changer.
- Step 2 The change module 140 generates an intermediate change instance set of the changer based on the original change instance set of the changer and the original change instance set of the changer called before the changer.
- Line number changes include but are not limited to: line number changes caused by adding or deleting lines from the changer called before the changer.
- the change module 140 can calculate the number of line changes caused by the changer previously called by the changer before changing the software code to be changed, for example, if the changer previously called by the changer increases by N line numbers, then add up The value of is a positive number, which is N; if the changer called before the changer deletes M row numbers, the accumulated value is a negative number, which is -M.
- the change module 140 subtracts the line number 1 from the record line number 1 in the change instance 1 of the changer, determines the line number 2 that the changer needs to change when the software code to be changed is used as the reference, and then generates the changer Change instance 2 for change instance 1 in the intermediate change instance set of (where the row number is row number 2, and the content of the row after the change is the same as the content of row number 1 recorded in the change instance 1). Using the above method, all the change instances in the set of intermediate change instances of the changer can be generated.
- changer A As shown in Figure 7, there are three changers in series, namely changer A, changer B, and changer C. Below each changer is marked when each changer changes the software code input to the changer , The line number that needs to be changed and the changed content (which can be regarded as the collection of original change instances of each changer) are identified by operations (value 1, value 2). Operations can be divided into add (add) and modify ( modify) and delete (delete) The value 1 represents the line number, and the value 2 represents the number of lines of the operation.
- adding (3, 2) means inserting 2 lines of code in the third line of the software code input to the changer, and deleting (4, 1) It means to delete 1 line of code in the 4th line of the software code of the changer, and modify (6,1) means to modify 1 line of code in the 6th line of the software code of the changer (that is, the number of lines does not increase. No reduction).
- changer B One operation of changer B is to add (2,1), because the previous changer (changer A) changes the software code to be changed, all changes to the second line of code, that is to say, the The line number in the operation has not changed. Another operation of changer B is to modify (6,1). You can see that when changer A changes the software code to be changed, it inserts 2 rows before row 6 and deletes 1 row. The number of row changes is 1. Therefore, another operation of changer B is to modify (6, 1). If the software code to be changed is used to change, it should be modified (5, 1). Similarly, the operation of changer C is to modify (8, 1) Change to modification (6,1).
- Step 3 The change module 140 generates the target change instance set of the changer based on the attributes of the changer, the set of intermediate change instances of the changer, and the set of intermediate change instances that the changer was previously called by the changer.
- Step 4 After the change module 140 generates the target change instance set of the changer, it can use the target change instance set of the changer to change the software code input to the changer.
- the change module 140 can determine whether the changer and the changer before the changer are called based on the intermediate change instance of the changer and the intermediate change instance that called the changer before the changer Will make changes to the same one or more lines of the software code to be changed. If the changer and the changer previously called the changer to make changes to the same one or more lines of the software code to be changed, the change is easy to cause Conflicts between changers need to be eliminated.
- the change module 140 can determine whether the changer is needed and the changer previously called by the changer is required to merge the changes of a specific row according to the merge change attribute of the changer. If it needs to be merged, the change can be made in the middle of the changer. The change instance corresponding to the specific row is retained in the instance, and the change instance corresponding to the specific row is retained in the original change instance of the changer.
- the change module 140 can determine whether to ignore the changes of other lines of the software code to be changed by the changer according to the ignore change attribute of the changer; if it needs to be ignored, it can delete the corresponding other lines in the intermediate change instance of the changer.
- the change instance of the changer delete the change instance corresponding to the other row in the original change instance of the changer.
- the change module 140 may determine, according to the overwrite change attribute of the changer, to overwrite the change of a specific line of the software code to be changed by the changer called before the changer. If it needs to be overwritten, the change module 140 may reserve the change instance corresponding to the specific row in the intermediate change instance of the changer, and may reserve the change instance corresponding to the specific row in the intermediate change instance of the changer.
- the change module 140 updates the original change instance set of the changer according to the various attributes of the changer (such as deleting the change instance or keeping the change instance), and the updated original change instance set of the changer is the changer's original change instance set.
- the change module 140 updates the set of intermediate change instances of the changer according to the various attributes of the changer (such as deleting the change instance or keeping the change instance), it can update the changes in the set of intermediate change instances of the changer.
- the instance is added to the total change instance set.
- each changer there are three serial changers, namely changer E, changer F, and changer G.
- the software code to be changed by each changer is marked.
- the line number that needs to be changed and the content after the change (which can be regarded as a set of intermediate change instances of each changer) are marked in the same way as the embodiment shown in FIG. 5, and will not be repeated here.
- m1, m2, m3, m4, and m5 are used to indicate the content of the modification, only to distinguish different modifications.
- the changer F and the changer G are marked with the true or false of merging change attributes, ignoring the changed attributes, and overriding the changed attributes.
- the merge change attribute of the changer B is true, the ignoring the change attribute and the overwriting of the change attribute are false.
- the merge change attribute and the ignore change attribute of the changer C are false, and the overwrite change attribute is true.
- a change instance of the changer F is modification (4, m3)
- a change instance of the changer E is modification (4, m2)
- the changer E also modifies the fourth row, because the changer
- the merge change attribute of F is true, the changes of changer B and changer E need to be merged, and the change instance of changer E and changer F needs to be kept at the same time, and the modification is retained in the intermediate change instance of changer B (4 ,m3)
- This change instance, the change instance corresponding to the change instance of modification (4, m3) is retained in the original change instance set of the changer F.
- the original change instance set of the updated changer F is the target instance set of the changer F.
- a change instance of the changer G is modify (1, m4), you can see that the changers (changer E and changer F) called before the previous changer G have not modified the first row, and the changer G The ignore change attribute of is true, delete the change instance (1,m4) in the set of intermediate change instances of the changer G, and delete the change (1,m4) in the set of original change instances of the changer G The change instance corresponding to the instance.
- Another operation of the changer G is to modify (3, m5), and the changer A also modified the third row, and the overwrite change attribute of the changer G is true, and the change module 140 retains the intermediate changes of the changer G
- the change instance (3, m5) is modified in the instance set, and the change module 140 retains the change instance corresponding to the change instance modified (3, m5) in the original change instance set of the changer G.
- the original change instance set of the updated changer G is the target instance set of the changer G.
- the changer may also add the updated intermediate change instance set of the changer E, the intermediate change instance set of the changer F, and the change instance in the intermediate change instance set of the changer G to the total change instance set.
- the total change instance set includes modification (4, m2), modification (3, m1), modification (4, m3), and modification (3, m5).
- the change instance modification (4, m3) of the changer F and the change instance modification (4, m2) of the changer E can be merged, that is, the merged change instance is the modification ( 4,[m2,m3]).
- the merged change instance modification (4, [m2, m3]) replaces the modification (4, m2) and the modification (4, m3) in the total change instance set.
- each changer when each changer changes the input software code, it needs to analyze the input software code first, analyze the position of all code elements in the input software code, and find the code element to be changed. Position (such as one or more rows), to change the code element to be changed at this position.
- the position (such as line) that may be changed is the same.
- the name of a method changes and its formal parameters also occur.
- a changer for changing the method name and a changer for changing the actual parameters of the method are required.
- the method name and the change position (row) of the actual parameters of the method are the same, and there is a conflict between the two changers at this time.
- each changer When each changer changes the input software code, it usually needs to analyze the input software code first, analyze the position of all code elements in the input software code, and analyze the containment relationship between each code element. For example, functions/methods contained in a certain class, variables/domains referenced in functions/methods, etc.
- the analysis process of the input software code by each changer usually takes a certain amount of time, in order to be able to efficiently implement the change of the software code to be changed.
- the first called changer can save the analysis result of the software code to be changed.
- the analysis result includes the position of all code elements in the software code to be changed and the relationship between each code element. Containment relationship.
- the analysis result may be stored in the cache space in the change module 140.
- the analysis results saved by the first called changer can be called, based on the analysis results saved by the first changer to the changed output of the previous changer
- the software code is changed.
- the change module 140 can apply the direct change content of each changer to the software code input to the changer.
- the change module 140 can uniformly apply the delayed change content of all changers to the last changer after the direct change content of the last changer called is applied to the software code input to the changer.
- the delayed change content of is applied to the software code output by the last changer.
- serial or parallel methods can also be used to apply all delayed changes of multiple changers to the output of the last changer.
- the serial mode is similar to the embodiment shown in FIG. 5 or FIG. 6, for example, the delayed change content of any one of all delayed change contents of multiple changers is characterized by a set of delayed change instances, and the delayed change The change instance in the instance set is based on the software code to be changed.
- the method of determining the change instance in the delayed change instance set is similar to the method of the change instance set in the intermediate change instance set of the changer.
- the changer called before the changer changes the number of line changes caused by the changes to the software code to be changed, and the corresponding accumulation is performed to determine the change instance in the delayed change instance set. You can also avoid differences based on the attributes of these multiple changers If there is conflict in the delayed change content, delete the change instance in the delayed change instance set, and update the delayed change instance set. After that, the change instances in the updated delayed change instance set are updated to the total change instance set.
- the change module 140 can display the total change set to the user through the display screen in the computing device, that is, display all the changed lines of the software code to be changed by the change module 140, the change method (delete, modify, add, etc.), and The content after the change.
- the change module 140 provides the following two display modes:
- the change module 140 can display the changed software code and the difference comparison page of the software code to be changed.
- the left side is the software code to be changed
- the right side is the changed software code.
- the page is marked with the line number, and the line that needs to be changed is marked in bold on the software code to be changed.
- the user can confirm the line to be changed and the content after the change through the difference comparison page. After confirming that the change is correct, the changed software code can be replaced with the originally imported software code to be changed.
- the change module 140 can display the software code to be changed, and display all the change instances of the total change instance set at the bottom of the page.
- the display interface of the software code to be changed the row that needs to be changed is displayed in the form of a small light bulb, and the changed content of the row is displayed.
- the user can confirm the changed content of a certain line. After confirming that the changed content of the line is correct, the changed content of the line can be separately applied to the software code to be changed.
- the disclosed system, device, and method may be implemented in other ways.
- the device embodiments described above are merely illustrative, for example, the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components may be combined or It can be integrated into another system, or some features can be ignored or not implemented.
- the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
- the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
本申请提供了一种代码变更方法及装置。变更装置根据用户发送的指令确定待变更的软件代码以及变更配置信息,并根据变更配置信息从保存的变更器中选择需要调用的多个变更器,并确定多个变更器的调用顺序以及每个变更器设置属性。变更装置可以按照调用顺序依次调用多个变更器,并且基于每个变更器的属性,对变更器输入的软件代码进行变更。该变更装置能够根据用户的需求,灵活的调用多个不同的变更器。
Description
本申请涉及计算机技术领域,尤其涉及一种代码变更方法及装置。
在软件开发与维护过程中,有许多场景需要对软件代码进行变更,比如库升级后的软件代码更新或者对软件代码的格式进行变更。每个场景中对软件代码的变更也存在多种不同的变更类型。例如,在库升级的场景中,某个库函数的形式参数发生变化,此时需要对软件代码中该库函数的所有引用点的实际参数作更改,或者某个库函数的名称发生变化,此时需要将软件代码中该库函数的名称更改为变化后的库函数名称等等。又例如,对软件代码的格式进行更改的场景中,可能需要修改软件代码的缩进方式、对齐方式等。
目前对软件代码的变更方式,仅是支持单一变更,即在对软件代码变更时,只能进行一种变更类型的变更。目前还没有一种能够对软件代码同时进行多种变更类型的变更方式。
发明内容
本申请提供一种代码变更方法,以提供一种高效的对软件代码同时进行多种变更类型的变更方式。
第一方面,本申请提供了一种代码变更方法,该方法可以由变更装置执行,该变更装置可以获取用户输入的软件代码以及软件代码的变更配置信息,其中,该变更配置信息包括待变更的代码元素、对待变更的代码元素的变更方式以及待变更的代码元素对应的变更后的代码元素。该变更装置可以根据该变更配置信息从保存的变更器中选择需要调用的多个变更器,并确定该多个变更器的调用顺序。变更装置可以按照调用顺序依次调用该多个变更器,对软件代码进行变更,其中,每一个变更器能够对软件代码中的一种待变更的代码元素进行变更,所述多个变更器中第一个被调用的变更器的输入为所述软件代码,被所述第一个被调用的变更器变更后的软件代码被输入所述多个变更器中的另一个变更器。
通过上述方法,变更装置能够根据用户的需求,灵活的调用多个不同的变更器,能够同时对软件代码进行多种不同的变更。
在一种可能的实现方式中,当变更装置先确定选择的多个变更器中是否存在冲突的变更器,其中冲突的变更器是指其中一个变更器先进行变更,导致后续变更器对该变更器输出的软件代码进行变更时,会无法进行正常的变更。若不存在冲突的变更器,变更装置可以采用并行变更模式,同时调用该多个变更器对该软件代码进行变更,之后在将每个变更器的变更内容进行合并。
若存在冲突的变更器,变更装置则确定该多个变更器采用串行变更模式或部分串 行部分并行变更模式对软件代码进行变更。
通过上述方法,变更装置可以灵活的选择不同的变更模式对软件代码进行变更,使得选择的变更模式更能适用于软件代码,变更的方式更加高效。
在一种可能的实现方式中,若该多个变更器中的至少一个变更器包括直接变更内容和延迟变更内容;变更装置在按照多个变更器的调用顺序依次调用多个变更器,对软件代码进行变更时,当调用至少一个变更器时,可以将直接变更内容应用在输入到该至少一个变更器的软件代码中;将延迟变更内容在所述多个变更器中最后一个变更器调用结束后应用。
在一种可能的实现方式中,在确定了调用顺序之后,还可以对每个变更器设置属性,变更器的属性用于描述该变更器对软件代码中的一些行的变更是否保留或删除。之后
通过上述方法,变更装置在调用每个变更器时,区分每个变更器的变更内容中的直接变更内容和可能存在变更冲突的延迟变更内容,将多个变更器产生的延迟变更内容统一在最后应用在软件代码上,能够有效避免不同变更器在调用过程中直接进行变更引起的冲突。
在一种可能的实现方式中,变更装置可以在依次调用所述多个变更器之前,先基于所述多个变更器的调用顺序确定每个变更器的属性,每个变更器的属性用于描述每个变更器对软件代码中的目标行的变更的处理。当然,变更装置也可以不确定每个变更器的属性。
通过上述方法,变更装置能够为变更器设置属性,以便变更器在后续被调用时,能够较为准确的确定对软件代码中一些目标行的变更是否保留或删除。
在一种可能的实现方式中,变更配置信息中可以还包括每个变更器的属性,每个变更器的属性用于描述每个变更器对所述软件代码中的目标行的变更的处理。
通过上述方法,用户可以自行对变更器的属性进行配置,给予用户更多的主动权,有利于提高软件代码变更的灵活性。
在一种可能的实现方式中,变更装置在确定至少一个变更器的直接变更内容时,可以直接根据至少一个变更器的变更操作,来确定至少一个变更器的直接变更内容。也可以根据至少一个变更器的属性,确定至少一个变更器的直接变更内容。
通过上述方法,变更装置基于变更器设置属性,能够较为准确的确定对软件代码中一些目标行的变更是否保留或删除,进一步确定变更器的直接变更内容。
在一种可能的设计中,变更装置在根据至少一个变更器的属性确定至少一个变更器的直接变更内容时,需要确定至少一个变更器的第一属性,如合并变更属性以及覆盖变更属性,该第一属性描述至少一个变更器对软件代码的第一目标行的变更保留或删除,第一目标行为至少一个变更器和至少一个变更器之前被调用变更器对软件代码变更的相同的一行或多行。根据至少一个变更器的第一属性,确定至少一个变更器需要保留的变更,进而确定至少一个变更器的直接变更内容。
通过上述方法,变更装置可以基于变更器的属性较为便捷的确定需要删除或保留的变更,进而能够确定最终实际执行的直接变更内容。
在一种可能的设计中,变更装置在根据至少一个变更器的属性确定至少一个变更 器的直接变更内容时,可以只基于至少一个变更器的第一属性来确定至少一个变更器的直接变更内容,还可以同时参照至少一个变更器的第一属性和第二属性来确定至少一个变更器的直接变更内容,也可以只基于至少一个变更器的第二属性来确定至少一个变更器的直接变更内容,其中,至少一个变更器的第二属性(如忽略变更属性)描述至少一个变更器对软件代码的第二目标行的变更保留或删除,第二目标行为至少一个变更器和至少一个变更器之前被调用变更器对软件代码变更的不同的一行或多行。
通过上述方法,变更装置可以基于变更器的属性较为便捷的确定需要删除或保留的变更,进而能够确定最终实际执行的直接变更内容。
在一种可能的设计中,变更装置在确定该变更器对输入到该变更器的软件代码执行变更时存在延迟变更内容时,可以预先设置一种或多种延迟变更内容,根据预设的延迟变更内容从该变更器对输入到该变更器的软件代码执行变更时的变更内容中确定延迟变更内容。
通过上述方法,,变更装置可以基于预设的信息确定延迟变更内容,能够较为快捷的确定出需要保留到最后再进行变更的延迟变更内容。
在一种可能的设计中,变更装置在调用第一个变更器时,第一个被调用的变更器可以对软件代码进行分析,产生分析结果,该分析结果中可以包括软件代码中所存在的所有代码元素的位置,变更装置可以保存该分析结果,以便后续在调用其他变更器时,其他变更器可以调用该分析结果,对输入到其他变更器的软件代码进行变更。
通过上述方法,对软件代码的分析操作只需要进行一次,后续变更器只需调用之前变更器产生的分析结果,不需要重复分析,能够有效节约时间,提高软件代码的变更效率。
在一种可能的设计中,变更装置对软件代码进行变更之后,还能显示最终的变更后的软件代码,并显示多个变更器对软件代码进行变更的变更位置以及变更的内容。
通过上述方法,变更装置能够较为直观的显示出变更后的软件代码,还能够显示所进行的变更,便于用户查看。
第二方面,本申请实施例还提供了一种变更装置,有益效果可以参见第一方面的描述此处不再赘述。该装置具有实现上述第一方面的方法实例中行为的功能。所述功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。所述硬件或软件包括一个或多个与上述功能相对应的模块。在一个可能的设计中,所述装置的结构中包括导入模块、配置模块、变更器库以及变更模块,这些模块可以执行上述第一方面方法示例中的相应功能,具体参见方法示例中的详细描述,此处不做赘述。
第三方面,本申请实施例还提供了一种计算设备,所述计算设备包括处理器和存储器,还可以包括通信接口。可选的还包括显示屏。所述处理器执行所述存储器中的程序指令执行上述第一方面或第一方面任一可能的实现方式提供的方法。所述存储器与所述处理器耦合,其保存确定交通流量的过程中必要的程序指令和数据。所述通信接口,用于与其他设备进行通信,如接收软件代码以及变更配置信息。所述显示屏用于在所述处理器的触发下向用户显示信息。
第四方面,本申请提供了一种计算设备集群,该计算设备集群包括至少一个计算设备。每个计算设备包括存储器和处理器。至少一个计算设备的处理器用于访问所述 存储器中的代码以执行第一方面或第一方面的任意一种可能的实现方式提供的方法。
第五方面,本申请提供了一种非瞬态的可读存储介质,所述非瞬态的可读存储介质被计算设备执行时,所述计算设备执行前述第一方面或第一方面的任意可能的实现方式中提供的方法。该存储介质中存储了程序。该存储介质包括但不限于易失性存储器,例如随机访问存储器,非易失性存储器,例如快闪存储器、硬盘(hard disk drive,HDD)、固态硬盘(solid state drive,SSD)。
第六方面,本申请提供了一种计算机程序产品,所述计算机程序产品包括计算机指令,在被计算设备执行时,所述计算设备执行前述第一方面或第一方面的任意可能的实现方式中提供的方法。该计算机程序产品可以为一个软件安装包,在需要使用前述第一方面或第一方面的任意可能的实现方式中提供的方法的情况下,可以下载该计算机程序产品并在计算设备上执行该计算机程序产品。
第七方面,本申请还提供一种计算机芯片,芯片与存储器相连,芯片用于读取并执行存储器中存储的软件程序,执行前述第一方面或第一方面的任意可能的实现方式中提供的方法。
图1A为本申请提供的一种代码元素的关系示意图;
图1B为本申请提供的一种部分串行部分并行模式的示意图;
图1C为本申请提供的另一种部分串行部分并行模式的示意图;
图2A为本申请提供的一种变更装置的结构示意图。
图2B为本申请提供的一种计算设备集群的结构示意图;
图2C为本申请提供的一种系统架构示意图;
图3为本申请提供的一种支持多变更的软件代码变更的方法示意图;
图4为本申请提供的一种提示用户输入待变更的软件代码的显示界面的示意图;
图5为本申请提供的一种变更模块140采用串行变更模式对待变更的软件代码进行变更方法示意图;
图6为本申请提供的一种变更模块140采用串行变更模式对待变更的软件代码进行变更流程示意图;
图7为本申请提供的一种生成变更器的中间变更实例集合的示意图;
图8为本申请提供的一种更新变更器的中间变更实例集合的示意图;
图9为本申请提供的一种显示变更后的软件代码的界面的示意图;
图10为本申请提供的另一种显示变更后的软件代码的界面的示意图。
在对本申请实施例提供的一种支持多变更的软件代码变更方法进行说明之前,先对本申请实施例涉及的概念进行说明:
(1)、软件代码,可执行代码,库,构建系统。
软件代码是程序员利用开发工具所支持的语言编写而成的。软件代码由一组具有指向意义的数字或字母构成。软件代码中包括多行代码,每行设置一个行号,通过行 号标识该行代码。
软件代码并不能在计算机上直接执行,需要通过构建系统根据构建文件中记录的配置信息调用编译器将软件代码转换为机器能够识别的二进制代码,该二进制代码也称为可执行代码。
库(library)是用于编写软件代码是可调用的代码集合,库中包括多个固定配置的代码,在编写软件程序时可以直接调用该库中的代码。库可以由第三方提供的,通过引用(调用)的方式嵌入软件代码中,提高代码的复用和开发效率。
构建系统(build system)是用于从软件代码生成机器识别的可执行程序的工具。为了构建目标,构建系统需要知道一些配置信息,如工具链组件的位置、软件代码的位置、库依赖、库的位置、库的版本等。这些配置信息通常在构建系统能够读取的构建文件中记录。
(2)、类,内部类,包,函数/方法,域/变量
软件代码在编写过程中需要满足一定编写规范,如面向对象程序编程(object-oriented programming,OOP)、面向过程程序编程(procedure-oriented programming,POP)等。面向对象程序编程的程序语言有C++,Java,C#等,面向过程程序编程的程序语言有fortran,C等。
采用一定编写规范所编写而成的软件代码中可以包括类、包、函数/方法、域/变量等代码元素。不同种类的代码元素之间关系可以参见图1A。其中,包中可以包括一个或多个类,每个类中可以包括内部类、函数/方法;函数/方法中可以调用域/变量。内部类与类相似,内部类中也可以包括函数/方法。
类(class)在面向对象编程中是一种面向对象计算机编程语言的构造,描述了所创建的对象共同的方法和域。
函数/方法(function/method)指的是类中的一种子程序。一个方法通常以一系列的语句所组成,并能够完成一个功能。在面向对象编程的编写规范中称为方法,在面向过程编程的编写规范中称为函数。
域/变量(field/variable)存储一些数据,如整数与字符,字符串、散列表、指针等。
包(package)用来说明某段程序的路径结构。一个包通常包含多个类,类引用的时候需要在包导入(import)区填写完整的包路径。
内部类(inner class)为包含在类中的类。
(3)、并行变更模式、串行变更模式以及部分串行或部分并行模式。
并行变更模式是指多个变更器同时对待变更的软件代码进行变更,之后将每个变更器对待变更的软件代码进行变更所产生的变更后的软件代码进行合并,产生最终的变更后的软件代码。
串行变更模式是指多个变更器依次对待变更的软件代码进行变更,每个变更器的输入为前一个变更器的输出,第一调用的变更器输入为待变更的软件代码。
部分串行或部分并行模式是并行变更模式与串行变更模式的结合,多个变更器中存在需要串行的变更器,也存在需要并行的变更器。部分串行或部分并行模式可以分为以并行模式为主的串并模式和以串行模式为主的串并模式。
如图1B所示,以并行模式为主的串并模式中可以分为多个变更器组合,每个变更器组合中存在一个或多个变更器。多个变更器组合同时对待变更的软件代码进行变更,之后将每个变更器组合对待变更的软件代码进行变更所产生的变更后的软件代码进行合并。多个变更器组合内部的多个变更器可以采用并行变更模式,也可以采用串行变更模式。
如图1C所示,以串行模式为主的串并模式中可以分为多个变更器组合,每个变更器组合中存在一个或多个变更器。多个变更器组合依次对待变更的软件代码进行变更,每个变更器组合的输入为前一个变更器组合的输出,第一调用的变更器组合输入为待变更的软件代码。多个变更器组合内部的多个变更器可以采用并行变更模式,也可以采用串行变更模式。
需要说明的是,上述两种部分串行或部分并行模式仅是举例,凡是存在多个串行调用的变更器以及多个并行调用的变更器的变更模式均属于部分串行或部分并行模式。
(4)、变更器,子变更器。
每个变更器用于对待变更的软件代码执行一种类型的变更,可以对待变更的软件代码中的一种代码元素(如类、方法、域等)进行变更,不同变更器所变更的代码元素不同。
此处列举一些在Java程序中库升级场景下常见的变更器:
a.类名变更器。在库升级场景下,当某个类的类名需要变更,该变更器可以对软件代码中该类的类名改为另一个类的类名。
b.方法名变更器。在库升级场景下,某个类中的某个方法的方法名需要变更,该变更器可以对软件代码中将类下的该方法的方法名改为该类中另一个方法的方法名。
c.域名变更器。在库升级场景下,某个类中的某个域的名称需要变更,该变更器可以对软件代码中将该类中的该域的名称改为该类中另一个域的名称。
d.库版本变更器。在库升级场景下,库的版本需要变更,该变更器可以对软件代码中将构建文件中该库的版本改为该库的另一个版本。
e.包名变更器。在库升级场景下,当某个包的包名需要变更,该变更器可以对软件代码中将该类的所有引用的包名改为另一个包的包名。
f.包删除变更器。在库升级场景下,当某个包需要删除,该变更器找到软件代码中该包的所有引用位置,并输出该包的所有引用位置。
g.类删除变更器。在库升级场景下,当某个类需要删除,该变更器找到软件代码中该类的所有引用位置,并输出该类的所有引用位置。
k.域删除变更器。在库升级场景下,当某个域需要删除,该变更器找到软件代码中该域的所有引用位置,并输出该域的所有引用位置。
l.方法删除变更器。在库升级场景下,当某个方法需要删除,该变更器找到软件代码中该方法的所有引用位置并提示给用户。
其中,三种名变更器(类名变更器、方法名变更器以及域名变更器)包括两个子变更器,每个子变更器用于对软件代码中特定区(如引用区以及包导入区)进行更改。以类名变更器为例,类名变更器可以分拆为类引用子变更器和包应用变更器。
其中,类引用子变更器。在库升级场景下,当某个类的类名需要变更,该子变更器可以对软件代码中将该类的所有引用的类名(也即引用区域内的该类的类名)改为另一个类的类名。
包导入子变更器。在库升级场景下,当某个类的类名需要变更,该子变更器可以对软件代码中将包导入区中该类的类名改为另一个类的类名。
变更器或子变更器可以理解为一个软件装置,该软件装置包括输入和输出,输入为需要变更的软件代码,输出为变更后的软件代码。
(5)、变更器的变更内容、直接变更内容以及延迟变更内容。
每个变更器在对软件代码进行变更时,通常是对该软件代码中的部分字段或一些格式进行变更。变更器对该软件代码进行变更时,需要变更的部分称为变更器的变更内容。
当多个变更器采用串行变更的模式对待变更的代码进行变更时,变更器的变更内容可以包括直接变更内容以及延迟变更内容。变更器的变更内容也可以只包括直接变更内容或延迟变更内容。
其中,直接变更内容是指可以直接对软件代码进行变更的部分,该部分的变更不会对后续变更器的变更产生影响。
相反的,延迟变更内容是指如果直接对软件代码进行变更,会对后续变更器的变更产生影响的部分。也就说,如果该部分内容进行变更,后续变更器在基于当前变更器变更后的软件代码执行变更时,会使得后续变更器不能执行正常的变更操作。延迟变更内容的类型可以使预先设置好的,当调用某一变更器对软件代码进行变更时,可以基于预设的延迟变更内容的类型,根据该变更器所进行的变更类型,确定该变更器的变更内容中是否存在延迟变更内容。
下面列举两种在库升级场景下两种类名变更器中的延迟变更内容,分别为内部类变更内容以及类拆分变更内容。
1、内部类变更内容。
若需要将待变更的软件代码中的第一类变更为第二类,且第一类中的一个或多个内部类需要变更到其他类中,其他类为除第一类外的类。这样,变更器将包导入区的第一类变更为第二类所产生的变更内容、以及将包导入区的第一类中的一个或多个内部类需要变更到其他类所产生的变更内容均可以作为变更器的内部类变更内容。
举例来说,当类A中存在多个内部类,分别为内部类B、内部类C以及内部类D,当需要将类A变更为类ZZ,且将内部类B、内部类C以及内部类D中的一个或多个变更到其他类中,如将内部类B变更到类ZZ中,内部类C变更到类F、内部类D变更到类Q。
例如,变更器1用于将类A变更为类ZZ,变更器2用于将内部类B变更到类ZZ中,变更器3用于将内部类C变更到类F中,变更器4用于将内部类D变更到类Q中。
若变更器1、变更器2、变更器3以及变更器4中的任一变更器对待变更的软件代码中的所有包导入(import)语句处涉及的内部类或类A进行变更,则会导致其他变更器在后续进行变更时,无法检测到需要变更的内部类的信息。例如,当变更器1先行将待变更的软件代码中的所有import语句处涉及的类A变更为类ZZ,当之后变更 器2、变更器3以及变更器4对变更器1变更后的软件代码继续变更时,则会由于在变更器1变更后的软件代码的包导入区中找不到类A,而无法查询到类A中的内部类,进而无法进行变更。
故而,变更器1、变更器2、变更器3以及变更器4针对包导入区的变更内容均属于内部类变更内容。
2、类拆分变更内容。
若需要将待变更的软件代码中的第一类变更为第二类,且第一类中的函数、方法或域需迁移至其他类。这样,将包导入区的第一类变更为第二类所产生的变更内容、以及将包导入区的第一类中的函数、方法或域需要变更到其他类所产生的变更内容均可以作为类拆分变更内容。
举例来说,当类A中存在域E和方法F,当需要将类A变更为类X,并将域E和方法F变更到其他类中,如将域E变更到类Y中,方法F变更到类Z。
例如,变更器5用于将类A变更为类X,变更器6用于将域E变更到类Y中,变更器7用于将方法F变更到类X中。
若变更器5、变更器6、变更器7中的任一变更器将待变更的软件代码中的所有包导入import语句处涉及的函数E、方法F或类A进行变更,则会导致其他变更器在后续进行变更时,无法检测到需要变更的内部类的信息。例如,当变更器5先行将待变更的软件代码中的所有import语句处涉及的类A变更为类X,当之后变更器6、以及变更器7对变更器1变更后的软件代码继续变更时,则会由于在变更器5变更后的软件代码的包导入区中找不到类A,无法查询到类A中的域E和方法F,进而无法进行变更。
故而,变更器5、变更器6、以及变更器7针对包导入区的变更内容均属于类拆分变更内容。
(6)、存在冲突的两个变更器。
存在冲突的两个变更器是指当这两个变更器对同一个软件代码进行变更,其中一个变更器的变更内容会对另一个变更器的变更产生影响。
在本申请实施例中,变更装置可以预先配置一个变更器集合,该变更器集合中包括一个或多个变更器,该变更器集合中的任意两个变更器均不存在冲突,当变更装置调用该变更集合中的变更器对待变更的软件代码进行变更时,可以采用并行变更模式调用该变更集合中的变更器对待变更的软件代码进行变更。
本申请实施例并不限定该变更器集合的配置方式,可以人工配置的,也可以是通过模拟仿真后,将能够并行调用的变更器放置在该变更器集合中。
(7)、原始变更实例集合、中间变更实例集合、目标变更实例集合。
变更器的原始变更实例集合中包括一个或多个变更实例,原始变更实例集合中的每个原始变更实例记录了变更器输入的软件代码(也就是该变更器的前一个变更器输出的软件代码)需要变更的一行以及该行变更后的内容。
变更器的中间变更实例集合中包括一个或多个变更实例,中间变更实例集合中的每个变更实例记录了该变更器对待变更的软件代码需要变更的一行以及该行变更后的内容。
原始变更实例集合和中间变更实例集合的区别在于作为基准的软件代码不同,原始变更实例集合是以该变更器输入的软件代码为基准的,中间变更实例集合是以待变更的软件代码为基准的,是以变更装置最初确定的待变更的软件代码为基准的。
当采用串行变更模式调用多个变更器对待变更的软件代码时,第一个被调用的变更器的原始变更实例集合和中间变更实例集合是相同的,第二个被调用的变更器的原始变更实例集合是以第一个调用的变更器输出的软件代码为基准的,第二个被调用的变更器的中间变更实例集合是以待变更的软件代码为基准的。
变更器的中间变更实例集合中的一个变更实例与变更器的原始变更实例集合的一个变更实例对应,变更器的中间变更实例集合中一个变更实例是基于变更器的原始变更实例集合种对应的一个变更实例生成的,根据该变更器之前调用的变更器的中间变更实例集合确定,具体的确定方式,可以参见下文实施例中的描述。
变更器的目标变更实例集合是消除了变更器之间的冲突之后所产生的,目标变更实例包括一个或多个变更实例,目标变更实例集合中的每个变更实例记录了变更器输入的软件代码(也就是该变更器的前一个变更器输出的软件代码)需要变更的一行以及该行变更后的内容。
原始变更实例集合和目标变更实例集合中包括的变更实例可能相同,目标变更实例集合也可以只包括原始变更实例集合中的部分变更实例。变更器的目标变更实例集合中的变更实例记录了该变更器在对输入的软件代码进行变更时,实际执行变更时所产生的直接变更内容。变更器的原始变更实例集合中的变更实例记录了该变更器在对输入的软件代码进行变更时,预计需要执行变更时所产生的变更内容,由于在消除变更器之间的冲突的过程中,会删除一些变更实例,故而导致目标变更实例集合中只能包括原始变更实例集合中的部分变更实例。
在本申请实施例中,变更装置需要对每个变更器维持一个中间变更实例集合,基于变更器的中间变更实例集合,变更装置能够利用变更器的属性消除了变更器之间的冲突,确定变更器的中间变更实例集合中需要删除的变更实例,变更装置可以将消除了变更器之间的冲突后、所需调用的变更器中间变更实例集合(若存在需要删除的变更实例,消除了变更器之间的冲突后,变更器的中间变更实例集合为已删除的变更实例的中间变更实例集合)汇总,汇总后的中间变更实例集合(为方便说明可以简称为总变更实例集合)保存起来,并通过显示屏显示给用户。
换句话说,总变更实例集合包括多个变更实例,是以待变更的软件代码为基准的,记录了变更装置在采用串行变更模式调用多个变更器时,对待变更的软件代码实际执行变更时所产生的变更内容。
当然,变更装置利用变更器的属性消除了变更器之间的冲突,删除掉变更器的中间变更实例集合中的一个或多个变更实例时,也可以在变更器的原始变更实例集合中删除对应的一个或多个变更实例,产生该变更器的目标变更实例集合。
由于软件代码变更的场景众多,本申请中以库升级的场景为例进行阐述。以下列举了两种库升级场景中的变更类型:
变更类型1、当某个库函数的形式参数发生改变时,需要对软件代码中该库函数 所有的调用点的实际参数作更改。这种类型的变更需要对待变更的软件代码中该库函数调用的实际参数均进行变更。
变更类型2、当某个库函数名称发生改变时,需要将软件代码中一个库函数名称更改为另一个库函数名称。这种类型的变更需要对待变更的软件代码中所有出现的特定的库函数名称改为另一个库函数名称。
目前,对软件代码进行变更时,一次执行一种变更类型的变更。若需要执行多种变更类型的变更,只能分别对软件代码执行不同的变更类型的变更,导致软件代码的变更方式较不灵活。
为此本申请实施例提供了一种支持多变更的软件代码变更方法,在本申请实施例中,变更装置可以根据用户对待变更的软件代码的变更配置信息选择变更器、设置变更器的调用顺序以及各个变更器的属性,之后,变更装置按照设置的调用顺序,依次调用各个变更器进行变更,其中,第一个被调用的变更器的输入为待变更的软件代码,除第一个被调用的变更器外的任一变更器的输入为前一个变更器的输出。
采用本申请实施例的方式,变更装置能够根据用户的变更配置信息,调用多个不同的变更器,在待变更的软件代码上实现多种不同类型的变更,能够灵活的组建多个不同的变更器对待变更的软件代码进行变更,有利于提高软件代码的变更效率。
本申请实施例提供的一种支持多变更的软件代码变更方法由变更装置执行,本申请实施例并不限定变更装置的部署位置,变更装置可以部署在云端,如变更装置可以是云端服务器;变更装置也可以是创建在云端服务器中的虚拟机;变更装置还可以是部署在云端服务器或者虚拟机上的软件装置,该软件装置用于对待变更的软件代码进行多种不同类型的变更,该软件装置可以分布式地部署在多个服务器上、或者分布式地部署在多个虚拟机上、或者分布式地部署在虚拟机和服务器上。
图2A所示,为本申请实施例提供的一种变更装置100,该变更装置包括导入模块110、变更器库120、配置模块130、以及变更模块140。
导入模块110用于确定待变更的软件代码,以及用户对该待变更的软件代码的变更配置信息。
变更器库120中存储有多个变更器,其中,部分变更器(例如名变更器)包括一个或多个子变更器,每个变更器能够执行一种代码元素的变更。
配置模块130可以根据变更配置信息从变更器库120中选择变更器,并配置调用模式,如选择串行变更模式或并行变更模式,还可以配置每个变更器的属性。
配置模块130在选择了调用模式后,变更模块140可以基于配置模块130选择的调用模式,调用配置模块130选择的变更器,对该待变更的软件代码进行变更。
变更模块140在调用配置模块130选择的变更器,对该待变更的软件代码进行变更的过程中,每个变更器可以对输入该变更器的软件代码进行变更。
变更装置100中包括的各个模块可以为软件模块。
下面对本申请实施例所适用于的系统架构进行说明,如图2B所示,为本申请实施例提供的一种计算机集群,该计算机集群中包括至少一个计算设备100,每个计算设备100间通过通信网络建立通信通路。
每个计算设备100中包括总线101、处理器102、通信接口103以及存储器104。可选的,计算设备10中还可以包括显示屏105。处理器102、存储器104和通信接口103之间通过总线101通信。
其中,处理器102可以由一个或者多个通用处理器构成,例如中央处理器(central processing unit,CPU),或者CPU和硬件芯片的组合。上述硬件芯片可以是专用集成电路(application-specific integrated circuit,ASIC)、可编程逻辑器件(programmable logic device,PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(complex programmable logic device,CPLD)、现场可编程逻辑门阵列(field-programmable gate array,FPGA)、通用阵列逻辑(generic array logic,GAL)或其任意组合。
存储器104可以包括易失性存储器(volatile memory),例如随机存取存储器(random access memory,RAM)。存储器104还可以包括非易失性存储器(non-volatile memory,NVM),例如只读存储器(read-only memory,ROM),快闪存储器,硬盘(hard disk drive,HDD)或固态硬盘(solid-state drive,SSD)。存储器104还可以包括上述种类的组合。
存储器104中存储存可执行代码,处理器102可以读取存储器104中的该可执行代码实现功能,还可以通过通信接口103与其他计算设备进行通信,处理器102还可以触发显示屏105向用户显示信息,如本申请实施例中如图4、9、10所示的界面中包括的信息。
在本申请实施例中,处理器102可以实现变更装置100的一个或多个模块(如导入模块110、变更器库120、配置模块130、以及变更模块140中的一个或多个模块)的功能,这种情况下,存储器104中存储有变更装置100的一个或多个模块(如导入模块110、变更器库120、配置模块130、以及变更模块140中的一个或多个模块)。
在本申请实施例中,多个计算设备10中的处理器101可以协调工作,执行本申请实施例提供的支持多变更的软件代码变更方法。
需要说明的是,当存储器104中存储有变更模块140时,该变更模块140中还包括缓存空间,该缓存空间位于存储器104中,该缓存空间可以用于存储第一个被调用的变更器对待变更的软件代码进行分析获得的分析结果,以及各个被调用的变更器的延迟变更内容。
如图2C所示,为本申请实施例提供的一种系统架构,该系统架构中包括客户端200和部署有变更装置的云端设备300,客户端200与云端设备300通过网络连接,该云端设备300位于云环境中,可以是部署在云数据中心中的服务器或者虚拟机,图2C中,仅是以该变更装置部署在一个云端设备300为例,作为一种可能的实施方式,该变更装置可以分布式地部署在多个云端设备300上。
如图2C所示,客户端200包括总线201、处理器202、通信接口203、存储器204。可选的包括客户端200还包括显示屏205。处理器202、存储器204和通信接口203之间通过总线201通信。其中,处理器202和存储器204的类型可以参见处理器102以及存储器104的相关说明,此处不再赘述。存储器204中存储存可执行代码,处理器202可以读取存储器204中的该可执行代码实现功能。处理器202还可以触发显示 屏205向用户显示信息,如本申请实施例中如图4、9、10所示的界面中包括的信息。处理器202还可以通过通信接口203与云端设备进行通信。例如处理器202可以通过显示屏提示用于输入待变更的软件代码以及变更配置信息,并在用户的触发下,确定待变更的软件代码以及变更配置信息;通过通信接口203将待变更的软件代码以及变更配置信息反馈给云端设备300。
如图2C所示,云端设备300包括总线301、处理器302、通信接口303以及存储器304。处理器302、存储器304和通信接口303之间通过总线301通信。其中,处理器302和存储器304的类型可以参见处理器102以及存储器104的相关说明,此处不再赘述。存储器304中存储存可执行代码,处理器302可以读取存储器304中的该可执行代码实现功能,还可以通过通信接口303与客户端200进行通信。在本申请实施例中,参考图2B,可以由多个云端设备300的处理器302配合实现变更装置300的功能,这种情况下,存储器304中存储有变更装置300的导入模块130、变更器库120、配置模块130、以及变更模块140中的一个或多个模块。
需要说明的是,当存储器304中存储有变更模块140时,该变更模块140中还包括缓存空间,该缓存空间位于存储器304中,该缓存空间可以用于存储第一个被调用的变更器对待变更的软件代码进行分析获得的分析结果,以及各个被调用的变更器的延迟变更内容。
处理器302通过通信接口303从客户端200接收到待变更的软件代码以及变更配置信息后,可以调用存储器304中存储的模块实现本申请实施例提供的代码变更方法,生成变更后的软件代码,处理器302可以通过通信接口303向客户端200发送该变更后的软件代码。可选的,处理器302还可以确定所调用的所有变更器的直接变更内容以及延迟变更内容,通过通信接口303向客户端200发送所调用的所有变更器的直接变更内容以及延迟变更内容。
客户端200中处理器202通过通信接口203在接收到变更后的软件代码以及所调用的所有变更器的直接变更内容以及延迟变更内容后,处理器202可以触发显示屏205向用户显示变更后的软件代码以及所调用的所有变更器的直接变更内容以及延迟变更内容
下面结合图3对本申请实施例提供的一种支持多变更的软件代码变更方法进行说明。参见图3,该方法包括:
步骤301:导入模块110确定待变更的软件代码以及用户对待变更的软件代码的变更配置信息。
该变更配置信息包括待变更的代码元素、对待变更的代码元素的变更方式(如修改或删除)以及待变更的代码元素对应的变更后的代码元素。
需要说明的是,对于需要将一个待变更的代码元素删除的变更,该待变更的代码元素对应的变更后的代码元素为空值。
本申请实施例并不限定待变更的代码元素的数量,可以是一个也可以是多个。该变更配置信息可以是用户配置的,也可以固定的,本申请实施例并不限定。
需要说明的是,在本申请实施例中以该变更配置信息包括多个待变更的代码元素 为例进行说明,当该变更配置信息包括一个待变更的代码元素时,配置模块130只需从变更器库120中选取能对该待变更的代码元素执行相应变更的变更器,变更模块140只需要调用该变更器对待变更的软件代码进行变更即可。
导入模块110确定待变更的软件代码或该变更配置信息的方式有许多种,例如,用户可以触发终端设备向导入模块110发送携带有待变更的软件代码以及该变更配置信息的请求消息,还请求消息用于请求变更装置100对待变更的软件代码执行变更。
又例如,用户可以将待变更的软件代码导入到导入模块110,并在导入模块110的提醒下设置该变更配置信息。
其中,待变更的软件代码可以是整个软件的代码(多个目录中的所有文件),也可以是整个软件的代码中用于实现某一特定功能的代码(某个特定目录中的所有文件),还可以是整个软件的代码中某个特定的代码文件。
作为一种可能的实施方式,用户可以将整个软件的代码文件导入到导入模块110中,用户可以在导入模块110的提醒下从整个代码文件中选择选取不需要变更的软件代码,将剩余的软件代码作为待变更的软件代码,如图4所示,用户输入不需要变更的软件代码的存储路径,以使得导入模块110可以从整个软件的代码文件中的部分代码确定待变更代码。
作为一种可能的实施方式,变更配置信息还可以包括其他信息,其他信息包括以下的部分或全部:需要调用的变更器的标识(Identity,ID)、待变更的软件代码的变更模式(如串行变更模式、并行变更模式或部分串行部分并行模式)。
可选的,当待变更的软件代码的变更模为串行变更模式或部分串行部分并行模式时,该变更配置信息还可以包括变更器的调用顺序以及每个变更器的属性。
在本申请实施例中,用户在确定需要对待变更的软件代码进行变更时,可以自行选择对待变更的软件代码进行变更时,需要调用的变更器。本申请实施例并不限定用户自行选择的需要调用的变更器的数量,用户选择的变更器可以只对该变更配置信息中的部分待变更的代码元素执行变更,针对该变更配置信息中的其余待变更的代码元素执行变更所需的变更器,可以交于配置模块130进行选择,选择的方式可以参见步骤302。
用户也可以自行选择待变更的软件代码的变更模式,例如,当用户确定对待变更的软件代码中的多个待变更的软件元素的变更之间不存在冲突,则可以选择并行变更模式。当用户确定对待变更的软件代码中的多个待变更的软件元素的变更之间存在冲突,则可以选择串行变更模式。
当用户选择采用串行变更模式或部分串行部分并行模式时,用户还可以对选择的多个变更器设置调用顺序以及每个变更器的属性。
本申请实施例中,对每个变更器可以设置属性,属性的可选项分别为合并变更属性、忽略变更属性以及覆盖变更属性。
其中,合并变更属性用于表述否对该变更器以及该变更器之前调用的变更器对特定行的变更进行合并,两个变更器对待变更的软件代码的相同的一行或多行简称为特定行。该变更器的合并变更属性可以设置为真(true)或假(false),当合并变更属性为真(true)表示对该变更器以及该变更器之前调用的变更器对待变更的软件代码 的特定行的变更进行合并;当合并变更属性为假(false)表示对该变更器以及该变更器之前调用的变更器对特定行的变更不进行合并,这种情况需要查看覆盖变更属性。
忽略变更属性用于描述否忽略该变更器对待变更的软件代码的其他行的变更。其他行是指待变更的软件代码中除特定行外的行。该变更器的忽略变更属性可以设置为真(true)或假(false),当忽略变更属性为真(true)表示对该变更器对其他行的变更进行忽略;当忽略变更属性为假(false)表示对该变更器对其他行的变更不进行忽略。
覆盖变更属性用于描述是否覆盖该变更器之前调用的变更器对待变更的软件代码的特定行的变更。该变更器的覆盖变更属性可以设置为真(true)或假(false),当覆盖变更属性为真(true)表示对该变更器之前调用的变更器对特定行的变更进行覆盖,也就是说,该变更器之前调用的变更器对特定行的变更无效,只保留该变更器对特定行的变更;当覆盖变更属性为假(false)表示对该变更器之前调用的变更器对特定行的变更不进行覆盖,这种情况需要查看合并变更属性。
当用户通过设置每个变更器的属性可以提前对多个变更器对待变更的软件代码的相同的一行或多行进行变更时所可能产生的冲突做规避,便于之后变更模块140在调用各个变更器时,每个变更器可以较快速的进行变更。
步骤302:配置模块130根据该变更配置信息从变更器库120中选择变更器。
若该变更配置信息包括待变更的代码元素、对待变更的代码元素的变更方式(如修改或删除)以及待变更的代码元素对应的变更后的代码元素。由于不同变更器用于变更不同的代码元素,配置模块130可以根据待变更的代码元素从变更器库120中选择能将待变更的代码元素变更为对应的变更后的代码元素的变更器。本申请实施例并不限定配置模块130所选择的变更器的数量,变更器的数量与该变更器配置信息有关。
若该变更配置信息还包括需要调用的变更器的ID,配置模块130可以根据变更器的ID从变更器库120中选择需要调用的变更器。若该变更配置信息中包括的需要调用的变更器的ID对应的变更器只能实现对部分待变更的代码元素的变更,配置模块130则还需要从变更器库120中选择能将剩余待变更的代码元素变更为对应的变更后的代码元素的变更器。本申请实施例并不限定配置模块130所选择的变更器的数量,变更器的数量与该变更器配置信息中剩余的待变更的代码元素的数量有关。
步骤303:配置模块130根据该变更配置信息确定待变更的软件代码的变更模式,如选择串行变更模式、并行变更模式或部分串行或部分并行模式。
若该变更配置信息包括待变更的软件代码的变更模式,配置模块130可以根据该变更配置信息直接确定该待变更的软件代码的变更模式。
若该变更配置信息不包括待变更的软件代码的变更模式。配置模块130可以根据选择的变更器确定待变更的软件代码的变更模式。
配置模块130在选择了多个变更器后,判断选择的多个变更器中是否存在冲突的两个变更器。若不存在冲突的两个变更器,配置模块130可以采用并行变更模式,否则采用串行变更模式或部分串行部分并行模式(其中存在冲突的变更器采用串行的方式,不存在冲突的变更器采用并行的模式)。
当待变更的软件代码的变更模式为串行变更模式或部分串行部分并行模式时,配 置模块130还可以设置变更器的调用顺序以及每个变更器的属性。
若该变更配置信息包括变更器的调用顺序以及每个变更器的属性,则配置模块130可以直接根据该变更配置信息设置变更器的调用顺序以及每个变更器的属性。
若该变更配置信息不包括变更器的调用顺序以及每个变更器的属性,则配置模块130可以先设置该多个变更器的调用顺序,之后,再基于该调用顺序配置每个变更器的属性。
本申请实施例并不限定调用顺序的设置方式。例如,配置模块130可以对变更器库120中的多个变更器设置优先级,优先级高的变更器需要先调用,优先级低的变更器后调用。配置模块130可以根据该多个变更器的优先级确定调用顺序。
又例如,配置模块130中预先保留多种调用方案,每种调用方案中可以包括所有变更器,也可以包括部分变更器。配置模块130可以根据多个变更器与多种调用方案进行匹配,获得目标调用方案,目标调用方案中包括该多个变更器,目标调用方案还可以包括该多个变更器之外的其他变更器。
配置模块130可以按照目标调用方案中该多个变更器的先后顺序确定该多个变更器的调用顺序。
举例来说,例如变更器库120中预先保存了五种不同的变更器,分别为变更器A、变更器B、变更器C、变更器D、变更器E,并配置模块130预先配置了三种调用方案,其中,方案一:A->B->D->E->C;方案二:A->B->D->E;方案三:A->D->E->C。
配置模块130选择的变更器为变更器A、变更器B、变更器C,只有方案一包括变更器A、变更器B、变更器C,则方案一即为目标调用方案。由于没有选择变更器D和变更器E,则方案一可以转换为A->B->C,配置模块130配置的调用顺序为A->B->C。
当然,前述调用顺序的确定方式仅是举例说明,本申请实施例并不限定配置模块130确定调用顺序的方式,作为一种可能的实施方式,配置模块130也可以采用随机的方式,确定该多个变更器的调用顺序。
配置模块130在确定了该多个变更器的调用顺序之后,可以基于该调用顺序(和该变更配置信息)设置除第一个被调用的变更器之外的变更器的属性。
配置模块130可以预先保存变更器的属性配置方案,对于一个变更器的属性配置方案中记录了该变更器与其他变更器(该其他变更器为与该变更器可能存在冲突的变更器)的调用的先后顺序,以及在该先后顺序下,该变更器的属性。配置模块130基于该多个变更器的调用属性,根据变更器的属性配置方案设置该变更器的属性。
例如,变更器A、变更器B以及变更器C,变更器B的属性配置方案如下:当变更器B的调用顺序先于变更器A,则变更器B的三个属性均设置为假,若变更器A的调用顺序先于变更器B,则变更器B的合并变更属性为真,忽略该变更属性以及覆盖该变更属性为假。变更器C的属性配置方案如下:当变更器C的调用顺序先于变更器B,则变更器C的三个属性均设置为假,若变更器B的调用顺序先于变更器C,则变更器C的的合并变更属性和忽略该变更属性为假,以及覆盖该变更属性为真。
若配置模块130确定的该多个变更器的调用顺序为A->B->C,则变更器B的合并变更属性为真,忽略该变更属性以及覆盖该变更属性为假,变更器C的的合并变更属性和忽略该变更属性为假,以及覆盖该变更属性为真,由于变更器A为调用的第一个 变更器,第一被调用的变更器并不存在在该变更器之前调用的变更器,所以配置模块130可以不设置变更器A的属性。
步骤304:变更模块140基于待变更的软件代码的变更模式,调用该多个变更器,对待变更的软件代码进行变更。
下面分别对并行变更模式以及串行变更模式下,变更模块140调用该多个变更器,对待变更的软件代码进行变更的方式进行说明。
对于部分串行部分并行模式,其实质上是并行变更模式以及串行变更模式的结合,部分串行部分并行模式下变更模块140调用该多个变更器,对待变更的软件代码进行变更的方式可以参见如下的方式一和方式二的说明,对于部分串行部分并行模式中并行的多个变更器,变更模块140采用方式一,调用该多个变更器,对输入到该多个变更器的软件代码进行变更;对于部分串行部分并行模式中串行的多个变更器(或变更器组合),变更模块140采用方式一,调用该多个变更器(或变更器组合),对输入到该多个变更器(或变更器组合)的软件代码进行变更。具体可参见下述说明,此处不再赘述。
方式一、基于并行变更模式,同时调用该多个变更器,对待变更的软件代码进行变更。
在并行变更模式下,变更模块140可以调用多个变更器同时对待变更的软件代码进行变更,在该多个变更器中的每个变更器变更结束后,可以将每个变更器所产生的变更后的软件代码进行合并,合并后的软件代码即为最终的变更后的软件代码。
示例性的,变更模块140可以确定每个变更器的变更内容,例如确定每个变更器对待变更的软件代码进行变更时,变更的一行或多行代码。将待变更的软件代码中每个变更器的变更内容对应位置的软件代码替换为每个变更器的变更内容,获取最终的变更后的软件代码。
方式二、基于串行变更模式,依次调用该多个变更器,对待变更的软件代码进行变更。
当多个不同的变更器采用串行的方式对待变更的软件代码进行变更时,不同变更器产生的变更内容需要采样一种较为便捷的方式进行合并,而现有的对软件代码的变更方式,并不能将不同变更器产生的变更内容进行合并。
例如,对软件代码进行变更类型1的变更时,针对函数P的形式参数作更改,将待变更的软件代码中函数P调用的形式参数均进行变更,生成变更后的软件代码1。对软件代码进行变更类型2的变更时,针对函数P作更改,将待变更的软件代码中的函数P更改为函数Q,生成变更后的软件代码2。由于变更后的软件代码2中不存在函数P,故而不能简单的将变更后的软件代码1和变更后的软件代码2进行合并。也就是说,对软件代码进行不同变更类型的变更,产生的变更内容之间容易存在冲突,不能简单合并。应需理解的是,上述举例仅是一种较为简化的情况,在实际对软件代码进行变更时,对软件代码进行不同变更类型的变更,产生的变更内容之间的冲突更加明显,合并难度更大。
由上可知,为了能够支持多变更类型的变更,需要解决对软件代码进行不同变更类型的变更之间的存在的冲突,需要更加高效、便捷的对软件代码进行不同变更类型 的变更所产生的变更内容进行合并。
在本申请实施例中,变更模块140在调用任一变更器对输入到该变更器的软件代码进行变更时,确定该变更器是否存在直接变更内容或延迟变更内容,若存在,将该变更器的直接变更内容直接应用在待变更的软件代码上,保留该变更器的延迟变更内容延迟,直至所有变更器调用完成后,统一将调用的多个变更器的延迟变更内容应用在最后一个变更器输出的软件代码上,获得变更后的软件代码。在调用每个变更器时,区分每个变更器的变更内容中的直接变更内容和可能存在变更冲突的延迟变更内容,将多个变更器产生的延迟变更内容统一在最后应用在待变更的软件代码上,能够有效避免不同变更器在调用过程中直接进行变更引起的冲突。
如图5所示,为变更模块140采用串行变更模式对待变更的软件代码进行变更的方法示意图。该方法包括:
步骤501:变更模块140按照该多个变更器的调用顺序依次调用该多个变更器对待变更的软件代码进行变更,每一个变更器的输入为前一个变更器的输出,待变更的软件代码为第一个调用的变更器的输入。
步骤502:变更模块140在调用一个变更器对输入该变更器的软件代码进行变更时,确定该变更器的变更内容中是否存在直接变更内容以及延迟变更内容。
步骤503:变更模块140将该变更器的直接变更内容直接应用在该变更器输入的软件代码中。
步骤504:若该变更器存在延迟变更内容,变更模块140保留该变更器的延迟变更内容。如可以将该变更器的延迟变更内容保存起来。
步骤505:直至所有变更器调用完成后,变更模块140统一将这多个变更器的延迟变更内容应用在最后一个变更器输出的软件代码上,生成变更后的软件代码。
为了更加直观呈现变更模块140采用串行变更模式对待变更的软件代码进行变更的方法,可以参见图6。图6为变更模块140采用串行变更模式对待变更的软件代码进行变更的流程图,变更模块140按照A->B->C的调用顺序依次调用变更器A、变更器B以及变更器。
变更模块140将待变更的软件代码输入到变更器A,在调用变更器A时,确定变更器A的变更内容中是否存在直接变更内容以及延迟变更内容,若存在直接变更内容,则变更模块140将直接变更内容应用到待变更的软件代码上(1),变更后的软件代码即为变更器A输出的软件代码。若存在延迟变更内容,变更模块140保留延迟变更内容(2)。变更器A在对待变更的软件代码进行变更时,还可以保存对待变更的软件代码的分析结果(3),该分析结果包括待变更的软件代码中所有代码元素的位置(关于分析结果的描述可以参见下文中的描述,此处不再赘述)。
之后,变更模块140将变更器A输出软件代码输入至变更器B,变更模块140调用变更器B时,确定变更器B的变更内容中是否存在直接变更内容以及延迟变更内容,若存在直接变更内容,则变更模块140将直接变更内容应用到输入到变更器B的软件代码上(5),变更后的软件代码即为变更器B输出的软件代码。若存在延迟变更内容,变更模块140保留延迟变更内容(6)。变更器B在对输入到变更器B的软件代码时,还可以调用变更器A保存的分析结果(3),基于分析结果,确定对输入到变更器B 的软件代码的变更位置。
之后,变更模块140将变更器B输出软件代码输入至变更器C,变更模块140调用变更器C时,确定变更器C的变更内容中是否存在直接变更内容以及延迟变更内容,若存在直接变更内容,则变更模块140将直接变更内容应用到输入到变更器C的软件代码上(8),变更后的软件代码即为变更器C输出的软件代码。若存在延迟变更内容,变更模块140保留延迟变更内容(9)。变更器C在对输入到变更器C的软件代码时,还可以调用变更器A保存的分析结果(7),基于分析结果,确定对输入到变更器C的软件代码的变更位置。
最后,变更模块140统一将这多个变更器的延迟变更内容应用在变更器C输出的软件代码上,生成变更后的软件代码。
在执行步骤502时,当变更模块140调用多个变更器的任一变更器对输入到该变更器的软件代码进行变更时,变更模块140可以根据预先设定的延迟变更内容(如内部类变更内容以及类拆分变更内容)确定该变更器的变更内容中是否存在延迟变更内容,若存在延迟变更内容,则保留该延迟变更内容,若不存在延迟变更内容,则变更模块140确定该变更器的直接变更内容。
这里需要注意的时,虽然从变更器的变更内容中保留了该变更器的延迟变更内容,但是变更器之间还可能存在一些潜在的冲突,这些潜在的冲突可能导致该变更器的变更内容中除了延迟变更内容中之外的内容只有一部分可以能够应用在输入至该变更器的软件代码(该部分即为直接变更内容),而不能应用在输入至该变更器的软件代码会被删除。
变更模块140确定变更器的变更器内容中的直接变更内容时,需要借助调用的变更器的属性,基于变更器的部分或全部属性确定该变更器的之间变更内容,下面对变更模块140确定该变更器的直接变更内容的方式进行说明:
步骤1:变更模块140每调用一个变更器,确定该变更器的原始变更实例集合。
步骤2:变更模块140基于该变更器的原始变更实例集合以及该变更器之前调用的变更器的原始变更实例集合,生成该变更器的中间变更实例集合。
对于变更器的原始变更实例集合中的一个变更实例1,该变更实例1记录了需要变更的行号1,变更模块140可以从该变更器之前调用的变更器的原始变更实例集合中,查找行号1之前所有的行号变化,行号变化包括但不限于:从该变更器之前调用的变更器增加或删除行导致的行号变化。
变更模块140可以通过累加的方式计算该变更器之前调用的变更器对待变更的软件代码进行变更所引起的行变化数量,例如,若该变更器之前调用的变更器增加N个行号,则累加的数值为正数,为N;若该变更器之前调用的变更器删除M个行号,则累加的数值为负数,为-M。
变更模块140将该变更器的变更实例1中记录行号1减去该行变化数量,确定当以待变更的软件代码为基准时,该变更器需要变更的行号2,进而生成该变更器的中间变更实例集合中变更实例1对于的变更实例2(其中行号为行号2,该行变更后的内容与变更实例1中记录的行号1的行变更后的内容相同)。采用上述方式,可以生成 该变更器的中间变更实例集合中所有的变更实例。
如图7所示为串行的三个变更器,分别为变更器A、变更器B、变更器C,每个变更器下面标注了每个变更器对输入该变更器的软件代码进行变更时,需要变更的行号以及变更的后的内容(可以看做为每个变更器的原始变更实例集合),以操作(数值1,数值2)标识,操作可以分为增加(add)、修改(modify)以及删除(delete)数值1表示行号,数值2表示操作的行数,比如增加(3,2)表示在输入该变更器的软件代码的第3行插入2行代码,删除(4,1)表示在输入该变更器的软件代码的第4行删除1行代码,修改(6,1)表示在输入该变更器的软件代码的第6行修改1行代码(也就是行数不增不减)。
变更器B的一个操作为增加(2,1),由于它之前的变更器(变更器A)在对待变更的软件代码进行变更时,都是针对第2行的代码进行变更,也就是说该操作中的行号没有发生变化。变更器B的另一个操作为修改(6,1),可以看到变更器A在对待变更的软件代码进行变更时,在第6行之前插入了2行,删除了1行,行变化数量为1,因此,变更器B的另一个操作为修改(6,1),若以待变更的软件代码进行变更,应该为修改(5,1),同理,变更器C的操作修改(8,1)变更为修改(6,1)。
步骤3:变更模块140基于该变更器的属性、以及该变更器的中间变更实例集合以及该变更器之前调用变更器的中间变更实例集合,生成该变更器的目标变更实例集合。
步骤4:变更模块140生成该变更器的目标变更实例集合后,可以利用该变更器的目标变更实例集合对输入至该变更器的软件代码进行变更。
在获取了一个变更器的中间变更实例集合后,变更模块140可以基于该变更器的中间变更实例以及该变更器之前调用变更器的中间变更实例确定该变更器和该变更器之前调用变更器是否会对待变更的软件代码的相同的一行或多行代码进行变更,若该变更器和该变更器之前调用变更器对待变更的软件代码的相同的一行或多行代码进行变更,该种变更容易引发变更器之间的冲突,需要消除这种冲突。
下面对消除两个变更器对待变更的软件代码的相同的一行或多行(为方便说明,同一行或多行简称为特定行)进行变更所引起的冲突的方式进行说明。
变更模块140可以根据该变更器的合并变更属性,确定是否需要该变更器以及该变更器之前调用的变更器对特定行的变更进行合并,如果需要进行合并,则可以在该变更器的中间变更实例中保留该特定行对应的变更实例,保留该变更器的原始变更实例中保留该特定行对应的变更实例。
变更模块140可以根据该变更器的忽略变更属性,确定是否忽略该变更器对待变更的软件代码的其他行的变更;如果需要忽略,则可以在该变更器的中间变更实例中删除该其他行对应的变更实例,删除该变更器的原始变更实例中该其他行对应的变更实例。
变更模块140可以根据该变更器的覆盖变更属性,确定覆盖该变更器之前调用的变更器对待变更的软件代码的特定行的变更。如果需要覆盖,则变更模块140可以在该变更器的中间变更实例中保留该特定行对应的变更实例,可以保留该变更器的中间变更实例中该特定行对应的变更实例。
变更模块140在根据该变更器各个属性,对该变更器的原始变更实例集合进行更新(如删除变更实例或保留变更实例),更新后的该变更器的原始变更实例集合即为该变更器的目标变更实例集合。
变更模块140在根据该变更器各个属性,对该变更器的中间变更实例集合更新(如删除变更实例或保留变更实例)后,可以将更新后的将该变更器的中间变更实例集合中的变更实例添加到总变更实例集合中。
举例来说,如图8所示,为串行的三个变更器,分别为变更器E、变更器F、变更器G,每个变更器下面标注了每个变更器对待变更的软件代码进行变更时,需要变更的行号以及变更后的内容(可以看做为每个变更器的中间变更实例集合),标注方式与图5所示的实施例相同,此处不再赘述。其中,图8中,m1、m2、m3、m4以及m5用于指示修改的内容,仅是区分不同的修改。变更器F、变更器G上面标注了合并变更属性、忽略该变更属性以及覆盖该变更属性的真或假。变更器B的合并变更属性为真,忽略该变更属性以及覆盖该变更属性为假。变更器C的合并变更属性和忽略该变更属性为假,以及覆盖该变更属性为真。
图8中,变更器F的一个变更实例为修改(4,m3),变更器E的一个变更实例为修改(4,m2),也就是说变更器E对第4行也有修改,由于变更器F的合并变更属性为true,需要变更器B和变更器E的变更需要进行合并,需要同时保留变更器E和变更器F的该变更实例,在变更器B的中间变更实例中保留修改(4,m3)这一变更实例,保留该变更器F的原始变更实例集合中保留修改(4,m3)这一变更实例对应的变更实例。更新后的变更器F的原始变更实例集合即为变更器F的目标实例集合。
变更器G的一个变更实例为修改(1,m4),可以看到之前的变更器G之前调用的变更器(变更器E和变更器F)都没有对第1行进行修改,且变更器G的忽略变更属性为true,在该变更器G的中间变更实例集合中删除修改(1,m4)这一变更实例,删除该变更器G的原始变更实例集合中修改(1,m4)这一变更实例对应的变更实例。变更器G的另一个操作为修改(3,m5),且变更器A也对第3行做了修改,且变更器G的覆盖变更属性为true,变更模块140保留该变更器G的中间变更实例集合中修改(3,m5)这一变更实例,变更模块140保留该变更器G的原始变更实例集合中修改(3,m5)这一变更实例对应的变更实例。更新后的变更器G的原始变更实例集合即为变更器G的目标实例集合。
变更器可以将更新后的该变更器E的中间变更实例集合、该变更器F的中间变更实例集合以及该变更器G的中间变更实例集合中的变更实例也添加到总变更实例集合中。总变更实例集合中包括修改(4,m2)、修改(3,m1)、修改(4,m3)以及修改(3,m5)。
作为一种可能的实施方式,可以将变更器F的变更实例修改(4,m3)和变更器E的变更实例修改(4,m2)进行合并,也就是说,合并后的变更实例为修改(4,[m2,m3])。该合并后的变更实例修改(4,[m2,m3])替换总变更实例集合中的修改(4,m2)和修改(4,m3)。
作为一种可能的实施方式,每个变更器在对输入的软件代码进行变更时,需要先输入的软件代码进行分析,分析输入的软件代码中所有代码元素的位置,找到待变更 的代码元素的位置(如一行或多行),对该位置的待变更的代码元素进行变更。
对于两个变更器,对待变更的软件代码进行变更时,可能变更的位置(如行)是相同的,例如,在库升级场景下,某个方法的名称发生变化,同时它的形式参数也发生变化,需要变更方法名称的变更器和变更方法实际参数的变更器。通常方法名称和方法实际参数的变更位置(行)是相同的,此时两个变更器就存在冲突。
而每个变更器在对输入的软件代码进行变更时,通常需要先对输入的软件代码进行分析,分析输入的软件代码中所有代码元素的位置,还可以分析各个代码元素之间的包含关系,如某个类中包含的函数/方法,函数/方法中所引用的变量/域等。而每个变更器对输入的软件代码的分析过程通常需要消耗一定的时间,为了能够高效的实现对待变更的软件代码的变更。在本申请实施例中第一个被调用的变更器可以将对待变更的软件代码的分析结果保存起来,该分析结果中包括待变更的软件代码中所有代码元素的位置以及各个代码元素之间的包含关系。示例性的,该分析结果可以保存在变更模块140中的缓存空间中。
当某一变更器对输入的软件代码进行变更时,可以调取第一个被调用的变更器保存的分析结果,基于第一个变更器保存的分析结果对前一个变更器输出的变更后的软件代码进行变更。
采用上述方式,变更模块140可以将每个变更器的直接变更内容应用到输入到该变更器的软件代码上。对于变更器的延迟变更内容,变更模块140可以在调用的最后一个变更器的直接变更内容应用到输入到该变更器的软件代码后,统一将所有变更器的延迟变更内容应用在最后一个变更器的延迟变更内容应用在最后一个变更器输出的软件代码中。
在将多个变更器的所有延迟变更内容应用到最后一个变更器输出的软件代码时,也可以采用串行或并行的方式,将多个变更器的所有延迟变更内容应用到最后一个变更器输出的软件代码。串行的方式与如图5或图6所示的实施例类似,例如对于多个变更器的所有延迟变更内容中任一个变更器的延迟变更内容通过一个延迟变更实例集合进行表征,该延迟变更实例集合中的变更实例是以待变更的软件代码为基准的,该延迟变更实例集合中的变更实例的确定方式与变更器的中间变更实例集合中的变更实例集合的方式类似,也是需要确定该变更器之前调用的变更器对待变更的软件代码进行变更所引起的行变化数量,并进行相应的累加,确定延迟变更实例集合中的变更实例,还可以根据这多个变更器的属性,避免不同延迟变更内容中存在冲突的内容,删除延迟变更实例集合中的变更实例,更新该延迟变更实例集合。之后,将更新后的延迟变更实例集合中的变更实例更新到总变更实例集合中。
变更模块140可以通过计算设备中的显示屏,向用户显示该总变更集合,也就是展示该变更模块140对待变更的软件代码的所有变更的行,变更的方式(删除、修改、增加等)以及变更后的内容。
变更模块140提供了如下两种显示方式:
第一种,如图9所示,变更模块140可以展示变更后的软件代码以及待变更的软件代码的差异对比页面,图9中,左边为待变更的软件代码,右边为变更后的软件代码。页面中以行号为标注,在待变更的软件代码上用加粗的方式标注需要变更的行。
用户可以通过差异比对页面,确认需要变更的行,以及变更后的内容,当确认变更正确后,可以将变更后的软件代码替换最初导入的待变更的软件代码。
第二种,如图10所示,变更模块140可以展示待变更的软件代码,并在页面的下方展示总变更实例集合的所有变更实例。在待变更的软件代码的展示界面中,以小灯泡形式对需要变更的行进行展示,展示该行的变更后的内容。
用户可以确认了某一行的变更后的内容,若确认该行的变更后的内容正确后,可以单独将该行变更后的内容应用到待变更的软件代码中。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
以上所述,仅为本发明的具体实施方式。熟悉本技术领域的技术人员根据本发明提供的具体实施方式,可想到变化或替换,都应涵盖在本发明的保护范围之内。
Claims (22)
- 一种代码变更方法,其特征在于,该方法包括:获取用户输入的软件代码以及变更配置信息,所述变更配置信息包括所述软件代码中待变更的代码元素、所述待变更的代码元素的变更方式以及所述待变更的代码元素对应的变更后的代码元素;根据所述变更配置信息确定多个变更器以及所述多个变更器的调用顺序;按照所述多个变更器的调用顺序依次调用所述多个变更器,对所述软件代码进行变更;其中,每一个变更器用于对所述软件代码中的一种待变更的代码元素进行变更,所述多个变更器中第一个被调用的变更器的输入为所述软件代码,被所述第一个被调用的变更器变更后的软件代码被输入所述多个变更器中的另一个变更器。
- 如权利要求1所述的方法,其特征在于,所述根据所述软件代码的变更配置信息确定所述多个变更器的调用顺序,还包括:若所述多个变更器中存在冲突的变更器,确定待变更的软件代码的变更模式为串行变更模式或部分串行部分并行变更模式。
- 如权利要求1或2所述的方法,其特征在于,所述多个变更器中的至少一个变更器包括直接变更内容和延迟变更内容;则,所述按照所述多个变更器的调用顺序依次调用所述多个变更器,对所述软件代码进行变更,包括:调用所述至少一个变更器时,将所述直接变更内容应用在输入到所述至少一个变更器的软件代码中;将所述延迟变更内容在所述多个变更器中最后一个变更器调用结束后应用。
- 如权利要求3所述的方法,其特征在于,在所述依次调用所述多个变更器之前,所述方法还包括:基于所述多个变更器的调用顺序确定每个变更器的属性,每个变更器的属性用于描述每个变更器对所述软件代码中的目标行的变更的处理。
- 如权利要求3所述的方法,其特征在于,所述变更配置信息还包括每个变更器的属性,每个变更器的属性用于描述每个变更器对所述软件代码中的目标行的变更的处理。
- 如权利要求4或5所述的方法,其特征在于,所述方法还包括:根据所述至少一个变更器的属性,确定所述至少一个变更器的直接变更内容。
- 如权利要求6所述的方法,其特征在于,所述根据所述至少一个变更器的属性,确定所述至少一个变更器的直接变更内容,包括:根据所述至少一个变更器的第一属性确定所述至少一个变更器的直接变更内容,所述至少一个变更器的第一属性用于描述对所述软件代码的第一目标行的变更保留或删除,所述第一目标行为所述至少一个变更器和所述至少一个变更器之前被调用的变更器对所述软件代码均执行了变更的。
- 如权利要求6或7所述的方法,其特征在于,根据所述至少一个变更器的属性,确定所述至少一个变更器的直接变更内容包括:根据所述至少一个变更器的第二属性确定所述至少一个变更器的直接变更内容, 所述至少一个变更器的第二属性用于描述对所述软件代码的第二目标行的变更保留或删除,所述第二目标行为所述至少一个变更器对所述软件代码执行了变更且和所述至少一个变更器之前调用的变更器对对所述软件代码未执行变更的。
- 如权利要求1至8任一所述的方法,其特征在于,所述方法还包括:保存所述第一个被调用的变更器对所述软件代码的分析结果,所述分析结果中包括所述软件代码中各代码元素的位置;所述多个变更器中的另一个变更器读取存储的所述分析结果,对所述软件代码进行变更。
- 如权利要求1至9任一所述的方法,其特征在于,所述方法还包括:输出所述多个变更器对所述软件代码进行变更后生成的变更后的软件代码,并显示所述多个变更器对所述软件代码进行变更的变更位置以及变更的内容。
- 一种变更装置,其特征在于,该装置包括:导入模块,用于获取用户输入的软件代码以及变更配置信息,所述变更配置信息包括所述软件代码中待变更的代码元素、所述待变更的代码元素的变更方式以及所述待变更的代码元素对应的变更后的代码元素;配置模块,用于根据所述变更配置信息确定多个变更器以及所述多个变更器的调用顺序;变更模块,用于按照所述多个变更器的调用顺序依次调用所述多个变更器,对所述软件代码进行变更;其中,每一个变更器用于对所述软件代码中的一种待变更的代码元素进行变更,所述多个变更器中第一个被调用的变更器的输入为所述软件代码,被所述第一个被调用的变更器变更后的软件代码被输入所述多个变更器中的另一个变更器。
- 如权利要求11所述的装置,其特征在于,所述配置模块在根据所述软件代码的变更配置信息确定所述多个变更器的调用顺序之前,还用于:若所述多个变更器中存在冲突的变更器,确定待变更的软件代码的变更模式为串行变更模式或部分串行部分并行变更模式。
- 如权利要求11或12所述的装置,其特征在于,所述多个变更器中的至少一个变更器包括直接变更内容和延迟变更内容;则,所述变更模块在按照所述多个变更器的调用顺序依次调用所述多个变更器,对所述软件代码进行变更,具体用于:调用所述至少一个变更器时,将所述直接变更内容应用在输入到所述至少一个变更器的软件代码中;将所述延迟变更内容在所述多个变更器中最后一个变更器调用结束后应用。
- 如权利要求13所述的装置,其特征在于,所述配置模块在所述依次调用所述多个变更器之前,还用于:基于所述多个变更器的调用顺序确定每个变更器的属性,每个变更器的属性用于描述每个变更器对所述软件代码中的目标行的变更的处理。
- 如权利要求13所述的装置,其特征在于,所述变更配置信息还包括每个变更器的属性,每个变更器的属性用于描述每个变更器对所述软件代码中的目标行的变更的处理。
- 如权利要求14或15所述的装置,其特征在于,所述配置模块,还用于:根据所述至少一个变更器的属性,确定所述至少一个变更器的直接变更内容。
- 如权利要求16所述的装置,其特征在于,所述配置模块在根据所述至少一个变更器的属性,确定所述至少一个变更器的直接变更内容,具体用于:根据所述至少一个变更器的第一属性确定所述至少一个变更器的直接变更内容,所述至少一个变更器的第一属性用于描述对所述软件代码的第一目标行的变更保留或删除,所述第一目标行为所述至少一个变更器和所述至少一个变更器之前被调用的变更器对所述软件代码均执行了变更的。
- 如权利要求16或17所述的装置,其特征在于,所述配置模块在根据所述至少一个变更器的属性,确定所述至少一个变更器的直接变更内容,具体用于:根据所述至少一个变更器的第二属性确定所述至少一个变更器的直接变更内容,所述至少一个变更器的第二属性用于描述对所述软件代码的第二目标行的变更保留或删除,所述第二目标行为所述至少一个变更器对所述软件代码执行了变更且和所述至少一个变更器之前调用的变更器对对所述软件代码未执行变更的。
- 如权利要求11至18任一所述的装置,其特征在于,所述变更模块还用于:保存所述第一个被调用的变更器对所述软件代码的分析结果,所述分析结果中包括所述软件代码中各代码元素的位置;所述多个变更器中的另一个变更器读取存储的所述分析结果,对所述软件代码进行变更。
- 如权利要求11至19任一所述的装置,其特征在于,所述变更模块还用于:输出所述多个变更器对所述软件代码进行变更后生成的变更后的软件代码,并显示所述多个变更器对所述软件代码进行变更的变更位置,以及变更的内容。
- 一种计算设备集群,其特征在于,所述计算设备集群中包括至少一个计算设备,每个计算设备包括处理器和存储器;所述至少一个计算设备中的存储器,用于存储计算机程序指令;所述至少一个计算设备中的处理器调用所述存储器中存储的计算机程序指令执行如权利要求1至10中任一项所述的方法。
- 一种包含指令的计算机程序产品,其特征在于,当所述计算机程序产品在计算设备上运行时,使得所述计算机执行权利要求1至10任一所述的方法。
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
EP20858958.0A EP4009162A4 (en) | 2019-08-26 | 2020-08-26 | CODE CHANGE PROCEDURE AND DEVICE |
US17/678,625 US20220179642A1 (en) | 2019-08-26 | 2022-02-23 | Software code change method and apparatus |
Applications Claiming Priority (4)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910792544 | 2019-08-26 | ||
CN201910792544.9 | 2019-08-26 | ||
CN201910877510.XA CN110780897B (zh) | 2019-08-26 | 2019-09-17 | 一种代码变更方法以及装置 |
CN201910877510.X | 2019-09-17 |
Related Child Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US17/678,625 Continuation US20220179642A1 (en) | 2019-08-26 | 2022-02-23 | Software code change method and apparatus |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2021037050A1 true WO2021037050A1 (zh) | 2021-03-04 |
Family
ID=69383528
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2020/111326 WO2021037050A1 (zh) | 2019-08-26 | 2020-08-26 | 一种代码变更方法及装置 |
Country Status (4)
Country | Link |
---|---|
US (1) | US20220179642A1 (zh) |
EP (1) | EP4009162A4 (zh) |
CN (1) | CN110780897B (zh) |
WO (1) | WO2021037050A1 (zh) |
Families Citing this family (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110780897B (zh) * | 2019-08-26 | 2022-05-10 | 华为云计算技术有限公司 | 一种代码变更方法以及装置 |
CN112559024A (zh) * | 2020-12-14 | 2021-03-26 | 建信金融科技有限责任公司 | 一种生成交易码变更列表的方法和装置 |
CN112925561B (zh) * | 2021-03-23 | 2024-07-16 | 抖音视界有限公司 | 一种软件开发方法、装置、计算机设备及存储介质 |
US11656977B2 (en) * | 2021-04-06 | 2023-05-23 | EMC IP Holding Company LLC | Automated code checking |
CN115543277A (zh) * | 2021-06-30 | 2022-12-30 | 中兴通讯股份有限公司 | 代码集成验证方法及装置 |
US11971806B2 (en) | 2022-02-23 | 2024-04-30 | Bank Of America Corporation | System and method for dynamic monitoring of changes in coding data |
CN116661812B (zh) * | 2022-11-25 | 2024-04-02 | 荣耀终端有限公司 | 设备升级方法、电子设备及系统 |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10223076B1 (en) * | 2016-08-29 | 2019-03-05 | The Mathworks, Inc. | Generating code based on user interactions with a user interface element in a code editor |
CN109828808A (zh) * | 2018-12-24 | 2019-05-31 | 珠海海鸟科技有限公司 | 一种防拦截方法及相关设备 |
CN109933326A (zh) * | 2017-12-15 | 2019-06-25 | 北京奇虎科技有限公司 | 改写代码的编译方法、装置及相应终端 |
CN110780897A (zh) * | 2019-08-26 | 2020-02-11 | 华为技术有限公司 | 一种代码变更方法以及装置 |
Family Cites Families (20)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CA2256931A1 (en) * | 1998-12-23 | 2000-06-23 | Robert Weisz | Source editing in a graphical hierarchical environment |
US6564374B1 (en) * | 1999-04-22 | 2003-05-13 | International Business Machines Corporation | Method and apparatus for employing cognitive compares in compare statement sequences |
US7257805B2 (en) * | 2001-11-09 | 2007-08-14 | International Business Machines Corporation | Restoring debugging breakpoints subsequent to program code modifications |
US20030131342A1 (en) * | 2002-01-08 | 2003-07-10 | International Business Machines Corporation | Debugger with activity alert |
US20070300215A1 (en) * | 2006-06-26 | 2007-12-27 | Bardsley Jeffrey S | Methods, systems, and computer program products for obtaining and utilizing a score indicative of an overall performance effect of a software update on a software host |
US8266594B2 (en) * | 2008-08-20 | 2012-09-11 | International Business Machines Corporation | System, method and program product for correcting semantic errors in code using peer submitted code snippets |
WO2010064260A1 (en) * | 2008-12-01 | 2010-06-10 | Kpit Cummins Infosystems Ltd. | Method and system for parallelization of sequencial computer program codes |
US8464261B2 (en) * | 2010-03-31 | 2013-06-11 | Oracle International Corporation | System and method for executing a transaction using parallel co-transactions |
US8768902B2 (en) * | 2010-06-11 | 2014-07-01 | Microsoft Corporation | Unified concurrent changes to data, schema, and application |
US9141519B2 (en) * | 2010-10-05 | 2015-09-22 | Infinera Corporation | Accurate identification of software tests based on changes to computer software code |
US8990771B2 (en) * | 2011-08-19 | 2015-03-24 | Red Hat, Inc. | Building and distributing software packages |
US9459862B2 (en) * | 2013-01-29 | 2016-10-04 | ArtinSoft Corporation | Automated porting of application to mobile infrastructures |
CN106033391B (zh) * | 2015-03-13 | 2019-06-21 | 上海爱韦讯信息技术股份有限公司 | 基于FOG数据的修复bug和变更控制的方法及装置 |
CN105159715B (zh) * | 2015-09-01 | 2018-07-20 | 南京大学 | 一种基于抽象语法树节点变更抽取的Python代码变更提示方法 |
US9703554B2 (en) * | 2015-12-07 | 2017-07-11 | Sap Se | Custom code migration suggestion system based on actual change references |
US9727623B1 (en) * | 2016-02-05 | 2017-08-08 | Accenture Global Solutions Limited | Integrated developer workflow for data visualization development |
CN106648618B (zh) * | 2016-11-16 | 2020-02-07 | 腾讯科技(深圳)有限公司 | 虚拟应用的文本信息生成方法和装置 |
CN106648636B (zh) * | 2016-12-08 | 2020-01-03 | 北京航空航天大学 | 一种基于图挖掘的软件函数变更预测系统及方法 |
CN109117164B (zh) * | 2018-06-22 | 2020-08-25 | 北京大学 | 基于关键元素差异性分析的微服务更新方法及系统 |
WO2020061587A1 (en) * | 2018-09-22 | 2020-03-26 | Manhattan Engineering Incorporated | Error recovery |
-
2019
- 2019-09-17 CN CN201910877510.XA patent/CN110780897B/zh active Active
-
2020
- 2020-08-26 EP EP20858958.0A patent/EP4009162A4/en active Pending
- 2020-08-26 WO PCT/CN2020/111326 patent/WO2021037050A1/zh unknown
-
2022
- 2022-02-23 US US17/678,625 patent/US20220179642A1/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10223076B1 (en) * | 2016-08-29 | 2019-03-05 | The Mathworks, Inc. | Generating code based on user interactions with a user interface element in a code editor |
CN109933326A (zh) * | 2017-12-15 | 2019-06-25 | 北京奇虎科技有限公司 | 改写代码的编译方法、装置及相应终端 |
CN109828808A (zh) * | 2018-12-24 | 2019-05-31 | 珠海海鸟科技有限公司 | 一种防拦截方法及相关设备 |
CN110780897A (zh) * | 2019-08-26 | 2020-02-11 | 华为技术有限公司 | 一种代码变更方法以及装置 |
Non-Patent Citations (1)
Title |
---|
See also references of EP4009162A4 * |
Also Published As
Publication number | Publication date |
---|---|
CN110780897A (zh) | 2020-02-11 |
EP4009162A4 (en) | 2022-09-21 |
US20220179642A1 (en) | 2022-06-09 |
EP4009162A1 (en) | 2022-06-08 |
CN110780897B (zh) | 2022-05-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021037050A1 (zh) | 一种代码变更方法及装置 | |
US10558642B2 (en) | Mechanism for deprecating object oriented data | |
US10740093B2 (en) | Advanced packaging techniques for improving work flows | |
US10481884B2 (en) | Systems and methods for dynamically replacing code objects for code pushdown | |
US20240045850A1 (en) | Systems and methods for database orientation transformation | |
US20200167143A1 (en) | Systems and methods for automated retrofitting of customized code objects | |
US9141510B2 (en) | Memory allocation tracking | |
US20150363195A1 (en) | Software package management | |
CN111176717B (zh) | 生成安装包的方法、装置及电子设备 | |
US10346150B2 (en) | Computerized system and method for patching an application by separating executables and working data using different images | |
US11474796B1 (en) | Build system for distributed applications | |
US20170351506A1 (en) | Automating feature graduation | |
CN111068328A (zh) | 游戏广告配置表格的生成方法、终端设备及介质 | |
CN108804100B (zh) | 创建界面元素的方法、装置、存储介质及移动终端 | |
CN110990356A (zh) | 一种用于逻辑镜像的实时自动扩容方法和系统 | |
CN114020840A (zh) | 一种数据处理方法、装置、服务器、存储介质及产品 | |
CN115994085A (zh) | 代码覆盖率的测试处理方法、装置、设备及存储介质 | |
CN115167822A (zh) | 分支代码合并方法、装置、设备和存储介质 | |
CN115688698A (zh) | 一种文本代码的编辑方法及系统 | |
CN117519691B (zh) | 应用程序处理方法、装置、计算机设备和存储介质 | |
CN118012421A (zh) | 一种小程序转换方法、装置、设备及存储介质 | |
US20210390085A1 (en) | Systems and methods of data migration in multi-layer model-driven applications | |
CN117149162A (zh) | 一种sdk自动生成方法、装置、电子设备及存储介质 | |
CN114840217A (zh) | 一种编译方法、装置、设备及可读存储介质 | |
CN116679912A (zh) | 代码生成方法、装置、设备、存储介质及计算机程序 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20858958 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
ENP | Entry into the national phase |
Ref document number: 2020858958 Country of ref document: EP Effective date: 20220303 |