IDE: TSourceEditor.UpdateIfDefNodeStates: check if scanner has changed

git-svn-id: trunk@41183 -
This commit is contained in:
mattias 2013-05-14 07:40:30 +00:00
parent 7185e6dc61
commit 6b007f92db

View File

@ -223,7 +223,7 @@ type
procedure ConnectScanner(Scanner: TLinkScanner); procedure ConnectScanner(Scanner: TLinkScanner);
procedure DisconnectScanner(Scanner: TLinkScanner); procedure DisconnectScanner(Scanner: TLinkScanner);
function GetIfDefNodeState(x, y: integer): TSynMarkupIfdefNodeState; function GetIfDefNodeState(x, y: integer): TSynMarkupIfdefNodeState;
function GetMainLinkScanner: TLinkScanner; function GetMainLinkScanner(Scan: boolean): TLinkScanner;
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
@ -248,6 +248,7 @@ type
// LinesDeleted messages // LinesDeleted messages
{$IFDEF WithSynMarkupIfDef} {$IFDEF WithSynMarkupIfDef}
FOnIfdefNodeStateRequest: TSynMarkupIfdefStateRequest; FOnIfdefNodeStateRequest: TSynMarkupIfdefStateRequest;
FLastIfDefNodeScannerStep: integer;
{$ENDIF} {$ENDIF}
FSyncroLockCount: Integer; FSyncroLockCount: Integer;
FPageName: string; FPageName: string;
@ -2629,7 +2630,7 @@ begin
debugln(['TSourceEditorSharedValues.GetIfDefNodeState out of code x=',x,' y=',y,' ',Filename]); debugln(['TSourceEditorSharedValues.GetIfDefNodeState out of code x=',x,' y=',y,' ',Filename]);
exit; exit;
end; end;
Scanner:=GetMainLinkScanner; Scanner:=GetMainLinkScanner(true);
if not Scanner.FindDirective(CodeBuffer,p,FirstSortedIndex,LastSortedIndex) if not Scanner.FindDirective(CodeBuffer,p,FirstSortedIndex,LastSortedIndex)
then begin then begin
debugln(['TSourceEditorSharedValues.GetIfDefNodeState no directive at x=',x,' y=',y,' ',Filename]); debugln(['TSourceEditorSharedValues.GetIfDefNodeState no directive at x=',x,' y=',y,' ',Filename]);
@ -2651,10 +2652,9 @@ begin
end; end;
end; end;
function TSourceEditorSharedValues.GetMainLinkScanner: TLinkScanner; function TSourceEditorSharedValues.GetMainLinkScanner(Scan: boolean
): TLinkScanner;
// Note: if this is an include file, the main scanner may change // Note: if this is an include file, the main scanner may change
var
NeedScan: Boolean;
begin begin
Result:=FMainLinkScanner; Result:=FMainLinkScanner;
if Result=nil then if Result=nil then
@ -2670,12 +2670,8 @@ begin
Result:=CodeToolBoss.CurCodeTool.Scanner; Result:=CodeToolBoss.CurCodeTool.Scanner;
ConnectScanner(Result); ConnectScanner(Result);
FMainLinkScanner:=Result; FMainLinkScanner:=Result;
NeedScan:=true;
end else begin
NeedScan:=false;
// ToDo: check stamps
end; end;
if NeedScan then if Scan and (FMainLinkScanner<>nil) then
begin begin
try try
FMainLinkScanner.Scan(lsrEnd,false); FMainLinkScanner.Scan(lsrEnd,false);
@ -5431,26 +5427,27 @@ var
X: integer; X: integer;
SynState: TSynMarkupIfdefNodeStateEx; SynState: TSynMarkupIfdefNodeStateEx;
begin begin
debugln(['TSourceEditor.UpdateIfDefNodeStates ']); debugln(['TSourceEditor.UpdateIfDefNodeStates CHECK ',Filename]);
Scanner:=SharedValues.GetMainLinkScanner; Scanner:=SharedValues.GetMainLinkScanner(true);
if Scanner=nil then exit;
if Scanner.ChangeStep=FLastIfDefNodeScannerStep then exit;
debugln(['TSourceEditor.UpdateIfDefNodeStates UPDATING ',Filename]);
FLastIfDefNodeScannerStep:=Scanner.ChangeStep;
EditorComponent.InvalidateAllIfdefNodes; EditorComponent.InvalidateAllIfdefNodes;
if Scanner<>nil then Code:=CodeBuffer;
for i:=0 to Scanner.DirectiveCount-1 do
begin begin
Code:=CodeBuffer; aDirective:=Scanner.DirectivesSorted[i];
for i:=0 to Scanner.DirectiveCount-1 do if TCodeBuffer(aDirective^.Code)<>Code then continue;
begin Code.AbsoluteToLineCol(aDirective^.SrcPos,Y,X);
aDirective:=Scanner.DirectivesSorted[i]; if Y<1 then continue;
if TCodeBuffer(aDirective^.Code)<>Code then continue; SynState:=idnInvalid;
Code.AbsoluteToLineCol(aDirective^.SrcPos,Y,X); case aDirective^.State of
if Y<1 then continue; lsdsActive: SynState:=idnEnabled;
SynState:=idnInvalid; lsdsInactive: SynState:=idnDisabled;
case aDirective^.State of lsdsSkipped: SynState:=idnInvalid;
lsdsActive: SynState:=idnEnabled;
lsdsInactive: SynState:=idnDisabled;
lsdsSkipped: SynState:=idnInvalid;
end;
EditorComponent.SetIfdefNodeState(Y,X,SynState);
end; end;
EditorComponent.SetIfdefNodeState(Y,X,SynState);
end; end;
end; end;
{$ENDIF} {$ENDIF}