Historical slice extraction method, system, device and storage medium of software code

By acquiring the revision history and semantic changes of software code, and combining this with refactoring detection tools to generate historical slices, the problem of accurately locating the revision and evolution process of fine-grained code entities in existing technologies is solved. This achieves higher-precision historical slices, supporting more effective defect location and code understanding.

CN115098159BActive Publication Date: 2025-11-04INST FOR INTERDISCIPLINARY INFORMATION CORE TECH XIAN CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210880158.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-25
Publication Date
2025-11-04
Estimated Expiration
2042-07-25

AI Technical Summary

Technical Problem

Existing software code history slicing techniques fail to adequately consider modification semantics, resulting in an inability to accurately locate the revision and evolution process of fine-grained code entities, making it difficult to effectively locate defects and analyze malicious code submissions.

Method used

By acquiring the revision history of the software code, the modification semantics are analyzed using the refactoring detection tool RefactoringMiner. Combined with the code entity information of the current version and historical versions, historical slices are generated, and the historical slices of each version are obtained directly using the modification semantics.

Benefits of technology

It improves the accuracy of historical slices, associating each version's slice with specific modification semantics, which aligns with developers' actual revision methods and is more conducive to defect localization and code understanding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115098159B_ABST
    Figure CN115098159B_ABST
Patent Text Reader

Abstract

The application belongs to the field of program analysis, and discloses a history slice extraction method, system, device and storage medium of software code, which comprises obtaining code entity information and version information of a current version of software code, code entity information and version information of each historical version of the software code, and revision history of the software code; obtaining a modification semantic set of each historical version of the software code according to the revision history of the software code; obtaining a history slice of each historical version of the software code and combining the history slice according to the code entity information and version information of the current version of the software code, the code entity information and version information of each historical version of the software code, and the modification semantic set of each historical version of the software code. Compared with the method based on text similarity matching of code, the history slice with higher precision can be obtained, and the history slice result which is more conducive to defect positioning and code understanding of the developer can be obtained.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of program analysis, and relates to a history slice extraction method, system, device and storage medium of software code. BACKGROUND

[0002] Many software engineering tasks require developers to be familiar with the history records and evolution processes of fine-grained code entities in software code, which is referred to as a history slice technology. The history slice technology can be used for defect positioning, malicious code submission prevention and malicious code submission analysis, and has a wide range of applications in the industry.

[0003] However, the history slice technology adopted by current software development technologies and history auxiliary analysis tools is mostly based on the similarity of software code texts, and fails to fully consider the modification semantics of software code, so that the revision and evolution processes of fine-grained code entities cannot be accurately positioned, and it is not easy to obtain such information, thereby bringing great difficulties to defect positioning and malicious code submission analysis. SUMMARY

[0004] The application aims to overcome the shortcomings in the prior art that the existing history slice technology fails to fully consider the modification semantics of software code and cannot accurately position the revision and evolution processes of fine-grained code entities, and provides a history slice extraction method, system, device and storage medium of software code.

[0005] To achieve the above-mentioned purpose, the application adopts the following technical solutions:

[0006] In a first aspect, the application provides a history slice extraction method of software code, comprising:

[0007] obtaining code entity information and version information of a current version of software code, code entity information and version information of each historical version of software code, and revision history of software code; obtaining a modification semantics set of each historical version of software code according to the revision history of software code; obtaining a history slice of each historical version of software code and combining to obtain a history slice of software code according to the code entity information and version information of the current version of software code, the code entity information and version information of each historical version of software code, and the modification semantics set of each historical version of software code.

[0008] Optionally, the code entity information comprises a software code entity name, a software code entity unique index name, a software code file path, a software code entity file start line number, a software code entity file end line number, a software code entity start column number and a software code entity end column number.

[0009] Optionally, the obtaining the modification semantic set of each historical version of the software code according to the revision history of the software code comprises: obtaining the revision history of each historical version of the software code according to the revision history of the software code; and calling a refactoring detection tool RefactoringMiner to analyze the revision history of each historical version of the software code, so as to obtain the modification semantic set of each historical version of the software code.

