IP Library Granted Patent US 11,822,909
Granted Patent B2
US 11,822,909 · App. 17/901,128 · Granted Nov 21, 2023

Adapting existing source code snippets to new contexts

Inventors: Qianyu Zhang (Sunnyvale, CA); Bin Ni (Fremont, CA); Rishabh Singh (San Jose, CA); Olivia Hatalsky (San Jose, CA)
Assignee: GOOGLE LLC
G06F8/447G06F8/34G06F8/36G06F8/71G06F16/00G06F16/2425G06N3/045G06N3/088
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,822,909
App. No.
17/901,128
Granted
Nov 21, 2023
Kind
B2
Abstract

Implementations are described herein for adapting existing source code snippets to new contexts. In various implementations, a command may be detected to incorporate an existing source code snippet into destination source code. An embedding may be generated based on the existing source code snippet, e.g., by processing the existing source code snippet using an encoder. The destination source code may be processed to identify one or more decoder constraints. Subject to the one or more decoder constraints, the embedding may be processed using a decoder to generate a new version of the existing source code snippet that is adapted to the destination source code.

Claims (34)

1. A method implemented using one or more processors, comprising:

detecting a command to incorporate an existing source code snippet into destination source code;

generating an embedding based on the existing source code snippet, wherein the generating includes processing the existing source code snippet using an encoder;

processing the destination source code to identify one or more decoder constraints, wherein the one or more decoder constraints comprise a dictionary of variable names or function names extracted from the destination source code;

subject to the one or more decoder constraints, processing the embedding using a decoder to generate a new version of the existing source code snippet that is adapted to the destination source code, wherein processing the embedding using the decoder includes biasing the decoder towards the variable names or function names in the dictionary.

2. The method of claim 1 , wherein the existing source code snippet includes a function call, and processing the embedding using the decoder includes generating glue code to adapt the function call to the destination source code.

3. The method of claim 1 , wherein the command comprises a paste command.

4. The method of claim 1 , wherein the command comprises a command to drag-and-drop a graphical element that includes the existing source code snippet into the destination source code.

5. The method of claim 1 , wherein the generating includes processing at least a portion of the destination source code using the encoder.

6. A method implemented using one or more processors, comprising:

detecting a command to incorporate an existing source code snippet into destination source code;

generating a first embedding based on the existing source code snippet, wherein the generating includes processing data indicative of the existing source code snippet using one or more encoders;

generating a second embedding based on the destination source code snippet, wherein the generating includes processing data indicative of the destination source code snippet using one or more of the encoders;

combining the first and second embeddings into a combined embedding; and

processing the combined embedding using a decoder to generate a new version of the existing source code snippet that is adapted to the destination source code.

7. The method of claim 6 , wherein the combining comprises concatenating the first and second embeddings.

8. The method of claim 6 , wherein generating the first and second embeddings include processing the existing and destination source code snippets to generate, respectively, first and second abstract syntax trees.

9. The method of claim 8 , wherein the first and second abstract syntax trees are processed using one or more of the encoders to generate, respectively, the first and second embeddings.

10. The method of claim 6 , wherein the existing source code snippet includes a function call.

11. The method of claim 10 , wherein processing the embedding using the decoder includes generating glue code to adapt the function call to the destination source code.

12. The method of claim 6 , wherein the command comprises a paste command.

13. The method of claim 6 , wherein the command comprises a command to drag-and-drop a graphical element that includes the existing source code snippet into the destination source code.

14. A system comprising one or more processors and memory storing instructions that, in response to execution by the one or more processors, cause the one or more processors to:

detect a command to incorporate an existing source code snippet into destination source code;

generate a first embedding based on the existing source code snippet, wherein the generating includes processing data indicative of the existing source code snippet using one or more encoders;

generate a second embedding based on the destination source code snippet, wherein the instructions to generate include instructions to process data indicative of the destination source code snippet using one or more of the encoders;

combine the first and second embeddings into a combined embedding; and

process the combined embedding using a decoder to generate a new version of the existing source code snippet that is adapted to the destination source code.

15. The system of claim 14 , wherein the instructions to combine include instructions to concatenate the first and second embeddings.

16. The system of claim 14 , wherein the instructions to generate the first and second embeddings include instructions to process the existing and destination source code snippets to generate, respectively, first and second abstract syntax trees.

17. The system of claim 16 , wherein the first and second abstract syntax trees are processed using one or more of the encoders to generate, respectively, the first and second embeddings.

18. The system of claim 14 , wherein the existing source code snippet includes a function call, and the instructions to process include instructions to process the embedding using the decoder includes generating glue code to adapt the function call to the destination source code.

19. The system of claim 14 , wherein the command comprises a paste command.

20. The system of claim 14 , wherein the command comprises a command to drag-and-drop a graphical element that includes the existing source code snippet into the destination source code.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Feb 2, 2023
From: X DEVELOPMENT LLC
To: GOOGLE LLC
Reel/Frame 062572/0565 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 1, 2022
From: ZHANG, QIANYU; NI, BIN; SINGH, RISHABH; HATALSKY, OLIVIA
To: X DEVELOPMENT LLC
Reel/Frame 060967/0748 →
Continuity (2)
Continuation 17159524 · Jan 27, 2021
Related Publication 20230004366A1 · Jan 5, 2023
Cited By (1)
US 12,210,331