Search

CN-122018873-A - Code prompting method and system

CN122018873ACN 122018873 ACN122018873 ACN 122018873ACN-122018873-A

Abstract

The embodiment of the specification provides a code prompting method and a code prompting system, wherein the code prompting method comprises the steps of collecting a cursor position in a code editing interface of a target item, selecting an area code associated with the cursor position in the code editing interface, determining at least two code libraries associated with the target item, determining code loading parameters respectively corresponding to the at least two code libraries according to the area code, extracting reference codes from the at least two code libraries based on the code loading parameters and the area code, and searching and displaying a prompting code matched with the code editing operation in the reference codes under the condition that the code editing operation is triggered by the cursor position. By means of pre-extracting the reference codes, when a user edits the codes, prompt codes can be directly matched in the extracted reference codes, so that the response speed of the code prompts is improved.

Inventors

  • LIU LIHUA
  • XIA XIAOWEN

Assignees

  • 阿里云计算有限公司

Dates

Publication Date
20260512
Application Date
20241111

Claims (12)

  1. 1. A code hint method comprising: collecting a cursor position in a code editing interface of a target item, and selecting an area code associated with the cursor position in the code editing interface; determining at least two code libraries associated with the target item, and determining code loading parameters corresponding to the at least two code libraries respectively according to the region code; extracting reference codes in the at least two code libraries based on the code loading parameters and the region codes; and under the condition that the cursor position is detected to trigger the code editing operation, searching a prompt code matched with the code editing operation in the reference code and displaying the prompt code.
  2. 2. The code prompting method according to claim 1, the selecting the region code associated with the cursor position in the code editing interface, comprising: determining a cursor area associated with the cursor position in the code editing interface based on a preset cursor time; the region code is extracted in the cursor region.
  3. 3. The code hint method according to claim 1, wherein the determining code loading parameters respectively corresponding to the at least two code libraries according to the region code includes: determining the code quantity of the region codes and the parameter lookup tables corresponding to the two code libraries respectively; and inquiring parameter inquiry tables respectively corresponding to the at least two code libraries based on the code quantity to obtain code loading parameters respectively corresponding to the at least two code libraries.
  4. 4. A code hint method according to claim 3, wherein the determining of code loading parameters corresponding to an object code library of the at least two code libraries includes: matching the code recall quantity corresponding to the code quantity in a target parameter lookup table corresponding to the target code library, and determining code loading time consumption in the target parameter lookup table based on the code recall quantity; And under the condition that the code loading time is less than a time consumption threshold, updating the code recall quantity into an object code recall quantity, and taking the object code recall quantity as the code loading parameter.
  5. 5. The code hint method according to claim 4, wherein the matching the number of code recalls corresponding to the number of codes in the target parameter lookup table corresponding to the target code library includes: Matching the code quantity intervals corresponding to the code quantity in a target parameter lookup table corresponding to the target code library; selecting code loading time consumption in the code quantity interval based on preset code loading time consumption, and acquiring the code recall quantity corresponding to the code loading time consumption.
  6. 6. The code hint method according to claim 1, wherein the extracting the target reference code corresponding to any one of the at least two code libraries includes: determining code loading parameters corresponding to the target code library; Extracting the target reference code matched with the region code in the target code library through code similarity calculation based on the code loading parameters.
  7. 7. The code hint method of claim 3, the extracting reference codes in the at least two code libraries based on the code loading parameters and the region codes, further comprising: determining code extraction time consumption and code extraction quantity corresponding to the code extraction time consumption; the number of codes, the number of code extractions, and the code extraction time consumption are added to the parameter lookup table.
  8. 8. The code prompting method according to claim 1, wherein in the case that the cursor position is detected to trigger a code editing operation, the reference code searches for a prompting code matched with the code editing operation and displays the prompting code, and the method comprises the following steps: reading the recall state of the reference code under the condition that the cursor position is detected to trigger the code editing operation and the code editing operation meets the prompt time condition; searching and displaying a prompt code matched with the code editing operation in the reference code based on the recall state.
  9. 9. A code prompting system comprises a server side and a client side; the client is used for generating a code prompt request based on a code editing interface of a target item and sending the code prompt request to the server; The server side is used for responding to the code prompt request, collecting a cursor position in the code editing interface, selecting an area code associated with the cursor position in the code editing interface, determining at least two code libraries associated with the target item, determining code loading parameters respectively corresponding to the at least two code libraries according to the area code, extracting reference codes from the at least two code libraries based on the code loading parameters and the area code, searching prompt codes matched with the code editing operation in the reference codes and sending the prompt codes to the client side under the condition that the cursor position is detected to trigger the code editing operation; And the client is used for displaying the prompt code in the code editing interface.
  10. 10. A computing device, comprising: A memory and a processor; The memory is configured to store a computer program or instructions, and the processor is configured to execute the computer program or instructions, which when executed by the processor implement the steps of the code prompting method according to any one of claims 1 to 8.
  11. 11. A computer readable storage medium storing a computer program or instructions which, when executed by a processor, implement the steps of the code prompting method of any one of claims 1 to 8.
  12. 12. A computer program product comprising computer programs or instructions which, when executed by a processor, implement the steps of the code prompting method of any one of claims 1 to 8.

