codetools: added TLinkScanner.FindFirstDirective

git-svn-id: trunk@53191 -
This commit is contained in:
mattias 2016-10-21 17:41:05 +00:00
parent d7a2596644
commit b23106921b

View File

@ -427,7 +427,7 @@ type
TLinkScanner = class(TObject)
private
FLinks: PSourceLink; // list of TSourceLink
FLinks: PSourceLink; // list of TSourceLink, sorted for CleanedPos
FLinkCount: integer;
FLinkCapacity: integer;
FCleanedSrc: string;
@ -646,6 +646,8 @@ type
property DirectivesStored: boolean read FDirectivesStored; // directives were stored on last scan
function FindDirective(aCode: Pointer; aSrcPos: integer;
out FirstSortedIndex, LastSortedIndex: integer): boolean;
function FindFirstDirective(aCode: Pointer; aSrcPos: integer;
const AllowedStates: TLSDirectiveStates): PLSDirective;
function GetDirectiveValueAt(ADirective: TSequenceDirective; ACleanPos: integer): string;
// source mapping (Cleaned <-> Original)
@ -1606,6 +1608,20 @@ begin
LastSortedIndex:=-1;
end;
function TLinkScanner.FindFirstDirective(aCode: Pointer; aSrcPos: integer;
const AllowedStates: TLSDirectiveStates): PLSDirective;
var
FirstSortedIndex, LastSortedIndex, i: integer;
begin
Result:=nil;
if not FindDirective(aCode,aSrcPos,FirstSortedIndex,LastSortedIndex) then exit;
for i:=FirstSortedIndex to LastSortedIndex do begin
Result:=DirectivesSorted[i];
if Result^.State in AllowedStates then exit;
end;
Result:=nil;
end;
function TLinkScanner.LinkIndexAtCleanPos(ACleanPos: integer): integer;
procedure ConsistencyError1;