CN118069141A - Method, device, equipment and storage medium for determining code change influence range - Google Patents

Method, device, equipment and storage medium for determining code change influence range Download PDF

Info

Publication number
CN118069141A
CN118069141A CN202410077513.6A CN202410077513A CN118069141A CN 118069141 A CN118069141 A CN 118069141A CN 202410077513 A CN202410077513 A CN 202410077513A CN 118069141 A CN118069141 A CN 118069141A
Authority
CN
China
Prior art keywords
code
change
function
determining
function call
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410077513.6A
Other languages
Chinese (zh)
Inventor
邓永亮
王冬冬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Baidu China Co Ltd
Original Assignee
Baidu China Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Baidu China Co Ltd filed Critical Baidu China Co Ltd
Priority to CN202410077513.6A priority Critical patent/CN118069141A/en
Publication of CN118069141A publication Critical patent/CN118069141A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The disclosure provides a method, a device, equipment and a storage medium for determining an influence range of code change, relates to the technical field of computers, in particular to the technical field of code processing, and can be applied to the scenes of code change, code test and the like. The specific implementation scheme comprises the following steps: determining a function call relation in a first code according to an abstract syntax tree of the first code, wherein the first code is a changed code; updating a function call relation in the first code according to the first code and the first association relation, wherein the first association relation is used for indicating the function call relation under a preset code structure; acquiring a change code, wherein the change code is determined according to a first code and a second code, and the second code is a code before change; determining an objective function associated with the change code according to the function call relation between the change code and the first code; and determining the influence range of the change code according to the objective function. The method and the device can improve the accuracy of determining the influence range of the change code.

Description

