IP Library Granted Patent US 11,442,702
Granted Patent B2
US 11,442,702 · App. 16/579,750 · Granted Sep 13, 2022

Code completion

Inventors: Adam Smith (San Francisco, CA); Tarak Upadhyaya (San Francisco, CA); Juan Lozano (San Francisco, CA); Daniel Hung (San Francisco, CA)
Assignee: Affirm, Inc.
G06F8/33G06F8/34G06F40/284G06N3/04
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,442,702
App. No.
16/579,750
Granted
Sep 13, 2022
Kind
B2
Abstract

A system and method may provide assistance to programmers during programming to reduce the number of routine tasks that must be performed. In some aspects, the system may suggest one or more code snippets that comprise code completions. The code snippets may be single or multi-token. In some aspects, the system may provide predictive editing or predictive navigation, where the system may predict edits or navigation actions based on a programmer's actions. In some aspects, the system is based on machine learning methods and is trained on past actions of programmers in a code editor.

Claims (78)

1. A computer-implemented method comprising:

receiving edits at a cursor location in a code editor from a programmer;

updating source code at the cursor location in response to the edits received from the programmer;

detecting, with a code completion system, an event to trigger code completion;

determining features of the source code near the cursor location, wherein the features include one or more tokens near the cursor location;

using the features to search for code snippets in a team or local data set and to generate code snippets based on one or more models trained using the team or local data set;

identifying or generating one or more candidate code snippets;

predictively determining a selection of one of the candidate code snippets as a selected code snippet without user input or selection; and

automatically modifying, with the code completion system, and without user input or selection, the source code by inputting the selected code snippet into the source code,

wherein the one or more trained models further employ machine learning to identify actions that lead to a navigation, and learn the navigation to be performed to suggest the navigation to the programmer,

wherein the team or local data set is specific to prior code snippet selections made by a member of the team or an individual user on the team, and

wherein the team or local data set includes both positive and negative examples of the prior code snippet selections.

2. The computer-implemented method of claim 1 , further comprising:

ranking the one or more candidate code snippets according to a score;

wherein the score is based at least on a calculation of relevance.

3. The computer-implemented method of claim 2 , wherein the calculation of relevance is based at least in part on one or more features of tokens near the cursor location.

4. The computer-implemented method of claim 1 , wherein using the features to search for or generate code snippets comprises inputting the features into a neural network and receiving an output from the neural network.

5. The computer-implemented method of claim 4 , wherein the neural network comprises a graph neural network.

6. The computer-implemented method of claim 1 , wherein using the features to search for or generate code snippets comprises using a lexical language model.

7. The computer-implemented method of claim 1 , wherein using the features to generate code snippets comprises using beam search.

8. The computer-implemented method of claim 1 , wherein the event is detecting that the programmer has finished typing.

9. The computer-implemented method of claim 1 , wherein one or more of the candidate code snippets is a multi-token code snippet.

10. The computer-implemented method of claim 1 , wherein each of the candidate code snippets includes a set of one or more associated keywords, the one or more associated keywords determined by analyzing one or more external codebases.

11. The computer-implemented method of claim 1 , wherein the selected candidate code snippet includes whitespace, and the whitespace is customized according to one or more inferred parameters from a codebase of the programmer.

12. The computer-implemented method of claim 1 , wherein the selected candidate code snippet includes whitespace, and the whitespace is customized according to one or more rules that are set in a development environment.

13. The computer-implemented method of claim 1 , wherein predictively determining the selection of the one of the candidate code snippets as the selected code snippet comprises determining an estimated value of each of the candidate code snippets and choosing the selected code snippet based on the estimated value.

14. The computer-implemented method of claim 1 , wherein predictively determining the selection of the one of the candidate code snippets as the selected code snippet comprises determining an estimated value of each of the candidate code snippets and automatically implementing the selected code snippet only if the estimated value of the selected code snippet is greater than a threshold.

15. A computer-implemented method comprising:

receiving edits at a cursor location in a code editor from a programmer;

updating source code at the cursor location in response to the edits received from the programmer;

detecting, with a code completion, an event to trigger code completion;

determining features of the source code near the cursor location, wherein the features include one or more tokens near the cursor location;

using the features to search for code snippets in a team or local data set and to generate code snippets based on one or more models trained using the team or local data set;

identifying or generating one or more candidate code snippets, wherein the one or more candidate code snippets are multi-token code snippets and the candidate code snippets contain content, the content of the candidate code snippets being adapted to a source code context at the cursor location;

predictively determining a selection of one of the candidate code snippets as a selected code snippet without user input or selection; and

automatically modifying, with the code completion system, and without user input or selection, the source code by inputting the selected code snippet into the source code,

wherein the one or more trained models further employ machine learning to identify actions that lead to a navigation, and learn the navigation to be performed to suggest the navigation to the programmer,

wherein the team or local data set is specific to prior code snippet selections made by a member of the team or an individual user on the team, and

wherein the team or local data set includes both positive and negative examples of the prior code snippet selections.

16. The computer-implemented method of claim 15 , further comprising:

ranking the one or more candidate code snippets according to a score;

