diff --git a/.gitattributes b/.gitattributes
index 8cafa79bf0..54199880e4 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -986,6 +986,7 @@ 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_nestedclasses.pas svneol=native#text/plain
+components/codetools/tests/fdt_objccategory.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
diff --git a/components/codetools/tests/fdt_objccategory.pas b/components/codetools/tests/fdt_objccategory.pas
new file mode 100644
index 0000000000..f36e3ef54d
--- /dev/null
+++ b/components/codetools/tests/fdt_objccategory.pas
@@ -0,0 +1,57 @@
+unit fdt_objccategory;
+
+{$mode objfpc}{$H+}
+{$ModeSwitch objectivec1}
+
+interface
+
+uses
+ Classes, SysUtils;
+
+type
+
+ { ta }
+
+ ta = objcclass(NSObject)
+ end;
+
+ { ca }
+
+ ca = objccategory(NSObject)
+ procedure categoryAmethod; message 'categoryAmethod';
+ end;
+
+ { cb }
+
+ cb = objccategory(ta)
+ procedure categoryBmethod; message 'categoryBmethod';
+ end;
+
+procedure DoIt;
+
+implementation
+
+{ ca }
+
+procedure ca.categoryAmethod;
+begin
+
+end;
+
+{ cb }
+
+procedure cb.categoryBmethod;
+begin
+
+end;
+
+procedure DoIt;
+var
+ a: NSObject;
+begin
+ a:=ta(ta.alloc).init;
+ a.categoryAmethod{declaration:fdt_objccategory.ca.categoryAmethod};
+end;
+
+end.
+
diff --git a/components/codetools/tests/fdtbase.pas b/components/codetools/tests/fdtbase.pas
index 4847de1a57..2f8755dd8f 100644
--- a/components/codetools/tests/fdtbase.pas
+++ b/components/codetools/tests/fdtbase.pas
@@ -4,11 +4,14 @@
./finddeclarationtest --format=plain --suite=TestFindDeclaration_Base
./finddeclarationtest --format=plain --suite=TestFindDeclaration_NestedClasses
./finddeclarationtest --format=plain --suite=TestFindDeclaration_ClassHelper
+ ./finddeclarationtest --format=plain --suite=TestFindDeclaration_ObjCCategory
}
unit fdtbase;
{$mode objfpc}{$H+}
+{off $define VerboseFindDeclarationTests}
+
interface
uses
@@ -27,6 +30,7 @@ type
procedure TestFindDeclaration_Base;
procedure TestFindDeclaration_NestedClasses;
procedure TestFindDeclaration_ClassHelper;
+ procedure TestFindDeclaration_ObjCCategory;
end;
var
@@ -76,6 +80,9 @@ var
Marker: String;
begin
Filename:=TrimAndExpandFilename(Filename);
+ {$IFDEF VerboseFindDeclarationTests}
+ debugln(['TTestFindDeclaration.FindDeclarations File=',Filename]);
+ {$ENDIF}
Code:=CodeToolBoss.LoadFile(Filename,true,false);
if Code=nil then
raise Exception.Create('unable to load '+Filename);
@@ -106,11 +113,15 @@ begin
if Marker='declaration' then begin
ExpectedPath:=copy(Src,PathPos,CommentP-1-PathPos);
//debugln(['TTestFindDeclaration.FindDeclarations ExpectedPath=',ExpectedPath]);
+ { $IFDEF VerboseFindDeclarationTests}
+ debugln(['TTestFindDeclaration.FindDeclarations searching "',Marker,'" at ',Tool.CleanPosToStr(NameStartPos-1),' ExpectedPath=',ExpectedPath]);
+ { $ENDIF}
Tool.CleanPosToCaret(NameStartPos-1,CursorPos);
if not CodeToolBoss.FindDeclaration(CursorPos.Code,CursorPos.X,CursorPos.Y,
FoundCursorPos.Code,FoundCursorPos.X,FoundCursorPos.Y,FoundTopLine)
then begin
- AssertEquals('find declaration failed at '+Tool.CleanPosToStr(NameStartPos-1)+': '+CodeToolBoss.ErrorMessage,false,true);
+ if ExpectedPath<>'' then
+ AssertEquals('find declaration failed at '+Tool.CleanPosToStr(NameStartPos-1)+': '+CodeToolBoss.ErrorMessage,false,true);
continue;
end else begin
FoundTool:=CodeToolBoss.GetCodeToolForSource(FoundCursorPos.Code,true,true) as TFindDeclarationTool;
@@ -158,6 +169,11 @@ begin
FindDeclarations('fdt_classhelper.pas');
end;
+procedure TTestFindDeclaration.TestFindDeclaration_ObjCCategory;
+begin
+ FindDeclarations('fdt_objccategory.pas');
+end;
+
initialization
GetTestRegistry.TestName := 'All tests';
BugsTestSuite := TTestSuite.Create('Bugs');
diff --git a/components/codetools/tests/finddeclarationtest.lpi b/components/codetools/tests/finddeclarationtest.lpi
index 63a8e11775..624ce937bd 100644
--- a/components/codetools/tests/finddeclarationtest.lpi
+++ b/components/codetools/tests/finddeclarationtest.lpi
@@ -41,7 +41,7 @@
-
+
@@ -49,23 +49,23 @@
-
-
-
-
+
+
+
+
diff --git a/components/codetools/tests/finddeclarationtest.lpr b/components/codetools/tests/finddeclarationtest.lpr
index a2c2fbd8cd..c5f4131210 100644
--- a/components/codetools/tests/finddeclarationtest.lpr
+++ b/components/codetools/tests/finddeclarationtest.lpr
@@ -22,6 +22,9 @@ program finddeclarationtest;
uses
Classes, sysutils, consoletestrunner, dom, fpcunit, CodeToolManager,
CodeToolsConfig, LazLogger, fdtbase, fdt_classhelper, fdt_nestedclasses,
+ {$IFDEF Darwin}
+ fdt_objccategory,
+ {$ENDIF}
fdt_basic;
const