• Login
Community
  • Login

Function List not working in v7.2

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
30 Posts 13 Posters 38.9k 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.
  • G
    Gary W
    last edited by Dec 16, 2016, 2:30 PM

    I have a functionList.xml file, it doesn’t work. The function list is empty for JavaScript files. Earlier versions worked.

    1 Reply Last reply Reply Quote 0
    • G
      Gary W
      last edited by Dec 16, 2016, 2:56 PM

      This is a clean install of Notepad++ 7.2.2 32-bit on Windows 10.

      1 Reply Last reply Reply Quote 0
      • F
        Florent Pagès
        last edited by Dec 16, 2016, 4:55 PM

        Just try to modify you functionList.xml file this way.

        add :

        		<association langID="19" id="js_function"/>		
        

        and add the parser

        		<parser id="js_function" displayName="Javascript" commentExpr="(?s:/\*.*?\*/)|(?m-s://.*?$)">
        		
        			<function
        
        				mainExpr="((^|\s+|[;\}\.])([A-Za-z_]\w*\.)*[A-Za-z_]\w*\s*[=:]|^|[\s;\}]+)\s*function(\s+[A-Za-z_]?\w*\([^\)\(]*\)|\([^\)\(]*\))[\n\s]*\{"
        			>
        				<functionName>
        
        
        					<nameExpr expr="[A-Za-z_]\w*\s*[=:]|[A-Za-z_]?\w*\s*\(" />
        					<nameExpr expr="[A-Za-z_]?\w*" />
        				</functionName>
        
        
        
        				<className>
        					<nameExpr expr="([A-Za-z_]\w*\.)*[A-Za-z_]\w*\." />
        					<nameExpr expr="([A-Za-z_]\w*\.)*[A-Za-z_]\w*" />
        				</className>
        			</function>
        			
        		</parser>
        

        It’s works don’t ask me why !

        1 Reply Last reply Reply Quote 1
        • M
          MAPJe71
          last edited by MAPJe71 Dec 16, 2016, 5:37 PM Dec 16, 2016, 5:36 PM

          Notepad++ should assign the “L_JAVASCRIPT” language ID (= 58) to JavaScript files. It appears to assign the “old” language ID “L_JS” (= 19).

          @donho is this a regression or am I missing something?

          C F 2 Replies Last reply Dec 16, 2016, 10:35 PM Reply Quote 1
          • C
            Claudia Frank @MAPJe71
            last edited by Dec 16, 2016, 10:35 PM

            @MAPJe71

            my function.xml has even a note

            Don't use L_JS (19) use L_JAVASCRIPT (58) instead!
            

            not to use 19 and as I’m 100% sure that I never touched javascript configuration,
            because I don’t like java at all (I don’t want to start flame war - java has its validity)
            I have to assume that this is the standard configuration.

            Cheers
            Claudia

            1 Reply Last reply Reply Quote 0
            • G
              Gary W
              last edited by Dec 19, 2016, 5:36 PM

              19 or 58, nothing works. Where can I find a corrected functionList.xml?

              1 Reply Last reply Reply Quote 0
              • G
                Gary W
                last edited by Dec 19, 2016, 5:59 PM

                There are two different files named functionList.xml. One is in Program Files (x86)\Notepad++. The other is in User\XXX\AppData\Roaming\Notepad++.

                The latter one is much bigger and more comprehensive, and by default, uses 58 for the association ID. This file also has the apparently incorrect statement “Don’t use L_JS (19) use L_JAVASCRIPT (58) instead!”

                When I change the association to 19, the function list works!

                C 1 Reply Last reply Dec 20, 2016, 4:53 PM Reply Quote 0
                • C
                  Claudia Frank @Gary W
                  last edited by Dec 20, 2016, 4:53 PM

                  @Gary-W

                  depending on your configuration whether to use %APPDATA% configuration or not the respective
                  functionlist gets loaded. I’m still confused that your saying that after changing the id it is working for you.
                  Could it be that you use an embedded js version as in html?

                  Cheers
                  Claudia

                  1 Reply Last reply Reply Quote 0
                  • G
                    Gary W
                    last edited by Dec 20, 2016, 10:07 PM

                    No, I am using straight-up JS files, Claudia.

                    C 1 Reply Last reply Dec 21, 2016, 12:30 AM Reply Quote 0
                    • C
                      Claudia Frank @Gary W
                      last edited by Dec 21, 2016, 12:30 AM

                      @Gary-W

                      ok - I can confirm. After complete deinstall and a wiping of all files and folders in
                      my installation directory and under %APPDATA% (which I thought I never used)
                      I reinstalled npp7.2.2. 32bit. Now I have the same behavior. The reason why it was working before is that I run into the doLocalConf bug.
                      I can’t say which version started ignoring the file but it seems 7.2.2 is doing it.
                      So @MAPJe71 was completely correct and I have to apologize.

                      Cheers
                      Claudia

                      1 Reply Last reply Reply Quote 1
                      • F
                        Florent Pagès @MAPJe71
                        last edited by Jun 8, 2017, 7:58 AM

                        @MAPJe71 said:

                        Notepad++ should assign the “L_JAVASCRIPT” language ID (= 58) to JavaScript files. It appears to assign the “old” language ID “L_JS” (= 19).

                        @donho is this a regression or am I missing something?

                        – Ver 7.4.1 32bits. for me the problem is still here. so I patched again my functionList.xml

                        1 Reply Last reply Reply Quote 0
                        • D
                          dinkumoil
                          last edited by Jun 8, 2017, 4:28 PM

                          Hi @all,

                          I also found a bug in the regular expression of the JavaScript parser for matching the pattern of a function header. If between the function name and the left parenthesis of the parameter list have been inserted one or more blanks the parser failed to find the function header.

                          Npp version

                          v7.4.1, 32 bit

                          File

                          C:\Program Files (x86)\Notepad++\functionList.xml
                          copied to
                          C:\Users<UserName>\AppData\Roaming\Notepad++\functionList.xml

                          Corrected JavaScript parser

                          <parser
                          	displayName="JavaScript"
                          	id         ="javascript_function"
                          	commentExpr="(?s:/\*.*?\*/)|(?m-s://.*?$)"
                          >
                          	<function
                          		mainExpr="((^|\s+|[;\}\.])([A-Za-z_]\w*\.)*[A-Za-z_]\w*\s*[=:]|^|[\s;\}]+)\s*function(\s+[A-Za-z_]?\w*\s*\([^\)\(]*\)|\([^\)\(]*\))[\n\s]*\{"
                          	>
                          		<functionName>
                          			<nameExpr expr="[A-Za-z_]\w*\s*[=:]|[A-Za-z_]?\w*\s*\(" />
                          			<nameExpr expr="[A-Za-z_]?\w*" />
                          		</functionName>
                          		<className>
                          			<nameExpr expr="([A-Za-z_]\w*\.)*[A-Za-z_]\w*\." />
                          			<nameExpr expr="([A-Za-z_]\w*\.)*[A-Za-z_]\w*" />
                          		</className>
                          	</function>
                          </parser>
                          

                          The bug was located in the value of mainExpr.

                          1 Reply Last reply Reply Quote 1
                          • D
                            dinkumoil
                            last edited by dinkumoil Jun 12, 2017, 11:36 PM Jun 12, 2017, 11:33 PM

                            I improved the parser for Inno Setup scripts too. Now it is also able to find procedures as well as functions/procedures with no or an empty parameter list. Furthermore forward declarations are no longer matched.

                            <!-- ================================================== [ Inno Setup ] -->
                            
                            <parser
                            	displayName="Inno Setup"
                            	id         ="innosetup_syntax"
                            >
                            	<classRange
                            		mainExpr    ="(?x)                                    # Utilize inline comments (see `RegEx - Pattern Modifiers`)
                            				(?ms)
                            				(?'SECTION_HEADER'
                            					^                                               # header starts at beginning of a line
                            					\[                                              # start of section header
                            					(?-i:Code)                                      # `Code` section name
                            					]                                               # end of section header
                            				)
                            				.*?                                               # whatever, up till...
                            				(?=                                               # ...next valid section header or...
                            					^                                               #    +-- header starts at beginning of a line
                            					\[                                              #    +-- start-of-header indicator
                            					(?-i:
                            						Components|(?:Custom)?Messages
                            					|	Dirs
                            					|	Files
                            					|	I(?:cons|nstallDelete)
                            					|	Languages
                            					|	R(?:egistry|un)
                            					|	Setup
                            					|	T(?:asks|ypes)
                            					|	Uninstall(?:Delete|Run)
                            					)                                               #    +-- valid section name
                            					]                                               #    \-- end-of-header indicator
                            				|	\Z                                              # ...end-of-file
                            				)
                            			"
                            	>
                            		<className>
                            			<nameExpr expr="^\[\K[^\h\]]+(?=])" />
                            		</className>
                            		<function
                            			mainExpr="(?x)                                      # Utilize inline comments (see `RegEx - Pattern Modifiers`)
                            					(?m-s)                                          # multi-line mode on, single-line mode off
                            					^\h*                                            # optional leading whitespace
                            					(?i:
                            						(
                            							(?'FUNCTION_HEADER'                         # function
                            								FUNCTION
                            							)
                            							|                                           # or
                            							(?'PROCEDURE_HEADER'                        # procedure
                            								PROCEDURE
                            							)
                            						)\h+
                            					)
                            					(?'VALID_ID'                                    # function/procedure identifier
                            						[A-Za-z_]\w*
                            					)
                            					(                                               # optional parameter list
                            						\s*\(                                         # start-of-parameter-list indicator
                            						[^()]*                                        # parameter list
                            						\)                                            # end-of-parameter-list indicator
                            					)*
                            					(?('FUNCTION_HEADER')                           # functions have a return type
                            						(
                            							\s*:                                        # type indicator
                            							\s*[A-Za-z_]\w*                             # type identifier
                            							\s*;                                        # end-of-statement indicator
                            						)
                            					)
                            					(?('PROCEDURE_HEADER')                          # procedures don't have a return type
                            						(
                            							\s*;                                        # end-of-statement indicator
                            						)
                            					)
                            					(?!(?i:\s*FORWARD\s*;))                         # prevent matching forward declarations
                            				"
                            		>
                            			<functionName>
                            				<funcNameExpr expr="(?i:(FUNCTION|PROCEDURE)\h+)\K[A-Za-z_]\w*\s*(\([^()]*\))*" />
                            				<!-- comment out the following node to display the method with its parameters -->
                            				<funcNameExpr expr="[A-Za-z_]\w*" />
                            			</functionName>
                            		</function>
                            	</classRange>
                            	<function
                            		mainExpr="(?x)                                        # Utilize inline comments (see `RegEx - Pattern Modifiers`)
                            				(?ms)
                            				(?'SECTION_HEADER'
                            					^                                               # header starts at beginning of a line
                            					\[                                              # start-of-header indicator
                            					(?-i:
                            						Components|(?:Custom)?Messages
                            					|	Dirs
                            					|	Files
                            					|	I(?:cons|nstallDelete)
                            					|	Languages
                            					|	R(?:egistry|un)
                            					|	Setup
                            					|	T(?:asks|ypes)
                            					|	Uninstall(?:Delete|Run)
                            					)                                               # valid section name
                            					]                                               # end-of-header indicator
                            				)
                            				.*?                                               # whatever, up till...
                            				(?=
                            					(?&amp;SECTION_HEADER)                          # ...next valid section header,...
                            				|	^\[(?-i:Code)]                                  # ...`Code` section header or...
                            				|	\Z                                              # ...end-of-file
                            				)
                            			"
                            	>
                            		<functionName>
                            			<nameExpr expr="^\[\K[^\]]+(?=])" />
                            		</functionName>
                            	</function>
                            </parser>
                            
                            1 Reply Last reply Reply Quote 0
                            • Alexander SchikoraA
                              Alexander Schikora
                              last edited by Alexander Schikora Jul 9, 2017, 2:09 PM Jul 9, 2017, 2:07 PM

                              doesn’t work anymore for 7.4.2, why is this even an issue? this is the most basic ui test possible, very disappointing. But looking at the “new” xml structure, no wonder people have problems navigating to this custom xml interpretation.
                              Switching ID to 19, even though a random comment says not to, fixed this for me…

                              1 Reply Last reply Reply Quote 0
                              • T
                                t12122013 Fink
                                last edited by t12122013 Fink Aug 8, 2017, 8:14 PM Aug 8, 2017, 8:11 PM

                                `
                                <parser
                                displayName=“JavaScript”
                                id =“javascript_function”
                                commentExpr=“(?s:/.?*/)|(?m-s://.*?$)”

                                	bemerkung1="für Kommentar zwischen function header und {. [\n\s]*\{ am Ende gelöscht."
                                	bemerkung2="für new Function(...)  (?:new\s*)? eingefügt."
                                	bemerkung3="für function (a,b,c) ohne Funktionsname ein \s* eingefügt."
                                
                                  comment1="comment between function header and function body {, removed [\n\s]*\{"
                                  comment2="new Function() : inserted (?:new\s*)? "
                                  comment3="function (a,b,c) without function name: inserted \s*"
                                  comment4="comment within function header still not recognized. e.g. function /*returns real*/ a(b) { }"
                                    comment99="there must be something wrong with processing of commentExpr"
                                	
                                >
                                <function
                                   	mainExpr="((^|\s+|[;\}\.])([A-Za-z_]\w*\.)*[A-Za-z_]\w*\s*[=:]|^|[\s;\}]+)\s*(?:new\s*)?function(\s+[A-Za-z_]?\w*\s*\([^\)\(]*\)|s*\([^\)\(]*\))"
                                			
                                			
                                      >
                                    <functionName>
                                        <nameExpr expr="[A-Za-z_]\w*\s*[=:]|[A-Za-z_]?\w*\s*\(" />
                                        <nameExpr expr="[A-Za-z_]?\w*" />
                                    </functionName>
                                    <className>
                                        <nameExpr expr="([A-Za-z_]\w*\.)*[A-Za-z_]\w*\." />
                                        <nameExpr expr="([A-Za-z_]\w*\.)*[A-Za-z_]\w*" />
                                    </className>
                                </function>
                                  </parser>`
                                
                                1 Reply Last reply Reply Quote 0
                                • T
                                  t12122013 Fink
                                  last edited by t12122013 Fink Aug 9, 2017, 1:01 AM Aug 9, 2017, 12:59 AM

                                  trying again, by content and by form

                                  <parser
                                  displayName="JavaScript"
                                  id         ="javascript_function"
                                  	XcommentExpr="(?s:/\*.*?\*/)|(?m-s://.*?$)"
                                  
                                  	
                                  	bemerkung1="für Kommentar zwischen function header und {. [\n\s]*\{ am Ende gelöscht."
                                  	bemerkung2="für new Function(...)  (?:new\s*)? eingefügt."
                                  	bemerkung3="für function (a,b,c) ohne Funktionsname ein \s* eingefügt."
                                  	bemerkung4="Kommentar im Funktionsheader wird nicht behandelt, z.B. function /*returns real*/ a(b) { } "
                                  	bemerkung5="commentExpr überhaupt X-ed."
                                  	bemerkung99="Es muss etwas falsch sein mit commentExpr durch nichts ersetzen."
                                  	
                                  	comment1="Comment between function header and function body {: removed [\n\s]*\{ "
                                  comment2="new Function(): inserted (?:new\s*)? "
                                  comment3="function (a,b,c) without function name: inserted \s*" 
                                  comment4="Comment within function header still not handled. e.g. function /*returns real*/ a(b) { } "
                                  	comment5="commentExpr disabled: X-ed."
                                  comment99="There must be something wrong in NPP when replacing commentExpr by nothing."
                                  	
                                  >
                                  <function
                                     	mainExpr="((^|\s+|[;\}\.])([A-Za-z_]\w*\.)*[A-Za-z_]\w*\s*[=:]|^|[\s;\}]+)\s*(?:new\s*)?function(\s+[A-Za-z_]?\w*\s*\([^\)\(]*\)|s*\([^\)\(]*\))"
                                  >
                                      <functionName>
                                          <nameExpr expr="[A-Za-z_]\w*\s*[=:]|[A-Za-z_]?\w*\s*\(" />
                                          <nameExpr expr="[A-Za-z_]?\w*" />
                                      </functionName>
                                      <className>
                                          <nameExpr expr="([A-Za-z_]\w*\.)*[A-Za-z_]\w*\." />
                                          <nameExpr expr="([A-Za-z_]\w*\.)*[A-Za-z_]\w*" />
                                      </className>
                                  </function>
                                  </parser>
                                  
                                  1 Reply Last reply Reply Quote 0
                                  • M
                                    MAPJe71
                                    last edited by MAPJe71 Aug 9, 2017, 1:25 AM Aug 9, 2017, 1:23 AM

                                    Notepad++ uses the commentExpr to determine which parts of the text to skip when searching for classes, methods and/or functions.
                                    “Embedded” comments are not supported.

                                    1 Reply Last reply Reply Quote 0
                                    • M
                                      MAPJe71
                                      last edited by Aug 9, 2017, 1:29 AM

                                      @t12122013-Fink
                                      See also issues #344 and #1023 on GitHub.

                                      1 Reply Last reply Reply Quote 0
                                      • D
                                        David Liang
                                        last edited by Aug 9, 2017, 7:48 AM

                                        C# function list fix for v7.4.2
                                        Basically copy the function section inside classRange and paste it at the same level of classRange.
                                        <!-- ========================================================== [ C# ] -->

                                        		<!--
                                        		|   Based on:
                                        		|       http://sourceforge.net/p/notepad-plus/patches/613/
                                        		\-->
                                        		<parser
                                        			displayName="C#"
                                        			id         ="csharp_class"
                                        			commentExpr="(?s:/\*.*?\*/)|(?m-s://.*?$)"
                                        		>
                                        			<classRange
                                        				mainExpr    ="^[\t\x20]*((public|protected|private|internal)\s+)?(\w+\s*)?(class|struct|interface)[\t\x20]+[^\{]+\{"
                                        				openSymbole ="\{"
                                        				closeSymbole="\}"
                                        			>
                                        				<className>
                                        					<nameExpr expr="(class|struct|interface)[\t\x20]+\w+" />
                                        					<nameExpr expr="[\t\x20]+\w+" />
                                        					<nameExpr expr="\w+" />
                                        				</className>
                                        				<function
                                        					mainExpr="^[^\S\r\n]*(?&lt;modifier1&gt;(?:public|protected|internal|private)\s*)?(?&lt;modifier2&gt;(?:new|static|virtual|sealed|override|abstract|extern)\s*)?(partial\s*)?(?&lt;type&gt;(?!(return|if|else))\w+(?&lt;genericType&gt;&lt;[\w,\s&lt;&gt;]+&gt;)?\s+)(?&lt;name&gt;\w+(?&lt;genericNameType&gt;&lt;[\w,\s&lt;&gt;]+&gt;)?\s?)\((?&lt;params&gt;[\w\s,&lt;&gt;\[\]\:=\.]*)\)(?&lt;ctorChain&gt;\s*\:\s*(?:base|this)\s*\((?&lt;ctorParams&gt;[\w\s,&lt;&gt;\[\]\:=\.]*)\))?[\w\s&lt;&gt;\:,\(\)\[\]]*(?:\{|;)"
                                        				>
                                        					<functionName>
                                        						<funcNameExpr expr="(\w+(&lt;[\w,\s&lt;&gt;]+&gt;)?\s?)\(" />
                                        						<funcNameExpr expr="(\w+(&lt;[\w,\s&lt;&gt;]+&gt;)?\s?)" />
                                        					</functionName>
                                        				</function>
                                        			</classRange>
                                        			<function
                                        				mainExpr="^[^\S\r\n]*(?&lt;modifier1&gt;(?:public|protected|internal|private)\s*)?(?&lt;modifier2&gt;(?:new|static|virtual|sealed|override|abstract|extern)\s*)?(partial\s*)?(?&lt;type&gt;(?!(return|if|else))\w+(?&lt;genericType&gt;&lt;[\w,\s&lt;&gt;]+&gt;)?\s+)(?&lt;name&gt;\w+(?&lt;genericNameType&gt;&lt;[\w,\s&lt;&gt;]+&gt;)?\s?)\((?&lt;params&gt;[\w\s,&lt;&gt;\[\]\:=\.]*)\)(?&lt;ctorChain&gt;\s*\:\s*(?:base|this)\s*\((?&lt;ctorParams&gt;[\w\s,&lt;&gt;\[\]\:=\.]*)\))?[\w\s&lt;&gt;\:,\(\)\[\]]*(?:\{|;)"
                                        			>
                                        				<functionName>
                                        					<funcNameExpr expr="(\w+(&lt;[\w,\s&lt;&gt;]+&gt;)?\s?)\(" />
                                        					<funcNameExpr expr="(\w+(&lt;[\w,\s&lt;&gt;]+&gt;)?\s?)" />
                                        				</functionName>
                                        			</function>
                                        		</parser>
                                        
                                        maroonmoon13M 1 Reply Last reply Aug 22, 2017, 7:23 PM Reply Quote 0
                                        • T
                                          t12122013 Fink
                                          last edited by t12122013 Fink Aug 9, 2017, 2:13 PM Aug 9, 2017, 2:12 PM

                                          @ MAPJe71
                                          Thank you for the explanation about comment handling. Of course I assumed Notepad++ would strip comments lexically, replacing them by an empty string, and only then apply mainExpr, but it seems not to be the case.

                                          For my situation and needs I prefer to disable commentExpr at all, and do the other minor improvements written in my comments. I do get all functions, and do not get false functions. Reasoning, I do not have functions inside comments, and I do not place comments in function headers except between ) and { . Besides that, functions temporarely commented out, may still count as functions.
                                          At least the <parser> above is a partial proposal to my and other’s issues.

                                          By the way do you have an idea how to remove the mis-written earlier posts. I was not fluent with this BB and with markup language, and is there a preview?

                                          M 1 Reply Last reply Aug 9, 2017, 4:14 PM Reply Quote 0
                                          • First post
                                            Last post
                                          The Community of users of the Notepad++ text editor.
                                          Powered by NodeBB | Contributors