WO2021003913A1 - Method and device for processing annotation information, computer apparatus, and storage medium - Google Patents

Method and device for processing annotation information, computer apparatus, and storage medium Download PDF

Info

Publication number
WO2021003913A1
WO2021003913A1 PCT/CN2019/116179 CN2019116179W WO2021003913A1 WO 2021003913 A1 WO2021003913 A1 WO 2021003913A1 CN 2019116179 W CN2019116179 W CN 2019116179W WO 2021003913 A1 WO2021003913 A1 WO 2021003913A1
Authority
WO
WIPO (PCT)
Prior art keywords
modification
comment
target
annotation
code
Prior art date
Application number
PCT/CN2019/116179
Other languages
French (fr)
Chinese (zh)
Inventor
高林龙
Original Assignee
平安普惠企业管理有限公司
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 平安普惠企业管理有限公司 filed Critical 平安普惠企业管理有限公司
Publication of WO2021003913A1 publication Critical patent/WO2021003913A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management

Definitions

  • This application relates to the field of code processing, in particular to an annotation information processing method, device, computer equipment and storage medium.
  • the embodiments of the present application provide an annotation information processing method, device, computer equipment, and storage medium, which can reduce the probability of code annotation errors.
  • An annotation information processing method characterized in that it comprises:
  • the target comment information is added to the comment of the target function.
  • An annotation information processing device characterized by comprising:
  • the acquisition module is used to acquire the user's modification record of the project code file
  • the determining module is configured to determine the number of code modification lines of the project code file, and the modification content and modification time corresponding to the code modification line number according to the modification record acquired by the acquiring module;
  • a parsing module for parsing the objective function to which the number of code modification lines determined by the determining module belongs;
  • a generating module configured to generate target annotation information according to the modification content and the modification time acquired by the acquiring module
  • the adding module is used to add the target annotation information generated by the generating module to the annotation of the target function.
  • a computer device including a memory, a processor, and computer-readable instructions stored in the memory and capable of running on the processor, and the processor implements the above-mentioned annotation information processing method when the processor executes the computer-readable instructions A step of.
  • One or more readable storage media storing computer readable instructions, and when the computer readable instructions are executed by one or more processors, the one or more processors implement the steps of the annotation information processing method.
  • FIG. 1 is a schematic structural diagram of an application of an annotation information processing method in an embodiment of the present application
  • FIG. 2 is a schematic flowchart of a method for processing annotation information in an embodiment of the present application
  • FIG. 3 is a schematic flowchart of an information processing method in an embodiment of the present application.
  • FIG. 4 is a schematic flowchart of an information processing method in an embodiment of the present application.
  • FIG. 5 is a schematic flowchart of an information processing method in an embodiment of the present application.
  • FIG. 6 is a schematic flowchart of an information processing method in an embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of an annotation information processing apparatus in an embodiment of the present application.
  • Fig. 8 is a schematic structural diagram of a computer device in an embodiment of the present application.
  • the annotation information processing method provided by the embodiment of the application can be applied in the application environment as shown in FIG. 1, where the annotation information processing device can obtain the user's modification record of the project code file; determine the project code file according to the modification record The number of code modification lines of the code, and the modification content and modification time corresponding to the code modification line number; parsing the target function to which the code modification line number belongs; generating target annotation information according to the modification content and the modification time; The target comment information is added to the comment of the target function.
  • the comment information processing device can help users determine the number of code modification lines in the modification record of the project code file, and add comments to the target function corresponding to the number of code modification lines according to the modification content and modification time, that is, when performing code comments, It can be based on timely addition or update to cause code comments, reducing the tedious operation of manually adding and updating code comments, and can reduce the inconsistency of comments and codes, and reduce the probability of code comments.
  • the annotation information processing device can obtain the user's modification record of the project code file, and generate target annotation information based on the modification record.
  • the annotation information processing device can be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, etc.
  • the annotation information processing device can also be implemented by a server, or the server can be an independent server or a combination of multiple servers. Server cluster to achieve.
  • a method for processing annotation information includes the following steps:
  • Project code files refer to code files written by users in some code development projects, such as APP and website development projects. During the project development process, the project code files are usually modified. For the server, the user's modification record to the project code file can be obtained.
  • some code management tools are usually used to manage the code project development process, specifically, including the management of the user's modification record of the project code file.
  • the user's modification record of the project code file can be obtained.
  • common version management tools generally include Subversion and Git tools. Take the Git tool as an example.
  • the Git submission record can be obtained using the Git tool, and the user's modification record of the project code file can be obtained according to the Git submission record.
  • the above submission record includes the user's project code file The number of code modification lines of the code file, and the modification records corresponding to the number of code modification lines, the modification content, and the number of modifications.
  • the submission record also includes the modification submission time and project version number.
  • the modified content refers to the modifications made by the user to the project code file.
  • the code modules in the project code file are divided by functions (also called methods), which have different names in different code programming languages. For example, they are usually called functions in the C language, and in the Java language. It is generally called a method.
  • the embodiments of the present application are collectively called a function.
  • Each function is a code module used to perform a certain function.
  • the user modifies the code of a function in the project code to adjust the function function.
  • the modification time refers to the time when the user modified the code in the project code file. For example, the user modified the code in the project code file on January 1, 2019.
  • the code has been modified.
  • the number of lines of code modification refers to the line number of the modified code when the user modifies the project code file. It should be noted that the above example is only illustrative here, for example, the modification time can also be specific to the time, which is not limited here.
  • S20 Determine, according to the modification record, the number of code modification lines of the project code file, and the modification content and modification time corresponding to the code modification line number.
  • the number of code modification lines of the project code file, and the modification content and modification time corresponding to the code modification line number are determined according to the modification record.
  • the modification record instructs the user to modify the code on line 36 of the project code from "a" to "b” on January 1, 2019, the modification time of the project code file can be determined based on the above modification record It is: January 1, 2019; the modification content is: the 36th line of the project code is changed from “a” to "b”, and the number of modified lines is: line 36 in the project code file.
  • the target function to which the code modification line number belongs is analyzed.
  • the modification record includes the number of code modification lines and modification content in the project code file
  • the modification content of the record can only record which line of code has been modified, and the modified code cannot be recorded as belonging to Which function in the project code file. Therefore, in the embodiment of the present application, it is necessary to analyze the objective function to which the code modification line number belongs based on the code modification line number.
  • S40 Generate target annotation information according to the modification content and the modification time.
  • the user determines the number of code modification lines in the modification record of the project code file, and adds comments to the target function corresponding to the number of code modification lines according to the modification content and modification time, that is, the code is in progress. Comments can be added or updated in time to cause code comments, reducing the tedious operation of manually adding and updating code comments, and can reduce the occurrence of inconsistencies between comments and code, and reduce the probability of code comments.
  • step S30 that is, the parsing of the objective function to which the code modification line number belongs, specifically includes the following steps:
  • a syntax tree analysis can be performed on the project code file according to an abstract syntax tree ((abstract syntax code, AST)) algorithm to obtain a syntax tree corresponding to the project code file.
  • an abstract syntax tree (abstract syntax code, AST)) algorithm to obtain a syntax tree corresponding to the project code file.
  • the syntax tree corresponding to the project code file is a tree representation of the abstract syntax structure of the source code of the project code file. Each node on the tree represents a structure in the source code.
  • the syntax tree analysis tool can be selected according to the programming language used by the project code file, and the syntax tree analysis tool is used to perform syntax tree analysis on the project code file.
  • each project represents a tree
  • the function in the project code file is abstracted into a node.
  • Multiple nodes with mutual references form a structural link, and the nodes and structural links together reflect each Reference, containment, and positional relationship between node codes. Therefore, by analyzing the project code file according to the abstract syntax tree algorithm to obtain the syntax tree corresponding to the project code file, the entire code structure of the source code of the project code file can be clearly obtained.
  • S32 traverse the syntax tree according to the number of code modification lines to determine the node position of the code modification line in the syntax tree.
  • the code can be modified according to the The number of lines traverses the syntax tree to determine the node position of the code modification line number in the syntax tree.
  • the code modification After traversing the syntax tree according to the number of code modification lines to determine that the code modification line number is at the node position of the syntax tree, the code modification can be determined according to the parent node of the node position The objective function to which the number of rows belongs. It can be seen that, in the embodiment of the present application, a method of analyzing the objective function to which the number of code modification lines belongs is proposed, which improves the implementability of the solution.
  • step S50 that is, adding the target annotation information to the target function annotation, specifically includes the following steps:
  • the target comment information needs to be added to the target function comment, it can be determined whether the Mubaoshi function has been commented. Specifically, in the embodiment of the application, a comment can be added for each of the project code files The function corresponding to generate a comment index number, and the comment index number is used to determine whether the target function has been commented. If the target function has a corresponding comment index number, it is determined that the target function has been commented. If the target function does not have a corresponding comment index number , It is determined that the target annotation information has been annotated.
  • the embodiment of the present application provides the following methods to process the newly generated target annotation information.
  • the first method is to overwrite the old annotation of the target function with the target annotation information to add the target annotation information to the
  • the comment of the target function is used to realize the function of updating the comment of the target function, so that the comment of the target function is updated correspondingly with each modification.
  • the second method is to add the target comment information to the comment of the target function according to the order of the comment addition time. For example, if the previous comment was comment 1, add the target comment information after the comment 1, and use the comment Tianjian time to distinguish. Through the second method, each modification record of the target function can be reflected in the comment. It is convenient for programmers to consult and browse the comment records, so that both new and old comments can be consulted.
  • the target comment information is added to the comment of the target function.
  • a note index number uniquely corresponding to the target note information is generated and added to the note of the target function.
  • different characters and/or character strings can be used as the above-mentioned annotation index number. It can be seen that in the embodiments of the present application, several specific methods of placing the annotation day to the annotation position of the function are proposed to improve the implementability of the solution.
  • step S40 generating target annotation information according to the modified content and the modification time, specifically includes the following steps:
  • the above-mentioned rule file is a file used to subsequently generate target annotation information.
  • a rule file of annotations will be created in the project, such as: what items (author, annotation content, etc.) the annotation needs to include, annotation content, generated The format of the comment field, layout, etc.
  • the above-mentioned rule file can be pre-configured manually, and is not specifically limited.
  • S42 Determine the annotation content according to the rule file and the modified content.
  • the comment content is determined according to the rule file and the modified content.
  • the modification record instructs the user to modify the code in line 36 of the project code from “a” to "b” on January 1, 2019, the modification time of the project code file can be determined based on the above modification record It is: January 1, 2019; the modification content is: the 36th line of the project code is changed from “a” to "b”, and the number of modified lines is: line 36 in the project code file.
  • the function belonging to the above line 36 is function A
  • the following comment content can be determined according to the rule file and the modified content:
  • the modifier Zhang modified the code from "a” to "b".
  • the programmer can use the Git tool to obtain the information of the user, thereby obtaining the modification personnel in the comment content.
  • S43 Generate the target annotation information according to the modification time and the annotation content.
  • the target annotation information is generated according to the modification time and the annotation content.
  • the modifier Zhang modified the code from "a" to "b", based on the modification time and the comment content, that is, January 1, 2019 and the above comment content, generate Final target comment information.
  • the annotation information processing method further includes the following steps:
  • S70 Generate a comment text file according to all the comments in the project code file and the comment index numbers corresponding to all the comments.
  • each function that contains comments in the project code file has a corresponding comment index number.
  • each function in the project code file can be obtained.
  • a comment index number corresponding to each of the comments, and a comment text file is generated according to all the comments in the project code file and the comment index numbers corresponding to all the comments.
  • the annotation index number may be a keyword to obtain the annotation corresponding to the annotation index number from the project code, and generate the annotation text file according to all the annotations in the project code file and the annotation index numbers corresponding to all the annotations.
  • the comment text file explains the comment of each function in the modification record, so that the programmer can obtain the comment text file formed by the comment of the entire project file completely and clearly, which is convenient for the programmer to browse and improve the user experience. .
  • an annotation information processing device is provided, and the annotation information processing device corresponds to the annotation information processing method in the foregoing embodiment one-to-one.
  • the annotation information processing apparatus 10 includes an acquisition module 101, a determination module 101, an analysis module 103, a generation module 104, and an addition module 105.
  • the detailed description of each functional module is as follows:
  • the obtaining module 101 is used to obtain the user's modification record of the project code file
  • the determining module 102 is configured to determine the number of code modification lines of the project code file, and the modification content and modification time corresponding to the code modification line number according to the modification record acquired by the acquiring module;
  • the analysis module 103 is configured to analyze the objective function to which the number of code modification lines determined by the determination module belongs;
  • the generating module 104 is configured to generate target annotation information according to the modification content and the modification time acquired by the acquiring module;
  • the adding module 105 is configured to add the target comment information generated by the generating module to the comment of the target function.
  • the comment information processing device allows the user to determine the number of code modification lines based on the modification record of the project code file, and adds comments to the target function corresponding to the code modification line number according to the modification content and modification time, that is, In other words, code comments can be added or updated in time to cause code comments, reducing the tedious operation of manually adding and updating code comments, and reducing the occurrence of inconsistencies between comments and code, and reducing the probability of code comments.
  • the adding module is specifically used for:
  • the old annotation of the objective function is overwritten by the objective annotation information, so that the objective annotation information is added to the annotation of the objective function, or according to the time sequence of annotation addition Sequentially, adding the target comment information to the comment of the target function;
  • the target comment information is added to the comment of the target function.
  • the annotation information processing device determines that the objective function has been annotated, it adds the objective annotation information to the annotation of the objective function. Specifically, a note index number uniquely corresponding to the target note information is generated and added to the note of the target function. Among them, different characters and/or character strings can be used as the above-mentioned annotation index number. It can be seen that in the embodiments of the present application, several specific methods of placing the annotation day to the annotation position of the function are proposed to improve the implementability of the solution.
  • the parsing module is specifically configured to:
  • the objective function to which the code modification line number belongs is determined according to the node position.
  • the annotation information processing device analyzes the project code file according to the abstract syntax tree algorithm to obtain the syntax tree corresponding to the project code file
  • the functions in the project code file in the syntax tree are abstracted into
  • a node multiple nodes with mutual reference relationships form a structural link.
  • the node and the structural link together reflect the reference, inclusion, and position relationship between the codes of each node. Therefore, in the embodiments of this application,
  • the code modification line number traverses the syntax tree to determine the node position of the code modification line number in the syntax tree.
  • the code modification After traversing the syntax tree according to the number of code modification lines to determine that the code modification line number is at the node position of the syntax tree, the code modification can be determined according to the parent node of the node position The objective function to which the number of rows belongs. It can be seen that, in the embodiment of the present application, a method of analyzing the objective function to which the number of code modification lines belongs is proposed, which improves the implementability of the solution.
  • the generating module is specifically configured to obtain a rule file for establishing code comments
  • the target annotation information is generated according to the modification time and the annotation content.
  • the obtaining module is further configured to: after adding the target comment information to the comment of the target function, obtain the comment index corresponding to each comment in the project code file number;
  • the generating module is also used to generate a comment text file according to all the comments in the project code file and the comment index numbers corresponding to all the comments.
  • the annotation information processing device can obtain the annotation corresponding to the annotation index number from the project code with the annotation index number as a keyword, and generate the annotation based on all the annotations in the project code file and the annotation index numbers corresponding to all the annotations.
  • Text file explains the comment of each function in the modification record, so that the programmer can obtain the comment text file formed by the comment of the entire project file completely and clearly, which is convenient for the programmer to browse and improve the user experience. .
  • Each module in the above-mentioned annotation information processing apparatus can be implemented in whole or in part by software, hardware, and a combination thereof.
  • the foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
  • a computer device is provided.
  • the computer device may be the above-mentioned annotation information processing apparatus, and its internal structure diagram may be as shown in FIG. 8.
  • the computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, computer readable instructions, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium.
  • the database of the computer equipment is used to store modification records, etc.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer-readable instruction is executed by the processor to realize a method for processing annotation information.
  • a computer device including a memory, a processor, and computer-readable instructions stored in the memory and capable of running on the processor, and the processor implements the following steps when the processor executes the computer-readable instructions:
  • the target comment information is added to the comment of the target function.
  • one or more readable storage media storing computer readable instructions are provided.
  • the readable storage medium includes a non-volatile readable storage medium and a volatile readable storage medium.
  • the one or more processors execute the following steps:
  • the target comment information is added to the comment of the target function.
  • Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • ROM read only memory
  • PROM programmable ROM
  • EPROM electrically programmable ROM
  • EEPROM electrically erasable programmable ROM
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Document Processing Apparatus (AREA)

