CN114661298A - Automatic public method generation method, system, device and medium - Google Patents

Automatic public method generation method, system, device and medium Download PDF

Info

Publication number
CN114661298A
CN114661298A CN202210372811.9A CN202210372811A CN114661298A CN 114661298 A CN114661298 A CN 114661298A CN 202210372811 A CN202210372811 A CN 202210372811A CN 114661298 A CN114661298 A CN 114661298A
Authority
CN
China
Prior art keywords
document
public
public method
syntax tree
mock
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210372811.9A
Other languages
Chinese (zh)
Inventor
谢敏
刘南翔
屠乐奇
李�远
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Asset Management Co Ltd
Original Assignee
Ping An Asset Management Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Asset Management Co Ltd filed Critical Ping An Asset Management Co Ltd
Priority to CN202210372811.9A priority Critical patent/CN114661298A/en
Publication of CN114661298A publication Critical patent/CN114661298A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis

Abstract

The embodiment of the invention discloses a method for automatically generating a public method, which comprises the following steps: acquiring a public method document, and generating an abstract syntax tree corresponding to the public method document based on a source code field in the public method document, wherein the abstract syntax tree comprises at least one syntax node, and the syntax node is used for representing a part of source codes of the public method document; traversing the grammar nodes of the abstract grammar tree to obtain grammar nodes with modification items; adjusting syntax nodes of the abstract syntax tree based on the modification items; and generating a new public method document based on the adjusted abstract syntax tree through a preset compiling tool. The invention can automatically generate a new public method document, thereby avoiding the problem of low efficiency caused by the maintenance of the public method document by the existing manpower.

Description

