简体   繁体   中英

Best “identifying markers” in code which help quick navigation to a certain location in code?

In a class with 750+ lines, it is very time consuming to scroll through the code searching a specific method. when you're not the author of the code, wasted time multiplies.

What techniques do you use when you need to quickly jump to a specific method? Remember, it's not your code and you cannot memorize method name. You also cannot jump to a specific line as it's hard to memorize line numbers.

I use two approaches, which are the best I came up to.

  1. I set a breakpoint at some method . Pro: visually appealing, Con: irritating when debugging and mixes with the "real" breakpoints
  2. I set //TODO marker at some method . Pro: easy to navigate via Todo list. Con: mixes with "real" todo tasks and increases possibility to oversee some task

Please advise...

This is one of the things IJ does best.

ctrl-click/ctrl-b: jump to definition from its usage (you should be using this constantly)

Structure View (Alt-7) combined with the structure view button which says "Scroll From Source"

ctrl-shift-left/right: move between previous cursor locations edit location

ctrl-alt-shift-N: find any symbol by name. Even if you dont know that much of the name. You can use wild cards, and camel case, or leave it all lowercase and perform case insensitive search.

Alt-F6 : find usages of element at caret. (Show me where this API is being used)

Bookmarks, they work like your breakpoints and todos, except their intended purpose matches your needs - are all visually different and support quick keyboard navigation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM