CN110688121A - Code completion method, device, computer device and storage medium - Google Patents

Code completion method, device, computer device and storage medium Download PDF

Info

Publication number
CN110688121A
CN110688121A CN201910780750.8A CN201910780750A CN110688121A CN 110688121 A CN110688121 A CN 110688121A CN 201910780750 A CN201910780750 A CN 201910780750A CN 110688121 A CN110688121 A CN 110688121A
Authority
CN
China
Prior art keywords
abstract syntax
training source
syntax tree
code
control flow
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
CN201910780750.8A
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.)
OneConnect Smart Technology Co Ltd
Original Assignee
OneConnect Smart Technology 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 OneConnect Smart Technology Co Ltd filed Critical OneConnect Smart Technology Co Ltd
Priority to CN201910780750.8A priority Critical patent/CN110688121A/en
Publication of CN110688121A publication Critical patent/CN110688121A/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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/29Graphical models, e.g. Bayesian networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention provides a code completion method, which comprises the following steps: acquiring a plurality of training source codes; generating abstract syntax trees of a plurality of training source codes, and generating a father abstract syntax tree and a son abstract syntax tree of the plurality of training source codes according to the abstract syntax trees; generating a parent control flow diagram of a plurality of training source codes according to a parent abstract syntax tree of the plurality of training source codes, and generating a child control flow diagram of the plurality of training source codes according to a child abstract syntax tree of the plurality of training source codes; constructing a Bayesian prediction model according to a father control flow diagram and a son control flow diagram of a plurality of training source codes; acquiring a source code to be complemented; and inputting the source code to be complemented into a Bayesian prediction model for code complementation to obtain a subsequent code of the source code to be complemented. The invention also provides a code completion device, a computer device and a computer readable storage medium. The invention can complete the code of the more complex code and improve the efficiency of compiling the software code.

Description

