Code recommendation method and device, equipment and medium

By extracting the target-related code segments corresponding to the cursor position and entering the big model, the processor errors and semantic incompleteness caused by excessive code files are solved, the accuracy and efficiency of code recommendations are improved, and the semantic understanding of the big model is enhanced.

CN119248243AActive Publication Date: 2025-01-03BEIJING QIHOOD TECHNOLOGY CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411774818.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-01-03
Estimated Expiration
2044-12-04

AI Technical Summary

Technical Problem

During the code development process, due to the limitations of model and hardware resources, the code file is too long and causes errors in the processor's video memory, code truncation or semantics, causing model illusions and generation errors, affecting the accuracy and efficiency of code recommendations.

Method used

By obtaining the cursor information in the editor, extract the target-related code segments corresponding to the cursor position, including the above and below code segments, and enter a large model to improve the accuracy and efficiency of code recommendations, and avoid errors caused by code length exceeding the threshold.

Benefits of technology

It improves the accuracy and efficiency of code recommendations, reduces the code length of model input, avoids the problems of processor memory errors and incomplete code semantics, and enhances the semantic understanding and integrity of the large model in code recommendations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248243A_ABST
    Figure CN119248243A_ABST
Patent Text Reader

Abstract

The invention discloses a code recommendation method and device, equipment and a medium. The method comprises the steps that according to cursor information in an editor and code structure information of a current file in the editor, target related code information such as a target preceding text related code segment and a target following text related code segment with complete semantics corresponding to the cursor information is extracted from the current file; and inputting the cursor information and the target related code information into the target large model to obtain the target recommendation code information corresponding to the cursor information, so that the correlation between the target related code information and the cursor information is ensured to a certain extent, the extraction efficiency of the target related code information corresponding to the cursor information is improved, and the user experience is improved. And the relevance between the process of performing code recommendation by using the target large model and the cursor context is improved by inputting target related code information with complete semantics, so that the semantic comprehension integrity in the process of performing code recommendation by using the target large model is kept, and the code recommendation accuracy is improved, thereby assisting developers to realize intelligent office.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a code recommendation method, device, equipment and medium. Background Art

[0002] In the code development scenario, developers generally need to rely on the mouse and keyboard to write code during the code development process. The speed of code writing depends entirely on the software engineer's proficiency in the mouse and keyboard, and each operation is delayed, resulting in low interaction efficiency and code writing efficiency in the entire code development process.

[0003] In related technologies, in order to simplify the code development process, intelligent code completion and code generation tools are gradually being used to assist developers in code development. These tools usually use machine learning technology, especially natural language processing (NLP) models, to predict and recommend code snippets. However, due to the limitations of models and hardware resources, code files are often too long and cannot be processed well. For example, the processor may crash due to memory errors, or the code may be truncated directly and arbitrarily, resulting in incomplete code semantics, which may cause model illusion problems, or code duplication and generation errors. Summary of the invention

[0004] The embodiments of the present application provide a code recommendation method, apparatus, device and medium, which not only ensures the relevance of target-related code information and cursor information to a certain extent, but also improves the extraction efficiency of cursor information corresponding to target-related code information, and improves the relevance of the code recommendation process using the target large model and the cursor context by inputting target-related code information with complete semantics, maintains the integrity of semantic understanding in the code recommendation process of the target large model, and improves the accuracy of code recommendation. The above technical solution is as follows: In a first aspect, an embodiment of the present application provides a code recommendation method, the method comprising: Get the cursor information in the editor; the above cursor information includes the cursor position; According to the cursor information and the code structure information of the current file in the editor, the target-related code information corresponding to the cursor information is extracted from the current file; the target-related code information includes a target-related code segment with complete semantics corresponding to the cursor information; the target-related code segment includes at least one of the following: a target-previous-context-related code segment and a target-next-context-related code segment corresponding to the cursor position; The cursor information and the target-related code information are input into the target macro model to obtain the target recommended code information corresponding to the cursor information.

[0005] In a possible implementation, extracting target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor includes: According to the code structure information of the current file in the editor, determine the target class code range where the cursor position is located in the current file; The target-related code information corresponding to the above cursor information is extracted from the target class code range of the above current file.

[0006] In a possible implementation, extracting the target-related code information corresponding to the cursor information from the target class code range of the current file includes: In the case where the code length of the target class code range is less than or equal to the threshold, determining the target context-related code segment according to the first starting position of the target class code range and the cursor position, and / or determining the target context-related code segment according to the first ending position of the target class code range and the cursor position; In the case where the code length of the target class code range is greater than the threshold, determining the target function information corresponding to the cursor position within the target class code range; When the target function information is less than or equal to the threshold, the target context-related code segment is determined according to the second starting position of the target function information and the cursor position, and / or the target context-related code segment is determined according to the second ending position of the target function information and the cursor position.

[0007] In a possible implementation, extracting target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor includes: According to the code structure information of the current file in the editor, determine the target class code range where the cursor position is located in the current file; Extracting the initial relevant code information corresponding to the cursor information from the target class code range of the current file according to the code length of the target class code range; According to the first function variable information within the target class code range, the second function variable information outside the target class code range in the current file is filtered to obtain the target function variable information related to the first function variable information; The target related code information corresponding to the cursor information is determined according to the initial related code information and the target function variable information.

[0008] In a possible implementation, before inputting the cursor information and the target-related code information into the target macro model to obtain the target recommended code information corresponding to the cursor information, the method further includes: In the case where the text length corresponding to the current file is less than or equal to the threshold, the full text information corresponding to the current file is determined as the target-related code information corresponding to the cursor information; When the text length corresponding to the above-mentioned current file is greater than the above-mentioned threshold value, the above-mentioned step of extracting the target-related code information corresponding to the above-mentioned cursor information from the above-mentioned current file according to the above-mentioned cursor information and the code structure information of the current file in the above-mentioned editor is executed.