[0010] Optionally, the modification semantic set of each historical version of the software code comprises a plurality of modification semantics; and the modification semantics comprise modification semantic corresponding source code, modification semantic content and modification semantic corresponding target code.

[0011] Optionally, the modification semantic content comprises extraction, renaming, moving, up-pushing, down-pushing and deletion.

[0012] Optionally, the obtaining the historical slice of each historical version of the software code according to the code entity information and version information of the current version of the software code, the code entity information and version information of each historical version of the software code, and the modification semantic set of each historical version of the software code comprises: initializing the historical slice of each historical version of the software code; traversing the current version and each historical version of the software code according to the version information of the software code and the version information of each historical version of the software code; when the current version of the software code has a parent version, obtaining the modification semantic set of the parent version of the current version of the software code and the historical slice of the current version of the software code; and traversing each modification semantic in the modification semantic set of the parent version of the current version of the software code; when the modification semantic corresponding source code of the current modification semantic belongs to the historical slice of the current version of the software code, combining the modification semantic content and the modification semantic corresponding target code of the current modification semantic to obtain a new modification semantic, and adding the new modification semantic to the historical slice of the parent version of the current version of the software code; and traversing each modification semantic in the historical slice of the current version of the software code; when the modification semantic corresponding target code of the current modification semantic does not belong to the modification semantic set of the parent version of the current version of the software code, combining the modification semantic corresponding target code of the current modification semantic with no modification information to obtain a new modification semantic, and adding the new modification semantic to the historical slice of the parent version of the current version of the software code; and obtaining the historical slice of each historical version of the software code after the traversal of the current version and each historical version of the software code is completed.

[0013] In a second aspect, the present application provides a system for extracting a historical slice of software code, comprising:

[0014] The information acquisition module is configured to acquire code entity information and version information of a current version of the software code, code entity information and version information of each historical version of the software code, and a revision history of the software code.

[0015] Optionally, the slice extraction module is specifically configured to: initialize historical slices of each historical version of the software code; according to the version information of the software code and the version information of each historical version of the software code, traverse the current version and each historical version of the software code; when the current version of the software code has a parent version: acquire a modification semantic set of the parent version of the current version of the software code and the historical slice of the current version of the software code; and traverse each modification semantic in the modification semantic set of the parent version of the current version of the software code: when modification semantic corresponding source code of the current modification semantic belongs to the historical slice of the current version of the software code, combine modification semantic content of the current modification semantic and modification semantic corresponding target code to obtain new modification semantic, and add the new modification semantic to the historical slice of the parent version of the current version of the software code; and traverse each modification semantic in the historical slice of the current version of the software code: when modification semantic corresponding target code of the current modification semantic does not belong to the modification semantic set of the parent version of the current version of the software code, combine the modification semantic corresponding target code of the current modification semantic with no modification information to obtain new modification semantic, and add the new modification semantic to the historical slice of the parent version of the current version of the software code; after the current version and each historical version of the software code are traversed, the historical slices of each historical version of the software code are obtained; and the historical slices of each historical version of the software code are combined to obtain the historical slice of the software code.

[0016] In a third aspect, the present application provides a computer device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the historical slice extraction method of the software code when executing the computer program.

[0017] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the processor implements the steps of the historical slice extraction method of the software code when executing the computer program.

[0018] Compared with the prior art, the present application has the following beneficial effects:

[0019] The history slice extraction method of the software code of the present application extracts the history slice of each historical version of the software code by obtaining the modification semantic set of each historical version of the software code according to the revision history of the software code, and then directly obtains the history slice of each historical version of the software code based on the modification semantic set of each historical version of the software code, in combination with the code entity information and version information of the current version of the software code and the code entity information and version information of each historical version of the software code, and assembles the history slice of each historical version of the software code to obtain the history slice of the software code. Compared with the current method of matching the text similarity of the software code, the method does not need to manually set the similarity threshold, but directly uses the modification semantic of the software code to obtain the history slice, and each version of the history slice is associated with a specific modification semantic, so that the accuracy of the final history slice of the software code is higher. At the same time, each history slice of each historical version of the software code corresponds to a specific modification semantic, and the obtained information is more in line with the actual revision manner of the developer, and is more conducive to the defect positioning and code understanding of the developer. BRIEF DESCRIPTION OF DRAWINGS