Abstract

A method and device for processing annotation information, a computer apparatus, and a storage medium capable of reducing probability of error in a code annotation. The method comprises: acquiring a record of modifications made to a project code file by a user (S10); determining, according to the record of modifications, a serial number of a row at which a code of the project code file has been modified, and modified content and a modification time corresponding to said serial number (S20); performing parsing to obtain a target function associated with said serial number (S30); generating target annotation information according to the modified content and the modification time (S40); and adding the target annotation information to an annotation location of the target function (S50).

Description

注释信息处理方法、装置、计算机设备及存储介质Annotation information processing method, device, computer equipment and storage medium
本申请以2019年07月11日提交的申请号为201910625168.4,名称为“注释信息处理方法、装置、计算机设备及存储介质”的中国发明专利申请为基础,并要求其优先权。This application is based on the Chinese invention patent application filed on July 11, 2019 with the application number 201910625168.4 and titled "Annotation Information Processing Method, Device, Computer Equipment, and Storage Medium", and claims its priority.
技术领域Technical field
本申请涉及代码处理领域,尤其涉及一种注释信息处理方法、装置、计算机设备及存储介质。This application relates to the field of code processing, in particular to an annotation information processing method, device, computer equipment and storage medium.
背景技术Background technique
每个软件工程师最头疼的事情不是写代码,而是写注释,而且是如何写出可维护的注释。即使内部项目有强制规范要求必须写注释,在工程师眼里这是十分耗费时间的。在进行代码注释中,可能会无法及时更新导致注释与代码不一致的情况出现,导致代码注释出错。The most troublesome thing for every software engineer is not to write code, but to write comments, and how to write maintainable comments. Even if internal projects have mandatory specifications that require comments to be written, this is very time-consuming in the eyes of engineers. In the code comments, it may not be able to update in time, causing the comments to be inconsistent with the code, resulting in errors in the code comments.
发明内容Summary of the invention
本申请实施例提供一种注释信息处理方法、装置、计算机设备及存储介质,可以减少代码注释出错概率。The embodiments of the present application provide an annotation information processing method, device, computer equipment, and storage medium, which can reduce the probability of code annotation errors.
一种注释信息处理方法,其特征在于,包括:An annotation information processing method, characterized in that it comprises:
获取用户对项目代码文件的修改记录;Obtain the user's modification record of the project code file;
根据所述修改记录确定所述项目代码文件的代码修改行数,以及所述代码修改行数对应的修改内容和修改时间;Determine, according to the modification record, the number of code modification lines of the project code file, and the modification content and modification time corresponding to the code modification line number;
解析所述代码修改行数所属的目标函数;Parsing the objective function to which the code modification line number belongs;
根据所述修改内容以及所述修改时间生成目标注释信息;Generating target annotation information according to the modification content and the modification time;
将所述目标注释信息添加至所述目标函数的注释处。The target comment information is added to the comment of the target function.
一种注释信息处理装置,其特征在于,包括:An annotation information processing device, characterized by comprising:
获取模块,用于获取用户对项目代码文件的修改记录;The acquisition module is used to acquire the user's modification record of the project code file;
确定模块,用于根据获取获取模块获取的所述修改记录确定所述项目代码文件的代码修改行数,以及所述代码修改行数对应的修改内容和修改时间;The determining module is configured to determine the number of code modification lines of the project code file, and the modification content and modification time corresponding to the code modification line number according to the modification record acquired by the acquiring module;
解析模块,用于解析所述确定模块确定的所述代码修改行数所属的目标函数;A parsing module for parsing the objective function to which the number of code modification lines determined by the determining module belongs;
生成模块,用于根据所述获取模块获取的所述修改内容以及所述修改时间生成目标注释信息;A generating module, configured to generate target annotation information according to the modification content and the modification time acquired by the acquiring module;
添加模块,用于将所述生成模块生成的所述目标注释信息添加至所述目标函数的注释处。The adding module is used to add the target annotation information generated by the generating module to the annotation of the target function.
一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现上述注释信息处理方法的步骤。A computer device including a memory, a processor, and computer-readable instructions stored in the memory and capable of running on the processor, and the processor implements the above-mentioned annotation information processing method when the processor executes the computer-readable instructions A step of.
一个或多个存储有计算机可读指令的可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器实现上述注释信息处理方法的步骤。One or more readable storage media storing computer readable instructions, and when the computer readable instructions are executed by one or more processors, the one or more processors implement the steps of the annotation information processing method.
本申请的一个或多个实施例的细节在下面的附图和描述中提出,本申请的其他特征和优点将从说明书、附图以及权利要求变得明显。The details of one or more embodiments of the present application are presented in the following drawings and description, and other features and advantages of the present application will become apparent from the description, drawings and claims.
附图说明Description of the drawings
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to explain the technical solutions of the embodiments of the present application more clearly, the following will briefly introduce the drawings that need to be used in the description of the embodiments of the present application. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative labor.
图1是本申请一实施例中注释信息处理方法应用的一结构示意图;FIG. 1 is a schematic structural diagram of an application of an annotation information processing method in an embodiment of the present application;
图2是本申请一实施例中注释信息处理方法的一流程示意图;2 is a schematic flowchart of a method for processing annotation information in an embodiment of the present application;
图3是本申请一实施例中释信息处理方法的一流程示意图;FIG. 3 is a schematic flowchart of an information processing method in an embodiment of the present application;
图4是本申请一实施例中释信息处理方法的一流程示意图;FIG. 4 is a schematic flowchart of an information processing method in an embodiment of the present application;
图5是本申请一实施例中释信息处理方法的一流程示意图;FIG. 5 is a schematic flowchart of an information processing method in an embodiment of the present application;
图6是本申请一实施例中释信息处理方法的一流程示意图;FIG. 6 is a schematic flowchart of an information processing method in an embodiment of the present application;
图7是本申请一实施例中注释信息处理装置的一结构示意图;FIG. 7 is a schematic structural diagram of an annotation information processing apparatus in an embodiment of the present application;
图8是本申请一实施例中计算机设备的一结构示意图。Fig. 8 is a schematic structural diagram of a computer device in an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be described clearly and completely in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of them. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of this application.
本申请实施例提供的注释信息处理方法,可应用在如图1的应用环境中,其中,注释信息处理装置可获取用户对项目代码文件的修改记录;根据所述修改记录确定所述项目代码文件的代码修改行数,以及所述代码修改行数对应的修改内容和修改时间;解析所述代码修改行数所属的目标函数;根据所述修改内容以及所述修改时间生成目标注释信息;将所述目标注释信息添加至所述目标函数的注释处。说明注释信息处理装置可利用户对项目代码文件的修改记录确定出代码修改行数,并依据修改内容和修改时间在代码修改行数对应的目标函数添加注释,也就是说,在进行代码注释,能依据及时添加或更新导致代码注释,减少人为添加、更新代码注释的繁琐操作,且能减少注释与代码不一致的情况出现,减少代码注释出错概率。注释信息处理装置可获取用户对项目代码文件的修改记录,根据修改记录生成目标注释信息。其中,注释信息处理装置可以但不限于各种个人计算机、笔记本电脑、智能手机、平板电脑等,注释信息处理装置也可以由服务器实现,也可服务器可以用独立的服务器或者是多个服务器组成的服务器集群来实现。The annotation information processing method provided by the embodiment of the application can be applied in the application environment as shown in FIG. 1, where the annotation information processing device can obtain the user's modification record of the project code file; determine the project code file according to the modification record The number of code modification lines of the code, and the modification content and modification time corresponding to the code modification line number; parsing the target function to which the code modification line number belongs; generating target annotation information according to the modification content and the modification time; The target comment information is added to the comment of the target function. Explain that the comment information processing device can help users determine the number of code modification lines in the modification record of the project code file, and add comments to the target function corresponding to the number of code modification lines according to the modification content and modification time, that is, when performing code comments, It can be based on timely addition or update to cause code comments, reducing the tedious operation of manually adding and updating code comments, and can reduce the inconsistency of comments and codes, and reduce the probability of code comments. The annotation information processing device can obtain the user's modification record of the project code file, and generate target annotation information based on the modification record. Among them, the annotation information processing device can be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, etc. The annotation information processing device can also be implemented by a server, or the server can be an independent server or a combination of multiple servers. Server cluster to achieve.
在一实施例中,如图2所示,提供一种注释信息处理方法,包括如下步骤:In an embodiment, as shown in FIG. 2, a method for processing annotation information is provided, which includes the following steps:
S10:获取用户对项目代码文件的修改记录。S10: Obtain the user's modification record of the project code file.
项目代码文件指的是一些代码开发项目中,例如APP、网站等开发项目中,用户所编写的代码文件。在项目开发过程中,通常都会对项目代码文件进行修改。对于服务器而言,可以获取到用户对项目代码文件的修改记录。Project code files refer to code files written by users in some code development projects, such as APP and website development projects. During the project development process, the project code files are usually modified. For the server, the user's modification record to the project code file can be obtained.
在一些应用场景中,通常会使用一些代码管理工具对,代码项目开发过程进行管理,具体地,包括用户对项目代码文件的修改记录的管理。在本申请实施例 中,可以获取用户对项目代码文件的修改记录。例如,常见的版本管理工具一般有Subversion和Git工具等。以Git工具为例,对于Gti工具而言,在可以获取利用Git工具获取到Git提交记录,依据Git提交记录获取到用户对项目代码文件的修改记录,其中,上述提交记录中包括了用户对项目代码文件的代码修改行数,以及代码修改行数对应的修改内容、修改次数等修改记录,除此之外,提交记录还包括修改提交时间、项目版本号等。另外,修改内容指的是用户对项目代码文件作了哪些修改。可以理解,项目代码文件中的代码模块是以函数(也称为方法)进行划分的,在不同的代码编程语言中具有不同的叫法,例如在c语言中通常称为函数,在java语言中通常称为方法,为了便于描述,本申请实施例统一称为函数。每个函数为一个代码模块,用于执行某种功能。例如,用户对项目代码中的某个函数的代码作了修改以调整函数功能,修改时间是指用户对项目代码文件中代码的修改时间,例如用户在2019年1月1日对项目代码文件中的代码作了修改,代码修改行数是指用户对项目代码文件进行修改时,修改的代码所在的行数。需要说明的是,上述例子在这里只是示例性说明,例如修改时间还可以具体到时刻,这里不做限定。In some application scenarios, some code management tools are usually used to manage the code project development process, specifically, including the management of the user's modification record of the project code file. In this embodiment of the application, the user's modification record of the project code file can be obtained. For example, common version management tools generally include Subversion and Git tools. Take the Git tool as an example. For the Gti tool, the Git submission record can be obtained using the Git tool, and the user's modification record of the project code file can be obtained according to the Git submission record. The above submission record includes the user's project code file The number of code modification lines of the code file, and the modification records corresponding to the number of code modification lines, the modification content, and the number of modifications. In addition, the submission record also includes the modification submission time and project version number. In addition, the modified content refers to the modifications made by the user to the project code file. It can be understood that the code modules in the project code file are divided by functions (also called methods), which have different names in different code programming languages. For example, they are usually called functions in the C language, and in the Java language. It is generally called a method. For ease of description, the embodiments of the present application are collectively called a function. Each function is a code module used to perform a certain function. For example, the user modifies the code of a function in the project code to adjust the function function. The modification time refers to the time when the user modified the code in the project code file. For example, the user modified the code in the project code file on January 1, 2019. The code has been modified. The number of lines of code modification refers to the line number of the modified code when the user modifies the project code file. It should be noted that the above example is only illustrative here, for example, the modification time can also be specific to the time, which is not limited here.
S20:根据所述修改记录确定所述项目代码文件的代码修改行数,以及所述代码修改行数对应的修改内容和修改时间。S20: Determine, according to the modification record, the number of code modification lines of the project code file, and the modification content and modification time corresponding to the code modification line number.
在获取了用户对项目代码文件的修改记录之后,根据所述修改记录确定所述项目代码文件的代码修改行数,以及所述代码修改行数对应的修改内容和修改时间。示例性的,若修改记录指示用户在2019年1月1日对项目代码中第36行的代码由“a”修改为“b”,则可根据上述修改记录,确定出项目代码文件的修改时间为:2019年1月1日;修改内容为:将项目代码中第36行的代码由“a”修改为“b”,修改行数为:项目代码文件中的第36行。After obtaining the user's modification record of the project code file, the number of code modification lines of the project code file, and the modification content and modification time corresponding to the code modification line number are determined according to the modification record. Exemplarily, if the modification record instructs the user to modify the code on line 36 of the project code from "a" to "b" on January 1, 2019, the modification time of the project code file can be determined based on the above modification record It is: January 1, 2019; the modification content is: the 36th line of the project code is changed from "a" to "b", and the number of modified lines is: line 36 in the project code file.
S30:解析所述代码修改行数所属的目标函数。S30: Analyze the objective function to which the code modification line number belongs.
根据所述修改记录确定所述项目代码文件的代码修改行数之后,解析出代码修改行数所属的目标函数。需要说明的是,在步骤S20中,虽然修改记录是包括了项目代码文件中的代码修改行数以及修改内容,但是记录的修改内容只能记录修改了哪一行代码,无法记录修改的代码是属于项目代码文件中的哪个函数。 因此,在本申请实施例,需依据代码修改行数解析出代码修改行数所属的目标函数。After determining the number of code modification lines of the project code file according to the modification record, the target function to which the code modification line number belongs is analyzed. It should be noted that in step S20, although the modification record includes the number of code modification lines and modification content in the project code file, the modification content of the record can only record which line of code has been modified, and the modified code cannot be recorded as belonging to Which function in the project code file. Therefore, in the embodiment of the present application, it is necessary to analyze the objective function to which the code modification line number belongs based on the code modification line number.
S40:根据所述修改内容以及所述修改时间生成目标注释信息。S40: Generate target annotation information according to the modification content and the modification time.
S50:将所述目标注释信息添加至所述目标函数的注释处。S50: Add the target comment information to the comment of the target function.
在解析所述代码修改行数所属的目标函数之后,就可以知道对项目代码文件中的哪个目标函数作了修改,此时,根据所述修改内容以及所述修改时间生成目标注释信息,并将所述目标注释信息添加至所述目标函数的注释处。因此,通过上述实施例,可生成项目代码文件中每个被修改的函数的注释,便于编程人员观看,且使得代码注释自动更新。After parsing the target function to which the number of lines of code modification belongs, it is possible to know which target function in the project code file is modified. At this time, target annotation information is generated according to the modification content and the modification time, and The target comment information is added to the comment of the target function. Therefore, through the above-mentioned embodiment, the comment of each modified function in the project code file can be generated, which is convenient for programmers to watch, and the code comment is automatically updated.
通过上述实施例可以看出,利用户对项目代码文件的修改记录确定出代码修改行数,并依据修改内容和修改时间在代码修改行数对应的目标函数添加注释,也就是说,在进行代码注释,能依据及时添加或更新导致代码注释,减少人为添加、更新代码注释的繁琐操作,且能减少注释与代码不一致的情况出现,减少代码注释出错概率。It can be seen from the above embodiment that the user determines the number of code modification lines in the modification record of the project code file, and adds comments to the target function corresponding to the number of code modification lines according to the modification content and modification time, that is, the code is in progress. Comments can be added or updated in time to cause code comments, reducing the tedious operation of manually adding and updating code comments, and can reduce the occurrence of inconsistencies between comments and code, and reduce the probability of code comments.
在一实施例中,如图3所示,步骤S30中,即所述解析出所述代码修改行数所属的目标函数,具体包括如下步骤:In one embodiment, as shown in FIG. 3, in step S30, that is, the parsing of the objective function to which the code modification line number belongs, specifically includes the following steps:
S31:根据抽象语法树算法对所述项目代码文件进行分析,以获得所述项目代码文件对应的语法树。S31: Analyze the project code file according to the abstract syntax tree algorithm to obtain a syntax tree corresponding to the project code file.
由于随着开发项目的系统以及复杂化,项目代码通常也比较繁多复杂,因此为了快速获取到代码修改行数所属的目标函数,有必要理清整个项目代码文件的接口,因此,本申请实施例可根据抽象语法树((abstract syntax code,AST))算法对项目代码文件进行语法树分析,以获得项目代码文件对应的语法树。需要说明的是,项目代码文件对应的语法树是项目代码文件的源代码的抽象语法结构的树状表示,树上的每个节点都表示源代码中的一种结构,具体地,在本申请实施例中,可根据项目代码文件所采用的编程语言来选择语法树分析工具,并采用语法树分析工具对项目代码文件进行语法树分析得到的。在语法树结构中,每一个项目代表一颗树,将项目代码文件中的函数抽象成一个节点, 多个具有相互引用关系的节点组成了一条结构链路,节点和结构链路共同反映了各个节点的代码之间的引用、包含以及位置关系。因此,在根据抽象语法树算法对所述项目代码文件进行分析,以获得所述项目代码文件对应的语法树,可清晰的得到项目代码文件的源代码的整个代码结构。As the system and complexity of the development project, the project code is usually more complicated, so in order to quickly obtain the target function to which the number of code modification lines belongs, it is necessary to clarify the interface of the entire project code file. Therefore, the embodiment of the application A syntax tree analysis can be performed on the project code file according to an abstract syntax tree ((abstract syntax code, AST)) algorithm to obtain a syntax tree corresponding to the project code file. It should be noted that the syntax tree corresponding to the project code file is a tree representation of the abstract syntax structure of the source code of the project code file. Each node on the tree represents a structure in the source code. Specifically, in this application In an embodiment, the syntax tree analysis tool can be selected according to the programming language used by the project code file, and the syntax tree analysis tool is used to perform syntax tree analysis on the project code file. In the syntax tree structure, each project represents a tree, and the function in the project code file is abstracted into a node. Multiple nodes with mutual references form a structural link, and the nodes and structural links together reflect each Reference, containment, and positional relationship between node codes. Therefore, by analyzing the project code file according to the abstract syntax tree algorithm to obtain the syntax tree corresponding to the project code file, the entire code structure of the source code of the project code file can be clearly obtained.
S32:根据所述代码修改行数对所述语法树进行遍历,以确定所述代码修改行数在所述语法树的节点位置。S32: traverse the syntax tree according to the number of code modification lines to determine the node position of the code modification line in the syntax tree.
S33:根据所述节点位置确定所述代码修改行数所属的所述目标函数。S33: Determine the objective function to which the code modification line number belongs according to the node position.
如前面所述,在根据抽象语法树算法对所述项目代码文件进行分析,以获得所述项目代码文件对应的语法树之后,由于语法树中的项目代码文件中的函数抽象成一个节点,多个具有相互引用关系的节点组成了一条结构链路,节点和结构链路共同反映了各个节点的代码之间的引用、包含以及位置关系,因此在本申请实施例中,可根据所述代码修改行数对所述语法树进行遍历,以确定所述代码修改行数在所述语法树的节点位置。在得到根据所述代码修改行数对所述语法树进行遍历,以确定所述代码修改行数在所述语法树的节点位置之后,依据该节点位置的父节点,即可确定所述代码修改行数所属的所述目标函数。可见,在本申请实施例中提出了一种解析出所述代码修改行数所属的目标函数的方式,提高了方案可实施性。As mentioned above, after analyzing the project code file according to the abstract syntax tree algorithm to obtain the syntax tree corresponding to the project code file, since the function in the project code file in the syntax tree is abstracted into one node, more Two nodes with a mutual reference relationship form a structural link, and the node and the structural link together reflect the reference, inclusion, and position relationship between the codes of each node. Therefore, in this embodiment of the application, the code can be modified according to the The number of lines traverses the syntax tree to determine the node position of the code modification line number in the syntax tree. After traversing the syntax tree according to the number of code modification lines to determine that the code modification line number is at the node position of the syntax tree, the code modification can be determined according to the parent node of the node position The objective function to which the number of rows belongs. It can be seen that, in the embodiment of the present application, a method of analyzing the objective function to which the number of code modification lines belongs is proposed, which improves the implementability of the solution.
在一实施例中,如图4所示,步骤S50中,即所述将所述目标注释信息添加至所述目标函数注释处,具体包括如下步骤:In an embodiment, as shown in FIG. 4, in step S50, that is, adding the target annotation information to the target function annotation, specifically includes the following steps:
S51:确定所述目标函数是否被添加过注释。S51: Determine whether the target function has been commented.
在需将所述目标注释信息添加至所述目标函数注释处时,可先确定牧宝势函数是否被添加过注释,具体地,本申请实施例中可为项目代码文件中每一个添加过注释的函数对应生成注释索引号,通过注释索引号确定目标函数是否被添加过注释,若目标函数存在对应的注释索引号,则确定目标函数被添加过注释,若目标函数不存在对应的注释索引号,则确定目标注释信息被添加过注释。When the target comment information needs to be added to the target function comment, it can be determined whether the Mubaoshi function has been commented. Specifically, in the embodiment of the application, a comment can be added for each of the project code files The function corresponding to generate a comment index number, and the comment index number is used to determine whether the target function has been commented. If the target function has a corresponding comment index number, it is determined that the target function has been commented. If the target function does not have a corresponding comment index number , It is determined that the target annotation information has been annotated.
S52:若确定所述目标函数被添加过注释,则通过所述目标注释信息覆盖所述目标函数的旧注释,以将所述目标注释信息添加至所述目标函数的注释处,或 按照注释添加时间先后顺序,将所述目标注释信息添加至所述目标函数的注释处。S52: If it is determined that the target function has been commented, overwrite the old comment of the target function with the target comment information to add the target comment information to the comment of the target function, or add according to the comment In chronological order, the target comment information is added to the comment of the target function.
若确定目标函数被添加过注释,本申请实施例提供以下方式处理新生成的目标注释信息,第一种是通过目标注释信息覆盖目标函数的旧注释,以将所述目标注释信息添加至所述目标函数的注释处,从而实现更新目标函数的注释的功能,使得目标函数的注释随着每次修改而对应更新。第二种是按照注释添加时间先后顺序,将所述目标注释信息添加至所述目标函数的注释处。例如,若前一次注释为注释1,则将目标注释信息添加在注释1后面,并用注释天剑时间区别开,通过第二种方式,可使得目标函数的每次修改记录得以在注释处体现,便于编程人员查阅浏览注释记录,使得新旧注释均能查阅到。If it is determined that the target function has been annotated, the embodiment of the present application provides the following methods to process the newly generated target annotation information. The first method is to overwrite the old annotation of the target function with the target annotation information to add the target annotation information to the The comment of the target function is used to realize the function of updating the comment of the target function, so that the comment of the target function is updated correspondingly with each modification. The second method is to add the target comment information to the comment of the target function according to the order of the comment addition time. For example, if the previous comment was comment 1, add the target comment information after the comment 1, and use the comment Tianjian time to distinguish. Through the second method, each modification record of the target function can be reflected in the comment. It is convenient for programmers to consult and browse the comment records, so that both new and old comments can be consulted.
S53:若确定所述函数未被添加过注释,则将所述目标注释信息添加至所述目标函数的注释处。S53: If it is determined that the function has not been commented, add the target comment information to the comment of the target function.
若确定目标函数被添加过注释,则将所述目标注释信息添加至所述目标函数的注释处。具体地,生成该目标注释信息唯一对应的注释索引号后添加至所述目标函数的注释处。其中,可以不同的字符和/或字符串作为上述注释索引号,由此可见,在本申请实施例中,提出了几种具体将注释天至函数的注释处的方式,提高方案可实施性。If it is determined that the target function has been commented, then the target comment information is added to the comment of the target function. Specifically, a note index number uniquely corresponding to the target note information is generated and added to the note of the target function. Among them, different characters and/or character strings can be used as the above-mentioned annotation index number. It can be seen that in the embodiments of the present application, several specific methods of placing the annotation day to the annotation position of the function are proposed to improve the implementability of the solution.
在一实施例中,如图5所示,步骤S40中,即根据所述修改内容以及所述修改时间生成目标注释信息,具体包括如下步骤:In one embodiment, as shown in FIG. 5, in step S40, generating target annotation information according to the modified content and the modification time, specifically includes the following steps:
S41:获取用于建立代码注释的规则文件。S41: Obtain a rule file for establishing code comments.
其中,上述规则文件是用于后续生成目标注释信息的文件,示例性的,会在项目中建立注释的规则文件,如:注释需包含哪些项(作者、注释内容等)、注释内容,生成的注释的字段、布局等格式。需要说明的是,上述规则文件可人为预先配置,具体不做限定。Among them, the above-mentioned rule file is a file used to subsequently generate target annotation information. Illustratively, a rule file of annotations will be created in the project, such as: what items (author, annotation content, etc.) the annotation needs to include, annotation content, generated The format of the comment field, layout, etc. It should be noted that the above-mentioned rule file can be pre-configured manually, and is not specifically limited.
S42:根据所述规则文件以及所述修改内容确定注释内容。S42: Determine the annotation content according to the rule file and the modified content.
在获取了用于建立代码注释的规则文件之后,根据所述规则文件以及所述修改内容确定注释内容。示例性说明,若修改记录指示用户在2019年1月1日对项目 代码中第36行的代码由“a”修改为“b”,则可根据上述修改记录,确定出项目代码文件的修改时间为:2019年1月1日;修改内容为:将项目代码中第36行的代码由“a”修改为“b”,修改行数为:项目代码文件中的第36行。此时,确定出了上述第36行所属的函数为函数A,则可根据规则文件以及修改内容确定出如下注释内容:修改人员张某将代码由“a”修改为“b”。其中,编程人员可利用Git工具获取使用人员的信息,从而得到注释内容中的修改人员。After obtaining the rule file for establishing the code comment, the comment content is determined according to the rule file and the modified content. Exemplary explanation, if the modification record instructs the user to modify the code in line 36 of the project code from "a" to "b" on January 1, 2019, the modification time of the project code file can be determined based on the above modification record It is: January 1, 2019; the modification content is: the 36th line of the project code is changed from "a" to "b", and the number of modified lines is: line 36 in the project code file. At this time, it is determined that the function belonging to the above line 36 is function A, and the following comment content can be determined according to the rule file and the modified content: The modifier Zhang modified the code from "a" to "b". Among them, the programmer can use the Git tool to obtain the information of the user, thereby obtaining the modification personnel in the comment content.
S43:根据所述修改时间以及所述注释内容生成所述目标注释信息。S43: Generate the target annotation information according to the modification time and the annotation content.
在根据所述规则文件以及所述修改内容确定注释内容之后,根据所述修改时间以及所述注释内容生成所述目标注释信息。如上述例子所示,在确定出注释内容:修改人员张某将代码由“a”修改为“b”之后,依据修改时间以及注释内容,也即2019年1月1日以及上述注释内容,生成最终的目标注释信息。After the annotation content is determined according to the rule file and the modification content, the target annotation information is generated according to the modification time and the annotation content. As shown in the above example, after confirming the content of the comment: after the modifier Zhang modified the code from "a" to "b", based on the modification time and the comment content, that is, January 1, 2019 and the above comment content, generate Final target comment information.
在一实施例中,如图6所示,步骤S50之后,也即将所述目标注释信息添加至所述目标函数的注释处之后,该注释信息处理方法还包括如下步骤:In one embodiment, as shown in FIG. 6, after step S50, that is, after adding the target annotation information to the annotation of the target function, the annotation information processing method further includes the following steps:
S60:获取所述项目代码文件中的每个所述注释对应的注释索引号。S60: Obtain a comment index number corresponding to each comment in the project code file.
S70:根据所述项目代码文件中的所有注释,以及所述所有注释对应的注释索引号生成注释文本文件。S70: Generate a comment text file according to all the comments in the project code file and the comment index numbers corresponding to all the comments.
对于步骤S60可以理解,在经过步骤S50处理之后,项目代码文件中的每个已包含注释的函数均具有对应的注释索引号,在本申请实施例中,可获取所述项目代码文件中的每个所述注释对应的注释索引号,并根据所述项目代码文件中的所有注释,以及所述所有注释对应的注释索引号生成注释文本文件。具体地,可以注释索引号为关键字从项目代码中获取释索引号对应的注释,并根据所述项目代码文件中的所有注释,以及所述所有注释对应的注释索引号生成注释文本文件。其中,该注释文本文件中说明了此次修改记录中,每个函数的注释,使得编程人员可完整清晰的获取整个项目文件的注释所形成的注释文本文件,便于编程人员查阅浏览,提高用户体验。For step S60, it can be understood that after step S50 is processed, each function that contains comments in the project code file has a corresponding comment index number. In this embodiment of the application, each function in the project code file can be obtained. A comment index number corresponding to each of the comments, and a comment text file is generated according to all the comments in the project code file and the comment index numbers corresponding to all the comments. Specifically, the annotation index number may be a keyword to obtain the annotation corresponding to the annotation index number from the project code, and generate the annotation text file according to all the annotations in the project code file and the annotation index numbers corresponding to all the annotations. Among them, the comment text file explains the comment of each function in the modification record, so that the programmer can obtain the comment text file formed by the comment of the entire project file completely and clearly, which is convenient for the programmer to browse and improve the user experience. .
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程 构成任何限定。It should be understood that the size of the sequence number of each step in the foregoing embodiment does not mean the order of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiment of the present application.
在一实施例中,提供一种注释信息处理装置,该注释信息处理装置与上述实施例中注释信息处理方法一一对应。如图7所示,该注释信息处理装置10包括获取模块101、确定模块101、解析模块103、生成模块104以及添加模块105。各功能模块详细说明如下:In one embodiment, an annotation information processing device is provided, and the annotation information processing device corresponds to the annotation information processing method in the foregoing embodiment one-to-one. As shown in FIG. 7, the annotation information processing apparatus 10 includes an acquisition module 101, a determination module 101, an analysis module 103, a generation module 104, and an addition module 105. The detailed description of each functional module is as follows:
获取模块101,用于获取用户对项目代码文件的修改记录;The obtaining module 101 is used to obtain the user's modification record of the project code file;
确定模块102,用于根据获取获取模块获取的所述修改记录确定所述项目代码文件的代码修改行数,以及所述代码修改行数对应的修改内容和修改时间;The determining module 102 is configured to determine the number of code modification lines of the project code file, and the modification content and modification time corresponding to the code modification line number according to the modification record acquired by the acquiring module;
解析模块103,用于解析所述确定模块确定的所述代码修改行数所属的目标函数;The analysis module 103 is configured to analyze the objective function to which the number of code modification lines determined by the determination module belongs;
生成模块104,用于根据所述获取模块获取的所述修改内容以及所述修改时间生成目标注释信息;The generating module 104 is configured to generate target annotation information according to the modification content and the modification time acquired by the acquiring module;
添加模块105,用于将所述生成模块生成的所述目标注释信息添加至所述目标函数的注释处。The adding module 105 is configured to add the target comment information generated by the generating module to the comment of the target function.
通过上述装置实施例可以看出,注释信息处理装置利用户对项目代码文件的修改记录确定出代码修改行数,并依据修改内容和修改时间在代码修改行数对应的目标函数添加注释,也就是说,在进行代码注释,能依据及时添加或更新导致代码注释,减少人为添加、更新代码注释的繁琐操作,且能减少注释与代码不一致的情况出现,减少代码注释出错概率。It can be seen from the above device embodiment that the comment information processing device allows the user to determine the number of code modification lines based on the modification record of the project code file, and adds comments to the target function corresponding to the code modification line number according to the modification content and modification time, that is, In other words, code comments can be added or updated in time to cause code comments, reducing the tedious operation of manually adding and updating code comments, and reducing the occurrence of inconsistencies between comments and code, and reducing the probability of code comments.
在一实施例中,所述添加模块具体用于:In an embodiment, the adding module is specifically used for:
确定所述目标函数是否被添加过注释;Determine whether the objective function has been commented;
若确定所述目标函数被添加过注释,则通过所述目标注释信息覆盖所述目标函数的旧注释,以将所述目标注释信息添加至所述目标函数的注释处,或按照注释添加时间先后顺序,将所述目标注释信息添加至所述目标函数的注释处;If it is determined that the objective function has been annotated, the old annotation of the objective function is overwritten by the objective annotation information, so that the objective annotation information is added to the annotation of the objective function, or according to the time sequence of annotation addition Sequentially, adding the target comment information to the comment of the target function;
若确定所述函数未被添加过注释,则将所述目标注释信息添加至所述目标函数的注释处。If it is determined that the function has not been commented, the target comment information is added to the comment of the target function.
若注释信息处理装置确定目标函数被添加过注释,则将所述目标注释信息添加至所述目标函数的注释处。具体地,生成该目标注释信息唯一对应的注释索引号后添加至所述目标函数的注释处。其中,可以不同的字符和/或字符串作为上述注释索引号,由此可见,在本申请实施例中,提出了几种具体将注释天至函数的注释处的方式,提高方案可实施性。If the annotation information processing device determines that the objective function has been annotated, it adds the objective annotation information to the annotation of the objective function. Specifically, a note index number uniquely corresponding to the target note information is generated and added to the note of the target function. Among them, different characters and/or character strings can be used as the above-mentioned annotation index number. It can be seen that in the embodiments of the present application, several specific methods of placing the annotation day to the annotation position of the function are proposed to improve the implementability of the solution.
在一实施例中,所述解析模块具体用于:In an embodiment, the parsing module is specifically configured to:
根据抽象语法树算法对所述项目代码文件进行分析,以获得所述项目代码文件对应的语法树;Analyzing the project code file according to an abstract syntax tree algorithm to obtain a syntax tree corresponding to the project code file;
根据所述代码修改行数对所述语法树进行遍历,以确定所述代码修改行数在所述语法树的节点位置;Traverse the syntax tree according to the number of code modification lines to determine the node position of the code modification line in the syntax tree;
根据所述节点位置确定所述代码修改行数所属的所述目标函数。The objective function to which the code modification line number belongs is determined according to the node position.
如前面所述,在注释信息处理装置根据抽象语法树算法对所述项目代码文件进行分析,以获得所述项目代码文件对应的语法树之后,由于语法树中的项目代码文件中的函数抽象成一个节点,多个具有相互引用关系的节点组成了一条结构链路,节点和结构链路共同反映了各个节点的代码之间的引用、包含以及位置关系,因此在本申请实施例中,可根据所述代码修改行数对所述语法树进行遍历,以确定所述代码修改行数在所述语法树的节点位置。在得到根据所述代码修改行数对所述语法树进行遍历,以确定所述代码修改行数在所述语法树的节点位置之后,依据该节点位置的父节点,即可确定所述代码修改行数所属的所述目标函数。可见,在本申请实施例中提出了一种解析出所述代码修改行数所属的目标函数的方式,提高了方案可实施性。As mentioned above, after the annotation information processing device analyzes the project code file according to the abstract syntax tree algorithm to obtain the syntax tree corresponding to the project code file, the functions in the project code file in the syntax tree are abstracted into For a node, multiple nodes with mutual reference relationships form a structural link. The node and the structural link together reflect the reference, inclusion, and position relationship between the codes of each node. Therefore, in the embodiments of this application, The code modification line number traverses the syntax tree to determine the node position of the code modification line number in the syntax tree. After traversing the syntax tree according to the number of code modification lines to determine that the code modification line number is at the node position of the syntax tree, the code modification can be determined according to the parent node of the node position The objective function to which the number of rows belongs. It can be seen that, in the embodiment of the present application, a method of analyzing the objective function to which the number of code modification lines belongs is proposed, which improves the implementability of the solution.
在一实施例中,所述生成模块具体用于获取用于建立代码注释的规则文件;In an embodiment, the generating module is specifically configured to obtain a rule file for establishing code comments;
根据所述规则文件以及所述修改内容确定注释内容;Determine the annotation content according to the rule file and the modified content;
根据所述修改时间以及所述注释内容生成所述目标注释信息。The target annotation information is generated according to the modification time and the annotation content.
在一实施例中,所述获取模块还用于:所述将所述目标注释信息添加至所述目标函数的注释处之后,获取所述项目代码文件中的每个所述注释对应的注释索引号;In an embodiment, the obtaining module is further configured to: after adding the target comment information to the comment of the target function, obtain the comment index corresponding to each comment in the project code file number;
所述生成模块,还用于根据所述项目代码文件中的所有注释,以及所述所有注 释对应的注释索引号生成注释文本文件。The generating module is also used to generate a comment text file according to all the comments in the project code file and the comment index numbers corresponding to all the comments.
具体地,注释信息处理装置可以注释索引号为关键字从项目代码中获取释索引号对应的注释,并根据所述项目代码文件中的所有注释,以及所述所有注释对应的注释索引号生成注释文本文件。其中,该注释文本文件中说明了此次修改记录中,每个函数的注释,使得编程人员可完整清晰的获取整个项目文件的注释所形成的注释文本文件,便于编程人员查阅浏览,提高用户体验。Specifically, the annotation information processing device can obtain the annotation corresponding to the annotation index number from the project code with the annotation index number as a keyword, and generate the annotation based on all the annotations in the project code file and the annotation index numbers corresponding to all the annotations. Text file. Among them, the comment text file explains the comment of each function in the modification record, so that the programmer can obtain the comment text file formed by the comment of the entire project file completely and clearly, which is convenient for the programmer to browse and improve the user experience. .
关于注释信息处理装置的具体限定可以参见上文中对于注释信息处理方法的限定,在此不再赘述。上述注释信息处理装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific limitation of the annotation information processing device, please refer to the above limitation of the annotation information processing method, which will not be repeated here. Each module in the above-mentioned annotation information processing apparatus can be implemented in whole or in part by software, hardware, and a combination thereof. The foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
在一个实施例中,提供了一种计算机设备,该计算机设备可以是上述注释信息处理装置,其内部结构图可以如图8所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于存储修改记录等。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令被处理器执行时以实现一种注释信息处理方法。In one embodiment, a computer device is provided. The computer device may be the above-mentioned annotation information processing apparatus, and its internal structure diagram may be as shown in FIG. 8. The computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide calculation and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer readable instructions, and a database. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium. The database of the computer equipment is used to store modification records, etc. The network interface of the computer device is used to communicate with an external terminal through a network connection. The computer-readable instruction is executed by the processor to realize a method for processing annotation information.
在一个实施例中,提供了一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机可读指令,处理器执行计算机可读指令时实现以下步骤:In one embodiment, a computer device is provided, including a memory, a processor, and computer-readable instructions stored in the memory and capable of running on the processor, and the processor implements the following steps when the processor executes the computer-readable instructions:
获取用户对项目代码文件的修改记录;Obtain the user's modification record of the project code file;
根据所述修改记录确定所述项目代码文件的代码修改行数,以及所述代码修改行数对应的修改内容和修改时间;Determine, according to the modification record, the number of code modification lines of the project code file, and the modification content and modification time corresponding to the code modification line number;
解析所述代码修改行数所属的目标函数;Parsing the objective function to which the code modification line number belongs;
根据所述修改内容以及所述修改时间生成目标注释信息;Generating target annotation information according to the modification content and the modification time;
将所述目标注释信息添加至所述目标函数的注释处。The target comment information is added to the comment of the target function.
需要说明的是,处理器执行计算机可读指令时实现上述步骤的详细内容,可对应参阅前述注释信息处理方法对应的描述,这里不再重复描述。It should be noted that, for the detailed content of the above steps when the processor executes the computer-readable instructions, please refer to the corresponding description of the aforementioned annotation information processing method, and the description will not be repeated here.
在一个实施例中,提供了一个或多个存储有计算机可读指令的可读存储介质,所述可读存储介质包括非易失性可读存储介质和易失性可读存储介质所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行如下步骤:In one embodiment, one or more readable storage media storing computer readable instructions are provided. The readable storage medium includes a non-volatile readable storage medium and a volatile readable storage medium. When the readable instructions are executed by one or more processors, the one or more processors execute the following steps:
获取用户对项目代码文件的修改记录;Obtain the user's modification record of the project code file;
根据所述修改记录确定所述项目代码文件的代码修改行数,以及所述代码修改行数对应的修改内容和修改时间;Determine, according to the modification record, the number of code modification lines of the project code file, and the modification content and modification time corresponding to the code modification line number;
解析所述代码修改行数所属的目标函数;Parsing the objective function to which the code modification line number belongs;
根据所述修改内容以及所述修改时间生成目标注释信息;Generating target annotation information according to the modification content and the modification time;
将所述目标注释信息添加至所述目标函数的注释处。The target comment information is added to the comment of the target function.
需要说明的是,计算机可读指令被处理器执行时实现上述步骤的详细内容,可对应参阅前述注释信息处理方法对应的描述,这里不再重复描述。It should be noted that, for the detailed content of implementing the above steps when the computer-readable instructions are executed by the processor, please refer to the corresponding description of the aforementioned annotation information processing method, and the description will not be repeated here.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一非易失性计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing relevant hardware through computer-readable instructions, which can be stored in a non-volatile computer. In a readable storage medium, when the computer-readable instructions are executed, they may include the processes of the above-mentioned method embodiments. Wherein, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and/or volatile memory. Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not a limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。Those skilled in the art can clearly understand that for the convenience and conciseness of description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned functions can be allocated to different functional units and modules as required. Module completion means dividing the internal structure of the device into different functional units or modules to complete all or part of the functions described above.
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that it can still implement the foregoing The technical solutions recorded in the examples are modified, or some of the technical features are equivalently replaced; these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the application, and should be included in Within the scope of protection of this application.