[0009] In a possible implementation, before inputting the cursor information and the target-related code information into the target macro model to obtain the target recommended code information corresponding to the cursor information, the method further includes: In the case where the cursor position is not located within any function scope of the current file or is only located within the class function scope of the current file or is not located within any sub-element of the current file, the target-related code information corresponding to the cursor information is determined according to the function information set corresponding to the current file and the cursor position; and / or In the case that the current file is a file of a specified language, the code information corresponding to a preset context line number at the cursor position in the current file is determined as the target-related code information corresponding to the cursor information.

[0010] In a possible implementation, after inputting the cursor information and the target-related code information into the target macro model to obtain the target recommended code information corresponding to the cursor information, the method further includes: Determine the target recommendation code length corresponding to the target recommendation code information; According to the cursor position and the target recommended code length, the target recommended code information is displayed in the editing interface corresponding to the editor in a preset display mode.

[0011] In a second aspect, an embodiment of the present application provides a code recommendation device, the code recommendation device comprising: An acquisition module is used to acquire cursor information in the editor; the cursor information includes the cursor position; An extraction module is used to extract target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor; the target-related code information includes a target-related code segment with complete semantics corresponding to the cursor information; the target-related code segment includes at least one of the following: a target-previous-context-related code segment and a target-next-context-related code segment corresponding to the cursor position; The code recommendation module is used to input the above cursor information and the above target related code information into the target macro model to obtain the target recommended code information corresponding to the above cursor information.

[0012] In a third aspect, an embodiment of the present application provides an electronic device, including: a processor and a memory; The processor is connected to the memory; The above-mentioned memory is used to store executable program code; The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the method provided by the first aspect of the embodiment of this specification or any possible implementation of the first aspect.

[0013] In a fourth aspect, an embodiment of the present specification provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the method provided by the first aspect of the embodiment of the present specification or any possible implementation of the first aspect.

[0014] In one or more embodiments of the present application, on the one hand, according to the cursor information in the editor and the code structure information of the current file in the editor, target-related code information (target-related code segments) such as target context-related code segments and target context-related code segments with complete semantics corresponding to the cursor information are extracted from the current file, so that by only extracting the current file instead of the entire target project file, the code to be analyzed is less than the code of the entire target project project, and the correlation between the target-related code information and the cursor information is ensured to a certain extent, while improving the extraction efficiency of the target-related code information corresponding to the cursor information, and the extraction of the complete semantic code information corresponding to the cursor position can be realized according to the code structure information of the current file where the cursor is located in the editor; on the other hand, the cursor information and the target-related code information with complete semantics are input into the target project file. The target large model uses target-related code information with complete semantics to assist the target large model in generating target recommended code information corresponding to the cursor information, which not only reduces the code length input by the target large model, but also avoids the current file where the cursor is located being too long and directly inputting the target large model, which may cause the processor to report a memory error and crash, or the code is directly truncated at will, resulting in incomplete code semantics, which may cause model hallucination problems, or code duplication and generation errors, etc., improves the efficiency of the target large model in generating target recommended code information, and improves the correlation between the code recommendation process using the target large model and the cursor context by inputting target-related code information with complete semantics, maintains the integrity of semantic understanding in the process of code recommendation by the target large model, improves the accuracy of code recommendation, and then uses the target large model to assist developers in realizing artificial intelligence (AI) office.

[0015] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0017] Figure 1 A schematic diagram of the architecture of a code recommendation system provided for an exemplary embodiment of the present application; Figure 2 A flowchart of a code recommendation method provided for an exemplary embodiment of the present application; Figure 3 A schematic diagram of a process for extracting target-related code information provided by an exemplary embodiment of the present application; Figure 4 A schematic diagram of another extraction flow of target-related code information provided by an exemplary embodiment of the present application; Figure 5 A flowchart of another code recommendation method provided for an exemplary embodiment of the present application; Figure 6 A flowchart of another code recommendation method provided for an exemplary embodiment of the present application; Figure 7 A schematic diagram of displaying target recommendation code information provided by an exemplary embodiment of the present application; Figure 8 A schematic diagram of an implementation process of a code recommendation method provided by an exemplary embodiment of the present application; Fig. 9 A schematic diagram of the structure of a code recommendation device provided by an exemplary embodiment of the present application; Fig.10 A schematic structural diagram of an electronic device provided as an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0018] In order to make the features and advantages of the present application more obvious and easy to understand, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

[0019] The terms "first", "second", "third", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0020] Please refer to the following Figure 1 , which is a schematic diagram of the architecture of a code recommendation system provided by an exemplary embodiment of this specification. Figure 1 As shown, the code recommendation system may include: a terminal 110 and a server 120. Among them: The terminal 110 can interact with the server 120 through the network to receive messages from the server 120 or send messages to the server 120. The terminal 110 can be hardware or software. When the terminal 110 is hardware, it can be various electronic devices, including but not limited to smart watches, smart phones, tablet computers, laptop portable computers and desktop computers. When the terminal 110 is software, it can be installed in the electronic devices listed above, which can be implemented as multiple software or software modules (for example: used to provide distributed services), or it can be implemented as a single software or software module, which is not specifically limited here.

[0021] In the embodiments of the present specification, the terminal 110 may be a user terminal corresponding to a user who needs code recommendation, such as a software developer. In the process of a user using an editor to write a code file, the cursor information in the editor on the terminal 110 may be obtained, but is not limited to, the cursor information including the cursor position. After obtaining the cursor information, the terminal 110 may first extract the target-related code information corresponding to the cursor information from the current file based on the cursor information and the code structure information of the current file in the editor, the target-related code information including the target-related code segment with complete semantics corresponding to the cursor information, and the target-related code segment including at least one of the following: the target context-related code segment corresponding to the cursor position and the target context-related code segment. Then, the cursor information and the target-related code information are input into the target large model to obtain the target recommended code information corresponding to the cursor information.

