Code change statistical method and system considering different editing scenes

By listening to events in different editing scenarios and uploading multi-dimensional data, the problem of coarse granularity and incomplete data in code change statistics in the VSCode environment has been solved. This has enabled efficient multi-dimensional data display and accurate code change statistics, improving data utilization and project management efficiency.

CN120973846APending Publication Date: 2025-11-18BEIJING YIYUANKU TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202511501277.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-21
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

Existing technologies in the VSCode environment have coarse-grained code change statistics methods, cannot distinguish between different editing scenarios, have incomplete data collection, lack multi-dimensional display, and cannot meet the needs of project management and developers.

Method used

By listening to events in different editing scenarios, including copy and paste, repeated changes, AI adoption, and AI completion, and combining them with save events, editor exit, and scheduled tasks, multi-dimensional data can be uploaded and visualized.

Benefits of technology

It improves the accuracy and data utilization of code change statistics, reduces errors, ensures data integrity, provides multi-dimensional visualization, and supports project management and developer analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120973846A_ABST
    Figure CN120973846A_ABST
Patent Text Reader

Abstract

The invention discloses a code change statistical method and system considering different editing scenes, and relates to the technical field of computer software development and code management, and the method comprises the following steps: S1, obtaining code change data under different editing scenes through an event monitoring mode; wherein the different editing scenes comprise copying and pasting, repeated changing, AI (Artificial Intelligence) adopting and AI complementing; s2, uploading the code change data based on three dimensions of a saving event, an editor exit and a timed task; and S3, performing statistics of different dimensions and visual display of different forms on the uploaded code change data. According to the method, a reliable data basis is provided for code quality evaluation and developer performance analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer software development and code management technology, and more specifically to a code change statistics method and system that takes into account different editing scenarios. Background Technology

[0002] Currently, VSCode primarily uses simple file version comparisons or basic line count plugins to track code changes. While these provide some basic information about code changes, their granularity is coarse and their functionality is relatively limited (i.e., current technology cannot differentiate the characteristics of code changes across different editing scenarios). Furthermore, current code change data reporting only occurs when files are saved, lacking data collection at other critical points in the editor's lifecycle (such as when the editor exits), resulting in poor data integrity. In addition, existing visualizations only present file-level line change counts, failing to showcase code changes across different dimensions, which hinders project managers and developers from quickly obtaining relevant information.

[0003] Therefore, how to provide a code change statistics method and system that can distinguish different editing scenarios, realize multi-dimensional data upload, and provide rich visualization is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a code change statistics method and system that takes into account different editing scenarios.

[0005] To achieve the above objectives, the present invention adopts the following technical solution:

[0006] Firstly, a code change statistics method that considers different editing scenarios is provided, including the following steps:

[0007] S1: Obtain code change data under different editing scenarios through event listening; the different editing scenarios include copy and paste, repeated changes, AI adoption, and AI completion;

[0008] S2: Upload the code change data based on three dimensions: save event, editor exit, and scheduled task;

[0009] S3: Perform statistical analysis on uploaded code change data from different dimensions and present it in different forms of visualization.

[0010] Preferably, S1 specifically includes the following steps:

[0011] S11: Listen for the onDidPaste event. If the onDidPaste event is triggered, get the pasted code text and the pasting time.

[0012] S12: Calculate the similarity between the pasted code text and the original code text;

[0013] S13: If the similarity is less than the first preset threshold, then generate code change data A1; wherein, the code change data A1 includes the developer account, the project, the pasting time, the current code change line number B1, and the code change type; the current code change line number B1 is equal to the number of lines of the pasted code text; the code change type is copy and paste;

[0014] If the similarity is greater than or equal to the first preset threshold, code change data A2 is generated; wherein, the code change data A2 includes the developer account, the project, the pasting time, the current code change line number B2, and the code change type; the current code change line number B2 is equal to 0; the code change type is copy and paste.

[0015] Preferably, S1 further includes the following steps:

