Method, device and equipment for intelligently complementing codes

By employing a dual filtering mechanism of pre-processing and post-processing interception, the resource waste and duplicate display issues of existing code completion systems are resolved, thereby improving the efficiency and accuracy of code completion and enhancing the user experience.

CN121680809APending Publication Date: 2026-03-17ALIBABA (CHINA) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511676101.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-14
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing code completion systems suffer from resource waste, repetitive display that disrupts user experience, lack of concurrency control, and insufficient intelligence, making it impossible to perform code completion efficiently and accurately.

Method used

A dual filtering mechanism of pre-processing and post-processing interception is adopted. The request interceptor performs multi-level interception of candidate code completion requests to determine the target code completion request. After generating candidate code completion content through a large language model, difference analysis and similarity checks are performed to ensure the accuracy and efficiency of the displayed content.

Benefits of technology

It reduces invalid requests and duplicate completion displays, improves system performance and user experience, and achieves efficient and accurate code completion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121680809A_ABST
    Figure CN121680809A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a code intelligent completion method, device and equipment. In the embodiment of the invention, a candidate code completion request is obtained, and the candidate code completion request is triggered through a code document change or cursor movement event in a code editor; performing front interception on the candidate code completion request, and determining a target code completion request; sending the target code completion request to a large language model, and receiving candidate code completion content sent by the large language model; performing post-processing interception on the candidate code completion content, and determining target code completion content; and sending the target code completion content to the code editor. Through the method, code completion can be efficiently and accurately carried out, invalid requests are reduced by adopting pre-interception, repeated completion content display is reduced by adopting post-processing interception, and the use experience of a user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and more specifically, to a method, apparatus, and device for intelligent code completion. Background Technology

[0002] With the popularization of artificial intelligence (AI)-assisted programming tools, intelligent code completion has become an important tool for improving developers' programming efficiency.

[0003] Existing code completion systems often suffer from the following problems: code editors frequently send invalid requests, leading to serious waste of system resources and overall performance degradation; repeatedly displaying the same code completion results interferes with user programming and affects user experience; lack of effective concurrency control and resource management mechanisms makes it difficult to cope with concurrent request conflicts in fast editing scenarios; and insufficient intelligence, failing to provide accurate completion and intelligent display based on user behavior patterns.

[0004] In conclusion, how to perform code completion efficiently and accurately, and improve the user experience, is a problem that needs to be solved. Summary of the Invention

[0005] In view of this, embodiments of the present invention provide a method, apparatus, and device for intelligent code completion, which can perform code completion efficiently and accurately, reduce invalid requests by pre-interception, reduce the display of duplicate completed content by post-processing interception, and improve the user experience.

[0006] In a first aspect, embodiments of the present invention provide a method for intelligent code completion, the method comprising: acquiring candidate code completion requests, wherein the candidate code completion requests are triggered by code document changes or cursor movement events in a code editor; pre-intercepting the candidate code completion requests to determine a target code completion request; sending the target code completion request to a large language model and receiving candidate code completion content sent by the large language model; post-processing and intercepting the candidate code completion content to determine the target code completion content; and sending the target code completion content to the code editor.

[0007] Optionally, the step of pre-intercepting the candidate code completion request to determine the target code completion request specifically includes: determining the corresponding code editor based on the candidate code completion request; in response to the code editor meeting the pre-set code completion requirements, performing multi-level pre-interception on the candidate code completion request; and in response to the candidate code completion request passing the multi-level pre-interception, determining the candidate code completion request as the target code completion request.

[0008] Optionally, the pre-set code completion requirements include: the code editor being the main editor and the prediction function of the code editor being enabled.

[0009] Optionally, the step of determining the candidate code completion request as the target code completion request in response to the candidate code completion request passing the multi-level pre-interception specifically includes: determining a non-duplicate code completion request in response to the candidate code completion request passing the duplicate display filtering; determining a delayed code completion request in response to the non-duplicate code completion request passing the delay debouncing mechanism; and determining the target code completion request in response to the delayed code completion request passing the legality check.

[0010] Optionally, the step of determining non-duplicate code completion requests in response to the candidate code completion requests through duplicate display filtering specifically includes: querying the rejection cache based on the candidate code completion requests, wherein the rejection cache includes the code completion content rejected by the user, its corresponding cursor position, and the display time; and in response to the rejection cache not finding the user-rejected code completion content corresponding to the candidate code completion request, determining the candidate code completion request as the non-duplicate code completion request.

[0011] Optionally, the response to the non-duplicate code completion request is determined by a delay debouncing mechanism to establish a delayed code completion request. Specifically, this includes: if the code document has not been changed and no cursor movement event has been sent within the set time period for non-duplicate code generation, the non-duplicate code completion request is determined as the delayed code completion request.

