Perl keywords "class" and "method" not recognised by Function List
-
The language highlight for perl recognises new keywords - class, field, ADJUST, method - BUT the Function List does not recognise class or method entries
-
@JohnL22 said in Perl keywords "class" and "method" not recognised by Function List:
The language highlight for perl recognises new keywords - class, field, ADJUST, method - BUT the Function List does not recognise class or method entries
The syntax highlight keyword lists are separate from the FunctionList parser, so having added one doesn’t guarantee having added the other.
And during the last update of the FunctionList parser, the test file that was being used didn’t already include that syntax, so I forgot to add in the
classto matchpackageandmethodto matchsub. (I haven’t started using the new perl class/method syntax yet)Does this screenshot do what you want? (I added the
class NewClassSyntaxsection to the Perl FunctionList test file for this screenshot)

using a file ending with…
################ From here on was added by pryrt/PeterJones to test Notepad++'s FunctionList, and is not part of pltags source code sub MyClass::new { return bless {}, 'MyClass' } sub MyClass::do_thing { return 42 } sub MyClass::debug { print "ok\n" } sub Other::run { return 'running' } sub Other::stop { return 'stopped' } package NameSpace::Block { sub inBlock { return 1 } sub inBlockProto($) { return $_[0] } sub inBlockAttrib :prototype($) { return $_[0] } } package NameSpace::Semicolon; sub afterSemi { return 0 } class NewClassSyntax { method inBlock { return 1 } method inBlockProto($) { return $_[0] } method inBlockAttrib :prototype($) { return $_[0] } }If so, then you can replace
c:\program files\Notepad++\functionList\perl.xmlwith<?xml version="1.0" encoding="UTF-8" ?> <!-- ==========================================================================\ | | To learn how to make your own language parser, please check the following | link: | https://npp-user-manual.org/docs/function-list/ | \=========================================================================== --> <NotepadPlus> <functionList> <!-- ======================================================== [ PERL ] --> <!-- Perl - functions and packages, including fully-qualtified subroutine names --> <!-- ... replacement perl parser ...: https://community.notepad-plus-plus.org/topic/19842 ... make sure to rename the id\s*=\s*"perl_function" near the beginning with "perl_syntax" to match ... ... 2025-11-26: Improve the regex to not include as much pointless backtracking --> <parser displayName="Perl" id="perl_syntax" commentExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?m-s:\x23.*$) # Single Line Comment | (?s:__(?:END|DATA)__.*\Z) # Discard up till end-of-text " > <classRange mainExpr ="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?m) # ^ and $ match at line-breaks (?'PACKAGE_HEADER' ^ # NO leading white-space at start-of-line (?-i:(?:package|class)\b) ) (?s:.*?) # whatever, (?= # ...up till \s* # ...optional leading white-space of (?: (?&PACKAGE_HEADER) # ...next header | \Z # ...or end-of-text ) ) " > <className> <nameExpr expr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) \s \K # discard text matched so far [^;{]+ " /> </className> <function mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?m) ^\h* (?:sub|method) \s+ (?:\w++\:\:)* # optional prefix::package::names:: \w+ \s*+(?:\([^()]*+\)\s*+)?+ # prototype or signature (?:\:[^{]+)?+ # attributes \{ # start of function body " > <functionName> <funcNameExpr expr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) ((?:sub|method)\s+)? \K # discard text matched so far (?:\w++\:\:)* # optional prefix::package::names:: \w+ # move the \K to just before this line if you don't want prefix::package shown in the functionList Panel " /> </functionName> </function> </classRange> <function mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?m) ^\h* (?:sub|method) \s+ (?:\w++\:\:)* # optional prefix::package::names:: \w+ # add \K before the \w+ if you don't want prefix::package:: shown in the functionList Panel \s*+(?:\([^()]*+\)\s*+)?+ # prototype or signature (?:\:[^{]+)?+ # attributes \{ # start of function body " > <functionName> <nameExpr expr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) (?:(?:sub|method)\s+)? \K # discard text matched so far (?:\w++\:\:)* # optional prefix::package::names:: \w+ " /> </functionName> <className> <nameExpr expr="(?:sub|method)\s+\K\w+(::\w+)*(?=::\w)"/> </className> </function> </parser> </functionList> </NotepadPlus>and try it out for a while. If it does what you expect, let me know, and I can create an official Issue and submit the updated FunctionList definition with class and method added.
And if you have examples of
classormethoddefinitions that include syntax that this updated functionList parser doesn’t handle right, give me a brief snippet of code which shows the ones that aren’t done right…update: for example, do you think ADJUST blocks should show up in as functions/methods in the FunctionList panel or not? Since it’s just code that’s run during object construction, so it’s more like a BEGIN/END block, which don’t show up as functions in the FunctionList, so I would lean toward not including them, but I could be persuaded otherwise.