> > |
%META:TOPICINFO{author="ThomasVollmer" date="1039322580" format="1.0" version="1.1"}%
%META:TOPICPARENT{name="ThomasVollmer"}%
This plugin was tested with IntelliJ IDEA 3.0 Build 681 but might work with other builds.
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.
Copy the jar file into the "plugins" directory of IntelliJ IDEA.
- 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.
- 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)
0.1 (08 Dec 2002)
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
%META:FORM{name="IntelliJPluginWebForm"}%
%META:FIELD{name="IntelliJPluginName" title="IntelliJPluginName" value="SmartGotoMethodDeclaration"}%
%META:FIELD{name="IntelliJPluginVersion" title="IntelliJPluginVersion" value="0.1"}%
%META:FIELD{name="IntelliJPluginVendor" title="IntelliJPluginVendor" value="Thomas Vollmer"}%
%META:FIELD{name="IntelliJPluginBinary" title="IntelliJPluginBinary" value="http://www.intellij.org/twiki/pub/Main/SmartGotoMethodDeclaration/SmartGotoMethodDeclaration-0.1.jar"}%
%META:FIELD{name="IntelliJPluginSource" title="IntelliJPluginSource" value="http://www.intellij.org/twiki/pub/Main/SmartGotoMethodDeclaration/SmartGotoMethodDeclaration-0.1-src.jar"}%
%META:FIELD{name="TopicClassification" title="TopicClassification" value="IntelliJPluginPackage"}%
%META:FIELD{name="TopicShortDescription" title="TopicShortDescription" value="This plugin provides somewhat smart navigation to method declarations."}%
%META:FIELD{name="TestedOnOS" title="TestedOnOS" value="OsWinXP"}%
%META:FIELD{name="ShouldRunOnOS" title="ShouldRunOnOS" value="AnyOS"}%
%META:FILEATTACHMENT{name="SmartGotoMethodDeclaration-0.1.jar" attr="" comment="jar" date="1039324795" path="C:\vollmer_t\Private\Projects\IdeaPlugins\SmartGotoMethodDeclaration\SmartGotoMethodDeclaration-0.1.jar" size="32557" user="ThomasVollmer" version="1.2"}%
%META:FILEATTACHMENT{name="SmartGotoMethodDeclaration-0.1-src.jar" attr="" comment="src" date="1039324810" path="C:\vollmer_t\Private\Projects\IdeaPlugins\SmartGotoMethodDeclaration\SmartGotoMethodDeclaration-0.1-src.jar" size="19580" user="ThomasVollmer" version="1.1"}% |