[0022] Optionally, after the terminal 110 obtains the cursor information in the editor and the target-related code information corresponding to the cursor information, the cursor information in the above-mentioned editor and the target-related code information corresponding to the cursor information can also be directly sent to the server 120 through the network, so that the server 120 generates and returns the target recommended code information corresponding to the cursor information according to the code recommendation method provided in the embodiment of the present application.

[0023] Server 120 can be a server that provides various code recommendation services or software supply chain map construction services. It should be noted that server 120 can be hardware or software. When server 120 is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When server 120 is software, it can be implemented as multiple software or software modules (for example, used to provide distributed services), or it can be implemented as a single software or software module, which is not specifically limited here. Server 120 can be, but is not limited to, a hardware server, a virtual server, a cloud server, etc.

[0024] Specifically, after receiving the cursor information in the editor sent by the terminal 110 and the target-related code information corresponding to the cursor information, the server 120 can also perform corresponding code recommendations through the code recommendation method provided in the embodiment of the present application and return the generated corresponding target recommended code information to the terminal 110.

[0025] It can be understood that the code recommendation method provided in the embodiment of the present application can be executed by the terminal 110 alone, by the server 120 alone, or by the terminal 110 and the server 120 together, and the embodiment of the present application is not limited to this.

[0026] The network may be a medium providing a communication link between the terminal 110 and the server 120, or may be the Internet including network devices and transmission media, but is not limited thereto. The transmission media may be a wired link, such as but not limited to coaxial cable, optical fiber, and digital subscriber line (DSL), or a wireless link, such as but not limited to wireless fidelity (WIFI), Hypertext Transfer Protocol (HTTP), Bluetooth, and mobile device network, etc.

[0027] Understandably, Figure 1 The number of terminals 110 and servers 120 in the code recommendation system shown is only an example. In a specific implementation, the code recommendation system may include any number of terminals 110 and servers 120.

[0028] Next, combine Figure 1 , taking the execution of code recommendation by terminal 110 as an example, the code recommendation method provided by an exemplary embodiment of the present application is introduced. For details, please refer to Figure 2 , which exemplarily shows a flowchart of a code recommendation method provided in an embodiment of the present application. Figure 2 As shown, the code recommendation method includes the following steps: S201, obtaining cursor information in the editor, where the cursor information includes a cursor position.

[0029] Specifically, a code recommendation function is provided in the editor. In the process of a user using an editor to write code, when the code recommendation function of the editor is turned on, the cursor information in the editor can be obtained first, so that code recommendations can be implemented based on the cursor information later. In addition to including the cursor position, the above cursor information may also include, but is not limited to, the line code information where the above cursor position is located. The above cursor position may be the line information where the cursor is located in the editor, and may also include the line information and column information where the cursor is located in the editor, which is not limited in the embodiments of the present application.

[0030] S202, extracting target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor, wherein the target-related code information includes a target-related code segment with complete semantics corresponding to the cursor information.

[0031] Specifically, the above-mentioned current file is the code file that the developer is currently editing in the editor. The above-mentioned code structure information may include the abstract syntax tree information corresponding to the current file, and may also include but is not limited to the class code information in the current file (such as but not limited to the line number range of each type of code and the corresponding attribute information, etc.) and function code information (such as but not limited to the line number range of each function code and the corresponding attribute information, variable information, etc.). The above-mentioned target-related code segment may include but is not limited to at least one of the following: the target context-related code segment corresponding to the cursor position and the target context-related code segment. The above-mentioned target-related code information may also include the target position information corresponding to the target-related code segment, so as to not only provide the target-related code segment corresponding to the cursor position for code recommendation for the target large model, but also provide the relationship between the corresponding position of the target-related code segment and the cursor position, thereby improving the accuracy of code recommendation for the target large model.

[0032] Alternatively, if Figure 3 As shown, the implementation process of extracting target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor in S202 may include but is not limited to: S301, determining a target class code range where a cursor is located in the current file according to code structure information of the current file in the editor.

[0033] Specifically, when a user writes code using an editor, the content of the current file in the editor can be parsed in real time or at preset intervals (for example, but not limited to every 1 minute, every 30 seconds, etc.), an abstract syntax tree of the code in the current file can be identified and constructed, and then the abstract syntax tree can be traversed to locate the target class node at the cursor position (cursor position), and the target class code range of the target class node can be determined. The above-mentioned target class code range can be, but is not limited to, composed of the first starting position information (for example, but not limited to the number of code lines where the first starting position is located) and the first ending position information (for example, but not limited to the number of code lines where the first ending position is located) of the above-mentioned target class node.

[0034] S302, extracting target-related code information corresponding to the cursor information from the target class code range of the current file.

[0035] Optionally, one or more target code segments with complete semantics can be extracted directly from the target class code range of the current file according to the code structure within the target class code range of the current file, for example but not limited to extracting all target code segments with complete semantics within the target class code range or the target context-related code segment and / or target context-related code segment within the target class code range that is closest to the cursor position, thereby obtaining the target-related code information corresponding to the cursor information.

[0036] Optionally, after determining the target class code range where the cursor position is located in the current file, it is possible to first determine whether the code length of the target class code range is less than or equal to a threshold. In the case where the code length of the target class code range is less than or equal to the threshold, it means that the code length corresponding to the target class code range where the cursor is located will not exceed the input length threshold of the target large model, that is, the code segment corresponding to the target class code range with complete semantics will not be truncated due to the input data being too long, so that the input data semantics is not complete enough to affect the accuracy of code recommendation. Then, the target context-related code segment can be directly determined according to the first starting position and cursor position of the target class code range, that is, the above-mentioned target context-related code segment can be a code segment in the corresponding range from the first starting position to the cursor position in the current file, and / or, the target context-related code segment is determined according to the first ending position and cursor position of the target class code range, that is, the above-mentioned target context-related code segment can be a code segment in the corresponding range from the cursor position to the first ending position in the current file. The above threshold is less than or equal to the input length threshold of the target large model, so that the target-related code information with complete semantics can be obtained while avoiding the data length input to the target large model exceeding the input length threshold of the target large model.