Description

Code prompting method and system Technical Field The embodiment of the specification relates to the technical field of computers, in particular to a code prompting method and a code prompting system. Background In a code development scenario, a developer often needs to rely on code hints and complement functions in the course of writing code on a daily basis. The speed of code writing depends not only on the speed of writing by the developer, but also on the response speed of code hints and code completions. In the prior art, in order to simplify the development flow and improve the timeliness of code prompt, it is proposed to set a recall timeout time, and if the recall timeout occurs when the prompt code is recalled, the subsequent code prompt logic is continuously executed. However, this method has a problem that prompt codes cannot be provided for developers in time. The existence of the recall timeout also greatly reduces the response speed of the code hint. Therefore, a more efficient code prompting method is needed to solve the above-mentioned problems. Disclosure of Invention In view of this, the present embodiments provide a code prompting method. One or more embodiments of the present specification are also directed to a code hint system, a code hint apparatus, a computing device, a computer readable storage medium, and a computer program product, to address the technical shortcomings of the prior art. According to a first aspect of embodiments of the present disclosure, there is provided a code prompting method, including: collecting a cursor position in a code editing interface of a target item, and selecting an area code associated with the cursor position in the code editing interface; determining at least two code libraries associated with the target item, and determining code loading parameters corresponding to the at least two code libraries respectively according to the region code; extracting reference codes in the at least two code libraries based on the code loading parameters and the region codes; and under the condition that the cursor position is detected to trigger the code editing operation, searching a prompt code matched with the code editing operation in the reference code and displaying the prompt code. According to a second aspect of embodiments of the present disclosure, a code hint system is provided, including a server and a client; the client is used for generating a code prompt request based on a code editing interface of a target item and sending the code prompt request to the server; The server side is used for responding to the code prompt request, collecting a cursor position in the code editing interface, selecting an area code associated with the cursor position in the code editing interface, determining at least two code libraries associated with the target item, determining code loading parameters respectively corresponding to the at least two code libraries according to the area code, extracting reference codes from the at least two code libraries based on the code loading parameters and the area code, searching prompt codes matched with the code editing operation in the reference codes and sending the prompt codes to the client side under the condition that the cursor position is detected to trigger the code editing operation; And the client is used for displaying the prompt code in the code editing interface. According to a third aspect of embodiments of the present specification, there is provided a code prompting apparatus, comprising: The acquisition module is configured to acquire a cursor position in a code editing interface of a target item and select an area code associated with the cursor position in the code editing interface; The determining module is configured to determine at least two code libraries associated with the target item, and determine code loading parameters respectively corresponding to the at least two code libraries according to the region code; An extraction module configured to extract a reference code in the at least two code libraries based on the code loading parameters and the region code; And the searching module is configured to search the reference code for a prompt code matched with the code editing operation and display the prompt code under the condition that the cursor position is detected to trigger the code editing operation. According to a fourth aspect of embodiments of the present specification, there is provided a computing device comprising: A memory and a processor; the memory is configured to store computer-executable instructions that, when executed by the processor, perform the steps of the code hint method described above. According to a fifth aspect of embodiments of the present specification, there is provided a computer-readable storage medium storing computer-executable instructions which, when executed by a processor, implement the steps of the code hint method described above. According to a sixth aspect