Community
    • Login

    Comments in function list

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    9 Posts 4 Posters 496 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.
    • Philippe GRANGEP
      Philippe GRANGE
      last edited by

      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

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Philippe GRANGE
        last edited by

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

        Lycan ThropeL 1 Reply Last reply Reply Quote 2
        • Lycan ThropeL
          Lycan Thrope @PeterJones
          last edited by

          @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
          • Philippe GRANGEP
            Philippe GRANGE
            last edited by

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

            Lycan ThropeL 1 Reply Last reply Reply Quote 0
            • Lycan ThropeL
              Lycan Thrope @Philippe GRANGE
              last edited by Lycan Thrope

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

              PeterJonesP 1 Reply Last reply Reply Quote 1
              • PeterJonesP
                PeterJones @Lycan Thrope
                last edited by

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

                Philippe GRANGEP Demetrio FotiD 2 Replies Last reply Reply Quote 1
                • Philippe GRANGEP
                  Philippe GRANGE @PeterJones
                  last edited by

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

                  1 Reply Last reply Reply Quote 0
                  • Demetrio FotiD
                    Demetrio Foti @PeterJones
                    last edited by

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

                    PeterJonesP 1 Reply Last reply Reply Quote 0
                    • PeterJonesP
                      PeterJones @Demetrio Foti
                      last edited by

                      @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