Comments in function list
-
Hi all,
When inserting comments it avoids function list to run correctly :
this works fine :
using System; public namsespace toto { public partial class A { public A() { } public int GetB(int a) { } public void SetAValue(int v) { AVal = a; } private int AVal {get; set; } } }
but this does not work :
using System; public namsespace toto { public partial class A { // <summary> // Constructor // </summary> public A() { } public int GetB(int a) { } public void SetAValue(int v) { AVal = a; } private int AVal {get; set; } } }
What am I doing wrong ?
Thx in advance,
Philippe -
It looks like it might be a bug in the default FunctionList parser for C#, because I can definitely confirm that adding a comment definitely stops the functionList from parsing correctly (even if I put blank lines before and after).
I took a brief look at it: if I extract out the function-name regex from the XML (and fix the &-entities to actual characters) to try regex
^[^\S\r\n]*(?<modifier1>(?:public|protected|internal|private)\s*)?(?<modifier2>(?:new|static|virtual|sealed|override|abstract|extern)\s*)?(partial\s*)?(?<type>(?!(return|if|else))\w+(?<genericType><[\w,\s<>]+>)?\s+)(?<name>\w+(?<genericNameType><[\w,\s<>]+>)?\s?)\((?<params>[\w\s,<>\[\]\:=\.]*)\)(?<ctorChain>\s*\:\s*(?:base|this)\s*\((?<ctorParams>[\w\s,<>\[\]\:=\.]*)\))?[\w\s<>\:,\(\)\[\]]*(?:\{|;)
in Notepad++, it can find the names whether or not there’s a comment. And the name-token-extractor(\w+(<[\w,\s<>]+>)?\s?)
regex works as it should.So I’m guessing it’s how the comment-expression
(?s:/\*.*?\*/)|(?m-s://.*?$)
is interacting with the name-searcher… I would think the.*?
to make those wildcards non-greedy would work correctly, and the comment would stop getting in the way.I don’t know if @MAPJe71 has ever applied his effort to the C# parser (maybe not, because his repo doesn’t have one), but maybe he has some ideas, because he’s our guru.
As an interim fix, you might want to edit your
c:\program files\notepad++\functionList\cs.xml
and get rid of the commentExpr for now; after making that edit and restarting notepad++, it should at least allow you to move forward until an expert can figure out what’s wrong. -
@PeterJones ,
If I remember right, I had this problem almost a year ago now, that the problem was most likely in the FunctionList functionParser.cpp, where comments zones would break the functionlist functionality when they were inside of class declaration areas.I could be wrong, but I went over and over this, and I think this is the answer I was given, and that it most likely wasn’t going to be fixed because it would need to be rewritten and would most likely break other code.
I could be wrong, but that is approximately the problem as I remember it.
-
OK I see your point. Thanks for documented answer !
Have fun,
Phil -
@Philippe-GRANGE ,
Rechecking the FunctionList FAQ, I found this section, which might be the reason for the problem.“Embedded” comment is not supported when the ‘commentExpr’-attribute is defined. All the comment blocks (found in parse step 1) are skipped when searching for class code blocks (parse step 2) and method/function code blocks (parse step 3.3 and 4, resp.) i.e. the function definition has to start and end in the same non-comment zone (even if ‘mainExpr’ takes into account function-definition-embedded comments).
I believe this was the reason a thread I started regarding comments and the functionlist finally resolved that the embedded comments was the reason it fails in a class.
-
Thanks for the research.
If you don’t frequently try to comment out a function name, then you can probably get away with just not having
commentExpr
defined long-term. -
@PeterJones
I’ll try this and let you know.
Thx !