IntelliJ Community . SmartGotoMethodDeclaration

 
SmartGotoMethodDeclaration 

HOME INDEX SEARCH CHANGES GO  

SmartGotoMethodDeclaration

This plugin was tested with IntelliJ IDEA 3.0 Build 681 but might work with other builds.

What is it?

This plugin provides somewhat smart navigation to method declarations. It works like the built-in "Go to Declaration" (Ctrl+B) with one key difference: It remembers the apparent type of the arguments being passed to a method and uses that information for subsequent navigations. This is useful whenever you're navigating along a chain of method calls and there are implicit type casts going on. Implicit type casts happen when the type of a method call argument is a subtype of the type of the formal parameter of the method being called. Consider this code:


public class ImplicitTypeCast {
  void foo() {
    BigDecimal b = new BigDecimal("42");
    bar(b); // (1)
  }
  void bar(Object o) {
    String s = o.toString(); // (2)
  }
}

There is an implicit type cast going on in line (1). "b", which is of type BigDecimal is cast to an Object. When using the built-in "Go to Declaration (Ctrl+B)", this type information is lost, and invoking "Go to Declaration (Ctrl+B)" again on "toString" in line (2) goes to Object.toString(). Wouldn't it be nice if it would go to BigDecimal.toString() instead? I thought it would be, so I wrote this plugin.

How to install it

Copy the jar file into the "plugins" directory of IntelliJ IDEA.

How to use it

  • Place the caret on a method call and invoke "Smart Goto Method Declaration" (Ctrl+Alt+S, G). The caret will move to the method declaration and a tooltip with the saved type information will show up.
  • From anywhere in the code, invoke "Goto Method Call" (Ctrl+Alt+S, C) to go back to the method call of the last navigation.
  • From anywhere in the code, invoke "Goto Method Declaration" (Ctrl+Alt+S, C) to go back to the method declaration of the last navigation.
  • From within the method declaration of the last navigation, invoke "Show Type Info" (Ctrl+Alt+S, I) to show the tooltip with the saved type information again.

To do

  • Use saved type info of previous navigation (if available) when determining type info of method call arguments. This will pass the original type info through to all method declarations, not just the next one.
  • Undo (returns to the method call and restores the saved info of the previous navigation)
  • Make tooltip go away when Esc is pressed
  • Disable/hide menu items when caret is not on a method call
  • Make it work for constructor calls
  • Be more sophisticated when determining the type of arguments (this get's very hairy very quickly, though)

Version History

0.1 (08 Dec 2002)
  • Initial version

Disclaimer

This plugin uses the as of yet unpublished and unsupported IDEA ProgramStructureInterface and may not work as intended in future builds. Please do not submit bug reports or feature requests to the Tracker.

-- ThomasVollmer - 08 Dec 2002

IntelliJPluginWebForm
IntelliJPluginName: SmartGotoMethodDeclaration
IntelliJPluginVersion: 0.1
IntelliJPluginVendor: Thomas Vollmer
IntelliJPluginBinary: http://www.intellij.org/twiki/pub/Main/SmartGotoMethodDeclaration/SmartGotoMethodDeclaration-0.1.jar
IntelliJPluginSource: http://www.intellij.org/twiki/pub/Main/SmartGotoMethodDeclaration/SmartGotoMethodDeclaration-0.1-src.jar
IntelliJPluginClassification:
TopicClassification: IntelliJPluginArchive
TopicShortDescription: This plugin provides somewhat smart navigation to method declarations.
TestedOnOS: OsWinXP
ShouldRunOnOS: AnyOS

Attachment: sort Action: Size: Date: Who: Comment:
SmartGotoMethodDeclaration-0.1.jar action 32557 08 Dec 2002 - 05:19 ThomasVollmer jar
SmartGotoMethodDeclaration-0.1-src.jar action 19580 08 Dec 2002 - 05:20 ThomasVollmer src

e d i t a t t a c h r e f - b y d i f f s m o r e
Have ideas, requests, problems regarding this site? Send feedback.
Copyright © 2000-2003 by the contributing authors. All materials at intellij.org are the property of the contributing authors.