Page 3 of 4

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 21 Mar 2017, 02:42
by hoppfrosch
Thanks for adding support for class properties! :thumbup:

If I notice any problems with this, I'll report them

Problem: Constructor is not detected

Posted: 21 Mar 2017, 04:23
by hoppfrosch
Within a class the constructor (__New()) is not detected:

Code: Select all

class Test{
	a() {
	}
	__New(_hWnd=-1, _debug=0, _test=0) {		
		return this
	}
}
Omitting the method a() within the class, even the class itself is not detected ....

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 21 Mar 2017, 10:29
by Nightwolf85
Wow pretty embarrassing how long this went without getting caught, it wasn't the constructor that was the problem, I hadn't allowed for negative default values... seeing as how that went unnoticed I'm sure there are others, keep pointing them out to me and I'll add the conditions to the parser.

Fixed:

Code: Select all

			<parser id="ahk_function" displayName="AHK" commentExpr="((/\*.*?\*)/|((?<=[\s]);.*?$))">
				<!-- AutoHotKey Function List -->
				<classRange
					mainExpr="^[ \t]*(class|struct)[ \t]+[\w]+([ \t]+|[ \t]+(extends)[ \t]+)?\w*([\s]|(/\*.*?\*)/|((?<=[\s]);[^\r\n]*?$))*?[\s]*\{"
					openSymbole = "\{"
					closeSymbole = "\}"
					displayMode="node">
					<className>
						<nameExpr expr="(class|struct)[\s]+[\w]+"/>
						<nameExpr expr="[\s]+[\w]+"/>
						<nameExpr expr="[\w]+"/>
					</className>
					<function
						mainExpr="^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$])+\d*(\([^)]*\)|\[[^]]*\])([\s]|(/\*.*?\*)/|((?<=[\s]);[^\r\n]*?$))*?[\s]*\{|^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$])+\d*:(?=([\s]*[\r\n]|[\s]+;.*[\r\n]))|^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$: ])+\d*(?<![\s])::(?=[^\s])?">
						<functionName>
							<funcNameExpr expr="([\w#!^+&<>*~$])+\d*(\([^)]*\)|\[[^]]*\])|([\w#!^+&<>*~$: ])+\d*::?"/>
						</functionName>
					</function>
				</classRange>
				<function
					mainExpr="^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$])+\d*\([^)]*\)([\s]|(/\*.*?\*)/|((?<=[\s]);[^\r\n]*?$))*?[\s]*\{|^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$])+\d*:(?=([\s]*[\r\n]|[\s]+;.*[\r\n]))|^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$: ])+\d*(?<![\s])::(?=[^\s])?"
					displayMode="$className->$functionName">
					<functionName>
						<nameExpr expr="([\w#!^+&<>*~$])+\d*\([^)]*\)|([\w#!^+&<>*~$: ])+\d*::?"/>
					</functionName>
				</function>
			</parser>
I've tried to just allow anything to be within the ( ... ), but I can't allow function parameters to include ) ( In Classes this is ] for class parameters ) otherwise calling functions consumes everything to the next { and calls it a function. Even with this, you can kind of break it if there is for some reason no ) on a line that could qualify as a function, basically a function call. Seeing as how that would be an error most likely anyway I think its the best option.

**Edited to fix something I broke with the version posted. (sorry I kept editing this version, I keep finding things the change broke)

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 22 Mar 2017, 01:20
by hoppfrosch
Thanks for the fast fix! :dance:
Nightwolf85 wrote:Wow pretty embarrassing how long this went without getting caught, it wasn't the constructor that was the problem, I hadn't allowed for negative default values... seeing as how that went unnoticed I'm sure there are others, keep pointing them out to me and I'll add the conditions to the parser.
I didn't notice, it's the negative default value causing the problem - I just saw there is a problem. If I'll find further problems, I'll let you know. :terms: :D

String Authors: within block-comment is detected as hotstring

Posted: 22 Mar 2017, 04:47
by hoppfrosch
As promised - here I'm again:

Within a blockcomment /* ... */ the String "Authors:" is detected as hotstring and appears in functionlist:

Code: Select all

class Test {
; ******************************************************************************************************************************************
/*
	Class: Test
		Helper class

	Authors:
	<hoppfrosch at [email protected]>: Original
	
	value:
	xxx - ABC
*/	
}

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 22 Mar 2017, 07:10
by Nightwolf85
Yeah, I am aware that block comments don't stop items from being found, but if you read the documentation page for the functionlist (https://notepad-plus-plus.org/features/ ... -list.html) it states that comment sections should be skipped over, but it doesn't for some reason. I'm not sure I can easily change the RegEx to fix this, as I use a line by line search currently.

The workaround is to either put a ; before the Authors: on the line, or since labels aren't allowed to have anything after the colon other than a comment, you can put any text after Authors: and it won't show in the functionlist.

As soon as I have a fix for this, if I can get one, I will post it.

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 22 Mar 2017, 09:06
by hoppfrosch
It's not a big thing for me - just wanted to let you know.

I automatically extract documentation from my sourse using NaturalDocs (ND) - I have to check, whether ND can handle preceeding semicoloms. If not, I'll live with the wrongly detected hotstring within the functionlist ...

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 22 Mar 2017, 18:59
by boiler
The block comments thing isn't all bad. I'm planning on soon posting a tool in this genre that makes use of the "feature" that function definitions in a comment block are included.

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 31 Mar 2017, 18:26
by KusochekDobra
Great work! Thank you very much! =)
Отличная и очень нужная работа! Большое спасибо за ваш творческий подход! =)

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 03 Apr 2017, 10:03
by Helgef
Thanks to all involved in this, :clap:
Although hotstring support wasn't stated, it seems to work except for,

Code: Select all

:?:f::fails on hotstrings with ? option
I'm using this version.

Cheers!

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 03 Apr 2017, 21:26
by Nightwolf85
Thank you for the report. I don't use HotStrings very often but I looked through the documentation to make sure there weren't any other characters that weren't covered, looks like ? was all that I was missing.

Fixed:

Code: Select all

			<parser id="ahk_function" displayName="AHK" commentExpr="((/\*.*?\*)/|((?<=[\s]);.*?$))">
				<!-- AutoHotKey Function List -->
				<classRange
					mainExpr="^[ \t]*(class|struct)[ \t]+[\w]+([ \t]+|[ \t]+(extends)[ \t]+)?\w*([\s]|(/\*.*?\*)/|((?<=[\s]);[^\r\n]*?$))*?[\s]*\{"
					openSymbole = "\{"
					closeSymbole = "\}"
					displayMode="node">
					<className>
						<nameExpr expr="(class|struct)[\s]+[\w]+"/>
						<nameExpr expr="[\s]+[\w]+"/>
						<nameExpr expr="[\w]+"/>
					</className>
					<function
						mainExpr="^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$])+\d*(\([^)]*\)|\[[^]]*\])([\s]|(/\*.*?\*)/|((?<=[\s]);[^\r\n]*?$))*?[\s]*\{|^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$])+\d*:(?=([\s]*[\r\n]|[\s]+;.*[\r\n]))|^[ \t]*(?!(;|if\(|while\(|for\())([^\r\n\t])+\d*(?<![\s])::(?=[^\s])?">
						<functionName>
							<funcNameExpr expr="([\w#!^+&<>*~$])+\d*(\([^)]*\)|\[[^]]*\])|([^\r\n\t])+\d*::?"/>
						</functionName>
					</function>
				</classRange>
				<function
					mainExpr="^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$])+\d*\([^)]*\)([\s]|(/\*.*?\*)/|((?<=[\s]);[^\r\n]*?$))*?[\s]*\{|^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$])+\d*:(?=([\s]*[\r\n]|[\s]+;.*[\r\n]))|^[ \t]*(?!(;|if\(|while\(|for\())([^\r\n\t])+\d*(?<![\s])::(?=[^\s])?"
					displayMode="$className->$functionName">
					<functionName>
						<nameExpr expr="([\w#!^+&<>*~$])+\d*\([^)]*\)|([^\r\n\t])+\d*::?"/>
					</functionName>
				</function>
			</parser>
