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
 Create Declaration doesn't always work
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

MrT
Junior Member

United Kingdom
14 Posts

Posted - Dec 08 2017 :  06:07:54 AM  Show Profile  Reply with Quote
Right clicking on a new function declared in a cpp file and then selecting "Quick Actions and Refactoring (VA)" quite often has the "Create Declaration" option greyed out, sometimes repeating the process may make the option available and others times not, if not I then have to create the declaration by hand in the header file.

Is this a bug in VA or is there something I'm missing or doing wrong as it's now becoming really annoying?

Sean Townsend

feline
Whole Tomato Software

United Kingdom
18724 Posts

Posted - Dec 08 2017 :  06:45:33 AM  Show Profile  Reply with Quote
When this is happening, has the new function been coloured by VA as a function yet? If you have not paused typing for a couple of seconds to give VA time to parse your latest edits, then VA won't know about this new function, so won't know which refactoring commands to offer on it.

Another thought, if the function name has been written for a few minutes but the Create Declaration command is still not offered, something may be confusing our parser, is the function above "finished", so it contains the same number of open and closing curly brackets?

If you look at VA Outline, is the new function implementation shown correctly? It should be, if not, then this may be a useful clue as to why you are seeing these problems.

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

MrT
Junior Member

United Kingdom
14 Posts

Posted - Dec 08 2017 :  06:59:45 AM  Show Profile  Reply with Quote
Yes, the function has been syntax coloured and the function is a finished function. Sometimes it works and others it doesn't.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18724 Posts

Posted - Dec 08 2017 :  08:57:14 AM  Show Profile  Reply with Quote
Next time you have a case where this does not work, can you please look and see if this function implementation is shown in VA Outline, and if it is in the correct position in the file?

Since VA is coloring the function correctly, I would expect Create Declaration to be offered and to work correctly all of the time.

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

MrT
Junior Member

United Kingdom
14 Posts

Posted - Dec 08 2017 :  10:12:28 AM  Show Profile  Reply with Quote
I now have a function that is coloured as expected (with a red underline), it is showing up in VA Outline (albeit in bold) in the correct place and the create declaration is greyed out, I can send you a screenshot if this would help.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18724 Posts

Posted - Dec 08 2017 :  2:36:27 PM  Show Profile  Reply with Quote
Can you please try Alt-g on this function name, and see what, if anything, happens? If VA, for some reason, thinks a declaration already exists then Create Declaration won't be offered. What refactoring commands are being offered on this function?

Is this a free function, or a class member function?

Bold in VA Outline just shows your current position in the file, so if you move the caret into a different function in the current file, the bold marker should move to match the new cursor position. Useful when you know what is going on, but this should have no effect on what refactoring commands are offered.

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

MrT
Junior Member

United Kingdom
14 Posts

Posted - Dec 11 2017 :  04:51:59 AM  Show Profile  Reply with Quote
Alt-G does nothing and the only refactoring commands available are:

Extract Method...
Create File...
Rename Files...
Edit refactoring snippets...
Find References

Also, this function is a class member function

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18724 Posts

Posted - Dec 11 2017 :  05:45:11 AM  Show Profile  Reply with Quote
This sort of makes sense, since this is what I would expect VA to show if the caret was in the white space in a file, so not in any symbol at all. So it suggests VA has no idea about this function, but I am not sure why.

With the caret in the function name, what, if anything, is shown in the VA navigation bar? This is normally shown at the top of the editor window, and is where the Alt-M list appears from.

If you move the caret back into the class name, does VA now show anything in the navigation bar? Does alt-g on the class name do anything?

Can you please try adding the following simple test into the .h and .cpp file where you are seeing this problem? I am wondering if somehow the problem is file specific, if so, this simple example, that works correctly for me, may now fail. This code goes into the header file:

class felineSimpleTestingClass
{
	void fullMethodForReference();
};

and this code goes into the matching .cpp file:

void felineSimpleTestingClass::fullMethodForReference() { }

