Hi.
I run version 1.37.1 on Debian.
I would like the symbol list to include variables declared with a `const` keyword. I tried searching in the configuration files accessible from the 'Tools' menu, and searching in the online manual, but I cannot find how to edit the sort of stuff that goes in there.
Please help! Thanks!
I'm not a javaist but
```java public class untitled { const int foo=1; public static void main (String[] args) { } } ```
shows foo in the symbol list with current git Geany.
I'm not a Javaist either; I'd like this to happen for JavaScript (ECMAScript, if you will) files. :)
Ahhhh, misread :)
I don't know javascript either but the extremely complex `.js` file: ```js const z = "abc"; ``` shows `z` in the symbols list.
If you have a more complex situation you need to provide an example that fails.
The script
``` const xsq = (function(x){ return x**2; })(2); const z = "abc"; ``` shows `z` as a "Macro", and `xsq` as a "Function". Since I didn't find a `const` variable on a script with plenty more stuff, I didn't think of looking under other symbol types. Is there a way of knowing how Geany classifies constructions? Quite specifically in JavaScript, but also in general. Thanks!
how Geany classifies constructions?
The classification is in the ctags parsers, and the ctags kinds are mapped by Geany [here](https://github.com/geany/geany/blob/90c6096ed6ea167f9100ce8f74229a3f47acc29a...)
Quite specifically in JavaScript,
which seems to be the problem, there is no Javascript case in the switch linked above, so it falls through to the somewhat random default. Well I guess it was good enough that whoever added the Javascript type didn't bother to change it, but clearly not perfect.
Anyway, if somebody with both JS and C knowledge wanted to contribute a pull request with a more specific mapping it would probably be accepted.
Lovely! I'm not knowledgeable in C, and it would take me a lot of time reading through that file, but I'll try to come up with a list, taking one of the available ones as a template. Thanks!! Also, in the LaTeX definitions it would be quite lovely to include "Figures" and "Tables"; sometimes it is useful to have them handy for back-reference. :)
In this case `z` shows as a "Macro" because it's indeed the default for the type the parser emits (thanks to C's macros), and `xsq` shows as a "Function" because the JavaScript parser (wrongly) recognizes it as not being a plain constant but actually a "lambda" function. JavaScript is tricky to parse, and here the problem is that the function part is recognized, but not the fact it's an inline call. We'd have to check if the upstream universal-ctags parser has this issue, and if not update it.
Where does the parser refer to "macro"? AFAICT [hereabouts](https://github.com/geany/geany/blob/90c6096ed6ea167f9100ce8f74229a3f47acc29a...) it doesn't have a "macro" kind, so its the mapping in symbols.c that is assigning it to a macro.
@elextr yeah, the parser emits a kind that is mapped to the TagManager type that maps to "Macro" in Geany. Easy, right? :)
Ok, so its the combination of symbols.c and tagmanager, so its not as simple as just the switch that I suggested. And now I'm remembering why I don't touch any of that stuff :)
As for the type of xsq in the above, well, I don't think ctags handles any expression evaluation, so noticing that the lambda is called and returns a value is beyond its pay grade, and (I think, jsfiddle was happy with it): ``` const xsq = (function(x){ return x*x}); ``` __is__ a function, so the presence of the parens about the lambda can't be simply taken to not make it a function. And in a dynamic language like JS static inference is unlikely to always work anyway (see also Python and other dynamic languages).
And inference is necessary in C++ and heaps of other languages too now. I'm afraid the world (except C) has run away ahead of the capabilities of the ctags model.
github-comments@lists.geany.org