Recent

Author Topic: Jump to implementation of procedure/function  (Read 8225 times)

russdirks

  • New Member
  • *
  • Posts: 35
Jump to implementation of procedure/function
« on: December 19, 2015, 01:35:24 am »
Is there any way to jump directly to the implementation code of a procedure/function/method?  The only way I can figure out how to do it is a two step process : Alt-H, followed by Ctrl-Shift-UpArrow.  Sure would be nice to do it in one step, especially via a right-click menu.  For me at least, 99.999 percent of the time it's the implementation I'm interested in, not the declaration.

Edit: Meant to say Alt-Up, not Alt-H
« Last Edit: December 19, 2015, 09:51:33 pm by russdirks »

balazsszekely

  • Guest
Re: Jump to implementation of procedure/function
« Reply #1 on: December 19, 2015, 06:09:18 am »
Perhaps you should record the key combinations with the macro recorder, then play it back whenever you need it.
Ctrl+Shift+R  --> Alt-H + Ctrl-Shift-UpArrow --> Ctrl+Shift+R
Ctrl+Shift+P --> to play back

russdirks

  • New Member
  • *
  • Posts: 35
Re: Jump to implementation of procedure/function
« Reply #2 on: December 19, 2015, 06:48:30 am »
Thanks!  That's definitely an improvement!

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: Jump to implementation of procedure/function
« Reply #3 on: December 19, 2015, 05:39:12 pm »
I would find useful this feature, too.  I think, it could be an item of the popup menu: "Jump to implementation".
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Jump to implementation of procedure/function
« Reply #4 on: December 19, 2015, 09:23:00 pm »
Ctrl+Shift+Down goes to implementation, when you are hovering the definition of procedure. And with Up key back to definition.

russdirks

  • New Member
  • *
  • Posts: 35
Re: Jump to implementation of procedure/function
« Reply #5 on: December 19, 2015, 10:05:36 pm »
Ctrl+Shift+Down goes to implementation, when you are hovering the definition of procedure. And with Up key back to definition.

On my system (Laz 1.4.4, Win10, all defaults), Ctrl+Shift+Up is mapped to "Find Procedure Definition" and Ctrl+Shift+Down is mapped to "Find Procedure Method".  In practice though, I find they both do the same thing ... if you press either of them repeatedly they will jump back and forth between the method declaration and the method implementation.

What I was talking about in my OP, though, was when you encounter a *reference* to a method/procedure somewhere in your code, either in the unit it is defined in, or even another unit, and you want to jump to the implementation of that method/procedure.  The only way I can find to do that is Alt+Up, followed by Ctrl+Shift+Up  (or Down).

guest58172

  • Guest
Re: Jump to implementation of procedure/function
« Reply #6 on: December 20, 2015, 03:01:41 am »
Not to mention that in the LCL the declarations and the implementations are often located in two separate files. So after the hiting the two shortcuts you often have two new pages in the editor.

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: Jump to implementation of procedure/function
« Reply #7 on: December 20, 2015, 07:37:20 am »
ref [ http://forum.lazarus.freepascal.org/index.php/topic,15688.msg161610.html#msg161610 ]
are others too
ref suggestion [ http://bugs.freepascal.org/view.php?id=27016 ] are others with similar  subject
the subject discussed and rejected
i make use of these macros to overcome
also post them here [ http://www.pilotlogic.com/sitejoom/index.php/forum/ct-tools/3004-ide-macros-you-might-find-them-usefull-as-well ]
--------------------
SelectProcedure -->Selects the current procedure
JunpToDefinition-->Jumps where the code is actualy writen for the identifier /<--- This is the one you are talking about ( implementation)
JunpToProcedureStart-->Jumps at the declarations place of the procedure
JunpToProcedureEnd-->Jumps at the last [end] of the procedure
EncloseParametr-->auto encloses the next word to the current selection from the drop down auto complete list ex. if your current word is ainteger and you are writting
writeln[ call the macro here ]ainteger you will get writeln(ainteger);
JumpToFirstOccurence-->useful when you are in the declaration place of a class field and you want to locate the first reference in a property declaration
--------------------
hope you will find them usefull
you can import the xml using the import command from the macro editor
pay attention to the key assignments maybe you prefere other combinations
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

russdirks

  • New Member
  • *
  • Posts: 35
Re: Jump to implementation of procedure/function
« Reply #8 on: December 20, 2015, 06:38:29 pm »
@Never,

Thanks.  Your JumpToDefinition is pretty much exactly what I got when I recorded Alt-Up, Ctrl+Shift+Up into a macro.

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: Jump to implementation of procedure/function
« Reply #9 on: December 20, 2015, 09:20:33 pm »
@russdirks,
you are welcome, i'm glad you found them useful
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

 

TinyPortal © 2005-2018