Code completion method, device, computer device and storage medium
Technical Field
The present invention relates to the field of computer software technologies, and in particular, to a code completion method and apparatus, a computer apparatus, and a computer-readable storage medium.
Background
The code completion means prompting subsequent codes according to input codes in the programming process, so that the software development efficiency is improved. The current common code completion method is based on simple grammar inference or word frequency statistics of common words, or is an n-gram method based on shallow semantic information. The method has limited content capable of completing the codes, can only complete the codes based on a limited number of elements in the source codes, and cannot complete the codes for more complex codes.
Disclosure of Invention
In view of the foregoing, there is a need for a code completion method, device, computer device and computer readable storage medium, which can perform code completion on more complex codes and improve the efficiency of writing software codes.
A first aspect of the present application provides a code completion method, the method including:
acquiring a plurality of training source codes;
generating abstract syntax trees of the training source codes, and generating a parent abstract syntax tree and a child abstract syntax tree of the training source codes according to the abstract syntax trees;
generating a parent control flow graph of the plurality of training source codes according to the parent abstract syntax tree of the plurality of training source codes, and generating a child control flow graph of the plurality of training source codes according to the child abstract syntax tree of the plurality of training source codes;
constructing a Bayesian prediction model according to the parent control flow diagram and the child control flow diagram of the training source codes;
acquiring a source code to be complemented;
and inputting the source code to be complemented into the Bayesian prediction model for code complementation to obtain a subsequent code of the source code to be complemented.
In another possible implementation manner, before generating the abstract syntax tree of the plurality of training source codes, the method further includes:
judging whether the sentence of each training source code in the plurality of training source codes is missing;
and if the sentence of the training source code is missing, discarding the training source code.
In another possible implementation manner, the generating the abstract syntax tree of the plurality of training source codes includes:
performing lexical analysis on each training source code, and converting the training source code into an array consisting of lexical units;
performing syntactic analysis on the training source code according to the array consisting of the lexical units, and determining whether the grammar of the training source code is correct;
and if the grammar of the training source code is correct, generating an abstract grammar tree of the training source code according to the array consisting of the lexical units.
In another possible implementation manner, the lexical analysis is performed on each training source code, and the converting of the training source code into an array composed of lexical units includes:
and carrying out lexical analysis on each sentence of the training source code through a lexical analyzer, and converting each sentence of the training source code into an array consisting of lexical units.
In another possible implementation manner, the generating a parent abstract syntax tree and a child abstract syntax tree according to the abstract syntax tree includes:
traversing all nodes of the abstract syntax tree,
determining parent and child nodes of the abstract syntax tree and a hierarchy of the parent and child nodes in the abstract syntax tree;
and generating the parent abstract syntax tree and the child abstract syntax tree according to the hierarchy of the parent node and the child node in the abstract syntax tree.
In another possible implementation manner, the generating a parent control flow graph of the plurality of training source codes according to the parent abstract syntax tree of the plurality of training source codes, and generating a child control flow graph of the plurality of training source codes according to the child abstract syntax tree of the plurality of training source codes includes:
generating a three-address instruction according to the father abstract syntax tree/the son abstract syntax tree;
constructing a basic block according to the three-address instruction;
and constructing the parent abstract syntax tree/the child control flow graph according to the basic block.
In another possible implementation manner, the constructing a bayesian prediction model according to the parent control flow graph and the child control flow graph of the plurality of training source codes includes:
extracting grammatical structure characteristics of a parent control flow graph of the training source codes;
counting the probability of the child control flow graph appearing in the parent control flow graph;
and constructing the Bayesian prediction model according to the probability of the child control flow graph appearing in the parent control flow graph.
A second aspect of the present application provides a code completion apparatus, the apparatus comprising:
the first acquisition module is used for acquiring a plurality of training source codes;
the first generation module is used for generating abstract syntax trees of the training source codes and generating a parent abstract syntax tree and a child abstract syntax tree of the training source codes according to the abstract syntax trees;
a second generating module, configured to generate a parent control flow graph of the plurality of training source codes according to a parent abstract syntax tree of the plurality of training source codes, and generate a child control flow graph of the plurality of training source codes according to a child abstract syntax tree of the plurality of training source codes;
the building module is used for building a Bayesian prediction model according to the parent control flow graph and the child control flow graph of the training source codes;
the second acquisition module is used for acquiring the source code to be complemented;
and the completion module is used for inputting the source code to be completed into the Bayesian prediction model to complete the code so as to obtain a subsequent code of the source code to be completed.
In another possible implementation manner, the apparatus further includes:
and the screening module is used for judging whether the sentences of each training source code in the plurality of training source codes are missing or not, and discarding the training source codes if the sentences of the training source codes are missing.
In another possible implementation manner, the generating the abstract syntax tree of the plurality of training source codes includes:
performing lexical analysis on each training source code, and converting the training source code into an array consisting of lexical units;
performing syntactic analysis on the training source code according to the array consisting of the lexical units, and determining whether the grammar of the training source code is correct;
and if the grammar of the training source code is correct, generating an abstract grammar tree of the training source code according to the array consisting of the lexical units.
In another possible implementation manner, the lexical analysis is performed on each training source code, and the converting of the training source code into an array composed of lexical units includes:
and carrying out lexical analysis on each sentence of the training source code through a lexical analyzer, and converting each sentence of the training source code into an array consisting of lexical units.
In another possible implementation manner, the generating a parent abstract syntax tree and a child abstract syntax tree according to the abstract syntax tree includes:
traversing all nodes of the abstract syntax tree, and determining parent nodes and child nodes of the abstract syntax tree and the levels of the parent nodes and the child nodes in the abstract syntax tree;
and generating the parent abstract syntax tree and the child abstract syntax tree according to the hierarchy of the parent node and the child node in the abstract syntax tree.
In another possible implementation manner, the generating a parent control flow graph of the plurality of training source codes according to the parent abstract syntax tree of the plurality of training source codes, and generating a child control flow graph of the plurality of training source codes according to the child abstract syntax tree of the plurality of training source codes includes:
generating a three-address instruction according to the father abstract syntax tree/the son abstract syntax tree;
constructing a basic block according to the three-address instruction;
and constructing the parent abstract syntax tree/the child control flow graph according to the basic block.
In another possible implementation manner, the constructing a bayesian prediction model according to the parent control flow graph and the child control flow graph of the plurality of training source codes includes:
extracting grammatical structure characteristics of a parent control flow graph of the training source codes;
counting the probability of the child control flow graph appearing in the parent control flow graph;
and constructing the Bayesian prediction model according to the probability of the child control flow graph appearing in the parent control flow graph.
A third aspect of the present application provides a computer apparatus comprising a memory for storing at least one instruction and a processor for executing the at least one instruction to implement the code completion method.
A fourth aspect of the present application provides a computer-readable storage medium storing at least one instruction which, when executed by a processor, implements the code completion method.
According to the technical scheme, the invention provides a code completion method, a device, a computer device and a computer readable storage medium, wherein the method obtains a plurality of training source codes; generating abstract syntax trees of the training source codes, and generating a parent abstract syntax tree and a child abstract syntax tree of the training source codes according to the abstract syntax trees; generating a parent control flow graph of the plurality of training source codes according to the parent abstract syntax tree of the plurality of training source codes, and generating a child control flow graph of the plurality of training source codes according to the child abstract syntax tree of the plurality of training source codes; constructing a Bayesian prediction model according to the parent control flow diagram and the child control flow diagram of the training source codes; acquiring a source code to be complemented; and inputting the source code to be complemented into the Bayesian prediction model for code complementation to obtain a subsequent code of the source code to be complemented. The method can obtain the subsequent code of the source code to be complemented, and improves the compiling efficiency of the software code.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flow chart of a method for completing a code according to an embodiment of the present invention;
FIG. 2 is a functional block diagram of a code completion apparatus according to an embodiment of the present invention;
FIG. 3 is a block diagram of a computer device for implementing code completion according to a preferred embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
Fig. 1 is a flowchart of a code completion method according to an embodiment of the present invention. The code completion method is applied to a computer device and used for performing code completion on more complex codes. The order of the steps in the flow chart may be changed and some steps may be omitted according to different needs.
As shown in fig. 1, the code completion method includes:
and S11, acquiring a plurality of training source codes.
In this embodiment, the plurality of training source codes may be acquired from a pre-established source code library. Alternatively, source code input by a user may be received, and the received source code may be used as the training source code.
In order to ensure the effectiveness of the training source codes, after a plurality of training source codes are acquired, whether the sentences of each acquired training source code are missing or not can be judged, and if the sentences of the training source codes are missing, the training source codes are discarded.
Judging whether the obtained sentences of each training source code have the deficiency or not can include:
judging whether the training source code only has a start statement and an end statement;
and if the training source code only has a start statement and an end statement, determining that the statement of the training source code has a deficiency.
Whether the training source code only has a start statement and an end statement can be judged according to preset keywords. For example, the keyword of the starting statement may be public class, the keyword of the ending statement may be system.out.println, and it may be determined whether the training source code only includes the keyword public class and the system.out.println, and if the training source code only includes the keyword public class and the system.out.println, it is determined that the training source code only has the starting statement and the ending statement, and the statement of the training source code has a deficiency.
And S12, generating abstract syntax trees of the training source codes, and generating a parent abstract syntax tree and a child abstract syntax tree of the training source codes according to the abstract syntax trees.
An abstract syntax tree is a tree-like representation of the syntax structure of the source code.
Preferably, generating the abstract syntax tree of the plurality of training source codes comprises:
performing lexical analysis on each training source code, and converting the training source code into an array consisting of lexical units;
performing syntactic analysis on the training source code according to the array consisting of the lexical units, and determining whether the grammar of the training source code is correct;
and if the grammar of the training source code is correct, generating an abstract grammar tree of the training source code according to the array consisting of the lexical units.
In this embodiment, each sentence of the training source code may be lexically analyzed by the lexical analyzer, and each sentence of the training source code may be converted into an array composed of lexical units.
And the lexical analyzer scans each sentence of the training source code and performs word segmentation while scanning to obtain a lexical unit of each sentence of the training source code. The lexical units are basic constituent units of the sentences, and can be keywords, variable names, operators, constants and the like.
For example, the obtained training source code is "const a ═ 1, const b ═ a + 1; "the lexical analyzer scans the first sentence" const a ═ 1, "first scan" const ", generate a lexical unit to indicate" const "as the keyword; scanning to 'a', and generating a lexical unit which indicates that 'a' is a variable name; then scanning to generate a lexical unit which represents that the word is an operator; then scanning to a constant value of 1, and generating a lexical unit to indicate that 1 is a constant value; finally, the punctuation mark is scanned to generate a lexical unit representation and the punctuation mark is generated. The lexical analyzer combines the lexical units of the sentence "const a ═ 1" into an array { const a ═ 1 }. Similarly, the lexical subsystem sets the statement "const b ═ a + 1; "convert to an array consisting of lexical units { const b ═ a + 1; }.
The grammar analyzer analyzes the grammar of the training source code to determine whether the grammar of the training source code is correct, and if the grammar of the training source code is correct, the abstract grammar tree of the training source code is generated.
If the grammar of the training source code is wrong, the error information can be fed back to the user, the modified training source code returned by the user is received, the lexical analysis is carried out on the modified training source code, the modified training source code is converted into an array consisting of lexical units, and the abstract grammar tree is generated according to the array consisting of the lexical units of the modified training source code. For example, the parser pairs the training source code "const a ═ 1, const b ═ a + 1; "analyze, determine the syntax error of the first sentence" const a ═ 1 "of the training source code, and the end of the sentence should be a semicolon instead of a comma. And the grammar analyzer feeds the error information back to the user and receives the modified training source code fed back by the user. For example, receiving a modified training source code "const a ═ 1 returned by the user; const b is a + 1; ". The lexical analyzer performs lexical analysis on the modified training source code to obtain an array of the modified training source code, which is composed of lexical units, for example, to obtain { const a ═ 1; { const b ═ a + 1; and the syntax analyzer generates the abstract syntax tree according to the array of the modified training source codes, which is composed of lexical units.
An abstract syntax tree is a tree-like representation of the syntax structure of the source code. When the abstract syntax tree of the training source code is generated according to the array formed by the lexical units, the root node and the child nodes of the abstract syntax tree are determined, and the root node and the child nodes are constructed into the abstract syntax tree. For example, for a statement "const b ═ a +1 in source code from training; the "root node is" const b ", the child nodes are" a "and" 1 ", and the parser constructs the root node and the child nodes as an abstract syntax tree.
In this embodiment, generating the parent abstract syntax tree and the child abstract syntax tree according to the abstract syntax tree includes: traversing all nodes of the abstract syntax tree, and determining parent nodes and child nodes of the abstract syntax tree and the levels of the parent nodes and the child nodes in the abstract syntax tree; and generating a parent abstract syntax tree and a child abstract syntax tree according to the hierarchy of the parent node and the child node in the abstract syntax tree. The traversal method of the abstract syntax tree may include a forward-order traversal, a middle-order traversal, and a backward-order traversal.
For example, for an abstract syntax tree { constb ═ a +1}, a parent node of the abstract syntax tree is { ═ according to a preamble traversal method, a level of the abstract syntax tree where the parent node { ═ is located is a first level, child nodes of the parent node { } are { constb } and { + }, and child nodes { constb } and { + }arelocated is a second level, and the parent node { }, child nodes { constb } and { + } and parent node { }, { constb } and { + } of the abstract syntax tree { constb { + a +1} are located, so that the abstract syntax tree is { constb + }. For the child node { a, 1}, { + } is a parent node, the level of the abstract syntax tree where the child node { a, 1} is located is a third level, and the level of the abstract syntax tree where the child node { a, 1} is located is obtained as { a +1} according to the level of the abstract syntax tree where the parent node { + }, the child node { a, 1} and the child node { a, 1} are located.
And S13, generating a parent control flow diagram of the plurality of training source codes according to the parent abstract syntax tree of the plurality of training source codes, and generating a child control flow diagram of the plurality of training source codes according to the child abstract syntax tree of the plurality of training source codes.
The control flow graph is a graph with basic blocks as nodes and jump information as edges. The parent control flow graph is a control flow graph generated from a parent abstract syntax tree of the training source code, and the child control flow graph is a control flow graph generated from a child abstract syntax tree of the training source code. In this embodiment, a control flow graph with a direction is generated according to the abstract syntax tree.
Preferably, generating a parent control flow graph of the plurality of training source codes according to the parent abstract syntax tree of the plurality of training source codes, and generating a child control flow graph of the plurality of training source codes according to the child abstract syntax tree of the plurality of training source codes comprises:
generating a three-address instruction according to the father abstract syntax tree/the son abstract syntax tree;
constructing the three address instruction as a basic block;
constructing the basic block as the parent control flow graph/the child control flow graph.
An instruction consists of two parts, an opcode (i.e., operand) and an address code (operand). A three address instruction is an instruction that includes three operands (i.e., three address codes), including one destination operand and two source operands. For example, a three address instruction is z ═ x or y, z is the destination operand, and x and y are the source operands.
The three-address instruction belongs to a linear structure, is an intermediate representation form of an abstract syntax tree generation control flow graph, converts the abstract syntax tree of the tree structure into the three-address instruction of the linear structure, and aims to reduce the difficulty of generating the control flow graph according to the abstract syntax tree of the tree structure.
The abstract syntax tree can be traversed to obtain a father node and a child node of the abstract syntax tree, the father node is used as a destination operand, the child node is used as a source operand, and a three-address instruction is generated according to the destination operand and the source operand.
For example, the parent node of the abstract syntax tree { constb { (a +1} } is { }, and the child nodes are { constb } and { + }. For the child node { a, 1}, { + } is the parent node of the child node { a, 1}, and the three-address instruction const b { + a +1 is generated according to the parent node { + } of the abstract syntax tree { constb { + a +1} } and the child nodes { const b } and { + }.
A basic block is a sequence of statements in the source code from one entry statement to the next (without the next entry statement). The basic block does not contain a jump instruction.
When generating basic blocks, first instructions of the basic blocks may be determined, each first instruction corresponding to one basic block.
The basic block and the jump between the basic blocks form a directed edge. And forming a control flow graph by taking the basic block as a node and the jump information as an edge.
And S14, constructing a Bayesian prediction model according to the parent control flow graph and the child control flow graph of the training source codes.
Preferably, the constructing a bayesian prediction model from the parent control flow graph and the child control flow graph of the plurality of training source codes comprises:
extracting grammatical structure characteristics of a parent control flow graph of the training source codes;
counting the probability of the child control flow graph appearing in the parent control flow graph;
and constructing the Bayesian prediction model according to the probability of the child control flow graph appearing in the parent control flow graph.
The syntactic structure features of the parent control flow graph represent specific syntactic structures in the training source code.
For example, the obtained training source code is as follows:
While(bookSc.hasNextLine()){
String bookInfo;
If(Cond)continue;
String authorInfo=getAuthorInfo(bookInfo);}
the grammatical structure characteristic of the parent control flow graph of the training source code comprises a while loop structure.
In this embodiment, the syntactic structure characteristic of the parent control flow graph is represented by g, and the probability of the child control flow graph is represented by c (g). Specifically, according to the grammar structure feature g of the father control flow graph and the probability of the appearance of the child control flow graph C (g), a Bayesian prediction model is constructed: f: g → C (g). Under the condition of the grammatical structure characteristics g (g1, g2, …, gn) of the parent control flow graph, C (g) (C1(g), C2(g), …, Cn (g)) with the highest probability of meeting the maxP (Ca (g) | g) is the optimal child control flow graph.
For example, the abstract syntax tree may be a while loop with if-continuity, and specifically, when the syntax structural feature is a while loop statement of a parent control flow graph, the probability that a child control flow graph is an if-continuity statement is the largest, and the if-continuity statement of the child control flow graph is determined to be the best child control flow graph.
Specifically, the principle of the bayesian prediction model is as follows:
pr (c (g) | Ctxt) ═ Pr ((g, N +, E +) | Ctxt)); wherein, c (g) represents that a child control flow graph is generated according to the grammatical structure feature g of the parent control flow graph, g represents the grammatical structure feature of the parent control flow graph which may affect the generation of the child control flow graph c (g), N + represents a newly added node, and E + represents a newly added edge. According to the Bayesian formula: p (a/B) ═ P (B/a) P (a)) ]/P (B), resulting in Pr (c) (g) | g1, g2, …, gn) ═ Pr (c (g) | g1, g2, …, gn)/Pr (g1, g2, …, gn) | Pr (c (g) | g1, g2, …, gn) ═ Pr (g1, g2, …, gn | c) (g))) Pr (c (g)); wherein, Pr (c (g) | g1, g2, …, gn) represents the probability that all c (g), g1, g2, …, gn appear at the same time, and Pr (c (g)) represents the probability that the sub-control flow graph c (g) appears.
And S15, acquiring the source code to be complemented.
In this embodiment, a source code to be complemented, which is input by a user, may be received.
The source code to be complemented can be obtained according to the mouse operation of the user. For example, whether to enter a code editing interface can be detected; if entering a code editing interface, acquiring a cursor position in the code editing interface; and determining the source code to be completed according to the cursor position. For example, a code segment corresponding to the position of the cursor is determined as the source code to be complemented.
For example, the source code to be complemented is obtained as:
While(bookSc.hasNextLine()){
String bookInfo;
();
String authorInfo=getAuthorInfo(bookInfo);}
wherein, "(); "indicates missing code.
And S16, inputting the source code to be complemented into the Bayes prediction model for code complementation, and obtaining the subsequent code of the source code to be complemented.
In this embodiment, the bayesian prediction model may predict missing codes according to the source code to be complemented.
For example, the obtained source code to be complemented may be the following source code:
While(bookSc.hasNextLine()){
String bookInfo;
();
String authorInfo=getAuthorInfo(bookInfo);}
predicting to obtain a missing code of' if (Cond) continue according to the Bayesian prediction model; "sentence.
The code completion method of the invention obtains a plurality of training source codes; generating abstract syntax trees of the training source codes, and generating a parent abstract syntax tree and a child abstract syntax tree of the training source codes according to the abstract syntax trees; generating a parent control flow graph of the plurality of training source codes according to the parent abstract syntax tree of the plurality of training source codes, and generating a child control flow graph of the plurality of training source codes according to the child abstract syntax tree of the plurality of training source codes; constructing a Bayesian prediction model according to the parent control flow diagram and the child control flow diagram of the training source codes; acquiring a source code to be complemented; and inputting the source code to be complemented into the Bayesian prediction model for code complementation to obtain a subsequent code of the source code to be complemented. The method can directly obtain the subsequent code of the source code to be complemented, and improves the compiling efficiency of the software code.
As shown in fig. 2, fig. 2 is a functional block diagram of a code completion apparatus according to an embodiment of the present invention. The code completing device 20 includes a first obtaining module 210, a first generating module 220, a second generating module 230, a constructing module 240, a second obtaining module 250 and a completing module 260. The module referred to in the present invention refers to a series of computer program segments capable of being executed by a processor of a computer device and performing a fixed function, which are stored in a memory of the computer device.
The first obtaining module 210 is configured to obtain a plurality of training source codes.
In this embodiment, the plurality of training source codes may be acquired from a pre-established source code library. Alternatively, source code input by a user may be received, and the received source code may be used as the training source code.
In order to ensure the validity of the training source code, the code completing device 20 may include a screening model (not shown in fig. 2) for determining whether a sentence of each acquired training source code is missing, and if the sentence of the training source code is missing, discarding the training source code.
Judging whether the obtained sentences of each training source code have the deficiency or not can include:
judging whether the training source code only has a start statement and an end statement;
and if the training source code only has a start statement and an end statement, determining that the statement of the training source code has a deficiency.
Whether the training source code only has a start statement and an end statement can be judged according to preset keywords. For example, the keyword of the starting statement may be public class, the keyword of the ending statement may be system.out.println, and it may be determined whether the training source code only includes the keyword public class and the system.out.println, and if the training source code only includes the keyword public class and the system.out.println, it is determined that the training source code only has the starting statement and the ending statement, and the statement of the training source code has a deficiency.
The first generating module 220 is configured to generate an abstract syntax tree of the plurality of training source codes, and generate a parent abstract syntax tree and a child abstract syntax tree of the plurality of training source codes according to the abstract syntax tree.
An abstract syntax tree is a tree-like representation of the syntax structure of the source code.
Preferably, the first generating module generates an abstract syntax tree of the plurality of training source codes, in particular for:
performing lexical analysis on each training source code, and converting the training source code into an array consisting of lexical units;
performing syntactic analysis on the training source code according to the array consisting of the lexical units, and determining whether the grammar of the training source code is correct;
and if the grammar of the training source code is correct, generating an abstract grammar tree of the training source code according to the array consisting of the lexical units.
In this embodiment, each sentence of the training source code may be lexically analyzed by the lexical analyzer, and each sentence of the training source code may be converted into an array composed of lexical units.
And the lexical analyzer scans each sentence of the training source code and performs word segmentation while scanning to obtain a lexical unit of each sentence of the training source code. The lexical units are basic constituent units of the sentences, and can be keywords, variable names, operators, constants and the like.
For example, the obtained training source code is "const a ═ 1, const b ═ a + 1; "the lexical analyzer scans the first sentence" const a ═ 1, "first scan" const ", generate a lexical unit to indicate" const "as the keyword; scanning to 'a', and generating a lexical unit which indicates that 'a' is a variable name; then scanning to generate a lexical unit which represents that the word is an operator; then scanning to a constant value of 1, and generating a lexical unit to indicate that 1 is a constant value; finally, the punctuation mark is scanned to generate a lexical unit representation and the punctuation mark is generated. The lexical analyzer combines the lexical units of the sentence "const a ═ 1" into an array { const a ═ 1 }. Similarly, the lexical subsystem sets the statement "const b ═ a + 1; "convert to an array consisting of lexical units { const b ═ a + 1; }.
The grammar analyzer analyzes the grammar of the training source code to determine whether the grammar of the training source code is correct, and if the grammar of the training source code is correct, the abstract grammar tree of the training source code is generated.
If the grammar of the training source code is wrong, the error information can be fed back to the user, the modified training source code returned by the user is received, the lexical analysis is carried out on the modified training source code, the modified training source code is converted into an array consisting of lexical units, and the abstract grammar tree is generated according to the array consisting of the lexical units of the modified training source code. For example, the parser pairs the training source code "const a ═ 1, const b ═ a + 1; "analyze, determine the syntax error of the first sentence" const a ═ 1 "of the training source code, and the end of the sentence should be a semicolon instead of a comma. And the grammar analyzer feeds the error information back to the user and receives the modified training source code fed back by the user. For example, receiving a modified training source code "const a ═ 1 returned by the user; const b is a + 1; ". The lexical analyzer performs lexical analysis on the modified training source code to obtain an array of the modified training source code, which is composed of lexical units, for example, to obtain { const a ═ 1; { const b ═ a + 1; and the syntax analyzer generates the abstract syntax tree according to the array of the modified training source codes, which is composed of lexical units.
An abstract syntax tree is a tree-like representation of the syntax structure of the source code. When the abstract syntax tree of the training source code is generated according to the array formed by the lexical units, the root node and the child nodes of the abstract syntax tree are determined, and the root node and the child nodes are constructed into the abstract syntax tree. For example, for a statement "const b ═ a +1 in source code from training; the "root node is" const b ", the child nodes are" a "and" 1 ", and the parser constructs the root node and the child nodes as an abstract syntax tree.
In this embodiment, generating the parent abstract syntax tree and the child abstract syntax tree according to the abstract syntax tree includes: traversing all nodes of the abstract syntax tree, and determining parent nodes and child nodes of the abstract syntax tree and the levels of the parent nodes and the child nodes in the abstract syntax tree; and generating a parent abstract syntax tree and a child abstract syntax tree according to the hierarchy of the parent node and the child node in the abstract syntax tree. The traversal method of the abstract syntax tree may include a forward-order traversal, a middle-order traversal, and a backward-order traversal. Forward traversal, middle traversal, and backward traversal
For example, for an abstract syntax tree { constb ═ a +1}, a parent node of the abstract syntax tree is { ═ according to a preamble traversal method, a level of the abstract syntax tree where the parent node { ═ is located is a first level, child nodes of the parent node { } are { constb } and { + }, and child nodes { constb } and { + }arelocated is a second level, and the parent node { }, child nodes { constb } and { + } and parent node { }, { constb } and { + } of the abstract syntax tree { constb { + a +1} are located, so that the abstract syntax tree is { constb + }. For the child node { a, 1}, { + } is a parent node, the level of the abstract syntax tree where the child node { a, 1} is located is a third level, and the level of the abstract syntax tree where the child node { a, 1} is located is obtained as { a +1} according to the level of the abstract syntax tree where the parent node { + }, the child node { a, 1} and the child node { a, 1} are located.
The second generating module 230 is configured to generate a parent control flow graph of the plurality of training source codes according to the parent abstract syntax tree of the plurality of training source codes, and generate a child control flow graph of the plurality of training source codes according to a child abstract syntax tree of the plurality of training source codes.
The control flow graph is a graph with basic blocks as nodes and jump information as edges. The parent control flow graph is a control flow graph generated from a parent abstract syntax tree of the training source code, and the child control flow graph is a control flow graph generated from a child abstract syntax tree of the training source code. In this embodiment, a control flow graph with a direction is generated according to the abstract syntax tree.
Preferably, generating a parent control flow graph of the plurality of training source codes according to the parent abstract syntax tree of the plurality of training source codes, and generating a child control flow graph of the plurality of training source codes according to the child abstract syntax tree of the plurality of training source codes comprises:
generating a three-address instruction according to the father abstract syntax tree/the son abstract syntax tree;
constructing the three address instruction as a basic block;
constructing the basic block as the parent control flow graph/the child control flow graph.
An instruction consists of two parts, an opcode (i.e., operand) and an address code (operand). A three address instruction is an instruction that includes three operands (i.e., three address codes), including one destination operand and two source operands. For example, a three address instruction is z ═ x or y, z is the destination operand, and x and y are the source operands.
The three-address instruction belongs to a linear structure, is an intermediate representation form of an abstract syntax tree generation control flow graph, converts the abstract syntax tree of the tree structure into the three-address instruction of the linear structure, and aims to reduce the difficulty of generating the control flow graph according to the abstract syntax tree of the tree structure.
The abstract syntax tree can be traversed to obtain a father node and a child node of the abstract syntax tree, the father node is used as a destination operand, the child node is used as a source operand, and a three-address instruction is generated according to the destination operand and the source operand.
For example, the parent node of the abstract syntax tree { constb { (a +1} } is { }, and the child nodes are { constb } and { + }. For the child node { a, 1}, { + } is the parent node of the child node { a, 1}, and the three-address instruction const b { + a +1 is generated according to the parent node { + } of the abstract syntax tree { constb { + a +1} } and the child nodes { const b } and { + }.
A basic block is a sequence of statements in the source code from one entry statement to the next (without the next entry statement). The basic block does not contain a jump instruction.
When generating basic blocks, first instructions of the basic blocks may be determined, each first instruction corresponding to one basic block.
The basic block and the jump between the basic blocks form a directed edge. And forming a control flow graph by taking the basic block as a node and the jump information as an edge.
The building module 240 is configured to build a bayesian prediction model according to the parent control flow graph and the child control flow graph of the plurality of training source codes.
Preferably, the building module builds a bayesian prediction model according to the parent control flow graph and the child control flow graph of the plurality of training source codes, and is specifically configured to:
extracting grammatical structure characteristics of a parent control flow graph of the training source codes;
counting the probability of the child control flow graph appearing in the parent control flow graph;
and constructing the Bayesian prediction model according to the probability of the child control flow graph appearing in the parent control flow graph.
The syntactic structure features of the parent control flow graph represent specific syntactic structures in the training source code.
For example, the obtained training source code is as follows:
While(bookSc.hasNextLine()){
String bookInfo;
If(Cond)continue;
String authorInfo=getAuthorInfo(bookInfo);}
the grammatical structure characteristic of the parent control flow graph of the training source code comprises a while loop structure.
In this embodiment, the syntactic structure characteristic of the parent control flow graph is represented by g, and the probability of the child control flow graph is represented by c (g). Specifically, according to the grammar structure feature g of the father control flow graph and the probability of the appearance of the child control flow graph C (g), a Bayesian prediction model is constructed: f: g → C (g). Under the condition of the grammatical structure characteristics g (g1, g2, …, gn) of the parent control flow graph, C (g) (C1(g), C2(g), …, Cn (g)) with the highest probability of meeting the maxP (Ca (g) | g) is the optimal child control flow graph.
For example, the abstract syntax tree may be a while loop with if-continuity, and specifically, when the syntax structural feature is a while loop statement of a parent control flow graph, the probability that a child control flow graph is an if-continuity statement is the largest, and the if-continuity statement of the child control flow graph is determined to be the best child control flow graph.
Specifically, the principle of the bayesian prediction model is as follows:
pr (c (g) | Ctxt) ═ Pr ((g, N +, E +) | Ctxt)); wherein, c (g) represents that a child control flow graph is generated according to the grammatical structure feature g of the parent control flow graph, g represents the grammatical structure feature of the parent control flow graph which may affect the generation of the child control flow graph c (g), N + represents a newly added node, and E + represents a newly added edge. According to the Bayesian formula: p (a/B) ═ P (B/a) P (a)) ]/P (B), resulting in Pr (c) (g) | g1, g2, …, gn) ═ Pr (c (g) | g1, g2, …, gn)/Pr (g1, g2, …, gn) | Pr (c (g) | g1, g2, …, gn) ═ Pr (g1, g2, …, gn | c) (g))) Pr (c (g)); wherein, Pr (c (g) | g1, g2, …, gn) represents the probability that all c (g), g1, g2, …, gn appear at the same time, and Pr (c (g)) represents the probability that the sub-control flow graph c (g) appears.
The second obtaining module 250 is configured to obtain a source code to be complemented.
In this embodiment, a source code to be complemented, which is input by a user, may be received.
The source code to be complemented can be obtained according to the mouse operation of the user. For example, whether to enter a code editing interface can be detected; if entering a code editing interface, acquiring a cursor position in the code editing interface; and determining the source code to be completed according to the cursor position. For example, a code segment corresponding to the position of the cursor is determined as the source code to be complemented.
For example, the source code to be complemented is obtained as:
While(bookSc.hasNextLine()){
String bookInfo;
();
String authorInfo=getAuthorInfo(bookInfo);}
wherein, "(); "indicates missing code.
The completion module 260 is configured to input the source code to be completed to the bayesian prediction model for code completion, so as to obtain a subsequent code of the source code to be completed.
In this embodiment, the bayesian prediction model may predict missing codes according to the source code to be complemented.
For example, the obtained source code to be complemented may be the following source code:
While(bookSc.hasNextLine()){
String bookInfo;
();
String authorInfo=getAuthorInfo(bookInfo);}
predicting to obtain a missing code of' if (Cond) continue according to the Bayesian prediction model; "sentence.
The code completion device 20 provided by the invention obtains a plurality of training source codes; generating abstract syntax trees of the training source codes, and generating a parent abstract syntax tree and a child abstract syntax tree of the training source codes according to the abstract syntax trees; generating a parent control flow graph of the plurality of training source codes according to the parent abstract syntax tree of the plurality of training source codes, and generating a child control flow graph of the plurality of training source codes according to the child abstract syntax tree of the plurality of training source codes; constructing a Bayesian prediction model according to the parent control flow diagram and the child control flow diagram of the training source codes; acquiring a source code to be complemented; and inputting the source code to be complemented into the Bayesian prediction model for code complementation to obtain a subsequent code of the source code to be complemented. The code completion device 20 can obtain the subsequent codes of the source codes to be completed, and the writing sales volume of the software codes is increased.
The integrated unit implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a computer readable storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention.
Fig. 3 is a schematic structural diagram of a computer device 3 according to a preferred embodiment of the present invention for implementing a code completion display method. In the present embodiment, the computer device 3 comprises at least one transmitting device 31, at least one memory 32, at least one processor 33, at least one receiving device 34 and at least one communication bus. Wherein the communication bus is used for realizing connection communication among the components.
The computer device 3 is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and its hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like. The computer arrangement 3 may also comprise network equipment and/or user equipment. Wherein the network device includes, but is not limited to, a single network server, a server group consisting of a plurality of network servers, or a Cloud Computing (Cloud Computing) based Cloud consisting of a large number of hosts or network servers, wherein Cloud Computing is one of distributed Computing, a super virtual computer consisting of a collection of loosely coupled computers.
The computer device 3 may be, but is not limited to, any electronic product that can perform human-computer interaction with a user through a keyboard, a touch pad, or a voice control device, for example, a tablet computer, a smart phone, a monitoring device, and other terminals.
The Network where the computer device 3 is located includes, but is not limited to, the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
The receiving device 34 and the transmitting device 31 may be wired transmitting ports, or may be wireless devices, for example, including antenna devices, for performing data communication with other devices.
The memory 32 is used to store program code. The memory 32 may be a memory bank, a TF Card (Trans-flash Card), a smart media Card (smart media Card), a secure digital Card (secure digital Card), a flash memory Card (flash Card), or other storage devices.
The processor 33 may comprise one or more microprocessors, digital processors. The processor 33 may call program code stored in the memory 32 to perform the associated functions. For example, the various modules illustrated in fig. 2 are program code stored in the memory 32 and executed by the processor 33 to implement a code completion display method. The processor 33 is also called a Central Processing Unit (CPU), and is an ultra-large scale integrated circuit, which is an operation Core (Core) and a Control Core (Control Unit).
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A method of code completion, the method comprising:
acquiring a plurality of training source codes;
generating abstract syntax trees of the training source codes, and generating a parent abstract syntax tree and a child abstract syntax tree of the training source codes according to the abstract syntax trees;
generating a parent control flow graph of the plurality of training source codes according to the parent abstract syntax tree of the plurality of training source codes, and generating a child control flow graph of the plurality of training source codes according to the child abstract syntax tree of the plurality of training source codes;
constructing a Bayesian prediction model according to the parent control flow diagram and the child control flow diagram of the training source codes;
acquiring a source code to be complemented;
and inputting the source code to be complemented into the Bayesian prediction model for code complementation to obtain a subsequent code of the source code to be complemented.
2. The method of claim 1, wherein prior to the generating the abstract syntax tree for the plurality of training source codes, the method further comprises:
judging whether the sentence of each training source code in the plurality of training source codes is missing;
and if the sentence of the training source code is missing, discarding the training source code.
3. The method of claim 1, wherein the generating the abstract syntax tree for the plurality of training source codes comprises:
performing lexical analysis on each training source code, and converting the training source code into an array consisting of lexical units;
performing syntactic analysis on the training source code according to the array consisting of the lexical units, and determining whether the grammar of the training source code is correct;
and if the grammar of the training source code is correct, generating an abstract grammar tree of the training source code according to the array consisting of the lexical units.
4. The method of claim 3, wherein the lexical analysis is performed on each training source code, and wherein converting the training source code into an array of lexical units comprises:
and carrying out lexical analysis on each sentence of the training source code through a lexical analyzer, and converting each sentence of the training source code into an array consisting of lexical units.
5. The method of claim 1, wherein generating a parent abstract syntax tree and a child abstract syntax tree from the abstract syntax trees comprises:
traversing all nodes of the abstract syntax tree, and determining parent nodes and child nodes of the abstract syntax tree and the levels of the parent nodes and the child nodes in the abstract syntax tree;
and generating the parent abstract syntax tree and the child abstract syntax tree according to the hierarchy of the parent node and the child node in the abstract syntax tree.
6. The method of claim 1, wherein the generating the parent control flow graph of the plurality of training source codes from the parent abstract syntax tree of the plurality of training source codes and the generating the child control flow graph of the plurality of training source codes from the child abstract syntax tree of the plurality of training source codes comprises:
generating a three-address instruction according to the father abstract syntax tree/the son abstract syntax tree;
constructing a basic block according to the three-address instruction;
and constructing the parent abstract syntax tree/the child control flow graph according to the basic block.
7. The method of claim 1, wherein constructing a bayesian prediction model from a parent control flow graph and a child control flow graph of the plurality of training source code comprises:
extracting grammatical structure characteristics of a parent control flow graph of the training source codes;
counting the probability of the child control flow graph appearing in the parent control flow graph;
and constructing the Bayesian prediction model according to the probability of the child control flow graph appearing in the parent control flow graph.
8. A code completion apparatus, the apparatus comprising:
the first acquisition module is used for acquiring a plurality of training source codes;
the first generation module is used for generating abstract syntax trees of the training source codes and generating a parent abstract syntax tree and a child abstract syntax tree of the training source codes according to the abstract syntax trees;
a second generating module, configured to generate a parent control flow graph of the plurality of training source codes according to a parent abstract syntax tree of the plurality of training source codes, and generate a child control flow graph of the plurality of training source codes according to a child abstract syntax tree of the plurality of training source codes;
the building module is used for building a Bayesian prediction model according to the parent control flow graph and the child control flow graph of the training source codes;
the second acquisition module is used for acquiring the source code to be complemented;
and the completion module is used for inputting the source code to be completed into the Bayesian prediction model to complete the code so as to obtain a subsequent code of the source code to be completed.
9. A computer apparatus comprising a memory for storing at least one instruction and a processor for executing the at least one instruction to implement the code completion method of any one of claims 1 to 7.
10. A computer-readable storage medium having stored thereon computer instructions, characterized in that: the computer instructions, when executed by a processor, implement a code completion method as recited in any of claims 1 to 7.
CN201910780750.8A 2019-08-22 2019-08-22 Code completion method, device, computer device and storage medium Pending CN110688121A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910780750.8A CN110688121A (en) 2019-08-22 2019-08-22 Code completion method, device, computer device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910780750.8A CN110688121A (en) 2019-08-22 2019-08-22 Code completion method, device, computer device and storage medium

Publications (1)

Publication Number Publication Date
CN110688121A true CN110688121A (en) 2020-01-14

Family

ID=69108329

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910780750.8A Pending CN110688121A (en) 2019-08-22 2019-08-22 Code completion method, device, computer device and storage medium

Country Status (1)

Country Link
CN (1) CN110688121A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112965695A (en) * 2021-03-12 2021-06-15 中国平安财产保险股份有限公司 Front-end code access detection method, device, equipment and storage medium
CN113064586A (en) * 2021-05-12 2021-07-02 南京大学 Code completion method based on abstract syntax tree augmented graph model
CN113076089A (en) * 2021-04-15 2021-07-06 南京大学 API completion method based on object type
WO2022126909A1 (en) * 2020-12-18 2022-06-23 平安科技(深圳)有限公司 Code completion method and apparatus, and related device
CN114693275A (en) * 2022-04-18 2022-07-01 浪潮通用软件有限公司 Dynamic execution method for service system function
WO2024027279A1 (en) * 2022-07-30 2024-02-08 华为技术有限公司 Code completion method and apparatus, and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140359572A1 (en) * 2013-06-04 2014-12-04 Microsoft Corporation System and method for providing code completion features for code modules
CN108388425A (en) * 2018-03-20 2018-08-10 北京大学 A method of based on LSTM auto-complete codes
CN109582352A (en) * 2018-10-19 2019-04-05 北京硅心科技有限公司 A kind of code completion method and system based on double AST sequences

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140359572A1 (en) * 2013-06-04 2014-12-04 Microsoft Corporation System and method for providing code completion features for code modules
CN108388425A (en) * 2018-03-20 2018-08-10 北京大学 A method of based on LSTM auto-complete codes
CN109582352A (en) * 2018-10-19 2019-04-05 北京硅心科技有限公司 A kind of code completion method and system based on double AST sequences

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022126909A1 (en) * 2020-12-18 2022-06-23 平安科技(深圳)有限公司 Code completion method and apparatus, and related device
CN112965695A (en) * 2021-03-12 2021-06-15 中国平安财产保险股份有限公司 Front-end code access detection method, device, equipment and storage medium
CN113076089A (en) * 2021-04-15 2021-07-06 南京大学 API completion method based on object type
CN113076089B (en) * 2021-04-15 2023-11-21 南京大学 API (application program interface) completion method based on object type
CN113064586A (en) * 2021-05-12 2021-07-02 南京大学 Code completion method based on abstract syntax tree augmented graph model
CN114693275A (en) * 2022-04-18 2022-07-01 浪潮通用软件有限公司 Dynamic execution method for service system function
WO2024027279A1 (en) * 2022-07-30 2024-02-08 华为技术有限公司 Code completion method and apparatus, and device

Similar Documents

Publication Publication Date Title
CN110688121A (en) Code completion method, device, computer device and storage medium
CN108388425B (en) Method for automatically completing codes based on LSTM
CN110187885B (en) Intermediate code generation method and device for quantum program compiling
CN108717470B (en) Code segment recommendation method with high accuracy
CN111026470B (en) System and method for verification and conversion of input data
EP3679483A1 (en) Pruning engine
CN108563433B (en) Device based on LSTM automatic completion code
KR20180122017A (en) Efficient state machine for real-time data flow programming
WO2018217745A1 (en) Automated dependency analyzer for heterogeneously programmed data processing system
EP3851977A1 (en) Method, apparatus, electronic device, and storage medium for extracting spo triples
CN110929145B (en) Public opinion analysis method, public opinion analysis device, computer device and storage medium
US9740480B1 (en) Apparatus and methodologies for code refactoring
WO2020219182A1 (en) Code completion for languages with hierarchical structures
Nguyen et al. Auto-locating and fix-propagating for HTML validation errors to PHP server-side code
US20220092252A1 (en) Method for generating summary, electronic device and storage medium thereof
EP3465428A1 (en) Sample driven profile guided optimization with precise correlation
CN114625844B (en) Code searching method, device and equipment
CN117113347A (en) Large-scale code data feature extraction method and system
CN113987405A (en) AST-based mathematical expression calculation algorithm
US20150169303A1 (en) Compiler optimization for finite state machines
CN116560666B (en) AI front end unified computing method, device and medium based on multi-level code generation
CN114385148A (en) Method, device, equipment and storage medium for realizing linkage function
CN109032946B (en) Test method and device and computer readable storage medium
CN116400910A (en) Code performance optimization method based on API substitution
CN115454702A (en) Log fault analysis method and device, storage medium and electronic equipment

Legal Events

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