Method, device, equipment and storage medium for determining code change influence range
Technical Field
The disclosure relates to the technical field of computers, in particular to the technical field of code processing, and can be applied to the scenes of code change, code test and the like, and particularly relates to a method, a device, equipment and a storage medium for determining an influence range of code change.
Background
After the PHP code of the program is changed (such as modified, added and deleted) by a developer, the code before and after the change is required to be compared, the change code is determined, and the influence range of the change code is determined according to the change code, so that the program is subjected to targeted test according to the influence range of the change code, and the normal operation of the program is ensured.
Currently, in order to determine the scope of influence of a change code, a developer generally analyzes a code file based on an abstract syntax tree to obtain a function call relationship, determines a change function according to the number of lines where the change code is located, and obtains an objective function associated with the change code according to the change function and the function call relationship.
The accuracy of the scope of influence of the change code determined in this way is not high.
Disclosure of Invention
The disclosure provides a method, a device, equipment and a storage medium for determining a code change influence range, which can improve the accuracy of determining the influence range of a changed code.
According to a first aspect of the present disclosure, there is provided a code change influence range determining method, including:
determining a function call relation in a first code according to an abstract syntax tree of the first code, wherein the first code is a changed code; updating a function call relation in the first code according to the first code and the first association relation, wherein the first association relation is used for indicating the function call relation under a preset code structure; acquiring a change code, wherein the change code is determined according to a first code and a second code, and the second code is a code before change; determining an objective function associated with the change code according to the function call relation between the change code and the first code; and determining the influence range of the change code according to the objective function.
According to a second aspect of the present disclosure, there is provided a code change influence range determination apparatus including:
And the determining module is used for determining the function call relation in the first code according to the abstract syntax tree of the first code, wherein the first code is changed code.
The updating module is used for updating the function call relation in the first code according to the first code and the first association relation, and the first association relation is used for indicating the function call relation under the preset code structure.
The acquisition module is used for acquiring a change code which is determined according to the first code and the second code, and the second code is a code before change.
The processing module is used for determining an objective function associated with the change code according to the function call relation between the change code and the first code; and determining the influence range of the change code according to the objective function.
According to a third aspect of the present disclosure, there is provided an electronic device comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a method as in the first aspect.
According to a fourth aspect of the present disclosure, there is provided a non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method according to the first aspect.
According to a fifth aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the method according to the first aspect.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
Fig. 1 is a flowchart illustrating a method for determining a code change influence range according to an embodiment of the present disclosure;
FIG. 2 is a schematic flow chart of another method for determining the influence range of code modification according to an embodiment of the disclosure;
FIG. 3 is a schematic flow chart of a method for determining the scope of influence of code modification according to an embodiment of the disclosure;
FIG. 4 is a schematic flow chart of a method for determining the scope of influence of code modification according to an embodiment of the disclosure;
FIG. 5 is a schematic flow chart of a method for determining the influence range of code modification according to an embodiment of the disclosure;
FIG. 6 is a schematic diagram of the composition of a code change influence range determination device provided by an embodiment of the present disclosure;
Fig. 7 is a schematic diagram of the composition of an electronic device according to an embodiment of the disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be appreciated that in embodiments of the present disclosure, the character "/" generally indicates that the context associated object is an "or" relationship. The terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
After the PHP code of the program is changed (such as modified, added and deleted) by a developer, the code before and after the change is required to be compared, the change code is determined, and the influence range of the change code is determined according to the change code, so that the program is subjected to targeted test according to the influence range of the change code, and the normal operation of the program is ensured.
Currently, in order to determine the scope of influence of a change code, a developer generally analyzes a code file based on an abstract syntax tree to obtain a function call relationship, determines a change function according to the number of lines where the change code is located, and obtains an objective function associated with the change code according to the change function and the function call relationship.
The accuracy of the scope of influence of the change code determined in this way is not high.
Under the background technology, the present disclosure provides a method for determining the influence range of code change, which can improve the accuracy of determining the influence range of the change code.
The execution subject of the code change influence range determining method provided by the embodiment of the disclosure may be a computer or a server, or may also be other electronic devices with data processing capability; or the execution subject of the method may be a processor (e.g., central processing unit (central processing unit, CPU)) in the electronic device described above; still alternatively, the execution subject of the method may be an Application (APP) installed in the electronic device and capable of implementing the function of the method; the execution subject of the method may be a functional module or a unit having the function of the method in the electronic device. The subject of execution of the method is not limited herein.
The code change influence range determination method is exemplarily described below with reference to the drawings.
Fig. 1 is a flowchart illustrating a method for determining a code change influence range according to an embodiment of the disclosure. As shown in fig. 1, the method may include:
s101, determining a function call relation in the first code according to an abstract syntax tree of the first code.
The first code is a changed code.
Illustratively, the features of variables, circulants, functions and function calls in the first code can be obtained by analyzing the abstract syntax tree, performing lexical analysis, syntax analysis and semantic analysis on the PHP code file, so as to determine the function call relationship in the first code.
Illustratively, for a variable, the name of the variable, the row and column number in which the variable was initialized, the location of the variable's use (e.g., as a function parameter, left-hand use of assignment, right-hand use of assignment, etc.) may be obtained. For a loop, the type of loop, the start and end lines of the loop, the variables in the loop can be obtained. For a function, the name of the class to which the function belongs, the name of the file to which the function belongs, the parameter of the function, the line number of the function start and the line number of the function end can be obtained. By extracting the characteristics of the variable, the loop and the function, the name, the belonging class name, the file name, the line number and the column number of the called external function and the entering and returning values of the called external function can be obtained when the external function is called in the function according to the characteristics of the variable, the loop and the function, so that the function calling relation in the code is obtained.
S102, updating the function call relation in the first code according to the first code and the first association relation.
The first association relationship is used for indicating a function call relationship under a preset code structure.
For example, when the preset code structure indicated in the first association relation exists in the first code, the function call relation corresponding to the code conforming to the preset code structure may be updated.
Illustratively, taking a preset code structure as follows, a function call relationship indicated by the preset code structure is that a function a in a first class is equivalent to a function a in a second class as an example;
When the following codes exist in the first code, it can be determined that the GETINSTANCE function of the cxx_render class is equivalent to the GETINSTANCE function of the cxx_dispatcher_;
If the function call relation in the first code obtained according to the abstract syntax tree comprises GETINSTANCE functions of the first function call cxx_render class, the updated function call relation in the first code comprises GETINSTANCE functions of the first function call cxx_dispatcher_, x_render class.
Illustratively, taking a preset code structure as follows, a function call relationship indicated by the preset code structure is an example that the function A is a function which is regularly matched with the first class;
A class name=first class;
function A;
When the first code contains the following codes, determining that the execution function is a function of which the regular CxX_Policy_ is matched with the Process class;
$className='Cxx_Policy_'.ucfirst(strtolower($policy)).'_'.ucfirst(strtolower($platform)).'_Process';
$className::execute($result,$resource);
If the function call relation in the first code obtained according to the abstract syntax tree comprises a first function call execution function, the updated function call relation in the first code comprises the execution function of which the first function call rule is matched with the cxx_policy_, x_, process class.
S103, acquiring a change code.
The change code is determined according to the first code and the second code, and the second code is a code before change.
The modification code may be determined by the executing body according to the second code before modification and the first code after modification, or may be sent to the executing body according to an acquisition request of the executing body after other electronic devices obtain the modification code, so that the acquisition mode of the modification code is not limited.
For example, the first code and the second code may be compared by a code comparison tool to determine the change code, and the determination manner of the change code is not limited.
S104, determining the objective function associated with the change code according to the function call relation between the change code and the first code.
For example, the function corresponding to the change code may be determined according to the position of the change code in the first code and the position of each function in the first code, so that the objective function associated with the function corresponding to the change code is determined according to the function call relationship.
The objective function may be a function that calls a function corresponding to the change code, and the type of the objective function is not limited, and the number of the objective functions is not limited.
S105, determining the influence range of the change code according to the objective function.
For example, the objective function may be directly used as a function affected by the change code, and the influence range of the change code is determined as the code range corresponding to the objective function.
According to the method, the function call relation in the first code is determined according to the abstract syntax tree of the first code, the function call relation in the first code is updated according to the first code and the first association relation, the objective function associated with the change code is determined according to the change code and the function call relation in the first code, the influence range of the change code is determined according to the objective function, the objective function associated with the change code can be accurately determined, the influence range of the change code is accurately determined according to the objective function, and accuracy of determining the influence range of the change code is improved.
Fig. 2 is another flow chart of a method for determining a code change influence range according to an embodiment of the disclosure. As shown in fig. 2, according to the first code and the first association relationship, updating the function call relationship may include:
s201, determining an object code which accords with a preset code structure in the first code according to the first code and the preset code structure.
For example, a part of codes of the first code whose code structures conform to the preset code structures may be determined as the target codes.
Illustratively, the first code includes the following codes;
$dataProcessor='Cxx_Data_Page_'.ucfirst($hookName);
$objProcessor=new$dataProcessor($this->resource);
$content=$objProcessor->execute();
when the preset code structure is the structure shown below, the above-indicated code may be determined to be the target code.
DataProcessor = first class;
$objProcessor=new$dataProcessor($this->resource);
Content= $ objProcessor- > function a;
S202, determining a function call relation in the target code according to the target code, a preset code structure which the target code accords with and the first association relation.
For example, continuing to take the example in S201 as an example, when the function call relation of the preset code structure in the first association relation is that the function a is a function that is regularly matched with the first class, it may be determined that the execute function in the object code is a function that is regularly matched with the cxx_data_page.
S203, updating the function call relation in the first code according to the function call relation in the target code.
For example, the function call relationship of the object code portion in the first code may be updated to the function call relationship in the object code.
Illustratively, continuing with the example in S202, when the function call relationship in the first code obtained according to the abstract syntax tree includes a first function call execution function, the function call relationship in the updated first code includes the execution function whose first function call rule matches cxx_data_page_.
According to the embodiment, the target code which accords with the preset code structure in the first code is determined according to the first code and the preset code structure; determining a function call relation in the target code according to the target code, a preset code structure which the target code accords with and the first association relation; according to the function call relationship in the target code, the function call relationship in the first code is updated, and the updated function call relationship of the first code can be accurately obtained.
In some possible embodiments, the function call relationship in the first code is stored by materialization.
By way of example, after the function call relationship in the first code is materialized, the developer can update manually more easily, and the expandability of the function call relationship is improved.
According to the embodiment, the function call relation in the first code can be materialized by materialized storage, and the expandability of the function call relation can be improved.
Fig. 3 is a schematic flowchart of a code change influence range determining method according to an embodiment of the disclosure. As shown in fig. 3, determining the objective function associated with the change code according to the function call relationship between the change code and the first code may include:
s301, determining a change function according to the change code.
The change function is a function including a change code in the first code.
Illustratively, the function including the change code may be determined as the change function according to the position of the change code in the first code, and the start line and the end line of each function in the first code.
For example, with the change code in the third line of the first code, the first function in the first code is the first line to the fourth line, and the second function in the first code is the seventh line to the eighth line, the first function may be determined to be the change function.
S302, determining an objective function associated with the change function according to the change function and the function call relation in the first code.
Illustratively, taking the change function as a function a, the function call relationship in the first code includes a function B calling the function a, a function a calling the function C, and a function D calling the function E as an example, and determining the function B as the target function.
According to the embodiment, the change function is determined according to the change code, and the objective function associated with the change function is determined according to the change function and the function call relation in the first code, so that the objective function can be accurately determined.
Fig. 4 is a schematic flowchart of another method for determining a code change influence range according to an embodiment of the disclosure. As shown in fig. 4, after determining the objective function associated with the change code according to the function call relationship in the change code and the first code, the method may further include:
S401, determining a change function according to the change code.
The change function is a function including a change code in the first code.
For example, the specific embodiment of S401 may refer to S301, which is not described herein.
S402, constructing a prompt word corresponding to the change code according to the change function, the objective function, the change code and the prompt word template.
For example, the alert word text may be constructed according to the code corresponding to the change function, the code corresponding to the objective function, the change code, and the alert word template.
For example, the hint word template may be "the first function is a code corresponding to a change function", the second function associated with the first function is a code corresponding to an objective function ", the change code is a change code", and ask whether the change part in the first function affects the final return value of the first function, and explain the detailed reason.
S403, inputting the prompt word into a large model, and determining whether the objective function is an influence function or not through the large model.
Wherein the influencing function is a function influenced by the altered code.
Illustratively, the large model may be a deep learning model of a natural language trained in advance.
By way of example, by determining whether the change code affects the function return value of the change function through the large model, when the change code affects the function return value of the change function, the function return value of the target function may be changed due to a change in the function return value of the change function because the target function calls the change function, and conversely, when the change code does not affect the function return value of the change function, the target function may be determined to be an affecting function.
For example, after determining that the objective function is an influence function, the influence range of the change code may be determined as a code range corresponding to the objective function belonging to the influence function. It will be appreciated that when the objective function includes a plurality and it is determined that all of the objective functions are not influence functions, it may be determined that the change code cannot have an influence on the first code, i.e., that there is no influence range of the change code.
According to the embodiment, the change function is determined according to the change code, the change code and the prompt word template, the prompt word corresponding to the change code is constructed, the prompt word is input into the large model, whether the target function is an influence function is determined through the large model, whether the change code has a substantial influence on the target function can be further determined, and accuracy of determining the influence range of the change code is further improved.
Fig. 5 is a schematic flowchart of a code change influence range determining method according to an embodiment of the disclosure. As shown in fig. 5, the method may further include:
S501, determining a variable influenced by a change code in a change function as a target variable through a large model.
For example, text that requires the large model to output the variable affected by the change code may be added to the prompt word template, so that the variable affected by the change code in the change function is determined by the large model.
S502, determining an influence variable of the target variable according to the influence function and the second association relation.
The second association relationship is used for indicating the association relationship between the variable and the function in the first code.
For example, taking the influencing function as a function a, the second association relationship indicates that the variable a is a function input parameter of the function a, the variable B is a function output parameter of the function a, and the variable C is an intra-function variable of the function a as an example, then the influencing variables of the variables a and B as target variables can be determined.
According to the embodiment, the variable influenced by the change code in the change function is determined through the large model, the influence variable of the target variable is determined according to the influence function and the second association relation, and the influence range of the change code can be determined in a finer granularity.
In some possible embodiments, the method may further comprise:
And determining the target test case according to the influence function and the influence variable.
For example, the test cases covered on the influence functions and the influence variables can be determined as target test cases according to the names of the influence functions and the influence variables.
According to the embodiment, the target test cases are determined according to the influence functions and the influence variables, and the target test cases with finer granularity can be determined through the influence variables with finer granularity. The accuracy of the test result can be improved by adopting the target test case obtained by the embodiment.
The foregoing description of the embodiments of the present disclosure has been presented primarily in terms of methods. To achieve the above functions, it includes corresponding hardware structures and/or software modules that perform the respective functions. Those of skill in the art will readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. The technical aim may be to use different methods to implement the described functions for each particular application, but such implementation should not be considered beyond the scope of the present disclosure.
In an exemplary embodiment, the present disclosure also provides a code change influence range determining apparatus, which may be used to implement the code change influence range determining method as in the foregoing embodiment.
Fig. 6 is a schematic diagram of the composition of a code change influence range determination apparatus provided in an embodiment of the present disclosure. As shown in fig. 6, the apparatus may include: a determining module 601, an updating module 602, an obtaining module 603 and a processing module 604.
The determining module 601 is configured to determine a function call relationship in a first code according to an abstract syntax tree of the first code, where the first code is a changed code;
The updating module 602 is configured to update a function call relationship in the first code according to the first code and a first association relationship, where the first association relationship is used to indicate the function call relationship under a preset code structure;
The acquiring module 603 is configured to acquire a change code, where the change code is determined according to a first code and a second code, and the second code is a code before change;
A processing module 604, configured to determine an objective function associated with the change code according to the function call relationship between the change code and the first code; and determining the influence range of the change code according to the objective function.
In some possible embodiments, the updating module 602 is specifically configured to:
determining an object code which accords with a preset code structure in the first code according to the first code and the preset code structure;
Determining a function call relation in the target code according to the target code, a preset code structure which the target code accords with and the first association relation;
And updating the function call relation in the first code according to the function call relation in the target code.
In some possible implementations, the function call relationship in the first code is recorded by a function call entity.
In some possible embodiments, the processing module 604 is specifically configured to:
Determining a change function according to the change code, wherein the change function is a function comprising the change code in the first code;
And determining the objective function associated with the change function according to the change function and the function calling relation in the first code.
In some possible embodiments, the apparatus further comprises:
The first analysis module 605 is configured to determine, according to the change code, a change function after determining, according to a function call relationship between the change code and the first code, a target function associated with the change code, where the change function is a function including the change code in the first code;
Constructing a prompting word corresponding to the change code according to the change function, the objective function, the change code and the prompting word template;
and inputting the prompt word into a large model, and determining whether the objective function is an influence function or not through the large model.
In some possible embodiments, the apparatus further comprises:
a second analysis module 606, configured to determine, through the large model, that a variable affected by the change code in the change function is a target variable;
and determining an influence variable of the target variable according to the influence function and a second association relation, wherein the second association relation is used for indicating the association relation between the variable and the function in the first code.
In some possible embodiments, the apparatus further comprises:
The test module 607 is configured to determine a target test case according to the influence function and the influence variable.
It should be noted that the division of the modules in fig. 6 is schematic, and is merely a logic function division, and other division manners may be implemented in practice. For example, two or more functions may also be integrated in one processing module. The embodiments of the present disclosure are not limited in this regard. The integrated modules may be implemented in hardware or in software functional modules.
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the related user personal information all conform to the regulations of related laws and regulations, and the public sequence is not violated.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
In an exemplary embodiment, an electronic device includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method as described in the above embodiments. The electronic device may be the computer or server described above.
In an exemplary embodiment, the readable storage medium may be a non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method according to the above embodiment.
In an exemplary embodiment, the computer program product comprises a computer program which, when executed by a processor, implements the method according to the above embodiments.
Fig. 7 illustrates a schematic block diagram of an example electronic device 700 that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 7, the electronic device 700 includes a computing unit 701 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 702 or a computer program loaded from a storage unit 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 may also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Various components in the electronic device 700 are connected to the I/O interface 705, including: an input unit 706 such as a keyboard, a mouse, etc.; an output unit 707 such as various types of displays, speakers, and the like; a storage unit 708 such as a magnetic disk, an optical disk, or the like; and a communication unit 709 such as a network card, modem, wireless communication transceiver, etc. The communication unit 709 allows the electronic device 700 to exchange information/data with other devices through a computer network, such as the internet, and/or various telecommunication networks.
The computing unit 701 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 701 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The calculation unit 701 performs the respective methods and processes described above, for example, the code change influence range determination method. For example, in some embodiments, the code change impact scope determining method may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as the storage unit 708. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 700 via the ROM 702 and/or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the code change influence range determination method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the code change impact range determination method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above can be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server) or that includes a middleware component (e.g., an application server) or that includes a front-end component through which a user can interact with an implementation of the systems and techniques described here, or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel, sequentially, or in a different order, provided that the desired results of the disclosed aspects are achieved, and are not limited herein.
The above detailed description should not be taken as limiting the scope of the present disclosure. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure are intended to be included within the scope of the present disclosure.