// test - caret into function name and VA navigation bar shows 
// class and function name
void felineSimpleTestingClass::simpleCreateDecTest() { }

// test - caret into function name and VA navigation bar shows 
// class and function name
long felineSimpleTestingClass::paramCreateDecTest(std::vector<std::pair<int, std::string> > vecParamTesting) { }

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

MrT
Junior Member

United Kingdom
14 Posts

Posted - Dec 11 2017 :  06:14:44 AM  Show Profile  Reply with Quote
1) With the caret in the function name, the VA navigator bar is empty.
2) If I move the caret into whitespace within the file it shows the filename
3) If I move the caret within the function body it shows the function name.
4) Clicking on the VA navigation bar lists all the function in the file, including the function in question.
5) Moving the caret to any other function in the file has the VA navigation bar empty.
6) Adding the code snippet to the header file resolved all the above issues, I then CTRL-Z the changes in the header file and all the issues are still resolved.

I have a few files that are showing this behaviour, making any changes at all to the header file resolves all the issues VA has with the functions in the cpp file.

Edited by - MrT on Dec 11 2017 06:42:44 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18724 Posts

Posted - Dec 11 2017 :  07:15:14 AM  Show Profile  Reply with Quote
This suggests that VA reparsing the header file, due to you making a code edit, is what is fixing the problem. Do you have:

VA Options -> Performance -> Parse all files when opening a project

turned On or Off?

When you see this problem, if you close both the .h and matching .cpp file, give VA a couple of seconds to catch up, and then re-open the files, do you still see the issue?

I am trying to work out what could be triggering such an odd behaviour.

Are you aware of anything "odd" or "different" about the files that show this problem? Are they standard C++ code? Using standard file extensions? Are they in a different project in your solution?

Heavy use of macros or template code?

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

MrT
Junior Member

United Kingdom
14 Posts

Posted - Dec 11 2017 :  07:23:15 AM  Show Profile  Reply with Quote
I have the "Parse all files when opening a project" option ticked.
Closing and opening the files again make no difference.
The files are using plain C/C++ there's no heavy use of macros or templates etc.

Loading up the project on some of my work colleagues PC's doesn't show this behaviour, so it looks like it's specific to my PC/IDE.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18724 Posts

Posted - Dec 11 2017 :  1:42:27 PM  Show Profile  Reply with Quote
Perhaps a silly question, but do your colleges have the same solution, the same files and versions of the files? I am just checking you are not on significantly different code bases / versions of the solution.

Just to double check, can you search your solution directory tree for any files called "va_stdafx.h", I assume you don't have any of these, but best to double check that assumption.

Do you have any IDE extensions installed that your colleges don't?

Once you find a function that has this problem, and then make a small edit to the header file, adding and removing a blank line maybe, to fix the problem, does closing and reloading the IDE bring the problem back?

Do you keep your IDE open for days at a time? I am wondering if the files are being changed on the hard drive after VA has parsed them on solution load. Perhaps due to source control merging in changes? On this line of thought, do you have:

VA Options -> Performance -> Watch for externally modified files and reparse when necessary

turned On or Off?

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

MrT
Junior Member

United Kingdom
14 Posts

Posted - Dec 12 2017 :  04:57:46 AM  Show Profile  Reply with Quote
Yes, my colleagues have the same solution and files, they have just got them straight out of our source control system.

I do not have va_stdafx.h in my solution tree.

My colleagues have the same IDE extensions that I have plus a few others of their own.

Closing and re-opening the IDE does not cause the problem to re-occur after making changes to the header file.

Yes, I keep my IDE open for days but I am the only person working on the project so files are not being merged or modified in any other way.

I have the "watch for externally modified files and reparse when necessary" option ticked.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18724 Posts

Posted - Dec 12 2017 :  08:32:57 AM  Show Profile  Reply with Quote
Next time you come across this, can you go to the .h file, and without making any edits, see if VA Outline is showing the correct outline for the file?

By the looks of it, all it takes to fix this is a re-parse of the header file, so hopefully something will be "wrong" in the initial VA Outline view of the file. If that something is then fixed after a file edit and undo, that would give us a solid clue about what is going wrong here.

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

