mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 16:19:21 +02:00
codetools: test GatherIdentifiers for dotted uses and program
This commit is contained in:
parent
bf7f5c51ee
commit
0c7a9dfcb9
@ -183,6 +183,7 @@ type
|
|||||||
procedure TestFindDeclaration_NS_FN_DottedUses;
|
procedure TestFindDeclaration_NS_FN_DottedUses;
|
||||||
procedure TestFindDeclaration_NS_MultiDottedUses;
|
procedure TestFindDeclaration_NS_MultiDottedUses;
|
||||||
procedure TestFindDeclaration_NS_MultiDottedPrg;
|
procedure TestFindDeclaration_NS_MultiDottedPrg;
|
||||||
|
procedure TestGatherIdentifier_NS_MultiDottedUses;
|
||||||
|
|
||||||
// directives
|
// directives
|
||||||
procedure TestFindDeclaration_Directive_OperatorIn;
|
procedure TestFindDeclaration_Directive_OperatorIn;
|
||||||
@ -493,6 +494,7 @@ begin
|
|||||||
StartOffs := StartOffs + IdentifierStartPos;
|
StartOffs := StartOffs + IdentifierStartPos;
|
||||||
MainTool.CleanPosToCaret(StartOffs,CursorPos);
|
MainTool.CleanPosToCaret(StartOffs,CursorPos);
|
||||||
|
|
||||||
|
//debugln(['TCustomTestFindDeclaration.FindDeclarations (Loop: '+IntToStr(TestLoop)+') test GatherIdentifiers at ',dbgs(CursorPos)]);
|
||||||
if not CodeToolBoss.GatherIdentifiers(CursorPos.Code,CursorPos.X,CursorPos.Y)
|
if not CodeToolBoss.GatherIdentifiers(CursorPos.Code,CursorPos.X,CursorPos.Y)
|
||||||
then begin
|
then begin
|
||||||
if ExpectedCompletion<>'' then begin
|
if ExpectedCompletion<>'' then begin
|
||||||
@ -507,14 +509,16 @@ begin
|
|||||||
if ExpInvert then
|
if ExpInvert then
|
||||||
Delete(ExpectedTerm, 1, 1);
|
Delete(ExpectedTerm, 1, 1);
|
||||||
i:=CodeToolBoss.IdentifierList.GetFilteredCount-1;
|
i:=CodeToolBoss.IdentifierList.GetFilteredCount-1;
|
||||||
//debugln(['TCustomTestFindDeclaration.FindDeclarations ',i,' ExpectedTerm="',ExpectedTerm,'"']);
|
//debugln(['TCustomTestFindDeclaration.FindDeclarations Count=',i,' ExpectedTerm="',ExpectedTerm,'" Invert=',ExpInvert]);
|
||||||
while i>=0 do begin
|
while i>=0 do begin
|
||||||
IdentItem:=CodeToolBoss.IdentifierList.FilteredItems[i];
|
IdentItem:=CodeToolBoss.IdentifierList.FilteredItems[i];
|
||||||
if IdentItem.Node<>nil then begin
|
if IdentItem.Node<>nil then begin
|
||||||
FoundPath:=NodeAsPath(IdentItem.Tool,IdentItem.Node);
|
FoundPath:=NodeAsPath(IdentItem.Tool,IdentItem.Node);
|
||||||
//debugln(['TTestFindDeclaration.FindDeclarations i=',i,' FoundPath="',FoundPath,'"']);
|
//debugln(['TTestFindDeclaration.FindDeclarations i=',i,' FoundPath="',FoundPath,'"']);
|
||||||
if SameText(ExpectedTerm,FoundPath) then
|
if SameText(ExpectedTerm,FoundPath) then begin
|
||||||
|
//debugln(['TTestFindDeclaration.FindDeclarations Found i=',i,' FoundPath="',FoundPath,'"']);
|
||||||
break;
|
break;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
//debugln(['TTestFindDeclaration.FindDeclarations i=',i,' Identifier=',IdentItem.Identifier]);
|
//debugln(['TTestFindDeclaration.FindDeclarations i=',i,' Identifier=',IdentItem.Identifier]);
|
||||||
s := IdentItem.Identifier;
|
s := IdentItem.Identifier;
|
||||||
@ -523,12 +527,17 @@ begin
|
|||||||
then
|
then
|
||||||
if s[1]<>'&' then
|
if s[1]<>'&' then
|
||||||
s := '&' + s;
|
s := '&' + s;
|
||||||
l:=length(s);
|
if CompareText(s,ExpectedTerm)=0 then break;
|
||||||
if ((l=length(ExpectedTerm)) or (ExpectedTerm[length(ExpectedTerm)-l]='.'))
|
if Marker='declaration' then begin
|
||||||
and (CompareText(s,RightStr(ExpectedTerm,l))=0)
|
// last identifier is enough
|
||||||
then break;
|
l:=length(s);
|
||||||
|
if ((l=length(ExpectedTerm)) or (ExpectedTerm[length(ExpectedTerm)-l]='.'))
|
||||||
|
and (CompareText(s,RightStr(ExpectedTerm,l))=0)
|
||||||
|
then break;
|
||||||
|
end;
|
||||||
dec(i);
|
dec(i);
|
||||||
end;
|
end;
|
||||||
|
//debugln(['TCustomTestFindDeclaration.FindDeclarations i=',i]);
|
||||||
if (i<0) and not ExpInvert then begin
|
if (i<0) and not ExpInvert then begin
|
||||||
WriteSource(StartOffs,MainTool);
|
WriteSource(StartOffs,MainTool);
|
||||||
AssertEquals('GatherIdentifiers misses "'+ExpectedTerm+'" at '+MainTool.CleanPosToStr(StartOffs,true),true,i>=0);
|
AssertEquals('GatherIdentifiers misses "'+ExpectedTerm+'" at '+MainTool.CleanPosToStr(StartOffs,true),true,i>=0);
|
||||||
@ -2129,6 +2138,50 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestFindDeclaration.TestGatherIdentifier_NS_MultiDottedUses;
|
||||||
|
var
|
||||||
|
RedUnit, RedRedUnit: TCodeBuffer;
|
||||||
|
begin
|
||||||
|
RedUnit:=CodeToolBoss.CreateFile('red.pp');
|
||||||
|
RedRedUnit:=CodeToolBoss.CreateFile('red.red.pp');
|
||||||
|
try
|
||||||
|
RedUnit.Source:=LinesToStr([
|
||||||
|
'unit Red;',
|
||||||
|
'interface',
|
||||||
|
'var Red, RedCol, Roll: word;',
|
||||||
|
'implementation',
|
||||||
|
'end.']);
|
||||||
|
RedRedUnit.Source:=LinesToStr([
|
||||||
|
'unit Red.Red;',
|
||||||
|
'interface',
|
||||||
|
'var Red, RedCol, Run: word;',
|
||||||
|
'implementation',
|
||||||
|
'end.']);
|
||||||
|
|
||||||
|
Add([
|
||||||
|
'program Red.',
|
||||||
|
' Red.',
|
||||||
|
' Red;',
|
||||||
|
'{$mode objfpc}{$H+}',
|
||||||
|
'uses',
|
||||||
|
' Red,',
|
||||||
|
' Red.',
|
||||||
|
' Red;',
|
||||||
|
'var RedCol, Rap: word;',
|
||||||
|
'begin',
|
||||||
|
' R{completion:Red.Red.Red,Red,Red.Red,RedCol,Rap};',
|
||||||
|
' Red.R{completion:Red.Red,Red,RedCol,Roll};',
|
||||||
|
' Red.Red.R{completion:Red,RedCol,Run};',
|
||||||
|
' Red.Red.Red.R{completion:RedCol,Rap};',
|
||||||
|
'end.',
|
||||||
|
'']);
|
||||||
|
FindDeclarations(Code);
|
||||||
|
finally
|
||||||
|
RedUnit.IsDeleted:=true;
|
||||||
|
RedRedUnit.IsDeleted:=true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestFindDeclaration.TestFindDeclaration_Directive_OperatorIn;
|
procedure TTestFindDeclaration.TestFindDeclaration_Directive_OperatorIn;
|
||||||
begin
|
begin
|
||||||
StartProgram;
|
StartProgram;
|
||||||
|
Loading…
Reference in New Issue
Block a user