Pascal function list parser enhancement
Prevent in function list panel entries of procedure/function declarations placed in interface section of a Pascal unit as they are superfluous duplicates. Fix #12693, fix #12687, close #12686, close #12694
This commit is contained in:
parent
3da880b4f8
commit
3596517894
|
@ -7,11 +7,6 @@ uses
|
|||
System.SysUtils, System.Types, System.Classes;
|
||||
|
||||
|
||||
// ATTENTION!!! This is a known issue!
|
||||
// The following function should NOT be part of the function list tree.
|
||||
// However, it is still included because of the TYPE keyword after its declaration.
|
||||
// Global functions or procedures should therefor be declared immediately before
|
||||
// the keyword IMPLEMENTATION.
|
||||
function FreeFunc(const Param: integer): integer;
|
||||
|
||||
|
||||
|
@ -131,13 +126,25 @@ type
|
|||
class function FromString(const AString: string): TStdClass; static;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Free routines
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
function FreeFunc2(const Param: integer): integer;
|
||||
function FreeFunc2(const Param: integer): integer;
|
||||
|
||||
procedure Foo(AParam: integer);
|
||||
function Bar(const AParam: string): integer;
|
||||
|
||||
{function Unused1(ANum: double): cardinal;}
|
||||
|
||||
procedure Boo(AParam: integer);
|
||||
|
||||
(*
|
||||
function Unused2(ANum: double): cardinal;
|
||||
function Unused3(ANum: double): cardinal;
|
||||
*)
|
||||
|
||||
|
||||
|
||||
|
@ -165,6 +172,46 @@ end;
|
|||
|
||||
|
||||
|
||||
{ Free function Foo }
|
||||
|
||||
procedure Foo(AParam: integer);
|
||||
begin
|
||||
// Do something
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{ Free function Bar }
|
||||
|
||||
function Bar(const AParam: string): integer;
|
||||
begin
|
||||
// Do something
|
||||
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{ Free function Test }
|
||||
function Test(Tnum: Double): DWord;
|
||||
begin
|
||||
// Do something
|
||||
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{ Free function Boo }
|
||||
procedure Boo(AParam: integer);
|
||||
begin
|
||||
// Do something
|
||||
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{ Free function 4 }
|
||||
|
||||
procedure FreeFunc4(const Param: integer); forward;
|
||||
|
@ -416,10 +463,10 @@ class function TEnumHelper.FromString(const AString: string): TEnum;
|
|||
begin
|
||||
if SameText(AString, 'Member 2') then
|
||||
Result := enMember2
|
||||
|
||||
|
||||
if SameText(AString, 'Member 3') then
|
||||
Result := enMember3
|
||||
|
||||
|
||||
else
|
||||
Result := enMember1;
|
||||
end;
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"leaves":["FreeFunc","FreeFunc","FreeFunc2","FreeFunc2Internal","FreeFunc3","FreeFunc3Internal","FreeFunc4","FreeFunc4Internal","FreeFunc5","FreeFunc5Internal","InitStdInternalClass","ReInitStdInternalClass"],"nodes":[{"leaves":["Create","Destroy","Init","DeInit","SetValue","Convert<X>"],"name":"TStdClass"},{"leaves":["Create","Destroy","CopyTo"],"name":"TStdClass.TStdInternalClass"},{"leaves":["Create","Destroy","Init<I>","DeInit","SetValue"],"name":"TGenericClass<T>"},{"leaves":["Create","Destroy","CopyTo<I>"],"name":"TGenericClass<T>.TGenericInternalClass<T, I>"},{"leaves":["ToString","FromString"],"name":"TEnumHelper"},{"leaves":["AsString","FromString"],"name":"TStdClassHelper"}],"root":"unitTest"}
|
||||
{"leaves":["FreeFunc","Foo","Bar","Test","Boo","FreeFunc2","FreeFunc2Internal","FreeFunc3","FreeFunc3Internal","FreeFunc4","FreeFunc4Internal","FreeFunc5","FreeFunc5Internal","InitStdInternalClass","ReInitStdInternalClass"],"nodes":[{"leaves":["Create","Destroy","Init","DeInit","SetValue","Convert<X>"],"name":"TStdClass"},{"leaves":["Create","Destroy","CopyTo"],"name":"TStdClass.TStdInternalClass"},{"leaves":["Create","Destroy","Init<I>","DeInit","SetValue"],"name":"TGenericClass<T>"},{"leaves":["Create","Destroy","CopyTo<I>"],"name":"TGenericClass<T>.TGenericInternalClass<T, I>"},{"leaves":["ToString","FromString"],"name":"TEnumHelper"},{"leaves":["AsString","FromString"],"name":"TStdClassHelper"}],"root":"unitTest"}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
<functionList>
|
||||
<!-- ====================================================== [ Pascal ] -->
|
||||
|
||||
<!-- ====================================================== [ Pascal ] -->
|
||||
|
||||
<parser
|
||||
displayName="Pascal"
|
||||
id ="pascal_syntax"
|
||||
|
@ -17,7 +19,7 @@
|
|||
(?s:\x7B.*?\x7D) # Multi Line Comment 1st variant
|
||||
| (?s:\x28\x2A.*?\x2A\x29) # Multi Line Comment 2nd variant
|
||||
| (?m-s:\x2F{2}.*$) # Single Line Comment
|
||||
"
|
||||
"
|
||||
>
|
||||
<classRange
|
||||
mainExpr="(?x) # Utilize inline comments (see `RegEx - Pattern Modifiers`)
|
||||
|
@ -135,18 +137,12 @@
|
|||
(?:\s*OVERLOAD\s*;)? # function/procedure overloading
|
||||
(?:\s*(?:REGISTER|PASCAL|CDECL|STDCALL|SAFECALL)\s*;)? # calling convention
|
||||
(?: # external function from object file
|
||||
(?:\s*(?:VARARGS)\s*;) # variadic C function with cdecl calling convention
|
||||
(?:\s*(?:VARARGS)\s*;) # variadic C function with cdecl calling convention
|
||||
| (?:\s*(?:EXTERNAL)\s+[^;]+;) # or normal function
|
||||
)?
|
||||
(?!\s*(?:FORWARD)\s*;) # prevent matching forward declarations
|
||||
(?=(?:\s* # only match function/procedure definitions
|
||||
(?: # optional comment
|
||||
(?s:\x7B.*?\x7D) # multi line comment 1st variant
|
||||
| (?s:\x28\x2A.*?\x2A\x29) # or multi line comment 2nd variant
|
||||
| (?-s:\x2F{2}.*$) # or single line comment
|
||||
)
|
||||
)*
|
||||
\s*(?:CONST|TYPE|VAR|LABEL|BEGIN|(?R))\s* # declaration block
|
||||
(?!
|
||||
(?s:.*?^\h*IMPLEMENTATION\s+) # prevent matching declarations in interface section of unit
|
||||
| (?:\s*FORWARD\s*;) # prevent matching forward declarations in implementation section of unit
|
||||
)
|
||||
"
|
||||
>
|
||||
|
@ -158,4 +154,4 @@
|
|||
</function>
|
||||
</parser>
|
||||
</functionList>
|
||||
</NotepadPlus>
|
||||
</NotepadPlus>
|
||||
|
|
Loading…
Reference in New Issue