preface

Sometimes, you need to mark up parts of your code for future reference, such as optimizations, improvements, possible changes, issues to discuss, etc. We usually put a todo tag in our code like this:

// I'm going TODO XXX here
Copy the code

If you do this, others will do the same. All of a sudden, there may be a lot of toDos in the project, and when you search for your TODO, it becomes very cumbersome, and you lose the meaning of the tag.

IntelliJ IDEA allows us to add special types of comments that are highlighted in the editor, indexed, and listed in the TODO tool window. This makes it easy to track our TODO.

The defaultTODO

By default, IntelliJ IDEA recognizes two patterns: lowercase and uppercase TODO and FIXME These patterns can be used inside line comments and block comments of any supported file type. We can modify the default schema or add our own schema as needed

As shown above, we can create a multi-line TODO (similar to YAML configuring multiple values in Spring Boot) that requires indenting the comment line after the first line. If there is no indentation, the line is treated as a regular comment line

To disable multi-line TODO items, use the shortcuts ⌘ +, open the Preferences, search TODO (Editor | TODO), you will see the following interface

To view all toDos in the system, open the TODO tool window (shortcut key ⌘ + 6). Toggle options to view TODO range:

  • All files from the current project
  • Only based on the scope of the current file
  • Specifies the range of files
  • List of changes to the activity

Here is the introduction of the default TODO provided by Intellij IDEA. In order to find our own TODO more quickly, we need to customize it

Custom TODO

Reopen the TODO location, add TODO Item, and add Optimize to identify the content to be optimized

Add a filter for grouping TODO

Add a random optimization note and use the features described above to quickly locate our own TODO

If your to-do list is usually a relatively fixed description, you can also quickly generate TODO content with a Live Template

Small TODO also has a big point

conclusion

When the team is large and you have a lot TODO at the same time, the TODO feature helps us with identification, and the custom TODO feature helps us locate quickly, so we can take advantage of this feature, but

Clean up TODO regularly

Soul asking

  1. What irregularities/uncleanliness did you find in the code in the project? (Feel free to leave a comment below)

Welcome to continue to pay attention to the public account: “One soldier of The Japanese Arch”

  • Cutting-edge Java technology dry goods sharing
  • Efficient tool summary | back “tool”
  • Interview question analysis and solution
  • Technical data to receive reply | “data”

To read detective novel thinking easy fun learning Java technology stack related knowledge, in line with the simplification of complex problems, abstract problems concrete and graphical principles of gradual decomposition of technical problems, technology continues to update, please continue to pay attention to……