[0012] Optionally, the step of post-processing and intercepting the candidate code completion content to determine the target code completion content specifically includes: segmenting the candidate code completion content to determine at least one difference; filtering the at least one difference content using change amount control to determine at least one candidate valid completion content; performing similarity checks and empty change checks on the at least one candidate valid completion content to determine at least one valid completion content; querying the rejection cache based on the at least one valid completion content, and in response to the fact that no code completion content corresponding to the valid completion content is found in the rejection cache, determining the at least one valid completion content as the target code completion content.

[0013] Optionally, the method further includes: saving the target code completion content to a completion result cache; or, saving the target code completion content to a rejection cache.

[0014] Optionally, the method further includes: querying the completion result cache according to the target code completion request, and in response to the existence of code content corresponding to the target code completion request in the completion result cache, determining the code content corresponding to the target code completion request as the code completion content.

[0015] Secondly, embodiments of the present invention provide an apparatus for intelligent code completion, the apparatus comprising: an acquisition unit, configured to acquire candidate code completion requests, wherein the candidate code completion requests are triggered by code document changes or cursor movement events in a code editor; a pre-processing unit, configured to pre-intercept the candidate code completion requests and determine a target code completion request; a transmission unit, configured to send the target code completion request to a large language model and receive candidate code completion content sent by the large language model; and a post-processing unit, configured to post-process and intercept the candidate code completion content to determine the target code completion content; the transmission unit is further configured to send the target code completion content to the code editor.

[0016] Optionally, the pre-processing unit is specifically configured to: determine the corresponding code editor based on the candidate code completion request; in response to the code editor meeting the pre-set code completion requirements, perform multi-level pre-processing interception on the candidate code completion request; and in response to the candidate code completion request passing the multi-level pre-processing interception, determine the candidate code completion request as the target code completion request.

[0017] Optionally, the pre-set code completion requirements include: the code editor being the main editor and the prediction function of the code editor being enabled.

[0018] Optionally, the front-end unit is further configured to: determine a non-duplicate code completion request in response to the candidate code completion request being filtered for repeated display; determine a delayed code completion request in response to the non-duplicate code completion request being filtered for delayed debouncing; and determine the target code completion request in response to the delayed code completion request being checked for validity.

[0019] Optionally, the front-end unit is further configured to: query the rejection cache according to the candidate code completion request, wherein the rejection cache includes the code completion content rejected by the user, its corresponding cursor position and display time; in response to not finding the user-rejected code completion content corresponding to the candidate code completion request in the rejection cache, determine the candidate code completion request as the non-duplicate code completion request.

[0020] Optionally, the front-end unit is further configured to: in response to the fact that the code document has not been changed and no cursor movement event has been sent within the non-repeating code generation set time, determine the non-repeating code completion request as the delayed code completion request.

[0021] Optionally, the post-processing unit is further configured to: segment the candidate code completion content to determine at least one difference; filter the at least one difference content by change amount control to determine at least one candidate valid completion content; perform similarity checks and empty change checks on the at least one candidate valid completion content to determine at least one valid completion content; query the rejection cache based on the at least one valid completion content, and in response to the failure to find the code completion content corresponding to the valid completion content in the rejection cache, determine the at least one valid completion content as the target code completion content.

[0022] Optionally, the apparatus further includes: a storage unit, configured to save the target code completion content to a completion result cache; or, to save the target code completion content to a rejection cache.

[0023] Optionally, the device further includes a query unit, configured to query the completion result cache according to the target code completion request, and in response to the existence of code content corresponding to the target code completion request in the completion result cache, determine the code content corresponding to the target code completion request as the code completion content.

[0024] Thirdly, embodiments of the present invention provide an electronic device, including a memory and a processor, wherein the memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method as described in the first aspect or any one of the possible methods of the first aspect.

[0025] Fourthly, embodiments of the present invention provide a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the method as described in the first aspect or any one of the possibilities of the first aspect.

[0026] In this embodiment of the invention, candidate code completion requests are obtained, wherein the candidate code completion requests are triggered by code document changes or cursor movement events in the code editor; the candidate code completion requests are pre-intercepted to determine the target code completion request; the target code completion request is sent to a large language model, and candidate code completion content sent by the large language model is received; the candidate code completion content is post-processed and intercepted to determine the target code completion content; and the target code completion content is sent to the code editor. Through this method, code completion can be performed efficiently and accurately. Pre-interception reduces invalid requests, and post-processing interception reduces the display of duplicate completion content, thus improving the user experience. Attached Figure Description

