Thanks for adding support for class properties!
If I notice any problems with this, I'll report them
Enable Function List in Notepad++ for AHK Scripts (with classes now)
- hoppfrosch
- Posts: 443
- Joined: 07 Oct 2013, 04:05
- Location: Rhine-Maine-Area, Hesse, Germany
- Contact:
- hoppfrosch
- Posts: 443
- Joined: 07 Oct 2013, 04:05
- Location: Rhine-Maine-Area, Hesse, Germany
- Contact:
Problem: Constructor is not detected
Within a class the constructor (__New()) is not detected:
Omitting the method a() within the class, even the class itself is not detected ....
Code: Select all
class Test{
a() {
}
__New(_hWnd=-1, _debug=0, _test=0) {
return this
}
}
-
- Posts: 302
- Joined: 05 Feb 2017, 00:03
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
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:
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)
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>
**Edited to fix something I broke with the version posted. (sorry I kept editing this version, I keep finding things the change broke)
- hoppfrosch
- Posts: 443
- Joined: 07 Oct 2013, 04:05
- Location: Rhine-Maine-Area, Hesse, Germany
- Contact:
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
Thanks for the fast fix!
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.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.
- hoppfrosch
- Posts: 443
- Joined: 07 Oct 2013, 04:05
- Location: Rhine-Maine-Area, Hesse, Germany
- Contact:
String Authors: within block-comment is detected as hotstring
As promised - here I'm again:
Within a blockcomment /* ... */ the String "Authors:" is detected as hotstring and appears in functionlist:
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 hoppfrosch@anywhere.com>: Original
value:
xxx - ABC
*/
}
-
- Posts: 302
- Joined: 05 Feb 2017, 00:03
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
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.
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.
- hoppfrosch
- Posts: 443
- Joined: 07 Oct 2013, 04:05
- Location: Rhine-Maine-Area, Hesse, Germany
- Contact:
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
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 ...
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)
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.
-
- Posts: 38
- Joined: 25 Apr 2016, 18:00
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
Great work! Thank you very much! =)
Отличная и очень нужная работа! Большое спасибо за ваш творческий подход! =)
Отличная и очень нужная работа! Большое спасибо за ваш творческий подход! =)
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
Thanks to all involved in this,
Although hotstring support wasn't stated, it seems to work except for,
I'm using this version.
Cheers!
Although hotstring support wasn't stated, it seems to work except for,
Code: Select all
:?:f::fails on hotstrings with ? option
Cheers!
-
- Posts: 302
- Joined: 05 Feb 2017, 00:03
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
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:
**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)
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>
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)
Last edited by Nightwolf85 on 04 May 2017, 08:05, edited 1 time in total.
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
This fails if there is nothing to the right of the last }.
Putting a single space, or whatever, fixes it. Eg, adding a line break,
Cheers.
Edit:
Code: Select all
class test {
a(){
}
}
Code: Select all
class test {
a(){
}
}
Edit:
Thanks for the fix.Nightwolf85 wrote: Fixed:
-
- Posts: 302
- Joined: 05 Feb 2017, 00:03
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
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.
-
- Posts: 302
- Joined: 05 Feb 2017, 00:03
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
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:
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)
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.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:
- ahkDustVorteX
- Posts: 47
- Joined: 14 May 2014, 12:08
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
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.
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.
Editor: Notepad++
"Those who wait and persist, always achieve."
"Those who wait and persist, always achieve."
Enable Function List in Notepad for AHK Scripts with classes now
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
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
- Trogluddite
- Posts: 8
- Joined: 23 Mar 2018, 06:42
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
Thankyou to all contributors, this works beautifully here.
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.)
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.)
- ahkDustVorteX
- Posts: 47
- Joined: 14 May 2014, 12:08
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
Hi Trogludite,
I'm glad that this thread helped you. If you have any idea to share please feel free.
Regards
I'm glad that this thread helped you. If you have any idea to share please feel free.
Regards
Editor: Notepad++
"Those who wait and persist, always achieve."
"Those who wait and persist, always achieve."
-
- Posts: 21
- Joined: 27 Oct 2015, 18:45
Re: Enable Function List in Notepad++ for AHK Scripts (with classes now)
For my future reference, I edited the parser so that it is valid XML:
Using a "text" codebox, because the "xml" codebox does not colour the contents correctly.
Code: Select all
<parser
displayName="AHK"
id ="ahk_function"
commentExpr="((/\*.*?\*)/|((?<=[\s]);.*?$))"
>
<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>
Who is online
Users browsing this forum: No registered users and 1 guest