Foreword
this article is based on Api13, DevEco Studio 5.0.5 Release
in the last article, we have a brief understanding of the AI programming tool CodeGenie brought by DevEcoStudio. I don't know if you have any hands-on experience. It is basically the same as most AI tools, but it has some characteristics of its own, supporting intelligent question and answering and code generation. Because it is brought by IDE itself, the results are relatively accurate in the field of Hongmeng programming language, it can be said to be "a riding dust".
In the previous article, we left behind three function points of the CodeGenie tool, namely, code generation, intelligent analysis of compilation errors, and intelligent code interpretation. In this article, we will focus on understanding. Finally, we hope that everyone can experience it in DevEcoStudio, which can deepen the impression of this tool.
Code generation
method 1: Language instruction generation
in the previous article, we experienced that in the CodeGenie tool, we selected the Generate Code option and made CodeGenie Generate Code through language instructions. Let's review the past again.
The use method is very simple, just click the CodeGenie option on the right, and you need to log in to your Huawei account.
In the dialog box that appears, select Generate Code to enable AI to Generate Code in its own language.
Language instructions are relatively flexible. You can organize whatever language you want. AI will generate corresponding code cases according to your language. You can copy, insert the cursor click, or click the "+" sign to save the code.
Way two, edit area code generation
this is great. You can right-click in any code editing area and select CodeGenie:Inline Edit, or execute the shortcut key, Alt + I (depending on the shortcut key configured by your IDE, the shortcut key is different according to the configuration, and Mac is option + I).
The following dialog box will appear, where you can implement the code you want according to your own language instructions, which is very convenient.
For example, if you Enter "write a Text component", it will immediately generate a Text component at the cursor of the mouse. You can click the Accept All option to agree, or the Alt + Enter shortcut key to agree (depending on the shortcut key configured by your IDE, the shortcut key is different depending on the configuration). Of course, you can continue editing or click the cross to close.
It will also reflect the contrast difference with the current code through different colors, green is the newly generated code content, Blue Is the content of the existing code to modify the content, red represents the deleted code content.
Click Regenerate in the dialog box to Regenerate the code fragment according to the current description. If you need to start a new round of Q & A, click Further Edit or use the shortcut Ctrl + K to enter again.
Method 3, in-line/fragment code continuation
this is even more severe. You can continue to write the previous Code, provided that you need to enter the File > Settings >DevEco CodeGenie > Code Generation page to open.
After opening, the code can be continued. The shortcut instructions are as follows:
For example, I have an array, I want to traverse it and print the log, I direct shortcut keys (windows:Alt + C,Mac:Option + C) trigger multi-line code generation, a traverse + log print is good, very convenient.
Compile error intelligent analysis
in addition to intelligent Q & A and code generation, the CodeGenie tool can also intelligently analyze compilation errors.
For example, I intentionally wrote an error:
when you run, the console will output an error message, but there will be an additional AI option, we can click for intelligent analysis.
After clicking, the intelligent question and answer will be automatically triggered and the cause of the error will be analyzed for you. It can be said to be very convenient. In solving the problem, CodeGenie can also free your hands.
Related Summary
it was originally an introduction. The code intelligently interprets this function. However, I found that the latest IDE I installed does not have this option, so I can only explain it later. However, this function is also simple, that is, we can select a piece of code and perform AI intelligent interpretation and analysis. In fact, it is the same as copying the code into the dialog box.
In short, CodeGenie is definitely a necessary and efficient tool in our development. At present, the government is also in continuous optimization. I believe that in the near future, its functions will be more powerful and more friendly to help more developers.
This article label: Hongmeng Development Tools/CodeGenie
Top comments (0)