[0020] Figure 1 The flow chart of the history slice extraction method of the software code of the embodiment of the present application.

[0021] Figure 2 The modification semantic extraction schematic diagram of each historical version of the software code of the embodiment of the present application.

[0022] Figure 3 The history slice extraction schematic diagram of each historical version of the software code of the embodiment of the present application.

[0023] Figure 4 The system structure block diagram of the history slice extraction system of the software code of the embodiment of the present application. DETAILED DESCRIPTION

[0024] In order to enable the persons skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by the persons skilled in the art without creative labor should belong to the protection scope of the present application.

[0025] It is to be understood that the terminology "first", "second" and the like used in the specification and the claims of the application as well as the preceding description of the drawings is merely used to distinguish between similar objects and does not necessarily imply a specific order or chronology. It is to be understood that the use of the term "about" in the description and claims of the application as well as the preceding description of the drawings is meant to encompass variations that are a few percent above or below the stated value. It is to be understood that the data thus used in the specification and claims of the application as well as the preceding description of the drawings is meant to be inter- changeable under appropriate circumstances, such that the embodiments of the application described herein can be practiced in other than the particular orders illustrated or described. Furthermore, the terms "comprising" and "including" and any variations thereof as used in the specification and claims of the application as well as the preceding description of the drawings are intended to cover not exclusively inclusive, for example, a process, method, system, product, or apparatus that includes a list of steps or units need not be limited to only those steps or units expressly listed, but can include other steps or units that are not expressly listed or inherent to such process, method, product, or apparatus.

[0026] The application will be further described with reference to the drawings in which:

[0027] Referring to Figure 1 In one embodiment of the application, a method for extracting a history slice of software code is provided. The method starts from a version of software code to be extracted, traces back from a revision history of the software code, and generates a history slice of the software code by using modification semantics obtained.

[0028] In particular, the method for extracting a history slice of software code comprises the following steps:

[0029] S1: obtaining code entity information and version information of a current version of software code, code entity information and version information of each historical version of the software code, and a revision history of the software code.

[0030] S2: obtaining a set of modification semantics of each historical version of the software code according to the revision history of the software code.

[0031] S3: obtaining a history slice of each historical version of the software code according to the code entity information and version information of the current version of the software code, the code entity information and version information of each historical version of the software code, and the set of modification semantics of each historical version of the software code, and combining the history slices to obtain a history slice of the software code.

[0032] To sum up, the history slice extraction method of the software code, by obtaining the modification semantic set of each historical version of the software code according to the revision history of the software code, then based on the modification semantic set of each historical version of the software code, combining the code entity information and version information of the current version of the software code and the code entity information and version information of each historical version of the software code, directly obtaining the history slice of each historical version of the software code and combining, and then obtaining the history slice of the software code. Compared with the current method based on the text similarity matching of the software code, it does not need to manually set the similarity threshold, directly uses the modification semantics of the software code to obtain the history slice, each version of the history slice is associated with a specific modification semantics, so the accuracy of the final obtained history slice of the software code is higher. At the same time, each history slice of each historical version of the software code corresponds to a specific modification semantics, the obtained information is more in line with the actual revision method of the developer, and is more conducive to the defect positioning and code understanding of the developer.

[0033] In a possible implementation, the code entity information includes: a software code entity name, a software code entity unique index name, a software code file path, a software code entity file start line number, a software code entity file end line number, a software code entity start column number, and a software code entity end column number. Specifically, the specific content of a code entity can be determined according to the code entity information.

