codetools: shrinked scan ranges from lsrEnd to lsrInitializationStart where possible

git-svn-id: trunk@42202 -
This commit is contained in:
mattias 2013-07-25 12:49:04 +00:00
parent 9a19939660
commit a1d47beded
7 changed files with 21 additions and 20 deletions

View File

@ -161,7 +161,8 @@ type
const FoundContext: TFindContext): TIdentifierFoundResult;
procedure RemoveNewMainUsesSectionUnit(p: PChar);
protected
procedure CheckWholeUnitParsed(var Node1, Node2: TCodeTreeNode);
procedure CheckWholeUnitParsed(var Node1, Node2: TCodeTreeNode;
Range: TLinkScannerRange = lsrEnd);
procedure FreeClassInsertionList;
procedure InsertNewClassParts(PartType: TNewClassPart);
function InsertAllNewClassParts: boolean;
@ -458,7 +459,7 @@ begin
FSourceChangeCache.MainScanner:=Scanner;
end;
procedure TCodeCompletionCodeTool.SetSetPropertyVariablename(aValue: string);
procedure TCodeCompletionCodeTool.SetSetPropertyVariablename(AValue: string);
begin
if FSetPropertyVariablename=aValue then Exit;
FSetPropertyVariablename:=aValue;
@ -499,20 +500,20 @@ begin
if s='' then ;
end;
procedure TCodeCompletionCodeTool.CheckWholeUnitParsed(
var Node1, Node2: TCodeTreeNode);
procedure TCodeCompletionCodeTool.CheckWholeUnitParsed(var Node1,
Node2: TCodeTreeNode; Range: TLinkScannerRange);
var
Pos1: Integer;
Pos2: Integer;
begin
//DebugLn(['TCodeCompletionCodeTool.CheckWholeUnitParsed ',EndOfSourceFound,' LastErrorMessage="',LastErrorMessage,'" LastErrorCurPos=',dbgs(LastErrorCurPos)]);
if (ScannedRange=lsrEnd) and (not LastErrorValid) then exit;
if (ScannedRange>=Range) and (not LastErrorValid) then exit;
Pos1:=0;
Pos2:=0;
if Node1<>nil then Pos1:=Node1.StartPos;
if Node2<>nil then Pos2:=Node2.StartPos;
ClearIgnoreErrorAfter;
BuildTree(lsrEnd); // parse whole unit
BuildTree(Range);
if Node1<>nil then Node1:=FindDeepestNodeAtPos(Pos1,true);
if Node2<>nil then Node2:=FindDeepestNodeAtPos(Pos2,true);
end;
@ -2899,7 +2900,7 @@ const
begin
Result:=false;
// reparse code and find jump point into new proc
BuildTree(lsrEnd);
BuildTree(lsrInitializationStart);
NewProcNode:=FindSubProcPath(SubProcPath,ShortProcFormat,true);
if NewProcNode=nil then begin
debugln(['FindJumpPointToNewProc FindSubProcPath failed, SubProcPath="',SubProcPath.Text,'"']);
@ -5200,7 +5201,7 @@ begin
if OnlyInterface then
BuildTree(lsrImplementationStart)
else
BuildTree(lsrEnd);
BuildTree(lsrInitializationStart);
// find all unit identifiers (excluding sub types)
TreeOfCodeTreeNodeExt:=TAVLTree.Create(@CompareCodeTreeNodeExt);
@ -5502,7 +5503,7 @@ begin
Result:=false;
AllEmpty:=false;
if (AClassName<>'') and (CursorPos.Y<1) then begin
BuildTree(lsrEnd);
BuildTree(lsrInitializationStart);
CursorNode:=FindClassNodeInInterface(AClassName,true,false,true);
CodeCompleteClassNode:=CursorNode;
end else begin
@ -6382,7 +6383,7 @@ var
ClassNode: TCodeTreeNode;
begin
Result:=false;
BuildTree(lsrEnd);
BuildTree(lsrInitializationStart);
if ScannedRange<>lsrEnd then exit;
if (SourceChangeCache=nil) or (Scanner=nil) then exit;
ClassNode:=FindClassNodeInUnit(AClassName,true,false,false,true);

