CN115525295A - Automatic code editing method and device, electronic equipment and storage medium - Google Patents

Automatic code editing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115525295A
CN115525295A CN202211293038.3A CN202211293038A CN115525295A CN 115525295 A CN115525295 A CN 115525295A CN 202211293038 A CN202211293038 A CN 202211293038A CN 115525295 A CN115525295 A CN 115525295A
Authority
CN
China
Prior art keywords
code
state
editing
current
conversion
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
CN202211293038.3A
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.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
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 Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202211293038.3A priority Critical patent/CN115525295A/en
Publication of CN115525295A publication Critical patent/CN115525295A/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/44Encoding
    • G06F8/447Target code generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/33Intelligent editors

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The embodiment of the invention discloses a method and a device for automatically editing codes, electronic equipment and a storage medium. The code automatic editing method specifically comprises the following steps: determining a current initial code state of a current code line; acquiring conversion identifiers corresponding to the code conversion sequences in the code conversion sequence list, and determining the code conversion sequences with the conversion identifiers as target code conversion sequences; and automatically editing the current code line according to the target code conversion sequence and the current initial code state. The technical scheme of the embodiment of the invention can automatically edit the codes, thereby improving the working efficiency and accuracy of code editing.

Description

Automatic code editing method and device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a code automatic editing method and device, electronic equipment and a storage medium.
Background
Computer programs are typically generated in a source code language by one or more developers. Code can become very large, involving thousands of lines, or even millions of lines of code.
However, during software development, developers often find themselves with repetitive code edits to add new features, reconstruct or fix bugs. For example, changing a method signature may require changing all calls to the method in the code base, and in addition to being tedious, manually performing these edits is error-prone and time-consuming.
In addition, developers often submit multiple times to complete a repeated code editing task, and in the process of submitting multiple times, due to errors of the developers, the positions of editing applications are mistaken, or the editing applications are applied to certain positions, and the like, so that the error rate of code editing is increased.
Disclosure of Invention
The embodiment of the invention provides a method and a device for automatically editing codes, electronic equipment and a storage medium, which can automatically edit the codes, thereby improving the working efficiency and accuracy of code editing.
According to an aspect of the present invention, there is provided an automatic code editing method, including:
determining a current initial code state of a current code line;
acquiring conversion identifiers corresponding to the code conversion sequences in the code conversion sequence list, and determining the code conversion sequences with the conversion identifiers as target code conversion sequences;
and automatically editing the current code line according to the target code conversion sequence and the current initial code state.
According to another aspect of the present invention, there is provided an automatic code editing apparatus, including:
the code state determining module is used for determining the current initial code state of the current code line;
the code conversion sequence determining module is used for acquiring conversion identifiers corresponding to the code conversion sequences in the code conversion sequence list and determining the code conversion sequences with the conversion identifiers as target code conversion sequences;
and the code automatic editing module is used for automatically editing the codes of the current code line according to the target code conversion sequence and the current initial code state.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform a method of automatically editing code according to any embodiment of the present invention.
According to another aspect of the present invention, there is provided a computer-readable storage medium storing computer instructions for causing a processor to implement the code automatic editing method according to any one of the embodiments of the present invention when the computer instructions are executed.
According to the technical scheme, the current initial code state of the current code line is determined, the conversion identification corresponding to each code conversion sequence in the code conversion sequence list is obtained, the code conversion sequence with the conversion identification as the target conversion identification is determined as the target code conversion sequence, so that the code of the current code line is automatically edited according to the target code conversion sequence and the current initial code state, the problems of low code editing efficiency and high error rate caused by manual code editing in the existing code editing are solved, the code editing can be automatically performed, and the working efficiency and the accuracy of the code editing are improved.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present invention, nor do they necessarily limit the scope of the invention. Other features of the present invention will become apparent from the following description.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart of a method for automatically editing code according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for automatically editing a code according to a second embodiment of the present invention;
fig. 3 is a schematic diagram of a prior art of a method for automatically editing a code according to a third embodiment of the present invention;
fig. 4 is an exemplary flowchart of a code automatic editing method provided by a third embodiment of the present invention;
5A-5L are specific exemplary flowcharts of a code automatic editing method according to a third embodiment of the present invention;
fig. 6 is a schematic diagram of an automatic code editing apparatus according to a fourth embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device implementing a code automatic editing method according to an embodiment of the present invention;
fig. 8 is a diagram illustrating a structure of a computing system according to a fifth embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, 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.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example one
Fig. 1 is a flowchart of an automatic code editing method according to an embodiment of the present invention, where this embodiment is applicable to automatically editing a code to improve the working efficiency and accuracy of code editing, and the method may be executed by an automatic code editing apparatus, and the apparatus may be implemented in a software and/or hardware manner, and may generally be directly integrated in an electronic device that executes the method, where the electronic device may be a terminal device or a server device. Specifically, as shown in fig. 1, the method for automatically editing a code may specifically include the following steps:
and S110, determining the current initial code state of the current code line.
Wherein the current code line can be any line of codes in the code file. It will be appreciated that in a code file, a line in which program code exists may be determined to be a line of code. The current initial code state may be an initial state of a code in a current code line, for example, may be an initial content of the code in the current code line, or may also be an initial format of the code in the current code line, and the like, which is not limited in this embodiment of the present invention.
In embodiments of the present invention, the current initial code state of the current line of code may be determined. It should be noted that, the embodiment of the present invention does not limit a specific manner of determining the current initial code state of the current code line, as long as the current initial code state of the current code line can be determined. For example, the current initial code state of the current code line may be determined by obtaining the code content in the current code line.
S120, obtaining conversion identifiers corresponding to the code conversion sequences in the code conversion sequence list, and determining the code conversion sequences with the conversion identifiers as target code conversion sequences.
Wherein the list of transcoding sequences may be a list consisting of transcoding sequences. The transcoding sequence may be a sequence file determined by a transcoding process resulting from a developer editing a line of code. The conversion identifier may be an identifier corresponding to each transcoding sequence, and may be used to identify whether the transcoding sequence is a repeated conversion. That is, the conversion identifier may be an identifier of a repeated conversion, or may be an identifier of a non-repeated conversion, which is not limited in this embodiment of the present invention. The target translation identity may be a target value of the translation identity. The target transcoding sequence may be one of the transcoding sequences in the list of transcoding sequences. Specifically, the translation identifier of the target transcoding sequence is a target translation identifier.
In the embodiment of the present invention, a conversion identifier corresponding to each code conversion sequence in the code conversion sequence list may be obtained, and the code conversion sequence whose conversion identifier is a target conversion identifier is determined as a target code conversion sequence. It will be appreciated that there may be one or more target transcoding sequences in the list of transcoding sequences. It should be noted that, if there are a plurality of transcoding sequences whose transcoding identifiers are target transcoding identifiers and the plurality of transcoding sequences are transcoded into the same type of transcoding, any one of the plurality of transcoding sequences may be determined as a target transcoding sequence.
It should be noted that fig. 1 is only a schematic diagram of an implementation manner, and step S110 and step S120 do not have a sequential relationship, and may be implemented alternatively, or may be performed synchronously.
And S130, automatically editing the current code line according to the target code conversion sequence and the current initial code state.
In the embodiment of the invention, the current code line can be automatically edited according to the target code conversion sequence and the current initial code state.
Optionally, the editing code to be determined may be determined according to the target code conversion sequence and the current initial code state, the editing code to be determined is displayed to a developer, a selected instruction of the developer to the editing code to be determined is received, the target editing code is determined according to the selected instruction, and the code of the current code line is automatically edited according to the target editing code. It is to be understood that the target transcoding sequence may be one or more. When the target code conversion sequence is multiple, the number of the editing codes to be determined is consistent with the number of the target code conversion sequence. That is, the developer can select one of the multiple codes to be determined and edit the current code line automatically.
According to the technical scheme of the embodiment, the current initial code state of the current code line is determined, the conversion identification corresponding to each code conversion sequence in the code conversion sequence list is obtained, and the code conversion sequence with the conversion identification as the target conversion identification is determined as the target code conversion sequence, so that the code of the current code line is automatically edited according to the target code conversion sequence and the current initial code state, the problems of low code editing efficiency and high error rate caused by manual code editing in the existing code editing are solved, the code editing can be automatically performed, and the working efficiency and the accuracy of the code editing are improved.
Example two
Fig. 2 is a flowchart of a method for automatically editing a code according to a second embodiment of the present invention, which further details the above technical solutions and provides a plurality of specific selectable implementation manners for determining a current initial code state of a current code line, obtaining a conversion identifier corresponding to each code conversion sequence in a code conversion sequence list, and automatically editing a code of the current code line according to the target code conversion sequence and the current initial code state. The solution in this embodiment may be combined with the individual alternatives in one or more of the embodiments described above. As shown in fig. 2, the method may include the steps of:
s210, determining the current initial code state of the current code line under the condition that the state of the current code line is determined to be the code editing state.
The code editing state may be a state of editing the code in the current code line.
In the embodiment of the invention, when the state of the current code line is determined to be the code editing state, the current initial code state of the current code line is determined. That is, when the current line of code enters the code edit state, the current initial code state of the current line of code is determined. It will be appreciated that if the current line of code has not entered the code edit state, then no code editing is required for the current line of code.
S220, according to the historical code editing operation, an editing code line corresponding to the historical code editing operation is determined, and an initial code state, a code conversion rule and an editing code state corresponding to the editing code line are determined.
Wherein, the history code editing operation may be a history operation of editing the code. Illustratively, if the current line of code is line 18 in the code file, the code editing operations on lines 1-17 before the code editing on line 18 may be determined to be historical code editing operations. The edit code line may be a code line of an edit operation at the time of a history code edit operation. The initial code state may be the initial state of the code in the line of compiled code. The code conversion rule may be a conversion rule followed by the code editing operation, and may be, for example, a rule for deleting a certain piece of code, a rule for adding a certain piece of code, or the like, which is not limited in the embodiment of the present invention. The edit code state may be a state of the code after editing the code in the edit code line.
In the embodiment of the invention, the editing code line corresponding to the historical code editing operation is determined according to the historical code editing operation so as to determine the initial code state, the code conversion rule and the editing code state corresponding to the editing code line. It is understood that there may be one or more of the history code editing operations. When there are a plurality of historical code editing operations, a plurality of editing code lines, and initial code states, code conversion rules, and editing code states corresponding to the plurality of editing code lines may be determined.
And S230, determining a code conversion sequence in the code conversion sequence list according to the initial code state, the code conversion rule and the editing code state corresponding to the editing code line.
In the embodiment of the present invention, after the initial code state, the transcoding rule, and the edited code state corresponding to the edited code line are determined, the transcoding sequence in the transcoding sequence list may be further determined according to the initial code state, the transcoding rule, and the edited code state corresponding to the edited code line.
Optionally, after determining a transcoding sequence in the transcoding sequence list according to the initial code state, the transcoding rule, and the edited code state corresponding to the edited code line, the method may further include: determining a first code conversion sequence in a code conversion sequence list, and a first initial code state and a first editing code state corresponding to the first code conversion sequence; determining a second transcoding sequence in the list of transcoding sequences based on the first initial code state; determining a second editing code state corresponding to the second code conversion sequence, and performing first state similarity comparison on the second editing code state and the first editing code state; and determining the conversion identifier of the first code conversion sequence and the second code conversion sequence as the target conversion identifier under the condition that the first state similarity comparison result is the target result.
Wherein the first transcoding sequence may be any one of a list of transcoding sequences. The first initial code state may be an initial code state corresponding to the first transcoding sequence. The first code state may correspond to a first code transition sequence of the first code state. The second transcoded sequence may be another transcoded sequence in the list of transcoded sequences. The second edit code state can be an edit code state corresponding to the second transcoding sequence. The first state similarity comparison may be a comparison of code state similarities between the second editing code state and the first editing code state, for example, a comparison of code content similarities, a comparison of code format similarities, and the like, which is not limited in this embodiment of the present invention. The first state similarity comparison result may be a result obtained by performing code state similarity comparison on the second editing code state and the first editing code state, and may be a similar result or a dissimilar result, for example, which is not limited in this embodiment of the present invention. The target result may be a target value of the code state similarity comparison, and may be a similar result, for example.
Specifically, after determining the code conversion sequence in the code conversion sequence list according to the initial code state, the code conversion rule and the edited code state corresponding to the edited code line, the first code conversion sequence in the code conversion sequence list, and the first initial code state and the first edited code state may be further determined, so as to determine the second code conversion sequence in the code conversion sequence list according to the first initial code state, and determine the second edited code state of the second code conversion sequence, thereby performing the first state similarity comparison between the second edited code state and the first edited code state, and further determining the conversion identifiers of the first code conversion sequence and the second code conversion sequence as the target conversion identifiers when the first state similarity comparison result is the target result.
It is to be understood that in the first state similarity comparison of the second editing code state and the first editing code state, if the code states of the second editing code state and the first editing code state are similar or the same type of code, the first transcoding sequence and the second transcoding sequence may be determined to be repeated conversions.
Optionally, determining a second transcoding sequence in the list of transcoding sequences according to the first initial code state may include: determining an initial code state corresponding to each code conversion sequence in a code conversion sequence list; performing second state similarity comparison on the initial code state corresponding to each code conversion sequence in the code conversion sequence list and the first initial code state; and determining the code conversion sequence with the second state similarity result as the target result as a second code conversion sequence.
The second state similarity comparison may be a state similarity comparison between the initial code state corresponding to each code conversion sequence and the first initial code state. The second state similarity comparison result may be a result of performing state similarity comparison between the initial code state corresponding to each code conversion sequence and the first initial code state.
Specifically, after determining the first transcoding sequence in the list of transcoding sequences and the first initial code state, the initial code state corresponding to each transcoding sequence in the list of transcoding sequences may be further determined, so as to perform a second state similarity comparison between the initial code state corresponding to each transcoding sequence in the list of transcoding sequences and the first initial code state, thereby determining the transcoding sequence whose second state similarity comparison result is the target result as the second transcoding sequence. It will be appreciated that a transcoding sequence corresponding to an initial code state similar to the first initial code state is determined as the second transcoding sequence. I.e. the code states corresponding to the second transcoding sequence are similar to the code states of the first initial code state or are of the same type of code.
S240, obtaining a conversion identifier corresponding to each code conversion sequence in the code conversion sequence list, and determining the code conversion sequence with the conversion identifier as a target code conversion sequence.
S250, determining a target initial code state corresponding to the target code conversion sequence, and performing third state similarity comparison on the target initial code state and the current initial code state.
Wherein the target initial code state may be an initial code state in a target transcoding sequence. The third state similarity comparison may be a comparison of code state similarity for the target initial code state and the current initial code state.
In the embodiment of the present invention, after the code conversion sequence with the conversion identifier as the target conversion identifier is determined as the target code conversion sequence, a target initial code state corresponding to the target code conversion sequence may be further determined, so as to perform a third state similarity comparison between the target initial code state and the current initial code state.
And S260, under the condition that the similarity result of the third state is a target result, automatically editing the current code line according to the target code conversion sequence and the current initial code state.
The third state similarity comparison result may be a result of comparing the state similarities of the target initial code state and the current initial code state.
In the embodiment of the present invention, after performing the third state similarity comparison between the target initial code state and the current initial code state, it may be further determined whether the third state similarity comparison result is the target result, and when the third state similarity comparison result is the target result, the code of the current code line is automatically edited according to the target code conversion sequence and the current initial code state.
Optionally, automatically editing the current code line according to the target code conversion sequence and the current initial code state, which may include: determining a target code conversion rule corresponding to the target code conversion sequence; and determining the current editing code state of the current code line according to the target code conversion rule and the current initial code state.
Wherein the target transcoding rule may be a transcoding rule of a target transcoding sequence. The current code editing state may be a code state obtained by performing code editing on the current code line.
Specifically, when the third state similarity comparison result is the target result, the target code conversion rule corresponding to the target code conversion sequence may be further determined, so as to determine the current editing code state of the current code line according to the target code conversion rule and the current initial code state, thereby implementing automatic code editing of the current code line. Optionally, the current editing code state of the current code line is determined according to the target code conversion rule and the current initial code state, and the current editing code state may be obtained by performing code conversion on the current initial code state according to the target code conversion rule.
According to the technical scheme of the embodiment, when the state of the current code line is determined to be the code editing state, the current initial code state of the current code line is determined, the editing code line corresponding to the historical code editing operation and the initial code state, the code conversion rule and the editing code state corresponding to the editing code line are determined according to the historical code editing operation, the code conversion sequence in the code conversion sequence list is determined according to the initial code state, the code conversion rule and the editing code state corresponding to the editing code line, the conversion identifier corresponding to each code conversion sequence in the code conversion sequence list is obtained, the code conversion sequence with the conversion identifier being the target conversion identifier is determined to be the target code conversion sequence, the target initial code state corresponding to the target code conversion sequence is further determined, third state similarity comparison is conducted on the target initial code state and the current initial code state, therefore when the third state similarity comparison result is the target result, code editing can be automatically conducted on the current code line according to the target code conversion sequence and the current initial code state, the problems that code editing efficiency is low and error caused by manual code editing are solved, and the work rate of code editing can be automatically improved, and the code editing efficiency can be improved.
EXAMPLE III
In order to make those skilled in the art better understand the method for automatically editing code of the present embodiment, a specific example is used for the following description. In the prior art, fig. 3 is a schematic diagram of a method for automatically editing a code according to a third embodiment of the present invention in the prior art, as shown in fig. 3, in the prior art, a common development document browser is usually connected online, a keyword tag to be searched is input, the browser is triggered to perform query, and a developer manually selects a required template to insert into a code according to prompted contents. In addition, the segment list in the template document can be stored off line, and the code can be automatically filled after the keyword is input. However, in the development work, a large number of repeated code editions exist, wherein a part of the part with ultrahigh frequency use is arranged into a template and can be directly utilized, but most of the repeated codes are not referenced by the template. The method for filling repeated codes by inquiring the template on line has small coverage area and is not common enough. And the updating iteration speed of the internet technology is very high, if the development is carried out by storing a fixed template, in order to ensure the real-time performance, the updating needs to be continuously carried out so as to enhance the practicability, and the dynamic maintenance cost is higher. Software development is flexible, actual conditions are changeable, and a template is a fixed mode, so that the practical conditions of applicability are limited, and the flexibility is poor.
Fig. 4 is an exemplary flowchart of a code automatic editing method provided by a third embodiment of the present invention, and as shown in fig. 4, the method may specifically include: when the code has entered a state, a series of code states that the developer is modifying are accessed and a plurality of transformations are identified. In particular, each transition represents a state change from a previous state in the series of states to a subsequent state in the series. Traversing a series of possible executed transformation sequences; in particular, the traversal may be from a first state of a series of states to a last state of the series of states. Identifying a particular transform sequence of the identified transform sequences as having a repeated transform. It will be appreciated that one or more of the determined transition sequences will have repeated transitions. Evaluating the code and providing a selected repeating sequence of transformations if a repeating transformation is determined at a position of the code. If an instruction is received that the developer is to apply the iterative transformation, the computing system automatically performs the iterative transformation for at least one other portion (and possibly multiple other portions) of the code.
Fig. 5A to 5L are specific exemplary flowcharts of a code automatic editing method according to a third embodiment of the present invention, and as shown in fig. 5A to 5E, a developer performs several sub-edits to perform an initial edit. Typically, a run named "generationalationresults" takes more than a certain amount of time to complete and the developer will attempt to time out the code print. Editing is performed as illustrated in fig. 5A, where the developer has navigated to line 17 of the code. In fig. 5B, the developer has added the text "generationationresults. "timeout" generalizationresults. ". In fig. 5C the developer further adds text ". ToString ()" before terminating the semicolon. In fig. 5D, the developer changes the second question mark to a colon. In FIG. 5E the developer replaces "pool" with "string".
Line 18 of the code is another edit of the repeat edit made to line 17. 5F-5H, the developer makes multiple sub-edits in line 18 of the code, similar to the 17 line edits, but now in a different order. As shown in FIG. 5F, the developer first changes "boul" to "string". In fig. 5G, developer adds "coverageresults. "timeout". In fig. 5G, the developer adds the text ". ToString ()" before terminating the semicolon. Note that the variable name "coverageResults" in the 18 rows is larger than the name of the variable "generallizationresults". However, the computing system can still recognize that the edit just performed by the developer in line 18 is a duplicate edit performed on line 17.
In FIG. 5I, the developer navigates to line 19 in order to repeat the editing again. However, the computing system recognizes that the same repeat editing may also be applied to line 19. Thus, as shown in FIG. 5I, the computing system provides a prompt to perform repeat edits. This cue can take two forms. First, visual emphasis (e.g., adding wavy underlines) is applied to line 19, indicating to the developer that context-specific repeated editing can be applied to that line. In addition, the appearance of the edits is displayed to the developer in the form of a window. As shown in fig. 5J, the developer accepts the prompt and the computer system automatically edits the line. The developer may accept the prompt as the code is developed, or may accept it later, since line 19 will remain visually emphasized at all times.
5K-5L, the developer navigates to line 20 with the intent to repeat the edit again. The computing system again recognizes that the same repeat editing may also apply to line 20.
According to the technical scheme, the code automatic editing method has no fixed template sample, can intelligently prompt according to the storage of the repeated operation code state in the development process, and is wide in application scene and high in flexibility; the method can be suitable for most development scenes, is intelligent, and does not need special maintenance cost.
Example four
Fig. 6 is a schematic diagram of an automatic code editing apparatus according to a fourth embodiment of the present invention, and as shown in fig. 6, the apparatus includes: a code state determination module 610, a transcoding sequence determination module 620, and an automatic code editing module 630, wherein:
a code state determining module 610, configured to determine a current initial code state of a current code line;
a code conversion sequence determining module 620, configured to obtain a conversion identifier corresponding to each code conversion sequence in the code conversion sequence list, and determine a code conversion sequence with the conversion identifier as a target code conversion sequence;
and a code automatic editing module 630, configured to perform code automatic editing on the current code line according to the target code conversion sequence and the current initial code state.
According to the technical scheme of the embodiment, the current initial code state of the current code line is determined, the conversion identification corresponding to each code conversion sequence in the code conversion sequence list is obtained, and the code conversion sequence with the conversion identification as the target conversion identification is determined as the target code conversion sequence, so that the code of the current code line is automatically edited according to the target code conversion sequence and the current initial code state, the problems of low code editing efficiency and high error rate caused by manual code editing in the existing code editing are solved, the code editing can be automatically performed, and the working efficiency and the accuracy of the code editing are improved.
Optionally, the code status determining module 610 may be specifically configured to: in the event that the state of the current line of code is determined to be a code edit state, the current initial code state of the current line of code is determined.
Optionally, the transcoding sequence determining module 620 may be specifically configured to: according to the historical code editing operation, determining an editing code line corresponding to the historical code editing operation, and determining an initial code state, a code conversion rule and an editing code state corresponding to the editing code line; and determining a code conversion sequence in the code conversion sequence list according to the initial code state, the code conversion rule and the editing code state corresponding to the editing code line.
Optionally, the transcoding sequence determining module 620 may be further specifically configured to: determining a first code conversion sequence in a code conversion sequence list, and a first initial code state and a first editing code state corresponding to the first code conversion sequence; determining a second transcoding sequence in the list of transcoding sequences based on the first initial code state; determining a second editing code state corresponding to the second code conversion sequence, and performing first state similarity comparison on the second editing code state and the first editing code state; and determining the conversion identifier of the first code conversion sequence and the second code conversion sequence as the target conversion identifier under the condition that the first state similarity comparison result is the target result.
Optionally, the transcoding sequence determining module 620 may be further configured to: determining an initial code state corresponding to each code conversion sequence in a code conversion sequence list; carrying out second state similarity comparison on the initial code state corresponding to each code conversion sequence in the code conversion sequence list and the first initial code state; and determining the code conversion sequence with the second state similarity result as the target result as a second code conversion sequence.
Optionally, the code automatic editing module 630 may be specifically configured to: determining a target initial code state corresponding to the target code conversion sequence, and performing third state similarity comparison on the target initial code state and the current initial code state; and under the condition that the third state similarity comparison result is a target result, automatically editing the code of the current code line according to the target code conversion sequence and the current initial code state.
Optionally, the code automatic editing module 630 may be further specifically configured to: determining a target code conversion rule corresponding to the target code conversion sequence; and determining the current editing code state of the current code line according to the target code conversion rule and the current initial code state.
The code automatic editing device provided by the embodiment of the invention can execute the code automatic editing method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
EXAMPLE five
FIG. 7 illustrates a schematic diagram of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 7, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, and the like, wherein the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data necessary for the operation of the electronic apparatus 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
A number of components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, or the like; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The processor 11 performs the various methods and processes described above, such as a code automatic editing method.
In some embodiments, the code auto-editing method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the code auto-editing method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the code auto-editing method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be performed. A computer program can execute entirely on a machine, partly on a machine, as a stand-alone software package partly on a machine and partly on a remote machine or entirely on a remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service are overcome.
Fig. 8 is a structural example diagram of a computing system according to a fifth embodiment of the present invention, and the code automatic editing method according to any embodiment of the present invention may be implemented by the computing system shown in fig. 8, and as shown in fig. 8, the computing system 800 may be implemented by one or more processors (e.g., hardware processing units) executing computer executable instructions located on one or more computer readable media (e.g., memories), and implement automation of repeated conversion performed by similar code segments by executing stored code states. The code auto-editing method can be performed by one or more processors of computing system 800 (e.g., hardware processing unit 802) executing computer-executable instructions located on one or more computer-readable media (e.g., memory 804). It will be appreciated that the computer system needs to be the same as the computing system used by the developer to write the code. If the computing system is distributed, the processing, memory, and storage capabilities may also be distributed. Computing system 800 may also contain communication channels 808 that allow computing system 800 to communicate with other computing systems over network 810. Computing system 800 may also include a user interface 812 for interacting with a user. User interface 812 may include an output mechanism 812A and an input mechanism 812B. The principles described herein are not limited to the precise output mechanism 812A or input mechanism 812B, as they will depend on the nature of the device. However, output mechanisms 812A may include, for example, speakers, displays, tactile output, holograms, and virtual reality, among others. Input mechanism 812B may include, for example, a microphone, touch screen, hologram, virtual reality, camera, keyboard, mouse or other pointer input, any type of sensor, and so forth.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present invention may be executed in parallel, sequentially, or in different orders, and are not limited herein as long as the desired results of the technical solution of the present invention can be achieved.
The above-described embodiments should not be construed as limiting the scope of the invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. An automatic code editing method, comprising:
determining a current initial code state of a current code line;
acquiring conversion identifiers corresponding to the code conversion sequences in the code conversion sequence list, and determining the code conversion sequences with the conversion identifiers as target code conversion sequences;
and automatically editing the current code line according to the target code conversion sequence and the current initial code state.
2. The method of claim 1, wherein determining the current initial code state of the current line of code comprises:
and under the condition that the state of the current code line is determined to be the code editing state, determining the current initial code state of the current code line.
3. The method of claim 1, further comprising, before obtaining the translation identifier corresponding to each of the translation sequences in the list of translation sequences:
according to historical code editing operation, determining an editing code line corresponding to the historical code editing operation, and determining an initial code state, a code conversion rule and an editing code state corresponding to the editing code line;
and determining a code conversion sequence in the code conversion sequence list according to the initial code state, the code conversion rule and the editing code state corresponding to the editing code line.
4. The method of claim 3, further comprising, after determining a transcoding sequence in the list of transcoding sequences according to the initial code state, the transcoding rules, and the edited code state corresponding to the edited code line:
determining a first code conversion sequence in the code conversion sequence list, and a first initial code state and a first editing code state corresponding to the first code conversion sequence;
determining a second transcoding sequence in the list of transcoding sequences based on the first initial code state;
determining a second editing code state corresponding to the second code conversion sequence, and performing first state similarity comparison on the second editing code state and the first editing code state;
and determining the conversion identifiers of the first code conversion sequence and the second code conversion sequence as target conversion identifiers under the condition that the first state similarity comparison result is a target result.
5. The method of claim 4, wherein determining a second transcoding sequence from the list of transcoding sequences based on the first initial code state comprises:
determining an initial code state corresponding to each code conversion sequence in the code conversion sequence list;
performing second state similarity comparison on the initial code state corresponding to each code conversion sequence in the code conversion sequence list and the first initial code state;
and determining the code conversion sequence with the second state similarity result as the target result as a second code conversion sequence.
6. The method of claim 1, wherein code automatically editing the current line of code according to the target transcoding sequence and the current initial code state comprises:
determining a target initial code state corresponding to the target code conversion sequence, and performing third state similarity comparison on the target initial code state and the current initial code state;
and under the condition that the similarity result of the third state is a target result, automatically editing the current code line according to the target code conversion sequence and the current initial code state.
7. The method of claim 1 or 6, wherein said automatically code editing the current line of code according to the target transcoding sequence and the current initial code state comprises:
determining a target code conversion rule corresponding to the target code conversion sequence;
and determining the current editing code state of the current code line according to the target code conversion rule and the current initial code state.
8. An automatic code editing apparatus, comprising:
the code state determining module is used for determining the current initial code state of the current code line;
the code conversion sequence determining module is used for acquiring conversion identifiers corresponding to the code conversion sequences in the code conversion sequence list and determining the code conversion sequences with the conversion identifiers as target code conversion sequences;
and the code automatic editing module is used for automatically editing the codes of the current code line according to the target code conversion sequence and the current initial code state.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the method of automatic code editing of any one of claims 1-7.
10. A computer-readable storage medium storing computer instructions for causing a processor to implement the code auto-editing method of any one of claims 1-7 when executed.
CN202211293038.3A 2022-10-21 2022-10-21 Automatic code editing method and device, electronic equipment and storage medium Pending CN115525295A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211293038.3A CN115525295A (en) 2022-10-21 2022-10-21 Automatic code editing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211293038.3A CN115525295A (en) 2022-10-21 2022-10-21 Automatic code editing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115525295A true CN115525295A (en) 2022-12-27

Family

ID=84703246

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211293038.3A Pending CN115525295A (en) 2022-10-21 2022-10-21 Automatic code editing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115525295A (en)

Similar Documents

Publication Publication Date Title
CN113342345A (en) Operator fusion method and device of deep learning framework
CN114691148B (en) Model reasoning acceleration method, device, electronic equipment and storage medium
CN114579104A (en) Data analysis scene generation method, device, equipment and storage medium
CN115469849B (en) Service processing system, method, electronic equipment and storage medium
CN116009847A (en) Code generation method, device, electronic equipment and storage medium
CN116483707A (en) Test method, test device, test apparatus, test program, and test program
CN115454971A (en) Data migration method and device, electronic equipment and storage medium
CN116185389A (en) Code generation method and device, electronic equipment and medium
CN114168119B (en) Code file editing method, device, electronic equipment and storage medium
US11947958B2 (en) Method, device, and program product for managing object in software development project
CN115186738A (en) Model training method, device and storage medium
CN113138760B (en) Page generation method and device, electronic equipment and medium
CN115328736A (en) Probe deployment method, device, equipment and storage medium
CN115525295A (en) Automatic code editing method and device, electronic equipment and storage medium
CN117573561B (en) Automatic test system, method, electronic equipment and storage medium
CN116383454B (en) Data query method of graph database, electronic equipment and storage medium
CN113360602B (en) Method, apparatus, device and storage medium for outputting information
CN113495753B (en) Method and device for acquiring label of item, electronic equipment and storage medium
CN117742686A (en) Program source code file generation method and device, electronic equipment and storage medium
CN115686479A (en) File creation method and related device
CN116974940A (en) Interface testing method, device, equipment and storage medium
CN117371416A (en) Project document generation method, device, equipment and storage medium
CN117610580A (en) Instruction identification method and device based on large model, electronic equipment and storage medium
CN118643138A (en) Question and answer method and device based on large language model
CN114510224A (en) Application generation method, device, 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