[0034] In a possible implementation, the obtaining of the modification semantic set of each historical version of the software code according to the revision history of the software code includes: obtaining the revision history of each historical version of the software code according to the revision history of the software code; calling a refactoring detection tool RefactoringMiner to analyze the revision history of each historical version of the software code to obtain the modification semantic set of each historical version of the software code.

[0035] Specifically, RefactoringMiner is a library / API written in Java, which can detect the refactoring applied in the software code, and the acquisition of the modification semantic set is realized by calling RefactoringMiner.

[0036] Optionally, the modification semantic set of each historical version of the software code includes a plurality of modification semantics; the modification semantics include modification semantic corresponding source code, modification semantic content, and modification semantic corresponding target code. The modification semantic content includes extraction, renaming, moving, up pushing, down pushing, and deleting, but is not limited thereto.

[0037] The modification semantic set can be represented as AllEdit={(e1, m, e2)}, where (e1, m, e2) is a modification semantic, e1 represents the source code corresponding to the modification semantic, e2 represents the target code corresponding to the modification semantic, and m represents the modification semantic content. The modification semantic of each historical version of the software code can be represented as a mapping from the version number of each historical version of the software code to the modification semantic set, so as to facilitate description.

[0038] In a possible implementation, the obtaining of the historical slice of each historical version of the software code according to the code entity information and the version information of the current version of the software code, the code entity information and the version information of each historical version of the software code, and the modification semantic set of each historical version of the software code comprises: initializing the historical slice of each historical version of the software code; traversing the current version and each historical version of the software code according to the version information of the software code and the version information of each historical version of the software code; when the current version of the software code has a parent version: obtaining the modification semantic set of the parent version of the current version of the software code and the historical slice of the current version of the software code; and traversing each modification semantic in the modification semantic set of the parent version of the current version of the software code: when the modification semantic corresponding to the source code of the current modification semantic belongs to the historical slice of the current version of the software code, combining the modification semantic content and the modification semantic corresponding target code of the current modification semantic to obtain a new modification semantic, and adding the new modification semantic to the historical slice of the parent version of the current version of the software code; and traversing each modification semantic in the historical slice of the current version of the software code: when the modification semantic corresponding target code of the current modification semantic does not belong to the modification semantic set of the parent version of the current version of the software code, combining the modification semantic corresponding target code of the current modification semantic with no modification information to obtain a new modification semantic, and adding the new modification semantic to the historical slice of the parent version of the current version of the software code; and after the traversal of the current version and each historical version of the software code is completed, the historical slice of each historical version of the software code is obtained.

[0039] Specifically, the obtaining of the historical slice of each historical version of the software code according to the code entity information and the version information of the current version of the software code, the code entity information and the version information of each historical version of the software code, and the modification semantic set of each historical version of the software code comprises the following detailed steps.

[0040] S301: initializing a set V of versions that have been visited V={v i}, where v i is a version in which the entity code e is located, the set V of versions includes the current version and each historical version of the software code, and the entity code e is a piece of entity code in the current version or any historical version of the software code.

[0041] S302: Initialize the version mapping of entity code e.

[0042] S303: For each version v in the version set V i If it has a parent version v parent Then use v i and v parent Generate entity code e in v parent Historical slice information e parent , will e parent The newly added historical slice EntityDictionary to the software code is in v parent The key-value pair at the location, if the history slice of the software code in EntityDictionary is in v parent If the key-value pair does not exist, create an EntityDictionary in v. parent Repeat this step for the key-value pair at the specified location until no version of EntityDictionary can be updated.

[0043] In this context, the historical slice of software code, EntityDictionary, represents the version mapping of entity code e, where for each version v... i EntityDictionary[v i The key value of ] is a set For each element of the set The input entity code e evolved to version v i The corresponding entity code at that location, The input entity code e evolved to version v i Entity code e v The semantic changes that have occurred.

[0044] Specifically, the use of v i and v parent Generate entity code e in v parent Historical slice information e parent Specifically, the following steps are included:

[0045] S30301: Initialize the version mapping of entity code e in v parent The key value at the location is an empty set e parent ={}.

