codetools: test for scope rule local before uses

This commit is contained in:
mattias 2025-01-01 09:47:46 +01:00
parent c082d566ac
commit 1448213e24
2 changed files with 38 additions and 1 deletions

View File

@ -5,7 +5,7 @@ unit tunitdots.main;
interface
uses
unitdots.dot, unitdots; // unit names (with or without namespaces) win over interface identifiers
unitdots.dot, unitdots; // unit names (with or without namespaces) win over used interface identifiers
// even though the 'unitdots.dot' is left of 'unitdots'
implementation

View File

@ -161,6 +161,9 @@ type
procedure TestFindDeclaration_IncludeSearch_StarStar;
procedure TestFindDeclaration_FindFPCSrcNameSpacedUnits;
// unit namespaces
procedure TestFindDeclaration_LocalBeforeUses;
// directives
procedure TestFindDeclaration_DirectiveWithIn;
@ -1687,6 +1690,40 @@ begin
Traverse(FPCSrcDir,0,-1);
end;
procedure TTestFindDeclaration.TestFindDeclaration_LocalBeforeUses;
var
DotsUnit: TCodeBuffer;
begin
DotsUnit:=nil;
try
DotsUnit:=CodeToolBoss.CreateFile('nsA.dots.pp');
DotsUnit.Source:='unit nsa.dots;'+LineEnding
+'interface'+LineEnding
+'implementation'+LineEnding
+'end.';
StartProgram;
Add([
'uses nsA.dots;',
'type',
' TWing = record',
' Size: word;',
' end;',
' TBird = record',
' DoTs: TWing;',
' end;',
'var NSA: TBird;',
'begin',
' NSA.dots.Size{declaration:twing.Size}:=3',
'end.',
'']);
FindDeclarations(Code);
finally
if DotsUnit<>nil then
DotsUnit.IsDeleted:=true;
end;
end;
procedure TTestFindDeclaration.TestFindDeclaration_DirectiveWithIn;
begin
StartProgram;