wherein the score is based at least on a calculation of relevance.

17. The computer-implemented method of claim 16 , wherein the calculation of relevance is based at least in part on one or more features of tokens near the cursor location.

18. The computer-implemented method of claim 15 , wherein using the features to search for or generate code snippets comprises inputting the features into a neural network and receiving an output from the neural network.

19. The computer-implemented method of claim 18 , wherein the neural network comprises a graph neural network.

20. The computer-implemented method of claim 15 , wherein using the features to search for or generate code snippets comprises using a lexical language model.

21. The computer-implemented method of claim 15 , wherein using the features to generate code snippets comprises using beam search.

22. The computer-implemented method of claim 15 , wherein the event is detecting that the programmer has finished typing.

23. The computer-implemented method of claim 15 , wherein each of the candidate code snippets includes a set of one or more associated keywords, the one or more associated keywords determined by analyzing one or more external codebases.

24. The computer-implemented method of claim 15 wherein the selected candidate code snippet includes whitespace, and the whitespace is customized according to one or more inferred parameters from a codebase of the programmer.

25. The computer-implemented method of claim 15 , wherein the selected candidate code snippet includes whitespace, and the whitespace is customized according to one or more rules that are set in a development environment.

26. The computer-implemented method of claim 15 , wherein predictively determining the selection of the one of the candidate code snippets as the selected code snippet comprises determining an estimated value of each of the candidate code snippets and choosing the selected code snippet based on the estimated value.

27. The computer-implemented method of claim 15 , wherein predictively determining the selection of the one of the candidate code snippets as the selected code snippet comprises determining an estimated value of each of the candidate code snippets and automatically implementing the selected code snippet only if the estimated value of the selected code snippet is greater than a threshold.

28. A computer-implemented method comprising:

receiving edits at a cursor location in a code editor from a programmer;

updating source code at the cursor location in response to the edits received from the programmer;

detecting, with a completion system, an event to trigger code completion;

receiving one or more keywords;

determining features of the source code near the cursor location, wherein the features include one or more tokens near the cursor location;

using the features and the one or more keywords to search for code snippets in a team or local data set and to generate code snippets based on one or more models trained using the team or local data set;

identifying or generating one or more candidate code snippets, wherein the one or more candidate code snippets are multi-token code snippets;

predictively determining a selection of one of the candidate code snippets as a selected code snippet without user input or selection; and

automatically modifying, with the code completion system, and without user input or selection, the source code by inputting the selected code snippet into the source code,

wherein the one or more trained models further employ machine learning to identify actions that lead to a navigation, and learn the navigation to be performed to suggest the navigation to the programmer,

wherein the team or local data set is specific to prior code snippet selections made by a member of the team or an individual user on the team, and

wherein the team or local data set includes both positive and negative examples of the prior code snippet selections.

29. The computer-implemented method of claim 28 , further comprising:

ranking the one or more candidate code snippets according to a score;

wherein the score is based at least on a calculation of relevance.

30. The computer-implemented method of claim 29 , wherein the calculation of relevance is based at least in part on one or more features of tokens near the cursor location.

31. The computer-implemented method of claim 28 , wherein using the features to search for or generate code snippets comprises inputting the features into a neural network and receiving an output from the neural network.

32. The computer-implemented method of claim 30 , wherein the neural network comprises a graph neural network.

33. The computer-implemented method of claim 28 , wherein using the features to search for or generate code snippets comprises using a lexical language model.

34. The computer-implemented method of claim 28 , wherein using the features to generate code snippets comprises using beam search.

35. The computer-implemented method of claim 28 , wherein the selected candidate code snippet includes whitespace, and the whitespace is customized according to one or more inferred parameters from a codebase of the programmer.

36. The computer-implemented method of claim 28 , wherein the selected candidate code snippet includes whitespace, and the whitespace is customized according to one or more rules that are set in a development environment.

37. The computer-implemented method of claim 28 , wherein predictively determining the selection of the one of the candidate code snippets as the selected code snippet comprises determining an estimated value of each of the candidate code snippets and choosing the selected code snippet based on the estimated value.

38. The computer-implemented method of claim 28 , wherein predictively determining the selection of the one of the candidate code snippets as the selected code snippet comprises determining an estimated value of each of the candidate code snippets and automatically implementing the selected code snippet only if the estimated value of the selected code snippet is greater than a threshold.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jun 15, 2021
From: MANHATTAN ENGINEERING INCORPORATED
To: AFFIRM, INC.
Reel/Frame 056548/0888 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jan 30, 2020
From: SMITH, ADAM; UPADHYAYA, TARAK; LOZANO, JUAN; HUNG, DANIEL
To: MANHATTAN ENGINEERING INCORPORATED
Reel/Frame 051664/0554 →
Continuity (2)
Provisional Application 62735024 · Sep 22, 2018
Related Publication 20200097261A1 · Mar 26, 2020
Cited By (10)
US 12,197,896 US 12,229,533 US 12,260,191 US 12,430,102 US 12,474,896 US 12,475,378 US 12,498,906 US 12,541,449 US 12,578,932 US 12,619,822