[0016] Listen for the onDidChangeActiveTextEditor and onDidChangeActiveEditorGroup events. If either the onDidChangeActiveTextEditor or onDidChangeActiveEditorGroup event is triggered, determine whether the same file has been modified twice within a preset time window. If so, calculate the similarity between the two modified code changes.

[0017] If the similarity is less than the second preset threshold, code change data A3 is generated; wherein, the code change data A3 includes the developer account, the project to which it belongs, the time of the most recent code change, the current code change line number B3, and the code change type; the current code change line number B3 is equal to the line number of the most recent code change; the code change type is repeated change;

[0018] If the similarity is greater than or equal to the second preset threshold, code change data A4 is generated; wherein, the code change data A4 includes the developer account, the project to which it belongs, the time of the most recent code change, the current code change line number B4, and the code change type; the current code change line number B4 is equal to 0; the code change type is a duplicate change.

[0019] Preferably, S1 further includes the following steps:

[0020] Listen for the insertion event of AI-generated code. If the insertion event of AI-generated code is triggered, generate code change data A5. The code change data A5 includes the developer account, the project, the insertion time of the AI-generated code, the current line number of code change B5, and the code change type. The current line number of code change B5 is equal to the number of lines of the inserted AI-generated code. The code change type is AI adoption change.

[0021] Preferably, S1 further includes the following steps:

[0022] Listen for the insertion event of AI-completed code. If the insertion event of AI-completed code is triggered, calculate the similarity between the code text before and after completion.

[0023] If the similarity is less than the third preset threshold, code change data A6 is generated; wherein, the code change data A6 includes the developer account, the project, the insertion time of the AI-completed code, the current code change line number B6, and the code change type; the current code change line number B6 is equal to the number of lines of the inserted AI-completed code; the code change type is AI-completed change;

[0024] If the similarity is greater than or equal to the third preset threshold, code change data A7 is generated; wherein, the code change data A7 includes the developer account, the project to which it belongs, the insertion time of the AI-completed code, the current code change line number B7, and the code change type; the current code change line number B7 is equal to 0; the code change type is AI completion change.

[0025] Preferably, S2 specifically includes the following steps:

[0026] Listen for the onDidSave event. If the onDidSave event is triggered, encapsulate the code change data of the current file into a JSON format data packet and send it to the backend server for storage via an HTTP request.

[0027] Preferably, S2 specifically includes the following steps:

[0028] Listen for the onWillQuit event. If the onWillQuit event is triggered, encapsulate the code change data of all currently open but unsaved files into a JSON format data packet and send it to the backend server for storage via an HTTP request.

[0029] Preferably, S2 specifically includes the following steps:

[0030] Determine whether the JavaScript / TypeScript timer function has been triggered. If it has, encapsulate the code change data of all files that have undergone code changes within the timer period into a JSON format data packet and send it to the backend server for storage via an HTTP request.

[0031] Preferably, the different dimensions in S3 include developer account, project, time granularity, and code change type; the different formats include line chart, bar chart, and pie chart.

[0032] Secondly, a code change statistics system considering different editing scenarios is provided to implement the code change statistics method described in the first aspect, including a first data processing module, a second data processing module and a display module;

[0033] The first data processing module is used to obtain code change data under different editing scenarios through event listening; wherein, different editing scenarios include copy and paste, repeated changes, AI adoption and AI completion;

[0034] The second data processing module is used to upload the code change data based on three dimensions: save event, editor exit, and scheduled task.

[0035] The display module is used to perform statistical analysis on the uploaded code change data from different dimensions and to display it in different forms of visualization.

[0036] As can be seen from the above technical solutions, compared with the prior art, the present invention discloses a code change statistics method and system that considers different editing scenarios, which can achieve the following beneficial technical effects:

[0037] 1) By processing four different editing scenarios—copy and paste, repeated changes, AI adoption, and AI completion—this invention can more accurately count the number of lines of code changed. Compared with existing technologies, the statistical error is reduced by about 70%, providing a reliable data foundation for code quality assessment and developer performance analysis.

