AST-Based Plugin Insertion for Source Code Processing

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

In software development, existing methods for performance optimization and memory leak testing require analyzing entire source code files, which is inefficient and limits flexibility, especially when dealing with large-scale programs, as plugins are typically inserted during compilation and cannot be modified afterward.

Innovation Solution

A method and system that scan a source file to identify a target code block, generate an abstract syntax tree (AST), insert plugin code into the AST, and write the modified AST back into the source file, allowing for selective processing and modification of the source code with plugins before compilation.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If plugins are placed into the source code in the original compilation process, then the source code can be compiled to obtain executable files, but the source code cannot be further modified and the processing efficiency is low when dealing with large-scale programs

Engineering Contradiction:
Improvefile processing efficiencyVSAvoidsource code flexibility
Core Design Contradiction:
ProductivityVSAdaptability or versatility

Solution Approach 1:

The patent segments the source code file into multiple code blocks and selectively processes only the target code block containing the plugin, rather than processing the entire source file. This segmentation approach improves processing efficiency by reducing the scope of analysis while maintaining the ability to modify and recompile only the necessary portions of the code.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent performs preliminary actions by scanning the source file to identify the target code block and determining the plugin insertion position before actually inserting the plugin code. This preliminary analysis phase separates the identification work from the modification work, enabling more efficient processing and allowing developers to review the planned changes before execution.

Inventive Principle:
Principle #10Preliminary action

2Manufacturing precision

If the whole source code file is analyzed to place a plugin, then the plugin can be correctly inserted, but the processing time and work amount increase considerably for large-scale programs

Engineering Contradiction:
Improveplugin insertion accuracyVSAvoidprocessing time
Core Design Contradiction:
Manufacturing precisionVSLoss of time

Solution Approach 1:

The patent extracts the target code block from the larger source code file by scanning and identifying specific code blocks that match certain criteria. By taking out only the relevant portion for plugin insertion, the system maintains accurate plugin placement while significantly reducing the time and computational resources required compared to analyzing the entire source code file.

Inventive Principle:
Principle #2Taking out (Extraction)

3Reliability

If plugins are inserted during compilation, then performance optimization analysis can be conducted, but the source code lacks flexibility for further modifications before compilation

Engineering Contradiction:
Improveperformance analysis capabilityVSAvoidsource code modifiability
Core Design Contradiction:
ReliabilityVSAdaptability or versatility

Solution Approach 1:

The patent implements a dynamic process where the source code file can be scanned, modified with plugin insertion, and recompiled multiple times as needed. The system allows developers to dynamically adjust the source code, add or remove plugins, and recompile only the affected portions, providing flexibility and adaptability throughout the development process rather than locking the code after initial compilation.

Inventive Principle:
Principle #15Dynamics

Data Source

PatentUS9116714B2Methods and systems for file processing
Publication Date: 2015.08.25 TENCENT TECHNOLOGY (SHENZHEN) CO LTD
  • US9116714B2 patent drawing
  • US9116714B2 patent drawing
  • US9116714B2 patent drawing

AI summary

The present disclosure relates to a method and system for file processing. The file processing method may include the steps of scanning a source files, identifying a target code block, and generating a first abstract syntax tree (AST) reflecting the structure of the target code block. The file processing method may further include the steps of identifying a position to place a plugin code, placing the plugin code into the first AST, generating a second AST reflecting the structure of the target code block with the plugin code, and using the write-back interface to write the second AST into the source file. The present disclosure may improve the efficiency and enhance the flexibility of the file processing system.