**Edit
Found some HotKeys that weren't being found either, this version allows for anything other than Newlines and Tabs to be a part of a HotKey definition.
Functions and labels are still restricted to be
Word characters:
[a-zA-Z_]
and this set of symbols:
#!^+&<>*~$

Should this be changed at all? I think this restriction is acceptable on Functions and Labels, but it wasn't inclusive enough for HotKeys. (Issue I found was ^!/:: wasn't found because of the slash)

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 05 Apr 2017, 10:14
by Helgef
This fails if there is nothing to the right of the last }.

Code: Select all

class test {
	a(){
	}
}
Putting a single space, or whatever, fixes it. Eg, adding a line break,

Code: Select all

class test {
	a(){
	}
}

Cheers.

Edit:
Nightwolf85 wrote: Fixed:
Thanks for the fix.

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 05 Apr 2017, 16:00
by Nightwolf85
Yeah, I've noticed that as well. I'm honestly not sure how to fix that part, since all the options I have for defining a class range are open and close symbols. I'll play around with it some and post if I have a solution, for now I just go through and make each of my files end with a newline (or like you said at least a space), not ideal but is an easy enough workaround.

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 23 Jun 2017, 08:27
by Nightwolf85
I noticed another bug, not with finding functions and labels, but with displaying them.

If a function had a default value using the := operator it would display as a label in the list. This wasn't a big deal since nothing was missing, but looked strange and so I fixed it:

Code: Select all

			<parser id="ahk_function" displayName="AHK" commentExpr="((/\*.*?\*)/|((?<=[\s]);.*?$))">
				<!-- AutoHotKey Function List -->
				<classRange
					mainExpr="^[ \t]*(class|struct)[ \t]+[\w]+([ \t]+|[ \t]+(extends)[ \t]+)?\w*([\s]|(/\*.*?\*)/|((?<=[\s]);[^\r\n]*?$))*?[\s]*\{"
					openSymbole = "\{"
					closeSymbole = "\}"
					displayMode="node">
					<className>
						<nameExpr expr="(class|struct)[\s]+[\w]+"/>
						<nameExpr expr="[\s]+[\w]+"/>
						<nameExpr expr="[\w]+"/>
					</className>
					<function
						mainExpr="^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$])+\d*(\([^)]*\)|\[[^]]*\])([\s]|(/\*.*?\*)/|((?<=[\s]);[^\r\n]*?$))*?[\s]*\{|^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$])+\d*:(?=([\s]*[\r\n]|[\s]+;.*[\r\n]))|^[ \t]*(?!(;|if\(|while\(|for\())([^\r\n\t])+\d*(?<![\s])::">
						<functionName>
							<funcNameExpr expr="([\w#!^+&<>*~$])+\d*(\([^)]*\)|\[[^]]*\])|([\w#!^+&<>*~$])+\d*:(?!:)|(?![ ])([^\r\n\t])+\d*::"/>
						</functionName>
					</function>
				</classRange>
				<function
					mainExpr="^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$])+\d*\([^)]*\)([\s]|(/\*.*?\*)/|((?<=[\s]);[^\r\n]*?$))*?[\s]*\{|^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&<>*~$])+\d*:(?=([\s]*[\r\n]|[\s]+;.*[\r\n]))|^[ \t]*(?!(;|if\(|while\(|for\())([^\r\n\t])+\d*(?<![\s])::"
					displayMode="$className->$functionName">
					<functionName>
						<nameExpr expr="([\w#!^+&<>*~$])+\d*\([^)]*\)|([\w#!^+&<>*~$])+\d*:(?!:)|(?![ ])([^\r\n\t])+\d*::"/>
					</functionName>
				</function>
			</parser>

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 09 Nov 2017, 17:56
by RiseUp
Nightwolf85 wrote:I noticed another bug, not with finding functions and labels, but with displaying them.