[0038] 2) This invention combines three data reporting methods—save events, editor exit, and scheduled tasks—to achieve full-cycle, comprehensive data collection of code change data. This ensures that code change information is reported to the backend server in a timely and accurate manner under various operational scenarios, providing complete data support for subsequent visualization.

[0039] 3) This invention can display code changes from multiple dimensions. Project managers can intuitively understand the overall project progress and the contributions of team members; developers can review their coding process and optimize development efficiency. Compared with existing technologies, data utilization is improved by approximately 80%. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0041] Figure 1 The flowchart illustrates a code change statistics method that takes into account different editing scenarios, as provided by this invention. Detailed Implementation

[0042] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0043] like Figure 1 As shown, in a first aspect, embodiments of the present invention disclose a code change statistics method considering different editing scenarios, comprising the following steps:

[0044] S1: Obtain code change data under different editing scenarios through event listening; the different editing scenarios include copy and paste, repeated changes, AI adoption, and AI completion;

[0045] In one embodiment, S1 specifically includes the following steps:

[0046] S11: Listen for the onDidPaste event. If the onDidPaste event is triggered, get the pasted code text and the pasting time.

[0047] S12: Calculate the similarity between the pasted code text and the original code text;

[0048] S13: If the similarity is less than the first preset threshold, then generate code change data A1; wherein, the code change data A1 includes the developer account, the project, the pasting time, the current code change line number B1, and the code change type; the current code change line number B1 is equal to the number of lines of the pasted code text; the code change type is copy and paste;

[0049] If the similarity is greater than or equal to the first preset threshold, code change data A2 is generated; wherein, the code change data A2 includes the developer account, the project, the pasting time, the current code change line number B2, and the code change type; the current code change line number B2 is equal to 0; the code change type is copy and paste.

[0050] In one embodiment, the first preset threshold is 80%;

[0051] In one embodiment, a string similarity algorithm (such as the Levenshtein distance algorithm) is used to calculate the similarity.

[0052] In one embodiment, S1 further includes the following steps:

[0053] Listen for the onDidChangeActiveTextEditor and onDidChangeActiveEditorGroup events. If either the onDidChangeActiveTextEditor or onDidChangeActiveEditorGroup event is triggered, determine whether the same file has been modified twice within a preset time window. If so, calculate the similarity between the two modified code changes.

[0054] If the similarity is less than the second preset threshold, code change data A3 is generated; wherein, the code change data A3 includes the developer account, the project to which it belongs, the time of the most recent code change (the most recent code change refers to the most recent code change among two code changes made to the same file), the current code change line number B3, and the code change type; the current code change line number B3 is equal to the line number of the most recent code change; the code change type is a duplicate change;

[0055] If the similarity is greater than or equal to the second preset threshold, code change data A4 is generated; wherein, the code change data A4 includes the developer account, the project to which it belongs, the time of the most recent code change, the current code change line number B4, and the code change type; the current code change line number B4 is equal to 0; the code change type is a duplicate change.

[0056] In one embodiment, the second preset threshold is 60%;

[0057] In one embodiment, S1 further includes the following steps:

[0058] Listen for the insertion event of AI-generated code. If the insertion event of AI-generated code is triggered, generate code change data A5. The code change data A5 includes the developer account, the project, the insertion time of the AI-generated code, the current line number of code change B5, and the code change type. The current line number of code change B5 is equal to the number of lines of the inserted AI-generated code. The code change type is AI adoption change.

[0059] In one embodiment, S1 further includes the following steps:

[0060] Listen for the insertion event of AI-completed code. If the insertion event of AI-completed code is triggered, calculate the similarity between the code text before and after completion.

[0061] If the similarity is less than the third preset threshold, code change data A6 is generated; wherein, the code change data A6 includes the developer account, the project, the insertion time of the AI-completed code, the current code change line number B6, and the code change type; the current code change line number B6 is equal to the number of lines of the inserted AI-completed code; the code change type is AI-completed change;

[0062] If the similarity is greater than or equal to the third preset threshold, code change data A7 is generated; wherein, the code change data A7 includes the developer account, the project to which it belongs, the insertion time of the AI-completed code, the current code change line number B7, and the code change type; the current code change line number B7 is equal to 0; the code change type is AI completion change.

