Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Hover and Enums

Hi

I am working to understand/fix the bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=285126 but since I'm new to Eclipse there are few questions I'd like to know the answer.

As far I could understand, the hovering over a enum string is being handled by CSourceHover class, which basically finds the enum item definition and display it as it is written in the source code, and therefore it won't show the actual integer value if it is not explicitly in the code.

I've also found that the indexer (I suppose it is it) parses the file as well at the beginning and, for example, when I save/change the file. During this process performed by PDOMCEnumerator class, the enum is also parsed and its items values are properly stored in a database - Seeing this I understand that the enum strings and values are already available "somewhere" and it would be simple to grab them and display.

Another alternative is to add the capability in AbstractGNUSourceCodeParser::enumBody (and in all other XXXXSourceCodeParser) to evaluate and set the value of the enum items that have no explicit assignment, and then change CSourceHover to display the values. Here I have my first question: Although CSourceHover stores the enum value (for now only when explicitly set), I couldn't find any way to retrieve that information from ASTTranslationUnit. As far I could see, the CSourceHover can only access  the item literal name. Is it possible to retrieve from ASTTranslationUnit object the value associated to each element?

I am a bit confused because it seems the PDOMCEnumerator and AbstractGNUSourceCodeParser are doing a little bit of duplicated work, at least when related to the enum. Is that so?

For me, the ideal approach would retrieve the enum information directly from PDOMEnumerator database object since it evaluates the values of all enum items already (explicit declared or not), and if it is not available, fallback to the current method parsing the source code text as is. To do that, however, I'd like to know where the indexer database is exposed in order for me to access it from CSourceHover (or maybe another specialized hover). Any clues?

Thanks

--
--------------------------------------------
Paulo



Back to the top