[0027] The above and other objects, features and advantages of the present invention will become clearer from the following description of embodiments of the invention with reference to the accompanying drawings, in which: Figure 1 This is a schematic diagram of a code intelligent completion system according to an embodiment of the present invention; Figure 2 This is a flowchart of a code intelligent completion method according to an embodiment of the present invention; Figure 3 This is a flowchart of a pre-interception method according to an embodiment of the present invention; Figure 4 This is a flowchart of another pre-interception method in an embodiment of the present invention; Figure 5 This is a flowchart of a post-processing interception method according to an embodiment of the present invention; Figure 6 This is a flowchart of the code intelligent completion method in an embodiment of the present invention; Figure 7 This is a schematic diagram of a code intelligent completion device according to an embodiment of the present invention; Figure 8 This is a schematic diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0028] The present application is described below based on embodiments, but it is not limited to these embodiments. In the detailed description of the present application below, certain specific details are described in detail. Those skilled in the art can fully understand the present application without these details. To avoid obscuring the substance of the present application, well-known methods, processes, flows, elements, and circuits are not described in detail.

[0029] Furthermore, those skilled in the art should understand that the accompanying drawings provided herein are for illustrative purposes only and are not necessarily drawn to scale.

[0030] Unless the context explicitly requires it, words such as "including" or "contains" throughout the application should be interpreted as including rather than exclusive or exhaustive; that is, meaning "including but not limited to".

[0031] In the description of this application, it should be understood that the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, in the description of this application, unless otherwise stated, "a plurality of" means two or more.

[0032] In existing technologies, common code completion systems suffer from the following problems: code editors frequently send invalid requests, leading to serious waste of system resources and overall performance degradation; repeatedly displaying the same code completion results interferes with user programming and affects user experience; lack of effective concurrency control and resource management mechanisms makes it difficult to handle concurrent request conflicts in fast editing scenarios; and insufficient intelligence prevents accurate completion and intelligent display based on user behavior patterns. Traditional rule-based filtering schemes suffer from fixed rules, inability to adapt to complex scenarios, and low filtering accuracy; simple delay mechanisms have fixed delay times, cannot be dynamically adjusted according to user behavior, and lack intelligent caching; frequency-based filtering schemes cannot handle new scenarios, statistical data is easily outdated, and lacks context awareness; single-dimensional duplicate detection schemes only consider content similarity, ignoring position and time factors, and are prone to misjudgment; other schemes based on machine learning prediction filtering, dynamic adjustment based on user feedback, and semantic analysis intelligent filtering have drawbacks such as requiring large amounts of training data, cold start, high complexity, and difficulty in meeting real-time requirements. Therefore, it is crucial to perform code completion efficiently and accurately, reduce invalid requests, minimize the display of duplicate completed content, reduce resource consumption, and improve the user experience.

[0033] In this embodiment of the invention, code completion is achieved by designing a system for intelligent code completion. Specifically, the system for intelligent code completion is as follows: Figure 1As shown, the system includes a code editor 101, a request interceptor 102, and a large language model 103. The code editor 101 can be an Integrated Development Environment (IDE) code editor, allowing users to open code documents and make code changes, including editing and modifying code. When code changes or cursor movement occur in the code editor, a candidate code completion request is triggered. The code editor sends this request to the request interceptor 102, which performs pre-interception to identify the target code completion request. The request interceptor 102 then sends the target code completion request to the large language model 103, which generates candidate code completion content and sends it to the request interceptor 102. The request interceptor 102 performs post-processing interception on the candidate code completion content to identify the target code completion content, which is then sent to the code editor 101 for display.

[0034] In this embodiment of the invention, to solve the above problems, the request interceptor 102 plays a crucial role in the intelligent code completion system. Using the request interceptor 102 as the execution entity, a method for intelligent code completion is proposed, specifically as follows: Figure 2 As shown, the method includes: Step S201: Obtain candidate code completion requests.

[0035] Specifically, the candidate code completion request is triggered by code document changes or cursor movement events in the code editor.

[0036] In one possible implementation, the candidate code completion request is sent by the code editor to the request interceptor. The conditions under which the code editor triggers the generation of the candidate code completion request include changes to the code document in the code editor, cursor movement events, and the user closing the IDE syntax service.

[0037] In this embodiment of the invention, the code document modification includes operations such as inserting, deleting, and replacing code documents, for example, the user inputs new code, deletes existing code, or pastes code snippets; the cursor movement event includes operations such as clicking and keyboard navigation, for example, the user clicks the cursor to a new position, uses the arrow keys to move the cursor, or jumps to a definition.

[0038] The code editor is used to listen for changes to the code document and cursor movement events, and to obtain the candidate code completion request.

[0039] Step S202: Pre-intercept the candidate code completion requests to determine the target code completion request.

[0040] In one possible implementation, the step of intercepting the candidate code completion requests in advance to determine the target code completion request is as follows: Figure 3 As shown, it includes the following steps: Step S301: Determine the corresponding code editor based on the candidate code completion request.

[0041] Specifically, the candidate code completion request carries an identifier of the code editor, which indicates the code editor that sent the candidate code completion request.

[0042] Step S302: In response to the code editor meeting the preset code completion requirements, the candidate code completion request is intercepted at multiple levels.

[0043] Specifically, the pre-set code completion requirements include: the code editor being the main editor and the prediction function of the code editor being enabled.

