Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the shortcut keys and tips for IDEA to view the source code efficiently?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is mainly for everyone to analyze the IDEA efficient view source shortcuts and tips is what the relevant knowledge points, detailed and easy to understand, reasonable operation details, with certain reference value. If you are interested, you may wish to follow Xiao Bian to have a look. Let's follow Xiao Bian to learn more about "IDEA's shortcut keys and tips for efficiently viewing source code".

Basic operations View the hierarchy of the current class Use frequency-related shortcuts Ctrl + H

Usually, when we read the source code, we often need to look at the class hierarchy. For example, when we encounter abstract classes or interfaces, we often need to see which classes implement them.

Taking Spring source code as an example, BeanDefinition is an interface for Bean properties/definitions.

public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement { ......}

If we need to see which classes BeanDefinition is implemented by, we simply move the mouse over the BeanDefinition class name and use Ctrl + H.

Similarly, if you want to see which classes implement the AttributeAccessory interface inherited by interface BeanDefinition, simply move the mouse over the AttributeAccessory class name and use Ctrl + H.

View class structure Use frequency-dependent shortcuts Alt + 7(Win) / Command +7 (Mac)

Class structure allows us to quickly understand the methods, variables/constants of the current class, very useful!

We can use the shortcut Alt + 7(Win) / Command +7 (Mac) anywhere in the corresponding class.

Quick Search Class Use Frequency-Related Shortcuts Ctrl + N (Win) / Command + O (Mac)

Use Ctrl + N (Win) / Command + O (Mac) to quickly retrieve classes/files.

Keyword search frequency of use related shortcuts

Ctrl + F (Win) / Command + F (Mac)

Global Text Retrieval: Ctrl + Shift + F (Win) / Command + Shift + F (Mac)

View the implementation of a method/class Class Use frequency-dependent shortcuts Ctrl + Alt + B (Win) / Command + Alt + B (Mac)

If we want to jump directly to the implementation class of a method/class, we can use Ctrl + Alt + B/Win/ Command + Alt + B/Mac on the method name or class name.

If the corresponding method/class has only one implementation class, it will jump directly to the corresponding implementation class.

For example, getBeanClassName() method of BeanDefinition interface is only implemented by AbstractBeanDefinition abstract class. We can directly jump to the corresponding implementation method in AbstractBeanDefinition abstract class by using shortcut key for this method.

public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement { @Nullable String getBeanClassName(); ......}

If there are multiple implementation classes for the corresponding method/class, IDEA will pop up a selection box for you to select.

For example, the getParentName() method of the BeanDefinition interface has several different implementations.

View how a method is used Use frequency-dependent shortcuts Alt + F7

We can see where this method has been called by pressing Alt + F7 directly on the method name.

View recently used files Use frequency-related shortcuts Ctrl + E(Win) / Command +E (Mac)

You can use Ctrl + E(Win) / Command +E (Mac) to display some of the files IDEA has recently used.

View the class inheritance chain in the form of a diagram. Use frequency related shortcuts. There are many related shortcuts. It is not recommended to remember them.

Right-click the class name and select Shw Diagrams to view the class inheritance chain in diagram form.

You can also do some manipulations on the chart. For example, you can right-click on a specific class in the diagram and choose to display its implementation class or parent class.

For example, you can also choose whether to display attributes, methods, internal classes, and so on.

If you want to jump to the source code of the corresponding class, right-click on the specific class in the diagram and select Jump to Source.

Plug-ins recommend one-click generation method sequence diagram

A sequence diagram, also known as a sequence diagram, is a UML behavior diagram. Represents the sequential invocation relationship between objects when the system executes a method/operation (such as login operation).

This sequence can be understood as follows: you need to execute a method/operation login provided by some object a in the system, but this object depends on the method getUser provided by object b. Therefore, there is a -> b call relation here.

SequenceDiagram is a plug-in that allows you to generate method sequence diagrams with one click.

If you can't use IDEA's plugin market due to network problems, you can also download and install it manually through the official website of IDEA's plugin market.

How to use it?

1. Select the method name (note not to select the class name), then right-click and select Sequence Diagram option!

2. Configure some basic parameters of the generated sequence diagram. For example, after calling the depth, we can click ok!

You can also locate the relevant code through the generated sequence diagram, which is especially helpful when we read the source code!

After the time series diagram is generated, you can also choose to export it as a picture.

Related reading: "IDEA one-click generation method of the sequence diagram God operation."

Item Code Statistics

In order to quickly analyze the project situation, we can count the total number of lines of code, lines of code in a single file, lines of comments, etc.

Statistic is a plug-in to help us achieve this requirement.

With this plug-in you can visually see all types of file information in your project such as number, size, etc., to help you better understand your project.

You can also use it to see the total number of classes, the number of valid lines of code, the number of comment lines, the percentage of valid code, and so on.

If you're worried about the plugin affecting IDEA's speed too much, turn it on only when there's a code statistics requirement, and disable it at other times!

About "IDEA efficient view source code shortcuts and tips is what" on the introduction to this, more related content can be searched for previous articles, hope to help you answer questions, please support the site!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report