[0046] S30302: Get version v parent The set of semantic modifications at each location is represented as AllEdit[v parent ].

[0047] S30303: Retrieve the version mapping of entity code e in v iThe key-value pair EntityDictionary[v i ].

[0048] S30304: For AllEdit[v parent For each modified semantic (ei, m, ej) in EntityDictionary[v], if ei exists in EntityDictionary[v], ... i ], then add (ej, m) to e parent .

[0049] S30305: For any (ei, m) belonging to EntityDictionary[v i If no (ei, m, ej) belongs to AllEdit[v], parent If the expression is ], it means that this version does not contain any semantic modifications related to ei, and (ei, Unchange) is added to e. parent .

[0050] S30306: If EntityDictionary is in v parent If the key value at that location has already been set, then e will be... parent Added to EntityDictionary in v parent The key value at the location; if EntityDictionary is in v parent If the key value at this location has not yet been set, then set it to e. parent .

[0051] In one possible implementation, taking the entity code `methodStart` as an example, the historical slice extraction method of the software code of the present invention is illustrated. See [link to relevant documentation]. Figure 2 and 3 The dashed box indicates a commit that involves modification semantics, specifically including the following steps:

[0052] S301: Initialize the set of visited versions V = {initial commit}.

[0053] S302: Initialize entity version mapping, The initialization results are shown in Table 1.

[0054] Table 1

[0055]

[0056] S303: For each version v in the version set V i If a parent version exists, then use v. i Compared with its parent version v parent Generate methodStart in v iHistorical slices at e parent Using e parent Update EntityDictionary in v parent The value at the location, and the parent version v parent Adding to V, repeating this step will not utilize any version update of EntityDictionary.

[0057] The historical slice of methodStart in submission A is {(MethodA, Rename)}, in submission B it is {(MethodA, Unchange)}, in submission C it is {(MethodC, Move)}, in submission D it is {(MethodC, Unchange)}, in submission E it is {(MethodA, Unchange), (MethodC, Unchange)}, and in submission F it is {(methodF, Rename), (methodC, Unchange)}. This completes the extraction of the historical slices for the entity methodStart.

[0058] Specifically, the process for each EntityDictionary update is as follows:

[0059] First update: V = {initial commit}, select "initial commit" and its parent version "commit A" to generate a historical slice of entity methodStart in commit A. First, obtain the key-value pair of EntityDictionary at "initial commit" {(methodStart, )}, iterate through the set of modification semantics of "submit A" {(methodStart, Rename, methodA)}, where the source entity exists in {(methodStart, The modified semantic set of )} is {(methodStart, Rename, methodA)}. Since EntityDictionary has not yet set a key value for "Submit A", {(methodA, Rename)} is set as the key value of EntityDictionary for "Submit A". The state of EntityDictionary after the first update is shown in Table 2. Finally, "Submit A" is added to V.

[0060] Table 2

[0061]

[0062] The second update: V = {initial commit, commit A}, select "initial commit" and its parent version "commit C" to generate the entity methodStart in the history slice of "commit C", first, get the key value {(methodStart, )} of EntityDictionary at "initial commit", traverse the modification semantics set {(methodStart, Move, methodC)} of "commit C", the modification semantics set of {(methodStart, )} is {(methodStart, Move, methodC)}, because EntityDictionary has not set the key value at "commit C", set {(methodC, Move)} as the key value of EntityDictionary at "commit C", the state of EntityDictionary after the second update is shown in Table 3; finally, add "commit C" to V.

[0063] Table 3

[0064]

[0065] The third update: V = {initial commit, commit A, commit C}, select "commit C" and its parent version "commit D" to generate the entity methodStart in the history slice of "commit D", get the key value {(methodC, Move)} of EntityDictionary at "commit C", the modification semantics set of "commit D" is empty set, which means that there is no source entity in the modification semantics of {(methodC, Move)}, therefore, set the key value of EntityDictionary at "commit D" to {(methodC, Unchange)}, the third update result is shown in Table 4; add "commit D" to V.

