Can anyone tell me how to get the name of the method in the code editor the cursor is currently in?

Can anyone tell me how to get the name of the method in the code editor the cursor is currently in?

I know that I could access the editor buffer via OTA and parse it myself but I prefer a solution that already exists and works (probably in some of the IDE plugins out there).

Comments

  1. In the CnPack wizards source, in CnWizUtils, there is CnOtaGetCurrentProcedure. It appears to do what you want.

    ReplyDelete
  2. David Millington I just said I don't want to do the parsing myself - if there is an OTA function that already does that it would be awesome but I doubt that.
    I don't think that GExperts has such a combobox but the ModelMaker plugin has for sure (which is closed source as is Castalia).
    Bill Meyer Not using CnPack I just know the GExperts procedure list does not select any method but the first in the list. If you can find that that would be much appreciated.

    ReplyDelete
  3. Stefan Glienke I rewrote my earlier note. I do not have time to discover how much of the CnPack code is needed to do the work. It does appear to use their parser, in addition to OTA capabilities.

    ReplyDelete
  4. There is no existing OTAPI method to get it, so the closest is a code example using the OTAPI. The example I gave doesn't make you do your own parsing, at least not true language parsing. It finds the method given a line number inside the method. You might need to write code to find the method name inside a single line. But it will get you pretty close at least!

    CnPack will probably have and use its own Delphi parser, from memory. Its code may be harder to integrate into whatever you're doing.

    ReplyDelete
  5. CnPack adds the Procedure List Toolbar to the IDE, with a combobox that provides navigation between methods and, at the same time, highlights the method where the cursor is in

    ReplyDelete
  6. I'm pretty sure I've discussed this with Gerrit Beuze a long while ago and the only thing is doing parsing. The Kibitz compiler is too broken to rely on.

    ReplyDelete

Post a Comment