Claims (17)

1. A code change impact range determination method, the method comprising:
Determining a function call relation in a first code according to an abstract syntax tree of the first code, wherein the first code is a changed code;
Updating a function call relation in the first code according to the first code and a first association relation, wherein the first association relation is used for indicating the function call relation under a preset code structure;
acquiring a change code, wherein the change code is determined according to the first code and a second code, and the second code is a code before change;
determining an objective function associated with the change code according to the function call relation between the change code and the first code;
And determining the influence range of the change code according to the objective function.
2. The method of claim 1, wherein updating the function call relationship according to the first code and the first association relationship comprises:
Determining an object code which accords with the preset code structure in the first code according to the first code and the preset code structure;
Determining a function call relation in the target code according to the target code, a preset code structure which the target code accords with and the first association relation;
and updating the function call relation in the first code according to the function call relation in the target code.
3. A method according to claim 1 or 2, wherein the function call relationship in the first code is recorded by a function call entity.
4. A method according to any one of claims 1-3, wherein said determining an objective function associated with said change code based on a function call relationship in said change code and said first code, comprises:
determining a change function according to the change code, wherein the change function is a function comprising the change code in the first code;
And determining the objective function associated with the change function according to the change function and the function call relation in the first code.
5. The method of any of claims 1-4, after determining the object function associated with the change code from the change code and a function call relationship in the first code, the method further comprising:
determining a change function according to the change code, wherein the change function is a function comprising the change code in the first code;
constructing a prompt word corresponding to the change code according to the change function, the objective function, the change code and the prompt word template;
And inputting the prompt word into a large model, and determining whether the objective function is an influence function or not through the large model.
6. The method of claim 5, the method further comprising:
determining a variable influenced by the change code in the change function as a target variable through the large model;
And determining the influence variable of the target variable according to the influence function and a second association relation, wherein the second association relation is used for indicating the association relation between the variable and the function in the first code.
7. The method of claim 6, the method further comprising:
And determining a target test case according to the influence function and the influence variable.
8. A code change impact range determining apparatus, the apparatus comprising:
The determining module is used for determining a function call relation in a first code according to an abstract syntax tree of the first code, wherein the first code is a changed code;
the updating module is used for updating the function call relation in the first code according to the first code and the first association relation, wherein the first association relation is used for indicating the function call relation under a preset code structure;
The acquisition module is used for acquiring a change code, wherein the change code is determined according to the first code and the second code, and the second code is a code before change;
the processing module is used for determining an objective function associated with the change code according to the function call relation between the change code and the first code;
And determining the influence range of the change code according to the objective function.
9. The apparatus of claim 8, the updating module is specifically configured to:
Determining an object code which accords with the preset code structure in the first code according to the first code and the preset code structure;
Determining a function call relation in the target code according to the target code, a preset code structure which the target code accords with and the first association relation;
and updating the function call relation in the first code according to the function call relation in the target code.
10. The apparatus according to claim 8 or 9, wherein the function call relation in the first code is recorded by a function call entity.
11. The apparatus according to any of claims 8-10, the processing module being specifically configured to:
determining a change function according to the change code, wherein the change function is a function comprising the change code in the first code;
And determining the objective function associated with the change function according to the change function and the function call relation in the first code.
12. The apparatus according to any one of claims 8-11, further comprising:
the first analysis module is used for determining a change function according to the change code after determining an objective function related to the change code according to a function call relation in the change code and the first code, wherein the change function is a function comprising the change code in the first code;
constructing a prompt word corresponding to the change code according to the change function, the objective function, the change code and the prompt word template;
And inputting the prompt word into a large model, and determining whether the objective function is an influence function or not through the large model.
13. The apparatus of claim 12, the apparatus further comprising:
The second analysis module is used for determining the variable influenced by the change code in the change function as a target variable through the large model;
And determining the influence variable of the target variable according to the influence function and a second association relation, wherein the second association relation is used for indicating the association relation between the variable and the function in the first code.
14. The apparatus of claim 13, the apparatus further comprising:
And the test module is used for determining a target test case according to the influence function and the influence variable.
15. An electronic device, comprising: at least one processor; and a memory communicatively coupled to the at least one processor;
Wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
16. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method of any one of claims 1-7.
17. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any of claims 1-7.
CN202410077513.6A 2024-01-19 2024-01-19 Method, device, equipment and storage medium for determining code change influence range Pending CN118069141A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410077513.6A CN118069141A (en) 2024-01-19 2024-01-19 Method, device, equipment and storage medium for determining code change influence range

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410077513.6A CN118069141A (en) 2024-01-19 2024-01-19 Method, device, equipment and storage medium for determining code change influence range