[0037] When the code length of the target class code range is greater than the threshold, it means that the code length corresponding to the target class code range where the cursor is located is likely to exceed the input length threshold of the target large model, that is, in the code recommendation process, it is likely that the corresponding code segment in the target class code range with complete semantics is too long, resulting in truncation when input into the target large model, resulting in incomplete semantics and affecting the accuracy of code recommendation. In this case, the target function information corresponding to the cursor position in the target class code range can be determined first, and then when the target function information is less than or equal to the threshold, the target context-related code segment can be determined according to the second starting position of the target function information and the cursor position, that is, the above-mentioned target context-related code segment can be a code segment in the range from the second starting position to the cursor position in the current file, and / or, the target context-related code segment can be determined according to the second ending position of the target function information and the cursor position, that is, the above-mentioned target context-related code segment can be a code segment in the range from the cursor position to the second ending position in the current file. When the target function information is greater than a threshold, the sub-element with complete semantics in the target function information, namely, the target context-related code segment and / or the target context-related code segment, can be directly extracted according to the cursor position, for example, but not limited to directly extracting the sub-element with complete semantics at the cursor position, or the previous sub-element with complete semantics at the cursor position (target context-related code segment) and / or the next sub-element with complete semantics (target context-related code segment), or directly extracting the sub-element with the greatest code relevance to the cursor position in the target function information, etc.

[0038] The embodiments of the present application not only ensure the semantic integrity of the target-related code information extracted from the current file to improve the accuracy of the code recommendation of the target large model, but also reduce the code length input by the target large model, so as to avoid the current file where the cursor is located being too long and directly inputting the target large model, which may cause the processor to report a memory error and crash, or the code to be truncated directly and arbitrarily, resulting in incomplete code semantics, which may cause model illusion problems, or code duplication and generation errors, thereby improving the efficiency of the target large model in generating target recommended code information.

[0039] Alternatively, if Figure 4 As shown, the implementation process of extracting target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor in S202 may include but is not limited to: S401, determining a target class code range where a cursor is located in the current file according to code structure information of the current file in the editor.

[0040] Specifically, the above S401 is consistent with S301 and will not be repeated here.

[0041] S402: extracting initial relevant code information corresponding to the cursor information from the target class code range of the current file according to the code length of the target class code range.

[0042] Specifically, the initial relevant code information may include, but is not limited to, an initial relevant code segment with complete semantics corresponding to the cursor position, such as, but not limited to, an initial preceding relevant code segment and / or an initial following relevant code segment. The method for extracting the initial relevant code information is consistent with the second optional implementation of extracting the target relevant code information in S302, and will not be described in detail here.

[0043] Optionally, when the cursor position is not within the scope of any class code in the current file, if the cursor position is within a function code segment, the function code segment where the cursor position is located can be directly extracted as the initial related code segment; if the cursor position is also within a function code segment, the previous function code segment and / or the next function code segment corresponding to the cursor position can be directly extracted as the initial related code segment, thereby ensuring the integrity of the extracted initial related code segment.

[0044] Please continue to refer to Figure 4 ,like Figure 4 As shown, after determining the target class code range where the cursor is located in the current file according to the code structure information of the current file in the editor, the above S401 may further include: S403: Filter the second function variable information outside the target class code range in the current file according to the first function variable information within the target class code range to obtain the target function variable information related to the first function variable information.

[0045] Specifically, in order to enhance the correlation between the initial relevant code information corresponding to the cursor position and other code segments in the current file, and improve the integrity and semantic richness of the target relevant code information, the second function variable information outside the target class code range in the current file can also be filtered according to the first function variable information within the target class code range, such as but not limited to filtering out the second function variable information related to the first function variable information within the target class code range from all the second function variable information outside the target class code range in the current file, such as but not limited to filtering out the second function variable information that has the same variable name as the local variable or parameter in the first function variable information, or not only has the same variable name but also has the same corresponding variable value, that is, obtaining the target function variable information related to the first function variable information, thereby avoiding the problem that the relevant code segment (initial relevant code information) corresponding to the cursor position has less semantics that affects the accuracy of the target large model code recommendation.

[0046] It can be understood that the above S403 and S402 can be executed simultaneously or one after another, and this embodiment of the present application does not limit this.

[0047] S404, determining target related code information corresponding to the cursor information according to the initial related code information and the target function variable information.

[0048] Specifically, after obtaining the initial relevant code information corresponding to the cursor information and the target function variable information related to the initial relevant code information, the initial relevant code information and the target function variable information can be directly combined, for example but not limited to splicing, to obtain the target relevant code information with complete semantics corresponding to the cursor information.

[0049] Please continue to refer to Figure 2 ,like Figure 2 As shown, in the above S202, according to the cursor information and the code structure information of the current file in the editor, the target-related code information corresponding to the cursor information is extracted from the current file, and the target-related code information includes the target-related code segment with complete semantics corresponding to the cursor information. The code recommendation method also includes: S203, inputting the cursor information and the target-related code information into the target macro model to obtain the target recommended code information corresponding to the cursor information.

