Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 SOLVED: googletest completion problems
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pjwhams
Senior Member

25 Posts

Posted - Feb 07 2017 :  07:34:49 AM  Show Profile  Reply with Quote
[previously titled: Bug: can't do completion on 'tester']

To reproduce:

- Create an object instance: 'Myclass tester;'
- On the next line start typing 'tester'

EXPECTED: the dropdown shows 'tester' as an option
ACTUAL: it shows 'Tester' and 'testerr' (we do have a class called Tester but it's in an anonymous namespace in another file, and testerr is in libxml)

Also:
- type 'tester.' to start autocompletion

EXPECTED: the dropdown shows the functions of Myclass
ACTUAL: the variable name gets changed to 'Tester' and the dropdown shows a list of global functions instead









Edited by - pjwhams on Feb 09 2017 09:36:52 AM

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Feb 07 2017 :  10:38:18 AM  Show Profile  Reply with Quote
This is working for me, as expected, using win10 + VS2015 + VA2118.

Do you have:

VA Options -> Coloring and Attributes -> Show local symbols in bold

turned On or Off? If you have this turned Off, can you please turn it on, and then try this test again. You need to wait a couple of moments after entering the new variable before VA will show it in bold. Once it goes bold, it should appear both in the listbox as a suggestion, and its members should be suggested.

If this variable does not go bold, please place your caret into "tester" on the line where you have declared it. What does VA show in its context and definition fields? These are normally shown at the top of the editor, and are where the Alt-M menu appears.

zen is the art of being at one with the two'ness
Go to Top of Page

pjwhams
Senior Member

25 Posts

Posted - Feb 07 2017 :  11:46:07 AM  Show Profile  Reply with Quote
I didn't have this option set. I have now set it on. When I type 'tester' the name shows up in bold as expected, but I still get the above problems.

I have managed to isolate this bug a bit more: I renamed the Tester class and now only 'testerr' shows up in the dropdown. That function is defined as:

#ifdef DEBUG_ERR
static void testerr(xmlRegExecCtxtPtr exec) {
#endif

So it appears to be that this seems to happen with functions or classes that are declared as static or in an anonymous namespace in a different cpp file, where part of the variable name matches a prefix of the function/class name. Unfortunately I can't reproduce this in a minimal test app.

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Feb 07 2017 :  2:23:02 PM  Show Profile  Reply with Quote
When you have your problem variable, if you place the caret into it, what does VA show in its navigation bar?

If you press Alt-G, what happens? I am trying to work out if VA knows this is both a local variable and the name of a function, or if somehow VA thinks this is only a function, despite it being shown in bold.

zen is the art of being at one with the two'ness
Go to Top of Page

pjwhams
Senior Member

25 Posts

Posted - Feb 07 2017 :  5:17:23 PM  Show Profile  Reply with Quote
Interestingly, the navigation bar is blank. I've also found that it's blank everywhere in the function. It seems that this is happening inside googletest test fixtures. If I put the code in a regular function then the dropdowns and code completion work as expected:

TEST_F(MyTest, test1)
{
MyClass tester;
tester [press ctrl-. reproduces bug, also no data in navigation bar]
}

void miscFunction()
{
MyClass tester;
tester [press ctrl-. - works as expected, navigation bar correct]
}

The tooltips show the correct information for 'tester', which suggests that VA does know that it's a local variable. Alt-G does go to the instance (though in some cases it shows a number of possible candidates, including the correct one). If I change it from a googletest fixture to a regular function then everything works correctly.

So I think this may be a problem with the handling of googletest fixtures, which get mangled into classes by some macro magic.

}
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Feb 09 2017 :  09:10:05 AM  Show Profile  Reply with Quote
This makes a bit more sense. This has come up once or twice before, and basically VA is getting confused by the test macros, and it looks like the IDE intellisense parser isn't doing any better. To try and work around this problem, can you please create a file called "va_stdafx.h" and place it in the same directory as your SLN file, as explained here:

http://docs.wholetomato.com/default.asp?W302

Into the file, place the following code:

namespace testing
{

#define TEST(cls, meth) class cls_meth_Test : public ::testing::Test { virtual void TestBody(); }; void cls_meth_Test::TestBody()


#define TEST_F(cls, meth) class cls_meth_Test : public cls { virtual void TestBody(); }; void cls_meth_Test::TestBody()

}


make sure the "va_stdafx.h" file ends with a blank line. Note, you do not need to add this file to your solution, VA looks for this helper file automatically, and you only want VA considering this file, not the compiler as well.

After creating the file, please press the button:

VA Options -> Performance -> Rebuild symbol databases

and restart your IDE. This will trigger a full reparse of your stable include directories and solution, which could take a few moments. Once done, hopefully, VA will have a better idea of what is going on inside these test functions. This is working for me in a simple test case, so hopefully it will work for you as well.

We are looking to improve default support for these google test macros at some point:

case=90217

zen is the art of being at one with the two'ness

Edited by - feline on Feb 09 2017 09:49:35 AM
Go to Top of Page

pjwhams
Senior Member

25 Posts

Posted - Feb 09 2017 :  09:36:00 AM  Show Profile  Reply with Quote
Yes! Thank you, that has fixed the problems. The navigation bar now shows the correct location and the autocompletion dropdowns now work as expected.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Feb 09 2017 :  09:50:56 AM  Show Profile  Reply with Quote
Thank you for the update, I am glad this has worked. I have now finally talked the forum into posting the code with new lines in it, to make it a bit easier to read and follow.

If you have the same problem in any other solutions, you can just copy the "va_stdafx.h" file across. Since it is not included, and just needs to be in the right directory, you can safely add it to source control as well.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000