codetools: linkscanner: counter for storedirectives

git-svn-id: trunk@41128 -
This commit is contained in:
mattias 2013-05-11 09:29:48 +00:00
parent 676c8f278e
commit 78f5a14553
4 changed files with 26 additions and 14 deletions

View File

@ -1860,7 +1860,8 @@ begin
{$ENDIF}
try
aScanner:=FCurCodeTool.Scanner;
aScanner.StoreDirectives:=true;
if not aScanner.StoreDirectives then
aScanner.DemandStoreDirectives;
aScanner.Scan(lsrEnd,true);
except
on e: Exception do Result:=HandleException(e);

View File

@ -408,7 +408,7 @@ type
FOnGetGlobalChangeSteps: TLSOnGetGlobalChangeSteps;
FSkippingDirectives: TLSSkippingDirective;
FSkipIfLevel: integer;
FStoreDirectives: boolean;
FStoreDirectives: integer;
FCompilerMode: TCompilerMode;
FCompilerModeSwitches: TCompilerModeSwitches;
FPascalCompiler: TPascalCompiler;
@ -417,7 +417,6 @@ type
function GetDirectives(Index: integer): PLSDirective; inline;
function GetDirectivesSorted(Index: integer): PLSDirective; inline;
procedure SetCompilerMode(const AValue: TCompilerMode);
procedure SetStoreDirectives(AValue: boolean);
procedure SkipTillEndifElse(SkippingUntil: TLSSkippingDirective);
procedure SortDirectives;
function InternalIfDirective: boolean;
@ -527,7 +526,9 @@ type
property DirectivesSorted[Index: integer]: PLSDirective read GetDirectivesSorted; // sorted for Code and SrcPos
property DirectiveCount: integer read FDirectivesCount;
procedure ClearDirectives(FreeMemory: boolean);
property StoreDirectives: boolean read FStoreDirectives write SetStoreDirectives; // store directives on next Scan
function StoreDirectives: boolean; inline; // store directives on next Scan
procedure DemandStoreDirectives; // increase internal counter to StoreDirectives
procedure ReleaseStoreDirectives; // decrease internal counter to StoreDirectives
property DirectivesStored: boolean read FDirectivesStored; // directives were stored on last scan
function FindDirective(aCode: Pointer; aSrcPos: integer;
out FirstSortedIndex, LastSortedIndex: integer): boolean;
@ -1030,6 +1031,12 @@ begin
Result:=CleanedLen+1;
end;
// inline
function TLinkScanner.StoreDirectives: boolean;
begin
Result:=FStoreDirectives>0;
end;
procedure TLinkScanner.SortDirectives;
var
i: Integer;
@ -1261,6 +1268,20 @@ begin
end;
end;
procedure TLinkScanner.DemandStoreDirectives;
begin
inc(FStoreDirectives);
end;
procedure TLinkScanner.ReleaseStoreDirectives;
begin
if FStoreDirectives=0 then
raise Exception.Create('');
dec(FStoreDirectives);
if FStoreDirectives=0 then
ClearDirectives(true);
end;
function TLinkScanner.FindDirective(aCode: Pointer; aSrcPos: integer; out
FirstSortedIndex, LastSortedIndex: integer): boolean;
var
@ -4075,14 +4096,6 @@ begin
FNestedComments:=cmsNested_comment in CompilerModeSwitches;
end;
procedure TLinkScanner.SetStoreDirectives(AValue: boolean);
begin
if FStoreDirectives=AValue then Exit;
FStoreDirectives:=AValue;
if not StoreDirectives then
ClearDirectives(true);
end;
function TLinkScanner.GetIgnoreMissingIncludeFiles: boolean;
begin
Result:=lssIgnoreMissingIncludeFiles in FStates;

View File

@ -5280,7 +5280,6 @@ begin
else
Result := idnInvalid;
end;
{$ENDIF}
function TSourceEditor.SharedEditorCount: Integer;

View File

@ -1517,7 +1517,6 @@ procedure TIDESynEditor.SetIfdefNodeState(ALinePos, AstartPos: Integer;
begin
FMarkupIfDef.SetNodeState(ALinePos, AstartPos, AState);
end;
{$ENDIF}
function TIDESynEditor.GetHighlightUserWordCount: Integer;