T O P I C R E V I E W |
Benzine |
Posted - Nov 26 2020 : 08:56:01 AM Hi everyone,
Sorry if the title isn't very clear but I wasn't sure how to summarise my problem.
In some of the files of my solution, the visual assist suggestion box doesn't appear or doesn't show anything related to the class I'm in (I would have suggestions on an std::string just fine, but not on anything contained in my class). I think it's related to the fact that if I press alt + M (to show the functions list in the top navigation bar), I don't see all of my functions. If I have "functionA" and "functionB" in my class, VA would show me only functionA in there, and if I go in functionA to code, there will be all the suggestions, but not in functionB. When I look for references, functionB would not show up in the result, I'd still have the code that's in it but the function will be mislabeled with an if, for example, instead of the function name.
I tried disabling VA and intellisence work fine. I tried rebuilding VA symbol database but nothing changed. I also tried to delete the .vs folder and nothing changed aswell.
I've ignored this problem for some time but it's getting anoying now and I hope there is something that can be done.
Good day to you all and thank you for your time. |
11 L A T E S T R E P L I E S (Newest First) |
feline |
Posted - Dec 02 2020 : 05:20:00 AM Same directory does mean the same directory, this is useful when your files are grouped together, so if you open one file, and you want VA to automatically parse the other files in the same directory, so files next to it.
So the only way this setting should have an effect is if another header file in the same directory as this "problem" header file is being included.
We might be able to work around this, but so far I cannot reproduce the problem here, so I cannot test the work around I am thinking of. My test case is the following block of code:
#if 1 == 0 #define MACRO_FUNCTION_NAME { { ( #endif
void functionBeforeMacroTest() { } void MACRO_FUNCTION_NAME() { } void functionAfterMacroTest() { }
and here all three functions are always listed in the Alt-M list.
If you want to try the work around, create a new text file called "va_stdafx.h" in the same directory as your SLN file. Edit this file and add the line:
#define PROBLEM_MACRO_NAME
making sure that the file ends with a blank line.
When rebuilding its symbol database VA searches for this file, and if found, it parses it before parsing anything else. This file is used to give our parser helpful hints, and to work around odd problems that we encounter. The file should not be added to your solution, so it doesn't matter if the content of the file conflict with code inside your solution.
Here the idea is to "hide" the problem macro definition from VA, by having this empty definition of the macro take priority.
Having created and edited the file, in the IDE press the button:
VA Options -> Performance -> Rebuild symbol databases
and restart your IDE. |
Benzine |
Posted - Dec 01 2020 : 08:08:25 AM I have the "Solution is empty" one turned on, but what does "same directory" imply ? because the two files are not directly in the same one. They're not event parents. I have a folder with my sln and inside, I have a tree structure with the file containing the macro and an other with the other file. |
feline |
Posted - Dec 01 2020 : 06:52:13 AM Do you have either part of:
VA Options -> Projects and Files -> Upon opening a file, parse all other unparsed files in the same directory: if Solution is empty if Solution is not empty
turned On? This could explain why a header file you don't expect to be parsed, to be picked up.
Yes, VA can get confused when the same name is used for two different symbols. We try to handle this, but since we don't get to compile the code, and try to run fast, sometimes we do get confused.
I am glad you have found the trigger, this really was very confusing |
Benzine |
Posted - Dec 01 2020 : 06:03:13 AM I tried putting dummies functions around the problematic function, testBeforeMissingFunction() shows up in the Alt-M menu but not testAfterMissingFunction(). I tried adding functions to the .h of my class and as long as I add them before the problematic function, I see them. Anything after is not shown.
And I think I found the problem thanks to that ! It made me realise that all the files with the problem shared a function with the same name, that was the same as a macro with mismatched curly brackets in it. I wasn't using it explicitely, that's why I didn't looked at it too much at first when you asked, but I renamed the macro and now my files are working again. I guess they got confused for one another somehow.
What troubles me is that I don't include the file anywhere since I don't use the corresponding class anymore but I guess some files that I include, include this one down the line, I'll have to investigate on that. |
feline |
Posted - Nov 30 2020 : 12:17:45 PM If you don't know about any complex macros, then you probably aren't making heavy use of them. Strange, I did expect smart select to look "wrong" in what was selected.
What happens if you place a couple of simple, "dummy" functions before and after the missing function?
void testBeforeMissingFunction() { }
void testAfterMissingFunction() { }
are either of these shown correctly? |
Benzine |
Posted - Nov 30 2020 : 10:50:14 AM When you ask if I have such macros, do you mean to ask if they exist in my solution, or if they're used in the problematic code / files ? I have some macros in the likes of the one you put in your message, but I don't use them where I have the problem. I don't use them anymore, they just sit there. The others macro I have are rather simple, defining simple values or small expressions, like this : #define SupThenAffect( A, B ) if( (A) > (B) ) { (A) = (B); } No curly brackets mismatch.
I also have some templates in my solution but, like the macros, I don't use them in the problematic files.
I never used those smart select features so I'm not sure what a wrong behaviour should look like but everything seemed fine, whether I'm in the function that works or the missing one. When using Extend Selection or Extend Block Selection, I see the selection slowly growing on my code, containing if and for blocks, and finally the function in itself. After the whole function is selected, if I extend again, all the file is selected.
Most of my projects are C++, I have a C# (Windows Form Application) one and two C++ projects with CLR support. None of those projects are used by the one I'm in right now, there is only C++ used in this case. |
feline |
Posted - Nov 27 2020 : 11:52:57 AM Do you make much use of macros or templates in your code?
More specifically, do you use macros that will insert mismatched curly brackets, for example, something like:
#define BEGIN_IF_BLOCK(x, y) if(x == y) { #define END_IF_BLOCK }
VA should handle this correctly, but if the macro has different definitions in different projects, then VA could be using the wrong projects definition, thus causing the problem.
If you sit inside the function that VA shows correctly in the Alt-M list and use a mixture of:
VAssistX -> Smart Select -> Extend Selection VAssistX -> Smart Select -> Shrink Selection VAssistX -> Smart Select -> Extend Block Selection VAssistX -> Smart Select -> Shrink Block Selection
does VA select the right blocks of code? It sounds like if you try this in this function, and probably in the missing function, at some point VA will select the wrong lines of code, it won't correctly pick up the start and end of a block. Hopefully this will be an easier way to pin down where the problem starts, and once you know this, the trigger should be more obvious.
Does your solution use different programming languages, or is it all C++? |
Benzine |
Posted - Nov 27 2020 : 08:36:26 AM I tried commenting my #include lines but wasn't sure how to know if VA is reparsing the file or not as nothing was indicated at the bottom of the screen, so I cleared the cache and rebuilt the symbol database. Nothing changed.
When using the up and down arrows in the navigation bar, I jumped at every function without fail but the navigation bar didn't always display the right informations. In the problematic functions, I had "if{" written instead of the name and when I click in a function the scope "path" is messed up, there is "if{" instead of "class.function.if".
Also, I just tried opening my project alone via its .vcxproj instead of opening the .sln and all my functions are there, everything works. |
feline |
Posted - Nov 26 2020 : 12:24:59 PM This suggests the problem might be being triggered, somehow, by one of your header files, or a macro with a "strange" definition in your solution.
Can you please try commenting out all of your #include lines, then give VA a few moments to reparse the file and notice the changes, and see if this makes any difference? If this is a cascade error from one of the header files then this should fix the problem. But if it's a macro defined in the solution this probably won't help.
Another approach to finding exactly where VA gets confused is to try using VA's Next and Previous scope commands. You can trigger these from the Up and Down arrows in the "middle" of VA's navigation bar, to the right hand side of where the Alt-M list appears.
If VA understands the file correctly then you will always jump to somewhere sensible, but since there is a problem, you should see the next / previous scope jumping to the wrong place, and this should help you to narrow down where the problem is being triggered.
I am happy to pin down the trigger for you, but I need an example that has the problem to do so, obviously. |
Benzine |
Posted - Nov 26 2020 : 11:37:10 AM I have the problem in multiple files across several projects, all in the same solution.
I just tried creating a new solution and importing a problematic file, all the functions showed up in the Alt-M menu, the suggestion menu also worked just fine.
My solution in a repo on Azure DevOps, so I tried to download my repo in a fresh setup to see if I still have the problem, and yes, it's still there. So I guess the problem comes from my solution somehow. |
feline |
Posted - Nov 26 2020 : 11:16:04 AM It sounds like there is something in the file that is confusing our parser, so that we don't understand the file correctly.
If you make a new, default solution, and just copy this single file across into the new solution, do you still see the Alt-M list problem? I am trying to find out if the problem is contained entirely inside the function, or if it is somehow a solution specific problem.
Assuming the problem is specific to the file on its own, would it be possible to get a copy of the file so I can try to find out what part of the file is confusing our parser and causing this problem?
I realise this is often not possible, but it's worth asking in case it is possible. If it is, then please send me the files via email:
[email protected]
including this thread ID or URL in the description, so we can match it up. |
|
|