[0050] Specifically, after obtaining the cursor information and target-related code information, the above information is input into the target big model for processing by calling the API interface of the target big model (for example, but not limited to a big model based on a deep neural network, a big language model, etc.). The target big model is used to analyze the structure, syntax, and semantics of the input target-related code information, and understand the function and intention of the code, so that the corresponding target recommended code information can be generated for the cursor information such as the cursor position and the code corresponding to the cursor position, so as to recommend the code content that may need to be written at the cursor position, and assist the developer to complete the code writing more efficiently. The above-mentioned target recommended code information may include the target recommended code, and may also include the target code annotation and / or target recommendation reason corresponding to the target recommended code, so that the developer can more intuitively understand the meaning of the target recommended code and the reason for recommending the target recommended code.

[0051] In the embodiment of the present application, on the one hand, according to the cursor information in the editor and the code structure information of the current file in the editor, target-related code information (target-related code segments) such as target context-related code segments and target context-related code segments with complete semantics corresponding to the cursor information are extracted from the current file, so that by only extracting the current file instead of the entire target project file, the code to be analyzed is less than the code of the entire target project project, and the correlation between the target-related code information and the cursor information is ensured to a certain extent, while improving the extraction efficiency of the target-related code information corresponding to the cursor information, and the extraction of the complete semantic code information corresponding to the cursor position can be realized according to the code structure information of the current file where the cursor is located in the editor; on the other hand, the cursor information and the target-related code information with complete semantics are input into the target large project file. The target-related code information with complete semantics is used to assist the target large model in generating the target recommended code information corresponding to the cursor information, which not only reduces the code length input by the target large model, but also avoids the current file where the cursor is located being too long and directly inputting the target large model, which may cause the processor to report a memory error and crash, or the code is directly truncated at will, resulting in incomplete code semantics, which may cause hallucination problems of the model, or code duplication and generation errors, thereby improving the efficiency of the target large model in generating target recommended code information. By inputting the target-related code information with complete semantics, the correlation between the code recommendation process using the target large model and the cursor context is improved, the integrity of the semantic understanding in the code recommendation process of the target large model is maintained, and the accuracy of the code recommendation is improved, and then the target large model is used to assist developers in realizing AI smart office and improving code development efficiency.

[0052] Please refer to Figure 5 , which exemplarily shows a flowchart of another code recommendation method provided by an embodiment of the present application. Figure 5 As shown, the code recommendation method includes the following steps: S501, obtaining cursor information in the editor, where the cursor information includes a cursor position.

[0053] Specifically, S501 is consistent with S201 and will not be described in detail here.

[0054] S502, determining whether the text length corresponding to the current file is less than or equal to a threshold.

[0055] Specifically, the above threshold is less than or equal to the input length threshold of the target large model, so that target-related code information with complete semantics can be obtained while avoiding the data length of the input target large model exceeding the input length threshold of the target large model.

[0056] S503: When the text length corresponding to the current file is less than or equal to the threshold, the full text information corresponding to the current file is determined as the target-related code information corresponding to the cursor information.

[0057] Specifically, when the text length corresponding to the current file is less than or equal to the threshold, it means that even if the entire current file is input into the target large model, it may not exceed the input length threshold of the target large model. The full-text information corresponding to the current file can be directly determined as the target-related code information corresponding to the cursor information to ensure the integrity and analyzability of the input data of the target large model.

[0058] S504, when the text length corresponding to the current file is greater than a threshold, extract target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor.

[0059] Specifically, when the text length corresponding to the current file is greater than the threshold, the extraction process of the target-related code information in the above S504 is consistent with the above S202, which will not be repeated here.

[0060] Optionally, please continue to refer to Figure 5 ,like Figure 5 As shown, after obtaining the cursor information in the editor in S501, the code recommendation method may also include but is not limited to: S505, when the cursor position is not located within any function scope of the current file or is only located within the class function scope of the current file or is not located within any sub-element of the current file, determine the target-related code information corresponding to the cursor information based on the function information set corresponding to the current file and the cursor position.

[0061] Specifically, in addition to determining the method of extracting the target-related code information based on the text length corresponding to the current file, the target-related code information corresponding to the cursor information can also be determined directly based on the function information set corresponding to the current file and the cursor position when the cursor position is not located within any function range of the current file, or is only located within the class function range of the current file, or is not located within any sub-element in the current file. That is, when the cursor position is not located within any code segment with complete semantics in the current file, the function information set of the current file can be directly extracted, and filtered according to the cursor position to obtain the target-related code information corresponding to the cursor information. The above-mentioned function information set can include, but is not limited to, each function code segment in the current file and the corresponding function code position information. For example, but not limited to, the function information corresponding to the function code segment closest to the cursor position in the function information set of the current file can be directly determined as the target-related code information.

[0062] and / or S506: When the current file is a file of a specified language, the code information corresponding to the preset context line number at the cursor position in the current file is determined as the target-related code information corresponding to the cursor information.

[0063] Specifically, since the statements of some specified languages ​​such as SQL are complete in themselves, each statement cannot be associated with other statements. Therefore, when the current file is a file of the specified language, the code information of the preset number of context lines (for example, but not limited to two lines above and below or five lines, etc.) corresponding to the cursor position in the current file can be directly determined as the target-related code information corresponding to the cursor information, so as to realize the extraction of target-related code information with complete semantics.

[0064] S507, input the cursor information and target-related code information into the target macro model to obtain target recommended code information corresponding to the cursor information.

[0065] Specifically, S507 is consistent with S203 and will not be described in detail here.

[0066] Please refer to Figure 6 , which exemplarily shows a flowchart of another code recommendation method provided by an embodiment of the present application. Figure 6 As shown, the code recommendation method includes the following steps: S601, obtaining cursor information in the editor, where the cursor information includes a cursor position.

[0067] Specifically, S601 is consistent with S201 and will not be described in detail here.

[0068] S602, extracting target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor, wherein the target-related code information includes a target-related code segment with complete semantics corresponding to the cursor information.

[0069] Specifically, S602 is consistent with S202 and will not be repeated here.

