views:

90

answers:

1

In a class declaration, you can press Ctrl+Space to get a list of virtual methods in the baseclass that you can override.

This list seems to be very limited, though. Ex.

 TMyBaseClass = class(TInterfacedObject)
 protected
   procedure mymethod; virtual;
 end;

 TMyClass = class(TMyBaseClass)
 protected
   {Ctrl+Space here...}
 end;

In TMyClass, I get methods from TInterfacedObject and TObject, but not from TMyBaseClass. Why is that?

-Vegar

EDIT: Forgot my delphi version... I'm using 2007.

+5  A: 

Because sometimes these IDE tools work and sometimes they don't (and afaik this is not a problem that is unique to Delphi/RAD Studio).

For example, if you have other edits outstanding which mean that the IDE cannot adequately parse your source up to the current insertion point, then it is likely that such things will be "broken".

In such cases I personally try a quick Ctrl+F9 to see if there are compilation errors that I perhaps may not be aware of. 9 times out of 10 there are, and fixing those then fixes the code insight behaviour.

Recreating your example verbatim in a new unit, I get "mymethod" in my code completion list as expected, so is it possible that in your actual case that your base class and your derived class are actually separated by other code, perhaps even in separate units, and that that other code contains errors "between" the two declarations at the time at which you are trying to invoke code completion?

As a more general point, ime it's better to treat such things as "nice to haves when they work" but to try to develop habits and practices that don't rely on them. In this case the only substitute is knowledge of the methods to be overridden, which isn't much help I admit.

Deltics
My current case is a little more complex than my little code snippet, your right about that. Everything compiles, though, and my experience is that not working is more the rule than the exception. If something that seldom work is better than nothing, I don't know...
Vegar
Do things work *after* a successful compile? Sometimes the IDE just need a little "nudge" or encouragement to "catch up".
Deltics
In the case that frustrated me enough to ask here at SO, it doesn't help to compile or build.
Vegar