[0044] In one possible implementation, in response to the code editor being the main editor and the existence of the code completion item corresponding to the candidate code completion request, the code editor is ensured to be executed in the correct environment; if the code editor is not the main editor, the candidate code completion request is in unit test mode, and the subsequent code completion process is not triggered to avoid interference from the test environment; when the code editor is determined to be the main editor, it is further determined whether the prediction function of the code editor is enabled, and in response to the prediction function of the code editor being enabled, the candidate code completion request is intercepted at multiple levels.

[0045] In one possible implementation, before performing multi-level pre-interception on the candidate code completion request, it is also necessary to check whether the code editor has a running completion task to avoid resource contention and poor user experience caused by concurrent execution.

[0046] Step S303: In response to the candidate code completion request passing the multi-level pre-interception, determine the candidate code completion request as the target code completion request.

[0047] In one possible implementation, the response to the candidate code completion request is determined to be the target code completion request through the multi-level pre-interception, specifically as follows: Figure 4 The process includes the following steps: Step S401: In response to the candidate code completion request, determine the non-duplicate code completion request through repeated display filtering.

[0048] Specifically, the rejection cache is queried based on the candidate code completion request, wherein the rejection cache includes the code completion content rejected by the user, its corresponding cursor position, and the display time; in response to the rejection cache not finding the user-rejected code completion content corresponding to the candidate code completion request, the candidate code completion request is determined as the non-duplicate code completion request.

[0049] In one possible implementation, the displayed time refers to the time when the user-rejected code completion content is displayed in the code editor interface. The rejection cache can also store the hash value corresponding to the cursor position as a cache key. The candidate code completion request carries the candidate cursor position, which is converted into a candidate hash value. The rejection cache is queried based on the candidate hash value. If the user-rejected code completion content corresponding to the candidate code completion request is not found in the rejection cache, the candidate code completion request is determined as the non-duplicate code completion request. If the user-rejected code completion content corresponding to the candidate code completion request is found in the rejection cache, the processing ends.

[0050] In one possible implementation, the cursor position is represented by a file path and a range of line numbers. This method checks whether the current cursor position is within the range of the last completion, thus avoiding the repeated display of code completion content at the same location.

[0051] Step S402: In response to the non-repeating code completion request, a delayed code completion request is determined through a delay debouncing mechanism.

[0052] Specifically, in response to the non-duplicate code generation set time, if the code document is not changed and no cursor movement event is sent, the non-duplicate code completion request is determined as the delayed code completion request.

[0053] In one possible implementation, if the code document changes or a cursor movement event occurs, the non-repeating code completion request is canceled. Through a cancelable delayed task mechanism, frequent triggering of code completion requests during rapid editing can be avoided. During the delay period, the code document is checked for changes, and if changes are found, the current task is canceled and the timer restarts.

[0054] Step S403: In response to the validity check of the delayed code completion request, determine the target code completion request.

[0055] Specifically, the validity check refers to checking for blank content, single symbols, excessive import statements, etc. For example, filtering blank content can avoid meaningless completion; filtering single symbols, such as filtering single closing curly braces, which do not need to be completed; filtering excessive import statements to avoid completion results mainly consisting of import statements; if the validity check passes, the delayed code completion request is determined to be the target code completion request; if the validity check fails, the processing ends.

[0056] In this embodiment of the invention, the delay time is dynamically adjusted based on the cursor position, display time, and user editing mode to balance response speed and request frequency. Accurate cache matching is performed in the rejection cache based on hash value to avoid duplicate processing. A multi-layered filtering and verification mechanism is used for pre-interception before sending the target code completion request.

[0057] Step S203: Send the target code completion request to the large language model and receive the candidate code completion content sent by the large language model.

[0058] Specifically, the Large Language Model (LLM) can also be called a large model or a large language model, etc. The large language model is a deep learning model based on a transformer architecture that can process and generate natural language text. It is usually trained on a large amount of text data and has the ability to understand and generate language. It is widely used in dialogue systems, text generation and other natural language processing tasks. In the embodiments of this invention, code completion is mainly performed through context.

[0059] In this embodiment of the invention, after receiving the target code completion request, the large language model constructs a prompt context, generates candidate code completion content based on the prompt context, and sends the candidate code completion content to the request interceptor.

[0060] Step S204: Post-process and intercept the candidate code completion content to determine the target code completion content.

[0061] Specifically, the process of post-processing and intercepting the candidate code completion content to determine the target code completion content is as follows: Figure 5 As shown, it includes the following steps: Step S501: Segment the completion results of the candidate code completion content to determine at least one difference.

[0062] Specifically, the differences between the candidate code completion content and the original document are calculated, and an inline diff utility is used to perform precise difference analysis to identify at least one difference, each of which includes at least one line of code. If there are multiple differences, the differences between the candidate code completion content and the original document include multiple code segments. These multiple code segments are sorted according to their end line numbers to ensure consistency in the processing order.