[0070] S603, inputting the cursor information and the target-related code information into the target macro model, and obtaining the target recommended code information corresponding to the cursor information.

[0071] Specifically, S603 is consistent with S203 and will not be repeated here.

[0072] S604, determining the target recommended code length corresponding to the target recommended code information.

[0073] Specifically, after obtaining the target recommended code information corresponding to the cursor information, you can also first determine the target recommended code length corresponding to the target recommended code information, so that when the target recommended code is displayed later, you can understand the position where the following code of the cursor position should be moved down.

[0074] S605 , displaying the target recommended code information in an editing interface corresponding to the editor in a preset display mode according to the cursor position and the target recommended code length.

[0075] Specifically, after determining the target recommended code length corresponding to the target recommended code information, the following code at the cursor position can be moved down by the corresponding number of lines according to the target recommended code length, and then the target recommended code information can be displayed at the cursor position in the editing interface corresponding to the editor, so that the user can intuitively understand the target recommended code information and its corresponding layout in the editing interface corresponding to the editor, thereby improving the visibility and practicality of the code recommendation. The above target recommended code information can be, but is not limited to, displayed in a ghost font.

[0076] For example, Figure 7 As shown, after obtaining the cursor position 710 and the target recommendation code 720, the target recommendation code 720 can be directly displayed in a ghost font with the cursor position 710 as the starting point. At the same time, the acceptance control 730 corresponding to the target recommendation code 720 can also be displayed in the form of a pop-up window, but is not limited to it. When the developer wants to use the target recommendation code 720 directly, it can be but is not limited to directly clicking the acceptance control 730 to insert the target recommendation code 720 at the cursor position 710, without the user having to complete the insertion and use of the target recommendation code 720 by copying and pasting, further assisting developers to improve the efficiency of code writing.

[0077] Please refer to the following Figure 8 , which exemplarily shows a schematic diagram of the implementation process of a code recommendation method provided in an embodiment of the present application. Figure 8 As shown, when developers use an editor to write code files, they can first obtain the environment information of the editor, such as obtaining the project information in the editor first, and then obtain the file currently being edited in the editor (the current file) from the project information, and obtain the cursor information in the current file (such as but not limited to the cursor position, the code corresponding to the cursor position, etc.) and the code structure information corresponding to the current file (such as but not limited to class code information, function code information, etc.). Then, based on the cursor information and code structure information, extract the target-related code information with complete semantics corresponding to the cursor information in the current file. The above extraction method can be but not limited to referring to the above Figure 2-5The extraction method described in the corresponding embodiment will not be repeated here. Then, the cursor information and the target-related code information are input into the target macro model, and the target recommended code information corresponding to the cursor information is output. In addition, the target recommended code length corresponding to the target recommended code information can also be determined. And according to the cursor position, the target recommended code length and the target recommended code information, the editing interface corresponding to the editor is displayed in a preset display mode.

[0078] Please refer to the following Fig. 9 , which is a schematic diagram of the structure of a code recommendation device provided by an exemplary embodiment of the present application. Fig. 9 As shown, the code recommendation device 900 includes: The acquisition module 910 is used to acquire cursor information in the editor; the cursor information includes the cursor position; The extraction module 920 is used to extract the target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor; the target-related code information includes the target-related code segment with complete semantics corresponding to the cursor information; the target-related code segment includes at least one of the following: the target-previous-context-related code segment and the target-next-context-related code segment corresponding to the cursor position; The code recommendation module 930 is used to input the above cursor information and the above target-related code information into the target macro model to obtain the target recommended code information corresponding to the above cursor information.

[0079] In a possible implementation, the extraction module 920 includes: A first determining unit, configured to determine a target class code range where the cursor is located in the current file according to code structure information of the current file in the editor; The first extraction unit is used to extract the target-related code information corresponding to the cursor information from the target class code range of the current file.

[0080] In a possible implementation, the extraction unit is specifically used to: In the case where the code length of the target class code range is less than or equal to the threshold, determining the target context-related code segment according to the first starting position of the target class code range and the cursor position, and / or determining the target context-related code segment according to the first ending position of the target class code range and the cursor position; In the case where the code length of the target class code range is greater than the threshold, determining the target function information corresponding to the cursor position within the target class code range; When the target function information is less than or equal to the threshold, the target context-related code segment is determined according to the second starting position of the target function information and the cursor position, and / or the target context-related code segment is determined according to the second ending position of the target function information and the cursor position.

[0081] In a possible implementation, the extraction module 920 includes: A second determining unit is used to determine the target class code range where the cursor position is located in the current file according to the code structure information of the current file in the editor; A second extraction unit is used to extract the initial relevant code information corresponding to the cursor information from the target class code range of the current file according to the code length of the target class code range; A filtering unit, configured to filter the second function variable information outside the target class code range in the current file according to the first function variable information within the target class code range, to obtain target function variable information related to the first function variable information; The third determining unit is used to determine the target related code information corresponding to the cursor information according to the initial related code information and the target function variable information.

[0082] In a possible implementation, the code recommendation device 900 further includes: A first determination module is used to determine the full text information corresponding to the current file as the target-related code information corresponding to the cursor information when the text length corresponding to the current file is less than or equal to a threshold value; The extraction module 920 is specifically used for: when the text length corresponding to the current file is greater than the threshold, executing the step of extracting the target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor.

[0083] In a possible implementation, the code recommendation device 900 further includes: A second determination module is used to determine the target-related code information corresponding to the cursor information according to the function information set corresponding to the current file and the cursor position when the cursor position is not located within any function range of the current file or is only located within the class function range of the current file or is not located within any sub-element in the current file; and / or The third determination module is used to determine the code information of the preset context line number corresponding to the cursor position in the current file as the target-related code information corresponding to the cursor information when the current file is a file of a specified language.

