Code navigation breaks inside of $IFDEF blocks in Delphi 2010

692 views Asked by At

I have a few conditionally compiled classes in my app.

{$IFDEF SOME_OPTION}
type
  TMyClass = class
    procedure Foo;
  end;
{$ENDIF}

...

{$IFDEF SOME_OPTION}
procedure TMyClass.Foo;
begin

end;
{$ENDIF}

That option SOME_OPTION is defined in "Project Options" - "Delphi Compiler" - "Conditional Defines" and in "Project Options" - "Resource Compiler" - "Directories and Conditionals" - "Defines a preprocessor symbol" for this project.

When I try to Ctrl+Click on their methods, nothing happens, code navigation don't want to work.

I use Delphi 2010. How can I solve this problem?

3

There are 3 answers

0
Andrew On BEST ANSWER

It is a bug, and the chances of it being fixed are zero.

/ Warren P

4
Francesca On

I don't think the proper place is in "Project Options" - "Resource Compiler"...
But in "Project Options" - "Delphi Compiler" - "Conditional Defines".

Update:
I tried in Delphi XE here at work and whether it is defined or not, or where, does not seem to matter for Ctrl+Click to work for me in all cases.
Note that I have Andreas Hausladen's IDE Fix Pack 4.6.6 and DDEv Extension 2.5 installed. Do you use them?

Update 2:
When in the same unit, it seems to work, even when SOME_OPTION is undefined, but not when Foo is called from another unit.
What seem to work though is when it is properly defined in the Project Options and you rebuild the application (you see the blue dot on the line calling Foo). Then the IDE can use the compiler to locate the function source in the other unit.

That's all I can think of for the moment to help with that. And as has been stated already, it's not the best part of the IDE...

1
RBA On

Is not working because you have not well defined your compilation directives. Directives must be defined as described here http://docwiki.embarcadero.com/RADStudio/en/Delphi_compiler_directives in the Using the IDE section. A good practice is also to recompile the project after conditional directives are changed.