[0063] Step S502: Perform change amount control filtering on the at least one difference content to determine at least one candidate valid completion content.

[0064] Specifically, for each difference, change volume control filtering is required, using configuration parameters to control the amount of change in a single completion operation. For example, limiting the number of lines inserted avoids inserting too much code at once; limiting the number of lines deleted avoids accidentally deleting a large amount of code; and controlling the total number of changed lines maintains the controllability of the completion process. The purpose of limiting the number of lines inserted is to avoid inserting too many code blocks at once, leading to a messy code structure, or inserting unwanted or lengthy code. The purpose of limiting the number of lines deleted is to prevent the completion operation from accidentally deleting a large amount of existing code. Controlling the total number of changed lines is a combination and supplement to the previous two, controlling the scope of code disturbance caused by a single completion operation.

[0065] Step S503: Perform similarity checks and empty change checks on the at least one candidate valid completion content to determine at least one valid completion content.

[0066] Specifically, the similarity check refers to avoiding duplicate displays using string similarity algorithms. For example, the String Similarity Utils class is used to check the similarity between candidate valid completion content and the current document content. If the candidate valid completion content is too similar to or exactly the same as the code in the current document, it is skipped from display. Candidate valid completion content with a similarity less than a set threshold is determined as valid completion content. The empty change check refers to checking whether the candidate valid completion content has produced actual code changes. The source code and the completed code are compared line by line. If any changes are all whitespace characters, it is considered invalid completion.

[0067] Step S504: Query the rejection cache based on the at least one valid completion content. In response to the fact that no code completion content corresponding to the valid completion content is found in the rejection cache, determine the at least one valid completion content as the target code completion content.

[0068] In this embodiment of the invention, a completion identifier is determined based on the valid completion content. The completion identifier can be a hash value. The hash value is matched with the hash value corresponding to the code completion content in the rejection cache. If the match is successful, it means that the valid completion content has been rejected by the user and will not be displayed again to avoid repeatedly displaying rejected content. If the match fails, it means that the valid completion content has not been rejected by the user, and the valid completion content is determined as the target code completion content.

[0069] In one possible implementation, after querying the rejection cache, intelligent detection is also performed. The intelligent detection is used to detect whether the user accepted the autocomplete before reversal. By analyzing code document change events and autocomplete content, the user's operation intent is determined to avoid re-displaying the same autocomplete after the rollback operation.

[0070] In this embodiment of the invention, the post-processing interception is a content filtering and optimization process performed before the target code completes the content display.

[0071] Step S205: Send the target code completion content to the code editor.

[0072] In this embodiment of the invention, after receiving the target code completion content, the code editor displays the target code completion content in the interface of the code editor.

[0073] In one possible implementation, the most suitable completion for the current cursor position is selected from multiple completion code segments in the target code completion content using the nearest completion selection algorithm. Priority is given to selecting the completion code segment within the cursor's range. If there is no direct match, the nearest completion code segment is selected. Then, the importance and relevance of the completion are considered and sorted.

[0074] Specifically, the display method of the target code completion content in the code editor is selected based on the complexity of the target code completion content, including Inlay prompts, Popup panels, and Tab buttons. The Inlay prompts are suitable for simple code insertions and are displayed directly in the code editor; the Popup panels are suitable for complex code changes, improving detailed difference comparisons; and the Tab buttons are suitable for completions that are far away, providing prompts to the user.

[0075] In one possible implementation, the user may perform operations such as receiving, delaying display, and rejecting the target code completion content. The target code completion content received and delayed display is saved to the completion result cache; the target code completion content rejected by the user is saved to the rejection cache.

[0076] In one possible implementation, before inputting the target code completion request into a large language model, the method further includes: querying the completion result cache based on the target code completion request, and in response to the existence of code content corresponding to the target code completion request in the completion result cache, determining the code content corresponding to the target code completion request as the code completion content.

[0077] In this embodiment of the invention, the code completion system also includes a task cancellation mechanism and a memory management mechanism. Before code documentation changes, all related resources are cleaned up, including cache cleanup, task cancellation, and resource release, to ensure the consistency of the code completion system and the effective utilization of resources. The system uses a disposable mode to manage the resource lifecycle and determines the timely release of resources by registering cleanup callbacks, thereby avoiding memory leaks and resource contention issues.

[0078] The following detailed explanation of the code completion process of the system, using a complete embodiment, is as follows: Figure 6 As shown, it includes the following steps: Step S601: The code editor triggers a code document change or cursor movement event.

[0079] Step S602: The request interceptor obtains the candidate code completion request.

[0080] Specifically, the event listener layer in the request interceptor obtains the candidate code completion request.

[0081] Step S603: The request interceptor performs code editor status detection. If the code editor status is normal, then step S604 is executed.

[0082] Specifically, the code editor status detection refers to detecting whether the code editor is the main editor, and the normal code editor status means that the code editor is the main editor.