[0066] Table 4

[0067]

[0068] The fourth update: V = {initial commit, commit A, commit C, commit D}, select "commit A" and its parent version "commit B" to generate the entity methodStart in the history slice of "commit B", similar to the third update, set the key value of EntityDictionary at "commit B" to {(methodA, Unchange)}, the fourth update result is shown in Table 5; add "commit B" to V.

[0069] Table 5

[0070]

[0071] 5th update: V = {Initial commit, Commit A, Commit C, Commit D, Commit B}, pick "Commit B" and its parent version "Commit E" to generate entity methodStart at the history slice of "Commit E", similar to the 3rd update, set the key value of EntityDictionary at "Commit E" to {(methodA, Unchange)}, the result of the 5th update is shown in Table 6, and "Commit E" is added to V.

[0072] Table 6

[0073]

[0074]

[0075] 6th update: V = {Initial commit, Commit A, Commit C, Commit D, Commit B, Commit E}, pick "Commit D" and its parent version "Commit E" to generate entity methodStart at the history slice of "Commit E", the modification semantics set of "Commit E" is empty set, and the key value of EntityDictionary at "Commit E" has been set to {(methodA, Unchange)}, therefore {(methodC, Unchange)} is added to the key value of EntityDictionary at "Commit E"; the state after the 6th update is shown in Table 7.

[0076] Table 7

[0077]

[0078] The 7th update: V={initial submission, submission A, submission C, submission D, submission B, submission E}, select "submission E" and its parent version "submission F" to generate the entity methodStart in the history slice of "submission F", first get the key value of EntityDictionary at "submission E" {(methodA, Unchange), (methodC, Unchange)}, traverse the modification semantics set of "submission F" {(methodA, Rename, methodF)}, wherein the source entity exists in the modification semantics {(methodA, Unchange), (methodC, Unchange)} of {(methodA, Rename, methodF)}, therefore set the key value of EntityDictionary at "submission F" to {(methodF, Rename), (methodC, Unchange)}; the state after the 7th update is shown in Table 8, and thus the history slice of the entity methodStart in all versions is obtained.

[0079] Table 8

[0080]

[0081] The following is an apparatus embodiment of the present application, which can be used to execute the method embodiment of the present application. For details not disclosed in the apparatus embodiment, please refer to the method embodiment of the present application.

[0082] Reference Figure 4 In still another embodiment of the present application, a history slice extraction system of software code is provided, which can be used to implement the history slice extraction method of software code described above. Specifically, the history slice extraction system of software code comprises an information acquisition module, a modification semantics extraction module and a slice extraction module.

[0083] The information acquisition module is configured to acquire the code entity information and version information of the current version of the software code, the code entity information and version information of each historical version of the software code, and the revision history of the software code. The modification semantics extraction module is configured to acquire the modification semantics set of each historical version of the software code according to the revision history of the software code. The slice extraction module is configured to obtain the history slice of each historical version of the software code according to the code entity information and version information of the current version of the software code, the code entity information and version information of each historical version of the software code, and the modification semantics set of each historical version of the software code, and combine the history slices to obtain the history slice of the software code.

[0084] In a possible implementation, the slice extraction module is specifically configured to: initialize historical slices of each historical version of the software code; traverse the current version and each historical version of the software code according to version information of the software code and version information of each historical version of the software code; when the current version of the software code has a parent version, obtain a modification semantic set of the parent version of the current version of the software code and a historical slice of the current version of the software code; and traverse each modification semantic in the modification semantic set of the parent version of the current version of the software code: when the modification semantic corresponding source code of the current modification semantic belongs to the historical slice of the current version of the software code, combine the modification semantic content of the current modification semantic and the modification semantic corresponding target code to obtain new modification semantics, and add the new modification semantics to the historical slice of the parent version of the current version of the software code; and traverse each modification semantic in the historical slice of the current version of the software code: when the modification semantic corresponding target code of the current modification semantic does not belong to the modification semantic set of the parent version of the current version of the software code, combine the modification semantic corresponding target code of the current modification semantic with no modification information to obtain new modification semantics, and add the new modification semantics to the historical slice of the parent version of the current version of the software code; after the current version and each historical version of the software code are traversed, the historical slices of each historical version of the software code are obtained; and the historical slices of each historical version of the software code are combined to obtain the historical slice of the software code.

