mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-03 13:59:35 +01:00
codetools: test for finding specialize identifier in list of ancestors
git-svn-id: trunk@50339 -
This commit is contained in:
parent
5b690a20f0
commit
a8546cf427
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -988,6 +988,7 @@ components/codetools/sourcelog.pas svneol=native#text/pascal
|
||||
components/codetools/stdcodetools.pas svneol=native#text/pascal
|
||||
components/codetools/tests/fdt_basic.pas svneol=native#text/plain
|
||||
components/codetools/tests/fdt_classhelper.pas svneol=native#text/plain
|
||||
components/codetools/tests/fdt_generics.pas svneol=native#text/plain
|
||||
components/codetools/tests/fdt_nestedclasses.pas svneol=native#text/plain
|
||||
components/codetools/tests/fdt_objccategory.pas svneol=native#text/plain
|
||||
components/codetools/tests/fdt_objcclass.pas svneol=native#text/plain
|
||||
|
||||
34
components/codetools/tests/fdt_generics.pas
Normal file
34
components/codetools/tests/fdt_generics.pas
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
./testcodetools --format=plain --suite=TestFindDeclaration_Generics
|
||||
}
|
||||
unit fdt_generics;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
|
||||
type
|
||||
generic TGenBaseAction<T> = class
|
||||
BaseName: T{declaration:fdt_generics.TGenBaseAction.T};
|
||||
end;
|
||||
|
||||
generic TGenCustomAction<T> = class(specialize TGenBaseAction{declaration:fdt_generics.TGenBaseAction}<T>)
|
||||
CustomName: T;
|
||||
end;
|
||||
|
||||
generic TGenAction<T> = class(specialize TGenCustomAction{declaration:fdt_generics.TGenCustomAction}<T>)
|
||||
ActionName: T;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
procedure DoSomething;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
{
|
||||
./testcodetools --format=plain --suite=TestFindDeclaration_NestedClasses
|
||||
}
|
||||
unit fdt_nestedclasses;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
./finddeclarationtest --format=plain --suite=TestFindDeclaration_TypeHelper
|
||||
./testcodetools --format=plain --suite=TestFindDeclaration_TypeHelper
|
||||
}
|
||||
unit fdt_typehelper;
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
./testcodetools --format=plain --suite=TestFindDeclaration_TypeHelper
|
||||
./testcodetools --format=plain --suite=TestFindDeclaration_ObjCClass
|
||||
./testcodetools --format=plain --suite=TestFindDeclaration_ObjCCategory
|
||||
./testcodetools --format=plain --suite=TestFindDeclaration_Generics
|
||||
|
||||
FPC tests:
|
||||
./testcodetools --format=plain --suite=TestFindDeclaration_FPCTests
|
||||
@ -48,6 +49,7 @@ type
|
||||
procedure TestFindDeclaration_TypeHelper;
|
||||
procedure TestFindDeclaration_ObjCClass;
|
||||
procedure TestFindDeclaration_ObjCCategory;
|
||||
procedure TestFindDeclaration_Generics;
|
||||
procedure TestFindDeclaration_FPCTests;
|
||||
procedure TestFindDeclaration_LazTests;
|
||||
end;
|
||||
@ -73,17 +75,22 @@ procedure TTestFindDeclaration.FindDeclarations(Filename: string);
|
||||
Result:='';
|
||||
while Node<>nil do begin
|
||||
case Node.Desc of
|
||||
ctnTypeDefinition,ctnVarDefinition,ctnConstDefinition:
|
||||
ctnTypeDefinition,ctnVarDefinition,ctnConstDefinition,ctnGenericName,ctnGenericParameter:
|
||||
PrependPath(GetIdentifier(@Tool.Src[Node.StartPos]),Result);
|
||||
ctnGenericParams:
|
||||
if Node.Parent.FirstChild.Desc=ctnGenericName then
|
||||
PrependPath(GetIdentifier(@Tool.Src[Node.Parent.FirstChild.StartPos]),Result);
|
||||
ctnInterface,ctnUnit:
|
||||
PrependPath(Tool.GetSourceName(false),Result);
|
||||
ctnProcedure:
|
||||
PrependPath(Tool.ExtractProcName(Node,[]),Result);
|
||||
ctnProperty:
|
||||
PrependPath(Tool.ExtractPropName(Node,false),Result);
|
||||
//else debugln(['NodeAsPath ',Node.DescAsString]);
|
||||
end;
|
||||
Node:=Node.Parent;
|
||||
end;
|
||||
debugln(['NodeAsPath ',Result]);
|
||||
end;
|
||||
|
||||
var
|
||||
@ -292,6 +299,11 @@ begin
|
||||
FindDeclarations('fdt_objccategory.pas');
|
||||
end;
|
||||
|
||||
procedure TTestFindDeclaration.TestFindDeclaration_Generics;
|
||||
begin
|
||||
FindDeclarations('fdt_generics.pas');
|
||||
end;
|
||||
|
||||
procedure TTestFindDeclaration.TestFindDeclaration_FPCTests;
|
||||
begin
|
||||
TestFiles('fpctests');
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
<PackageName Value="fpcunitconsolerunner"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="11">
|
||||
<Units Count="12">
|
||||
<Unit0>
|
||||
<Filename Value="testcodetools.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -87,6 +87,10 @@
|
||||
<Filename Value="rt_explodewith.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="fdt_generics.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit11>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
||||
@ -30,7 +30,7 @@ uses
|
||||
{$IFDEF Darwin}
|
||||
fdt_objccategory, fdt_objcclass,
|
||||
{$ENDIF}
|
||||
fdt_basic, fdt_with, rt_explodewith;
|
||||
fdt_basic, fdt_with, rt_explodewith, fdt_generics;
|
||||
|
||||
const
|
||||
ConfigFilename = 'codetools.config';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user