codetools: added test find declaration with

git-svn-id: trunk@50040 -
This commit is contained in:
mattias 2015-10-12 21:57:21 +00:00
parent 63f549b488
commit b298088ee4
5 changed files with 65 additions and 3 deletions

1
.gitattributes vendored
View File

@ -992,6 +992,7 @@ 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
components/codetools/tests/fdt_typehelper.pas svneol=native#text/plain
components/codetools/tests/fdt_with.pas svneol=native#text/plain
components/codetools/tests/fdtbase.pas svneol=native#text/plain
components/codetools/tests/finddeclarationtest.lpi svneol=native#text/plain
components/codetools/tests/finddeclarationtest.lpr svneol=native#text/plain

View File

@ -0,0 +1,49 @@
unit fdt_with;
{$mode objfpc}{$H+}
interface
type
TTest = class
public
I: string;
end;
TContainer = class
public
Sub: TTest;
I: string;
end;
implementation
procedure Test;
var
Test: TTest{declaration:fdt_with.TTest};
A: array[0..9] of string;
X: string;
aContainer: TContainer{declaration:fdt_with.TContainer};
I: integer;
begin
with Test{declaration:Test.Test} do
begin
I{declaration:fdt_with.TTest.I} := 'hello';
A{declaration:Test.A}[0] := 'abc';
end;
aContainer:=TContainer.Create;
with aContainer{declaration:Test.aContainer}, Sub{declaration:fdt_with.TContainer.Sub} do begin
I{declaration:fdt_with.TTest.I} := 'tool';
end;
for I{guesstype:Integer} := Low(A{declaration:Test.A}) to High(A) do
begin
Test.I{declaration:fdt_with.TTest.I} := 'bye';
X{declaration:Test.X} := A[I];
end;
if X='' then ;
end;
end.

View File

@ -2,6 +2,7 @@
Test with:
./finddeclarationtest --format=plain --suite=TTestFindDeclaration
./finddeclarationtest --format=plain --suite=TestFindDeclaration_Basic
./finddeclarationtest --format=plain --suite=TestFindDeclaration_With
./finddeclarationtest --format=plain --suite=TestFindDeclaration_NestedClasses
./finddeclarationtest --format=plain --suite=TestFindDeclaration_ClassHelper
./finddeclarationtest --format=plain --suite=TestFindDeclaration_TypeHelper
@ -36,6 +37,7 @@ type
procedure FindDeclarations(Filename: string);
published
procedure TestFindDeclaration_Basic;
procedure TestFindDeclaration_With;
procedure TestFindDeclaration_NestedClasses;
procedure TestFindDeclaration_ClassHelper;
procedure TestFindDeclaration_TypeHelper;
@ -84,7 +86,7 @@ procedure TTestFindDeclaration.FindDeclarations(Filename: string);
PrependPath(GetIdentifier(@Tool.Src[Node.StartPos]),Result);
ctnInterface,ctnUnit:
PrependPath(Tool.GetSourceName(false),Result);
ctnProcedureHead:
ctnProcedure:
PrependPath(Tool.ExtractProcName(Node,[]),Result);
end;
Node:=Node.Parent;
@ -171,6 +173,7 @@ begin
end else begin
FoundTool.CaretToCleanPos(FoundCursorPos,FoundCleanPos);
FoundNode:=FoundTool.FindDeepestNodeAtPos(FoundCleanPos,true);
//debugln(['TTestFindDeclaration.FindDeclarations Found: ',FoundTool.CleanPosToStr(FoundNode.StartPos,true)]);
FoundPath:=NodeAsPath(FoundTool,FoundNode);
end;
//debugln(['TTestFindDeclaration.FindDeclarations FoundPath=',FoundPath]);
@ -234,6 +237,11 @@ begin
FindDeclarations('fdt_basic.pas');
end;
procedure TTestFindDeclaration.TestFindDeclaration_With;
begin
FindDeclarations('fdt_with.pas');
end;
procedure TTestFindDeclaration.TestFindDeclaration_NestedClasses;
begin
FindDeclarations('fdt_nestedclasses.pas');

View File

@ -40,7 +40,7 @@
<PackageName Value="fpcunitconsolerunner"/>
</Item2>
</RequiredPackages>
<Units Count="8">
<Units Count="9">
<Unit0>
<Filename Value="finddeclarationtest.lpr"/>
<IsPartOfProject Value="True"/>
@ -73,6 +73,10 @@
<Filename Value="fdt_objcclass.pas"/>
<IsPartOfProject Value="True"/>
</Unit7>
<Unit8>
<Filename Value="fdt_with.pas"/>
<IsPartOfProject Value="True"/>
</Unit8>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -29,7 +29,7 @@ uses
{$IFDEF Darwin}
fdt_objccategory, fdt_objcclass,
{$ENDIF}
fdt_basic;
fdt_basic, fdt_with;
const
ConfigFilename = 'codetools.config';