Publications (1)

Publication Number Publication Date
CN118069141A true CN118069141A (en) 2024-05-24

Family

ID=91096334

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410077513.6A Pending CN118069141A (en) 2024-01-19 2024-01-19 Method, device, equipment and storage medium for determining code change influence range

Country Status (1)

Country Link
CN (1) CN118069141A (en)

Similar Documents

Publication Publication Date Title
CN112597754B (en) Text error correction method, apparatus, electronic device and readable storage medium
CN112527281B (en) Operator upgrading method and device based on artificial intelligence, electronic equipment and medium
CN113011155B (en) Method, apparatus, device and storage medium for text matching
CN114816393A (en) Information generation method, device, equipment and storage medium
CN112989797B (en) Model training and text expansion methods, devices, equipment and storage medium
CN113849581A (en) Alarm information processing method, device, equipment and storage medium
CN113220367A (en) Applet running method and device, electronic equipment and storage medium
CN116302218B (en) Function information adding method, device, equipment and storage medium
CN114492370B (en) Webpage identification method, webpage identification device, electronic equipment and medium
CN114743586B (en) Mirror image storage implementation method and device of storage model and storage medium
CN113448668B (en) Method and device for skipping popup window and electronic equipment
CN113704256B (en) Data identification method, device, electronic equipment and storage medium
CN118069141A (en) Method, device, equipment and storage medium for determining code change influence range
CN113408304B (en) Text translation method and device, electronic equipment and storage medium
CN114386577A (en) Method, apparatus, and storage medium for executing deep learning model
CN115840867A (en) Generation method and device of mathematical problem solving model, electronic equipment and storage medium
CN114138358A (en) Application program starting optimization method, device, equipment and storage medium
CN113361575A (en) Model training method and device and electronic equipment
CN113010182B (en) Method and device for generating upgrade file and electronic equipment
CN113553407B (en) Event tracing method and device, electronic equipment and storage medium
CN113238765B (en) Method, device, equipment and storage medium for distributing small program
CN113011494B (en) Feature processing method, device, equipment and storage medium
CN113344405B (en) Method, device, equipment, medium and product for generating information based on knowledge graph
CN113961263B (en) Applet distribution method, device, apparatus and storage medium
CN115630630B (en) Language model processing method, service processing method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination