CN116756196A - Method and plug-in for rapidly editing Makefile - Google Patents
Method and plug-in for rapidly editing Makefile Download PDFInfo
- Publication number
- CN116756196A CN116756196A CN202311027648.3A CN202311027648A CN116756196A CN 116756196 A CN116756196 A CN 116756196A CN 202311027648 A CN202311027648 A CN 202311027648A CN 116756196 A CN116756196 A CN 116756196A
- Authority
- CN
- China
- Prior art keywords
- matching
- content
- list
- target
- input
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 74
- 230000003068 static effect Effects 0.000 claims description 30
- 238000001914 filtration Methods 0.000 claims description 20
- 230000003213 activating effect Effects 0.000 claims description 4
- 230000008569 process Effects 0.000 description 7
- 230000001960 triggered effect Effects 0.000 description 6
- 238000011161 development Methods 0.000 description 3
- 230000008859 change Effects 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 230000004913 activation Effects 0.000 description 1
- 238000004140 cleaning Methods 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000007373 indentation Methods 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 238000004806 packaging method and process Methods 0.000 description 1
- 238000009417 prefabrication Methods 0.000 description 1
- 239000000126 substance Substances 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2282—Tablespace storage structures; Management thereof
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
- G06F16/24552—Database cache management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/248—Presentation of query results
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/01—Input arrangements or combined input and output arrangements for interaction between user and computer
- G06F3/048—Interaction techniques based on graphical user interfaces [GUI]
- G06F3/0481—Interaction techniques based on graphical user interfaces [GUI] based on specific properties of the displayed interaction object or a metaphor-based environment, e.g. interaction with desktop elements like windows or icons, or assisted by a cursor's changing behaviour or appearance
- G06F3/0482—Interaction with lists of selectable items, e.g. menus
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/166—Editing, e.g. inserting or deleting
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Computational Linguistics (AREA)
- Software Systems (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- General Health & Medical Sciences (AREA)
- Human Computer Interaction (AREA)
- User Interface Of Digital Computer (AREA)
Abstract
The invention discloses a method and a plug-in for rapidly editing Makefile, wherein the method comprises the following steps: acquiring input contents of an edited Makefile, identifying key characters in the input contents, acquiring a corresponding target list, matching the input contents with the target list to obtain a first matching result, returning the first matching result to carry out association display, waiting for and acquiring contents selected by a user in the first matching result of the association display, and outputting the contents selected by the user; obtaining target content, wherein the target content is Makefile content hovered by a mouse or selected, identifying key characters in the target content, obtaining corresponding matching objects, matching the input content with the corresponding matching objects to obtain second matching results, displaying the second matching results through a floating layer, and if the target content is a dynamic library, selecting the second matching results to replace the target content by a user. The invention can improve the editing efficiency of the Makefile file.
Description
Technical Field
The invention relates to the field of code processing, in particular to a method and a plug-in for rapidly editing Makefile files.
Background
In the process of writing Makefile, developers often refer to system resources such as dynamic libraries, static libraries and header files of the system, and Linux system commands, macro definitions and general predefined variables in the Makefile files, and the like.
When a developer refers to a predefined variable, it may be necessary to consult the Makefile manual to obtain it. The predefined variables include automatic variables and special variables, the special variables include environment variables and some other default values for the user-controlled build process, such as CC, are C compiler names, defaulting to 'CC'. The developer may want to acquire the predefined variable value by writing and executing the predefined value corresponding to makefile printing, which is cumbersome.
During the compiling and compiling process, a developer queries a dynamic library and a static library, and usually needs to switch to a Linux terminal, query by using system tools such as pkg-config, ldconfig, locate and the like, and then switch back to an editor for editing and inputting.
Editing Makefile files under Linux generally has the following method:
the method comprises the following steps: editing Makefile using vim, this method has the following drawbacks:
1) The method comprises the steps that association input such as predefined variables, dynamic libraries, static libraries, macro definitions and the like is not supported in an edited Makefile;
2) When predefined VARIABLES (including environment VARIABLES) are used, a manual is queried or a terminal is entered, and execution make is written to traverse $ (.variables) to print to obtain the corresponding value or the environment VARIABLES are printed by the echo $ xxx method to change phase to obtain.
3) When a dynamic library and a static library are used, a terminal is required to be accessed, and tools such as pkg-config, ldconfig, locate and the like are used for inquiring;
4) When the internal macro definition needs to be referenced, the content above the file needs to be searched for reference. Even though vim provides some ways of shortcut characters, the types are not distinguished, and all the inputted contents can be displayed and the efficiency can not be improved.
The second method is as follows: editing Makefile using IDE, this method has the following drawbacks:
1) The method comprises the steps that association input such as predefined variables, dynamic libraries, static libraries, macro definitions and the like is not supported in an edited Makefile;
2) When predefined VARIABLES (including environment VARIABLES) are used, a manual is required to be queried, or a terminal is entered, make execution is written to traverse $ (.VARIABLES) to print to obtain corresponding values, or the environment VARIABLES are printed by the echo $ xxx method to change phase to obtain
3) When a dynamic library and a static library are used, a terminal is required to be accessed, and tools such as pkg-config, ldconfig, locate and the like are used for inquiring;
4) When the internal macro definition needs to be referenced, the content above the file needs to be searched for reference.
In summary, the developer has complicated operations when editing the Makefile, needs to switch back and forth between the editor and the terminal, and also can remember various Linux commands to complete Makefile editing.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: aiming at the technical problems existing in the prior art, the invention provides a method and a plug-in for rapidly editing a Makefile file so as to improve the editing efficiency of the Makefile.
In order to solve the technical problems, the technical scheme provided by the invention is as follows:
a method for rapidly editing Makefile, comprising the steps of:
acquiring input contents of an edited Makefile, identifying key characters in the input contents, acquiring a corresponding target list, matching the input contents with the target list to obtain a first matching result, returning the first matching result to carry out association display, waiting for and acquiring contents selected by a user in the first matching result of the association display, and outputting the contents selected by the user to replace the input contents;
obtaining target content, wherein the target content is Makefile content hovered by a mouse or selected, identifying key characters in the target content, obtaining corresponding matching objects, matching the input content with the corresponding matching objects to obtain second matching results, displaying the second matching results through a floating layer, waiting for and obtaining the second matching results selected by a user if the target content is a dynamic library, and replacing the target content with the second matching results selected by the user.
Further, when identifying the key characters in the input content and acquiring the corresponding target list, the method includes: if the tab key is pressed for the first time in single input, acquiring a system command selection list as a target list;
when the input content matching target list obtains a first matching result, the method comprises the following steps: and carrying out regular matching filtering on the subsequent input content after the tab key is pressed and the system command selection list to obtain a first matching result.
Further, when identifying the key characters in the input content and acquiring the corresponding target list, the method includes: if the input content comprises a variable reference input item "$ (" or "$ {"), acquiring a macro definition list and a predefined variable list as target lists;
when the input content matching target list obtains a first matching result, the method comprises the following steps: and carrying out regular matching filtering on the subsequent input content of the variable reference input item, the macro definition list and the predefined variable list respectively to obtain matching results corresponding to the macro definition list and the predefined variable list as first matching results.
Further, when identifying the key characters in the input content and acquiring the corresponding target list, the method includes: if the input content comprises a preset combination key, acquiring a system operation command list as a target list;
when the input content matching target list obtains a first matching result, the method comprises the following steps: and acquiring target content before the user cursor, wherein the target content is the content between the user cursor and the adjacent space thereof, and carrying out regular matching filtering on the target content and a system operation command list to obtain a first matching result.
Further, when identifying the key characters in the input content and acquiring the corresponding target list, the method includes: if the input content comprises a variable reference input item '-l', acquiring a dynamic library list and a static library list as target lists;
when the input content matching target list obtains a first matching result, the method comprises the following steps: and carrying out regular matching filtering on the subsequent input content of the variable reference input item, the dynamic library list and the static library list respectively to obtain matching results corresponding to the dynamic library list and the static library list as first matching results.
Further, when obtaining the corresponding target list, the method includes: judging whether the target list exists in the target cache region, if yes, acquiring the target list from the target cache region, otherwise, calling a Linux command to inquire to acquire a corresponding target list and storing the corresponding target list in the target cache region.
Further, identifying key characters in the target content and obtaining corresponding matching objects, and when the input content is matched with the corresponding matching objects to obtain a second matching result, the method comprises the following steps: if the key character is a variable reference input item "$ (" or "${"), acquiring the reference content of the variable reference input item, analyzing a Makefile to obtain a macro definition value list, calling a Linux command to acquire a predefined variable list, and matching the reference content with the macro definition value list and the predefined variable list to obtain a second matching result.
Further, identifying key characters in the target content and obtaining corresponding matching objects, and when the input content is matched with the corresponding matching objects to obtain a second matching result, the method comprises the following steps: and if the key character is a variable reference input item '-l', acquiring the reference content of the variable reference input item, and inquiring compiling and linking marks containing the reference content as a second matching result.
Further, when the query contains the compiling and linking flag of the reference content as the second matching result, the method includes: if the compiling and linking marks of the appointed library are stored in the target cache area, inquiring the compiling and linking marks identical to the quoted content, and if the compiling and linking marks of the appointed library are not found in the target cache area, or the compiling and linking marks identical to the quoted content are not inquired in the target cache area, invoking the Linux command to inquire and acquiring the corresponding compiling and linking marks in the appointed library.
The invention also provides a Makefile editing plug-in, which is arranged in the IDE and is configured to execute the following steps:
activating a plug-in when the editor opens a Makefile;
acquiring input contents of an edited Makefile, identifying key characters in the input contents, acquiring a corresponding target list, matching the input contents with the target list to obtain a first matching result, returning the first matching result to carry out association display, waiting for and acquiring contents selected by a user in the first matching result of the association display, and outputting the contents selected by the user to replace the input contents;
obtaining target content, wherein the target content is Makefile content hovered by a mouse or selected, identifying key characters in the target content, obtaining corresponding matching objects, matching the input content with the corresponding matching objects to obtain second matching results, displaying the second matching results through a floating layer, waiting for and obtaining the second matching results selected by a user if the target content is a dynamic library, and replacing the target content with the second matching results selected by the user.
Compared with the prior art, the invention has the advantages that:
after the input content of the edited Makefile is obtained, the key characters in the input content are identified or an external input command is received, a corresponding target list is selected to match the input content, and the matching result is used as a candidate association result. In addition, after the content hovered or selected by the mouse is acquired, the key characters in the content can be identified, the corresponding objects are selected to be matched with the corresponding content of the key characters, and then the matching result is returned to be displayed in a floating layer. By means of automatic query, associative selection input, mouse hovering and back display replacement and other methods, operation steps are reduced, writing difficulty is simplified, complexity of writing Makefile by a developer is reduced, and efficiency of the developer is improved. The developer can conveniently and rapidly edit the Makefile file, and the technical threshold is reduced.
Drawings
Fig. 1 is a schematic diagram of an embodiment of the present invention.
Fig. 2 is a flow chart of an embodiment of the present invention.
FIG. 3 is a detailed flow chart of associative input using a macro definition list and a predefined variable list when editing Makefile in an embodiment of the present invention.
FIG. 4 is a detailed flowchart of the associative input using the system operation command list when editing Makefile according to an embodiment of the present invention.
FIG. 5 is a detailed flow chart of associative input using a dynamic library list and a static library list when editing Makefile in an embodiment of the present invention
FIG. 6 is a detailed flow chart showing a macro definition or predefined variable hovered or selected by a mouse when editing a Makefile in an embodiment of the invention.
FIG. 7 is a detailed flowchart showing a mouse-over region or a selected dynamic link library when editing a Makefile in an embodiment of the present invention.
Detailed Description
The invention is further described below in connection with the drawings and the specific preferred embodiments, but the scope of protection of the invention is not limited thereby.
Before describing the embodiments of the present invention, related concepts will be explained.
Makefile: makefile is a build tool used to define and manage the compilation and build process of a program. The method is a building tool widely used in a Linux system, but is not limited to Linux, and can be used on other Unix-like systems. Linux is the main material to be described later herein. Many of the items in the current linux system are built using Makefile, especially the C/c++ items. When constructing a development project, a developer needs to edit a Makefile, and an automatic construction process is realized by configuring a compiler, compiling options, dependency relationships, target files and the like. Different commands of the Linux system, such as directory creation, directory deletion, copy and the like, are used to realize an automatic installation and deployment process.
IDE: an integrated development environment is a software application that helps programmers develop software code efficiently. The method improves the working efficiency of developers by combining the functions of software editing, constructing, testing, packaging and the like into an application program which is easy to use.
Example 1
The existing Makefile is edited in Linux environment, whether using tools such as vim or in IDE, and needs to be manually switched to a system terminal to execute various Linux commands, and inquire resources such as system commands, macro definitions (environment variables), system dynamic libraries, static libraries and the like. In addition, when editing Makefile, the predefined variables defined above do not have the capability of associative input, and self-scrolling page search, comparison and input are needed. To facilitate rapid editing of Makefile by developers, we consider developing a plug-in the IDE that is used to provide associative inputs of predefined variables, dynamic libraries, static libraries, system commands, internal macro definitions when the developer edits Makefile in the IDE, as shown in fig. 1. The plug-in automatically expands the display variable values when the mouse hovers or a predefined variable is selected. In particular, it is desirable that the insert has the following functions:
1) In IDE, supporting the association input of internal macro definition and predefined variable by "$ (" or "${" triggering) when editing Makefile by plug-in mode, default association macro definition and variable are switched by left and right keys, and selected by carriage return or mouse;
2) In IDE, supporting the associative input of system command by predefined shortcut key mode (such as ctrl+p, different shortcut key or activation mode can be configured by IDE) when editing Makefile by plug-in mode, and selecting by getting on carriage return or mouse;
3) In IDE, supporting the associative input of a dynamic library and a static library by-l triggering when editing a Makefile in a plug-in mode, switching the dynamic library by a left-right key mode by default, and selecting by a carriage return or a mouse;
4) In IDE, supporting automatic expansion of default value when mouse floats or selects predefined variable by plug-in mode;
5) In IDE, support by plug-in means when the mouse hovers or selects a dynamic library static library reference (e.g.: lcurl) automatically expands the compiling and linking flags (-I/usr/include/x86_64-linux-gnu-lcurl) in its current environment, and can be quickly modified.
In order to realize the functions, the plug-in is prefabricated with the following matching conditions, the plug-in judges the matching conditions for the acquired content, and the input content is correspondingly processed according to the satisfied conditions, wherein the conditions comprise:
in the single input of the user, the tab key is pressed for the first time, a system command selection list is popped up, alphabetical order is defaulted, and association filtering is carried out according to the subsequent input of the user. When the user presses the tab key again, the contact input is triggered to be closed, and the tab input indentation effect is generated substantially;
when the user inputs $ { the variables needed to be referenced by the user are automatically identified, the variables comprise 'macro definition variables', 'predefined variables', a selection list containing the two variables is popped up, and association filtering is carried out according to the subsequent input of the user. When the user presses the carriage return, selecting the content supplementary input of the position of the cursor of the current list; when the user presses a key such as a space or esc, the selection list is closed;
when the user inputs-L (the case of letter L), a rule is triggered, a system dynamic and static library selection list is popped up, and the user can select to finish inputting: (e.g.: -lcurl);
identifying the code blocks as variable references according to the $ { XXX }, and matching the variable references to related logic of variable value display;
identifying as library dependent references by the-lxxx code block, matching to executing related query commands, i.e., executing system calls: pkg-config-libs-cflags libcur, acquiring the compiling and linking mark, outputting the executing result to the hovering display area, and clicking the compiling and linking mark by the user to replace the corresponding original input content. There is a cache to increase efficiency.
More input trigger conditions can be supplemented as 'prefabricated matching conditions' based on Makefile editing, so that the association between input and relevant data resources of a system and environment is realized, and the method is not limited.
Based on the above-described conditions of prefabrication, in this embodiment, the plug-in is configured to perform the following steps to implement the function of associative input:
the method comprises the steps of obtaining input contents of an edited Makefile, identifying key characters in the input contents, obtaining a corresponding target list, obtaining a matching result (called a first matching result for distinguishing) of the input contents matching the target list, returning the first matching result for associatively displaying, waiting for and obtaining contents selected by a user in the associatively displayed first matching result, and outputting the contents selected by the user to replace original input contents.
Further, in this embodiment, the plug-in is configured to perform the following steps to implement the function of hover display:
obtaining target content, wherein the target content is Makefile content hovered by a mouse or selected, identifying key characters in the target content and obtaining corresponding matching objects, obtaining matching results (for distinguishing, called second matching results) by matching the matching objects corresponding to the input content, displaying the second matching results through a floating layer, if the target content is a dynamic library, selecting the second matching results to replace the target content by a user, waiting for and obtaining the second matching results selected by the user in the second matching results displayed on the floating layer, and replacing the target content by the second matching results selected by the user.
As shown in fig. 2, the flow of using the configured plug-in by the user is as follows:
1) Developing a plug-in IDE: makefile editing plug-in;
2) Activating a plug-in when a user opens a Makefile;
3) When a user inputs, the input content is transmitted to the plug-in unit, the plug-in unit judges according to the prefabricated matching condition, and after the matching is successful, the plug-in unit inquires according to the type, and the plug-in unit comprises:
a. the method comprises the steps that a current Makefile macro definition list is obtained through analyzing two macro definition modes of the current Makefile based on AAA=. And AAA=. Respectively;
b. calling Linux command query:
predefined variables: executing makefile script to obtain list and value of predefined variables, script code is as follows:
querying a dynamic library: ldconfig-p
Querying a static library: locate ". A'
The query system may execute the program: executing a query script, wherein the script code is as follows:
4) Returning the matched data list to an editor for associative display input;
5) The user hovers or selects the input content, the content is transmitted to the plug-in, matching is carried out according to the preset condition, after matching is successful, the query result is returned according to the query type, and the method comprises the following steps:
a. and the macro definition value of the current Makefile is obtained by analyzing the current Makefile.
b. Compiling and linking marks corresponding to the designated dynamic linking library: execution by exec system call: pkg-config-libs-cflags libcur.
6) The plug-in returns the query result to the editor cursor or the selected place for display, and the user can copy, paste or replace the source.
Based on the Makefile editing plug-in of the present embodiment, the present embodiment further provides a method for rapidly editing Makefile, as shown in fig. 2, including the following steps:
s101) acquiring input contents of an edited Makefile, identifying key characters in the input contents, acquiring a corresponding target list, matching the input contents with the target list to obtain a first matching result, returning the first matching result to carry out association display, waiting for and acquiring contents selected by a user in the first matching result of association display, and outputting the contents selected by the user to replace the input contents;
s102) obtaining target content, wherein the target content is Makefile content hovered by a mouse or selected, identifying key characters in the target content and obtaining corresponding matching objects, matching the input content with the corresponding matching objects to obtain second matching results, displaying the second matching results through a floating layer, waiting for and obtaining the second matching results selected by a user if the target content is a dynamic library, and replacing the target content with the second matching results selected by the user.
In this embodiment, based on the foregoing pre-matching condition, identifying the key characters in the input content and obtaining the corresponding target list includes the following cases:
if the tab key is pressed for the first time in single input, acquiring a system command selection list as a target list;
if the input content comprises a variable reference input item "$ (" or "$ {"), acquiring a macro definition list and a predefined variable list as target lists;
if the input content comprises a preset combination key, acquiring a system operation command list as a target list;
if the input content comprises a variable reference input item '-l', a dynamic library list and a static library list are obtained as target lists.
The manner of obtaining these directory lists is specifically that the macro definition list is obtained by parsing Makefile as described in the foregoing step 3, and the predefined variable list, dynamic library list, static library list and system operation command list of the system executable program are obtained by calling each Linux command query.
Correspondingly, when the input content matching target list is matched with the key characters to obtain a first matching result, the method comprises the following steps:
if a tab key is pressed for the first time in single input, carrying out regular matching filtering on subsequent input contents after the tab key is pressed and a system command selection list to obtain a first matching result;
if the input content includes a variable reference input item "$ (" or "${", performing regular matching filtering on the subsequent input content of the variable reference input item, a macro definition list and a predefined variable list respectively to obtain matching results corresponding to the macro definition list and the predefined variable list as first matching results, specifically, after the matching results corresponding to the macro definition list and the predefined variable list are obtained, taking the matching result of the macro definition list or the predefined variable list as a default first matching result, and taking the matching result of another list (the predefined variable list or the macro definition list) as a new first matching result if a switching instruction of a user is received;
if the input content comprises a preset combination key, acquiring target content before a user cursor, wherein the target content is the content between the user cursor and an adjacent space of the user cursor, and performing regular matching filtering on the target content and a system operation command list to obtain a first matching result;
if the input content comprises a variable reference input item '-l', carrying out regular matching filtering on the subsequent input content of the variable reference input item and the dynamic library list and the static library list respectively to obtain matching results corresponding to the dynamic library list and the static library list as first matching results, specifically, after the matching results corresponding to the dynamic library list and the static library list are obtained, taking the matching results of the dynamic library list or the static library list as default first matching results, and if a switching instruction of a user is received, taking the matching results of the other list (the static library list or the dynamic library list) as new first matching results.
In this embodiment, based on the foregoing pre-matching condition, identifying the key character in the target content and obtaining the corresponding matching object, and obtaining the second matching result by matching the input content with the corresponding matching object includes the following situations:
if the key character is a variable reference input item "$ (" or "${", acquiring reference content of the variable reference input item, analyzing a Makefile to obtain a macro definition value list, calling a Linux command to acquire a predefined variable list, and matching the reference content with the macro definition value list and the predefined variable list to obtain a second matching result;
and if the key character is a variable reference input item '-l', acquiring the reference content of the variable reference input item, and inquiring compiling and linking marks containing the reference content as a second matching result.
Considering that each time an input rule is matched, the logic of triggering a display list is triggered, and time is wasted when the list is read from the original content each time, we consider that a buffer Map is built, and after each input rule is matched, a key is generated according to the input content. Thus, the same key will be generated by the same operation. When each time of inquiry is triggered, firstly, searching a cache Map through a key before inquiring to see whether available contents exist or not, and if yes, directly returning the contents; if not, executing the functional logic, and obtaining corresponding data from the original data; at this time, the obtained data is written into the buffer Map and then returned. The corresponding data content can be obtained by caching the Map after the same query.
Based on the foregoing thought, in this embodiment, when obtaining the corresponding target list, the method includes: and judging whether the target list exists in the target cache region, if so, acquiring the target list from the target cache region, otherwise, calling a Linux command to inquire to acquire a corresponding target list, and storing the corresponding target list in the target cache region.
Querying the compiling and linking mark containing the cited content as a second matching result comprises: if the compiling and linking marks of the appointed dynamic library are stored in the target cache region, inquiring the compiling and linking marks identical to the quoted content, and if the compiling and linking marks of the appointed dynamic library are not found in the target cache region, or the compiling and linking marks identical to the quoted content are not inquired in the target cache region, invoking the Linux command to inquire and acquire the corresponding compiling and linking marks in the appointed dynamic library.
To avoid duplicate processing of the same operation for short periods of time; the problem of non-uniform content and the like caused by long-time non-updating can be avoided, and the cache Map (target cache area) can be maintained in a mode of timed expiration or manual cleaning; for example, the buffer is stored for 10 minutes, and each data is automatically cleaned up after being written for 10 minutes; or the unified logic is realized to empty the cache Map under the conditions of refreshing and the like.
Example two
As shown in fig. 3, the method and the plug-in according to the first embodiment use a macro definition list and a predefined variable list for associative input, and include the following steps:
1) The user opens a Makefile;
2) IDE enters the text editor;
3) IDE activates and runs Makefile editing plug-in;
4) Editing Makefile by a user, and transmitting input content to the plug-in provided by the invention by an editor;
5) When the plug-in receives input content and recognizes that the variable references an input item (triggered according to "$ (" or "$ {" or activated by a shortcut key or other modes), analyzing a current Makefile to obtain a macro definition list, and calling a Linux command to query to obtain a predefined variable list;
6) After data is returned, the input content and the query result are subjected to regular matching filtering, for example, the input is "$ (a)", and after the regular filtering, a matched result array is returned. Because of multiple groups of different data, default macro definition list is matched in association;
7) When the user presses the left and right keys, carrying out association matching switching according to the macro definition list and the predefined variable list sequence;
8) The user presses the carriage return or the mouse to select, returns the content to the editor and outputs the cursor position to replace the input content before, if "$ (a)" is input, the abc in the user selection is replaced by "$ (abc)".
Example III
As shown in fig. 4, the method and the plug-in according to the first embodiment use the system operation command list for associative input, and include the following steps:
1) The user opens a Makefile;
2) IDE enters the text editor;
3) IDE activates and runs Makefile editing plug-in;
4) Editing the Makefile by a user, positioning a cursor of the user on the Makefile, and pressing ctrl+p;
5) The plug-in receives input content, identifies the input content as system command reading operation, acquires a word before a cursor (without space dividing part), calls a Linux command to inquire, and acquires a system operation command list;
6) After the data is returned, carrying out regular matching filtering according to the word content of the cursor position and the query result, for example, inputting an m cursor, carrying out associative matching according to a matched result list after regular filtering by using m;
7) The user presses the carriage return or the mouse to select, returns the content to the editor and outputs the content at the cursor position, replaces the input content before the input content, if the input is'm', mv in the user selection is replaced by 'mv'.
Example IV
As shown in fig. 5, the method and the plug-in according to the first embodiment use a dynamic library list and a static library list for associative input, and include the following steps:
1) The user opens a Makefile;
2) IDE enters the text editor;
3) IDE activates and runs Makefile editing plug-in;
4) Editing Makefile by a user, and transmitting input content to the plug-in provided by the invention by an editor;
5) When the plug-in receives input content and recognizes that the variable references an input item (triggered according to "-l", or activated by a shortcut key or other modes), a Linux command is called to query, including obtaining a dynamic library list and a static library list;
6) After data return, the input content and the query result are subjected to regular matching filtration, for example, if the input content is 'lc', the matched result array is returned after being subjected to regular filtration by 'linear index', and a default dynamic library list is subjected to associative matching because a plurality of groups of different data exist;
7) When the user presses the left and right keys, carrying out association matching switching according to the sequence of the dynamic library list and the static library list;
8) The user presses carriage return or mouse selection, returns the content to the editor and outputs the cursor position, replaces the previous input content, such as input "-lc", and replaces libcurl in the user selection with "-lcurl".
Example five
As shown in fig. 6, the method and the plug-in according to the first embodiment show a macro definition or a predefined variable hovered or selected by a mouse, including the following steps:
1) The user opens a Makefile;
2) IDE enters the text editor;
3) IDE activates and runs Makefile editing plug-in;
4) Editing Makefile by a user, and hovering or selecting the input content by the user by using a mouse;
5) The method comprises the steps that the plug-in receives hovering selected content, identifies the hovering selected content as "$ (& gt)" or "${ & gt reference content, analyzes a Makefile to obtain a macro definition value list, obtains a predefined variable list value by calling a Linux command, and matches the" $ (& gt) "or" $ {.} "reference content" & gt content to obtain corresponding value return;
if the content hovered or selected by the mouse is "$ (OBJC)", acquiring: "objc=cc", return "cc";
6) The results are returned to the text editor.
7) The text editor displays the content through a floating layer that can be viewed and copied by the user.
Example six
As shown in fig. 7, the method and the plugin according to the first embodiment show a mouse hovering area or a selected dynamic link library, including the following steps:
1) The user opens a Makefile;
2) IDE enters the text editor;
3) IDE activates and runs Makefile editing plug-in;
4) Editing Makefile by a user, and hovering or selecting the input content by the user by using a mouse;
5) The plug-in receives hovering selected content, identifies the hovering selected content as "-I.C." content, reads a compiling and linking mark of a required library obtained by caching or recalling Linux command query.
If the content hovering or selected by the mouse is that a "-lcurl" cursor hovers, acquiring and returning a compiling and linking mark "-I/usr/include/x86_64-linux-gnu-lcurl";
6) The results are returned to the text editor.
7) The text editor displays the content through the floating layer, so that a user can view and copy or replace the current cursor content, and the automatic introduction of-I is realized.
In summary, the present invention aims at the existence of a Makefile writing process by a developer: the method includes the steps of inquiring a Makefile manual, frequently switching editors and executing command inquiry by a terminal, executing script inquiry, inquiring complicated editing of macro definition contents in the Makefile in a full text mode and the like, introducing a Makefile editing plug-in based on an IDE development environment, and providing associative input of internal macro definition, predefined variables, a dynamic library and a static library when Makefile editing is provided in an IDE in a plug-in mode. The definition of macro is automatically expanded and displayed when the mouse is hovered or macro definition and predefined variable are selected in IDE in plug-in mode. The compiling and linking mark of the dynamic library is automatically unfolded and displayed when the mouse is suspended or the dynamic library is selected in the IDE in a plug-in mode, and the click automatic replacement is supported to introduce the include dependency. Therefore, the methods of automatic inquiry, associative selection input, mouse hovering and back display replacement and the like are realized, the operation steps are reduced, the writing difficulty is simplified, the complexity of writing Makefile by a developer is reduced, and the efficiency of the developer is improved. Under the support of the visual editing tool for information collection and associated input hovering prompt realized in the text, the compiling efficiency and quality of the compiling and constructing script file of Makefile can be greatly improved; the developer can conveniently and rapidly edit the Makefile file, and the technical threshold is reduced.
The foregoing is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. While the invention has been described with reference to preferred embodiments, it is not intended to be limiting. When editing a Makefile based on IDE, identifying and matching through keywords, and acquiring an association data acquisition value through the inside of the current project; and realizing association input or value through inquiring by the Linux system terminal, which belong to the category of the method and the plug-in tool of the invention.
For example, opening Makefile by editor, activating plug-in, inputting-I in file, triggering logic popup catalog system catalog selection box, completing automatic filling of-I/aa/bbb catalog content after selection, etc.
Therefore, any simple modification, equivalent variation and modification of the above embodiments according to the technical substance of the present invention shall fall within the scope of the technical solution of the present invention.
Claims (10)
1. A method for rapidly editing Makefile, comprising the steps of:
acquiring input contents of an edited Makefile, identifying key characters in the input contents, acquiring a corresponding target list, matching the input contents with the target list to obtain a first matching result, returning the first matching result to carry out association display, waiting for and acquiring contents selected by a user in the first matching result of the association display, and outputting the contents selected by the user to replace the input contents;
obtaining target content, wherein the target content is Makefile content hovered by a mouse or selected, identifying key characters in the target content, obtaining corresponding matching objects, matching the input content with the corresponding matching objects to obtain second matching results, displaying the second matching results through a floating layer, waiting for and obtaining the second matching results selected by a user if the target content is a dynamic library, and replacing the target content with the second matching results selected by the user.
2. The method for quickly editing Makefile according to claim 1, wherein when identifying key characters in the input content and acquiring a corresponding target list, the method comprises: if the tab key is pressed for the first time in single input, acquiring a system command selection list as a target list;
when the input content matching target list obtains a first matching result, the method comprises the following steps: and carrying out regular matching filtering on the subsequent input content after the tab key is pressed and the system command selection list to obtain a first matching result.
3. The method for quickly editing Makefile according to claim 1, wherein when identifying key characters in the input content and acquiring a corresponding target list, the method comprises: if the input content comprises a variable reference input item "$ (" or "$ {"), acquiring a macro definition list and a predefined variable list as target lists;
when the input content matching target list obtains a first matching result, the method comprises the following steps: and carrying out regular matching filtering on the subsequent input content of the variable reference input item, the macro definition list and the predefined variable list respectively to obtain matching results corresponding to the macro definition list and the predefined variable list as first matching results.
4. The method for quickly editing Makefile according to claim 1, wherein when identifying key characters in the input content and acquiring a corresponding target list, the method comprises: if the input content comprises a preset combination key, acquiring a system operation command list as a target list;
when the input content matching target list obtains a first matching result, the method comprises the following steps: and acquiring target content before the user cursor, wherein the target content is the content between the user cursor and the adjacent space thereof, and carrying out regular matching filtering on the target content and a system operation command list to obtain a first matching result.
5. The method for quickly editing Makefile according to claim 1, wherein when identifying key characters in the input content and acquiring a corresponding target list, the method comprises: if the input content comprises a variable reference input item '-l', acquiring a dynamic library list and a static library list as target lists;
when the input content matching target list obtains a first matching result, the method comprises the following steps: and carrying out regular matching filtering on the subsequent input content of the variable reference input item, the dynamic library list and the static library list respectively to obtain matching results corresponding to the dynamic library list and the static library list as first matching results.
6. The method for quickly editing a Makefile according to claim 1, wherein when obtaining the corresponding target list, the method comprises: judging whether the target list exists in the target cache region, if yes, acquiring the target list from the target cache region, otherwise, calling a Linux command to inquire to acquire a corresponding target list and storing the corresponding target list in the target cache region.
7. The method for quickly editing a Makefile according to claim 1, wherein identifying key characters in the target content and obtaining corresponding matching objects, and when matching the input content with the corresponding matching objects to obtain a second matching result, the method comprises: if the key character is a variable reference input item "$ (" or "${"), acquiring the reference content of the variable reference input item, analyzing a Makefile to obtain a macro definition value list, calling a Linux command to acquire a predefined variable list, and matching the reference content with the macro definition value list and the predefined variable list to obtain a second matching result.
8. The method for quickly editing a Makefile according to claim 1, wherein identifying key characters in the target content and obtaining corresponding matching objects, and when matching the input content with the corresponding matching objects to obtain a second matching result, the method comprises: and if the key character is a variable reference input item '-l', acquiring the reference content of the variable reference input item, and inquiring compiling and linking marks containing the reference content as a second matching result.
9. The method for quickly editing Makefile according to claim 8, wherein querying the compiled and linked flag containing the referenced content as the second matching result comprises: if the compiling and linking marks of the appointed library are stored in the target cache area, inquiring the compiling and linking marks identical to the quoted content, and if the compiling and linking marks of the appointed library are not found in the target cache area, or the compiling and linking marks identical to the quoted content are not inquired in the target cache area, invoking the Linux command to inquire and acquiring the corresponding compiling and linking marks in the appointed library.
10. A Makefile editing plug-in, wherein the Makefile editing plug-in is disposed in an IDE, the Makefile editing plug-in configured to perform the steps of:
activating a plug-in when the editor opens a Makefile;
acquiring input contents of an edited Makefile, identifying key characters in the input contents, acquiring a corresponding target list, matching the input contents with the target list to obtain a first matching result, returning the first matching result to carry out association display, waiting for and acquiring contents selected by a user in the first matching result of the association display, and outputting the contents selected by the user to replace the input contents;
obtaining target content, wherein the target content is Makefile content hovered by a mouse or selected, identifying key characters in the target content, obtaining corresponding matching objects, matching the input content with the corresponding matching objects to obtain second matching results, displaying the second matching results through a floating layer, waiting for and obtaining the second matching results selected by a user if the target content is a dynamic library, and replacing the target content with the second matching results selected by the user.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311027648.3A CN116756196B (en) | 2023-08-16 | 2023-08-16 | Method and plug-in for rapidly editing Makefile |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311027648.3A CN116756196B (en) | 2023-08-16 | 2023-08-16 | Method and plug-in for rapidly editing Makefile |
Publications (2)
Publication Number | Publication Date |
---|---|
CN116756196A true CN116756196A (en) | 2023-09-15 |
CN116756196B CN116756196B (en) | 2023-12-26 |
Family
ID=87961203
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311027648.3A Active CN116756196B (en) | 2023-08-16 | 2023-08-16 | Method and plug-in for rapidly editing Makefile |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116756196B (en) |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5761689A (en) * | 1994-09-01 | 1998-06-02 | Microsoft Corporation | Autocorrecting text typed into a word processing document |
US5940847A (en) * | 1995-06-07 | 1999-08-17 | Microsoft Corporation | System and method for automatically correcting multi-word data entry errors |
JP2001075792A (en) * | 1999-09-02 | 2001-03-23 | Nec Yonezawa Ltd | Method for preparing program by automatic preparation of makefile |
CN105183838A (en) * | 2015-09-02 | 2015-12-23 | 有戏(厦门)网络科技有限公司 | Text editing method and system based on material obtaining |
CN112882408A (en) * | 2020-12-31 | 2021-06-01 | 深圳市雷赛控制技术有限公司 | Online editing method and device for ST text language |
CN114627207A (en) * | 2022-02-28 | 2022-06-14 | 阿里巴巴(中国)有限公司 | Flow chart processing method and device |
CN115437684A (en) * | 2022-09-21 | 2022-12-06 | 麒麟软件有限公司 | File-level clipping method and system for Linux kernel source code |
CN116301886A (en) * | 2023-02-22 | 2023-06-23 | 杭州杰峰科技有限公司 | Data processing method, device, electronic equipment and computer readable storage medium |
-
2023
- 2023-08-16 CN CN202311027648.3A patent/CN116756196B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5761689A (en) * | 1994-09-01 | 1998-06-02 | Microsoft Corporation | Autocorrecting text typed into a word processing document |
US5940847A (en) * | 1995-06-07 | 1999-08-17 | Microsoft Corporation | System and method for automatically correcting multi-word data entry errors |
JP2001075792A (en) * | 1999-09-02 | 2001-03-23 | Nec Yonezawa Ltd | Method for preparing program by automatic preparation of makefile |
CN105183838A (en) * | 2015-09-02 | 2015-12-23 | 有戏(厦门)网络科技有限公司 | Text editing method and system based on material obtaining |
CN112882408A (en) * | 2020-12-31 | 2021-06-01 | 深圳市雷赛控制技术有限公司 | Online editing method and device for ST text language |
CN114627207A (en) * | 2022-02-28 | 2022-06-14 | 阿里巴巴(中国)有限公司 | Flow chart processing method and device |
CN115437684A (en) * | 2022-09-21 | 2022-12-06 | 麒麟软件有限公司 | File-level clipping method and system for Linux kernel source code |
CN116301886A (en) * | 2023-02-22 | 2023-06-23 | 杭州杰峰科技有限公司 | Data processing method, device, electronic equipment and computer readable storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN116756196B (en) | 2023-12-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP0664027B1 (en) | Program modeling system | |
US5519866A (en) | Method and apparatus of incrementally linking components of a modeled computer program | |
US5956513A (en) | System and method for automated software build control | |
CA2144874C (en) | Incremental build system | |
US5513305A (en) | System and method for documenting and displaying computer program code | |
EP0536077B1 (en) | Method and system for enhancing interactive query of a database | |
CN108762743B (en) | Data table operation code generation method and device | |
US20120192151A1 (en) | Software development tool | |
JPH05197697A (en) | Apparatus and method for constructing software system | |
US7631004B2 (en) | Systems and methods for creating a template from an existing file | |
CN111488155B (en) | Coloring language translation method | |
US5805893A (en) | Assembly language program converter | |
CN117453713A (en) | SQL sentence generation method, device and storage medium for multi-type database | |
CN107145538A (en) | List data querying method, device and system | |
CN112860312A (en) | Method and device for detecting item dependency relationship change | |
Rosen | A compiler-building system developed by Brooker and Morris: including a comprehensive discussion of the major features of the system | |
CN116756196B (en) | Method and plug-in for rapidly editing Makefile | |
CN113590088A (en) | Method and device for automatically analyzing service condition of component and electronic equipment | |
CN111949309A (en) | Method and device for pulling IDL file, computer equipment and storage medium | |
JP3712320B2 (en) | Variable document creation system, variable document output device and variable document creation device | |
JP2607975B2 (en) | Debug method | |
CN117708385A (en) | Operation method and device of resource character string and electronic equipment | |
JPH06324853A (en) | Source program editor setting object oriented programming language as target | |
CN112633856A (en) | Data processing method and device based on work items | |
CN111597323A (en) | Key field filtering method and device, storage medium and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |