mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-05 21:34:11 +02:00
codetools: fixed CompareTextIgnoringSpace, bug #12177
git-svn-id: trunk@16635 -
This commit is contained in:
parent
874285d5bb
commit
d8e36f10fb
@ -2503,13 +2503,10 @@ function CompareTextIgnoringSpace(Txt1: PChar; Len1: integer;
|
||||
A; A -1
|
||||
}
|
||||
var P1, P2: integer;
|
||||
InIdentifier: boolean;
|
||||
begin
|
||||
P1:=0;
|
||||
P2:=0;
|
||||
InIdentifier:=false;
|
||||
while (P1<Len1) and (P2<Len2) do begin
|
||||
//DebugLn('CompareTextIgnoringSpace P1=',dbgs(P1),' P2=',dbgs(P2));
|
||||
if (CaseSensitive and (Txt1[P1]=Txt2[P2]))
|
||||
or ((not CaseSensitive) and (UpChars[Txt1[P1]]=UpChars[Txt2[P2]])) then
|
||||
begin
|
||||
@ -2517,7 +2514,8 @@ begin
|
||||
inc(P2);
|
||||
end else begin
|
||||
// different chars found
|
||||
if InIdentifier and (IsIdentChar[Txt1[P1]] xor IsIdentChar[Txt2[P2]]) then begin
|
||||
if (P1>0) and (IsIdentChar[Txt1[P1-1]])
|
||||
and (IsIdentChar[Txt1[P1]] xor IsIdentChar[Txt2[P2]]) then begin
|
||||
// one identifier is longer than the other
|
||||
if IsIdentChar[Txt1[P1]] then
|
||||
// identifier in Txt1 is longer than in Txt2
|
||||
@ -2552,7 +2550,6 @@ begin
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
InIdentifier:=IsIdentChar[Txt1[P1]];
|
||||
end;
|
||||
// one text was totally read -> check the rest of the other one
|
||||
// skip spaces
|
||||
|
@ -5549,6 +5549,7 @@ var
|
||||
FirstExistingProcBody:=ANode;
|
||||
if ANode.StartPos>LastExistingProcBody.StartPos then
|
||||
LastExistingProcBody:=ANode;
|
||||
//DebugLn(['FindTopMostAndBottomMostProcBodies ',TCodeTreeNodeExtension(ExistingNode.Data).Txt]);
|
||||
ExistingNode:=ProcBodyNodes.FindSuccessor(ExistingNode);
|
||||
end;
|
||||
end;
|
||||
@ -5690,7 +5691,7 @@ begin
|
||||
|
||||
{AnAVLNode:=ClassProcs.FindLowest;
|
||||
while AnAVLNode<>nil do begin
|
||||
DebugLn(' AAA ',TCodeTreeNodeExtension(AnAVLNode.Data).Txt);
|
||||
DebugLn(' Existing proc headers: ',TCodeTreeNodeExtension(AnAVLNode.Data).Txt);
|
||||
AnAVLNode:=ClassProcs.FindSuccessor(AnAVLNode);
|
||||
end;}
|
||||
|
||||
@ -5752,7 +5753,7 @@ begin
|
||||
ANodeExt:=TCodeTreeNodeExtension(MissingNode.Data);
|
||||
CreateCodeForMissingProcBody(ANodeExt);
|
||||
InsertProcBody(ANodeExt);
|
||||
MissingNode:=ProcBodyNodes.FindPrecessor(MissingNode);
|
||||
MissingNode:=ClassProcs.FindPrecessor(MissingNode);
|
||||
end;
|
||||
|
||||
end else begin
|
||||
@ -5771,9 +5772,10 @@ begin
|
||||
MissingNode:=ClassProcs.FindHighest;
|
||||
NearestNodeValid:=false;
|
||||
while (MissingNode<>nil) do begin
|
||||
ExistingNode:=ProcBodyNodes.Find(MissingNode.Data);
|
||||
if ExistingNode=nil then begin
|
||||
ANodeExt:=TCodeTreeNodeExtension(MissingNode.Data);
|
||||
ExistingNode:=ProcBodyNodes.Find(MissingNode.Data);
|
||||
//DebugLn(['TCodeCompletionCodeTool.CreateMissingProcBodies ANodeExt.Txt=',ANodeExt.Txt,' ExistingNode=',ExistingNode<>nil]);
|
||||
if ExistingNode=nil then begin
|
||||
// MissingNode does not have a body -> insert proc body
|
||||
case MethodInsertPolicy of
|
||||
mipAlphabetically:
|
||||
@ -5841,7 +5843,7 @@ begin
|
||||
CreateCodeForMissingProcBody(ANodeExt);
|
||||
InsertProcBody(ANodeExt);
|
||||
end;
|
||||
MissingNode:=ProcBodyNodes.FindPrecessor(MissingNode);
|
||||
MissingNode:=ClassProcs.FindPrecessor(MissingNode);
|
||||
end;
|
||||
end;
|
||||
Result:=true;
|
||||
|
@ -312,6 +312,7 @@ var
|
||||
//-----------------------------------------------------------------------------
|
||||
// useful functions
|
||||
function NodeDescriptionAsString(Desc: TCodeTreeNodeDesc): string;
|
||||
procedure WriteNodeExtTree(Tree: TAVLTree);
|
||||
function FindCodeTreeNodeExt(Tree: TAVLTree; const Txt: string
|
||||
): TCodeTreeNodeExtension;
|
||||
function FindCodeTreeNodeExtAVLNode(Tree: TAVLTree; const Txt: string
|
||||
@ -438,6 +439,27 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure WriteNodeExtTree(Tree: TAVLTree);
|
||||
var
|
||||
Node: TAVLTreeNode;
|
||||
NodeExt: TCodeTreeNodeExtension;
|
||||
begin
|
||||
if Tree=nil then begin
|
||||
DebugLn(['WriteNodeExtTree Tree=nil']);
|
||||
exit;
|
||||
end;
|
||||
DebugLn(['WriteNodeExtTree ']);
|
||||
Node:=Tree.FindLowest;
|
||||
while Node<>nil do begin
|
||||
NodeExt:=TCodeTreeNodeExtension(Node.Data);
|
||||
if NodeExt=nil then
|
||||
DebugLn([' NodeExt=nil'])
|
||||
else
|
||||
NodeExt.WriteDebugReport;
|
||||
Node:=Tree.FindSuccessor(Node);
|
||||
end;
|
||||
end;
|
||||
|
||||
function FindCodeTreeNodeExt(Tree: TAVLTree; const Txt: string
|
||||
): TCodeTreeNodeExtension;
|
||||
var
|
||||
@ -927,6 +949,13 @@ end;
|
||||
procedure TCodeTreeNodeExtension.WriteDebugReport;
|
||||
begin
|
||||
// nothing special
|
||||
DbgOut(' ');
|
||||
if Node<>nil then
|
||||
DbgOut('Node=',NodeDescriptionAsString(Node.Desc))
|
||||
else
|
||||
DbgOut('Node=nil');
|
||||
DbgOut(' Position=',dbgs(Position),' Txt="'+Txt+'" ExtTxt1="'+ExtTxt1+'" ExtTxt2="'+ExtTxt2+'" ExtTxt3="'+ExtTxt3+'"');
|
||||
debugln;
|
||||
end;
|
||||
|
||||
{ TCodeTreeNodeMemManager }
|
||||
|
Loading…
Reference in New Issue
Block a user