DEV Community

Cover image for HarmonyOS Development: Those Practical Small Functions in DevEcoStudio
程序员一鸣
程序员一鸣

Posted on

HarmonyOS Development: Those Practical Small Functions in DevEcoStudio

Foreword 

this article is based on DevEco Studio 5.0.5 Release 

as the saying goes, if a worker wants to do a good job, he must first sharpen his tools. If he is skilled in using a development tool, he can be said to be even more powerful in writing code. On the basis of proficiency, he is familiar with several practical small tools, which can improve the efficiency of development and problem solving. In this article, we simply list several small functions in DevEcoStudio to see if you have used them. 

Function 1: Show in APi Reference 

this function must be familiar to everyone. It can go directly to the Api with one key to help you quickly understand the relevant introduction of this component or attribute. The usage is also very simple. On top of the components or attributes you need to know, right-click directly and select the Show in APi Reference option. 

Image description

After clicking, the relevant Api introduction will be displayed on the right, and it will be directly located on the components or attributes you have selected. It is very convenient. In development, it is simply too convenient to encounter attributes that you cannot, or you want to view the set parameters, how to use them, etc. After directly right-clicking and selecting, you can view the official documents, and you no longer need to look around without the development tools. 

Image description

Function two: Find Usages 

in many scenarios, for example, to reconstruct a certain function, or to replace an object, method and variable for the whole project, at this time, you need to globally retrieve the positions referenced by the current objects, Method variables and so on, and modify them one by one. The Find Usages function is used, which can quickly help you to check the places where the objects you choose are referenced, it can greatly improve your development efficiency.

The usage is very simple, just place the mouse on the object you want to retrieve, which can be an object, a function, a variable, etc., right-click and select Find Usages, or you can also use shortcut keys (because the system is different, the shortcut keys selected by IDE are different, then the shortcut keys are also different, normally WindowsAlt + F7,macOS is Option + F7). 

Image description

After selection, all the referenced places will be displayed at the bottom of the development tool, without any missing, so that you can avoid forgetting one when modifying. 

Image description

Function three: quick generation of function comments 

this function really has nothing to say, and it also exists in other IDE. The reason why it is written is that everyone can use it skillfully. Don't comment on the function by hand. It is also very simple to use. Enter "/** "+ Enter key on a function to quickly generate Comment Information. If your function has many parameters, this function is simply not too convenient. 

Image description

Function four: code structure tree view 

if there are many codes and functions in a file, it is very inconvenient for us to view them. With the code structure tree view, we can intuitively see the code structure information of the current file, including global variables and functions, class member variables and methods, etc., and jump to the corresponding code line. 

After opening a file, directly click the Structure option at the lower left foot, or use the shortcut key (the same sentence, the system and setting language are different, the shortcut key is also different, the common shortcut key is: WindowsAlt +7 / Ctrl + F12,macOS is Command +7). 

Image description

The code structure can be viewed in the lower left area:

Image description

Related Summary 

this article will give you four inventory for the time being. In the following articles, the functions in DevEco Studio that can improve our development efficiency will also be summarized continuously. 

This article label: Hongmeng Development Tools/DevEco Studio

Top comments (0)