UDL Folding problems in ADA
-
Since many years ago I am trying to build a perfect configuration for ADA with Notepad++.
UDL doesn´t support regular expressions !! and that is a big problem for languages like ADA because a procedure / function / struct / for / when / etc… has many ways to be opened and closed…
I have a more or less good configuration but UDL has a BUG that has not been fixed with the last version…
It seems that it is something about end line special characters (linux).
Sometimes UDL is detecting the star for example in the next line instead of the same line where it is the special word.
Example using “then” and “end” as special words for code folding (“>” is where udl is detecting these words !!)
1
2 If condition then
3 > expression;
4 end if;
5 >The very strange thing is that is being auto fixed if I press enter in line 1 !! automatically and suddenly what I get is:
1
2 If condition then
3 > expression;
4 end if;
5 >But no matter if I save the file because when I open it again is again wrong.
Is there anything I can do to fix this ¿? any possible new version to fix this bug ¿?
Will UDL support regular expressions any day in the future ¿?
Many thanks for all !!
-
would you mind sharing your ADA UDL.xml?
I haven’t digged into folding enough to understand instantly what might going on but I would give it a try to find out.
Maybe we can do something similar to what I’ve posted here, this one is for syntax highlighting but maybe can be modified for folding as well. -
there is a builtin Ada lexer, may I ask you why you don’t use this one?
-
About ADA lexer included, is totally useless… no colors… no functions… nothing… :(
And about UDL.xml you mean the custom lang xml ¿? if yes, it is inside file “userDefineLang.xml” with this content:
<UserLang name="ADA Mod" ext="a ada app" udlVersion="2.1"> <Settings> <Global caseIgnored="yes" allowFoldOfComments="yes" foldCompact="no" forcePureLC="0" decimalSeparator="2" /> <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" /> </Settings> <KeywordLists> <Keywords name="Comments">00-- 01 02 03 04</Keywords> <Keywords name="Numbers, prefix1"></Keywords> <Keywords name="Numbers, prefix2"></Keywords> <Keywords name="Numbers, extras1"></Keywords> <Keywords name="Numbers, extras2"></Keywords> <Keywords name="Numbers, suffix1"></Keywords> <Keywords name="Numbers, suffix2"></Keywords> <Keywords name="Numbers, range"></Keywords> <Keywords name="Operators1">. * : < > = / - + @ " ' ( )</Keywords> <Keywords name="Operators2">"is new" "is array" "and then" "is access"</Keywords> <Keywords name="Folders in code1, open">is</Keywords> <Keywords name="Folders in code1, middle">begin</Keywords> <Keywords name="Folders in code1, close">end</Keywords> <Keywords name="Folders in code2, open">#if then loop declare</Keywords> <Keywords name="Folders in code2, middle">#else #elsif else elsif</Keywords> <Keywords name="Folders in code2, close">#end end</Keywords> <Keywords name="Folders in comment, open"></Keywords> <Keywords name="Folders in comment, middle"></Keywords> <Keywords name="Folders in comment, close"></Keywords> <Keywords name="Keywords1">abort abstract accept access aliased all at body declare delay delta digits entry generic goto limited new of package pragma protected range requeue select separate tagged task terminate until</Keywords> <Keywords name="Keywords2">when while with for others reverse loop case</Keywords> <Keywords name="Keywords3">function procedure begin is</Keywords> <Keywords name="Keywords4">exception raise</Keywords> <Keywords name="Keywords5">return exit null</Keywords> <Keywords name="Keywords6">array record constant renames subtype type use record</Keywords> <Keywords name="Keywords7"></Keywords> <Keywords name="Keywords8">in out</Keywords> <Keywords name="Delimiters">00(type 00subtype) 01 02((EOL)) 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords> </KeywordLists> <Styles> <WordsStyle name="DEFAULT" fgColor="C0C0C0" bgColor="1D1D1D" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="COMMENTS" fgColor="0000FF" bgColor="1D1D1D" fontName="" fontStyle="1" nesting="117702655" /> <WordsStyle name="LINE COMMENTS" fgColor="008000" bgColor="1D1D1D" fontName="" fontStyle="1" nesting="0" /> <WordsStyle name="NUMBERS" fgColor="0080C0" bgColor="1D1D1D" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS1" fgColor="0000FF" bgColor="1D1D1D" fontName="" fontStyle="1" nesting="0" /> <WordsStyle name="KEYWORDS2" fgColor="0000FF" bgColor="1D1D1D" fontName="" fontStyle="1" nesting="0" /> <WordsStyle name="KEYWORDS3" fgColor="0000FF" bgColor="1D1D1D" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS4" fgColor="FF8000" bgColor="1D1D1D" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS5" fgColor="FF8000" bgColor="1D1D1D" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS6" fgColor="0000FF" bgColor="1D1D1D" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS7" fgColor="FF0000" bgColor="1D1D1D" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS8" fgColor="FF8000" bgColor="1D1D1D" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="OPERATORS" fgColor="FF8000" bgColor="1D1D1D" fontName="" fontStyle="1" nesting="0" /> <WordsStyle name="FOLDER IN CODE1" fgColor="FF0000" bgColor="1D1D1D" fontName="" fontStyle="1" nesting="0" /> <WordsStyle name="FOLDER IN CODE2" fgColor="0000FF" bgColor="1D1D1D" fontName="" fontStyle="1" nesting="0" /> <WordsStyle name="FOLDER IN COMMENT" fgColor="FF8000" bgColor="1D1D1D" fontName="" fontStyle="1" nesting="0" /> <WordsStyle name="DELIMITERS1" fgColor="0000FF" bgColor="1D1D1D" fontName="" fontStyle="1" nesting="117702655" /> <WordsStyle name="DELIMITERS2" fgColor="0000FF" bgColor="1D1D1D" fontName="" fontStyle="0" nesting="117702655" /> <WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> </Styles> </UserLang>
-
thx for the udl. As I don’t know ADA at all I searched the web for an example
and copied this one and yes, it looks weird.
For example line 86 and following do have opened folding start/ends.
The main problem, as you already know, is the usage of a multiple single end for closing a folding point.A couple of question,
- is the example a good one we can use to figure out what might be possible?
- do you already have something in mind, you mentioned regex, which might solve the problem?
- is it ok to assume that indentation might be a valid indicator where a folding point
starts and ends? If not in general, but maybe in your programming way?
-
Yes there is many ways to open and close a procedure, function, and all the rest… is very very complex compared with other languages…
Answering your questions:
- is the example a good one we can use to figure out what might be possible?
Yes. Is a good example but I miss things like a “case” and other things but is a good example anyway !
- do you already have something in mind, you mentioned regex, which might solve the problem?
I have modded function_list xml for example to be able to get functions and procedures It was difficult because of all different ways to do it… but seems it is working perfect… This is an example:
<parser id="ada_mod" displayName="ADA Mod"> <function mainExpr="(procedure|function|task body) (( * )?)([a-zA-Z0-9]([a-zA-Z0-9_-]*[a-zA-Z0-9])?)((( (( * )?)|;|is|\())?)" displayMode="$functionName"> <functionName> <nameExpr expr="(procedure|function|task body) ((( )?)+)\w+"/> <!-- <nameExpr expr="(procedure|function|task body) (( * )?)([a-zA-Z0-9]([a-zA-Z0-9_-]*[a-zA-Z0-9])?)( (( * )?)|;|is|\()"/> --> </functionName> </function> </parser>
I suppose there are more ways to reach the goal… but doing something like this is can work and is easier to model everything also for code folding… and for probably any language… but UDL doesn’t support regex…
- is it ok to assume that indentation might be a valid indicator where a folding point
starts and ends? If not in general, but maybe in your programming way?
No… that cannot be a solution… because there are many people working in the same code and for some projects we don’t have clear style rules… so there will be many times that the code indentation can be wrong… :(
Many thanks for the help !!! Hope we will be able to fix this ! Notepad++ is great and I am near to get a perfect editor for ADA !!!
-
Any news about this ¿?
Many thanks !!
-
- yes, in terms of getting a better understanding about ada but
- no about a solution yet (I still find it hard to figure out when and how an ada code block starts and stops)
BUT I learned, that there is a libadalang library available, which is accessible from python
and maybe this can be used to analyze, and maybe determine, folding points. It claims to be able to analyze 100% ada 2012 code. In addition I’m investigating ada BNF to see if there is a chance to get the needed info. Tha ada lsp, does, at its current state, not support folding info. -
I was surprised seeing a plugin template for ada. Doesn’t this provide
everything you need to make npp your ada ide like you want? -
Hi !! I cannot find that ada plugin :(… I can see a plugin called “plugin template” but nothing about Ada… Can u please help me to find that plugin ¿?
Many thanks !!
-
hmmm … maybe some browser issue but if you search for ada you should get it as the first found item. Anyways here the direct link to the ada demo plugin/template.