Public method automatic generation method, system, device and medium
Technical Field
The embodiment of the invention relates to the field of code development, in particular to a public method automatic generation method, a public method automatic generation system, computer equipment and a computer readable storage medium.
Background
With the continuous development of computer technology, in project code development, some reusable common methods exist among different businesses, and common components of the type are generally centralized in a common library. The common method in the common library also generates iterative development, so that the code document of the common method also needs to be maintained, and the existing maintenance mode only can modify and write the code document of the common method manually, so that the efficiency is low and the error rate is high.
Disclosure of Invention
In view of the above, there is a need to provide a method, a system, a computer device and a computer readable storage medium for automatically generating a public method, so as to solve the problem of inefficiency caused by manually modifying and writing a code document.
In order to achieve the above object, an embodiment of the present invention provides a method for automatically generating a public method, where the method includes:
acquiring a public method document, and generating an abstract syntax tree corresponding to the public method document based on a source code field in the public method document, wherein the abstract syntax tree comprises at least one syntax node, and the syntax node is used for representing a part of source codes of the public method document;
traversing the syntax nodes of the abstract syntax tree to obtain syntax nodes with modification items;
adjusting syntax nodes of the abstract syntax tree based on the modification items;
and generating a new public method document based on the adjusted abstract syntax tree through a preset compiling tool.
Optionally, the modified entry is carried by a mock parameter in the form of source code.
Optionally, before the step of obtaining a public method document and generating an abstract syntax tree corresponding to the public method document based on a source code field in the public method document, the method further includes:
acquiring the matched modification item from a preset scene resource packet based on the specified application scene;
placing the modified entry as a source code field in the common method document.
Optionally, before the step of placing the modified item as a source code field in the public method document, the method further includes:
judging whether the common method document contains a mock parameter;
if so, covering the value of the mock parameter by taking the direct modification item as the value;
and if not, creating the mock parameter in the public method document, and assigning the mock parameter based on the modification item.
Optionally, after the step of generating a new common method document based on the adjusted abstract syntax tree by using a preset compiling tool, the method further includes:
and debugging the new public method document to obtain a debugging result corresponding to the debugged public method document and displaying the debugging result.
Optionally, the modification item is a hash routing value or a pass-through type definition.
Optionally, the step of adjusting the syntax node of the abstract syntax tree based on the modification item includes:
acquiring a grammar node matched with the mock parameter based on the mock parameter;
and deleting the matched grammar nodes and creating new grammar nodes based on the source codes of the mock parameters.
In order to achieve the above object, an embodiment of the present invention further provides an automatic public method generation system, where the system includes:
the conversion module is used for acquiring a public method document and generating an abstract syntax tree corresponding to the public method document based on a source code field in the public method document, wherein the abstract syntax tree comprises at least one syntax node, and the syntax node is used for representing a part of source codes of the public method document;
the traversal module is used for traversing the grammar nodes of the abstract grammar tree to obtain grammar nodes with modification items;
an adjustment module for adjusting the syntax nodes of the abstract syntax tree based on the modification items;
and the creating module is used for generating a new public method document based on the adjusted abstract syntax tree through a preset compiling tool.
To achieve the above object, an embodiment of the present invention further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the automatic generation of the public method as described above.
To achieve the above object, an embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, the computer program being executable by at least one processor to cause the at least one processor to execute the method as described above
The public method automatically generates the steps of the method.
The method, the device, the computer equipment and the computer readable storage medium for automatically generating the public method, provided by the embodiment of the invention, can automatically generate a new public method document, thereby avoiding the problem of low efficiency caused by manually maintaining the public method document in the prior art.
Drawings
Fig. 1 is a flow chart illustrating an automatic public method generating method according to an embodiment of the present invention.
Fig. 2 is a schematic flow chart of an embodiment of the invention before step S100.
Fig. 3 is a schematic flow chart of the embodiment before step S100B.
Fig. 4 is a flowchart illustrating a step S300 according to an embodiment of the present invention.
FIG. 5 is a schematic diagram of program modules of a second embodiment of the public automatic generation system according to the present invention.
Fig. 6 is a schematic diagram of a hardware structure of a third embodiment of the computer apparatus according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the present invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be noted that the description relating to "first", "second", etc. in the present invention is for descriptive purposes only and is not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the feature. In addition, technical solutions between various embodiments may be combined with each other, but must be realized by a person skilled in the art, and when the technical solutions are contradictory or cannot be realized, such a combination should not be considered to exist, and is not within the protection scope of the present invention.
It should be understood that the term "and/or" as used herein is merely one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter associated objects are in an "or" relationship.
The word "if" as used herein may be interpreted as referring to "at … …" or "when … …" or "corresponding to a determination" or "in response to a detection", depending on the context. Similarly, the phrase "if determined" or "if detected (a stated condition or time)" may be interpreted as "when determined" or "in response to a determination" or "when detected (a stated condition or event)" or "in response to a detection (a stated condition or event)", depending on the context.
In the following embodiments, the computer device 2 will be exemplarily described as an execution subject.
Example one
Referring to fig. 1, a flow chart of steps of a public method automatic generation method according to an embodiment of the present invention is shown. It is to be understood that the flow charts in the embodiments of the present method are not intended to limit the order in which the steps are performed. The following description is made by way of example with the computer device 2 as the execution subject. The details are as follows.
The embodiment of the invention provides an automatic generation method of a public method, which comprises the following steps:
step S100 obtains a public method document and generates an abstract syntax tree corresponding to the public method document based on a source code field in the public method document, where the abstract syntax tree includes at least one syntax node, and the syntax node is used to represent a part of source codes of the public method document.
The public method is a method which can be reused among different application scenes and can be stripped into the public method. For example, common methods for product judgment getproducts and for common jumps getrefmodulesUrl.
The common method document is usually placed in a common method library, and certainly, the common method document can also be extracted from a page packaging file, after the common method document is obtained, the common method document is analyzed, a document source code can be analyzed into an abstract syntax tree, the abstract syntax tree can be regarded as a common js object, and traversal and reading can be performed through js.
Illustratively, document nodes for forming an abstract syntax tree by disassembling methods in a common method are as follows:
disassembling a simple add function
function add(a,b){
return a+b
}
First, we get this grammar block, which is a function definition object.
The product is separated into three parts:
an id, its name, add
Two params, which are its parameters, i.e. [ a, b ]
A body, i.e. a stack of things in parentheses
The add has no way to continue to be removed, which is a most basic Identifier object, used as a unique Identifier for a function,
Figure RE-GDA0003633266680000051
Figure RE-GDA0003633266680000061
params continues to be disassembled, which is actually an array of two identifiers. And cannot be removed later. Step S200, traversing the grammar nodes of the abstract grammar tree to obtain grammar nodes with modification items;
the abstract syntax tree is an AST syntax tree, and the Abstract Syntax Tree (AST) is a tree representation of an abstract syntax structure of a source code, and each node on the tree represents one structure in the source code, which is abstract because the abstract syntax tree does not represent every detail of the real syntax, for example, a nesting bracket is hidden in the structure of the tree and is not represented in the form of a node. The abstract syntax tree does not depend on the syntax of the source language, that is, the context used in the parsing stage is grammatical-free, because when the grammar is written, the grammar is often equivalently transformed (left recursion, backtracking, ambiguity and the like are eliminated), which introduces some redundant components into the grammar analysis, adversely affects the subsequent stages, and even makes the combined stages confused. For this reason, many compilers often construct parse trees independently, establishing a clear interface for the front-end and back-end.
Specifically, all syntax nodes or part of syntax nodes of the abstract syntax tree are traversed to find whether the syntax node with the modification item exists. In general, the directly extracted common method document may not be adapted to the development environment of secondary development by the current technicians, or in the connection with part of other functional modules, part of the parameter or variable name does not correspond, so that the variable name or parameter specification specified in the common method document needs to be adjusted by the modification item. Illustratively, in conjunction with the parameter logic determination, the AST object structure of the common method may be obtained. The second part is conversion, when the AST nodes are traversed by using @ base/transition, operations such as adding, deleting, modifying and checking are carried out on the parsed AST syntax tree structure, specific nodes in the syntax tree are operated by an internal transition method and a special node function (such as export NamedDescription), for example, there are three common method export modes in the project, one is that the nodes return an export object, and the method includes the following steps: the method comprises the steps of firstly judging related attributes of a node, when nodes are arrays and the length of the arrays is larger than 0, traversing the node arrays, then traversing AST nodes by a transition method and a special node function (method sound limitation), generating source code mapping by an @ base/t generator according to the method name of the node function, and automatically writing the source code mapping into a markdown document, wherein one is a node return function, such as the exit function ({ … }, and the other is a node return defined variable, such as the exit request test, which can automatically generate a markdown document according to the source code by only executing the transition method once.
Step S300 adjusts syntax nodes of the abstract syntax tree based on the modification item.
Step S400 generates a new common method document based on the adjusted abstract syntax tree through a preset compiling tool.
The abstract syntax tree is based on pre-added mock parameter fields. After the node operation is carried out on the document node, the grammar tree is converted into a code in a character string form through a babel/generator tool library, a public method document is generated, and the generated public method document can be applied to the current development environment.
The method for automatically generating the public method provided by the embodiment of the invention can automatically generate a new public method document, thereby avoiding the problem of low efficiency caused by manually maintaining the public method document in the prior art.
In some embodiments, the modification item is carried with a mock parameter as a carrier.
In some embodiments, before the step of obtaining the common method document and generating the abstract syntax tree corresponding to the common method document based on the source code field in the common method document in step S100, the method further includes:
step S100A, based on the specified application scenario, obtaining the matched modification item from the preset scenario resource package;
step S100B puts the modification item as a source code field in the common method document.
Specifically, before automatically generating the public method document, a technician needs to specify an application scenario to be developed in advance, or an application scenario that the technician wants to develop next, for example, application development for a safe financial settlement function.
After the technician designates the application scene, the program executing the invention will acquire the matched modification item from the preset scene resource package, and then give the modification item as a numerical value to a specific object in the public method document.
The scene resource package is formed by a technician encapsulating modification items in different application scenes in advance according to each application scene, for example, the scene resource package may include a "modification item of a safe financial settlement service" and a "modification item of a safe financial loan application", the technician designates a keyword such as "settlement", the computer device 2 takes the written keyword as a result, extracts a corresponding modification item from the scene resource package, and places the modification item as a partial source code field in a public method document.
In some embodiments, before the step of placing the modified entry as a source code field in the common method document at step S100B, the method further comprises:
step S100C, determining whether the public method document includes a mock parameter;
if so, covering the value of the mock parameter by taking the direct modification item as the value;
and if not, creating the mock parameter in the public method document, and assigning the mock parameter based on the modification item.
Specifically, before the modified item is put into the public method document as the source code field, it is further required to judge whether the public method document contains a mock parameter capable of bearing the modified item, if the mock parameter exists, the modified item can be used as a parameter value to directly cover the value of the mock parameter, namely, the value is reassigned, when the subsequent computer device 2 adjusts the abstract semantic tree, the parameter value of the mock parameter can be extracted, and then the semantic node is subjected to add-delete operation based on the format requirement recorded in the parameter value of the mock parameter or the socket field, and the adjustment of the public method document code is completed.
In some embodiments, the modification item is a first attribute, and the step S300 of adjusting the syntax node of the abstract syntax tree based on the modification item includes:
step S310, based on the mock parameter, a grammar node matched with the mock parameter is obtained;
step S320 prunes the matched syntax nodes and creates a new syntax node based on the source code of the mock parameter.
Specifically, the nodes of the abstract semantic tree are traversed, the mock parameters of the documents which are put into the public method in advance are further obtained, the grammar nodes related to the attribute values of the mock parameters are judged according to the attribute values of the mock parameters, the related grammar nodes are deleted, and new grammar nodes are created again based on the recorded source codes of the mock parameters.
Illustratively, a technician wants to modify the add function in the common method document from the original function add (a, b) { } to an export
Then the socket field or the logic code how to prune is defined in the mock parameter. For example:
Figure RE-GDA0003633266680000091
the specific AST structure is obtained by deducing the processes of ports. Next, all functions are successfully rewritten by only replacing id ('add') with the function name obtained by traversal, replacing the parameter with the function parameter obtained by traversal, and replacing blockStatement ([ ]) with the function block-level scope obtained by traversal in the obtained final expression.
In some embodiments, after the step of generating a new common method document based on the adjusted abstract syntax tree by a preset compiling tool in step S400, the method further includes:
step S500, debugging the new public method document to obtain a debugging result corresponding to the debugged public method document and displaying the debugging result.
Specifically, the grammar tree can be converted into codes in a character string form through a babel/generator tool library, source code mapping is established at the same time, the dependency relationship among components is analyzed, and finally, the public method document is automatically debugged, so that the public method document can directly run programs after automatically generating a format adjustment matched with an application scene specified by a technician based on a modification item preset by the technician, the technician is not required to manually debug the automatically generated public method document, and the overall convenience is improved.
Example two
FIG. 5 is a schematic diagram of program modules of a second embodiment of the public automatic generation system according to the present invention. The public method automatic generation system 20 may include or be divided into one or more program modules, which are stored in a storage medium and executed by one or more processors to implement the present invention and implement the public method automatic generation method described above. The program module referred to in the embodiments of the present invention refers to a series of computer program instruction segments capable of performing specific functions, and is more suitable than the program itself for describing the execution process of the public method automatic generation system 20 in the storage medium. The following description will specifically describe the functions of the program modules of the present embodiment:
a conversion module 200, configured to obtain a public method document and generate an abstract syntax tree corresponding to the public method document based on a source code field in the public method document, where the abstract syntax tree includes at least one syntax node, and the syntax node is used to represent a part of source codes of the public method document;
a traversing module 210, configured to traverse the syntax node of the abstract syntax tree, and obtain a syntax node with a modification item;
an adjusting module 220, configured to adjust a syntax node of the abstract syntax tree based on the modification item;
and a creating module 230 for generating a new common method document based on the adjusted abstract syntax tree through a preset compiling tool.
The method for automatically generating the public method provided by the embodiment of the invention can automatically generate a new public method document, thereby avoiding the problem of low efficiency caused by manually maintaining the public method document in the prior art.
In some embodiments, the modification entry is carried in source code by a mock parameter. In some embodiments, the conversion module 200 is further configured to:
acquiring the matched modification item from a preset scene resource packet based on the specified application scene;
placing the modified entry as a source code field in the common method document.
In some embodiments, the conversion module 200 is further configured to:
judging whether the common method document contains a mock parameter;
if so, covering the value of the mock parameter by taking the direct modification item as the value;
if not, the mock parameter is created in the public method document, and the mock parameter is assigned based on the modification item.
In some embodiments, the conversion module 200 is further configured to:
and debugging the new public method document to obtain a debugging result corresponding to the debugged public method document and displaying the debugging result.
In some embodiments, the modification term is a hash routing value or a pass-through type definition. In some embodiments, the creation module 230 is further configured to:
acquiring a grammar node matched with the mock parameter based on the mock parameter;
and deleting the matched grammar nodes and creating new grammar nodes based on the source codes of the mock parameters.
The automatic public method generation system provided by the embodiment of the invention can automatically generate a new public method document, thereby avoiding the problem of low efficiency caused by the existing manual maintenance of the public method document.
EXAMPLE III
Fig. 6 is a schematic diagram of a hardware architecture of a computer device according to a third embodiment of the present invention. In the present embodiment, the computer device 2 is a device capable of automatically performing numerical calculation and/or information processing in accordance with a preset or stored instruction. The computer device 2 may be a rack server, a blade server, a tower server or a rack server (including an independent server or a server cluster composed of a plurality of servers), and the like. As shown, the computer device 2 includes, but is not limited to, at least a memory 21, a processor 22, a network interface 23, and a common method auto generation system 20, communicatively coupled to each other via a system bus.
In this embodiment, the memory 21 includes at least one type of computer-readable storage medium including a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the storage 21 may be an internal storage unit of the computer device 2, such as a hard disk or a memory of the computer device 2. In other embodiments, the memory 21 may also be an external storage device of the computer device 2, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like provided on the computer device 2. Of course, the memory 21 may also comprise both internal and external memory units of the computer device 2. In this embodiment, the memory 21 is generally used for storing an operating system and various application software installed in the computer device 2, for example, the program code of the public method automatic generation system 20 of the second embodiment. Further, the memory 21 may also be used to temporarily store various types of data that have been output or are to be output.
Processor 22 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 22 is typically used to control the overall operation of the computer device 2. In this embodiment, the processor 22 is configured to run the program code stored in the memory 21 or process data, for example, run the automatic public method generating system 20, so as to implement the automatic public method generating method according to the first embodiment.
The network interface 23 may comprise a wireless network interface or a wired network interface, and the network interface 23 is generally used for establishing communication connection between the computer device 2 and other electronic apparatuses. For example, the network interface 23 is used to connect the computer device 2 to an external terminal through a network, establish a data transmission channel and a communication connection between the computer device 2 and the external terminal, and the like. The network may be a wireless or wired network such as an Intranet (Intranet), the Internet (Internet), a Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), a 4G network, a 5G network, Bluetooth (Bluetooth), Wi-Fi, and the like.
It is noted that fig. 6 only shows the computer device 2 with components 20-23, but it is to be understood that not all shown components are required to be implemented, and that more or less components may be implemented instead.
In this embodiment, the common method automatic generation system 20 stored in the memory 21 may also be divided into one or more program modules, which are stored in the memory 21 and executed by one or more processors (in this embodiment, the processor 22) to complete the present invention.
For example, fig. 5 is a schematic diagram of program modules of the automatic public method generating system 20 according to the second embodiment of the present invention, in this embodiment, the automatic public method generating system 20 may be divided into a conversion module 200, a traversal module 210, an adjustment module 220, and a creation module 230. The program module referred to in the present invention refers to a series of computer program instruction segments capable of performing specific functions, and is more suitable than a program for describing the execution process of the public method automatic generation system 20 in the computer device 2. The specific functions of the program modules 200 and 230 have been described in detail in the second embodiment, and are not described herein again.
Example four
The present embodiment also provides a computer-readable storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, a server, an App application mall, etc., on which a computer program is stored, which when executed by a processor implements corresponding functions. The computer-readable storage medium of the present embodiment is used in the automatic public method generating system 20, and when executed by a processor, implements the automatic public method generating method of the first embodiment.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the description of the foregoing embodiments, it is clear to those skilled in the art that the method of the foregoing embodiments may be implemented by software plus a necessary general hardware platform, and certainly may also be implemented by hardware, but in many cases, the former is a better implementation.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention, and all equivalent structures or equivalent processes performed by the present invention or directly or indirectly applied to other related technical fields are also included in the scope of the present invention.

