A method to support code completion when editing very large files

By maintaining the token collection in memory, dynamically maintaining and filtering tokens that meet the conditions, the problem of excessively long code completion when editing super-large-scale source code files in the existing technology is solved, and efficient code completion in semiconductor testing is achieved and compile.

CN118708170BActive Publication Date: 2024-11-15NANJING MACROTEST SEMICON TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411195214.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2024-11-15
Estimated Expiration
2044-08-29

AI Technical Summary

Technical Problem

When editing ultra-large-scale source code files, the code completion function takes too long, resulting in program lag and unresponsiveness. Especially in semiconductor testing, it is impossible to effectively support the editing and compilation of tens of millions of lines of code.

Method used

By maintaining a token collection participating in code completion in memory, the collection is dynamically maintained during the user editing process. When the user taps the keyboard at the cursor, the tokens that meet the conditions are filtered directly from the token collection. It is used for code completion and avoids Retraverse the edit window content.

Benefits of technology

It greatly improves the efficiency of code completion, reduces system retrieval work, reduces the real-time load of operating equipment, and realizes the need for rapid editing and compilation of super-large files in semiconductor testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118708170B_ABST
    Figure CN118708170B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for supporting code completion when editing a very large file, and relates to the technical field of code completion. The method for supporting code completion when editing a very large file maintains a token set participating in code completion in a memory, and dynamically maintains the token set memory when the user is editing a text. When the user subsequently taps the keyboard at the cursor, the qualified token is directly filtered out from the token set memory for code completion, which greatly improves the efficiency of code completion. The method for supporting code completion when editing a very large file classifies the maintenance type of the code, and for the addition and deletion operations, different operation methods are selected according to their different operation positions, so as to meet the demand for code completion when editing a very large file, especially in semiconductor testing work, where there are many very large source code files, which facilitates testers to write test processes.
Need to check novelty before this filing date? Find Prior Art

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 a very large file. Background Art

[0002] Code completion is a behavior that connects the context and completes the matching token, which is convenient for users to operate. There is no need to type all the text one by one, and quick editing is achieved.

[0003] 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. When the current source code compilation software is editing more than tens of millions of lines of code, Microsoft's vs series software such as vs2019, vs2022, etc. no longer support it (and do not support completion for the labels of goto instructions), and ultraedit cannot support it either. vscode can provide simple and highly fault-tolerant prompts. When the open source software codeblocks needs prompts, it will freeze directly without any response.

[0004] The main reason for this is that the current technology automatically determines whether completion is needed based on the content before the typing position when the user types characters in the editing window. If completion is needed, the entire editing window content is re-traversed to extract each token, 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 restart from the editing window and re-parse the content to obtain the token. If it is a file with more than 10 million lines of code, it is extremely time-consuming and the program will be stuck and unresponsive. For this reason, a method that supports code completion when editing very large files is provided to solve the above problem. Summary of the invention

[0005] In view of the deficiencies in the prior art, the present invention provides a method for supporting 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.

[0006] To achieve the above objectives, the present invention is implemented through the following technical solutions: a method for supporting code completion when editing a very large file, by maintaining a token set participating in code completion in a memory, dynamically maintaining the token set memory when the user is editing the text, and subsequently filtering out qualified tokens from the token set memory when the user taps the keyboard at the cursor, for code completion, which will greatly improve the efficiency of code completion;

[0007] Taking the jump instruction label as an example, the following memory set needs to be maintained:

[0008] The regular expression of Label is [a-zA-Z_][0-9], and the specific steps are as follows;

[0009] S1, find the insertion position and deletion position;

[0010] S2. Determine the operation type, where the operation type includes adding text content and deleting text content;

[0011] S3. Perform token maintenance operations;

[0012] S4. Maintain the token start / end point.

[0013] 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.

[0014] Preferably, when the insertion position is "before a token, inside 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;

[0015] 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. 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;

[0016] The insertion position is "inside 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;

[0017] The insertion position is "in pos". When there is ":label" in the text, there is continuous text before the first ":" of the inserted text. It is necessary to merge the continuous text before the ":" 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.

[0018] Preferably, the deletion position "pos is before a token and between two tokens", when 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;

[0019] 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;

[0020] 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.

[0021] When deleting the position "within the token", if it does not reach ":", the current token name is updated, and the end position - length;

[0022] When the deletion position is "token after", token is not affected.

[0023] Preferably, the text editing window is actually a text control, and the text content can be obtained.

[0024] Preferably, each label includes a name, a starting position startpos, and an ending position endpos.

[0025] The present invention discloses a method for supporting code completion when editing a very large file, which has the following beneficial effects:

[0026] 1. The method supports code completion when editing a very large file. By maintaining a token set participating in code completion in the memory, the token set memory is dynamically maintained while the user is editing the text. When the user subsequently types on the keyboard at the cursor, the qualified token is directly filtered out from the token set memory for code completion. This will greatly improve the efficiency of code completion and meet the needs of code completion when editing very large files. In particular, in semiconductor testing work, there are many very large source code files, which makes it convenient for testers to write test processes. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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 creative work.

[0028] Figure 1 This is a flow chart of the code completion method of the present invention;

[0029] Figure 2 A schematic diagram of the code completion operation type of the present invention;

