From d6a111cdf2997c40ba04e32588f2b7d3b5ab3cb6 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 17 Dec 2012 12:40:51 +0000 Subject: [PATCH] codetools: fixed TLinkScanner.CursorToCleanPos to search further for a better link when code was disabled git-svn-id: trunk@39568 - --- components/codetools/linkscanner.pas | 84 +++++++++++++------------ components/codetools/methodjumptool.pas | 7 ++- 2 files changed, 49 insertions(+), 42 deletions(-) diff --git a/components/codetools/linkscanner.pas b/components/codetools/linkscanner.pas index cbb4265206..5081988d51 100644 --- a/components/codetools/linkscanner.pas +++ b/components/codetools/linkscanner.pas @@ -3898,19 +3898,30 @@ function TLinkScanner.CursorToCleanPos(ACursorPos: integer; ACode: pointer; // 0=valid CleanPos //-1=CursorPos was skipped, CleanPos is between two links // 1=CursorPos beyond scanned code +// ACleanPos starts at 1 +type + TLinkQuality = (qNone,qSkipped,qDisabled,qClean); var - i, j, SkippedCleanPos: integer; - SkippedPos: boolean; + i, BestCleanPos: integer; Link: PSourceLink; + BestQuality: TLinkQuality; + LinkEnd: Integer; + Enabled: Boolean; begin + Result:=1; ACleanPos:=0; - if ACode=nil then exit(1); + if ACode=nil then exit; i:=0; - SkippedPos:=false; - SkippedCleanPos:=-1; + BestQuality:=qNone; + BestCleanPos:=0; + Enabled:=true; while iACode) do inc(j); - //DebugLn('[TLinkScanner.CursorToCleanPos] D j=',j); - if (jACursorPos) then begin - if not SkippedPos then begin - // CursorPos was skipped, CleanPos is between two links - // but because include files can be parsed multiple times, - // search must continue - SkippedPos:=true; - // set found cleanpos to end of link - SkippedCleanPos:=Link^.CleanedPos+LinkSize(i); + LinkEnd:=FLinks[i+1].CleanedPos; + end else + LinkEnd:=CleanedLen+1; + if ACleanPos save position and continue search + if BestQuality search next end; - // search next - i:=j; - end else begin - // in last link - //DebugLn(['[TLinkScanner.CursorToCleanPos] E ACleanPos=',ACleanPos,' CleanedLen=',CleanedLen]); - if ACleanPos<=CleanedLen then begin - Result:=0; // valid position - exit; - end; - break; end; - end else - inc(i); + if BestQuality=LastAtomEnd then CleanCursorPos:=LastAtomEnd-1;