[0063] S2: Upload the code change data based on three dimensions: save event, editor exit, and scheduled task;

[0064] In one embodiment, S2 specifically includes the following steps:

[0065] Listen for the onDidSave event. If the onDidSave event is triggered, encapsulate the code change data of the current file into a JSON format data packet and send it to the backend server for storage via an HTTP request.

[0066] In one embodiment, S2 specifically includes the following steps:

[0067] Listen for the onWillQuit event. If the onWillQuit event is triggered, encapsulate the code change data of all currently open but unsaved files into a JSON format data packet and send it to the backend server for storage via an HTTP request.

[0068] In one embodiment, S2 specifically includes the following steps:

[0069] Determine whether the JavaScript / TypeScript timer function has been triggered. If it has, encapsulate the code change data of all files that have undergone code changes within the timer period into a JSON format data packet and send it to the backend server for storage via an HTTP request.

[0070] S3: Perform statistical analysis on uploaded code change data from different dimensions and present it in different forms of visualization.

[0071] In one embodiment, the different dimensions in S3 include developer account, project, time granularity, and code change type; the different formats include line chart, bar chart, and pie chart.

[0072] In one embodiment, the number of lines of code changes (including lines of code changes B1-B7) is summed and statistically analyzed from four dimensions: developer account, project, time granularity (by hour or by day), and code change type, to obtain the code change statistics results of the selected combination of dimensions.

[0073] The code change statistics for the selected combination dimensions include: the code change trend of a developer at different time periods within a day; the number of lines of code changes by different developers in the same project (including lines of code changes B1-B7); and the percentage of lines of code changes for different code change types (copy and paste, duplicate changes, AI adoption changes, and AI completion changes) in a project.

[0074] It is understandable that this invention utilizes VSCode's WebView technology to embed a visual interface within the editor. It employs the ECharts chart library as the visualization rendering engine, providing users with various chart types such as line charts, bar charts, and pie charts. For example, users can view a developer's code change trends over different time periods within a day using a line chart; compare the number of lines of code changed by different developers in the same project using a bar chart; and display the percentage of lines of code changed under different code change types using a pie chart.

[0075] Secondly, a code change statistics system considering different editing scenarios is provided to implement the code change statistics method described in the first aspect, including a first data processing module, a second data processing module and a display module;

[0076] The first data processing module is used to obtain code change data under different editing scenarios through event listening; wherein, different editing scenarios include copy and paste, repeated changes, AI adoption and AI completion;

[0077] The second data processing module is used to upload the code change data based on three dimensions: save event, editor exit, and scheduled task.

[0078] The display module is used to perform statistical analysis on the uploaded code change data from different dimensions and to display it in different forms of visualization.

[0079] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.

[0080] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not 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

1. A code change statistics method considering different editing scenarios, characterized in that, The method comprises the following steps: S1: obtaining code change data in different editing scenarios through event listening; wherein the different editing scenarios include copy and paste, repeated change, AI adoption and AI completion; S2: uploading the code change data based on three dimensions of save event, editor exit and timing task; S3: performing different dimension statistics and different form visual display on the uploaded code change data. 2.The code change statistics method considering different editing scenarios according to claim 1, wherein, S1 specifically comprises the following steps: S11: listening to the onDidPaste event, if the onDidPaste event is triggered, obtaining the pasted code text and the paste time; S12: calculating the similarity between the pasted code text and the code text before pasting; S13: if the similarity is less than a first preset threshold, generating code change data A1; wherein the code change data A1 includes the developer account, the project it belongs to, the paste time, the current code change line number B1 and the code change type; the current code change line number B1 is equal to the line number of the pasted code text; the code change type is copy and paste; if the similarity is greater than or equal to the first preset threshold, generating code change data A2; wherein the code change data A2 includes the developer account, the project it belongs to, the paste time, the current code change line number B2 and the code change type; the current code change line number B2 is equal to 0; the code change type is copy and paste. 3.The code change statistics method considering different editing scenarios according to claim 1, wherein, S1 specifically further comprises the following steps: listening to the onDidChangeActiveTextEditor and onDidChangeActiveEditorGroup events, if the onDidChangeActiveTextEditor event or the onDidChangeActiveEditorGroup event is triggered; then judging whether two code changes have been made on the same file within a preset time window, if yes, calculating the similarity of the two changed codes; if the similarity is less than a second preset threshold, generating code change data A3; wherein the code change data A3 includes the developer account, the project it belongs to, the time of the last code change, the current code change line number B3 and the code change type; the current code change line number B3 is equal to the line number of the last code change; the code change type is repeated change; if the similarity is greater than or equal to the second preset threshold, generating code change data A4; wherein the code change data A4 includes the developer account, the project it belongs to, the time of the last code change, the current code change line number B4 and the code change type; the current code change line number B4 is equal to 0; the code change type is repeated change.