Claims (20)

  1. 一种注释信息处理方法,其特征在于,包括:An annotation information processing method, characterized in that it comprises:
    获取用户对项目代码文件的修改记录;Obtain the user's modification record of the project code file;
    根据所述修改记录确定所述项目代码文件的代码修改行数,以及Determine the number of code modification lines of the project code file according to the modification record, and
    所述代码修改行数对应的修改内容和修改时间;The modification content and modification time corresponding to the number of code modification lines;
    解析所述代码修改行数所属的目标函数;Parsing the objective function to which the code modification line number belongs;
    根据所述修改内容以及所述修改时间生成目标注释信息;Generating target annotation information according to the modification content and the modification time;
    将所述目标注释信息添加至所述目标函数的注释处。The target comment information is added to the comment of the target function.
  2. 如权利要求1所述的注释信息处理方法,其特征在于,所述将所述目标注释信息添加至所述目标函数注释处,包括:The annotation information processing method according to claim 1, wherein the adding the target annotation information to the target function annotation includes:
    确定所述目标函数是否被添加过注释;Determine whether the objective function has been commented;
    若确定所述目标函数被添加过注释,则通过所述目标注释信息覆盖所述目标函数的旧注释,以将所述目标注释信息添加至所述目标函数的注释处,或按照注释添加时间先后顺序,将所述目标注释信息添加至所述目标函数的注释处;If it is determined that the objective function has been annotated, the old annotation of the objective function is overwritten by the objective annotation information, so that the objective annotation information is added to the annotation of the objective function, or according to the time sequence of annotation addition Sequentially, adding the target comment information to the comment of the target function;
    若确定所述函数未被添加过注释,则将所述目标注释信息添加至所述目标函数的注释处。If it is determined that the function has not been commented, the target comment information is added to the comment of the target function.
  3. 如权利要求1所述的注释信息处理方法,其特征在于,所述解析出所述代码修改行数所属的目标函数,包括:5. The annotation information processing method according to claim 1, wherein said parsing out the objective function to which the number of code modification lines belongs comprises:
    根据抽象语法树算法对所述项目代码文件进行分析,以获得所述项目代码文件对应的语法树;Analyzing the project code file according to an abstract syntax tree algorithm to obtain a syntax tree corresponding to the project code file;
    根据所述代码修改行数对所述语法树进行遍历,以确定所述代码修改函数在所述语法树的节点位置;Traversing the syntax tree according to the number of code modification lines to determine the node position of the code modification function in the syntax tree;
    根据所述节点位置确定所述代码修改行数所属的所述目标函数。The objective function to which the code modification line number belongs is determined according to the node position.
  4. 如权利要求1所述的注释信息处理方法,其特征在于,所述根据所述修改内容以及所述修改时间生成目标注释信息,包括:The annotation information processing method according to claim 1, wherein said generating target annotation information according to said modified content and said modification time comprises:
    获取用于建立代码注释的规则文件;Obtain the rule file used to create code comments;
    根据所述规则文件以及所述修改内容确定注释内容;Determine the annotation content according to the rule file and the modified content;
    根据所述修改时间以及所述注释内容生成所述目标注释信息。The target annotation information is generated according to the modification time and the annotation content.
  5. 如权利要求1所述的注释信息处理方法,其特征在于,所述将所述目标注释信息添加至所述目标函数的注释处之后,所述方法还包括:5. The annotation information processing method according to claim 1, wherein after adding the target annotation information to the annotation of the objective function, the method further comprises:
    获取所述项目代码文件中的每个所述注释对应的注释索引号;Obtaining a comment index number corresponding to each comment in the project code file;
    根据所述项目代码文件中的所有注释,以及所述所有注释对应的注释索引号生成注释文本文件。Generate a comment text file according to all the comments in the project code file and the comment index numbers corresponding to all the comments.
  6. 一种注释信息处理装置,其特征在于,包括:An annotation information processing device, characterized by comprising:
    获取模块,用于获取用户对项目代码文件的修改记录;The acquisition module is used to acquire the user's modification record of the project code file;
    确定模块,用于根据获取获取模块获取的所述修改记录确定所述项目代码文件的代码修改行数,以及所述代码修改行数对应的修改内容和修改时间;The determining module is configured to determine the number of code modification lines of the project code file, and the modification content and modification time corresponding to the code modification line number according to the modification record acquired by the acquiring module;
    解析模块,用于解析所述确定模块确定的所述代码修改行数所属的目标函数;A parsing module for parsing the objective function to which the number of code modification lines determined by the determining module belongs;
    生成模块,用于根据所述获取模块获取的所述修改内容以及所述修改时间生成目标注释信息;A generating module, configured to generate target annotation information according to the modification content and the modification time acquired by the acquiring module;
    添加模块,用于将所述生成模块生成的所述目标注释信息添加至所述目标函数的注释处。The adding module is used to add the target annotation information generated by the generating module to the annotation of the target function.
  7. 如权利要求6所述的注释信息处理装置,其特征在于,所述添加模块具体用于:8. The annotation information processing device according to claim 6, wherein the adding module is specifically configured to:
    确定所述目标函数是否被添加过注释;Determine whether the objective function has been commented;
    若确定所述目标函数被添加过注释,则通过所述目标注释信息覆盖所述目标函数的旧注释,以将所述目标注释信息添加至所述目标函数的注释处,或按照注释添加时间先后顺序,将所述目标注释信息添加至所述目标函数的注释处;If it is determined that the objective function has been annotated, the old annotation of the objective function is overwritten by the objective annotation information, so that the objective annotation information is added to the annotation of the objective function, or according to the time sequence of annotation addition Sequentially, adding the target comment information to the comment of the target function;
    若确定所述函数未被添加过注释,则将所述目标注释信息添加至所述目标函数的注释处。If it is determined that the function has not been commented, the target comment information is added to the comment of the target function.
  8. 如权利要求6所述的注释信息处理装置,其特征在于,所述解析模 块具体用于:The annotation information processing device according to claim 6, wherein the analysis module is specifically used for:
    根据抽象语法树算法对所述项目代码文件进行分析,以获得所述项目代码文件对应的语法树;Analyzing the project code file according to an abstract syntax tree algorithm to obtain a syntax tree corresponding to the project code file;
    根据所述代码修改行数对所述语法树进行遍历,以确定所述代码修改行数在所述语法树的节点位置;Traverse the syntax tree according to the number of code modification lines to determine the node position of the code modification line in the syntax tree;
    根据所述节点位置确定所述代码修改行数所属的所述目标函数。The objective function to which the code modification line number belongs is determined according to the node position.
  9. 如权利要求6所述的注释信息处理装置,其特征在于,所述生成模块具体用于:8. The annotation information processing device according to claim 6, wherein the generating module is specifically configured to:
    获取用于建立代码注释的规则文件;Obtain the rule file used to create code comments;
    根据所述规则文件以及所述修改内容确定注释内容;Determine the annotation content according to the rule file and the modified content;
    根据所述修改时间以及所述注释内容生成所述目标注释信息。The target annotation information is generated according to the modification time and the annotation content.
  10. 如权利要求6所述的注释信息处理装置,其特征在于,所述生成模块还用于:8. The annotation information processing device according to claim 6, wherein the generating module is further configured to:
    获取所述项目代码文件中的每个所述注释对应的注释索引号;Obtaining a comment index number corresponding to each comment in the project code file;
    根据所述项目代码文件中的所有注释,以及所述所有注释对应的注释索引号生成注释文本文件。Generate a comment text file according to all the comments in the project code file and the comment index numbers corresponding to all the comments.
  11. 一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如下步骤:A computer device includes a memory, a processor, and computer-readable instructions stored in the memory and capable of running on the processor, wherein the processor executes the computer-readable instructions as follows step:
    获取用户对项目代码文件的修改记录;Obtain the user's modification record of the project code file;
    根据所述修改记录确定所述项目代码文件的代码修改行数,以及所述代码修改行数对应的修改内容和修改时间;Determine, according to the modification record, the number of code modification lines of the project code file, and the modification content and modification time corresponding to the code modification line number;
    解析所述代码修改行数所属的目标函数;Parsing the objective function to which the code modification line number belongs;
    根据所述修改内容以及所述修改时间生成目标注释信息;Generating target annotation information according to the modification content and the modification time;
    将所述目标注释信息添加至所述目标函数的注释处。The target comment information is added to the comment of the target function.
  12. 如权利要求11所述的计算机设备,其特征在于,所述将所述目标注释信息添加至所述目标函数注释处,包括:The computer device of claim 11, wherein the adding the target annotation information to the target function annotation includes:
    确定所述目标函数是否被添加过注释;Determine whether the objective function has been commented;
    若确定所述目标函数被添加过注释,则通过所述目标注释信息覆盖所述目标函数的旧注释,以将所述目标注释信息添加至所述目标函数的注释处,或按照注释添加时间先后顺序,将所述目标注释信息添加至所述目标函数的注释处;If it is determined that the objective function has been annotated, the old annotation of the objective function is overwritten by the objective annotation information, so that the objective annotation information is added to the annotation of the objective function, or according to the time sequence of annotation addition Sequentially, adding the target comment information to the comment of the target function;
    若确定所述函数未被添加过注释,则将所述目标注释信息添加至所述目标函数的注释处。If it is determined that the function has not been commented, the target comment information is added to the comment of the target function.
  13. 如权利要求11所述的计算机设备,其特征在于,所述解析出所述代码修改行数所属的目标函数,包括:11. The computer device according to claim 11, wherein said parsing out the objective function to which the number of code modification lines belongs comprises:
    根据抽象语法树算法对所述项目代码文件进行分析,以获得所述项目代码文件对应的语法树;Analyzing the project code file according to an abstract syntax tree algorithm to obtain a syntax tree corresponding to the project code file;
    根据所述代码修改行数对所述语法树进行遍历,以确定所述代码修改函数在所述语法树的节点位置;Traversing the syntax tree according to the number of code modification lines to determine the node position of the code modification function in the syntax tree;
    根据所述节点位置确定所述代码修改行数所属的所述目标函数。The objective function to which the code modification line number belongs is determined according to the node position.
  14. 如权利要求11所述的计算机设备,其特征在于,所述根据所述修改内容以及所述修改时间生成目标注释信息,包括:11. The computer device according to claim 11, wherein said generating target annotation information according to said modification content and said modification time comprises:
    获取用于建立代码注释的规则文件;Obtain the rule file used to create code comments;
    根据所述规则文件以及所述修改内容确定注释内容;Determine the annotation content according to the rule file and the modified content;
    根据所述修改时间以及所述注释内容生成所述目标注释信息。The target annotation information is generated according to the modification time and the annotation content.
  15. 如权利要求11所述的计算机设备,其特征在于,所述处理器执行所述计算机可读指令时还包括如下步骤:The computer device according to claim 11, wherein the processor further comprises the following steps when executing the computer-readable instruction:
    将所述目标注释信息添加至所述目标函数的注释处之后,获取所述项目代码文件中的每个所述注释对应的注释索引号;After adding the target comment information to the comment of the target function, obtain the comment index number corresponding to each comment in the project code file;
    根据所述项目代码文件中的所有注释,以及所述所有注释对应的注释索引号生成注释文本文件。Generate a comment text file according to all the comments in the project code file and the comment index numbers corresponding to all the comments.
  16. 一个或多个存储有计算机可读指令的可读存储介质,其特征在于,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行如下步骤:One or more readable storage media storing computer readable instructions, wherein when the computer readable instructions are executed by one or more processors, the one or more processors execute the following steps:
    获取用户对项目代码文件的修改记录;Obtain the user's modification record of the project code file;
    根据所述修改记录确定所述项目代码文件的代码修改行数,以及Determine the number of code modification lines of the project code file according to the modification record, and
    所述代码修改行数对应的修改内容和修改时间;The modification content and modification time corresponding to the number of code modification lines;
    解析所述代码修改行数所属的目标函数;Parsing the objective function to which the code modification line number belongs;
    根据所述修改内容以及所述修改时间生成目标注释信息;Generating target annotation information according to the modification content and the modification time;
    将所述目标注释信息添加至所述目标函数的注释处。The target comment information is added to the comment of the target function.
  17. 如权利要求16所述的可读存储介质,其特征在于,所述将所述目标注释信息添加至所述目标函数注释处,包括:The readable storage medium of claim 16, wherein the adding the target annotation information to the target function annotation includes:
    确定所述目标函数是否被添加过注释;Determine whether the objective function has been commented;
    若确定所述目标函数被添加过注释,则通过所述目标注释信息覆盖所述目标函数的旧注释,以将所述目标注释信息添加至所述目标函数的注释处,或按照注释添加时间先后顺序,将所述目标注释信息添加至所述目标函数的注释处;If it is determined that the objective function has been annotated, the old annotation of the objective function is overwritten by the objective annotation information, so that the objective annotation information is added to the annotation of the objective function, or according to the time sequence of annotation addition Sequentially, adding the target comment information to the comment of the target function;
    若确定所述函数未被添加过注释,则将所述目标注释信息添加至所述目标函数的注释处。If it is determined that the function has not been commented, the target comment information is added to the comment of the target function.
  18. 如权利要求16所述的可读存储介质,其特征在于,所述解析出所述代码修改行数所属的目标函数,包括:The readable storage medium of claim 16, wherein the parsing to obtain the objective function to which the number of code modification lines belongs comprises:
    根据抽象语法树算法对所述项目代码文件进行分析,以获得所述项目代码文件对应的语法树;Analyzing the project code file according to an abstract syntax tree algorithm to obtain a syntax tree corresponding to the project code file;
    根据所述代码修改行数对所述语法树进行遍历,以确定所述代码修改函数在所述语法树的节点位置;Traversing the syntax tree according to the number of code modification lines to determine the node position of the code modification function in the syntax tree;
    根据所述节点位置确定所述代码修改行数所属的所述目标函数。The objective function to which the code modification line number belongs is determined according to the node position.
  19. 如权利要求16所述的可读存储介质,其特征在于,所述根据所述修改内容以及所述修改时间生成目标注释信息,包括:15. The readable storage medium of claim 16, wherein the generating target annotation information according to the modified content and the modification time comprises:
    获取用于建立代码注释的规则文件;Obtain the rule file used to create code comments;
    根据所述规则文件以及所述修改内容确定注释内容;Determine the annotation content according to the rule file and the modified content;
    根据所述修改时间以及所述注释内容生成所述目标注释信息。The target annotation information is generated according to the modification time and the annotation content.
  20. 如权利要求16所述的可读存储介质,其特征在于,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器 还执行如下步骤:The readable storage medium of claim 16, wherein when the computer readable instructions are executed by one or more processors, the one or more processors further execute the following steps:
    将所述目标注释信息添加至所述目标函数的注释处之后,获取所述项目代码文件中的每个所述注释对应的注释索引号;After adding the target comment information to the comment of the target function, obtain the comment index number corresponding to each comment in the project code file;
    根据所述项目代码文件中的所有注释,以及所述所有注释对应的注释索引号生成注释文本文件。Generate a comment text file according to all the comments in the project code file and the comment index numbers corresponding to all the comments.