MrT
Junior Member

United Kingdom
14 Posts

Posted - Dec 12 2017 :  08:46:35 AM  Show Profile  Reply with Quote
VA outline for the header files is as expected, showing all classes, member variables and member functions.

VA outline is also correct for the cpp file.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18724 Posts

Posted - Dec 12 2017 :  12:04:48 PM  Show Profile  Reply with Quote
Are you seeing any signs or hints of problems that I have missed? Apart from the VA context and navigation fields in the new function name in the cpp file, and the refactoring not being offered, everything looks and works correctly doesn't it? I would expect what ever is going on here to show up somewhere else, somehow else.

OK, then let's test my assumption that its actually the reparse of the file that fixes this. While in the header file, can you please use the menu command:

VAssistX -> Tools -> Reparse Current File

without actually editing the file. When you go back to the .cpp file, is Create Declaration now offered correctly? Or is VA still not offering this refactoring?

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

MrT
Junior Member

United Kingdom
14 Posts

Posted - Dec 13 2017 :  04:59:44 AM  Show Profile  Reply with Quote
VA works as expected with the other files, Reparsing the header file using VAssist->Tools->Reparse Current File and then going back to the cpp file resolves the issue, so it looks like changes made to the file are not triggering a reparse for some reason.

Edited by - MrT on Dec 13 2017 05:43:47 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18724 Posts

Posted - Dec 14 2017 :  12:37:26 PM  Show Profile  Reply with Quote
While you are still seeing this problem, please go to the .cpp file, and the problem function implementation. If you show VA View, then place keyboard focus back into the editor, and now hover the mouse over the class name before the function name, is the correct information for this class displayed?

If VA knows about the class, and recognises that there is no declaration for this function, then I would expect the refactoring command to be offered, even if VA is not 100% up to date on changes to the header file.

A second check, can you please find the .h and .cpp files in Windows Explorer, and check both their modified and accessed date / time stamp in the file properties? I am wondering if for some strange reason the modified date / time stamp is not being updated when the file is updated by your source control system. I don't see why this should happen, but it might help to explain what is going on here.

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

MrT
Junior Member

United Kingdom
14 Posts

Posted - Dec 15 2017 :  05:01:40 AM  Show Profile  Reply with Quote
Hovering over the class for the following function:

void GameLog::writef(const char* p_cFormat, ...)

shows:

class GameLog

hovering over the function itself shows

void GameLog::writef(const char* p_cFormat,...)


The date accessed and date modified are both the same
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18724 Posts

Posted - Dec 15 2017 :  05:12:35 AM  Show Profile  Reply with Quote
Apologies, I was not clear in my description. With VA View showing, and keyboard focus in the editor, when you hover the mouse over a class that VA knows about, the bottom section of VA View should be updated with the class details, showing all of its members, and any base classes it inherits from. Since this information is coming from VA's symbol database, not from the current file, it might give us a clue as to what is happening, especially if the class members listed for GameLog are out of date.

Does the date accessed seem correct? Are you doing a source code update with the IDE open or closed? Or both?

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

MrT
Junior Member

United Kingdom
14 Posts

Posted - Dec 15 2017 :  06:58:08 AM  Show Profile  Reply with Quote
I had to reboot my PC as a process was hogging the sound card meaning I couldn't start the game I was working on, after rebooting and going through all the class files they all appear to be behaving correctly now.

It's probably about 2-3 weeks since a last rebooted my PC and I have only been working on this one project.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18724 Posts

Posted - Dec 15 2017 :  07:24:41 AM  Show Profile  Reply with Quote
Thank you for the update. At a wild guess, something was "blocking" VA from seeing the new updates to the files, so the header files were not quite up to date, but that still does not explain why the refactoring was not being offered in the cpp file.

That's very strange. Obviously if this comes back again please let me know. At least now we know to try looking into external processes that could be "locking" files in some sense, which is a clue of sorts.

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