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