CN112698821A - Code labeling method, device, computer equipment, medium and system - Google Patents

Code labeling method, device, computer equipment, medium and system Download PDF

Info

Publication number
CN112698821A
CN112698821A CN202110036104.8A CN202110036104A CN112698821A CN 112698821 A CN112698821 A CN 112698821A CN 202110036104 A CN202110036104 A CN 202110036104A CN 112698821 A CN112698821 A CN 112698821A
Authority
CN
China
Prior art keywords
code
file
target
snapshot
annotation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110036104.8A
Other languages
Chinese (zh)
Other versions
CN112698821B (en
Inventor
刘杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202110036104.8A priority Critical patent/CN112698821B/en
Publication of CN112698821A publication Critical patent/CN112698821A/en
Application granted granted Critical
Publication of CN112698821B publication Critical patent/CN112698821B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/128Details of file system snapshots on the file-level, e.g. snapshot creation, administration, deletion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/117Tagging; Marking up; Designating a block; Setting of attributes

Abstract

The present disclosure provides a code annotation method, apparatus, computer device, medium, and system, wherein a snapshot change notification message is sent to a code annotation server via a code management platform, the code annotation server obtains a first annotation data file corresponding to a reference code snapshot from a database according to an identifier of the reference code snapshot, and determines the corresponding relation between the reference line number of the reference code file and the target line number of the target code file according to the code modification information, according to the corresponding relation, determining the marking data of the reference line number as the marking data of the corresponding target line number, generating a second sub marking data file corresponding to the target code file, generating a second annotation data file corresponding to the target code snapshot according to the second sub-annotation data file, therefore, the target code file does not need to be marked based on a scanning tool or a manual mode, and the code marking efficiency is improved.

Description

Code labeling method, device, computer equipment, medium and system
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a code labeling method, apparatus, computer device, medium, and system.
Background
With the rapid development of computer technology, the traffic volume of software projects is also rapidly increasing. Software developers usually label codes in the process of code development so as to conveniently carry out code quality review. For example, the status label of the overlay, the status label of the sensitive word, the static code scan label or the comment label, etc.
After the original code is modified, the markup data file corresponding to the original code will be invalidated, for example, the 10 th row obsolete code is recorded in the markup data file corresponding to the original code, and if the 9 th row and the 10 th row of the original code are deleted, the 10 th row is actually the original 12 th row, so the markup data file corresponding to the original code will be invalidated. In the prior art, after an original code is modified, the modified code is re-labeled to generate a new labeled data file.
However, with the prior art methods, the efficiency of code labeling is not high.
Disclosure of Invention
In order to solve the technical problem, the present disclosure provides a code labeling method, apparatus, computer device, medium, and system.
A first aspect of the present disclosure provides a code labeling method, including:
receiving a snapshot change notification message sent by a code management platform, wherein the snapshot change notification message comprises: the identification of the target code snapshot, the identification of the reference code snapshot and the code modification information; the target code snapshot comprises one or more target code files, the reference code snapshot comprises one or more reference code files, and the code modification information comprises an identifier of a target code file, an identifier of a reference code file corresponding to the target code file and line modification information;
acquiring a first annotation data file corresponding to the reference code snapshot from a database according to the identifier of the reference code snapshot, wherein the first annotation data file comprises at least one first sub-annotation data file, and one first sub-annotation data file corresponds to one reference code file;
determining the corresponding relation between the reference line number of the reference code file and the target line number of the target code file according to the code modification information;
according to the corresponding relation, determining the marking data of the reference line number of the reference code file as the marking data of the corresponding target line number of the target code file, and generating a second sub marking data file corresponding to the target code file;
and generating a second annotation data file corresponding to the target code snapshot according to the second sub-annotation data file, wherein the second annotation data comprises the second sub-annotation data file.
Optionally, the line modification information includes: a reference line number and a line offset of the reference code file;
the determining the corresponding relationship between the reference line number of the reference code file and the target line number of the target code file according to the code modification information includes:
obtaining a target line number of the target code file corresponding to the reference line number of the reference code file according to the reference line number and the line offset of the reference code file;
and determining the corresponding relation between the reference line number of the reference code file and the target line number of the target code file.
Optionally, the line modification information includes: and the corresponding relation between the reference line number of the reference code file and the target line number of the target code file.
Optionally, before the obtaining, according to the identifier of the reference code snapshot, the first annotation data file corresponding to the reference code snapshot from the database, the method further includes:
acquiring a marked reference code snapshot from a code management platform;
acquiring a first labeled data file corresponding to the reference code snapshot based on the labeled reference code snapshot;
and storing the first annotation data file into the database.
Optionally, the method further includes:
receiving a first access request sent by an annotation access server, wherein the first access request comprises: identification of the target code snapshot; and sending a second annotation data file corresponding to the target code snapshot to the annotation access server.
Optionally, the method further includes:
receiving a second access request sent by an annotation access server, wherein the second access request comprises: the identity of the target code snapshot and the identity of the target code file;
and sending a second sub-annotation data file corresponding to the target code file to the annotation access server.
Optionally, the method further includes:
receiving an annotation data modification request sent by an annotation access server, wherein the annotation data modification request comprises: marking data modification information;
and responding to the annotation data modification request, and modifying the second annotation data file according to the annotation data modification information.
A second aspect of the present disclosure provides a code labeling apparatus, including:
a receiving module, configured to receive a snapshot change notification message sent by a code management platform, where the snapshot change notification message includes: the identification of the target code snapshot, the identification of the reference code snapshot and the code modification information; the target code snapshot comprises one or more target code files, the reference code snapshot comprises one or more reference code files, and the code modification information comprises an identifier of a target code file, an identifier of a reference code file corresponding to the target code file and line modification information;
the processing module is used for acquiring a first annotation data file corresponding to the reference code snapshot from a database according to the identifier of the reference code snapshot, wherein the first annotation data file comprises at least one first sub-annotation data file, and one first sub-annotation data file corresponds to one reference code file;
the processing module is further used for determining the corresponding relation between the reference line number of the reference code file and the target line number of the target code file according to the code modification information;
the processing module is further configured to determine, according to the correspondence, the annotation data of the reference line number of the reference code file as the annotation data of the corresponding target line number of the target code file, and generate a second sub-annotation data file corresponding to the target code file;
the processing module is further configured to generate a second annotated data file corresponding to the target code snapshot according to the second sub-annotated data file, where the second annotated data includes the second sub-annotated data file.
Optionally, the line modification information includes: a reference line number and a line offset of the reference code file;
the processing module is specifically configured to obtain a target line number of the target code file corresponding to the reference line number of the reference code file according to the reference line number of the reference code file and the line offset; and determining the corresponding relation between the reference line number of the reference code file and the target line number of the target code file.
Optionally, the line modification information includes: and the corresponding relation between the reference line number of the reference code file and the target line number of the target code file.
Optionally, the receiving module is further configured to obtain the annotated reference code snapshot from the code management platform;
the processing module is further used for acquiring a first labeled data file corresponding to the reference code snapshot based on the labeled reference code snapshot;
the processing module is further configured to store the first annotation data file in the database.
Optionally, the receiving module is further configured to receive a first access request sent by an annotation access server, where the first access request includes: identification of the target code snapshot;
and the sending module is used for sending a second annotation data file corresponding to the target code snapshot to the annotation access server.
Optionally, the receiving module is further configured to receive a second access request sent by the annotation access server, where the second access request includes: the identity of the target code snapshot and the identity of the target code file;
and the sending module is used for sending the second sub-annotation data file corresponding to the target code file to the annotation access server.
Optionally, the receiving module is further configured to receive an annotation data modification request sent by an annotation access server, where the annotation data modification request includes: marking data modification information;
the processing module is further configured to respond to the annotation data modification request, and modify the second annotation data file according to the annotation data modification information.
A third aspect of the present disclosure provides a computer device comprising: a processor for executing a computer program stored in a memory, the computer program, when executed by the processor, implementing the steps of the method of any of the first aspects.
A fourth aspect of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method of any of the first aspects.
A fifth aspect of the present disclosure provides a code labeling system, comprising: the system comprises a code management platform and a code marking server;
the code management platform is used for sending a snapshot change notification message to the code annotation server; the snapshot change notification message includes: the identification of the target code snapshot, the identification of the reference code snapshot and the code modification information; the target code snapshot comprises one or more target code files, the reference code snapshot comprises one or more reference code files, and the code modification information comprises an identifier of a target code file, an identifier of a reference code file corresponding to the target code file and line modification information;
the code annotation server is used for acquiring a first annotation data file corresponding to the reference code snapshot from a database according to the identifier of the reference code snapshot, wherein the first annotation data file comprises at least one first sub-annotation data file, and one first sub-annotation data file corresponds to one reference code file; determining the corresponding relation between the reference line number of the reference code file and the target line number of the target code file according to the code modification information; according to the corresponding relation, determining the marking data of the reference line number of the reference code file as the marking data of the corresponding target line number of the target code file, and generating a second sub marking data file corresponding to the target code file; and generating a second annotation data file corresponding to the target code snapshot according to the second sub-annotation data file, wherein the second annotation data comprises the second sub-annotation data file.
Optionally, the method further includes: marking an access server;
the annotation access server is configured to send a first access request or a second access request to the code annotation server, where the first access request includes: identification of a target code snapshot, the second access request including: the identity of the target code snapshot and the identity of the target code file;
accordingly;
the code annotation server is also used for sending a second annotation data file corresponding to the target code snapshot to the annotation access server; or sending a second sub-annotation data file corresponding to the target code file to the annotation access server.
Optionally, the annotation access server is further configured to send an annotation data modification request to the code annotation server, where the annotation data modification request includes: marking data modification information;
correspondingly, the code annotation server is further configured to respond to the annotation data modification request, and modify the second annotation data file according to the annotation data modification information.
Compared with the prior art, the technical scheme provided by the embodiment of the disclosure has the following advantages:
sending a snapshot change notification message to a code annotation server through a code management platform, wherein the code annotation server acquires a first annotation data file corresponding to a reference code snapshot from a database according to the identifier of the reference code snapshot, wherein the first annotation data file comprises at least one first sub-annotation data file, one first sub-annotation data file corresponds to one reference code file, the corresponding relation between a reference line number of the reference code file and a target line number of a target code file is determined according to code modification information, the annotation data of the reference line number is determined as the annotation data of the corresponding target line number according to the corresponding relation, a second sub-annotation data file corresponding to the target code file is generated, a second annotation data file corresponding to the target code snapshot is generated according to the second sub-annotation data file, and therefore, the target code file is not required to be annotated based on a scanning tool or in a manual mode, the efficiency of code marking is improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present disclosure, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
FIG. 1 is a schematic diagram of a system architecture provided by the present disclosure;
FIG. 2 is a schematic flow chart of a code labeling method according to the present disclosure;
FIG. 3 is a schematic flow chart of another code labeling method provided by the present disclosure;
FIG. 4 is a schematic flow chart of yet another code labeling method provided by the present disclosure;
FIG. 5 is a schematic flow chart of another code labeling method provided by the present disclosure;
FIG. 6 is a schematic flow chart of another code labeling method provided by the present disclosure;
fig. 7 is a schematic structural diagram of a code labeling apparatus provided in the present disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, aspects of the present disclosure will be further described below. It should be noted that the embodiments and features of the embodiments of the present disclosure may be combined with each other without conflict.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced in other ways than those described herein; it is to be understood that the embodiments disclosed in the specification are only a few embodiments of the present disclosure, and not all embodiments.
Fig. 1 is a schematic diagram of a system architecture provided in the present disclosure, the system architecture including: the system comprises a code management platform 101, a code annotation server 102 and an annotation access server 103, wherein the code management platform 101, the code annotation server 102 and the annotation access server 103 are in communication connection with each other.
The code management platform 101 is used for storing and managing code files developed by developers. The code annotation server 102 is configured to annotate a code in a code file, where the code annotation server may be a cloud server or a local server. The annotation access server 103 is configured to access the code annotation server to obtain annotation data corresponding to the code file, and view or modify the annotation data.
In the process of software code development, local modification is usually required to be performed on a code snapshot on the basis of a previous code snapshot so as to complete the functions that can be realized by the code. Wherein a code snapshot may contain one or more code files. For convenience of description, the previous code snapshot is described as a reference code snapshot, a code snapshot formed after modification on the basis of the reference code snapshot is described as a target code snapshot, a code file in the reference code snapshot is described as a reference code file, and a code file in the target code snapshot is described as a target code file. One object code snapshot contains one or more object code files and one reference code snapshot contains one or more reference code files. In the present disclosure, the line number of the reference code file is also described as a reference line number, and the line number of the target code file is described as a target line number. The code in the target code snapshot is also the code that the present disclosure requires for code annotation.
The technical solution of the present disclosure is described below in several specific embodiments.
Fig. 2 is a schematic flow chart of a code labeling method provided by the present disclosure, and as shown in fig. 2, the method of this embodiment is as follows:
s201: and the code management platform sends a snapshot change notification message to the code annotation server.
Wherein, the snapshot change notification message includes: the code modification information is used for indicating the modified content of the target code snapshot relative to the reference code snapshot. For example, the code modification information may include an identifier of the object code file, an identifier of a reference code file corresponding to the object code file, and line modification information.
And when the developer modifies the reference code snapshot, a target code snapshot is formed after the modification is completed, and the target code snapshot is uploaded to the code management platform.
The code management platform may obtain the code modification information through, but not limited to, the following possible implementation manners.
One possible implementation: and the code management platform compares the target code snapshot with the reference code snapshot to generate code modification information.
Another possible implementation: the developer instructs the code modification information while uploading the snapshot of the target code.
After receiving the target code snapshot, the code management platform generates a snapshot change notification message and sends the snapshot change notification message to the code annotation server.
S202: and the code annotation server acquires a first annotation data file corresponding to the reference code snapshot from a database according to the identifier of the reference code snapshot.
Optionally, the first annotation data file is named according to the identifier of the reference code snapshot, for example, the first annotation data file may be named according to the identifier of the reference code snapshot.
Optionally, the first sub-annotation data file is named according to the identifier of the reference code file, for example, the first sub-annotation data file may be named according to the identifier of the reference code file.
The first sub-annotation data file comprises: the line number and the marking data corresponding to the line number; it should be noted that, in a file, not all rows are necessarily corresponding to row labels, and only a part of rows may have row labels. For example, the first sub-annotation data file can be as shown in Table 1.
TABLE 1
Line number Annotating data
1 Annotation data 1
2 Annotation data 2
3 Annotation data 3
4 Annotation data 4
5 Annotation data 5
6 Annotation data 6
7 Annotation data 7
8 Annotation data 8
9 Annotation data 9
10 Annotation data 10
S203: and the code marking server determines the corresponding relation between the reference line number of the reference code file and the target line number of the target code file according to the code modification information.
Since the code modification information can indicate the contents of the object code file modification with respect to the reference code file. Therefore, the correspondence relationship between the reference line number of the reference code file and the target line number of the target code file can be determined based on the code modification information.
One possible implementation: the line modification information includes: and obtaining the target line number of the target code file corresponding to the reference line number of the reference code file according to the reference line number and the line offset of the reference code file, and determining the corresponding relation between the reference line number of the reference code file and the target line number of the target code file. Where the row offset may indicate a forward offset or a backward offset, the backward offset may be represented by a positive number, the forward offset may be represented by a negative number, and the non-offset may be represented by 0. For example: the target line number of the corresponding target code file can be obtained by adding the line offset to the reference line number of the reference code file.
Optionally, the code modification information may include all reference line numbers and line offsets of the reference code file. For example: the reference code file has 10 lines in total, and the code modification information may include: the reference row number is "1-4", the row offset is "0"; the reference line number is "5-10" and the line offset is "+ 3". Shown in Table 2:
TABLE 2
Reference line number Offset amount
1-4 0
5-10 +3
According to the reference line number and the line offset, one-to-one correspondence between the reference line number 1-4 and the target line number 1-4 can be obtained. The reference line numbers "5-10" correspond one-to-one to the target line numbers "8-13", as shown in table 3.
TABLE 3
Reference line number Offset amount Target line number
1-4 0 1-4
5-10 +3 8-13
Optionally, for the case of only adding a line operation, the code modification information may only include a reference line number and a line offset, which are modified in the reference code file. The reference line number not embodied in the code modification information can be regarded as being consistent with the target line number. For example, the code modification information includes: the reference line number is "5-10" and the line offset is "+ 3". As shown in table 4:
TABLE 4
Reference line number Offset amount
5-10 +3
According to the reference line number and the line offset, the target line number is 8-13. I.e., indicating that the reference line number "lines 5-10" corresponds one-to-one to the target line number "lines 8-13". Assuming that the reference code has 10 lines, it can be considered that reference line numbers "1 to 4" not reflected in the code modification information correspond to target line numbers "1 to 4" one to one, as shown in table 5.
TABLE 5
Reference line number Offset amount Target line number
1-4 0 1-4
5-10 +3 8-13
Optionally, for the case of a delete operation, the offset for the deleted line may be defined as a special character, for example: "+ ∞". For example: the code modification information includes: the reference line number is "1", and the line offset is "0"; base line number "2-4", line offset "+ ∞", base line number "5-10", and line offset "-3". As shown in table 6.
TABLE 6
Reference line number Offset amount
1 1
2-4 +∞
5-10 -3
According to the reference line number and the line offset, the correspondence between the reference line number "1" and the target line number "1" can be obtained. The reference line numbers "5-10" correspond one-to-one to the target line numbers "2-7". The reference line numbers "2-4" have no corresponding relationship with the target line numbers.
TABLE 7
Reference line number Offset amount Target line number
1 1 1
2-4 +∞ Is free of
5-10 -3 2-7
Another possible implementation, the row modification information: and the corresponding relation between the reference line number of the reference code file and the target line number of the target code file. For example: the reference line numbers "1-4" correspond one-to-one to the target line numbers "1-4", and the reference line numbers "5-10" correspond one-to-one to the target line numbers "8-13", as shown in table 8.
TABLE 8
Reference line number Target line number
1-4 1-4
5-10 8-13
S204: and the code marking server determines the marking data of the reference line number of the reference code file as the marking data of the target line number of the corresponding target code file according to the corresponding relation, and generates a second sub marking data file corresponding to the target code file.
The second sub-markup data file can be named according to the identifier of the target code file, for example, the second sub-markup data file is named according to the identifier of the target code file.
Taking table 8 as an example, the reference data of the reference line number "1-4" is determined as the reference data of the target line number "1-4", and the reference data of the reference line number "5-10" is determined as the reference data of the target line number "8-13".
The marking data of the reference line number 1-4 are marking data 1, marking data 2, marking data 3 and marking data 4, and the marking data of the target line number 1-4 are determined to be marking data 1, marking data 2, marking data 3 and marking data 4; the annotation data of the reference line number "5-10" is "annotation data 5, annotation data 6, annotation data 7, annotation data 8, annotation data 9, annotation data 10", and the annotation data of the target line number "8-13" is determined to be "annotation data 5, annotation data 6, annotation data 7, annotation data 8, annotation data 9, annotation data 10". The second sub-annotation data file is shown in table 9:
TABLE 9
Line number Annotating data
1 Annotation data 1
2 Annotation data 2
3 Annotation data 3
4 Annotation data 4
5 Is free of
6 Is free of
7 Is free of
8 Annotation data 5
9 Annotation data 6
10 Annotation data 7
11 Annotation data 8
12 Annotation data 9
13 Annotation data 10
S205: and the code annotation server generates a second annotation data file corresponding to the target code snapshot according to the second sub-annotation data file.
The steps of S203 and S204 are performed on the code files in the target code snapshot, so that second sub-annotation data files corresponding to the files in the target code block can be obtained, and a second annotation data file corresponding to the target code snapshot is generated according to all the obtained second sub-annotation data files, wherein the second annotation data includes all the second sub-annotation data files.
Optionally, the second annotation data file may be named according to the identifier of the target code snapshot. For example, the second annotation data file can be named with the identification of the target code snapshot.
In this embodiment, a snapshot change notification message is sent to a code annotation server through a code management platform, and the code annotation server obtains a first annotation data file corresponding to a reference code snapshot from a database according to an identifier of the reference code snapshot, where the first annotation data file includes at least one first sub-annotation data file, one first sub-annotation data file corresponds to one reference code file, and determines a correspondence between a reference line number of the reference code file and a target line number of a target code file according to code modification information, and determines annotation data of the reference line number as annotation data of a corresponding target line number according to the correspondence to generate a second sub-annotation data file corresponding to the target code file, and generates a second annotation data file corresponding to the target code snapshot according to the second sub-annotation data file corresponding to the target code file, therefore, the target code file does not need to be marked based on a scanning tool or a manual mode, and the code marking efficiency is improved.
And after the code annotation server generates a second annotation data file corresponding to the target code snapshot, storing the second annotation data file into a database, so that other target code snapshots modify the target code snapshot as a reference code snapshot. In addition, the historical annotation data file is stored in the code annotation server, so that developers can trace the code modification process conveniently, and the project condition can be known more comprehensively.
Fig. 3 is a schematic flowchart of another code labeling method provided by the present disclosure, and fig. 3 is based on the embodiment shown in fig. 2, and further before S202, further includes:
s2001: and the code marking server acquires the marked reference code snapshot from the code management platform and acquires a first marking data file corresponding to the reference code snapshot based on the marked reference code snapshot.
And a developer scans the full code through manual marking or an automatic tool to mark the reference code snapshot and uploads the marked reference code snapshot to a code management platform. And the code marking server acquires the marked reference code snapshot from the code management platform, and establishes a corresponding relation between the reference line number of the reference code file and the marked data based on the marked reference code snapshot, so that a first marked data file corresponding to the reference code snapshot is generated.
S2002: and the code labeling server stores the first labeling data file into the database.
S2001 and S2002 may be performed before S201; it may also be performed after S201 and before S202, and the disclosure is not limited thereto.
Fig. 4 is a schematic flowchart of another code annotation method provided by the present disclosure, and fig. 4 is a flowchart of the embodiment shown in fig. 2 or fig. 3, further, the present disclosure provides a function of viewing an annotation data file in a code annotation server, and as shown in fig. 4, the method further includes:
s206 a: the annotation access server sends a first access request to the code annotation server.
The first access request includes: identification of a snapshot of the object code.
S207 a: and the code annotation server sends a second annotation data file corresponding to the target code snapshot to the annotation access server.
S208 a: and the annotation access server displays a second annotation data file corresponding to the target code snapshot.
In this embodiment, a developer sends a first access request to a code annotation server through an annotation access server, the code annotation server sends a second annotation data file corresponding to the target code snapshot to the annotation access server, and the annotation access server displays the second annotation data file corresponding to the target code snapshot. Therefore, developers can conveniently look up the second annotation data file corresponding to the target code snapshot, and the readability of code reading is improved.
Fig. 5 is a schematic flowchart of a code annotation method provided by the present disclosure, and fig. 5 and fig. 4 are different in that fig. 4 accesses an entire target code snapshot, fig. 5 can access a certain target code file of the target code snapshot, and fig. 5 is based on the embodiment shown in fig. 2 or fig. 3, and further, the present disclosure provides a function of viewing an annotation data file in a code annotation server, and as shown in fig. 5, the present disclosure further includes:
s206 b: and the annotation access server sends a second access request to the code annotation server.
The second access request includes: an identification of the object code snapshot and an identification of the object code file. I.e. which object code file of the object code snapshot is to be accessed in particular.
S207 b: and the code annotation server sends a second sub-annotation data file corresponding to the target code file to the annotation access server.
Wherein, one code file corresponds to one sub-label data file.
S208 b: and the annotation access server displays a second sub-annotation data file corresponding to the target code file.
In this embodiment, the developer sends a second access request to the code annotation server through the annotation access server, the code annotation server sends a second sub-annotation data file corresponding to the target code file to the annotation access server, and the annotation access server displays the second sub-annotation data file corresponding to the target code file. Therefore, developers can conveniently look up the second sub-annotation data file corresponding to the target code snapshot, and the readability of code reading is improved.
Fig. 6 is a schematic flow chart of another code annotation method provided by the present disclosure, and fig. 6 is a functional block diagram of modifying an annotation data file in a code annotation server based on the embodiment shown in fig. 4 or fig. 5, and as shown in fig. 6, the method further includes:
s209: and the annotation access server receives annotation data modification information input by the developer.
The annotation data modification information comprises adding annotation information, deleting annotation information or modifying annotation information.
S210: the annotation access server sends the annotation data modification request to the code annotation server, wherein the annotation data modification request comprises: and marking data modification information.
S211: and the code annotation server responds to the annotation data modification request and modifies the second annotation data file according to the annotation data modification information.
In this embodiment, the annotation access server receives annotation data modification information input by a developer, and sends an annotation data modification request to the code annotation server, where the annotation data modification request includes: and marking data modification information, and modifying the second marked data file by the code marking server according to the marked data modification information. Therefore, developers can add or modify the labeled data files stored in the database so as to improve the accuracy of the labeled data files.
Fig. 7 is a schematic structural diagram of a code labeling apparatus provided by the present disclosure, and as shown in fig. 7, the apparatus of this embodiment includes a receiving module 701 and a processing module 702, where the receiving module 701 is configured to receive a snapshot change notification message sent by a code management platform, and the snapshot change notification message includes: the identification of the target code snapshot, the identification of the reference code snapshot and the code modification information; the target code snapshot comprises one or more target code files, the reference code snapshot comprises one or more reference code files, and the code modification information comprises an identifier of a target code file, an identifier of a reference code file corresponding to the target code file and line modification information; the processing module 702 is configured to obtain, from a database, a first annotated data file corresponding to the reference code snapshot according to the identifier of the reference code snapshot, where the first annotated data file includes at least one first sub-annotated data file, and one first sub-annotated data file corresponds to one reference code file; the processing module 702 is further configured to determine, according to the code modification information, a corresponding relationship between a reference line number of the reference code file and a target line number of the target code file;
the processing module 702 is further configured to determine, according to the correspondence, the annotation data of the reference line number of the reference code file as the annotation data of the target line number of the corresponding target code file, and generate a second sub-annotation data file corresponding to the target code file;
the processing module 702 is further configured to generate a second annotated data file corresponding to the target code snapshot according to the second sub-annotated data file, where the second annotated data includes the second sub-annotated data file.
Optionally, the line modification information includes: a reference line number and a line offset of the reference code file;
the processing module 702 is specifically configured to obtain, according to the reference line number and the line offset of the reference code file, a target line number of the target code file corresponding to the reference line number of the reference code file; and determining the corresponding relation between the reference line number of the reference code file and the target line number of the target code file.
Optionally, the line modification information includes: and the corresponding relation between the reference line number of the reference code file and the target line number of the target code file.
Optionally, the receiving module 701 is further configured to obtain a reference code snapshot after annotation from the code management platform;
the processing module 702 is further configured to obtain, based on the annotated reference code snapshot, a first annotated data file corresponding to the reference code snapshot;
the processing module 702 is further configured to store the first annotation data file in the database.
Optionally, the receiving module 701 is further configured to receive a first access request sent by an annotation access server, where the first access request includes: identification of the target code snapshot;
and the sending module is used for sending a second annotation data file corresponding to the target code snapshot to the annotation access server.
Optionally, the receiving module 701 is further configured to receive a second access request sent by the annotation access server, where the second access request includes: the identity of the target code snapshot and the identity of the target code file;
and the sending module is used for sending the second sub-annotation data file corresponding to the target code file to the annotation access server.
Optionally, the receiving module 701 is further configured to receive an annotation data modification request sent by an annotation access server, where the annotation data modification request includes: marking data modification information;
the processing module 702 is further configured to respond to the annotation data modification request, and modify the second annotation data file according to the annotation data modification information.
The present disclosure also provides a computer device comprising: a processor for executing a computer program stored in a memory, the computer program, when executed by the processor, implementing the steps of the method of any of the embodiments of fig. 2-6.
The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method according to any one of the embodiments of fig. 2-6.
The present disclosure also provides a code annotation system, as shown in fig. 1, a code management platform 101 and an annotation access server 103.
The code management platform 101 is configured to send a snapshot change notification message to the code annotation server; the snapshot change notification message includes: the identification of the target code snapshot, the identification of the reference code snapshot and the code modification information; the target code snapshot comprises one or more target code files, the reference code snapshot comprises one or more reference code files, and the code modification information comprises an identifier of a target code file, an identifier of a reference code file corresponding to the target code file and line modification information;
the code annotation server 103 is configured to obtain, from a database, a first annotation data file corresponding to the reference code snapshot according to the identifier of the reference code snapshot, where the first annotation data file includes at least one first sub-annotation data file, and one first sub-annotation data file corresponds to one reference code file; determining the corresponding relation between the reference line number of the reference code file and the target line number of the target code file according to the code modification information; according to the corresponding relation, determining the marking data of the reference line number of the reference code file as the marking data of the corresponding target line number of the target code file, and generating a second sub marking data file corresponding to the target code file; and generating a second annotation data file corresponding to the target code snapshot according to the second sub-annotation data file, wherein the second annotation data comprises the second sub-annotation data file.
Optionally, the method further includes: the annotation access server 102;
the annotation access server 102 is configured to send a first access request or a second access request to the code annotation server, where the first access request includes: identification of a target code snapshot, the second access request including: the identity of the target code snapshot and the identity of the target code file;
accordingly;
the code annotation server 102 is further configured to send a second annotation data file corresponding to the target code snapshot to the annotation access server; or sending a second sub-annotation data file corresponding to the target code file to the annotation access server.
Optionally, the annotation access server 102 is further configured to send an annotation data modification request to the code annotation server, where the annotation data modification request includes: marking data modification information;
correspondingly, the code annotation server 102 is further configured to respond to the annotation data modification request, and modify the second annotation data file according to the annotation data modification information.
The system of this embodiment, when executed correspondingly, implements the steps of the method described in any of the embodiments of fig. 2-6. The implementation principle and the technical effect are similar, and the detailed description is omitted here.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present disclosure, which enable those skilled in the art to understand or practice the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method for labeling code, comprising:
receiving a snapshot change notification message sent by a code management platform, wherein the snapshot change notification message comprises: the identification of the target code snapshot, the identification of the reference code snapshot and the code modification information; the target code snapshot comprises one or more target code files, the reference code snapshot comprises one or more reference code files, and the code modification information comprises an identifier of a target code file, an identifier of a reference code file corresponding to the target code file and line modification information;
acquiring a first annotation data file corresponding to the reference code snapshot from a database according to the identifier of the reference code snapshot, wherein the first annotation data file comprises at least one first sub-annotation data file, and one first sub-annotation data file corresponds to one reference code file;
determining the corresponding relation between the reference line number of the reference code file and the target line number of the target code file according to the code modification information;
according to the corresponding relation, determining the marking data of the reference line number of the reference code file as the marking data of the corresponding target line number of the target code file, and generating a second sub marking data file corresponding to the target code file;
and generating a second annotation data file corresponding to the target code snapshot according to the second sub-annotation data file, wherein the second annotation data comprises the second sub-annotation data file.
2. The method of claim 1, wherein the line modification information comprises: a reference line number and a line offset of the reference code file;
the determining the corresponding relationship between the reference line number of the reference code file and the target line number of the target code file according to the code modification information includes:
obtaining a target line number of the target code file corresponding to the reference line number of the reference code file according to the reference line number and the line offset of the reference code file;
and determining the corresponding relation between the reference line number of the reference code file and the target line number of the target code file.
3. The method of claim 1, wherein the line modification information comprises: and the corresponding relation between the reference line number of the reference code file and the target line number of the target code file.
4. The method according to any one of claims 1-3, further comprising:
receiving a first access request sent by an annotation access server, wherein the first access request comprises: identification of the target code snapshot; sending a second annotation data file corresponding to the target code snapshot to the annotation access server;
alternatively, the first and second electrodes may be,
receiving a second access request sent by an annotation access server, wherein the second access request comprises: the identity of the target code snapshot and the identity of the target code file; and sending a second sub-annotation data file corresponding to the target code file to the annotation access server.
5. The method of claim 4, further comprising:
receiving an annotation data modification request sent by an annotation access server, wherein the annotation data modification request comprises: marking data modification information;
and responding to the annotation data modification request, and modifying the second annotation data file according to the annotation data modification information.
6. A code labeling apparatus, comprising:
a receiving module, configured to receive a snapshot change notification message sent by a code management platform, where the snapshot change notification message includes: the identification of the target code snapshot, the identification of the reference code snapshot and the code modification information; the target code snapshot comprises one or more target code files, the reference code snapshot comprises one or more reference code files, and the code modification information comprises an identifier of a target code file, an identifier of a reference code file corresponding to the target code file and line modification information;
the processing module is used for acquiring a first annotation data file corresponding to the reference code snapshot from a database according to the identifier of the reference code snapshot, wherein the first annotation data file comprises at least one first sub-annotation data file, and one first sub-annotation data file corresponds to one reference code file;
the processing module is further used for determining the corresponding relation between the reference line number of the reference code file and the target line number of the target code file according to the code modification information;
the processing module is further configured to determine, according to the correspondence, the annotation data of the reference line number of the reference code file as the annotation data of the corresponding target line number of the target code file, and generate a second sub-annotation data file corresponding to the target code file;
the processing module is further configured to generate a second annotated data file corresponding to the target code snapshot according to the second sub-annotated data file, where the second annotated data includes the second sub-annotated data file.
7. A computer device, comprising: a processor for executing a computer program stored in a memory, the computer program, when executed by the processor, implementing the steps of the method of any of claims 1-5.
8. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 5.
9. A code annotation system, comprising: the system comprises a code management platform and a code marking server;
the code management platform is used for sending a snapshot change notification message to the code annotation server; the snapshot change notification message includes: the identification of the target code snapshot, the identification of the reference code snapshot and the code modification information; the target code snapshot comprises one or more target code files, the reference code snapshot comprises one or more reference code files, and the code modification information comprises an identifier of a target code file, an identifier of a reference code file corresponding to the target code file and line modification information;
the code annotation server is used for acquiring a first annotation data file corresponding to the reference code snapshot from a database according to the identifier of the reference code snapshot, wherein the first annotation data file comprises at least one first sub-annotation data file, and one first sub-annotation data file corresponds to one reference code file; determining the corresponding relation between the reference line number of the reference code file and the target line number of the target code file according to the code modification information; according to the corresponding relation, determining the marking data of the reference line number of the reference code file as the marking data of the corresponding target line number of the target code file, and generating a second sub marking data file corresponding to the target code file; and generating a second annotation data file corresponding to the target code snapshot according to the second sub-annotation data file, wherein the second annotation data comprises the second sub-annotation data file.
10. The system of claim 9, further comprising: marking an access server;
the annotation access server is configured to send a first access request or a second access request to the code annotation server, where the first access request includes: identification of a target code snapshot, the second access request including: the identity of the target code snapshot and the identity of the target code file;
accordingly, the number of the first and second electrodes,
the code annotation server is also used for sending a second annotation data file corresponding to the target code snapshot to the annotation access server; or sending a second sub-annotation data file corresponding to the target code file to the annotation access server.
CN202110036104.8A 2021-01-12 2021-01-12 Code labeling method, device, computer equipment, medium and system Active CN112698821B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110036104.8A CN112698821B (en) 2021-01-12 2021-01-12 Code labeling method, device, computer equipment, medium and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110036104.8A CN112698821B (en) 2021-01-12 2021-01-12 Code labeling method, device, computer equipment, medium and system

Publications (2)

Publication Number Publication Date
CN112698821A true CN112698821A (en) 2021-04-23
CN112698821B CN112698821B (en) 2024-03-26

Family

ID=75514083

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110036104.8A Active CN112698821B (en) 2021-01-12 2021-01-12 Code labeling method, device, computer equipment, medium and system

Country Status (1)

Country Link
CN (1) CN112698821B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110145186A1 (en) * 2009-12-16 2011-06-16 Henrik Hempelmann Online access to database snapshots
CN102339218A (en) * 2010-07-21 2012-02-01 阳振庭 Program code annotating management method and device
CN103324513A (en) * 2013-06-04 2013-09-25 北京大学 Program annotation method and device
CN104462342A (en) * 2014-12-04 2015-03-25 北京国双科技有限公司 Synchronous processing method and device for database snapshots
US20160170746A1 (en) * 2014-12-16 2016-06-16 Google Inc. Efficient annotation system for distributed version control systems
CN106293662A (en) * 2015-05-22 2017-01-04 中兴通讯股份有限公司 A kind of code change statistics of variables method and device thereof
CN108228231A (en) * 2018-01-08 2018-06-29 南京邮电大学 A kind of visualization shift algorithm of Git warehouses file annotation system
CN110471694A (en) * 2019-07-11 2019-11-19 平安普惠企业管理有限公司 Annotation information processing method, device, computer equipment and storage medium
US20220004367A1 (en) * 2018-10-12 2022-01-06 Code Walker L.L.C. Annotated Method For Computer Code Mapping and Visualization

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110145186A1 (en) * 2009-12-16 2011-06-16 Henrik Hempelmann Online access to database snapshots
CN102339218A (en) * 2010-07-21 2012-02-01 阳振庭 Program code annotating management method and device
CN103324513A (en) * 2013-06-04 2013-09-25 北京大学 Program annotation method and device
CN104462342A (en) * 2014-12-04 2015-03-25 北京国双科技有限公司 Synchronous processing method and device for database snapshots
US20160170746A1 (en) * 2014-12-16 2016-06-16 Google Inc. Efficient annotation system for distributed version control systems
CN106293662A (en) * 2015-05-22 2017-01-04 中兴通讯股份有限公司 A kind of code change statistics of variables method and device thereof
CN108228231A (en) * 2018-01-08 2018-06-29 南京邮电大学 A kind of visualization shift algorithm of Git warehouses file annotation system
US20220004367A1 (en) * 2018-10-12 2022-01-06 Code Walker L.L.C. Annotated Method For Computer Code Mapping and Visualization
CN110471694A (en) * 2019-07-11 2019-11-19 平安普惠企业管理有限公司 Annotation information processing method, device, computer equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
白杨;张丽萍;: "挖掘软件源代码的代码注释自动生成方法", 计算机工程与应用, no. 10, pages 251 - 258 *

Also Published As

Publication number Publication date
CN112698821B (en) 2024-03-26

Similar Documents

Publication Publication Date Title
CN103246595B (en) Application management method, device, server and terminating unit
CN107783766A (en) The method and apparatus cleared up the file of application program
CN110688353A (en) File management method, device and computer readable medium
US20080162944A1 (en) Information processing apparatus, information processing system, and computer readable storage medium
CN110716804A (en) Method and device for automatically deleting useless resources, storage medium and electronic equipment
CN110990346A (en) File data processing method, device, equipment and storage medium based on block chain
WO2019223073A1 (en) Contract recordation method and apparatus, and computer device and storage medium
CN112860507A (en) Method and device for controlling sampling rate of distributed link tracking system
CN112698821B (en) Code labeling method, device, computer equipment, medium and system
CN111145143A (en) Problem image determination method and device, electronic equipment and storage medium
CN111222065B (en) Information display method and device, electronic equipment and medium
CN110083509B (en) Method and device for arranging log data
CN111045983B (en) Nuclear power station electronic file management method, device, terminal equipment and medium
CN110674249B (en) Information processing method and device
CN113590564A (en) Data storage method and device, electronic equipment and storage medium
CN112632211A (en) Semantic information processing method and equipment for mobile robot
JP2017045106A (en) Information processing device and information processing program
CN112379891B (en) Data processing method and device
CN113342288B (en) Data protection method, client, server and system
CN115221338B (en) Knowledge graph construction method and system and computer equipment
CN111159665A (en) File label-based plaintext data tracing method and device
CN115035527B (en) Method, device and equipment for identifying electronic signature position
CN115964051A (en) Multilingual entry detection method and device, computer equipment and storage medium
CN110750268B (en) File cleaning method and device, computer readable storage medium and electronic equipment
JP2012063822A (en) Information processor and information processing program

Legal Events

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