Context-Based Code Completion With Static Analysis Ranking

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current AI-based code completion methods suffer from low accuracy in predicting to-be-completed code, requiring manual completion or correction by users, and are resource-intensive, leading to inefficiencies and poor user experience.

Innovation Solution

A code processing method that performs static analysis on user input to determine candidate items from a context database, using features like syntax and semantic analysis, and employs a lightweight assessment model to filter and rank suggestions, avoiding network delays and recommending high-accuracy code completions.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Extent of automation

If AI-based code completion is used, then code completion automation is improved, but prediction accuracy deteriorates

Engineering Contradiction:
Improvecode completion automationVSAvoidprediction accuracy
Core Design Contradiction:
Extent of automationVSMeasurement precision

Solution Approach 1:

The patent introduces a context database as an intermediary between the user's code input and the completion suggestions. Instead of directly using AI prediction, the system queries a pre-built database of code contexts and uses static analysis results as intermediaries to retrieve relevant completion candidates, thereby improving accuracy while maintaining automation.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The system performs preliminary static analysis on the user's code input before generating completion suggestions. By analyzing the code structure, semantics, and context in advance, the system can retrieve more accurate completion candidates from the database, resolving the accuracy issue without sacrificing automation.

Inventive Principle:
Principle #10Preliminary action

2Extent of automation

If complex AI models are used for code completion, then prediction capability is improved, but computing resource consumption increases

Engineering Contradiction:
Improvecode completion capabilityVSAvoidcomputing resource consumption
Core Design Contradiction:
Extent of automationVSUse of energy by moving object

Solution Approach 1:

The patent replaces expensive, complex AI models with a simpler database-querying approach. The context database stores pre-computed code completion information that can be retrieved quickly without requiring heavy computational resources, thus reducing energy consumption while maintaining automation capability.

Inventive Principle:
Principle #27Cheap short-living objects (Disposable)

Solution Approach 2:

The system substitutes the mechanical process of running complex AI models with a database query mechanism. Instead of using computational power to generate completions in real-time, the system queries pre-processed information from the context database, significantly reducing computing resource requirements.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

3Extent of automation

If network-based AI prediction is used, then code completion functionality is improved, but response time increases due to network transmission delay

Engineering Contradiction:
Improvecode completion functionalityVSAvoidresponse time
Core Design Contradiction:
Extent of automationVSLoss of time

Solution Approach 1:

The system performs self-service by executing static analysis locally on the user's code input and querying the context database without requiring network connections. This self-contained approach eliminates network transmission delays while maintaining full code completion functionality through local processing.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The context database is pre-built and stored locally, containing code completion information that can be accessed immediately without network requests. By performing the database query locally after static analysis, the system eliminates network delays and provides fast response times while maintaining automation functionality.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS12547382B2Code processing method and apparatus, device, and medium
Publication Date: 2026.02.10 HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
  • US12547382B2 patent drawing
  • US12547382B2 patent drawing
  • US12547382B2 patent drawing

AI summary

Code inputted by a user is received through a user interface. A feature of context of to-be-completed code is determined based on the code inputted by the user. Next, at least one candidate item of the to-be-completed code is determined from a context database based on the feature of context of the to-be-completed code. The context database stores sample code and a feature of context of the sample code. Then, the at least one candidate item is presented to the user through the user interface.