PCT/CN2019/116179 2019-07-11 2019-11-07 Method and device for processing annotation information, computer apparatus, and storage medium WO2021003913A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910625168.4A CN110471694A (en) 2019-07-11 2019-07-11 Annotation information processing method, device, computer equipment and storage medium
CN201910625168.4 2019-07-11

Publications (1)

Publication Number Publication Date
WO2021003913A1 true WO2021003913A1 (en) 2021-01-14

Family

ID=68507993

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/116179 WO2021003913A1 (en) 2019-07-11 2019-11-07 Method and device for processing annotation information, computer apparatus, and storage medium

Country Status (2)

Country Link
CN (1) CN110471694A (en)
WO (1) WO2021003913A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115688072A (en) * 2023-01-05 2023-02-03 武汉星碑科技有限公司 Distributed project management method based on big data

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112463210A (en) * 2020-12-04 2021-03-09 上海路人王信息科技有限公司 Interface document generation method, terminal device and computer-readable storage medium
CN112698821B (en) * 2021-01-12 2024-03-26 北京字节跳动网络技术有限公司 Code labeling method, device, computer equipment, medium and system
CN113094036B (en) * 2021-04-19 2022-09-27 罗普特科技集团股份有限公司 Software engineering directory structure annotation aerial view generation method and system
CN113495753A (en) * 2021-07-06 2021-10-12 北京百度网讯科技有限公司 Project label acquisition method and device, electronic equipment and storage medium
CN113609138B (en) * 2021-09-30 2022-01-25 成都数联云算科技有限公司 Class and database table matching method, device, equipment and medium
CN114840250B (en) * 2022-07-04 2022-10-04 金现代信息产业股份有限公司 Code conflict merging method and system, electronic equipment and readable storage medium
CN116302218B (en) * 2023-03-15 2024-05-10 北京百度网讯科技有限公司 Function information adding method, device, equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105824794A (en) * 2016-03-11 2016-08-03 天脉聚源(北京)教育科技有限公司 Annotation adding method and device
CN107545030A (en) * 2017-07-17 2018-01-05 阿里巴巴集团控股有限公司 Processing method, device and the equipment of data genetic connection
CN107885499A (en) * 2017-10-19 2018-04-06 平安壹钱包电子商务有限公司 A kind of interface document generation method and terminal device

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6874140B1 (en) * 2000-07-31 2005-03-29 Microsoft Corporation Debug annotations
CN103678110B (en) * 2012-09-26 2016-03-30 国际商业机器公司 The method and apparatus of amendment relevant information is provided
CN106055334B (en) * 2016-06-01 2019-05-31 努比亚技术有限公司 Code management system and method
CN107016047A (en) * 2017-02-20 2017-08-04 阿里巴巴集团控股有限公司 Document query, document storing method and device
CN108228231B (en) * 2018-01-08 2021-07-27 南京邮电大学 Visualization drifting method of Git warehouse file annotation system
CN108628635B (en) * 2018-05-07 2021-12-14 广州视源电子科技股份有限公司 Method, device, equipment and storage medium for acquiring parameter name and local variable name
CN109828783A (en) * 2018-12-15 2019-05-31 中国平安人寿保险股份有限公司 Document automatic creation method, device, electronic equipment and medium based on code
CN109857390B (en) * 2019-01-16 2022-05-31 南京邮电大学 Annotation transmission method of Git warehouse file annotation system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105824794A (en) * 2016-03-11 2016-08-03 天脉聚源(北京)教育科技有限公司 Annotation adding method and device
CN107545030A (en) * 2017-07-17 2018-01-05 阿里巴巴集团控股有限公司 Processing method, device and the equipment of data genetic connection
CN107885499A (en) * 2017-10-19 2018-04-06 平安壹钱包电子商务有限公司 A kind of interface document generation method and terminal device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115688072A (en) * 2023-01-05 2023-02-03 武汉星碑科技有限公司 Distributed project management method based on big data

