Code query system, method, device, equipment, medium and product
By introducing the design of node servers and multiple warehouse servers in the code query system, the efficiency problem of developers need to access multiple warehouse servers one by one to query front-end code is solved, and efficient query of multiple warehouse server codes is achieved.
Patent Information
- Application Number
- CN202411821906.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-08
AI Technical Summary
In the prior art, developers need to access multiple warehouse servers separately to query front-end code, which is inefficient and cannot query code in multiple warehouse servers at the same time.
Design a code query system, including node servers and multiple warehouse servers. Each repository server stores front-end code files for its corresponding function type and sends these files to the node server. The node server receives these files, parses and stores them, supports conditional query, grep query and component query, and realizes simultaneous query of multiple warehouse server codes.
Through the parsing and querying functions of node servers, developers can efficiently query the front-end code in multiple warehouse servers, avoiding the inefficiency problem of accessing each warehouse server one by one and improving query efficiency.
Smart Images

Figure CN119782263A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a code query system, method, device, equipment, medium and product. Background Art
[0002] As the functionality of web applications expands, the complexity of front-end code continues to increase. Developers need to understand the front-end code in order to optimize and improve it.
[0003] In the prior art, in order to flexibly manage the front-end codes of different functions, micro-front-end technology is used to store the front-end codes of different functions in different servers (which can be called warehouse servers). However, if developers need to understand all the front-end codes, they need to visit each warehouse server separately to query the front-end codes, which is not very efficient.
[0004] It can be seen that how to conduct code query to improve the efficiency of developers querying front-end codes is an urgent problem to be solved. Summary of the invention
[0005] The purpose of the embodiments of the present invention is to provide a code query system, method, device, equipment, medium and product to improve the efficiency of developers querying front-end code. The specific technical solution is as follows:
[0006] In a first aspect, an embodiment of the present invention provides a code query system, the system comprising: a node server and a plurality of warehouse servers; wherein:
[0007] Each warehouse server is used to store the front-end code files of the functional type corresponding to the warehouse server, and send the front-end code files stored in itself to the node server; a front-end code file contains the front-end code for implementing at least one function;
[0008] The node server is used to store the front-end code files received from the multiple warehouse servers;
[0009] The node server is further used to obtain a query request carrying a code to be queried and a query method identifier; if the query method identifier represents a conditional query method, the locally stored front-end code file is parsed to obtain a first syntax tree of each front-end code file; wherein the node information of each node in the first syntax tree of each front-end code file includes: a code of a syntax structure in the front-end code file, and the position of the code in the front-end code file; each node in a syntax tree corresponds to a minimum code unit of a syntax structure;
[0010] The node server is also used to search for the first target code containing the code to be queried in the code contained in each node information of each first syntax tree; use the front-end code file containing the first target code as the first front-end code file; and use the position contained in the node information of the node to which the first target code belongs as the position of the first target code in the first front-end code file.
[0011] Optionally, each warehouse server is further used to send a file directory of each front-end code file to the node server; the file directory of each front-end code file sent by the warehouse server represents: a storage path of the front-end code file in the warehouse server;
[0012] The node server is also used to store the file directory of each front-end code file;
[0013] The node server is further used to determine the file directory of the first front-end code file in the file directories of each stored front-end code file.
[0014] Optionally, the node server is also used to, if the query mode identifier represents a grep (command) query mode, concatenate the code to be queried and the identifier of each warehouse server as input parameters, add them to a preset regular expression, and generate a grep command for querying in the front-end code file having the identifier of the warehouse server; use the generated grep command to determine, in each locally stored front-end code file, a second front-end code file containing a second target code of the code to be queried, and the position of the second target code in the second front-end code file; and determine the file directory of the second front-end code file in the file directory of each stored front-end code file.
[0015] Optionally, the node server is further used to, through a first generation process, add the code to be queried and the identifier of each warehouse server as input parameters to a preset regular expression, and generate a grep command for searching in a front-end code file having the identifier of the warehouse server; and start a query process corresponding to the identifier of each warehouse server; for each warehouse server identifier, send the grep command having the identifier of the warehouse server to the query process corresponding to the identifier of the warehouse server;
[0016] Based on the received grep command, each query process performs a query in the locally stored front-end code file with the identification of the warehouse server, and according to the query results obtained by each query process, determines the second front-end code file containing the second target code of the code to be queried, the position of the second target code in the second front-end code file, and the front-end code file containing the target code; in the file directory of each stored front-end code file, determines the file directory of the second front-end code file.
[0017] Optionally, the node server is used to, if the query mode identifier represents a component query mode, traverse the file suffix names of the locally stored front-end code files through a first traversal process to determine the writing language of the front-end code in each front-end code file;
[0018] For each front-end code file, through a parsing process, the front-end code file is parsed using a parsing function in a compiler corresponding to the writing language of the front-end code in the front-end code file to obtain a second syntax tree of the front-end code file; wherein the node information of each node in the second syntax tree of each front-end code file includes a code of a syntax structure in the front-end code file and the position of the code in the front-end code file;
[0019] In the codes contained in the node information of the component nodes of each second syntax tree, a third target code containing the code to be queried is searched; a front-end code file containing the third target code is used as a third front-end code file; the position in the node information of the node to which the third target code belongs is used as the position of the third target code in the third front-end code file; the syntax structure of each component node indicates that the node belongs to a component type;
[0020] In the file directories of each stored front-end code file, the file directory of the third front-end code file is determined.
[0021] Optionally, each warehouse server is specifically configured to send the updated front-end code file to the node server when the front-end code file in the warehouse server is updated;
[0022] and / or,
[0023] Each warehouse server is specifically used to send the front-end code file stored in itself to the node server at a preset time point;
[0024] and / or,
[0025] Each warehouse server is specifically configured to send the front-end code file stored in itself to the node server when receiving a request for obtaining the front-end code file sent by the node server.
[0026] Optionally, each warehouse server is used to collect statistics on the front-end code in the warehouse server when the front-end code file in the warehouse server is updated, obtain the statistical result of the front-end code in the warehouse server, and send it to the node server;
[0027] The node server is also used to generate charts of locally stored statistical results; and display the generated charts on the front-end page of the node server.
[0028] Optionally, for each warehouse server, the statistical result includes a first sub-statistical result and / or a second sub-statistical result;
[0029] Specifically used for traversing the file suffix names of the front-end code files stored locally through the second traversal process, and determining the writing language of the front-end code in each front-end code file; for each front-end code file, through the parsing process, using the parsing function in the compiler corresponding to the writing language of the front-end code in the front-end code file, the front-end code file is parsed to obtain a third syntax tree of the front-end code file; wherein the node information of each node in the third syntax tree of each front-end code file includes a code of a syntax structure and the position of the code in the front-end code file; and the node information of each component node in the third syntax tree also includes a component name; the syntax structure of the component node indicates that: the node belongs to a component type;
[0030] According to the position of the node information of each node in each third syntax tree and the writing language of the front-end code represented by the third syntax tree, determine the proportion of the front-end code of the specified coding language in the front-end code of the warehouse server as the first sub-statistical result;
[0031] According to the node information of the component nodes in each third syntax tree, the number of each component node in the warehouse server is determined as the second sub-statistical result.
[0032] Optionally, the statistical result includes a third sub-statistical result; each warehouse server is specifically used to determine, for each front-end code file stored locally, if there is a point-of-use annotation of the template code in the front-end code file, whether the template code exists in the front-end code file, and count the number of front-end code files stored locally that contain the template code;
[0033] According to the number of front-end code files containing the template code and the number of all front-end code files stored locally on the warehouse server, the proportion of front-end code files containing the template code in the front-end code files of the warehouse server is determined as the third sub-statistical result.
[0034] Optionally, for each warehouse server, the statistical result includes a fourth sub-statistical result; specifically used to query the keywords of the standard interface and the keywords of all interfaces in the front-end code file stored locally on the warehouse server;
[0035] According to the number of keywords of the queried standard interface and the number of keywords of all interfaces, the proportion of the standard interface in all interfaces of the front-end code file of the warehouse server is determined as the fourth sub-statistical result.
[0036] In a second aspect, an embodiment of the present invention further provides a code query method, which is applied to a node server in a code query system, wherein the code query system further includes: a plurality of warehouse servers; each warehouse server is used to store a front-end code file of a functional type corresponding to the warehouse server, and the method includes:
[0037] Obtaining a query request carrying a code to be queried and a query method identifier;
[0038] If the query mode identifier represents a conditional query mode, the locally stored front-end code files are parsed to obtain a first syntax tree of each front-end code file; wherein the node information of each node in the first syntax tree of each front-end code file includes: a code of a syntax structure in the front-end code file, and the position of the code in the front-end code file; each node in a syntax tree corresponds to a minimum code unit of a syntax structure;
[0039] In the codes contained in each node information of each first syntax tree, search for the first target code containing the code to be queried; use the front-end code file containing the first target code as the first front-end code file; and use the position contained in the node information of the node to which the first target code belongs as the position of the first target code in the first front-end code file.
[0040] In a third aspect, an embodiment of the present invention further provides a code query method, which is applied to each warehouse server in a plurality of warehouse servers in a code query system, wherein the code query system further comprises: a node server, and the method comprises:
[0041] Store the front-end code files of the functional types corresponding to the warehouse server;
[0042] Send the front-end code file stored in the node server to enable the node server to obtain a query request carrying the code to be queried and a query method identifier; if the query method identifier represents a conditional query method, parse the locally stored front-end code file to obtain a first syntax tree for each front-end code file; wherein the node information of each node in the first syntax tree of each front-end code file includes: a code of a syntax structure in the front-end code file, and the position of the code in the front-end code file; each node in a syntax tree corresponds to a minimum code unit of a syntax structure; in the code contained in each node information of each first syntax tree, query the first target code containing the code to be queried; use the front-end code file containing the first target code as the first front-end code file; use the position contained in the node information of the node to which the first target code belongs as the position of the first target code in the first front-end code file.
[0043] An embodiment of the present invention further provides an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0044] Memory, used to store computer programs;
[0045] The processor is used to implement the above code query method when executing the program stored in the memory.
[0046] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned code query method is implemented.
[0047] An embodiment of the present invention further provides a computer program product, including a computer program, and the computer program implements the above-mentioned code query method when executed by a processor.
[0048] A code query system provided by an embodiment of the present invention includes a node server and multiple warehouse servers. Each warehouse server stores a front-end code file of a functional type corresponding to the warehouse server, and the warehouse server sends the front-end code file stored by itself to the node server. The node server obtains a query request carrying a code to be queried and a query method identifier; if the query method identifier represents a conditional query method, the locally stored front-end code file is parsed to obtain a first syntax tree for each front-end code file; in the code contained in each node information of each first syntax tree, the first target code containing the code to be queried is searched; the front-end code file containing the first target code is used as the first front-end code file; the position contained in the node information of the node to which the first target code belongs is used as the position of the first target code in the first front-end code file; each node in a syntax tree corresponds to the minimum code unit of a syntax structure.
[0049] Based on the above processing, since the node server stores the front-end code files received from multiple warehouse servers, the front-end code files stored locally on the node server are the front-end code files in multiple warehouse servers. The node server parses the front-end code files stored locally to obtain the first syntax tree of each front-end code file; by searching the code to be queried in the first syntax tree, the code contained in the node information of the node of the first syntax tree of each front-end code file can be queried to obtain the first target code containing the code to be queried in the first front-end code file. The front-end code files in multiple warehouse servers can be queried at the same time, avoiding accessing each warehouse server separately to query the front-end code, which can improve the efficiency of developers in querying the front-end code. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] 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 are briefly introduced below.
[0051] Figure 1 A schematic diagram of the structure of a code query system in an embodiment of the present invention;
[0052] Figure 2 This is a schematic diagram of the working principle of the first code query system in an embodiment of the present invention;
[0053] Figure 3 This is a schematic diagram of the working principle of the second code query system in an embodiment of the present invention;
[0054] Figure 4 A schematic diagram of a code query method in an embodiment of the present invention;
[0055] Figure 5A schematic diagram of a flow chart of another code query method in an embodiment of the present invention;
[0056] Figure 6 Schematic diagram of the structure of a code query device in an embodiment of the present invention;
[0057] Figure 7 is a schematic diagram of the structure of another code query device in an embodiment of the present invention;
[0058] Figure 8 FIG. 4 is a schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION
[0059] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0060] In order to more clearly understand the embodiments of the present invention, the prior art is introduced below.
[0061] The principle of micro-frontend technology is that modern complex web applications are usually composed of many relatively independent functional modules, and these modules are responsible for multiple independent teams; each independent team is responsible for a specific functional module. Specifically, the front-end codes of different functions are stored in different warehouse servers, and the developers of each team maintain the front-end codes stored in the corresponding warehouse server. Among them, the warehouse server can also be called a code warehouse.
[0062] In the prior art, if developers need to understand all front-end codes, they access multiple warehouse servers for query based on the Integrated Development Environment (IDE). That is, it is impossible to query across code repositories for codes in multiple warehouse servers at the same time, so the query efficiency is not high.
[0063] In addition, the query based on IDE only supports keyword query, and cannot query the number of components in the warehouse server, nor can it support code query based on complex rules such as complex keyword combinations.
[0064] In addition, the code stored in the warehouse server is usually the code that has been maintained for a long time, and the code situation is relatively complicated. For example, there may be multiple programming languages for writing code, and the stability of codes in different programming languages is different. Developers may need to understand the proportion of codes in each programming language in the warehouse server. However, there is no existing technology that can count the codes in multiple warehouse servers, that is, developers cannot understand the situation of the codes in multiple warehouse servers.
[0065] It can be seen that how to conduct code query to improve the efficiency of developers querying front-end codes is an urgent problem to be solved.
[0066] In order to improve the efficiency of developers in querying front-end codes, embodiments of the present invention provide a code query system, method, apparatus, device, medium and product.
[0067] Among them, a warehouse server in a code query system provided by an embodiment of the present invention can store front-end codes; and a node server in the code query system can obtain the front-end codes stored in the warehouse server.
[0068] A code query system provided by an embodiment of the present invention includes: a node server and multiple warehouse servers;
[0069] Each warehouse server is used to store the front-end code files of the functional type corresponding to the warehouse server, and send the front-end code files stored in itself to the node server; a front-end code file contains the front-end code for implementing at least one function;
[0070] Node server, used to store front-end code files received from multiple warehouse servers;
[0071] The node server is further used to obtain a query request carrying a code to be queried and a query method identifier; if the query method identifier represents a conditional query method, the locally stored front-end code file is parsed to obtain a first syntax tree of each front-end code file; wherein the node information of each node in the first syntax tree of each front-end code file includes: a code of a syntax structure in the front-end code file, and the position of the code in the front-end code file; each node in a syntax tree corresponds to a minimum code unit of a syntax structure;
[0072] The node server is also used to search for the first target code containing the code to be queried in the code contained in each node information of each first syntax tree; use the front-end code file containing the first target code as the first front-end code file; and use the position contained in the node information of the node to which the first target code belongs as the position of the first target code in the first front-end code file.
[0073] Based on the above processing, since the node server stores the front-end code files received from multiple warehouse servers, the front-end code files stored locally on the node server are the front-end code files in multiple warehouse servers. The node server parses the front-end code files stored locally to obtain the first syntax tree of each front-end code file; the code to be queried is searched in the first syntax tree, and the code contained in the node of the first syntax tree of each front-end code file can be queried to obtain the first target code containing the code to be queried in the first front-end code file. The front-end code files in multiple warehouse servers can be queried at the same time, avoiding accessing each warehouse server separately to query the front-end code, which can improve the efficiency of developers in querying the front-end code.
[0074] The following describes a code query system provided by an embodiment of the present invention in conjunction with the accompanying drawings. Figure 1 As shown, the system may include a node server 110 and a plurality of warehouse servers 120 .
[0075] Each warehouse server 120 is used to store the front-end code files of the functional type corresponding to the warehouse server 120 and send the front-end code files stored in itself to the node server 110; a front-end code file contains the front-end code for implementing at least one function.
[0076] It is understandable that each warehouse server 120 may store a front-end code file of a functional type corresponding to the warehouse server 120. For example, a warehouse server stores a front-end code file for implementing a shopping function, and another warehouse server stores a front-end code file for implementing a video playback function. A front-end code file contains a front-end code for implementing at least one function, that is, the front-end code in the front-end code file of the functional type can implement at least one function under the functional type. For example, a warehouse server stores a front-end code file for implementing a shopping function, and the front-end code file may include: a front-end code for implementing a product display and a front-end code for implementing a product transaction.
[0077] The front-end code in the front-end code file may be written in at least one coding language, such as Vue language (Vue JavaScript, Vue), JAVA script (JavaScript, JS) language or typescript (TypeScript, TS) language for building the front-end interface.
[0078] It is understandable that each warehouse server 120 can send the front-end code file stored in itself to the node server 110. Exemplarily, each warehouse server 120 can copy the front-end code file stored in itself and send the copied front-end code file to the node server 110.
[0079] It is understandable that the warehouse server 120 can send the front-end code file according to the specified upload rules. For example, the front-end code file can be sent at a fixed time point, etc.
[0080] Optionally, in one implementation, each warehouse server 120 is specifically used to send the updated front-end code file to the node server 110 when the front-end code file in the warehouse server 120 is updated; and / or, each warehouse server 120 is specifically used to send the front-end code file stored in itself to the node server 110 at a preset time point; and / or, each warehouse server 120 is specifically used to send the front-end code file stored in itself to the node server 110 when receiving a request for obtaining the front-end code file sent by the node server 110.
[0081] It can be understood that when there is a front-end code file update in the warehouse server 120, the warehouse server can send the updated front-end code file to the node server 110, which can not only improve the real-time performance of the front-end code file stored in the node server, but also avoid sending all the front-end code files to the node server, thereby reducing the resources required for data transmission.
[0082] When the preset time point is reached, the warehouse server 120 can send all the front-end code files stored in itself to the node server 110. Exemplarily, when the preset time point is reached, the warehouse server 120 can copy its own front-end code files through a preset automatic script file, and send the copied front-end code files to the node server 110. The preset time point can be set according to the rest time of the developer (for example, 24:00 every day), ensuring that when sending the front-end code files, the developer will not update the front-end code files in the warehouse server, thereby improving the real-time performance of the front-end code files received by the node server.
[0083] When receiving the request for obtaining the front-end code file sent by the node server 110 , the warehouse server 120 may respond to the request and send the front-end code file stored in the warehouse server 120 to the node server 110 .
[0084] It should be noted that, for the three situations of when the front-end code file is updated, at a preset time point, and when a request for acquisition is received, the warehouse server 120 can send the front-end code file stored in itself to the node server 110 if one of the situations is met.
[0085] The node server 110 is used to store the front-end code files received from the multiple warehouse servers 120 (hereinafter collectively referred to as the node server storage function).
[0086] The node server 110 is also used to obtain a query request carrying a code to be queried and a query method identifier; if the query method identifier represents a conditional query method, the locally stored front-end code file is parsed to obtain a first syntax tree for each front-end code file; wherein the node information of each node in the first syntax tree of each front-end code file includes: a code of a syntax structure in the front-end code file, and the position of the code in the front-end code file; each node in a syntax tree corresponds to a minimum code unit of a syntax structure (hereinafter collectively referred to as the node server parsing function).
[0087] The node server 110 is also used to search for a first target code containing a code to be queried in the code contained in each node information of each first syntax tree; use a front-end code file containing the first target code as the first front-end code file; and use a position contained in the node information of the node to which the first target code belongs as the position of the first target code in the first front-end code file (hereinafter collectively referred to as the node server search function).
[0088] Regarding the node server storage function, it can be understood that the node server 110 can receive and store the front-end code files sent by multiple warehouse servers 120. Since the node server 110 stores the front-end code files of multiple warehouse servers, the node server 110 can query the front-end code files stored in itself, avoiding accessing the warehouse servers one by one to obtain the front-end code files.
[0089] For the node server resolution function, the front page of the node server 110 can display optional query methods and search boxes. The user can select the query method he wants to use on the front page, enter the code to be queried in the search box of the front page, and then start the query of the node server. For example, the user can click the query button to start the query of the node server.
[0090] After the user operates on the front-end page, the front-end page of the node server 110 can send a query request to the back-end processor. In other words, the node server 110 can obtain a query request carrying a code to be queried and a query method identifier. Among them, the query method identifier can represent the query method selected by the user on the front-end page. Specifically, the query method identifier can be an interface of the corresponding query method. Exemplarily, the front-end page is designed in a comprehensive front-end development environment that supports the react framework, the Vue framework, and the nest framework.
[0091] It is understandable that if the query method identifier obtained by the node server 110 represents a conditional query method, a conditional query tool can be used to parse the locally stored front-end code files to obtain the first syntax tree of each front-end code file. Exemplarily, the conditional query tool can be a gogocode tool, which is a tool for processing code files based on an abstract syntax tree (AST). The tool may include a parsing function (also called a parsing method), a search function (also called a find method), and other functions.
[0092] Specifically, the node server 110 may call the parsing function of the gogocode tool to parse the front-end code files stored locally to obtain a first syntax tree for each front-end code file.
[0093] It is understandable that if the query method selected by the user is a conditional query method, that is, the query method identifier represents the conditional query method, and the code to be queried entered by the user in the search box of the front-end page is a query statement that the conditional query tool can adapt. Exemplarily, the conditional query tool is the gogocode tool, and the code to be queried can be a query statement composed of at least one of a keyword, a keyword combination, and a code attribute; wherein the code attribute is a feature of the code, which is used to represent the state or data of the defined object, for example, the code attribute can be a template type code or a script type code. In an embodiment of the present invention, since the conditional query method can support the query of query statements composed of at least one of a keyword, a keyword combination, and a code attribute, it is possible to use accurate code to be queried for querying, and perform condition-rich code retrieval, which helps developers to more effectively locate the code to be queried and improve the accuracy of the query. And querying through a customized query statement can improve flexibility and enhance the user experience.
[0094] It can be understood that the abstract syntax tree (collectively referred to as a syntax tree in the embodiment of the present invention) is an abstract representation of the syntax structure of the code. It displays multiple syntax structures of a writing language in a tree form. The node information of each node on the tree contains a code of a syntax structure and the position of the code in the front-end code file. The code can be uniquely distinguished in the front-end code file through the syntax structure and position of the code. A syntax tree contains code in a front-end code file. There may be multiple codes of the same syntax structure in the front-end code file. Each node in a syntax tree corresponds to the minimum code unit of a syntax structure. For example, the code contained in a node is if, which can represent the code of a selection structure. Among them, the syntax structure can be a sequential structure, a loop structure, or a selection structure, etc., and the position can be the code line number of the code in the front-end code file.
[0095] Optionally, in one implementation, the node server 110 is used to traverse the file suffixes of the locally stored front-end code files through a traversal process to determine the writing language of the front-end code in each front-end code file; if there are front-end codes written in multiple languages in a front-end code file, then through a parsing process, using the parsing function of the gogocode tool, the front-end codes in the multiple writing languages in the front-end code file are parsed separately to obtain the first syntax tree of the front-end code in each writing language in the front-end code file.
[0096] It is understandable that the file suffix of the front-end code file can indicate the writing language used by the front-end code file. For example, the file suffix ".vue" can indicate that the front-end code file uses the Vue language, the file suffix ".ts" can indicate that the front-end code file uses the TS language, and the file suffix ".js" can indicate that the front-end code file uses the JS language. The node server 110 can determine the writing language used by the front-end code file by traversing the file suffixes of the front-end code files stored locally through the traversal process.
[0097] Each front-end code file can be parsed through the parsing function of the gogocode tool, and the file suffix of the front-end code file is also added to the parsing result to obtain the first syntax tree including the file suffix of the front-end code file, that is, the first syntax tree of the front-end code file.
[0098] Since there is only code in one language in a syntax tree, if there are front-end codes in multiple languages in a front-end code file, the parsing function of the gogocode tool can be used to parse the front-end codes in multiple languages in the front-end code file separately through the parsing process to obtain the first syntax tree of the front-end code in each language in the front-end code file.
[0099] Exemplarily, if the file extension of the front-end code file is ".vue", the writing language of the front-end code file is Vue language, and the files written in Vue language are usually the files where the framework and components in the front-end page are located. The framework in the front-end page can be the page content that does not interact with the user, and the code that implements the framework display in the front-end page can be the code of a fixed template; the component in the front-end page can be the content that can interact with the user, for example, the component can be a button, etc., and the code that implements the component display in the front-end page can be the code of the script. Moreover, the template code and the script code are written in different writing languages, so there are two codes written in two writing languages in the file written in Vue language. The template code and the script code in the file written in Vue language can be parsed separately to obtain the first syntax tree of the template code and the first syntax tree of the script code in the front-end code file.
[0100] It is understandable that the file extensions can be traversed in the traversal process of the node server 110, and the front-end code files can be parsed in the parsing process. The traversal process and the parsing process separate the processing of traversing the file extensions from the processing of parsing the front-end code files, that is, the processing of traversing the file extensions and the processing of parsing the front-end code files are decoupled. Through the above processing, the coupled operation of checking the file extensions and parsing the front-end code files for each front-end code file in one process is avoided, which can improve the parsing efficiency and further improve the efficiency of developers in querying the front-end code.
[0101] Regarding the node server search function, it is understandable that for each first syntax tree, the search function of the conditional query tool can be called to traverse the code contained in the node information of each node in the first syntax tree to find out whether there is a code containing the code to be queried. Exemplarily, the search function of the gogocode tool can be used to traverse the code contained in the node information of each node in the first syntax tree.
[0102] Optionally, in one implementation, each warehouse server 120 is further configured to send a file directory of each front-end code file to the node server; the file directory of each front-end code file sent by the warehouse server represents: a storage path of the front-end code file in the warehouse server;
[0103] The node server 110 is also used to store the file directory of each front-end code file;
[0104] The node server 110 is further used to determine the file directory of the first front-end code file in the file directories of each stored front-end code file.
[0105] It is understandable that each warehouse server 120 can simultaneously send the front-end code files stored in itself and the file directory of the front-end code files to the node server 110; the node server 110 can store the front-end code files of each warehouse server and the file directory of the front-end code files in the corresponding warehouse server. The node server 110 can simultaneously store the front-end code files of each warehouse server and the file directory of the front-end code files in the warehouse server to which they belong.
[0106] The node server 110 can parse each front-end code file to obtain the first syntax tree of the front-end code file. If the writing language used by the front-end code in the front-end code file is the same writing language, all the front-end codes in the front-end code file can be represented by a syntax tree. If the front-end code in the front-end code file is written in multiple writing languages, the front-end code for each writing language in the front-end code file can be represented by a syntax tree, that is, multiple syntax trees can be obtained by parsing the front-end code file. That is, there is at least one syntax tree corresponding to a front-end code file. The node server 110 can generate a corresponding relationship between a syntax tree and a file directory while obtaining the syntax tree. Specifically, the object relationship can be a corresponding relationship between a syntax tree and the front-end code file to which the syntax tree belongs in the file directory of the corresponding warehouse server.
[0107] If the node server 110 finds the first target code containing the code to be queried in a first syntax tree, the file directory corresponding to the first syntax tree can be found in the corresponding relationship as the file directory of the front-end code file where the first target code is located. The location of the first target code and the file directory of the front-end code file containing the first target code are determined as the query result of the first syntax tree. The query results of each first syntax tree are aggregated to obtain the location of the code to be queried in the front-end code file and the file directory of the front-end code file containing the code to be queried in the corresponding warehouse server.
[0108] It can be understood that, by using the queried location and file directory, the code at the location in the front-end code file under the storage path represented by the file directory can be processed, thereby improving the convenience of maintaining the front-end code file in the warehouse server. Specifically, the queried location can be the code line number in the front-end code file, and the storage location of the code to be queried in the warehouse server can be determined based on the code line represented by the queried code line number and the storage path represented by the file directory, and the code line where the code to be queried is located can be processed. For example, if an object name A needs to be modified, the object name A can be used as a keyword to query, obtain the file directory of the code line where the object name A is located in the warehouse server, and modify the code line where the object name A is located in the warehouse server.
[0109] Based on the above processing, since the node server stores the front-end code files received from multiple warehouse servers, the front-end code files stored locally on the node server are the front-end code files in multiple warehouse servers. The node server parses the front-end code files stored locally to obtain the first syntax tree of each front-end code file; the code to be queried is searched in the first syntax tree, and the code contained in the node of the first syntax tree of each front-end code file can be queried to obtain the first target code containing the code to be queried in the first front-end code file. The front-end code files in multiple warehouse servers can be queried at the same time, avoiding accessing each warehouse server separately to query the front-end code, which can improve the efficiency of developers in querying the front-end code.
[0110] Optionally, in another embodiment, the node server 110 is also used to, if the query mode identifier represents a grep query mode, concatenate the code to be queried and the identifier of each warehouse server as input parameters, add them to a preset regular expression, and generate a grep command for searching in the front-end code file having the identifier of the warehouse server; use the generated grep command to determine, in each locally stored front-end code file, a second front-end code file containing a second target code of the code to be queried, and the position of the second target code in the second front-end code file; and determine the file directory of the second front-end code file in the file directory of each stored front-end code file.
[0111] It is understandable that if the query mode identifier represents the grep query mode, the query can be performed according to the query mode of the grep command of the Linux operating system. It should be noted that the grep command can be used to search for a specific string in a file, and the grep command containing different regular expressions can implement different specific query modes. For example, the grep command containing the regular expression -r can be used to recursively read all files in the file directory, match the code to be queried, and obtain the location of the code to be queried; the grep command containing the regular expression -B6 can be used to match the code to be queried, and the line number of the code line where the code to be queried is located and the line numbers of the 6 code lines above the code line can be obtained. Among them, in the embodiment of the present invention, the regular expression can be pre-set to -r, that is, the node server 110 can query the location of the code to be queried through the grep command containing the regular expression -r.
[0112] Specifically, the node server 110 can search for the location of the second target code containing the code to be queried in each locally stored front-end code file according to the search method represented by a preset regular expression; then, in the file directory of the warehouse server to which each locally stored front-end code file belongs, determine the second front-end code file to which the second target code belongs in the file directory of the warehouse server to which it belongs, and obtain the file directory of the second front-end code file.
[0113] Optionally, in one implementation, the node server 110 is further used to, through a first generation process, add the code to be queried and the identifier of each warehouse server as input parameters to a preset regular expression, and generate a grep command for searching in a front-end code file having the identifier of the warehouse server; and start a query process corresponding to the identifier of each warehouse server; for each warehouse server identifier, send the grep command having the identifier of the warehouse server to the query process corresponding to the identifier of the warehouse server;
[0114] Based on the received grep command, each query process performs a query in the locally stored front-end code file with the identification of the warehouse server, and according to the query results obtained by each query process, determines the second front-end code file containing the second target code of the code to be queried, the position of the second target code in the second front-end code file, and the front-end code file containing the second target code; in the file directory of each stored front-end code file, determines the file directory of the second front-end code file.
[0115] It is understandable that the node server 110 can store each front-end code file and the identifier of the warehouse server to which the front-end code file belongs. The node server 110 can generate a grep command for querying the front-end code files in each warehouse server stored locally by splicing the code to be queried, the regular expression and the identifier of each warehouse server through the first generation process, that is, multiple grep commands can be generated.
[0116] Furthermore, the node server 110 may start multiple query processes, the number of which is the same as the number of warehouse servers to which the locally stored front-end code files belong, and the identifier of each warehouse server 120 corresponds to each query process.
[0117] The node server 110 may send a grep command with the identifier of each warehouse server to the query process corresponding to the identifier of the warehouse server, that is, a grep command is allocated to each query process.
[0118] The node server 110 can run the grep command received by each query process through each query process, and query in the front-end code file with the identification of the warehouse server. If the code to be queried is found, the query result of the query process can be determined to be the position of the code to be queried in the front-end code file; if the code to be queried is not found, it can be determined that the query result of the query process is empty. Then, the query results obtained by each query process are summarized, and the file directory of the warehouse server to which each front-end code file stored locally belongs is determined, and the file directory of the warehouse server to which the queried position belongs is determined, and the position of the code to be queried in the front-end code file and the file directory of the front-end code file are obtained. Among them, if the query method identifier represents the grep query method, the code to be queried is a keyword.
[0119] Exemplarily, if the operating environment of the node server 110 is the Node.js environment in which the JS language code is running, the node server 110 can start the query process of the identification of each warehouse server through the child process (child_process) module in Node.js; for each warehouse server identification, the grep command with the identification of the warehouse server is sent to the query process corresponding to the identification of the warehouse server.
[0120] For example, for a grep command with the identifier of each warehouse server, the grep command may be:
[0121] `grep -r"${searchContent}"${path.resolve(
[0122] __dirname,
[0123] `${project.name}`,
[0124] grep–r indicates that the grep command uses the search method represented by the regular expression -r; searchContent indicates the code to be queried, path.resolve indicates the file directory, dirname indicates the file name, and project.name indicates the identifier of the warehouse server.
[0125] In the embodiment of the present invention, by using multiple query processes, the front-end code files of each warehouse server are queried in parallel, which can improve the query efficiency and further improve the efficiency of developers in querying the front-end code.
[0126] Moreover, through the grep command query, users only need to open the front-end page of the node server, without the help of other tools, to quickly query the front-end codes in multiple warehouse servers, saving time and improving work efficiency.
[0127] Optionally, in another embodiment, the node server 110 is used to, if the query mode identifier represents the component query mode, traverse the file suffix names of the locally stored front-end code files through a first traversal process to determine the writing language of the front-end code in each front-end code file; (hereinafter collectively referred to as the node server traversal function)
[0128] For each front-end code file, through the parsing process, the front-end code file is parsed using the parsing function in the compiler corresponding to the writing language of the front-end code in the front-end code file to obtain a second syntax tree of the front-end code file; wherein the node information of each node in the second syntax tree of each front-end code file includes a code of a syntax structure in the front-end code file, and the position of the code in the front-end code file; (hereinafter collectively referred to as the node server parsing function)
[0129] In the code contained in the node information of the component node of each second syntax tree, the third target code containing the code to be queried is searched; the front-end code file containing the third target code is used as the third front-end code file; the position in the node information of the node to which the third target code belongs is used as the position of the third target code in the third front-end code file; the syntax structure of each component node indicates that the node belongs to the component type; in the file directory of each stored front-end code file, the file directory of the third front-end code file is determined. (hereinafter collectively referred to as the node server search function)
[0130] For the node server traversal function, if the query method identifier represents the component query method, the node server 110 can traverse the file suffixes of all the front-end code files stored locally through the first traversal process to determine the writing language of each front-end code file. For example, the file suffix ".vue" can indicate that the front-end code file uses the Vue language, the file suffix ".ts" can indicate that the front-end code file uses the TS language, and the file suffix ".js" can indicate that the front-end code file uses the JS language.
[0131] Regarding the node server parsing function, it can be understood that the process of parsing the front-end code file can be handled by the parsing process. Different writing languages have corresponding compilers. For example, the corresponding compiler of the Vue language can be the compiler in the @Vue / compiler-sfc tool. The code can be converted into nodes in the syntax tree through the parsing function in the compiler.
[0132] The node server 110 can parse each front-end code file stored locally using the parsing function in the compiler corresponding to the language in which the front-end code is written in the front-end code file to obtain a second syntax tree for the front-end code file. It can be understood that the process of traversing the file suffix name is processed in the traversal process, and the process of generating the syntax tree is processed in the parsing process. Through different process processing, the process of traversing the file suffix name and the process of generating the syntax tree can be decoupled to improve query efficiency.
[0133] For the node server search function, for the second syntax tree of each front-end code file, each component node in the second syntax tree can be traversed to determine whether the code in the node information corresponding to the component node contains the code to be queried, so as to query the third target code containing the code to be queried; the front-end code file containing the third target code is used as the third front-end code file; the position in the node information of the node to which the third target code belongs is used as the position of the third target code in the third front-end code file. Among them, the syntax structure of each component node indicates that the node belongs to the component type.
[0134] The node server can determine the file directory of the third front-end code file in the file directory of each stored front-end code file. Exemplarily, after generating the second syntax tree of each front-end code file, the second syntax tree of each front-end code file can be matched with the file directory of the front-end code file according to the file directory of the warehouse server corresponding to each front-end code file stored locally, and a corresponding relationship between the second syntax tree of each front-end code file and the file directory is generated. After determining the third front-end code file containing the third target code, the file directory of the third front-end code file is determined in the corresponding relationship.
[0135] Optionally, in one implementation, the code to be queried includes component name, component attributes, and attribute values of the component attributes; the node information corresponding to each component node also includes: component name, component attributes, and attribute values of the component represented by the component node.
[0136] It is understandable that, in the code contained in the node information of the component node of each second syntax tree, in the process of querying the third target code containing the code to be queried, it is necessary to determine whether the component name, component attributes and attribute values of the component attributes in the code to be queried are the same as the component name, component attributes and attribute values of the component attributes represented by the component node in the node information. Among them, the component name can be the identifier of the component, or it can be a specific name, for example, the name of the component can be a button; the component attribute can be the feature of the component, for example, the component attribute can be a large size or a small size, etc.; the attribute value of the component attribute can be a specific numerical value of the feature, for example, the attribute value of the component attribute can be 3*3 cm or 5*5 cm, etc. Exemplarily, the node information of a component node can be that the size of a large-sized button component is 5*5 cm.
[0137] In the above query method, it is necessary to simultaneously satisfy the matching of component name, component attribute and attribute value of component attribute. Optionally, in another query method, the code to be queried may include the component name. In this case, it is only necessary that the component name in the code to be queried matches the component name in the node information of a component node to determine that the component node is the matched component node. Optionally, in yet another query method, the code to be queried may include the component name and component attribute. In this case, it is only necessary that the component name and component attribute in the code to be queried matches the component name and component attribute in the node information of a component node to determine that the component node is the matched component node.
[0138] The grep command cannot query component attributes or attribute values of component attributes, and the conditional query method requires the input of complex query statements with multiple code combinations. The embodiment of the present invention provides a component query method, in which the user can directly input the component name, component attribute, and attribute value of the component attribute to query, avoiding the input of complex query statements, querying the component name, component attribute, and attribute value of the component attribute, which can expand the method of querying components, reduce the content that the user needs to input to query the component, and improve the user experience.
[0139] Furthermore, the embodiment of the present invention provides a method for querying components, which can accurately retrieve component codes in the front-end code, making it convenient for developers to query the usage of components in the component library and facilitating the management of the component library.
[0140] Optionally, in one embodiment, each warehouse server 120 is used to perform statistics on the front-end code in the warehouse server 120 when the front-end code file in the warehouse server 120 is updated, obtain the statistical result of the front-end code in the warehouse server 120, and send it to the node server 110;
[0141] The node server 110 is also used to generate charts of the statistical results stored locally; and display the generated charts on the front-end page of the node server 110 .
[0142] It can be understood that each warehouse server 120 can be pre-installed with a script file for counting front-end code. When the front-end code file in the warehouse server 120 is updated, the warehouse server 120 can count the front-end code in the warehouse server based on the method set in the script file, obtain the statistical results of the front-end code in the warehouse server, and send them to the node server 110.
[0143] Exemplarily, when the version number of the front-end code file in the warehouse server 120 is updated, the warehouse server 120 performs statistics on the front-end code. The version number may be a tag label, and when the tag label is generated, the version number is updated and the front-end code file is updated.
[0144] The node server 110 can receive and store the statistical results sent by each warehouse server. The node server 110 can generate a chart of the statistical results based on the statistical results stored locally, and display the generated chart on the front-end page of the node server 110. Exemplarily, the front-end icon library Echarts can be used to generate an icon instance, and the statistical results can be used as parameters in the icon instance to generate a chart of the statistical results. Optionally, the node server 110 can generate a chart of the statistical results stored locally when receiving a statistical result display instruction.
[0145] The embodiment of the present invention can perform statistics on the front-end code and display the statistical results on the front-end page, so that the user can intuitively view the status of the front-end code in each warehouse server, thereby improving the user's usage experience.
[0146] Optionally, in another embodiment, each warehouse server 120 is specifically used to traverse the file suffixes of the locally stored front-end code files through a second traversal process to determine the writing language of the front-end code in each front-end code file; for each front-end code file, through a parsing process, the front-end code file is parsed using a parsing function in a compiler corresponding to the writing language of the front-end code in the front-end code file to obtain a third syntax tree of the front-end code file; wherein the node information of each node in the third syntax tree of each front-end code file includes a code of a syntax structure and the position of the code in the front-end code file; and the node information of each component node in the third syntax tree also includes a component name; the syntax structure of the component node indicates that the node belongs to a component type; (hereinafter collectively referred to as the warehouse server parsing function)
[0147] According to the position of the node information of each node in each third syntax tree and the writing language of the front-end code represented by the third syntax tree, determine the proportion of the front-end code of the specified coding language in the front-end code of the warehouse server as the first sub-statistical result;
[0148] According to the node information of the component nodes in each third syntax tree, the number of each component node in the warehouse server is determined as the second sub-statistical result. (hereinafter collectively referred to as the warehouse server statistical function)
[0149] Regarding the warehouse server parsing function, it can be understood that the warehouse server 120 can traverse the file suffixes of the front-end code files stored locally in the warehouse server through the second traversal process to determine the writing language of the front-end code in each front-end code file. Through the parsing process, the front-end code file is parsed using the parsing function in the compiler corresponding to the writing language of the front-end code in the front-end code file to obtain the third syntax tree of the front-end code file. The specific implementation method of the warehouse server 120 performing the above processing is similar to the specific implementation method of the node server 110 in the aforementioned embodiment, and will not be described in detail here.
[0150] For the warehouse server statistics function, in the process of determining the first sub-statistics function, since the node information of each node in the third syntax tree of each front-end code file includes a code of a syntax structure and its position in the front-end code file, the position of the code in the third syntax tree can be determined. In addition, each third syntax tree corresponds to a writing language, so the position of the code of each writing language can be determined, and naturally the position of the code of the specified writing language can also be determined. Then, the proportion of the front-end code of the specified coding language in the front-end code of the warehouse server is determined as the first sub-statistical result. The specified writing language can be a pre-set language, such as TS language. Optionally, TS language can be used as the specified writing language. Since TS language is usually used to write template-type code, in the scenario where multiple teams maintain different front-end codes, template-type code is easier to maintain. By understanding the proportion of TS language in the warehouse server, the maintenance difficulty of the code in the warehouse server can be better evaluated to improve the efficiency of maintenance for the front-end code.
[0151] In the process of determining the second sub-statistical function, since the node information of the component node in the third syntax tree can also include the component name, the type of the component node can be determined according to the component name in the node information of each component node in each third syntax tree, and then the number of components of different types can be counted to obtain the second sub-statistical result.
[0152] In the embodiment of the present invention, the number of components is counted, which can help developers understand commonly used components and infrequently used components. In the process of maintaining the code, they can focus on the codes of commonly used components, thereby improving the efficiency of front-end code maintenance.
[0153] Optionally, in another embodiment, each warehouse server 120 is specifically used to determine, for each front-end code file stored locally, that the template code exists in the front-end code file when there is a point annotation of the template code in the front-end code file, and count the number of front-end code files stored locally that have the template code;
[0154] According to the number of front-end code files with template codes and the number of all front-end code files stored locally on the warehouse server, the proportion of front-end code files with template codes in the front-end code files of the warehouse server is determined as the third sub-statistical result.
[0155] It is understandable that the warehouse server 120 can use the embedded annotations of the template code as the code to be queried, and query the embedded annotations of the template code in the front-end code files locally stored in the warehouse server 120. If the embedded annotations of the template code are queried in a front-end code file, it can be determined that the code in the front-end code file is the template code; if the embedded annotations of the template code are not queried in a front-end code file, it can be determined that the code in the front-end code file is not the template code. Then, the number of front-end code files with template code is determined, and the number of front-end code files with template code is divided by the number of all front-end code files. The proportion of front-end code files with template code in the front-end code files of the warehouse server can be obtained as the third sub-statistical result. Among them, the template code is a code that can be quickly configured and generated based on the low-code platform, which can also be called low-code.
[0156] Optionally, after using the embedded point annotation of the template code as the code to be queried, the warehouse server 120 can use the grep query method or conditional query method mentioned in the above embodiment to query the code to be queried. Since only the embedded point annotation needs to be used as a keyword for query, the efficiency of using the grep query method to query the embedded point annotation of the template code is higher.
[0157] In a scenario where multiple teams maintain different front-end codes, template codes are easier to maintain. By measuring the proportion of front-end code files containing template codes in the front-end code files of the warehouse server, we can better evaluate the maintenance difficulty of the code in the warehouse server and improve the efficiency of front-end code maintenance.
[0158] Optionally, in another embodiment, each warehouse server 120 is specifically used to query the keywords of the standard interface and the keywords of all interfaces in the front-end code file stored locally in the warehouse server 120;
[0159] According to the number of keywords of the queried standard interface and the number of keywords of all interfaces, the proportion of the standard interface in all interfaces of the front-end code file of the warehouse server is determined as the fourth sub-statistical result.
[0160] It is understandable that the standard interface can be an interface uniformly generated based on a standardized data processing framework. For example, the standard interface can be an interface generated based on the Atlas framework. It is understandable that the standard interface can be used to manage data, such as data collection and query. The keyword of the standard interface can be an identifier representing the framework that generates the interface. For example, the standard interface can be an interface generated based on the Atlas framework, and the keyword of the standard interface can be @AtlasAction. The keyword of all interfaces can be interface.
[0161] The number of standard interfaces and the number of all interfaces can be determined according to the number of keywords of the queried standard interfaces and the number of keywords of all interfaces. Exemplarily, the number of keywords of the queried standard interfaces is taken as the number of standard interfaces, and the number of keywords of all interfaces is taken as the number of all interfaces. By dividing the number of standard interfaces by the number of all interfaces, the proportion of standard interfaces in all interfaces of the front-end code file of the warehouse server can be obtained as the fourth sub-statistical result.
[0162] Optionally, after using the keywords of the standard interface and the keywords of all interfaces as the code to be queried, the warehouse server 120 can use the grep query method or conditional query method mentioned in the above embodiment to query the code to be queried. Since only keywords need to be used for querying, the efficiency of querying using the grep query method is higher.
[0163] It is understandable that at least one of the first sub-statistical result, the second sub-statistical result, the third sub-statistical result, and the fourth sub-statistical result in the above embodiment and this embodiment can be used as a statistical result. Optionally, the first sub-statistical result, the second sub-statistical result, the third sub-statistical result, and the fourth sub-statistical result can be used as a statistical result at the same time.
[0164] In an embodiment of the present invention, the proportion of standard interfaces in all interfaces of the front-end code file of the warehouse server can be obtained. If the proportion of standard interfaces is higher, the less interface definition work required manually, and the standardization of the front-end code can be better evaluated.
[0165] In order to more clearly understand the embodiments of the present invention, Figure 2 The query process of the node server 110 is introduced.
[0166] like Figure 2 As shown, the warehouse server 120 may store front-end code files with different functions, such as file 1, file 2, file 3, etc. A front-end code file contains front-end code for implementing at least one function.
[0167] The backend processor of the node server 110 may be provided with a timed script file, and through the timed script file, the backend processor may be used to periodically send a request to obtain the frontend code file to each warehouse server. When receiving the acquisition request, the warehouse server 120 may send the frontend code file stored in itself and the file directory of each frontend code file in the warehouse server to the node server 110, thereby realizing the copying of the frontend code file from the warehouse server.
[0168] In the front page of the node server 110, there may be buttons for conditional query mode, grep (command) query mode and component query mode for the user to select. After the user selects the query mode and enters the code to be queried, the front page of the node server 110 may send a query request to the back-end processor.
[0169] The node server 110 may obtain a query request carrying a code to be queried and a query method identifier. If the query method identifier represents a conditional query method, a conditional query method service may be provided; if the query method identifier represents a grep query method, a grep (command) query method service may be provided; if the query method identifier represents a component query method, a component query method service may be provided.
[0170] The front-end page and the back-end processor of the node server 110 may be developed based on a JAVAScript-based Web development framework, which may be a Moose framework.
[0171] Based on the above processing, since the node server stores the front-end code files received from multiple warehouse servers, the front-end code files stored locally on the node server are the front-end code files in multiple warehouse servers. The node server parses the front-end code files stored locally to obtain the first syntax tree of each front-end code file; the code to be queried is searched in the first syntax tree, and the code contained in the node of the first syntax tree of each front-end code file can be queried to obtain the first target code containing the code to be queried in the first front-end code file. The front-end code files in multiple warehouse servers can be queried at the same time, avoiding accessing each warehouse server separately to query the front-end code, which can improve the efficiency of developers in querying the front-end code.
[0172] In order to more clearly understand the embodiments of the present invention, Figure 3 The statistical process of the warehouse server 120 is introduced.
[0173] like Figure 3 As shown, a script file for code analysis is pre-installed in the warehouse server 120, and the script file includes a code analysis script file, and the code analysis script file includes a method for counting the first sub-statistical result, the second sub-statistical result, the third sub-statistical result, and the fourth sub-statistical result. Exemplarily, the script file can be a scripts node management package (Scripts Node Package Manager, scripts npm).
[0174] When the front-end code file in the warehouse server 120 is updated, statistics are performed on the front-end code in the warehouse server according to the method in the script file to obtain the statistical result of the front-end code in the warehouse server, and the statistical result is sent to the node server 110.
[0175] The node server 110 may store the received statistical results in a statistical database. When a user chooses to view the statistical results on the front-end page of the node server 110, the front-end page of the node server 110 may send a display request for the statistical results to the back-end processor of the node server 110. After receiving the display request for the statistical results, the back-end processor of the node server 110 may generate a chart of the statistical results stored locally; and display the generated chart on the front-end page of the node server 110.
[0176] In the embodiment of the present invention, various statistical information can be counted and displayed in the form of charts, which is convenient for developers to quickly understand the situation of the front-end code and improve the efficiency of developers in querying the front-end code.
[0177] The embodiment of the present invention also provides a code query method, which is applied to a node server in a code query system, wherein the code query system further comprises: a plurality of warehouse servers; each warehouse server is used to store a front-end code file of a functional type corresponding to the warehouse server. Figure 4 As shown, the method includes steps S401-S403.
[0178] S401, obtaining a query request carrying a code to be queried and a query method identifier.
[0179] S402: If the query mode identifier represents a conditional query mode, the locally stored front-end code files are parsed to obtain a first syntax tree of each front-end code file.
[0180] Among them, the node information of each node in the first syntax tree of each front-end code file includes: the code of a syntax structure in the front-end code file, and the position of the code in the front-end code file; each node in a syntax tree corresponds to the minimum code unit of a syntax structure.
[0181] S403, searching for the first target code containing the code to be queried in the code contained in each node information of each first syntax tree; using the front-end code file containing the first target code as the first front-end code file; using the position contained in the node information of the node to which the first target code belongs as the position of the first target code in the first front-end code file.
[0182] It can be understood that the specific implementation of the code query method provided in the embodiment of the present invention has been described in the above embodiment, and will not be repeated here.
[0183] Based on the above processing, since the node server stores the front-end code files received from multiple warehouse servers, the front-end code files stored locally on the node server are the front-end code files in multiple warehouse servers. The node server parses the front-end code files stored locally to obtain the first syntax tree of each front-end code file; the code to be queried is searched in the first syntax tree, and the code contained in the node of the first syntax tree of each front-end code file can be queried to obtain the first target code containing the code to be queried in the first front-end code file. The front-end code files in multiple warehouse servers can be queried at the same time, avoiding accessing each warehouse server separately to query the front-end code, which can improve the efficiency of developers in querying the front-end code.
[0184] Optionally, in another embodiment, the embodiment of the present invention further provides a code query method, which is applied to each warehouse server in a plurality of warehouse servers in a code query system, and the code query system further includes: a node server. Figure 5 As shown, the method includes steps S501-S502.
[0185] S501, storing the front-end code file of the functional type corresponding to the warehouse server;
[0186] S502, sending the front-end code file stored in the node server to the node server.
[0187] So that the node server obtains a query request carrying the code to be queried and a query method identifier; if the query method identifier represents a conditional query method, the locally stored front-end code file is parsed to obtain a first syntax tree for each front-end code file; wherein the node information of each node in the first syntax tree of each front-end code file includes: a code of a syntax structure in the front-end code file, and the position of the code in the front-end code file; each node in a syntax tree corresponds to a minimum code unit of a syntax structure; in the code contained in each node information of each first syntax tree, the first target code containing the code to be queried is searched; the front-end code file containing the first target code is used as the first front-end code file; the position contained in the node information of the node to which the first target code belongs is used as the position of the first target code in the first front-end code file.
[0188] It can be understood that the specific implementation of the code query method provided in the embodiment of the present invention has been described in the above embodiment, and will not be repeated here.
[0189] Based on the above processing, since the node server stores the front-end code files received from multiple warehouse servers, the front-end code files stored locally on the node server are the front-end code files in multiple warehouse servers. The node server parses the front-end code files stored locally to obtain the first syntax tree of each front-end code file; the code to be queried is searched in the first syntax tree, and the code contained in the node of the first syntax tree of each front-end code file can be queried to obtain the first target code containing the code to be queried in the first front-end code file. The front-end code files in multiple warehouse servers can be queried at the same time, avoiding accessing each warehouse server separately to query the front-end code, which can improve the efficiency of developers in querying the front-end code.
[0190] The embodiment of the present invention also provides a code query device, which is applied to a node server in a code query system. The code query system also includes: a plurality of warehouse servers; each warehouse server is used to store a front-end code file of a functional type corresponding to the warehouse server. Figure 6 As shown, the device comprises:
[0191] The acquisition module 610 is used to acquire a query request carrying a code to be queried and a query mode identifier;
[0192] The parsing module 620 is used to parse the locally stored front-end code files to obtain a first syntax tree of each front-end code file if the query mode identifier represents a conditional query mode.
[0193] Among them, the node information of each node in the first syntax tree of each front-end code file includes: the code of a syntax structure in the front-end code file, and the position of the code in the front-end code file; each node in a syntax tree corresponds to the minimum code unit of a syntax structure.
[0194] The query module 630 is used to query the first target code containing the code to be queried in the code contained in each node information of each first syntax tree; use the front-end code file containing the first target code as the first front-end code file; and use the position contained in the node information of the node to which the first target code belongs as the position of the first target code in the first front-end code file.
[0195] Based on the above processing, since the node server stores the front-end code files received from multiple warehouse servers, the front-end code files stored locally on the node server are the front-end code files in multiple warehouse servers. The node server parses the front-end code files stored locally to obtain the first syntax tree of each front-end code file; the code to be queried is searched in the first syntax tree, and the code contained in the node of the first syntax tree of each front-end code file can be queried to obtain the first target code containing the code to be queried in the first front-end code file. The front-end code files in multiple warehouse servers can be queried at the same time, avoiding accessing each warehouse server separately to query the front-end code, which can improve the efficiency of developers in querying the front-end code.
[0196] Optionally, in another embodiment, the present invention further provides a code query device, which is applied to each warehouse server in a plurality of warehouse servers in a code query system, and the code query system further includes: a node server. Figure 7 As shown, the device comprises:
[0197] Storage module 710, used to store the front-end code files of the functional type corresponding to the warehouse server;
[0198] The sending module 720 is used to send the front-end code file stored in the node server to the node server.
[0199] So that the node server obtains a query request carrying the code to be queried and a query method identifier; if the query method identifier represents a conditional query method, the locally stored front-end code file is parsed to obtain a first syntax tree for each front-end code file; wherein the node information of each node in the first syntax tree of each front-end code file includes: a code of a syntax structure in the front-end code file, and the position of the code in the front-end code file; each node in a syntax tree corresponds to a minimum code unit of a syntax structure; in the code contained in each node information of each first syntax tree, the first target code containing the code to be queried is searched; the front-end code file containing the first target code is used as the first front-end code file; the position contained in the node information of the node to which the first target code belongs is used as the position of the first target code in the first front-end code file.
[0200] Based on the above processing, since the node server stores the front-end code files received from multiple warehouse servers, the front-end code files stored locally on the node server are the front-end code files in multiple warehouse servers. The node server parses the front-end code files stored locally to obtain the first syntax tree of each front-end code file; the code to be queried is searched in the first syntax tree, and the code contained in the node of the first syntax tree of each front-end code file can be queried to obtain the first target code containing the code to be queried in the first front-end code file. The front-end code files in multiple warehouse servers can be queried at the same time, avoiding accessing each warehouse server separately to query the front-end code, which can improve the efficiency of developers in querying the front-end code.
[0201] The embodiment of the present invention further provides an electronic device, such as Figure 8 As shown, it includes a processor 801, a communication interface 802, a memory 803 and a communication bus 804, wherein the processor 801, the communication interface 802, and the memory 803 communicate with each other through the communication bus 804.
[0202] Memory 803, used for storing computer programs;
[0203] The processor 801 is used to implement the above code query method when executing the program stored in the memory 803.
[0204] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0205] The communication interface is used for communication between the above terminal and other devices.
[0206] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0207] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0208] In another embodiment of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the code query method described in any one of the above embodiments is implemented.
[0209] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the code query method described in any one of the above embodiments.
[0210] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0211] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0212] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for method embodiments and device embodiments, since they are basically similar to system embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0213] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A code query system, characterized in that: The system includes: a node server and a plurality of warehouse servers; wherein, Each warehouse server is used to store the front-end code files of the functional type corresponding to the warehouse server, and send the front-end code files stored in itself to the node server; a front-end code file contains the front-end code for implementing at least one function; The node server is used to store the front-end code files received from the multiple warehouse servers; The node server is further used to obtain a query request carrying a code to be queried and a query method identifier; if the query method identifier represents a conditional query method, the locally stored front-end code file is parsed to obtain a first syntax tree of each front-end code file; wherein the node information of each node in the first syntax tree of each front-end code file includes: a code of a syntax structure in the front-end code file, and the position of the code in the front-end code file; each node in a syntax tree corresponds to a minimum code unit of a syntax structure; The node server is also used to search for the first target code containing the code to be queried in the code contained in each node information of each first syntax tree; use the front-end code file containing the first target code as the first front-end code file; and use the position contained in the node information of the node to which the first target code belongs as the position of the first target code in the first front-end code file.
2. The system according to claim 1, characterized in that Each warehouse server is further used to send a file directory of each front-end code file to the node server; the file directory of each front-end code file sent by the warehouse server represents: the storage path of the front-end code file in the warehouse server; The node server is also used to store the file directory of each front-end code file; The node server is further used to determine the file directory of the first front-end code file in the file directories of each stored front-end code file.
3. The system according to claim 2, characterized in that The node server is further configured to, if the query mode identifier represents a grep query mode, concatenate the code to be queried and the identifier of each warehouse server as input parameters, add them to a preset regular expression, and generate a grep command for querying in a front-end code file having the identifier of the warehouse server; Using the generated grep command, determine the second front-end code file containing the second target code of the code to be queried, and the position of the second target code in the second front-end code file in each front-end code file stored locally; In the file directories of each stored front-end code file, determine the file directory of the second front-end code file.
4. The system according to claim 3, characterized in that The node server is further used to add the code to be queried and the identifier of each warehouse server as input parameters to a preset regular expression through a first generation process, generate a grep command for searching in a front-end code file having the identifier of the warehouse server; and start a query process corresponding to the identifier of each warehouse server; For each warehouse server identifier, a grep command having the warehouse server identifier is sent to a query process corresponding to the warehouse server identifier; Through each query process, based on the received grep command, a query is performed in the front-end code file with the identification of the warehouse server stored locally, and according to the query results obtained by each query process, a second front-end code file containing the second target code of the code to be queried, a position of the second target code in the second front-end code file, and a front-end code file containing the second target code are determined; In the file directories of each stored front-end code file, determine the file directory of the second front-end code file.
5. The system according to claim 2, characterized in that The node server is used for, if the query mode identifier represents a component query mode, traversing the file suffixes of the locally stored front-end code files through a first traversal process to determine the writing language of the front-end code in each front-end code file; For each front-end code file, through a parsing process, the front-end code file is parsed using a parsing function in a compiler corresponding to the writing language of the front-end code in the front-end code file to obtain a second syntax tree of the front-end code file; wherein the node information of each node in the second syntax tree of each front-end code file includes a code of a syntax structure in the front-end code file and the position of the code in the front-end code file; In the codes contained in the node information of the component nodes of each second syntax tree, a third target code containing the code to be queried is searched; a front-end code file containing the third target code is used as a third front-end code file; the position in the node information of the node to which the third target code belongs is used as the position of the third target code in the third front-end code file; the syntax structure of each component node indicates that the node belongs to a component type; In the file directories of each stored front-end code file, the file directory of the third front-end code file is determined.
6. The system according to any one of claims 1 to 5, characterized in that: Each warehouse server is specifically configured to send the updated front-end code file to the node server when the front-end code file in the warehouse server is updated; and / or, Each warehouse server is specifically used to send the front-end code file stored in itself to the node server at a preset time point; and / or, Each warehouse server is specifically configured to send the front-end code file stored in itself to the node server when receiving a request for obtaining the front-end code file sent by the node server.
7. The system according to claim 1, characterized in that Each warehouse server is used to collect statistics on the front-end code in the warehouse server when the front-end code file in the warehouse server is updated, obtain the statistical result of the front-end code in the warehouse server, and send it to the node server; The node server is also used to generate charts of locally stored statistical results; and display the generated charts on the front-end page of the node server.
8. The system according to claim 7, characterized in that The statistical result includes a first sub-statistical result and / or a second sub-statistical result; Each warehouse server is specifically used to traverse the file suffix names of the front-end code files stored locally through a second traversal process to determine the writing language of the front-end code in each front-end code file; for each front-end code file, through a parsing process, the front-end code file is parsed using the parsing function in the compiler corresponding to the writing language of the front-end code in the front-end code file to obtain a third syntax tree of the front-end code file; wherein the node information of each node in the third syntax tree of each front-end code file includes a code of a syntax structure and the position of the code in the front-end code file; and the node information of each component node in the third syntax tree also includes a component name; the syntax structure of the component node indicates that the node belongs to a component type; According to the position of the node information of each node in each third syntax tree and the writing language of the front-end code represented by the third syntax tree, determine the proportion of the front-end code of the specified coding language in the front-end code of the warehouse server as the first sub-statistical result; According to the node information of the component nodes in each third syntax tree, the number of each component node in the warehouse server is determined as the second sub-statistical result.
9. The system according to claim 7, characterized in that The statistical result includes a third sub-statistical result; Each warehouse server is specifically used for determining, for each front-end code file stored locally, if there is a point annotation of the template code in the front-end code file, whether the template code exists in the front-end code file, and counting the number of front-end code files stored locally that contain the template code; According to the number of front-end code files containing the template code and the number of all front-end code files stored locally on the warehouse server, the proportion of front-end code files containing the template code in the front-end code files of the warehouse server is determined as the third sub-statistical result.
10. The system according to claim 7, characterized in that The statistical result includes a fourth sub-statistical result; Each warehouse server is specifically used to search for keywords of standard interfaces and keywords of all interfaces in the front-end code files stored locally in the warehouse server; According to the number of keywords of the queried standard interface and the number of keywords of all interfaces, the proportion of the standard interface in all interfaces of the front-end code file of the warehouse server is determined as the fourth sub-statistical result.
11. A code query method, characterized in that: A node server applied to a code query system, the code query system further comprising: a plurality of warehouse servers; each warehouse server is used to store a front-end code file of a functional type corresponding to the warehouse server, the method comprising: Obtaining a query request carrying a code to be queried and a query method identifier; If the query mode identifier represents a conditional query mode, the locally stored front-end code files are parsed to obtain a first syntax tree of each front-end code file; wherein the node information of each node in the first syntax tree of each front-end code file includes: a code of a syntax structure in the front-end code file, and the position of the code in the front-end code file; each node in a syntax tree corresponds to a minimum code unit of a syntax structure; In the codes contained in each node information of each first syntax tree, search for the first target code containing the code to be queried; use the front-end code file containing the first target code as the first front-end code file; and use the position contained in the node information of the node to which the first target code belongs as the position of the first target code in the first front-end code file.
12. A code query method, characterized in that: Applied to each warehouse server in a plurality of warehouse servers in a code query system, the code query system further comprising: a node server, the method comprising: Store the front-end code files of the functional types corresponding to the warehouse server; Send the front-end code file stored in the node server to enable the node server to obtain a query request carrying the code to be queried and a query method identifier; if the query method identifier represents a conditional query method, parse the locally stored front-end code file to obtain a first syntax tree for each front-end code file; wherein the node information of each node in the first syntax tree of each front-end code file includes: a code of a syntax structure in the front-end code file, and the position of the code in the front-end code file; each node in a syntax tree corresponds to a minimum code unit of a syntax structure; in the code contained in each node information of each first syntax tree, query the first target code containing the code to be queried; use the front-end code file containing the first target code as the first front-end code file; use the position contained in the node information of the node to which the first target code belongs as the position of the first target code in the first front-end code file.
13. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method of claim 11 or 12 when executing a program stored in a memory.
14. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method of claim 11 or 12.