View File

@ -1936,7 +1936,7 @@ begin
try
Paths.Add(CleanDef);
try
FCurCodeTool.BuildTree(lsrEnd);
FCurCodeTool.BuildTree(lsrInitializationStart);
Node:=FCurCodeTool.FindSubProcPath(Paths,Attr,false);
Result:=Node<>nil;
except

View File

@ -484,7 +484,7 @@ var SectionNode, ANode: TCodeTreeNode;
begin
Result:=nil;
if (AMethodName='') or (AClassName='') then exit;
if BuildTreeBefore then BuildTree(lsrEnd);
if BuildTreeBefore then BuildTree(lsrInitializationStart);
// find implementation node
SectionNode:=Tree.Root;
while SectionNode<>nil do begin
@ -701,7 +701,7 @@ begin
Result:=false;
ActivateGlobalWriteLock;
try
BuildTree(lsrEnd);
BuildTree(lsrInitializationStart);
ClassNode:=FindClassNodeInInterface(AClassName,true,false,ErrorOnNotFound);
if ClassNode=nil then begin
DebugLn(['TEventsCodeTool.JumpToPublishedMethodBody class not found: ',AClassName]);
@ -820,7 +820,7 @@ function TEventsCodeTool.CreateMethod(const AClassName,
var AClassNode: TCodeTreeNode;
begin
Result:=false;
BuildTree(lsrEnd);
BuildTree(lsrInitializationStart);
AClassNode:=FindClassNodeInInterface(AClassName,true,false,true);
Result:=CreateMethod(AClassNode,AMethodName,ATypeInfo,
APropertyUnitName,APropertyPath,
@ -1047,7 +1047,7 @@ begin
PChar(AUnitName))=0)
then begin
// search in this unit
BuildTree(lsrEnd);
BuildTree(lsrInitializationStart);
FindContext.Node:=FindClassNodeInUnit(AClassName,true,false,false,
ExceptionOnNotFound);
if FindContext.Node=nil then begin

View File

@ -1000,7 +1000,7 @@ var
begin
Result:=false;
// reparse code and find jump point into new proc
BuildTree(lsrEnd);
BuildTree(lsrInitializationStart);
NewProcNode:=FindSubProcPath(SubProcPath,ShortProcFormat,true);
{$IFDEF CTDebug}
DebugLn('FindJumpPointToNewProc A found=',dbgs(NewProcNode<>nil));

View File

@ -1742,7 +1742,7 @@ begin
ActivateGlobalWriteLock;
Params:=TFindDeclarationParams.Create;
try
BuildTree(lsrEnd);
BuildTree(lsrInitializationStart);
//DebugLn(['TFindDeclarationTool.FindDeclarationOfPropertyPath ',Src]);

View File

@ -540,7 +540,7 @@ type
IsUnit: boolean;
SourceName: string;
ScannedRange: TLinkScannerRange;
ScannedRange: TLinkScannerRange; // excluding the section with a syntax error
function MainFilename: string;
property ChangeStep: integer read FChangeStep; // see CTInvalidChangeStamp
@ -1723,7 +1723,7 @@ begin
// -> if there was an error and it was in a needed range, raise it again
if LastErrorIsValid then begin
// the error has happened in ScannedRange
if ord(ScannedRange)>ord(Range) then begin
if ord(ScannedRange)>=ord(Range) then begin
// error is behind needed range => ok
end else if (not IgnoreErrorAfterValid)
or (not IgnoreErrAfterPositionIsInFrontOfLastErrMessage)

View File

@ -1215,7 +1215,7 @@ var SectionNode, CurProcNode: TCodeTreeNode;
CurProcHead: string;
begin
Result:=false;
BuildTree(lsrEnd);
BuildTree(lsrInitializationStart);
SectionNode:=Tree.Root;
while (SectionNode<>nil) do begin
if SectionNode.Desc in [ctnProgram,ctnImplementation] then begin