Huawei Cloud CodeArts Snap Intelligent Programming Assistant PyCharm Plug-in Installation and Usage Guide

1 Plug-in installation and download

1.1 Search plug-in

Open PyCharm, select File, and click Settings.

Select Plugins, click Marketplace, and enter Huawei Cloud CodeArts Snap in the search box.

1.2 Install plug-ins

As shown in the picture above, click the Install button to install the Huawei Cloud CodeArts Snap plug-in. A pop-up message will appear saying that you need to install the Huawei Cloud Toolkit Platform. Click Install to continue the installation. (Note: Huawei Cloud plug-in relies on the unified Huawei Cloud developer ecological base for login, this is a required option)

After the plug-in is downloaded and installed, click Restart IDE, or manually close the IDE and reopen it to make the plug-in installation take effect.

After the download is completed, we can see on the IDE panel: 1) Huawei Cloud Tookit function key in the left sidebar; 2) Huawei Cloud CodeArts Snap plug-in icon in the lower right corner.

2 Plug-in login

2.1 Obtain an authorized account

If your Huawei Cloud account has obtained CodeArts Snap trial authorization, please go to the next step. If not, please click https://devcloud.cn-north-4.huaweicloud.com/codeartssnap/apply to submit an application.

2.2 Multiple login methods

The Huawei Cloud plug-in provides three login methods: 1) Huawei account login; 2) Huawei Cloud AK/SK login; 3) Third-party account login (CSDN).

2.2.1 Log in with Huawei account

Method 1: Click the CodeArts Snap icon in the lower right corner and click Login to HUAWEI.

Method 2: Click Huawei Cloud Toolkit on the left toolbar, click on the character logo as shown in the figure, and select "Huawei Account Login".

On the browser page that pops up, fill in your Huawei account and password.

Read and agree to the disclaimer and complete the login process.

2.2.2 Huawei Cloud AK/SK login

Method 1: Click the CodeArts Snap icon in the lower right corner and click Login to HUAWEI.

Method 2: Click Huawei Cloud Toolkit on the left toolbar, click on the character logo as shown in the figure, and select "Huawei Account Login".

Method 3: Find Huawei Cloud Toolkit Settings in File -> Settings and click log in to quickly enter the Huawei Cloud console.

Click "Add Access Key" to apply for an access key.

Fill in any remark information and click "OK".

After successful creation, the system will prompt you to click Download Now, and the access key information will be saved in the credentials.csv file. Please note that each person can add up to 2 access keys, and each access key can only be downloaded once, so please keep it safe. If you accidentally lose the key, you don’t need to worry. You only need to delete the historical key and apply for creation again.

Open the downloaded access key document, copy the AK in the Access Key Id column and the SK in the Secret Access Key column and fill them in respectively on the login interface and click OK.

Read and agree to the disclaimer and complete the login process.

3 Plug-in usage instructions

3.1 Generate trigger and function key descriptions

3.1.1 Generate trigger instructions

Code (including comments) generation can be triggered anywhere in the IDE edit box, and there are three triggering methods.

  • Hit Enter
  • Shortcut key Alt + c
  • Automatically trigger after waiting for a certain period of time during programming (time and trigger mechanism can be adjusted)

3.1.2 Function key description

If shown, from left to right they are:

  • Accept: Use the Tab key to accept the generated results
  • Next: Use Alt+] keys to view the next recommendation
  • More: Use Alt+R keys to open the results bar on the right to view multiple result options
  • Results: The number of generated results and the result item currently being read

3.2 Introduction to settings

Find Huawei Cloud CodeArts Snap under File -> Settings and click to display the feature list.

Click Code Generation to see various personalization options.

3.3 Setup instructions

3.3.1 Code generation function switch

This can be considered as the master switch of the function. Enable means to start the code generation function, and Disable means to turn off the code generation function.

3.3.2 Personalized function settings

As shown in the figure, the default configuration items of the personalization function are explained from top to bottom.

3.3.2.1 Line-level Generation

Row-level code generation (enabled by default). CodeArts Snap generates corresponding code snippets based on existing code and contextual information. Row-level code generation scenarios include but are not limited to:

1) Trigger generation in a line of code: When the cursor is in a certain line of code to trigger code generation, CodeArts Snap will provide corresponding code continuation suggestions to quickly complete the line of code.

2) Trigger generation when there is already code in the function body: When developers write code in the function body, the plug-in will provide code continuation suggestions based on the existing code and function signature to help developers complete the writing of the function body more efficiently.

This default setting can help developers quickly implement business logic and improve programming efficiency.

3.3.2.2 Function-level Generation

Function-level code generation (enabled by default). CodeArts Snap will generate corresponding code based on existing function signatures and text descriptions. Function-level code generation scenarios include but are not limited to:

1) Trigger generation when there is a function signature: the plug-in will automatically generate matching function body code based on the function signature.

2) Trigger generation when there is a function signature and text description: The plug-in will combine the function signature and text description to generate more accurate function body code to meet specific business needs.

This default setting can help developers quickly implement business logic and improve programming efficiency.

3.3.2.3 Hide Generation Tip

Hide function of prompt box during generation (closed by default). The "Generating Code..." prompt box more clearly reminds developers that the code generation function is in use.

Developers can activate the hidden prompt box function according to their own needs and programming habits. At this time, only the progress bar in the lower right corner will prompt that the code generation function is in use.

3.3.2.4 Auto-trigger on Pause

Automatically trigger tag generation (enabled by default). When developers pause typing while writing code, the plug-in will automatically identify the contextual content of the cursor position and provide generated recommendations for the next line of code or the continuation of the current line of code. This function can provide programming inspiration when developers pause to think, improve development efficiency, and allow developers to focus more on core business logic.

3.3.2.5 Auto-trigger Time Delay

Automatically trigger code generation interval setting (default setting is 3s). Used to control how long CodeArts Snap automatically triggers code generation after the developer pauses input. By adjusting the time delay, you can provide developers with more appropriate thinking time and avoid too frequent prompts from interfering with the developer's programming process, thereby achieving better developer experience and programming efficiency. The minimum adjustable value is 1s and the maximum value is 10s.

Guess you like

Origin blog.csdn.net/weixin_38933806/article/details/134005452