[0030] Figure 3 This is an operation flow chart of the present invention in the case of inserting content into a token;

[0031] Figure 4 The operation flow chart of the present invention when inserting content outside of token;

[0032] Figure 5 This is a flowchart of the operation of deleting content starting from a token in the present invention;

[0033] Figure 6 This is a flowchart of the operation of deleting content starting outside the token in the present invention;

[0034] Figure 7 It is a block diagram of the method for distinguishing the location and text content when inserting text content according to the present invention;

[0035] Figure 8 It is a block diagram of the processing method for distinguishing existing positions and text contents when deleting text contents according to the present invention. DETAILED DESCRIPTION

[0036] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention are clearly and completely described. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0037] 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 for supporting 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.

[0038] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0039] The embodiment of the present invention discloses a method for supporting code completion when editing a very large file.

[0040] According to the attached Figure 1-8 As shown in the figure, 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.

[0041] Taking the jump instruction label as an example, the following memory set needs to be maintained:

[0042] The regular expression of Label is [a-zA-Z_][0-9], and the specific steps are as follows;

[0043] S1, find the insertion position and deletion position;

[0044] S2. Determine the operation type, where the operation type includes adding text content and deleting text content;

[0045] S3. Perform token maintenance operations;

[0046] S4. Maintain the token start / end point.

[0047] 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.

[0048] Preferably, when the insertion position is "before a token, inside 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;

[0049] 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. 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;

[0050] 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;

[0051] The insertion position is "inside 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 the ":" and the token part of the 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.

[0052] 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, ensure that the inserted items meet the application requirements, and can achieve the effect of fast and accurate identification. 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.

[0053] The above is a method for distinguishing the location and text content when inserting text content. Figure 7 As shown;

[0054] 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.

[0055] When deleting the position "pos before a token and between two tokens", if it ends in the next token, update the name, start and end positions of the token, the start and end positions of the token after pos - the text length; if there are multiple tokens in the text, the parsed token needs to be removed from the vector collection;

[0056] 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.

[0057] When deleting the position "token inside", if it does not reach ":", update the current token name, end position - length;

[0058] When deleting the position "token after", token is not affected.

[0059] The above is a method for distinguishing the location and text content when deleting text content. Figure 8 As shown in the figure, during the code completion and deletion process, different operation methods should be used for different types of deletion positions 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 be automatically read and operated, which greatly improves the efficiency of code completion. In the process of code completion, it is ensured that each token operation complies with the specification and will not cause code errors.

[0060] The text editing window is actually a text control that can obtain text content.

[0061] Each label contains a name, a starting position startpos, and an ending position endpos.

[0062] In the current existing technical operations, for semiconductor testing work, it is often necessary to face the editing and compilation of source code files of hundreds of MB or tens of millions of lines. In particular, some code completion functions need to be implemented during editing. The current technology is that when the user types characters in the editing window, it will automatically determine whether completion is required based on the content before the tapping position. If completion is required, the entire editing window content is traversed again, each token is extracted, and then each token is filtered and compared to obtain the token set that needs to be prompted in the end, and the token set is prompted. Each time a character is typed at the cursor, it is necessary to re-parse the content from the beginning of the editing window to obtain the token. If there are more than 10 million lines of code, the program will be stuck and unresponsive. In the process of using this method for operation, 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 qualified token is directly filtered out from the token set memory for code completion. There is no need to traverse the entire editing window content, and the target token is directly increased or decreased, 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.

[0063] The following uses the data structure of the token collection memory as an example:

[0064] The token used in this example is the label for the jump.

[0065] typedef struct LabelInfo

[0066] {

[0067] char labelName

[256] ;

[0068] int startpos;

[0069] int endpos;

[0070] bool operator()(const LabelInfo* t1,const LabelInfo* t2){

[0071] return t1->startpos < t2->startpos;}

[0072] bool operator < (const LabelInfo& ti) const {

[0073] return startpos < ti.startpos;}

[0074] }_LabelInfo_; / / token is label

[0075] typedef struct atpToken

[0076] {

[0077] char vectorName

[256] ;

[0078] int startpos;

[0079] int endpos;

[0080] std::vector<_LabelInfo_> vecLabel; / / Store all label sets involved in code completion

[0081] }_AtpToken_; / / Store the label's valid range, starting point, and end point.

[0082] The atpToken structure stores the valid range, start point, and end point of all labels. This structure needs to set the position range because the test case is a language used in semiconductor testing.

[0083] The above shows and describes the basic principles and main features of the present invention and the advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited to the above embodiments. The above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached 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. The label of the jump instruction needs to maintain the following memory set: 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; 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; 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 starting position and ending position of the token after pos will be directly updated, and the starting position = starting position + text length; the ending position = ending position + text length; 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 "token". 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 the token". When there is a ":label" in the text, the text before the first ":" is continuous text. The continuous text before ":" and the token part before the insertion position need to be merged into a new token, which is stored in the vector collection. The token after the insertion position is then updated. If there are other tokens in the inserted text, they are stored in the token collection. 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 the token - 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 "token inside", if it does not reach ":", the current token name is updated, and the end position - length; When the deletion position is "token after", token is not affected.

2. A method for supporting code completion when editing a very large file according to claim 1, characterized in that: The text editing window is actually a text control that can obtain text content.

3. 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.