Method for supporting code completion during oversized file editing
By maintaining the token collection in memory and dynamically maintaining and filtering qualified tokens, the problem in the existing technology that code completion takes too long when editing very large files is solved, and fast and efficient code completion in semiconductor testing work is achieved. Complete.
Patent Information
- Application Number
- CN202411195214.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-08-29
AI Technical Summary
In the existing technology, when editing very large files, the code completion function takes too long, causing the program to freeze and become unresponsive. Especially in semiconductor testing work, code completion cannot be effectively supported when compiling and editing tens of millions of line-level source code files. .
By maintaining a token collection in memory that participates in code completion, the collection is dynamically maintained during the user editing process. When the user taps the keyboard at the cursor, qualified tokens are directly filtered out from the token collection for code completion. Avoid re-traversing the edit window contents.
It greatly improves the efficiency of code completion, reduces system retrieval work, reduces the real-time load on operating equipment, and enables rapid editing and compilation of very large files in semiconductor testing work.
Smart Images

Figure CN118708170A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of code completion, and in particular to a method for supporting code completion when editing an extremely large file. Background Art
[0002] Code completion is a context-sensitive process that completes the text matching the token. This facilitates user operation and eliminates the need to type all the text one by one, enabling quick editing.
[0003] Semiconductor testing often requires editing and compiling source code files exceeding hundreds of megabytes or tens of millions of lines. Code completion is especially crucial during editing. Current source code compilation software, such as Microsoft's VS series software like VS2019 and VS2022, no longer supports editing over tens of millions of lines of code (and doesn't support completion for goto labels). UltraEdit also doesn't support this. VSCode provides simple, highly fault-tolerant prompts, but open-source software like CodeBlocks freezes and becomes unresponsive when prompts are needed. The main reason for this is that when the user types characters in the editing window, the current technology will automatically determine whether completion is needed based on the content before the typing position. If completion is needed, the entire editing window content will be traversed again, each token will be extracted, and then each token will be filtered and compared to obtain the final token set that needs to be prompted. The token set will be prompted. Each time a character is typed at the cursor, it is necessary to restart from the beginning of the editing window, re-parse the content, and obtain the token. If it is for a file with more than 10 million lines of code, it is extremely time-consuming and the program will become stuck and unresponsive. Therefore, a method that supports code completion when editing very large files is provided to solve the above problem. Summary of the Invention
[0004] In response to the shortcomings of the existing technology, the present invention provides a method that supports code completion when editing very large files, which solves the problem that in semiconductor testing work, it is often necessary to edit and compile source code files of hundreds of megabytes or tens of millions of lines; in particular, some code completion functions need to be implemented during editing, which is extremely time-consuming and causes the program to become stuck and unresponsive.
[0005] To achieve the above objectives, the present invention is implemented through the following technical solutions: a method for supporting code completion when editing very large files, by maintaining a token set participating in code completion in memory. While the user is editing text, the token set memory is dynamically maintained. Subsequently, when the user taps the keyboard at the cursor, the token set memory is directly filtered out of the token set memory to be used for code completion, which greatly improves the efficiency of code completion. Taking the jump instruction label as an example, the following memory set needs to be maintained: The regular expression of Label is [a-zA-Z_][0-9], and the specific steps are as follows; S1, find the insertion position and deletion position; S2. Determine the operation type, where the operation type includes adding text content and deleting text content; S3. Perform token maintenance operations; S4. Maintain the token start / end point.
[0006] Preferably, in step S2, the types of insertion positions and deletion positions include: before all tokens, within a token, between two tokens 1, and after the last token.
[0007] Preferably, when the insertion position is "before a token, within a token, between two tokens, and after all tokens", if there is no ":label" in the text, the start and end positions of the token after the pos + the text length are directly used; When the insertion position is "before all tokens, between two tokens, and after all tokens", when there is a ":" in the text, the text before the ":" is connected to the text before the insertion position. The text before the ":" and the continuous text before the insertion position need to be combined to generate a token and stored in the vector set. As long as there is a ":" in the current text, the token is extracted and stored in the vector set; the starting and ending positions of the token after pos + the text length; if there are multiple tokens in the text, the label needs to be parsed and inserted into the vector set; The insertion position is "Pos". When there is no ":label" in the text, the current label content needs to be updated, and the start and end positions of all labels after the current label + the text length; The insertion position is "inside Pos". When there is a ":label" in the text, the text before the first ":" is continuous text. The continuous text before the ":" and the token part of the text before the insertion position need to be merged into a new token, stored in the vector collection, and start updating the token after the insertion position. If there are other tokens in the inserted text, they are stored in the token collection.
[0008] Preferably, the deletion position "Pos is before a token and between two tokens". If the next token is not deleted, the token after pos and the start and end positions of the vector minus the text length are directly deleted. When the deletion position "Pos is before a token and between two tokens", if it ends within the next token, the name, start and end positions of the token, the start and end positions of the token after pos - the text length are updated; if there are multiple tokens in the text, the parsed token needs to be removed from the vector collection; When the deletion position is "Pos before a token and between two tokens", if it crosses the next token, all the tokens that are crossed need to be deleted from the vector set. If the end position reaches a token, the current token is updated and the start and end positions of all subsequent tokens are minus the text length. When deleting the position "pos", if it does not reach ":", the current token name is updated, ending position - length; When the deletion position "Pos is at the end", the token is not affected.
[0009] Preferably, the text editing window is actually a text control that can obtain text content.
[0010] Preferably, each label includes a name, a starting position startpos, and an ending position endpos.
[0011] The present invention discloses a method for supporting code completion when editing a very large file, which has the following beneficial effects: 1. The method supports code completion when editing very large files. By maintaining a token set participating in code completion in memory, the token set memory is dynamically maintained while the user is editing text. Subsequently, when the user taps the keyboard at the cursor, the token that meets the conditions is directly filtered out from the token set memory and used for code completion. This will greatly improve the efficiency of code completion and meet the needs of code completion when editing very large files. This is especially convenient for testers to write test processes in semiconductor testing work where there are many very large source code files. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0013] Figure 1 This is a flow chart of the code completion method of the present invention; Figure 2This is a schematic diagram of the code completion operation type of the present invention; Figure 3 This is an operational flow chart of the present invention in the case of inserting content into a token; Figure 4 This is a flowchart of the operation of inserting content outside of a token in the present invention; Figure 5 This is a flowchart of the operation of deleting content starting from a token in the present invention; Figure 6 This is a flowchart of the operation of deleting content starting outside the token in the present invention; Figure 7 A block diagram of a method for distinguishing between the location and the text content when inserting text content according to the present invention; Figure 8 This is a block diagram of the present invention's method for distinguishing between the location and text content when deleting text content. DETAILED DESCRIPTION
[0014] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention are clearly and completely described. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0015] The embodiment of the present application solves the problem that in semiconductor testing work, it is often necessary to edit and compile source code files of hundreds of megabytes or tens of millions of lines, by providing a method that supports code completion when editing very large files. In particular, some code completion functions need to be implemented during editing, which is extremely time-consuming and causes the program to become stuck and unresponsive.
[0016] In order to better understand the above technical solution, the above technical solution will be described in detail below with reference to the accompanying drawings and specific implementation methods.
[0017] An embodiment of the present invention discloses a method for supporting code completion when editing an extremely large file.
[0018] According to the attached Figure 1-8 As shown in the figure, by maintaining a token set participating in code completion in memory, the token set memory is dynamically maintained while the user is editing text. Subsequently, when the user types on the keyboard at the cursor position, the token that meets the conditions is directly filtered out from the token set memory and used for code completion, which will greatly improve the efficiency of code completion. Taking the jump instruction label as an example, the following memory set needs to be maintained: The regular expression of Label is [a-zA-Z_][0-9], and the specific steps are as follows; S1, find the insertion position and deletion position; S2. Determine the operation type, where the operation type includes adding text content and deleting text content; S3. Perform token maintenance operations; S4. Maintain the token start / end point.
[0019] In step S2, the types of insertion positions and deletion positions include: before all tokens, within a token, between two tokens 1, and after the last token.
[0020] Preferably, when the insertion position is "before a token, within a token, between two tokens, and after all tokens", when there is no ":label" in the text, the start and end positions of the token after the pos + the text length are directly used; When the insertion position is "before all tokens, between two tokens, and after all tokens", when there is a ":" in the text, the text before the ":" is connected to the text before the insertion position. The text before the ":" and the continuous text before the insertion position need to be combined to generate a token and stored in the vector set. As long as there is a ":" in the current text, the token is extracted and stored in the vector set; the starting and ending positions of the token after pos + the text length; if there are multiple tokens in the text, the label needs to be parsed and inserted into the vector set; The insertion position is "Pos". When there is no ":label" in the text, the current label content needs to be updated, and the start and end positions of all labels after the current label + the text length; The insertion position is "Pos". When there is a ":label" in the text, the text before the first ":" is continuous text. The continuous text before the ":" and the token part of the text before the insertion position need to be merged into a new token, stored in the vector collection, and the token after the insertion position is updated. If there are other tokens in the inserted text, they are stored in the token collection.
[0021] Using the above solution, when the user is completing the code, different operation methods should be used for different types of insertion positions to avoid affecting the upper and lower content tokens during the content insertion process, ensuring that the inserted items meet the application requirements and can achieve the effect of fast and accurate recognition. In actual applications, it can be automatically read and operated, which greatly improves the efficiency of code completion. In addition, during the code completion process, it is ensured that each token operation complies with the specifications.
[0022] The above is the method for distinguishing the location and text content when inserting text content, as shown in the attached Figure 7 As shown; Preferably, the deletion position "Pos is before a token and between two tokens". If the next token is not deleted, the token after pos and the start and end positions of the vector minus the text length are directly deleted. When deleting a position "Pos before a token and between two tokens", if the end point is within the next token, update the name, start and end positions of the token, and the start and end positions of the token after pos - text length; if there are multiple tokens in the text, remove the parsed token from the vector collection; When deleting the position "Pos before a token and between two tokens", if it crosses the next token, all the tokens that are crossed need to be deleted from the vector set. If the end position reaches a token, the current token is updated and the start and end positions of all subsequent tokens are minus the text length. When deleting the position "pos", if it does not reach ":", then update the current token name, ending position - length; Deleting the position "Pos after" does not affect the token.
[0023] The above is a method for distinguishing the location and text content when deleting text content. Figure 8 As shown, during the code completion and deletion process, different operation methods should be used for different types of deletion locations to avoid affecting the upper and lower content tokens during the content deletion process, ensure that the deleted items meet the application requirements, and achieve the effect of fast and accurate identification. In actual applications, it can automatically read and operate, greatly improving the efficiency of code completion. In addition, during the code completion process, it is ensured that each token operation complies with the specifications and will not cause code errors. The text editing window is actually a text control that can obtain text content.
[0024] Each label contains a name, a starting position startpos, and an ending position endpos.
[0025] In current technical operations, semiconductor testing work often requires editing and compiling source code files of hundreds of megabytes or tens of millions of lines. Especially in editing, some code completion functions need to be implemented. The current technology is that when the user types characters in the editing window, it will automatically determine whether completion is needed based on the content before the tapping position. If completion is needed, the entire editing window content is traversed again, each token is extracted, and then each token is filtered and compared to obtain the final token set that needs to be prompted, and the token set is prompted. Each time a character is typed at the cursor, it is necessary to start from the beginning of the editing window, re-parse the content, and obtain the token. If it is for a file with more than 10 million lines of code, the program will be stuck and unresponsive. In the process of using this method, a token set participating in code completion is maintained in the memory. When the user is editing the text, the token set memory is dynamically maintained. When the user taps the keyboard at the cursor later, the token that meets the conditions is directly filtered out from the token set memory for code completion. There is no need to traverse the entire editing window content. The target token is directly added or subtracted, which reduces the system's retrieval work, improves the convenience and immediacy of token maintenance, and greatly reduces the real-time load on the operating device. The following uses the data structure of the token collection memory as an example: The token used in this example is the label for the jump. typedef struct LabelInfo { charlabelName
[256] ; intstartPos; intendPos; bool operator()(const LabelInfo* t1,const LabelInfo* t2){ return t1->startPos <t2->startPos;} bool operator<(const LabelInfo&ti) const { return startPos <ti.startPos;} }_LabelInfo_; / / token is label typedef struct atpToken { charvectorName
[256] ; int startPos; int endPos; std::vector<_LabelInfo_>vecLabel; / / Store all label sets involved in code completion }_AtpToken_; / / Store the valid range, starting point and end point of the label.
[0026] The atpToken structure stores the valid range, starting point, and end point of all labels. Because the test case is a language used in semiconductor testing, this structure requires a location range.
[0027] The basic principles, main features, and advantages of the present invention are shown and described above. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions are merely illustrative of the principles of the present invention. Various changes and modifications may be made to the present invention without departing from the spirit and scope of the present invention. Such changes and modifications are intended to fall within the scope of the present invention. The scope of protection claimed in the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for supporting code completion when editing a very large file, characterized in that: By maintaining a token set involved in code completion in memory, the token set memory is dynamically maintained while the user is editing text. When the user subsequently types on the keyboard at the cursor, the token that meets the conditions is directly filtered out from the token set memory for code completion, which greatly improves the efficiency of code completion. Taking the jump instruction label as an example, the following memory set needs to be maintained: The regular expression of Label is [a-zA-Z_][0-9], and the specific steps are as follows; S1, find the insertion position and deletion position; S2. Determine the operation type, where the operation type includes adding text content and deleting text content; S3. Perform token maintenance operations; S4. Maintain the token start / end point.
2. A method for supporting code completion when editing a very large file according to claim 1, characterized in that: In step S2, the types of insertion positions and deletion positions include: before all tokens, within a token, between two tokens 1, and after the last token.
3. A method for supporting code completion when editing a very large file according to claim 2, characterized in that: When the insertion position is "before a token, inside a token, between two tokens, and after all tokens", and there is no ":label" in the text, the start and end positions of the token after pos + the text length are directly added; When the insertion position is "before all tokens, between two tokens and after all tokens", when there is ":" in the text, the text before ":" is connected to the text before the insertion position, and the text before ":" needs to be combined with the continuous text before the insertion position to generate a token and store it in the vector set. As long as there is ":" in the current text, the token is extracted and stored in the vector set; the starting and ending positions of the token after pos + the text length; if there are multiple tokens in the text, the label needs to be parsed and inserted into the vector set; The insertion position is "in Pos". When there is no ":label" in the text, the current label content needs to be updated, and the start and end positions of all labels after the current label + the text length; The insertion position is "in Pos". When there is ":label" in the text, there is continuous text before the first ":" in the inserted text. It is necessary to merge the continuous text before ":" and the token part text before the insertion position into a new token, store it in the vector collection, and start updating the token after the insertion position. If there are other tokens in the inserted text, store them in the token collection.
4. The method for supporting code completion when editing a very large file according to claim 2, characterized in that: The deletion position "Pos is before a token and between two tokens", when the next token is not deleted, directly delete the token after pos and the start and end positions of the vector minus the text length; When the deletion position "Pos is before a token and between two tokens", if it ends within the next token, the name, start and end positions of the token, the start and end positions of the token after pos - the text length are updated; if there are multiple tokens in the text, the parsed token needs to be removed from the vector collection; When the deletion position "Pos is before a token and between two tokens", if it crosses the next token, all the crossed tokens need to be deleted from the vector set. If the end position reaches a token, the current token is updated, and the start and end positions of all subsequent tokens are minus the text length. When deleting the position "pos", if it does not reach ":", the current token name is updated, ending position - length; When the deletion position is "Pos at the end", the token is not affected.
5. The method for supporting code completion when editing a very large file according to claim 1, characterized in that: The window for editing text is actually a text control, which can obtain text content.
6. The method for supporting code completion when editing a very large file according to claim 1, characterized in that: Each label contains a name, a starting position startpos, and an ending position endpos.
Citation Information
Patent Citations
Keyword prompt method for improving Qt development environment
CN106843528A
Code editing method and device, server, user equipment and storage medium
CN112817583A
Code processing method and device, equipment and medium
CN118535141A
Cited By
Method for supporting code completion during ultra-large file editing
WO2026045657A1
Method for supporting compilation of ultra-large source code file on basis of antlr tool
WO2026077041A1