Also Published As

Publication number Publication date
CN110471694A (en) 2019-11-19

Similar Documents

Publication Publication Date Title
WO2021003913A1 (en) Method and device for processing annotation information, computer apparatus, and storage medium
US10067993B2 (en) Post-migration validation of ETL jobs and exception management
US9519700B2 (en) Automatically synchronizing production data of a source system and a target system
US20240045850A1 (en) Systems and methods for database orientation transformation
US10592220B2 (en) Metadata-driven binding of converted source code to original source code
US10585655B2 (en) Systems and methods for automated retrofitting of customized code objects
CN107016047A (en) Document query, document storing method and device
WO2022227314A1 (en) Method and apparatus for dynamic synchronous testing, device, and storage medium
CN111737227A (en) Data modification method and system
WO2021051501A1 (en) Sql extraction method and apparatus, computer device, and storage medium
US10592400B2 (en) System and method for creating variants in a test database during various test stages
CN111782207A (en) Method, device and equipment for generating task stream code and storage medium
US20170010955A1 (en) System and method for facilitating change based testing of a software code using annotations
US20190361684A1 (en) Systems and methods for providing an application transformation tool
CN111124872A (en) Branch detection method and device based on difference code analysis and storage medium
WO2021022702A1 (en) Log insertion method and apparatus, computer apparatus and storage medium
CN111796855A (en) Incremental version updating method and device, storage medium and computer equipment
JP7131119B2 (en) Systems and methods for merging source data from a source application with target data in a target application
CN115129598A (en) Risk detection method, device, system and medium for SQL (structured query language) statements
US20150033213A1 (en) Compiling method, storage medium and compiling apparatus
JP2024506528A (en) System and method for database migration in application environment migration
WO2021042532A1 (en) Database information analysis method and apparatus, computer apparatus, and storage medium
US10606577B1 (en) System and method for assuring customers during software deployment
CN116627390B (en) ICD file substitution method and device in aviation software development
CN115964075B (en) Application export import method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19937018

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 16/05/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 19937018

Country of ref document: EP

Kind code of ref document: A1