DEV Community

ZHZL-m
ZHZL-m

Posted on

【Journey of HarmonyOS Next】DevEco Studio User Guide (10)

Image description

1 -> Optimize Imports feature

Using the Optimize Imports provided by the editor, you can quickly clear unused imports and merge or sort imports according to the set rules. Select a file or directory and use the shortcut Ctrl+Alt+O (Control+Option+O for macOS) or click Code > Optimize Imports in the menu bar.

Image description

If you need to modify the optimization configuration, go to File > Settings... > Editor > Code Style, select the development language (currently using ArkTS as an example), and in the Imports tab, you can select whether to merge imports from the same module, sort the elements imported by the same import statement, or sort multiple import statements by module.

Image description

2 -> Parent/child class quick jump

The editor supports quick jumps to the subclass/parent class of the current interface, class, method, and property. Click on the Gutter Icons (gutter icon) to the left of the code editing area to jump to the corresponding parent/child interface or class. If there are multiple inheritance relationships, select the interface/class you want to view in the file list in the pop-up window.

Implemented: You can jump to the corresponding implementation class or subinterface and its corresponding properties/methods.
Implementing: allows you to jump to the corresponding parent interface or the attributes/methods of the parent interface.
Overridden: supports jumping to the corresponding subclass or subclass attributes/methods.
Overriding: supports jumping to the corresponding parent class or the attributes/methods of the parent class.

Image description

This function is enabled by default, and you can enter File > Settings > Editor > General > Gutter Icons through the menu bar, and turn it on or off by checking or unchecking Implemented, Implementing, Overridden, and Overriding.

Image description

3 -> Review the hierarchy of interfaces/classes

The editor supports viewing the hierarchy of the current interface/class parent or subclass. Select or place the cursor in the class/interface name, use the shortcut key Ctrl+H, or select Type Hierarchy on the Navigate tab in the menu bar to view the inheritance structure of the interface/class in the pop-up Hierarchy window.

Hierarchy Window Button Functions:

Image description

4 -> code autocomplete

The editor tool analyzes the context and prompts the names of classes, methods, fields, and keywords that can be completed based on the input content, and supports fuzzy matching.

By default, the autocomplete function sorts by the shortest path, for example, you only need to provide the completion content by the name of the most recently used class, method, field, keyword, etc., you can find it in File > Settings (DevEco Studio > Preferences for MacOS) > Editor > General > Code Sort suggestions by recently used.

illustrate

If you have checked Sort suggestions alphabetically and it doesn't work, check the Code Completion page to make sure that "Sort suggestions alphabetically" is unchecked.

Image description

Image description

Top comments (0)