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

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Enable Function List in Notepad++ for AHK Scripts (with classes now)

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

Post by ahkDustVorteX » 05 Apr 2018, 12:16

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)

Post by Trogluddite » 24 Mar 2018, 16:48

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

Enable Function List in Notepad for AHK Scripts with classes now

Post by RobertQuora » 14 Feb 2018, 04:29

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)

Post by ahkDustVorteX » 28 Nov 2017, 12:41

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.

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

Post by RiseUp » 09 Nov 2017, 17:56

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)

Post by Nightwolf85 » 23 Jun 2017, 08:27

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] [Expand]GeSHi © Codebox Plus

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

Post by Nightwolf85 » 05 Apr 2017, 16:00

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)

Post by Helgef » 05 Apr 2017, 10:14

This fails if there is nothing to the right of the last }.

Code: [Select all]GeSHi © Codebox Plus

class test {
a(){
}
}

Putting a single space, or whatever, fixes it. Eg, adding a line break,

Code: [Select all]GeSHi © Codebox Plus

class test {
a(){
}
}


Cheers.

Edit:
Nightwolf85 wrote:Fixed:

Thanks for the fix.

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

Post by Nightwolf85 » 03 Apr 2017, 21:26

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] [Expand]GeSHi © Codebox Plus



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

Post by Helgef » 03 Apr 2017, 10:03

Thanks to all involved in this, :clap:
Although hotstring support wasn't stated, it seems to work except for,

Code: [Select all]GeSHi © Codebox Plus

:?:f::fails on hotstrings with ? option

I'm using this version.

Cheers!

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

Post by KusochekDobra » 31 Mar 2017, 18:26

Great work! Thank you very much! =)
Отличная и очень нужная работа! Большое спасибо за ваш творческий подход! =)

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

Post by boiler » 22 Mar 2017, 18:59

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)

Post by hoppfrosch » 22 Mar 2017, 09:06

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)

Post by Nightwolf85 » 22 Mar 2017, 07:10

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/function-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.

String Authors: within block-comment is detected as hotstring

Post by hoppfrosch » 22 Mar 2017, 04:47

As promised - here I'm again:

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

Code: [Select all] [Expand]GeSHi © Codebox Plus

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

Post by hoppfrosch » 22 Mar 2017, 01:20

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

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

Post by Nightwolf85 » 21 Mar 2017, 10:29

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] [Expand]GeSHi © Codebox Plus



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)

Problem: Constructor is not detected

Post by hoppfrosch » 21 Mar 2017, 04:23

Within a class the constructor (__New()) is not detected:

Code: [Select all]GeSHi © Codebox Plus

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)

Post by hoppfrosch » 21 Mar 2017, 02:42

Thanks for adding support for class properties! :thumbup:

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

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

Post by Nightwolf85 » 19 Mar 2017, 20:07

That makes sense, and I appreciate the feedback and clarification.

I'll work on putting in the comments so it is easier for other people to understand, and modify. To start this isn't a complete parser, but this is the big RegEx string split into Function, Label, and Hotkey parts. It isn't everything broken down, but should help understand a little.

Code: [Select all]GeSHi © Codebox Plus

^[\t ]*(?!(if\(|while\(|for\())([a-zA-Z0-9#!^+&<>*~$_])+\d*\([\w+:=\d\s,&quot;#.;*`]*\)([\s\t\r\n]|(/\*.*?\*)/|((?<=[\s\t]);[^\r\n]*?$))*?[\s\t]*\{    -- Function RegEx (Not in a class)
^[\t ]*(?!(if\(|while\(|for\())([a-zA-Z0-9#!^+&<>*~$_])+\d*(\(|\[)[\w+:=\d\s,&quot;#.;*`]*(\)|\])([\s\t\r\n]|(/\*.*?\*)/|((?<=[\s\t]);[^\r\n]*?$))*?[\s\t]*\{ -- Function RegEx (In classes since it allows [] as well as () to allow parameters to match)
^[\t ]*(?!(if\(|while\(|for\())([a-zA-Z0-9#!^+&<>*~$_])+\d*:(?=([\s\t]*[\r\n]|[\s\t]+;.*[\r\n])) -- Label Regex
^[\t ]*(?!(if\(|while\(|for\())([a-zA-Z0-9#!^+&<>*~$_: ])+\d*(?&lt;![ ])::(?=[^\r\n\t\s])? -- Hotkey Regex

I then just put a | between each and use that in the parser.

To test it in Notepadd++ Search make sure to change the &quot; to a " and the &lt; to a <

and that is basically how I build and test each change.

Top