[0083] Step S604: The request interceptor performs prediction function switch detection. In response to the prediction function switch being turned on, step S605 is executed.

[0084] Step S605: The request interceptor performs duplicate display filtering on the candidate code completion requests to determine non-duplicate code completion requests.

[0085] Step S606: The request interceptor performs a delay debouncing mechanism on the non-repeating code completion request to determine the delayed code completion request.

[0086] Step S607: The request interceptor performs a validity check on the delayed code completion request and determines the target code completion request.

[0087] Step S608: The request interceptor sends the target code completion request to the large language model.

[0088] Steps S602 to S608 described above are processed by the pre-interception layer in the request interceptor.

[0089] Step S609: The large language model generates candidate code completion content based on the received target code completion request.

[0090] Step S610: The large language model sends the target code completion content to the code editor.

[0091] Step S611: The code editor segments the completion results of the candidate code completion content and determines at least one difference. Step S612: The code editor performs change amount control filtering on the at least one difference content to determine at least one candidate valid completion content; Step S613: The code editor performs similarity checks and empty change checks on the at least one candidate valid completion content to determine at least one valid completion content; Step S614: The code editor queries the rejection cache based on the at least one valid completion content. In response to the fact that no code completion content corresponding to the valid completion content is found in the rejection cache, the at least one valid completion content is determined as the target code completion content. Step S615: The code editor sends the target code completion content to the front-end interface display layer of the code editor.

[0092] The steps S611 to S61 above are processed by the post-processing interception layer in the request interceptor.

[0093] Step S616: The front-end display interface of the code editor displays the target code completion content through intelligent display selection Inlay prompts, Popup panels, or Tab buttons.

[0094] Step S617: When the front-end display interface of the code editor receives a user's acceptance and delayed display instruction, it saves the target code completion content to the completion result cache; or, when it receives a user's rejection instruction, it saves the target code completion content to the rejection cache.

[0095] In one possible implementation, step S605 uses the rejected cached content for repeated display filtering.

[0096] Through the above embodiments, a multi-layered interception architecture, intelligent anti-shake algorithm, result segmentation based on difference analysis, multi-dimensional similarity detection, adaptive display strategy, and atomic resource management are adopted. The multi-layered interception architecture features a dual filtering system of pre-interception and post-processing interception. The intelligent anti-shake algorithm incorporates a dynamic latency adjustment mechanism based on user behavior patterns. The result segmentation based on difference analysis is used for accurate code difference calculation and intelligent segmentation algorithms. The multi-dimensional similarity detection comprehensively considers content, location, and time similarity judgment algorithms. The adaptive display strategy intelligently selects display options based on the complexity of the completed content and user preferences. The atomic resource management is a complete resource management mechanism based on the lifecycle. Through these processing methods, invalid completion requests can be reduced, system response speed can be improved, and the repeated display of completed content can be reduced.

[0097] In this embodiment of the invention, a device for intelligent code completion is provided, such as... Figure 7 As shown, it specifically includes: an acquisition unit 701, a front-end unit 702, a transmission unit 703, and a post-processing unit 704; The acquisition unit 701 is used to acquire candidate code completion requests, wherein the candidate code completion requests are triggered by code document changes or cursor movement events in the code editor; the pre-processing unit 702 is used to intercept the candidate code completion requests in advance and determine the target code completion request; the transmission unit 703 is used to send the target code completion request to the large language model and receive the candidate code completion content sent by the large language model; the post-processing unit 704 is used to intercept the candidate code completion content in post-processing and determine the target code completion content; the transmission unit 703 is also used to send the target code completion content to the code editor.

[0098] Furthermore, the pre-processing unit is specifically configured to: determine the corresponding code editor based on the candidate code completion request; in response to the code editor meeting the pre-set code completion requirements, perform multi-level pre-processing interception on the candidate code completion request; and in response to the candidate code completion request passing the multi-level pre-processing interception, determine the candidate code completion request as the target code completion request.

[0099] Furthermore, the pre-set code completion requirements include: the code editor being the main editor and the prediction function of the code editor being enabled.

[0100] Furthermore, the front-end unit is specifically configured to: determine a non-duplicate code completion request in response to the candidate code completion request being filtered for repeated display; determine a delayed code completion request in response to the non-duplicate code completion request being filtered for delayed debouncing; and determine the target code completion request in response to the delayed code completion request being filtered for legality.

[0101] Furthermore, the front-end unit is specifically configured to: query the rejection cache according to the candidate code completion request, wherein the rejection cache includes the code completion content rejected by the user, its corresponding cursor position, and the display time; in response to the rejection cache not finding the user-rejected code completion content corresponding to the candidate code completion request, determine the candidate code completion request as the non-duplicate code completion request.

[0102] Furthermore, the front-end unit is specifically configured to: in response to the fact that the code document has not been changed and no cursor movement event has been sent within the non-repeating code generation set time, determine the non-repeating code completion request as the delayed code completion request.

