mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-13 10:09:25 +02:00
fixed recaching
git-svn-id: trunk@4326 -
This commit is contained in:
parent
05b82e5d51
commit
636309fd06
@ -32,6 +32,10 @@ interface
|
||||
|
||||
{$I codetools.inc}
|
||||
|
||||
|
||||
// for debugging
|
||||
{ $DEFINE HardExceptions}
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BasicCodeTools, AVL_Tree, CodeTree, LinkScanner,
|
||||
PascalParserTool, CodeToolMemManager;
|
||||
@ -642,59 +646,74 @@ var
|
||||
OldEntry: PCodeTreeNodeCacheEntry;
|
||||
OldNode: TAVLTreeNode;
|
||||
NewSearchRangeFlags: TNodeCacheEntryFlags;
|
||||
|
||||
procedure RaiseConflictException;
|
||||
|
||||
function ParamsDebugReport: string;
|
||||
var
|
||||
s: string;
|
||||
begin
|
||||
s:='[TCodeTreeNodeCache.Add] internal error:'
|
||||
+' conflicting cache nodes: Ident='+GetIdentifier(Identifier);
|
||||
if Owner<>nil then
|
||||
s:=s+' Owner='+Owner.DescAsString;
|
||||
s:=s+' OwnerPos='+IntToStr(Owner.StartPos);
|
||||
s:=s+' Old: Range='+IntToStr(OldEntry^.CleanStartPos)
|
||||
+'-'+IntToStr(OldEntry^.CleanEndPos);
|
||||
if OldEntry^.NewNode<>nil then begin
|
||||
s:=s+' Node='+OldEntry^.NewNode.DescAsString
|
||||
+' Pos='+IntToStr(OldEntry^.NewNode.StartPos);
|
||||
end else
|
||||
s:=s+' Node=nil';
|
||||
if OldEntry^.NewTool<>nil then begin
|
||||
s:=s+' Tool='+OldEntry^.NewTool.MainFilename;
|
||||
if OldEntry^.NewNode<>nil then
|
||||
s:=s+' Src="'
|
||||
+StringToPascalConst(
|
||||
copy(OldEntry^.NewTool.Src,OldEntry^.NewNode.StartPos,50))+'"';
|
||||
end;
|
||||
s:=' Ident='+GetIdentifier(Identifier);
|
||||
s:=s+' New: Range='+IntToStr(CleanStartPos)
|
||||
+'-'+IntToStr(CleanEndPos);
|
||||
if Owner<>nil then begin
|
||||
s:=s+' Owner='+Owner.DescAsString;
|
||||
s:=s+' OwnerPos='+IntToStr(Owner.StartPos);
|
||||
end;
|
||||
if OldEntry<>nil then begin
|
||||
s:=s+' Old: Range='+IntToStr(OldEntry^.CleanStartPos)
|
||||
+'-'+IntToStr(OldEntry^.CleanEndPos);
|
||||
if OldEntry^.NewNode<>nil then begin
|
||||
s:=s+' Node='+OldEntry^.NewNode.DescAsString
|
||||
+' Pos='+IntToStr(OldEntry^.NewNode.StartPos);
|
||||
end else
|
||||
s:=s+' Node=nil';
|
||||
if OldEntry^.NewTool<>nil then begin
|
||||
s:=s+' Tool='+ExtractFilename(OldEntry^.NewTool.MainFilename);
|
||||
if OldEntry^.NewNode<>nil then
|
||||
s:=s+' Src="'
|
||||
+StringToPascalConst(
|
||||
copy(OldEntry^.NewTool.Src,OldEntry^.NewNode.StartPos,50))+'"';
|
||||
end;
|
||||
end;
|
||||
if NewNode<>nil then begin
|
||||
s:=s+' Node='+NewNode.DescAsString
|
||||
+' Pos='+IntToStr(NewNode.StartPos);
|
||||
end else
|
||||
s:=s+' Node=nil';
|
||||
if NewTool<>nil then begin
|
||||
s:=s+' Tool='+NewTool.MainFilename;
|
||||
s:=s+' Tool='+ExtractFileName(NewTool.MainFilename);
|
||||
if NewNode<>nil then
|
||||
s:=s+' Src="'
|
||||
+StringToPascalConst(copy(NewTool.Src,NewNode.StartPos,50))+'"';
|
||||
end;
|
||||
Result:=s;
|
||||
end;
|
||||
|
||||
procedure RaiseConflictException(const Msg: string);
|
||||
var
|
||||
s: string;
|
||||
begin
|
||||
s:='[TCodeTreeNodeCache.Add] internal error:'+Msg+ParamsDebugReport;
|
||||
{$IFDEF HardExceptions}
|
||||
writeln(s);
|
||||
RaiseCatchableException('TCodeTreeNodeCache.Add A');
|
||||
{$ELSE}
|
||||
raise Exception.Create(s);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
begin
|
||||
OldEntry:=nil;
|
||||
if CleanStartPos>=CleanEndPos then
|
||||
raise Exception.Create('[TCodeTreeNodeCache.Add] internal error:'
|
||||
+' CleanStartPos>=CleanEndPos');
|
||||
{if GetIdentifier(Identifier)='TDefineAction' then begin
|
||||
writeln('[[[[======================================================');
|
||||
writeln('[TCodeTreeNodeCache.Add] Ident=',GetIdentifier(Identifier),
|
||||
' CleanStartPos=',CleanStartPos,' CleanEndPos=',CleanEndPos,
|
||||
' Flags=[',NodeCacheEntryFlagsAsString(Flags),']',
|
||||
' NewNode=',NewNode<>nil
|
||||
);
|
||||
writeln('======================================================]]]]');
|
||||
end;}
|
||||
RaiseConflictException('CleanStartPos>=CleanEndPos');
|
||||
{if GetIdentifier(Identifier)='TDefineAction' then begin
|
||||
writeln('[[[[======================================================');
|
||||
writeln('[TCodeTreeNodeCache.Add] Ident=',GetIdentifier(Identifier),
|
||||
' CleanStartPos=',CleanStartPos,' CleanEndPos=',CleanEndPos,
|
||||
' Flags=[',NodeCacheEntryFlagsAsString(Flags),']',
|
||||
' NewNode=',NewNode<>nil
|
||||
);
|
||||
writeln('======================================================]]]]');
|
||||
end;}
|
||||
if FItems=nil then
|
||||
FItems:=TAVLTree.Create(@CompareTCodeTreeNodeCacheEntry);
|
||||
// if identifier already exists, try to combine them
|
||||
@ -719,7 +738,7 @@ end;}
|
||||
OldEntry^.Flags:=NewSearchRangeFlags;
|
||||
end else begin
|
||||
// different FindContext with overlapping search ranges
|
||||
RaiseConflictException;
|
||||
RaiseConflictException('conflicting cache nodes');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@ -1679,7 +1679,6 @@ var
|
||||
NodeCache.WriteDebugReport('NANUNANA: ');
|
||||
end;
|
||||
{$ENDIF}
|
||||
ContextNode:=Params.NewNode;
|
||||
Result:=true;
|
||||
end;
|
||||
end;
|
||||
@ -5531,6 +5530,23 @@ var Node: TCodeTreeNode;
|
||||
NewCleanPos: integer;
|
||||
{$IFDEF ShowNodeCache}
|
||||
BeVerbose: boolean;
|
||||
NodeOwner: TObject;
|
||||
|
||||
function WriteSrcPos(t: TPascalParserTool; p: integer): string;
|
||||
begin
|
||||
Result:=StringToPascalConst(copy(t.Src,p-10,10)+'|'+copy(t.Src,p,15)+'"');
|
||||
end;
|
||||
|
||||
function NodeOwnerAsString(ANodeOwner: TObject): string;
|
||||
begin
|
||||
if ANodeOwner=nil then
|
||||
Result:='nil'
|
||||
else if ANodeOwner is TPascalParserTool then
|
||||
Result:=ExtractFileName(TPascalParserTool(ANodeOwner).MainFilename)
|
||||
else
|
||||
Result:='?'+ANodeOwner.ClassName+'?';
|
||||
end;
|
||||
|
||||
{$ENDIF}
|
||||
begin
|
||||
if StartNode=nil then exit;
|
||||
@ -5566,7 +5582,7 @@ begin
|
||||
end;
|
||||
|
||||
{$IFDEF ShowNodeCache}
|
||||
beVerbose:=CompareSrcIdentifiers(Params.Identifier,'VISIBLE');
|
||||
beVerbose:=CompareSrcIdentifiers(Params.Identifier,'TOBJECT');
|
||||
if beVerbose then begin
|
||||
writeln('(((((((((((((((((((((((((((==================');
|
||||
|
||||
@ -5578,30 +5594,36 @@ begin
|
||||
if ncefSearchedInAncestors in SearchRangeFlags then write(',Ancestors');
|
||||
writeln(']');
|
||||
|
||||
writeln(' Tool=',MainFilename);
|
||||
|
||||
write(' StartNode=',StartNode.DescAsString,'="',copy(Src,StartNode.StartPos-10,10),'|',copy(Src,StartNode.StartPos,15),'"');
|
||||
if EndNode<>nil then
|
||||
write(' EndNode=',EndNode.DescAsString,'="',copy(Src,EndNode.StartPos,25),'"')
|
||||
else
|
||||
write(' EndNode=nil');
|
||||
write(' StartNode=',StartNode.DescAsString,
|
||||
'(',StartNode.StartPos,'-',StartNode.EndPos,')=',
|
||||
WriteSrcPos(Self,StartNode.StartPos));
|
||||
NodeOwner:=FindOwnerOfCodeTreeNode(StartNode);
|
||||
if NodeOwner<>Self then write(' StartNodeOwner=',NodeOwnerAsString(NodeOwner));
|
||||
writeln('');
|
||||
|
||||
writeln(' StartNode(',StartNode.StartPos,'-',StartNode.EndPos,')');
|
||||
if EndNode<>nil then
|
||||
writeln(' EndNode(',EndNode.StartPos,'-',EndNode.EndPos,')');
|
||||
write(' EndNode=',EndNode.DescAsString,
|
||||
'(',EndNode.StartPos,'-',EndNode.EndPos,')=',
|
||||
WriteSrcPos(Self,EndNode.StartPos))
|
||||
else
|
||||
write(' EndNode=nil');
|
||||
NodeOwner:=FindOwnerOfCodeTreeNode(EndNode);
|
||||
if NodeOwner<>Self then write(' EndNodeOwner=',NodeOwnerAsString(NodeOwner));
|
||||
writeln('');
|
||||
|
||||
writeln(' Self=',MainFilename);
|
||||
writeln(' Self=',ExtractFileName(MainFilename));
|
||||
|
||||
if NewNode<>nil then begin
|
||||
writeln(' NewNode=',NewNode.DescAsString,
|
||||
' NewTool=',NewTool.MainFilename);
|
||||
'(',NewNode.StartPos,'-',NewNode.EndPos,')=',
|
||||
WriteSrcPos(NewTool,NewNode.StartPos),
|
||||
' NewTool=',ExtractFileName(NewTool.MainFilename));
|
||||
end else begin
|
||||
writeln(' NOT FOUND');
|
||||
end;
|
||||
|
||||
writeln(' CleanStartPos=',CleanStartPos,' "',copy(Src,CleanStartPos,70),'"');
|
||||
writeln(' CleanEndPos=',CleanEndPos,' "',copy(Src,CleanEndPos-70,70),'"');
|
||||
writeln(' CleanStartPos=',CleanStartPos,' ',WriteSrcPos(Self,CleanStartPos));
|
||||
writeln(' CleanEndPos=',CleanEndPos,' ',WriteSrcPos(Self,CleanEndPos));
|
||||
end;
|
||||
{$ENDIF}
|
||||
LastNodeCache:=nil;
|
||||
|
@ -6207,7 +6207,6 @@ begin
|
||||
gtk_progress_set_show_text (GTK_PROGRESS (Handle), 0);
|
||||
Widget := PGtkWidget( gtk_adjustment_new (0, Min, Max, 0, 0, 0));
|
||||
gtk_progress_set_adjustment (GTK_PROGRESS (Handle), PGtkAdjustment (Widget));
|
||||
writeln('SetProperties A ',Position);
|
||||
gtk_progress_set_value (GTK_PROGRESS (Handle), Position);
|
||||
end;
|
||||
|
||||
@ -7475,6 +7474,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.383 2003/06/26 18:18:25 mattias
|
||||
fixed recaching
|
||||
|
||||
Revision 1.382 2003/06/26 17:00:00 mattias
|
||||
fixed result on searching proc in interface
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user