[0084] In a possible implementation, the code recommendation device 900 further includes: A fourth determination module, used to determine the target recommended code length corresponding to the above target recommended code information; The display module is used to display the target recommended code information in the editing interface corresponding to the editor according to a preset display mode according to the cursor position and the target recommended code length.

[0085] The division of the modules in the above-mentioned code recommendation device is only for illustration. In other embodiments, the code recommendation device can be divided into different modules as needed to complete all or part of the functions of the above-mentioned code recommendation device. The implementation of each module in the code recommendation device provided in the embodiment of this specification can be in the form of a computer program. The computer program can be run on a terminal or a server. The program modules constituted by the computer program can be stored in the memory of the terminal or the server. When the computer program is executed by the processor, all or part of the steps of the code recommendation method described in the embodiment of this specification are implemented.

[0086] See next Fig.10 , which is a schematic diagram of the structure of an electronic device provided by an exemplary embodiment of this specification. Fig.10 As shown, the electronic device 1000 may include: at least one processor 1010 , at least one communication bus 1020 , a user interface 1030 , at least one network interface 1040 , and a memory 1050 .

[0087] The communication bus 1020 may be used to realize the connection and communication among the above-mentioned components.

[0088] The user interface 1030 may include a display screen (Display) and a camera (Camera), and the optional user interface 1030 may also include a standard wired interface and a wireless interface.

[0089] The network interface 1040 may optionally include a Bluetooth module, a Near Field Communication (NFC) module, a Wireless Fidelity (Wi-Fi) module, and the like.

[0090] Among them, the processor 1010 may include one or more processing cores. The processor 1010 uses various interfaces and lines to connect various parts of the entire electronic device 1000, and executes various functions and processes data of the routing electronic device 1000 by running or executing instructions, programs, code sets or instruction sets stored in the memory 1050, and calling data stored in the memory 1050. Optionally, the processor 1010 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 1010 can be an integrated processor (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU) and a modem. One or more combinations thereof. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 1010, but may be implemented separately through a chip.

[0091] Among them, the memory 1050 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory, ROM). Optionally, the memory 1050 includes a non-transitory computer-readable medium. The memory 1050 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 1050 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as an acquisition function, an extraction function, a code recommendation function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 1050 may also be optionally at least one storage device located away from the aforementioned processor 1010. As Fig.10 As shown, the memory 1050 as a computer storage medium may include an operating system, a network communication module, a user interface module, and program instructions.

[0092] In some possible embodiments, the electronic device 1000 may be the aforementioned Fig. 9In the code recommendation device 900 shown, the processor 1010 can be used to call the program instructions stored in the memory 1050, and specifically perform the following operations: obtain cursor information in the editor; the above cursor information includes the cursor position; according to the above cursor information and the code structure information of the current file in the above editor, extract the target related code information corresponding to the above cursor information from the above current file; the above target related code information includes the target related code segment with complete semantics corresponding to the above cursor information; the above target related code segment includes at least one of the following: the target previous related code segment and the target next related code segment corresponding to the above cursor position; the above cursor information and the above target related code information are input into the target large model to obtain the target recommended code information corresponding to the above cursor information.

[0093] In some possible embodiments, when the processor 1010 executes the above-mentioned extraction of target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor, it is specifically used to execute: According to the code structure information of the current file in the editor, the target class code range where the cursor position is located in the current file is determined; and the target related code information corresponding to the cursor information is extracted from the target class code range of the current file.

[0094] In some possible embodiments, when the processor 1010 executes the extraction of the target-related code information corresponding to the cursor information from the target class code range of the current file, it is specifically used to execute: when the code length of the target class code range is less than or equal to a threshold, the target context-related code segment is determined according to the first starting position of the target class code range and the cursor position, and / or, the target context-related code segment is determined according to the first ending position of the target class code range and the cursor position; when the code length of the target class code range is greater than the threshold, the target function information corresponding to the cursor position within the target class code range is determined; when the target function information is less than or equal to the threshold, the target context-related code segment is determined according to the second starting position of the target function information and the cursor position, and / or, the target context-related code segment is determined according to the second ending position of the target function information and the cursor position.

[0095] In some possible embodiments, when the processor 1010 executes the above-mentioned extraction of target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor, it is specifically used to execute: determining the target class code range where the cursor position is located in the current file according to the code structure information of the current file in the editor; extracting the initial related code information corresponding to the cursor information from the target class code range of the current file according to the code length of the target class code range; filtering the second function variable information outside the target class code range in the current file according to the first function variable information within the target class code range to obtain the target function variable information related to the first function variable information; determining the target related code information corresponding to the cursor information according to the initial related code information and the target function variable information.

[0096] In some possible embodiments, before the processor 1010 executes the above-mentioned step of inputting the cursor information and the target-related code information into the target large model to obtain the target recommended code information corresponding to the cursor information, it is also used to execute: when the text length corresponding to the current file is less than or equal to a threshold, the full-text information corresponding to the current file is determined as the target-related code information corresponding to the cursor information; when the text length corresponding to the current file is greater than the threshold, the step of extracting the target-related code information corresponding to the cursor information from the current file based on the cursor information and the code structure information of the current file in the editor is executed.

[0097] In some possible embodiments, before the processor 1010 executes the above-mentioned inputting of the cursor information and the target-related code information into the target big model to obtain the target recommended code information corresponding to the cursor information, it is also used to execute: when the cursor position is not located within any function scope of the current file or is only located within the class function scope of the current file or is not located within any sub-element in the current file, determine the target-related code information corresponding to the cursor information according to the function information set corresponding to the current file and the cursor position; and / or, when the current file is a file of a specified language class, determine the code information of a preset number of context lines corresponding to the cursor position in the current file as the target-related code information corresponding to the cursor information.

