Code Completion Using Machine Learning Ranking
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing code completion systems face challenges in efficiently recommending method invocation parameters due to large numbers of irrelevant or lengthy candidate lists, which can hinder developer productivity and increase errors.
Innovation Solution
A machine learning-based approach that uses a weighted sum of scope, edit distance, and declaration proximity scores to rank candidate variables for method invocations, trained on a scope model and method overload model, to provide more accurate and relevant recommendations.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Quantity of substance
If a large list of type-compatible candidates is provided for method parameter completion, then the completeness of candidate coverage is improved, but the time required for developers to browse and select the correct element increases
Solution Approach 1:
The patent replaces the mechanical browsing process with an intelligent recommendation system using machine learning. The system automatically ranks candidate variables based on multiple scoring factors (scope score, edit distance score, declaration proximity score) and presents only the most relevant candidates, eliminating the need for developers to manually browse through lengthy lists while maintaining comprehensive candidate coverage.
Solution Approach 2:
The patent changes the parameter of candidate presentation from displaying all type-compatible candidates to displaying ranked candidates based on computed scores. By introducing scoring parameters (scope, edit distance, declaration proximity) and weighting them appropriately, the system transforms the candidate list from an exhaustive unranked collection to a prioritized recommendation list, reducing browsing time while maintaining completeness.
2Device complexity
If traditional code completion methods are used, then the implementation is simple, but the accuracy of recommendations is low due to irrelevant candidates
Solution Approach 1:
The patent performs preliminary actions by pre-training machine learning models on scope models and method overload models before actual code completion. These pre-trained models capture patterns and relationships in the codebase, enabling accurate recommendations without requiring complex real-time analysis. The scope model and method overload model are prepared in advance to quickly evaluate candidate variables during completion.
Solution Approach 2:
The patent introduces machine learning models as intermediaries between the code context and candidate variable selection. Instead of directly matching candidates based on simple type compatibility, the system uses trained models to compute scope scores, edit distance scores, and declaration proximity scores, which serve as intermediate evaluations to determine the most relevant candidates, thereby improving recommendation accuracy.
3Adaptability or versatility
If multiple features are added to detect coding patterns, then the detection capability is improved, but the system complexity increases necessitating modifications to recommendation logic
Solution Approach 1:
The patent creates a universal machine learning framework that can handle multiple coding patterns and features through a single cohesive system. Instead of implementing separate detection mechanisms for different patterns, the system uses trained models that generalize across various coding contexts. The scope model, method overload model, and scoring mechanism work together as a multi-functional system that adapts to different patterns without requiring separate recommendation logic for each feature.
Data Source
Figure 1
Figure 2A
Figure 2B
AI summary
A code completion tool uses machine learning models to more precisely predict the likelihood of the parameters of a method invocation. A score is computed for each candidate variable that is used to rank the viability of a variable as the intended parameter. The score is a weighted sum of a scope factor, an edit distance factor and a declaration proximity factor. The factors are based on a scope model, a method overload model, and a weight file trained offline on a training set of source code programs utilizing various method invocations.