[0085] In a possible implementation, the code entity information includes a software code entity name, a software code entity unique index name, a software code file path, a software code entity file start line number, a software code entity file end line number, a software code entity file start column number, and a software code entity file end column number.

[0086] In a possible implementation, the obtaining, from the revision history of the software code, of a modification semantic set of each historical version of the software code includes: obtaining, from the revision history of the software code, a revision history of each historical version of the software code; and calling a refactoring detection tool RefactoringMiner to analyze the revision history of each historical version of the software code to obtain the modification semantic set of each historical version of the software code.

[0087] In a possible implementation, the modification semantic set of each historical version of the software code includes a plurality of modification semantics; and the modification semantic includes modification semantic corresponding source code, modification semantic content, and modification semantic corresponding target code.

[0088] In a possible implementation, the modification semantic content includes extraction, renaming, moving, up pushing, down pushing, and deletion.

[0089] The foregoing embodiments of the software code history slice extraction method involve all relevant contents of the steps, which can be cited as the functional description of the functional modules corresponding to the software code history slice extraction system in the embodiments of the present application, and will not be repeated here.

[0090] The division of the modules in the embodiments of the present application is illustrative, and is merely a logical functional division. In actual implementation, there can be another division manner. In addition, each functional module in each embodiment of the present application can be integrated in one processor, or can be a separate physical existence, or two or more modules can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software functional module.

[0091] In another embodiment of the present application, a computer device is provided, which includes a processor and a memory. The memory is configured to store a computer program, and the computer program includes program instructions. The processor is configured to execute the program instructions stored in the computer storage medium. The processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor is the computing core and control core of the terminal, and is suitable for implementing one or more instructions, and is specifically suitable for loading and executing one or more instructions in the computer storage medium to implement a corresponding method flow or a corresponding function. The processor in the embodiments of the present application can be used for the operation of the software code history slice extraction method.

[0092] In still another embodiment, the present application provides a storage medium, specifically a computer readable storage medium (Memory), which is a memory device in a computer device, for storing programs and data. It can be understood that the computer readable storage medium here can include the built-in storage medium of the computer device, and of course can also include the expansion storage medium supported by the computer device. The computer readable storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer readable storage medium here can be a high-speed RAM memory, or a non-volatile memory such as at least one disk memory. One or more instructions stored in the computer readable storage medium can be loaded and executed by the processor to implement the corresponding steps of the historical slice extraction method of the software code in the above embodiments.

[0093] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage, etc.) containing computer-usable program code.

[0094] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a means for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 an apparatus that carries out the functions specified in one or more flows or blocks.

[0095] These computer program instructions can also be stored in a computer readable memory that can direct the computer or other programmable data processing devices to work in a specific manner, so that the instructions stored in the computer readable memory produce a product including instruction means, which implements the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocksFigure 1 the function specified in the one or more blocks.

[0096] These computer program instructions can also be loaded into computer or other programmable data processing devices, so that a series of operation steps are performed on the computer or other programmable data processing devices to generate computer-implemented processes, thus the instructions executed on the computer or other programmable data processing devices provide a process for implementing the flow Figure 1 the flow or flows and / or blocks Figure 1 the steps of the function specified in the one or more blocks.

[0097] Finally, it should be noted that: the above examples are only used to illustrate the technical solutions of the present application, but not to limit it, although the above embodiments of the present application have been described in detail, those skilled in the art should understand: the specific embodiments of the present application can be modified or replaced by the same, without departing from the spirit and scope of the present application, any modification or equivalent replacement, which should be covered within the scope of protection of the claims of the present application.

Claims