[0098] In some possible embodiments, after the processor 1010 executes the input of the cursor information and the target-related code information into the target macro model to obtain the target recommended code information corresponding to the cursor information, it is also used to execute: determining the target recommended code length corresponding to the target recommended code information; and displaying the target recommended code information in the editing interface corresponding to the editor according to a preset display method based on the cursor position and the target recommended code length.

[0099] The embodiment of the present application also provides a computer storage medium, which stores instructions, and when the instructions are executed on a computer or a processor, the computer or the processor executes one or more steps in any of the above methods. If the components of the above code recommendation device are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above storage medium.

[0100] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The above computer program product includes one or more computer instructions. When the above computer program instructions are loaded and executed on a computer, the above process or function according to the embodiment of the present application is generated in whole or in part. The above computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The above computer instructions may be stored in a computer-readable storage medium or transmitted through the above computer-readable storage medium. The above computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The above computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The above available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.

[0101] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes. In the absence of conflict, the technical features in this embodiment and the implementation scheme can be combined arbitrarily.

[0102] The above-mentioned embodiments are merely preferred embodiments of the present application and are not intended to limit the scope of the present application. Without departing from the design spirit of the present application, various modifications and improvements made to the technical solutions of the present application by ordinary technicians in this field should fall within the protection scope determined by the claims of the present application.

Claims

1. A code recommendation method, characterized in that: include: Obtaining cursor information in the editor; the cursor information includes the cursor position; Extracting target-related code information corresponding to the cursor information from the current file according to the cursor information and code structure information of the current file in the editor; The target-related code information includes a target-related code segment with complete semantics corresponding to the cursor information; the target-related code segment includes at least one of the following: a target-previous-context-related code segment and a target-next-context-related code segment corresponding to the cursor position; The cursor information and the target-related code information are input into the target macro model to obtain the target recommended code information corresponding to the cursor information.

2. The method according to claim 1, characterized in that The step of extracting target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor includes: Determine the target class code range where the cursor position is located in the current file according to the code structure information of the current file in the editor; The target-related code information corresponding to the cursor information is extracted from the target class code range of the current file.

3. The method according to claim 2, characterized in that The extracting target-related code information corresponding to the cursor information from the target class code range of the current file includes: In the case where the code length of the target class code range is less than or equal to a threshold, determining the target context-related code segment according to the first starting position of the target class code range and the cursor position, and / or determining the target context-related code segment according to the first ending position of the target class code range and the cursor position; When the code length of the target class code range is greater than the threshold, determining the target function information corresponding to the cursor position within the target class code range; When the target function information is less than or equal to the threshold, the target context-related code segment is determined according to the second starting position of the target function information and the cursor position, and / or the target context-related code segment is determined according to the second ending position of the target function information and the cursor position.

4. The method according to claim 1, characterized in that The step of extracting target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor includes: Determine the target class code range where the cursor position is located in the current file according to the code structure information of the current file in the editor; Extracting initial relevant code information corresponding to the cursor information from the target class code range of the current file according to the code length of the target class code range; Filtering the second function variable information outside the target class code range in the current file according to the first function variable information within the target class code range to obtain the target function variable information related to the first function variable information; The target related code information corresponding to the cursor information is determined according to the initial related code information and the target function variable information.

5. The method according to claim 1, characterized in that Before inputting the cursor information and the target-related code information into the target macro model to obtain the target recommended code information corresponding to the cursor information, the method further includes: In the case where the text length corresponding to the current file is less than or equal to a threshold, determining the full text information corresponding to the current file as the target-related code information corresponding to the cursor information; When the text length corresponding to the current file is greater than the threshold, the step of extracting target-related code information corresponding to the cursor information from the current file based on the cursor information and the code structure information of the current file in the editor is performed.

6. The method according to claim 1, characterized in that Before inputting the cursor information and the target-related code information into the target macro model to obtain the target recommended code information corresponding to the cursor information, the method further includes: In a case where the cursor position is not located within any function scope of the current file or is only located within a class function scope of the current file or is not located within any sub-element in the current file, determining target-related code information corresponding to the cursor information according to a function information set corresponding to the current file and the cursor position; and / or In the case that the current file is a file of a specified language, code information corresponding to a preset context line number at a cursor position in the current file is determined as target-related code information corresponding to the cursor information.

7. The method according to claim 1, characterized in that After inputting the cursor information and the target-related code information into the target macro model to obtain the target recommended code information corresponding to the cursor information, the method further includes: Determine the target recommended code length corresponding to the target recommended code information; According to the cursor position and the target recommended code length, the target recommended code information is displayed in an editing interface corresponding to the editor in a preset display manner.

8. A code recommendation device, characterized in that: The code recommendation device comprises: An acquisition module, used for acquiring cursor information in the editor; the cursor information includes a cursor position; An extraction module is used to extract target-related code information corresponding to the cursor information from the current file according to the cursor information and the code structure information of the current file in the editor; the target-related code information includes a target-related code segment with complete semantics corresponding to the cursor information; the target-related code segment includes at least one of the following: a target-previous-context-related code segment and a target-next-context-related code segment corresponding to the cursor position; The code recommendation module is used to input the cursor information and the target-related code information into the target macro model to obtain the target recommended code information corresponding to the cursor information.

9. An electronic device, characterized in that: include: processor and memory; wherein, The processor is connected to the memory; the memory is used to store executable program code; The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the method steps according to any one of claims 1 to 7.

10. A computer storage medium, characterized in that: The computer storage medium stores a plurality of instructions, which are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Information recommendation method and device, equipment, storage medium and program product

    CN116560632A

  • Code generation method and device, computer equipment and storage medium

    CN117971185A

  • SQL (Structured Query Language) code completion method and device, medium and computing equipment

    CN118210487A

  • Code prompting method

    CN118444895A

  • Code interception method and code range determination method

    CN118733109A