Claims (10)

1. A method for automatic generation of a public method, the method comprising:
acquiring a public method document, and generating an abstract syntax tree corresponding to the public method document based on a source code field in the public method document, wherein the abstract syntax tree comprises at least one syntax node, and the syntax node is used for representing a part of source codes of the public method document;
traversing the grammar nodes of the abstract grammar tree to obtain grammar nodes with modification items;
adjusting syntax nodes of the abstract syntax tree based on the modification items;
and generating a new public method document based on the adjusted abstract syntax tree through a preset compiling tool.
2. The method for automatic generation of public methods as claimed in claim 1, wherein the modification item is carried by mock parameter in the form of source code.
3. The method for automatically generating a public method according to claim 1, wherein before the step of obtaining a public method document and generating an abstract syntax tree corresponding to the public method document based on a source code field in the public method document, the method further comprises:
acquiring the matched modification item from a preset scene resource packet based on the specified application scene;
placing the modified entry as a source code field in the common method document.
4. The public method auto-generation method of claim 2 or 3, wherein the step of placing the modified item as a source code field in the public method document is preceded by the step of:
judging whether the common method document contains a mock parameter;
if so, covering the value of the mock parameter by taking the direct modification item as the value;
and if not, creating the mock parameter in the public method document, and assigning the mock parameter based on the modification item.
5. The method for automatically generating a public method according to claim 1, wherein after the step of generating a new public method document based on the adjusted abstract syntax tree by a preset compiling tool, the method further comprises:
and debugging the new public method document to obtain a debugging result corresponding to the debugged public method document and displaying the debugging result.
6. The public-method auto-generation method of claim 1, wherein the modification term is a hash routing value or a pass-through type definition.
7. The method of common method auto-generation according to claim 2, wherein the step of adjusting the syntax nodes of the abstract syntax tree based on the modification term comprises:
acquiring a grammar node matched with the mock parameter based on the mock parameter;
and deleting the matched grammar nodes and creating new grammar nodes based on the source codes of the mock parameters.
8. A public method automatic generation system, the system comprising:
the conversion module is used for acquiring a public method document and generating an abstract syntax tree corresponding to the public method document based on a source code field in the public method document, wherein the abstract syntax tree comprises at least one syntax node, and the syntax node is used for representing a part of source codes of the public method document;
the traversal module is used for traversing the grammar nodes of the abstract grammar tree to obtain grammar nodes with modification items;
an adjustment module for adjusting the syntax nodes of the abstract syntax tree based on the modification items;
and the creating module is used for generating a new public method document based on the adjusted abstract syntax tree through a preset compiling tool.
9. A computer arrangement comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the computer program, when executed by the processor, implements the steps of the method for automatic generation of a public method according to any one of claims 1 to 7.
10. A computer-readable storage medium, in which a computer program is stored which is executable by at least one processor for causing the at least one processor to perform the steps of the method of automatically generating a public method according to any one of claims 1 to 7.
CN202210372811.9A 2022-04-11 2022-04-11 Automatic public method generation method, system, device and medium Pending CN114661298A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210372811.9A CN114661298A (en) 2022-04-11 2022-04-11 Automatic public method generation method, system, device and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210372811.9A CN114661298A (en) 2022-04-11 2022-04-11 Automatic public method generation method, system, device and medium