If a function had a default value using the := operator it would display as a label in the list. This wasn't a big deal since nothing was missing, but looked strange and so I fixed it:
Hey Nightwolf85, I just wanted to say thank you for all your work on this. I have put this function list ability into play a few minutes ago, and I look forward to taking advantage of it. :D

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 28 Nov 2017, 12:41
by ahkDustVorteX
Hello everyone!

Thanks a lot everyone for the effort to improve this function list. I've been absent for several weeks and I am really surprised with the progress in this subject. I will update the first message with the last modification made by Nightwolf85.

Enable Function List in Notepad for AHK Scripts with classes now

Posted: 14 Feb 2018, 04:29
by RobertQuora
OK I want try use TNxAutoCompletion with TNxComboBox until there is not a native function but I have a problem.

If I use TNxComboBox with Style = dsDropDown it works, but I need use Style = dsDropDownList because I need the user choose only one of my items, the user cannot add item

Can I do it? How?

план противодействия коррупции на 2018

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 24 Mar 2018, 16:48
by Trogluddite
Thankyou to all contributors, this works beautifully here. :D
It does a better job than some of the built in ones! I might even have a go at improving the one for Ruby now that I've seen how you guys tackled this one (it doesn't handle Ruby classes/modules.)

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 05 Apr 2018, 12:16
by ahkDustVorteX
Hi Trogludite,

I'm glad that this thread helped you. If you have any idea to share please feel free.

Regards

Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)

Posted: 09 Mar 2019, 23:00
by anotherautohotkeyusr
For my future reference, I edited the parser so that it is valid XML:

Code: Select all

			<parser
                displayName="AHK"
                id         ="ahk_function"
                commentExpr="((/\*.*?\*)/|((?&lt;=[\s]);.*?$))"
            >
				<classRange
					mainExpr="^[ \t]*(class|struct)[ \t]+[\w]+([ \t]+|[ \t]+(extends)[ \t]+)?\w*([\s]|(/\*.*?\*)/|((?&lt;=[\s]);[^\r\n]*?$))*?[\s]*\{"
					openSymbole = "\{"
					closeSymbole = "\}"
					displayMode="node">
					<className>
						<nameExpr expr="(class|struct)[\s]+[\w]+" />
						<nameExpr expr="[\s]+[\w]+" />
						<nameExpr expr="[\w]+" />
					</className>
					<function
						mainExpr="^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&amp;&lt;&gt;*~$])+\d*(\([^)]*\)|\[[^]]*\])([\s]|(/\*.*?\*)/|((?&lt;=[\s]);[^\r\n]*?$))*?[\s]*\{|^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&amp;&lt;&gt;*~$])+\d*:(?=([\s]*[\r\n]|[\s]+;.*[\r\n]))|^[ \t]*(?!(;|if\(|while\(|for\())([^\r\n\t])+\d*(?&lt;![\s])::">
						<functionName>
							<funcNameExpr expr="([\w#!^+&amp;&lt;&gt;*~$])+\d*(\([^)]*\)|\[[^]]*\])|([\w#!^+&amp;&lt;&gt;*~$])+\d*:(?!:)|(?![ ])([^\r\n\t])+\d*::" />
						</functionName>
					</function>
				</classRange>
				<function
					mainExpr="^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&amp;&lt;&gt;*~$])+\d*\([^)]*\)([\s]|(/\*.*?\*)/|((?&lt;=[\s]);[^\r\n]*?$))*?[\s]*\{|^[ \t]*(?!(if\(|while\(|for\())([\w#!^+&amp;&lt;&gt;*~$])+\d*:(?=([\s]*[\r\n]|[\s]+;.*[\r\n]))|^[ \t]*(?!(;|if\(|while\(|for\())([^\r\n\t])+\d*(?&lt;![\s])::"
					displayMode="$className->$functionName">
					<functionName>
						<nameExpr expr="([\w#!^+&amp;&lt;&gt;*~$])+\d*\([^)]*\)|([\w#!^+&amp;&lt;&gt;*~$])+\d*:(?!:)|(?![ ])([^\r\n\t])+\d*::" />
					</functionName>
				</function>
			</parser>
Using a "text" codebox, because the "xml" codebox does not colour the contents correctly.