4. The method of claim 1, wherein the method further comprises: S1 specifically further comprises the following steps: The AI-generated code insertion event is monitored. If the AI-generated code insertion event is triggered, code change data A5 is generated. The code change data A5 includes a developer account, a project, an AI-generated code insertion time, a current code change line number B5, and a code change type. The current code change line number B5 is equal to the number of lines of the inserted AI-generated code. The code change type is AI adoption change.

5. The method for code change statistics considering different editing scenarios according to claim 1, wherein, S1 specifically includes the following steps: The AI completion code insertion event is monitored. If the AI completion code insertion event is triggered, the similarity of the code text before and after completion is calculated. If the similarity is less than a third preset threshold, code change data A6 is generated. The code change data A6 includes a developer account, a project, an AI completion code insertion time, a current code change line number B6, and a code change type. The current code change line number B6 is equal to the number of lines of the inserted AI completion code. The code change type is AI completion change. If the similarity is greater than or equal to the third preset threshold, code change data A7 is generated. The code change data A7 includes a developer account, a project, an AI completion code insertion time, a current code change line number B7, and a code change type. The current code change line number B7 is equal to 0. The code change type is AI completion change.

6. The method for code change statistics considering different editing scenarios according to claim 1, wherein, S2 specifically includes the following steps: The onDidSave event is monitored. If the onDidSave event is triggered, the code change data of the current file is packaged into a JSON format data packet and sent to the background server for storage through an HTTP request. 7.The code change statistics method considering different editing scenarios according to claim 1, wherein, S2 specifically includes the following steps: The onWillQuit event is monitored. If the onWillQuit event is triggered, the code change data of all currently open but unsaved files is packaged into a JSON format data packet and sent to the background server for storage through an HTTP request. 8.The code change statistics method considering different editing scenarios according to claim 1, wherein, S2 specifically includes the following steps: It is determined whether the timer function of JavaScript / TypeScript is triggered. If it is triggered, the code change data of all files that have occurred code changes within the timing period is packaged into a JSON format data packet and sent to the background server for storage through an HTTP request. 9.The code change statistics method considering different editing scenarios according to claim 1, wherein, The different dimensions in S3 include developer account, project, time granularity, and code change type. The different forms include line chart, column chart, and pie chart.

10. A code change statistics system considering different editing scenarios, for implementing the code change statistics method of any one of claims 1-9, characterized in that, It includes a first data processing module, a second data processing module, and a display module. The first data processing module is used to obtain code change data in different editing scenarios through event monitoring. Different editing scenarios include copy and paste, repeated changes, AI adoption, and AI completion. The second data processing module is used to upload the code change data based on three dimensions of save event, editor exit, and timing task. The display module is used to statistically analyze the uploaded code change data in different dimensions and visually display it in different forms.

Citation Information

Patent Citations

  • RTC code quantity statistical method and system, medium and terminal

    CN113485683A

  • Multi-dimensional visual code line number statistics method and system

    CN115981703A

  • Evaluation method and device for automatic programming

    CN117707934A

  • Code completion method and device, electronic equipment and storage medium

    CN119149000A

  • AI auxiliary programming method and system, storage medium and program product

    CN119883226A