1. A method of historical slice extraction of software code, characterized by, The method comprises the following steps: acquiring code entity information and version information of a current version of software code, code entity information and version information of each historical version of the software code, and revision history of the software code; acquiring revision history of each historical version of the software code according to the revision history of the software code; calling a refactoring detection tool RefactoringMiner to analyze the revision history of each historical version of the software code, so as to obtain a modification semantic set of each historical version of the software code; initializing a history slice of each historical version of the software code; traversing the current version and each historical version of the software code according to the version information of the software code and the version information of each historical version of the software code: when the current version of the software code has a parent version, acquiring the modification semantic set of the parent version of the current version of the software code and the history slice of the current version of the software code; and traversing each modification semantic in the modification semantic set of the parent version of the current version of the software code: when the modification semantic corresponding source code of the current modification semantic belongs to the history slice of the current version of the software code, combining the modification semantic content of the current modification semantic and the modification semantic corresponding target code to obtain new modification semantic, and adding the new modification semantic to the history slice of the parent version of the current version of the software code; traversing each modification semantic in the history slice of the current version of the software code: when the modification semantic corresponding target code of the current modification semantic does not belong to the modification semantic set of the parent version of the current version of the software code, combining the modification semantic corresponding target code of the current modification semantic with no modification information to obtain new modification semantic, and adding the new modification semantic to the history slice of the parent version of the current version of the software code; after the current version and each historical version of the software code are traversed, obtaining the history slice of each historical version of the software code.

2. The method of claim 1, wherein, The code entity information comprises a software code entity name, a software code entity unique index name, a software code file path, a software code entity file start line number, a software code entity file end line number, a software code entity start column number and a software code entity end column number.

3. The method of claim 1, wherein, The modification semantic set of each historical version of the software code comprises a plurality of modification semantics; the modification semantic comprises modification semantic corresponding source code, modification semantic content and modification semantic corresponding target code.

4. The method of claim 3, wherein, The modification semantic content comprises extraction, renaming, moving, up pushing, down pushing and deletion.

5. A system for historical slice extraction of software code, characterized in that, The method comprises the following steps: an information acquisition module is configured to acquire code entity information and version information of a current version of software code, code entity information and version information of each historical version of the software code, and revision history of the software code; a modification semantic extraction module is configured to acquire revision history of each historical version of the software code according to the revision history of the software code; and call a refactoring detection tool RefactoringMiner to analyze the revision history of each historical version of the software code, so as to obtain a modification semantic set of each historical version of the software code; The slice extraction module is configured to initialize historical slices of each historical version of the software code; according to version information of the software code and version information of each historical version of the software code, traverse the current version and each historical version of the software code; when the current version of the software code has a parent version, obtain a modification semantic set of the parent version of the current version of the software code and a historical slice of the current version of the software code; and traverse each modification semantic in the modification semantic set of the parent version of the current version of the software code; when modification semantic corresponding source code of the current modification semantic belongs to the historical slice of the current version of the software code, combine modification semantic content of the current modification semantic and modification semantic corresponding target code to obtain new modification semantic, and add the new modification semantic to the historical slice of the parent version of the current version of the software code; and traverse each modification semantic in the historical slice of the current version of the software code; when modification semantic corresponding target code of the current modification semantic does not belong to the modification semantic set of the parent version of the current version of the software code, combine the modification semantic corresponding target code of the current modification semantic with no modification information to obtain new modification semantic, and add the new modification semantic to the historical slice of the parent version of the current version of the software code; after the current version and each historical version of the software code are traversed, the historical slices of each historical version of the software code are obtained. The processor executes the computer program to implement the steps of the historical slice extraction method of the software code according to any one of claims 1 to 4.

6. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The computer program is executed by the processor to implement the steps of the historical slice extraction method of the software code according to any one of claims 1 to 4.

7. A computer-readable storage medium storing a computer program, wherein the computer program comprises the following steps of: ​

Citation Information

Patent Citations

  • Software code fragment history tracing method

    CN110532019A

  • Evolution history slicing method for software code units and code metrics

    CN111290777A