[0103] Furthermore, the post-processing unit is specifically configured to: segment the candidate code completion content to determine at least one difference; perform change amount control filtering on the at least one difference to determine at least one candidate valid completion content; perform similarity checks and empty change checks on the at least one candidate valid completion content to determine at least one valid completion content; query the rejection cache based on the at least one valid completion content, and in response to the failure to find the code completion content corresponding to the valid completion content in the rejection cache, determine the at least one valid completion content as the target code completion content.

[0104] Furthermore, the device further includes: a storage unit, used to save the target code completion content to a completion result cache; or, to save the target code completion content to a rejection cache.

[0105] Furthermore, the device also includes a query unit, configured to query the completion result cache according to the target code completion request, and in response to the existence of code content corresponding to the target code completion request in the completion result cache, determine the code content corresponding to the target code completion request as the code completion content.

[0106] Figure 8 This is a schematic diagram of the structure of the electronic device described in an embodiment of the present invention. For example... Figure 8As shown, it includes a general computer hardware architecture, which includes at least a processor 801 and a memory 802. The processor 801 and the memory 802 are connected via a bus 803. The memory 802 is adapted to store instructions or programs executable by the processor 801. The processor 801 can be a standalone microprocessor or a collection of one or more microprocessors. Thus, the processor 801 executes the instructions stored in the memory 802 to perform the method flow of the embodiments of the present invention as described above, thereby realizing data processing and control of other devices. The bus 803 connects the above-mentioned components together, and also connects the above-mentioned components to a display controller 804, a display device, and an input / output (I / O) device 805. The input / output (I / O) device 805 can be a mouse, keyboard, modem, network interface, touch input device, motion-sensing input device, printer, and other devices known in the art. Typically, the input / output device 805 is connected to the system via an input / output (I / O) controller 806.

[0107] The instructions stored in memory 802 are executed by at least one processor 801 to achieve the following: obtaining candidate code completion requests; pre-intercepting the candidate code completion requests to determine target code completion requests; sending the target code completion requests to a large language model and receiving candidate code completion content sent by the large language model; post-processing and intercepting the candidate code completion content to determine target code completion content; and sending the target code completion content to the code editor.

[0108] Specifically, the electronic device includes: one or more processors 801 and a memory 802. Figure 8 Take a processor 801 as an example. The processor 801 and the memory 802 can be connected via a bus or other means. Figure 8 Taking a bus connection as an example, memory 802, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Processor 801 executes various functional applications and data processing of the device by running the non-volatile software programs, instructions, and modules stored in memory 802, thus implementing the aforementioned method of deterministic code intelligent completion.

[0109] Memory 802 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; the data storage area may store an option list, etc. Furthermore, memory 802 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 802 may optionally include memory remotely located relative to processor 801, and these remote memories can be connected to external devices via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0110] One or more modules are stored in memory 802, and when executed by one or more processors 801, they execute the code intelligent completion method in any of the above method embodiments.

[0111] As those skilled in the art will recognize, various aspects of the embodiments of the present invention can be implemented as a system, method, or computer program product. Therefore, various aspects of the embodiments of the present invention can take the form of a completely hardware implementation, a completely software implementation (including firmware, resident software, microcode, etc.), or an implementation combining software and hardware aspects, which may generally be referred to herein as a "circuit," "module," or "system." Furthermore, various aspects of the embodiments of the present invention can take the form of a computer program product implemented in one or more computer-readable media having computer-readable program code implemented thereon.

[0112] Any combination of one or more computer-readable media can be used. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, (but not limited to) an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination thereof. More specific examples (not an exhaustive list) of computer-readable storage media will include: an electrical connection having one or more wires, a portable computer floppy disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable optical disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In the context of embodiments of the present invention, a computer-readable storage medium can be any tangible medium capable of containing or storing a program used by or in conjunction with an instruction execution system, device, or apparatus.

[0113] Computer-readable signal media may include propagated digital signals having computer-readable program code implemented therein, such as in baseband or as part of a carrier wave. Such propagated signals may take any of a variety of forms, including, but not limited to, electromagnetic, optical, or any suitable combination thereof. A computer-readable signal medium may be any computer-readable medium that is not a computer-readable storage medium and can communicate, propagate, or transmit a program used by or in conjunction with an instruction execution system, device, or apparatus.

[0114] Program code implemented on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, fiber optic cable, RF, or any suitable combination thereof.

[0115] Computer program code for performing operations relating to various aspects of embodiments of the present invention can be written in any combination of one or more programming languages, including: object-oriented programming languages ​​such as Java, Smalltalk, C++, etc.; and conventional procedural programming languages ​​such as the "C" programming language or similar programming languages. The program code can be executed as a standalone software package entirely on the user's computer, partially on the user's computer, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet provided by an Internet service provider).

