Consider this admittedly contrived bit of code:
{$Define Debug}
{$IfDef Debug}
{.$Define DebugXYZ}
{$IfDef DebugXYZ}
procedure XYZ;
begin
{Some code here...}
Counter := Counter + 1; {first instance}
end;
{$Else}
Procedure XYZ;
begin
{Some other code...}
Counter := Counter + 1; {second instance}
end;
{$Endif}
{$Else}
Procedure OptimizedXYZ;
{Some code...}
Counter := Counter + 1; {3rd instance}
end;
{$EndIf}
{$EndIf}
Code which is not active should be shown as dimmed. So assume the highlighter is working on the first instance of
To determine if the highlighting should be dimmed or not, it needs to find out the conditional context this line is in. If I can write a method that returns a list of pairs as in :
function ConditionalDirectiveContext(const aLineNumber: LineNumber): ;
Which returns a list of pairs as follows:
(
(xcfbt_IfDefDirective, 'DebugXYZ'),
(xcfbt_IfDefDirective, 'Debug' )
)
Then, I could quickly determine that the directive DebugXYZ is active but the directive Debug is not, therefore I should return a dimmed attribute.
That would do it.
If I could subclass TSynCustomCodeFoldBlock and add a text property called DirectiveName then
I should be home free.
But I'm a bit stumped. I know I can subclass TSynCustomCodeFoldBlock.I also know I can override override the GetRangeClass in TSynCustomFoldHighlighter to get replace TSynCustomHighlighterRange with my descendant.
Where I'm stumped is that I can't figure out how subclassing TSynCustomHighlighterRange would help. There doesn't seem to be a way to tell this class to use my subclass of TSynCustomCodeFoldBlock. What am I missing?