Code repairing method and device, electronic equipment, storage medium and program product
By scanning and previewing the code, the user can directly replace the target problem code after confirming the modification, solving the problem of being unable to preview and adopt the code after repair in the existing technology, and improving the efficiency of code repair.
Patent Information
- Application Number
- CN202510706300.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2025-09-09
AI Technical Summary
The code scanning method in the prior art does not support preview after repair and adoption of repair suggestions, resulting in low code repair efficiency.
A code repair method is provided, which scans the original code information, identifies the problem code, obtains the repair code and previews it, and directly replaces the target problem code after the user confirms the modification.
It improves the efficiency of code repair, enables direct adoption of repaired code, and simplifies the code repair process.
Smart Images

Figure CN120610733A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a code repair method, device, electronic device, storage medium, and program product. Background Art
[0002] In IDEs (such as JetBrains' IDEA), there are many plugins for scanning for code bugs, such as Sonarlint and Alibaba Java Coding Guidelines. These plugins all scan code based on fixed rules, and code repairs are also performed based on these fixed rules. However, existing code scanning methods do not support post-repair preview and the adoption of repair suggestions. Summary of the Invention
[0003] In order to solve the above technical problems, the present disclosure is proposed. Embodiments of the present disclosure provide a code repair method, apparatus, electronic device, storage medium, and program product.
[0004] According to one aspect of an embodiment of the present disclosure, a code repair method is provided, comprising:
[0005] Scanning the original code information to determine at least one problem code in the original code information;
[0006] determining a target problem code from the at least one problem code according to the received pointer instruction;
[0007] Obtaining the repair code corresponding to the target problem code and previewing the repair code;
[0008] According to the received confirmation modification instruction, the target problem code is replaced by the repair code to obtain repair code information.
[0009] Optionally, scanning the original code information to determine at least one problem code in the original code information includes:
[0010] Scanning the original code information using a code problem scanning method to determine the at least one problem code;
[0011] The at least one problem code is highlighted.
[0012] Optionally, determining a target problem code from the at least one problem code according to the received pointer instruction includes:
[0013] Determining instruction position information in the original code information corresponding to the pointer instruction;
[0014] A problem code is determined from the at least one problem code as the target problem code based on the instruction location information.
[0015] Optionally, determining one problem code from the at least one problem code as the target problem code based on the instruction location information includes:
[0016] Determining problem location information corresponding to each problem code according to a start offset and an end offset corresponding to each problem code in the at least one problem code;
[0017] matching the instruction location information with at least one of the problem location information;
[0018] The problem code corresponding to the problem location information matching the instruction location information is determined as the target problem code.
[0019] Optionally, matching the instruction location information with at least one piece of problem location information includes:
[0020] Determining an instruction offset corresponding to the instruction position information;
[0021] The problem location information matching the instruction location information is determined according to a target distance between the instruction offset and at least one of the problem location information.
[0022] Optionally, the determining a target distance between the instruction offset and at least one of the problem location information includes:
[0023] respectively calculating a first distance between the instruction offset and a starting offset corresponding to each piece of the problem position information, and a second distance between the instruction offset and an ending offset corresponding to the problem position information;
[0024] The target distance is determined based on the first distance and the second distance.
[0025] Optionally, obtaining the repair code corresponding to the target problem code and previewing the repair code includes:
[0026] Performing repair processing on the target problem code by using a preset large model to generate the repair code;
[0027] The repair code is previewed and displayed through an independent preview area.
[0028] Optionally, performing repair processing on the target problem code by using a preset large model to generate the repair code includes:
[0029] Sending the target problem code to the preset large model on the server side through a preset interface;
[0030] Performing repair processing on the target problem code by using the preset large model to generate the repair code;
[0031] The repair code fed back by the server is received through the preset interface.
[0032] According to another aspect of an embodiment of the present disclosure, there is provided a code repairing apparatus, comprising:
[0033] a problem scanning module, configured to scan the original code information and determine at least one problem code in the original code information;
[0034] a target determination module, configured to determine a target problem code from the at least one problem code according to the received pointer instruction;
[0035] A code preview module is used to obtain the repair code corresponding to the target problem code and preview the repair code;
[0036] The code replacement module is used to replace the target problem code with the repair code according to the received confirmation modification instruction to obtain repair code information.
[0037] Optionally, the problem scanning module is specifically configured to scan the original code information using a code problem scanning method to determine the at least one problem code; and highlight the at least one problem code.
[0038] Optionally, the target determination module includes:
[0039] a position determining unit, configured to determine instruction position information in the original code information corresponding to the pointer instruction;
[0040] A position matching unit is configured to determine, based on the instruction position information, one of the at least one problem code as the target problem code.
[0041] Optionally, the position matching unit is specifically used to determine the problem position information corresponding to each problem code based on the starting offset and ending offset corresponding to each problem code in the at least one problem code; match the instruction position information with at least one problem position information; and determine the problem code corresponding to the problem position information matching the instruction position information as the target problem code.
[0042] Optionally, when matching the instruction position information with at least one of the problem position information, the position matching unit is used to determine the instruction offset corresponding to the instruction position information; and determine the problem position information that matches the instruction position information based on the target distance between the instruction offset and at least one of the problem position information.
[0043] Optionally, the position matching unit is used to calculate, based on the target distance between the instruction offset and at least one of the problem position information, a first distance between the instruction offset and the starting offset corresponding to each of the problem position information, and a second distance between the instruction offset and the ending offset corresponding to the problem position information; and determine the target distance based on the first distance and the second distance.
[0044] Optionally, the code preview module includes:
[0045] A code repair unit, configured to perform repair processing on the target problem code using a preset large model to generate the repair code;
[0046] The preview display unit is used to preview and display the repair code through an independent preview area.
[0047] Optionally, the code repair unit is specifically used to send the target problem code to the preset large model of the server through a preset interface; perform repair processing on the target problem code through the preset large model to generate the repair code; and receive the repair code fed back by the server through the preset interface.
[0048] According to another aspect of the present disclosure, there is provided an electronic device, including:
[0049] a memory for storing a computer program product;
[0050] The processor is configured to execute the computer program product stored in the memory, and when the computer program product is executed, implement the code repair method described in any one of the above embodiments.
[0051] According to another aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the code repair method described in any of the above embodiments is implemented.
[0052] According to another aspect of the embodiments of the present disclosure, a computer program product is provided, including computer program instructions, which implement the code repair method described in any of the above embodiments when executed by a processor.
[0053] Based on the code repair method, device, electronic device, storage medium and program product provided in the above embodiments of the present disclosure, the original code information is scanned and processed to determine at least one problem code in the original code information; according to the received pointer instruction, the target problem code is determined from the at least one problem code; the repair code corresponding to the target problem code is obtained, and the repair code is previewed and displayed; according to the received confirmation modification instruction, the target problem code is replaced with the repair code to obtain repair code information; the embodiments of the present disclosure propose for the first time to preview and display the repair code, and based on the preview display, the target problem code can be replaced based on the repair code only if the user confirms the modification, thereby realizing the direct adoption of the repair code and improving the efficiency of code repair.
[0054] The technical solution of the present disclosure is further described in detail below through the accompanying drawings and examples. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0056] The present disclosure can be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:
[0057] Figure 1 is a flowchart of a code repair method provided by an exemplary embodiment of the present disclosure;
[0058] Figure 2 is a flowchart of problem code scanning in a code repair method provided by another exemplary embodiment of the present disclosure;
[0059] Figure 3 This is a flowchart of determining a target problem code in a code repair method provided by another exemplary embodiment of the present disclosure;
[0060] Figure 4 1 is a flowchart of determining a target problem code in a code repair method provided by another exemplary embodiment of the present disclosure;
[0061] Figure 5 is a flowchart of previewing repaired code in a code repair method provided by another exemplary embodiment of the present disclosure;
[0062] Figure 6 is a timing diagram of a code repair method provided by another exemplary embodiment of the present disclosure;
[0063] Figure 7a is a diagram showing code problems in a code repair method provided by another exemplary embodiment of the present disclosure;
[0064] Figure 7bis a diagram showing code repair in a code repair method provided by another exemplary embodiment of the present disclosure;
[0065] Figure 8 is a structural diagram of a code repair device provided by an exemplary embodiment of the present disclosure;
[0066] Figure 9 A block diagram of an electronic device according to an embodiment of the present disclosure is illustrated. DETAILED DESCRIPTION
[0067] Below, the exemplary embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all the embodiments of the present disclosure, and it should be understood that the present disclosure is not limited to the exemplary embodiments described herein.
[0068] It should be noted that the relative arrangement of components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present disclosure unless specifically stated otherwise.
[0069] Those skilled in the art will understand that the terms "first" and "second" in the embodiments of the present disclosure are only used to distinguish different steps, devices or modules, and do not represent any specific technical meanings, nor do they indicate a necessary logical order between them.
[0070] It should also be understood that in the embodiments of the present disclosure, “a plurality of” may refer to two or more than two, and “at least one” may refer to one, two, or more than two.
[0071] It should also be understood that any component, data or structure mentioned in the embodiments of the present disclosure can generally be understood as one or more, unless explicitly limited or otherwise indicated in the context.
[0072] In addition, the term "and / or" in this disclosure is merely a description of the association relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this disclosure generally indicates that the related objects are in an "or" relationship. The data referred to in this disclosure can include unstructured data such as text, images, and videos, as well as structured data.
[0073] It should also be understood that the description of the various embodiments in this disclosure focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced with each other. For the sake of brevity, they will not be described one by one.
[0074] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0075] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.
[0076] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.
[0077] It should be noted that like reference numerals and letters refer to like items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0078] The embodiments of the present disclosure can be applied to electronic devices such as terminal devices, computer systems, and servers, and can operate in conjunction with numerous other general-purpose or special-purpose computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments, and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, and servers include, but are not limited to, personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, minicomputer systems, mainframe computer systems, and distributed cloud computing technology environments including any of the above systems, among others.
[0079] Electronic devices such as terminal devices, computer systems, and servers can be described in the general context of computer system-executable instructions (such as program modules) executed by a computer system. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in a distributed cloud computing environment, where tasks are performed by remote processing devices linked via a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media, including storage devices.
[0080] Application Overview
[0081] In the process of implementing the present disclosure, the inventors found that the code repair method in the prior art has at least the following problems: it does not support direct preview of code repair problems, and in addition to providing the repaired code, it also provides a lot of descriptive language text, which makes it impossible to directly apply it to code repair.
[0082] Exemplary Methods
[0083] Figure 1 This is a flowchart of a code repair method provided by an exemplary embodiment of the present disclosure. This embodiment can be applied to electronic devices, such as Figure 1 As shown, the following steps are included:
[0084] Step 102: Scan the original code information to determine at least one problem code in the original code information.
[0085] Optionally, after the problem code is scanned, the problem code can also be rendered onto the code, such as by highlighting. In this embodiment, the scanning of code problems (bugs) can be implemented based on the problem scanning technology in the prior art.
[0086] Step 104: Determine a target problem code from at least one problem code according to the received pointer instruction.
[0087] In one embodiment, the pointer instruction moves according to the user's operation of the mouse. When the user moves the mouse to point to a scanned problem code, the problem code is determined to be the target problem code, and interactive code repair is achieved. The user in this embodiment can be a developer, tester, or other person who can edit the code.
[0088] Step 106: Obtain the repair code corresponding to the target problem code, and preview and display the repair code.
[0089] Optionally, this embodiment can generate the repair code corresponding to the target problem code based on a large model (e.g., an existing AI large model, etc.). In addition, this embodiment proposes to preview the repair code on the code display page through an independent floating page, so that users can understand the code repair more intuitively.
[0090] Step 108: According to the received confirmation modification instruction, the repair code is replaced with the target problem code to obtain repair code information.
[0091] In this embodiment, since the repair code is previewed, the user can directly operate on the repair code after viewing the repair code, for example, by clicking the confirm modification button with the mouse to confirm the modification; since the repair code provided in this application does not include descriptive language, the target problem code can be directly replaced, and the repair code information can be obtained after the replacement; optionally, when replacing the repair code, the position of the code to be replaced can be determined according to the starting offset and ending offset corresponding to the target problem code, and the code at the address can be replaced with the repair code.
[0092] The code repair method provided by the above-mentioned embodiment of the present disclosure scans and processes the original code information to determine at least one problem code in the original code information; determines the target problem code from the at least one problem code according to the received pointer instruction; obtains the repair code corresponding to the target problem code, and previews and displays the repair code; replaces the target problem code with the repair code according to the received confirmation modification instruction to obtain repair code information; the embodiment of the present disclosure proposes for the first time to preview and display the repair code, and based on the preview display, the target problem code can be replaced based on the repair code only if the user confirms the modification, thereby realizing the direct adoption of the repair code and improving the efficiency of code repair.
[0093] Figure 2 FIG. 1 is a flow chart of problem code scanning in a code repair method provided by another exemplary embodiment of the present disclosure. Figure 2 As shown, based on any of the above embodiments, step 102 may include the following steps:
[0094] Step 1021: Scan the original code information using a code problem scanning method to determine at least one problem code.
[0095] Optionally, this embodiment uses any existing technology that can implement code scanning to implement code scanning, and confirms all problematic codes in the original code information. In some optional examples, the code scanning plug-in, for example, the code quality detection assistant SonarLint, performs code scanning, for example, the code quality detection assistant (SonarLint), JavaScript code checker, OWASP security scanner, etc.
[0096] Step 1022: highlight at least one problem code.
[0097] In this embodiment, after the scan is completed, in order to assist the user in quickly locating the problem code, the code problems scanned by AI and the code problems scanned by the code scanning plug-in can also be rendered onto the code; by rendering, part or all of the problem code can be highlighted.
[0098] Figure 3 FIG. 1 is a flow chart of determining a target problem code in a code repair method provided by another exemplary embodiment of the present disclosure. Figure 3 As shown, based on any of the above embodiments, step 104 may include the following steps:
[0099] Step 1041: Determine the instruction location information in the original code information corresponding to the pointer instruction.
[0100] Optionally, when the mouse moves to a certain code in the original code information, the instruction position information can be determined based on the offset of the code selected in the code page according to the pointer instruction corresponding to the mouse in the original code information; wherein, offset: refers to the absolute position of the character in the text content (index in bytes or characters). It is usually used to locate a specific character position in a file, document or editor. Each character has a unique offset, including startOffset (the starting offset of a line in the file) and endOffset (the ending offset of a line in the file). In this embodiment, the offset refers to the absolute position of the code in the original code information.
[0101] Step 1042: Determine a problem code as a target problem code from at least one problem code based on the instruction location information.
[0102] In this embodiment, after each problem code is determined through code scanning, the code position corresponding to each problem code can be determined in combination with the offset; after receiving the pointer instruction and determining the instruction position information, the problem code corresponding to the instruction position information can be determined through position matching, and the problem code is used as the target problem code. This embodiment improves the efficiency and accuracy of problem location through position matching.
[0103] Figure 4 FIG. 1 is a flow chart of determining a target problem code in a code repair method provided by another exemplary embodiment of the present disclosure. Figure 4 As shown, based on any of the above embodiments, step 1042 may include the following steps:
[0104] Step 401: Determine the problem location information corresponding to each problem code according to the start offset and end offset corresponding to each problem code in at least one problem code.
[0105] Optionally, after scanning and determining each problem code, the absolute position of each problem code in the original code information can be determined based on the scanning results, and the starting position and ending position of the absolute position of the problem code can be represented by the starting offset and ending offset to achieve the position representation of each problem code.
[0106] Step 402: Match the instruction location information with at least one piece of problem location information.
[0107] Optionally, an instruction offset corresponding to the instruction position information is determined; and problem position information matching the instruction position information is determined based on a target distance between the instruction offset and at least one problem position information.
[0108] In this embodiment, the absolute position of the pointer instruction corresponding to the original code information is represented by the instruction offset. By matching the instruction offset with at least one problem position information, the problem code pointed to by the pointer instruction can be determined, thereby locating the user's needs.
[0109] Step 403: Determine the problem code corresponding to the problem location information that matches the instruction location information as the target problem code.
[0110] In this embodiment, the instruction location information is matched with the problem location information to determine the problem code pointed to by the pointer instruction, thereby determining the target problem code, thereby improving the efficiency and accuracy of determining the target problem code, and the target problem code determined in this way can be more convenient for obtaining the repair code.
[0111] Optionally, the process of determining the target distance between the instruction offset and the at least one problem location information may specifically include:
[0112] Calculating respectively a first distance between the instruction offset and the starting offset corresponding to each problem position information, and a second distance between the instruction offset and the ending offset corresponding to the problem position information;
[0113] A target distance is determined based on the first distance and the second distance.
[0114] In this embodiment, since each problem location information corresponds to a starting offset and an ending offset, and the pointer instruction only corresponds to the instruction offset, when determining the target distance, the smaller distance value between the first distance and the second distance can be determined as the target distance, or the target distance can be determined based on the sum and average of the first distance and the second distance; the target distance determined by the first distance and the second distance is more accurate, reducing the recognition error problem caused by the close distance between the two problem code positions.
[0115] Figure 5 FIG. 1 is a flow chart of previewing a repaired code in a code repair method provided by another exemplary embodiment of the present disclosure. Figure 5 As shown in the above Figure 1 Based on the illustrated embodiment, step 106 may include the following steps:
[0116] Step 1061: Perform repair processing on the target problem code using a preset large model to generate a repair code.
[0117] Optionally, the target problem code is sent to a preset large model of the server through a preset interface; repair processing is performed on the target problem code through the preset large model to generate a repair code; and the repair code fed back by the server is received through the preset interface.
[0118] Optionally, the preset interface can be an http interface; in this embodiment, the preset big model can be set on the server side, the target problem code is sent to the server side to call the preset big model, the repair code is generated by the big model, and the repair code is received through the preset interface.
[0119] Step 1062: Preview and display the repair code in an independent preview area.
[0120] This embodiment previews the repair code through a preview area independent of the code display area. For example, when the mouse moves to the target problem code, a selection window is provided, and the problem code is repaired according to the user's selection to obtain the repair code. The repair code is previewed in an independent floating preview area according to the selection, which solves the problem that the repair code cannot be previewed in the prior art.
[0121] Figure 6 FIG. 1 is a timing diagram of a code repair method provided by another exemplary embodiment of the present disclosure. Figure 6 As shown, the method provided in this embodiment includes the following steps:
[0122] Step 601, for the original code information that has been scanned and processed; when the user moves the mouse to the target problem code, a description of the target code problem (such as Figure 7a As shown in the figure, the code is schematically represented by a grayscale bar). After selecting "more actions", moving to "Preview repair code" will trigger the monitoring of this button to start repairing the target problem code.
[0123] Step 602: Get a list of all highlighted code information (problem codes) in the current original code information. <highlightinfo>。
[0124] Step 603: Screen out the target problem code corresponding to the mouse. Each problem code includes the start offset (startOffset) and end offset (endOffset) of the code. Set the offset (Offset) where the current mouse is located as currentOffset. Traverse all problem codes, and determine the target problem code according to startOffset < currentOffset < endOffset. Optionally,
[0125] Based on startOffset and endOffset, the included code bugCode, start line startLine, and end line endLine can be obtained.
[0126] Step 604: According to the target problem code and problem cause obtained in Step 603, call the preset AI large model in the server through the http interface, obtain the repair code corresponding to the target problem code, and perform a preview display on the repair code.
[0127] Step 605: When the user left-clicks on "Preview Repair Code", it means that the user accepts the previewed repair code. The plugin will replace the corresponding target problem code with the repair code returned by the server according to the start offset (startOffset) and end offset (endOffset) corresponding to the target problem code. For example, as Figure 7b shown.
[0128] Any code repair method provided by the embodiments of the present disclosure can be executed by any suitable device with data processing capabilities, including but not limited to: terminal devices and servers, etc. Alternatively, any code repair method provided by the embodiments of the present disclosure can be executed by a processor. For example, the processor executes any code repair method mentioned in the embodiments of the present disclosure by calling the corresponding instructions stored in the memory. Details will not be described hereinafter.
[0129] Exemplary devices
[0130] Figure 8 is a schematic structural diagram of a code repair device provided by an exemplary embodiment of the present disclosure. As Figure 8 shown, the device provided in this embodiment includes:
[0131] A problem scanning module 81, configured to scan and process the original code information to determine at least one problem code in the original code information.
[0132] s A target determination module 82, configured to determine a target problem code from at least one problem code according to the received pointer instruction.
[0133] The code preview module 83 is used to obtain the repair code corresponding to the target problem code and preview and display the repair code.
[0134] The code replacement module 84 is configured to replace the target problem code with the repair code according to the received confirmation modification instruction to obtain repair code information.
[0135] The code repair device provided by the above-mentioned embodiment of the present disclosure scans and processes the original code information to determine at least one problem code in the original code information; determines the target problem code from the at least one problem code according to the received pointer instruction; obtains the repair code corresponding to the target problem code, and previews and displays the repair code; replaces the target problem code with the repair code according to the received confirmation modification instruction to obtain repair code information; the embodiment of the present disclosure proposes for the first time to preview and display the repair code, and based on the preview display, the target problem code can be replaced based on the repair code only if the user confirms the modification, thereby realizing the direct adoption of the repair code and improving the efficiency of code repair.
[0136] In some optional embodiments, the problem scanning module 81 is specifically configured to scan the original code information using a code problem scanning method to determine at least one problem code; and highlight the at least one problem code.
[0137] In some optional embodiments, the target determination module 82 includes:
[0138] A position determination unit, configured to determine instruction position information in original code information corresponding to a pointer instruction;
[0139] The position matching unit is used to determine a problem code as a target problem code from at least one problem code based on the instruction position information.
[0140] Optionally, the position matching unit is specifically used to determine the problem position information corresponding to each problem code based on the starting offset and ending offset corresponding to each problem code in at least one problem code; match the instruction position information with at least one problem position information; and determine the problem code corresponding to the problem position information matching the instruction position information as the target problem code.
[0141] Optionally, when matching the instruction position information with at least one problem position information, the position matching unit is used to determine the instruction offset corresponding to the instruction position information; and determine the problem position information that matches the instruction position information based on the target distance between the instruction offset and at least one problem position information.
[0142] Optionally, the position matching unit is used to calculate a first distance between the instruction offset and the starting offset corresponding to each problem position information, and a second distance between the instruction offset and the ending offset corresponding to the problem position information, based on the target distance between the instruction offset and at least one problem position information; and determine the target distance based on the first distance and the second distance.
[0143] In some optional embodiments, the code preview module 83 includes:
[0144] A code repair unit is used to perform repair processing on the target problem code through a preset large model to generate repair code;
[0145] The preview display unit is used to preview the repair code through an independent preview area.
[0146] Optionally, the code repair unit is specifically used to send the target problem code to the preset large model of the server through the preset interface; perform repair processing on the target problem code through the preset large model to generate a repair code; and receive the repair code fed back by the server through the preset interface.
[0147] Exemplary electronic devices
[0148] Below, reference Figure 9 The electronic device according to the embodiment of the present disclosure is described. The electronic device may be either or both of the first device and the second device, or a standalone device independent of them, and the standalone device may communicate with the first device and the second device to receive collected input signals from them.
[0149] Figure 9 A block diagram of an electronic device according to an embodiment of the present disclosure is illustrated.
[0150] like Figure 9 As shown, the electronic device includes one or more processors and memory.
[0151] The processor may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.
[0152] The memory may store one or more computer program products, and the memory may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), a hard disk, flash memory, etc. One or more computer program products may be stored on the computer-readable storage medium, and the processor may execute the computer program products to implement the code repair methods of the various embodiments of the present disclosure described above and / or other desired functions.
[0153] In one example, the electronic device may further include an input device and an output device, and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0154] In addition, the input device may also include, for example, a keyboard, a mouse, and the like.
[0155] The output device can output various information to the outside, including determined distance information, direction information, etc. The output device can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.
[0156] Of course, to simplify, Figure 9 Only some of the components related to the present disclosure in the electronic device are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, the electronic device may further include any other appropriate components according to specific application scenarios.
[0157] In addition to the above-mentioned methods and devices, an embodiment of the present disclosure may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to perform the steps of the code repair method according to various embodiments of the present disclosure described in the above part of this specification.
[0158] The computer program product may be written in any combination of one or more programming languages to implement the operations of the disclosed embodiments, including object-oriented programming languages such as Java, C++, and conventional procedural programming languages such as C or similar programming languages. The program code may be executed entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0159] In addition, an embodiment of the present disclosure may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, causes the processor to execute the steps of the code repair method according to various embodiments of the present disclosure described in the above part of this specification.
[0160] The computer-readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can, for example, include but is not limited to a system, device or component of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0161] The basic principles of the present disclosure have been described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, and effects mentioned in this disclosure are merely illustrative and not restrictive, and should not be construed as necessarily possessed by each embodiment of the present disclosure. Furthermore, the specific details disclosed above are provided for illustrative purposes and to facilitate understanding, rather than as limitations. These details do not limit the present disclosure to necessarily being implemented using these specific details.
[0162] Each embodiment in this specification is described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. References to the same or similar parts between the various embodiments are sufficient. For system embodiments, since they largely correspond to method embodiments, their description is relatively simple. For relevant parts, references to the description of the method embodiments are sufficient.
[0163] The block diagrams of the devices, devices, equipment, and systems involved in this disclosure are intended to be illustrative examples only and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, devices, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including," "comprising," "having," and the like are open-ended words that mean "including but not limited to," and can be used interchangeably therewith. The words "or," "and," and "as used herein refer to the words "and / or," and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as," as used herein, refers to the phrase "such as, but not limited to," and can be used interchangeably therewith.
[0164] The methods and apparatus of the present disclosure may be implemented in many ways. For example, the methods and apparatus of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above unless otherwise specified. In addition, in some embodiments, the present disclosure may also be implemented as programs recorded in a recording medium, which include machine-readable instructions for implementing the methods according to the present disclosure. Thus, the present disclosure also covers recording media that store programs for executing the methods according to the present disclosure.
[0165] It should also be noted that in the apparatus, device, and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.
[0166] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0167] The above description has been provided for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although a number of example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.< / highlightinfo>
Claims
1. A code repair method, characterized in that: include: Scanning the original code information to determine at least one problem code in the original code information; determining a target problem code from the at least one problem code according to the received pointer instruction; Obtaining the repair code corresponding to the target problem code and previewing the repair code; According to the received confirmation modification instruction, the target problem code is replaced by the repair code to obtain repair code information.
2. The method according to claim 1, characterized in that The scanning of the original code information to determine at least one problem code in the original code information includes: Scanning the original code information using a code problem scanning method to determine the at least one problem code; The at least one problem code is highlighted.
3. The method according to claim 1 or 2, characterized in that Determining a target problem code from the at least one problem code according to the received pointer instruction includes: Determining instruction position information in the original code information corresponding to the pointer instruction; A problem code is determined from the at least one problem code as the target problem code based on the instruction location information.
4. The method according to claim 3, characterized in that The determining, based on the instruction location information, one of the problem codes as the target problem code from the at least one problem code comprises: Determining problem location information corresponding to each problem code according to a start offset and an end offset corresponding to each problem code in the at least one problem code; matching the instruction location information with at least one of the problem location information; The problem code corresponding to the problem location information matching the instruction location information is determined as the target problem code.
5. The method according to claim 4, characterized in that The matching of the instruction location information with at least one piece of problem location information includes: Determining an instruction offset corresponding to the instruction position information; The problem location information matching the instruction location information is determined according to a target distance between the instruction offset and at least one of the problem location information.
6. The method according to claim 5, characterized in that The target distance between the instruction offset and at least one of the problem position information includes: respectively calculating a first distance between the instruction offset and a starting offset corresponding to each piece of the problem position information, and a second distance between the instruction offset and an ending offset corresponding to the problem position information; The target distance is determined based on the first distance and the second distance.
7. The method according to any one of claims 1 to 6, characterized in that: The obtaining of the repair code corresponding to the target problem code and previewing the repair code includes: Performing repair processing on the target problem code by using a preset large model to generate the repair code; The repair code is previewed and displayed through an independent preview area.
8. The method according to claim 7, characterized in that The performing repair processing on the target problem code by using a preset large model to generate the repair code includes: Sending the target problem code to the preset large model on the server side through a preset interface; Performing repair processing on the target problem code by using the preset large model to generate the repair code; The repair code fed back by the server is received through the preset interface.
9. A code repair device, characterized in that: include: a problem scanning module, configured to scan the original code information and determine at least one problem code in the original code information; a target determination module, configured to determine a target problem code from the at least one problem code according to the received pointer instruction; A code preview module is used to obtain the repair code corresponding to the target problem code and preview the repair code; The code replacement module is used to replace the target problem code with the repair code according to the received confirmation modification instruction to obtain repair code information.
10. An electronic device, characterized in that: include: a memory for storing a computer program product; A processor is configured to execute a computer program product stored in the memory, and when the computer program product is executed, implements the code repair method according to any one of claims 1 to 8.
11. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the code repair method described in any one of claims 1 to 8 is implemented.
12. A computer program product comprising computer program instructions, characterized in that When the computer program instructions are executed by a processor, the code repair method described in any one of claims 1 to 8 is implemented.