[0116] The flowchart illustrations and / or block diagrams of the methods, apparatus (systems), and computer program products according to embodiments of the present invention describe various aspects of the embodiments of the present invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus to produce a machine such that the instructions (executed via the processor of the computer or other programmable data processing apparatus) create means for implementing the functions / actions specified in the flowchart and / or block diagram blocks or blocks.

[0117] These computer program instructions may also be stored in a computer-readable medium that can direct a computer, other programmable data processing apparatus or other means to operate in a particular manner, such that the instructions stored in the computer-readable medium produce an article of writing that includes instructions that implement the functions / actions specified in flowchart and / or block diagram blocks or blocks.

[0118] Computer program instructions may also be loaded onto a computer, other programmable data processing apparatus or other device to cause a series of operable steps to be performed on the computer, other programmable apparatus or other device to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable apparatus, provide for implementing the functions / actions specified in flowchart and / or block diagram blocks or blocks.

[0119] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

[0120] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, and displayed data) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use, and processing of such data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding access points are provided for users to choose to authorize or refuse processing. A user's refusal to process personal information beyond what is necessary for basic functions will not affect the user's use of basic functions.

Claims

1. A method of code intelligence completion, characterized by, The method comprises: obtaining a candidate code completion request, wherein the candidate code completion request is triggered by a code document change or a cursor movement event in a code editor; pre-intercepting the candidate code completion request to determine a target code completion request; sending the target code completion request to a large language model and receiving candidate code completion content sent by the large language model; post-intercepting the candidate code completion content to determine target code completion content; sending the target code completion content to the code editor.

2. The method of claim 1, wherein, The pre-intercepting the candidate code completion request to determine a target code completion request specifically comprises: determining the corresponding code editor of the candidate code completion request; in response to the code editor meeting the pre-set code completion requirements, performing multi-level pre-interception on the candidate code completion request; in response to the candidate code completion request passing the multi-level pre-interception, determining that the candidate code completion request is the target code completion request.

3. The method of claim 2, wherein, The pre-set code completion requirements include that the code editor is a main editor and the prediction function of the code editor is turned on.

4. The method of claim 2, wherein, The response to the candidate code completion request passing the multi-level pre-interception to determine that the candidate code completion request is the target code completion request specifically comprises: in response to the candidate code completion request passing the repeated display filtering, determining a non-repeated code completion request; in response to the non-repeated code completion request passing the delay anti-shake mechanism, determining a delay code completion request; in response to the delay code completion request passing the legality check, determining the target code completion request.

5. The method of claim 4, wherein, The response to the candidate code completion request passing the repeated display filtering to determine a non-repeated code completion request specifically comprises: querying a rejection cache according to the candidate code completion request, wherein the rejection cache includes code completion content rejected by a user, the corresponding cursor position, and the display time; in response to not querying the code completion content rejected by the user corresponding to the candidate code completion request in the rejection cache, determining the candidate code completion request as the non-repeated code completion request.

6. The method of claim 4, wherein, The response to the non-repeated code completion request passing the delay anti-shake mechanism to determine a delay code completion request specifically comprises: in response to the code document not being changed and no cursor movement event being sent within the set time of the non-repeated code completion request, determining the non-repeated code completion request as the delay code completion request.

7. The method of claim 1, wherein, The post-intercepting the candidate code completion content to determine target code completion content specifically comprises: performing completion result segmentation on the candidate code completion content to determine at least one difference content; performing change amount control filtering on the at least one difference content to determine at least one candidate effective completion content; performing similarity check and null change check on the at least one candidate effective completion content to determine at least one effective completion content; According to the at least one valid completion content query rejection cache, in response to not querying the code completion content corresponding to the valid completion content in the rejection cache, the at least one valid completion content is determined as the target code completion content.

8. The method of claim 1, wherein, The method further comprises: saving the target code completion content to a completion result cache; or, saving the target code completion content to a rejection cache.

9. The method of claim 8, wherein, The method further comprises: querying the completion result cache according to the target code completion request, and in response to the code content corresponding to the target code completion request existing in the completion result cache, determining the code content corresponding to the target code completion request as the code completion content.

10. An apparatus for code intelligence completion, the apparatus comprising: The device comprises: an acquisition unit configured to acquire a candidate code completion request, wherein the candidate code completion request is triggered by a code document change or a cursor movement event in a code editor; a pre-processing unit configured to pre-process and intercept the candidate code completion request to determine a target code completion request; a transmission unit configured to send the target code completion request to a large language model and receive candidate code completion content sent by the large language model; a post-processing unit configured to post-process and intercept the candidate code completion content to determine target code completion content; the transmission unit is further configured to send the target code completion content to the code editor.

11. An electronic device comprising a memory and a processor, characterized in that The memory is configured to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method according to any one of claims 1-9.

12. A computer-readable storage medium, characterized in that, The computer program is stored in the computer readable storage medium, and the computer program is executed by the processor to implement the method according to any one of claims 1-9.