• Login
Community
  • Login

Comments in function list

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
9 Posts 4 Posters 513 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P
    Philippe GRANGE
    last edited by Jan 25, 2024, 6:54 PM

    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; }
    	}
    }
    

    5222cf58-0b73-4c74-a351-97d46c800378-image.png

    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; }
    	}
    }
    

    d7fa6db6-afc8-4173-9a9f-26fb571b364d-image.png

    What am I doing wrong ?

    Thx in advance,
    Philippe

    P 1 Reply Last reply Jan 25, 2024, 7:24 PM Reply Quote 0
    • P
      PeterJones @Philippe GRANGE
      last edited by Jan 25, 2024, 7:24 PM

      @Philippe-GRANGE ,

      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.

      L 1 Reply Last reply Jan 25, 2024, 8:10 PM Reply Quote 2
      • L
        Lycan Thrope @PeterJones
        last edited by Jan 25, 2024, 8:10 PM

        @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.

        1 Reply Last reply Reply Quote 1
        • P
          Philippe GRANGE
          last edited by Jan 25, 2024, 8:47 PM

          OK I see your point. Thanks for documented answer !
          Have fun,
          Phil

          L 1 Reply Last reply Jan 25, 2024, 9:04 PM Reply Quote 0
          • L
            Lycan Thrope @Philippe GRANGE
            last edited by Lycan Thrope Jan 25, 2024, 9:05 PM Jan 25, 2024, 9:04 PM

            @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.

            P 1 Reply Last reply Jan 25, 2024, 9:15 PM Reply Quote 1
            • P
              PeterJones @Lycan Thrope
              last edited by Jan 25, 2024, 9:15 PM

              @Lycan-Thrope ,

              Thanks for the research.

              @Philippe-GRANGE ,

              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.

              P D 2 Replies Last reply Jan 26, 2024, 7:36 PM Reply Quote 1
              • P
                Philippe GRANGE @PeterJones
                last edited by Jan 26, 2024, 7:36 PM

                @PeterJones
                I’ll try this and let you know.
                Thx !

                1 Reply Last reply Reply Quote 0
                • D
                  Demetrio Foti @PeterJones
                  last edited by Nov 28, 2024, 4:52 PM

                  Hi all.
                  After reading as much as I can in the community forum, I decided not to having a defined commentExpr until the bug is solved.
                  First of all I noticed I cannot simply delete the label, but I have to keep it together with an empty string:
                  commentExpr=“”

                  Once I took this decision, I just met a situation where the function was entirely commented :(
                  “Luck is blind but misfortune sees very well” :P

                  So I don’t want to push the bugfix, I’d like just to know if the fix is planned in the very next releases or not. Just to remember when I will be able to enable again comments.
                  Tx ;)

                  P 1 Reply Last reply Nov 28, 2024, 5:15 PM Reply Quote 0
                  • P
                    PeterJones @Demetrio Foti
                    last edited by Nov 28, 2024, 5:15 PM

                    @Demetrio-Foti said in Comments in function list:

                    I’d like just to know if the fix is planned in the very next releases or not

                    It is not planned, no. The bug has been known about for at least 7 years, so if it’s been around that long, it’s not likely to get fixed in the near future.

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors