waldo: New Command in My CRS AL Language Extension: Search Object Names
Recently, I came across this post by Jack Mallender. An interesting idea on how to efficiently find AL Objects among your files. It basically comes down to using regex in combination with the global search functionality in VSCode, like (yep, I’m stealing this from Jack’s post – sorry, Jack ;-)):
It immediatelyconvinced me that this would be very useful for everyone, so I was thinking –why not making it part of “waldo’sCRS AL Language Extension“? Itdidn’t seem too difficult for the experienced TypeScript developer – so for anoob like me, it should be do-able as well ;-). A few hours later – after a lot of googling – I found the 9 lines of code that made this easily possible.. I’m not joking ;-).
So – I present to you – a new command as part of the extension: Search Object Names. Simply call the command, provide the searchstring, and look at the result in the search window:
Now, I made it so that when you are on a word, or selected a word in the active editor, it’s going to take that word as the default Searchstring. Just imagen, you’d like to go to the source of the code of a variable you’re on, simply make sure your cursor is on the word, and invoke the command:
May be it’s a bit overdone, but yes, there is a setting as well (CRS.SearchObjectNamesRegexPattern) , because you might want to search differently than I do .. . We were discussing that on twitter, and I just decided to not decide for you on how you want to search, but let you set it up if you would like to search differently as me. Let me give you a few options on what would be interesting settings…
Find the source object (default)
'^\w+ (\d* )?"*'Setting in VSCode:
"CRS.SearchObjectNamesRegexPattern": "^\\w+ (\\d* )?\"*"// Mind the escape charactersThis is the default pattern, which means you don’t have to set anything up for this behaviour. Basically this pattern will search any occasion where it starts with a word, than optionally a number, and then your search string.. . In other words: the exact source object of the object name you’re searching for.. .
Find all references
'\w+ (\d* )?"*'Setting in VSCode:
"CRS.SearchObjectNamesRegexPattern": "\\w+ (\\d* )?\"*"// I just removed the "^" from the default setting, which indicates "search anywhere"This pattern willsearch any occasion in code – which means: also the variable declarations. Let’s say it’s an alternative “whereused”. I won’t set it up like thisas a default setting, but I might just change it ad hoc in the search by simplyremoving that character.. .
Find anywhere in the name
'^\w+ (\d* )?"*(\w+ *)*'Setting in VSCode:
"CRS.SearchObjectNamesRegexPattern": "^\\w+ (\\d* )?\"*(\\w+ *)*"// basically added that there could be multiple words before the searchstring.This pattern issomewhat more complicated, but if you would not rely on your search term beingthe beginning of the object, but rather “somewhere” in the objectname, you could use this one.
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
|waldo: Why and how to rename all AL-files of your app with the “CRS AL Language Extension”||Blog bot||NAV: Blogs||0||09.01.2020 09:14|
|waldo: CRS AL Language Extension – version 1.1.0||Blog bot||NAV: Blogs||0||30.03.2019 00:33|
|waldo: CRS AL Language Extension – File Management||Blog bot||NAV: Blogs||0||03.07.2018 04:33|
|waldo: CRS Al Language Extension – Running Objects||Blog bot||NAV: Blogs||0||19.06.2018 04:33|
|waldo: CRS Al Language Extension||Blog bot||NAV: Blogs||0||18.04.2018 05:13|
|Опции темы||Поиск в этой теме|