April meeting follow-up

Open Tools API

Warren Postma showed us different ways to write plug-ins for the Rad Studio IDE and explained the pros and cons of each approach.

One of his examples uses the Castalia Delphi Parser to look for badly aligned begin/end statements or evil WITHs in the current unit. For the purposes of this discussion, an “evil WITH” is defined as absolutely any use of the statement. This alone made the whole night worth while. Nick Hodges would be proud.

Here are his notes:

Each sample repository contains a readme in html format with some notes and links. You can browse the code online or grab a copy (clone) with mercurial, using the repo link, or you can go to the download tab (links shown below) to download a zip copy.
The recommended way to use the helloworld samples is to open them up and build them, then install them and try them, then poke around the code and find how it works by reading it. There’s not so much code there, and almost all of it is important, except you can ignore the castalia parser code which was put in there just to make it easier to get it integrated when you want to have a pascal parser library in a real world expert, as shown in the last of the three demos.
The first of our three demos, the hello world Wizard sample shows in Package (BPL) form, how to use the open tools api Wizard interface.It may seem easier to use but the limitations and annoyances of a BPL wizard are severe and it is not a recommended approach for most IDE plugin requirements.
The second demo, the hello world Expert sample shows in an Expert DLL form, how to use the most central open tools api  Expert  interfaces.  It shows how to export the registration function from the DLL, how to integrate with the IDE about box and IDE splash screen including a little icon that shows while Delphi starts up, and how to add a menu item in the main menu and add a menu item in the project right click menu, how to integrate with the IDE Insight feature, and how to make keyboard shortcuts (hotkeys) work.
Finally a third demo that actually tries to do something interesting using the open tools APIs. Since the above helloworld expert is only a skeleton, and while useful as a starting place for someone who wants to write a wizard, doesn’t actually do anything that you might want to do and is certainly not something you would find you couldn’t live without, I wanted to make a demo that while not yet an invaluable tool, shows some of the potential for wizards. This one implements a custom parser, grabs the currently selected editor window and checks the code inside for two kinds of problems. The first is incorrect use of the WITH statement. All uses of WITH are incorrect, and should be killed with fire.  Secondly, it tries to line up your begin and end statements and see if they match up. If they don’t match up, it tells you. If your code is nicely formatted and free of With statements, it is pronounced good.

If you are interested in more information on this subject, there is a Google+ Group dedicated to the Open Tools API.

If you really want to dig in to it, then David Hoyle has written The Delphi Open Tools API Book.

Delphi 10.1 Berlin

Embarcadero released the latest version of Delphi on Tuesday, April 19th – Delphi 10.1 Berlin. Just in time for Warren to give us a first look.

Embarcadero had an introduction webinar. If you missed it, the replay is available now.

Aside from the features, Malcolm Groves commented on the the progress with regards to bug fixes and Delphi’s “Quality, Performance and Stability” efforts.

Meeting Location

This meeting was at a new location, the Fairview Library, which is in the north of the Fairview Mall plaza. The Sheppard subway ends here and free parking is available. And apparently, it’s easier to book rooms.

Rick Dermont gets credit for finding this location. We will probably use it for future meetings.

Please let us know what you think.

Our next meeting will be Wednestay May 25 in  Room 1 from 6pm to 8pm at the North York Central Library. Please join us.

This entry was posted in Events, General. Bookmark the permalink.

2 Responses to April meeting follow-up

  1. David M says:

    Good to see more experts appear!

    Why did you use the Castalia parser? DelphiAST is based on it, and far more functional. https://github.com/RomanYankovsky/DelphiAST

  2. Warren Postma says:

    Hi David,

    Thanks for the suggestion. I will try the DelphiAST for my next version of this wizard. The Castalia parser is not ideal for the kinds of stuff I was trying to do, I just happened to be familiar with it. The “parsing” element of this wizard could have been done probably using just the tokenizer and a simple block-parser that understood when a procedure or class or some inner block begins and ends, but doesn’t care about statements. For the particular task I was trying to do (begin/end matchups) neither the lexer nor the parser level of Castalia did things exactly the way I would have wanted them.

    W

Comments are closed.