Publications (1)

Publication Number Publication Date
CN114661298A true CN114661298A (en) 2022-06-24

Family

ID=82035484

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210372811.9A Pending CN114661298A (en) 2022-04-11 2022-04-11 Automatic public method generation method, system, device and medium

Country Status (1)

Country Link
CN (1) CN114661298A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117435244A (en) * 2023-12-21 2024-01-23 南京掌控网络科技有限公司 Front-end engineering-crossing public library system and construction method thereof

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117435244A (en) * 2023-12-21 2024-01-23 南京掌控网络科技有限公司 Front-end engineering-crossing public library system and construction method thereof
CN117435244B (en) * 2023-12-21 2024-03-19 南京掌控网络科技有限公司 Front-end engineering-crossing public library system and construction method thereof

Similar Documents

Publication Publication Date Title
US8091071B2 (en) Method and system for template-based code generation
US8028276B1 (en) Method and system for generating a test file
CN109800258B (en) Data file deployment method, device, computer equipment and storage medium
CN110244941B (en) Task development method and device, electronic equipment and computer readable storage medium
CN110543427B (en) Test case storage method and device, electronic equipment and storage medium
CN111209005A (en) Method and apparatus for compiling program file, and computer-readable storage medium
US20130152061A1 (en) Full fidelity parse tree for programming language processing
CN112394942A (en) Distributed software development compiling method and software development platform based on cloud computing
CN112667287A (en) Method, device and equipment for creating rule file and computer readable storage medium
CN114661298A (en) Automatic public method generation method, system, device and medium
CN114003269A (en) Component processing method and device, electronic equipment and storage medium
CN113901083A (en) Heterogeneous data source operation resource analysis positioning method and equipment based on multiple analyzers
CN111078529B (en) Client writing module testing method and device and electronic equipment
CN115757174A (en) Database difference detection method and device
CN112069052A (en) Abnormal object detection method, device, equipment and storage medium
CN115221047A (en) Automatic test case generation method and electronic equipment
CN114896161A (en) File construction method and device based on artificial intelligence, computer equipment and medium
CN114816364A (en) Method, device and application for dynamically generating template file based on Swagger
CN111708542B (en) Test case generation method, system, equipment and storage medium
CN111711605B (en) Data protocol active analysis method for Internet of things platform
CN111580821B (en) Script binding method and device, electronic equipment and computer readable storage medium
CN113050987A (en) Interface document generation method and device, storage medium and electronic equipment
CN114218261A (en) Data query method and device, storage medium and electronic equipment
CN114675835A (en) Automatic generation method, system, device and medium for public component
CN109509467B (en) Code generation method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination