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 from usage (and other options) not showing
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

MikMik
Senior Member

25 Posts

Posted - Nov 16 2021 :  06:17:30 AM  Show Profile  Reply with Quote
Hi,
I'm trying to use "Create from usage" but the option does not show when I press SHIFT+ALT+Q (VA Refactor context menu) and it is greyed out in the refactoring menu.

We have quite a big solution, with probably all kinds of issues (files "too long", with mixed tabs and spaces, mixed line endings, Unicode characters...), so it is not easy to create a minimal example. In fact, with newly created files it usually works (though not always).

I don't know if it is related, but there are other options missing too, like "Move Selection to new file".

Is there anything I can check to know why it is failing to show those options (and fix it)?
Thanks!

Edited by - MikMik on Nov 16 2021 06:22:43 AM

feline
Whole Tomato Software

United Kingdom
17503 Posts

Posted - Nov 16 2021 :  08:57:25 AM  Show Profile  Reply with Quote
Files to long should not be a normal problem you encounter. My large test file, for stress testing VA with a big file, is 23,000 lines long. Hopefully you don't have to many files in this size range and bigger.

VA should generally handle both mixed line endings and Unicode characters. Odd bugs do turn up, so it is good to know to watch for this. Mixed spaces and tabs should not matter at all.

Move Selection to new file may be having problems due to your other thread about Create File not working. So lets try to get Create File worked out first.

For create from usage, can you add the following very simple test function to the top of a file where you see the problem:

static void simpleVACreateTestCase()
{
	long* pTestLongPtr;
	// you should be able to trigger create from usage on "newGlobalVar4"
	newGlobalVar4 = pTestLongPtr;
}

testing at the top of the file helps to eliminate any "cascade" errors because something further up the file, sometimes even a #include statement, is confusing our parser.

Does this test case work correctly for you, or do you get the problem here?

If it works correctly here, can you please try moving the function to below a function where you are seeing problems with Create from Usage. Again just trying to get a sense of where and why you are having problems, so we can pin down the triggers and try to fix this.

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

MikMik
Senior Member

25 Posts

Posted - Nov 16 2021 :  11:19:31 AM  Show Profile  Reply with Quote
I'm getting mixed results here. I've been able to make "Create From Usage" work by closing Visual Studio and opening it again. Also, it seems to be working everywhere. It doesn't matter if the code is at the beginning, in the middle or at the end of the file... It even works inside the functions where it didn't before... However, it stops working at some point when I'm testing different positions in code, and I havent' been able to pinpoint when. It may be related to building the project/solution, or a matter of time (background parsing?)...
Go to Top of Page

MikMik
Senior Member

25 Posts

Posted - Nov 16 2021 :  11:32:37 AM  Show Profile  Reply with Quote
Here's a test I've done a few times and reproduces reliably in my setup:

Reopen Visual Studio so "Create From Usage" works.
Paste the snippet you passed me at the end of a file: create from usage shows
Move it around: it still shows

Build the project: the compilation fails, because I did not end up creating the variable, but Create from usage still shows

Delete the snippet

Build again

Paste the snippet again. Now create from usage doesn't appear
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17503 Posts

Posted - Nov 16 2021 :  11:57:54 AM  Show Profile  Reply with Quote
That is really unhelpful.

One surprise I ran into with the Create File bug thread is that white space, a single tab or space, is enough to stop the bug appearing! If you don't have:

IDE Edit menu -> Advanced -> View White Space

turned On then it will be very hard to notice this pattern. I don't know if that will help you or not though.

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

MikMik
Senior Member

25 Posts

Posted - Nov 17 2021 :  02:04:28 AM  Show Profile  Reply with Quote
I knew my steps to reproduce wouldn't be very helpful, because they don't seem to work in a toy example... But maybe they could point you in the right direction, or give you new ideas to try and test...
Anyway, I will keep trying it, and if I will report back if I find a reliable way to reproduce it. Create from usage" is, in my opinion, one of the top features of Visual Assist, and not being able to use it, is a bummer...
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17503 Posts

Posted - Nov 17 2021 :  07:30:05 AM  Show Profile  Reply with Quote
The fact that Create from Usage seems to stop working after a while suggests that something is confusing our parser.

Have you tried rebuilding VA's symbol database yet? This might help, or it might have no effect, but it should be a fairly fast test, unless you have a really massive solution. You can trigger this via:

VA Options -> Performance -> Rebuild symbol databases

and then restart the IDE.

Assuming this doesn't help, when Create from Usage stops working, can you please try using Alt+Up Arrow. This should take you to the top of the current scope. Does this take you to the correct location? If you use it again do you end up at the top of the current function, or somewhere else?

If you place the caret into known symbol names just before and above, and just after, where you are trying to use Create from Usage, what, if anything, is shown in VA's navigation bar? This is normally placed at the top of the editor window, and is where the Alt-M list appears from.

If Create from Usage isn't working then its likely that VA cannot work anything out. If that is happening then VA probably is having problems identifying symbols correctly. If we can prove this is happening it gives us something much more specific to study, and should help us to pin down what is going wrong and the limits of the problem. Hopefully this makes sense and you can see what I am thinking here.

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

MikMik
Senior Member

25 Posts

Posted - Nov 17 2021 :  07:49:02 AM  Show Profile  Reply with Quote
I had already rebuilt the database yesterday, but I've done it again. "Create from usage" has worked for a little while... I've pasted the snippet in a previous message in a few places, built the project... And suddenly it's stopped working...

Alt+Up and the navigation bar seem to be working just fine... The caret goes where it is supposed to, and the navigation bar updates with the correct context and definition for the symbols, as far as I can tell...
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17503 Posts

Posted - Nov 17 2021 :  12:11:34 PM  Show Profile  Reply with Quote
So create from usage is failing even with the very simple test function? I just want to make sure I understand correctly.

Does it still fail with this simple test function at the top of a cpp file?

I had guessed create from usage was failing since VA did not understand the type on the right hand sign of the =

but if even the very simple test case above is failing then this doesn't make much sense. If VA is this confused then you should be seeing problems with next and previous scope, VA Outline, Alt-M list, and just in general.

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

MikMik
Senior Member

25 Posts

Posted - Nov 18 2021 :  03:24:59 AM  Show Profile  Reply with Quote
Yes, you are exactly right. It is not working even with the simple snippet you provided, no matter where I put it. But all the options you mention seem to be working...

However, after my finding in my other thread about Create File that in some projects it works, I've tried Create From Usage in differen projects too, and I get the same result: it works in exe projects, but not in dll projects. I think something in the configuration (some path or something) must be messing up with VA...
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17503 Posts

Posted - Nov 18 2021 :  07:39:45 AM  Show Profile  Reply with Quote
Very unexpected. It sounds like the same root problem is triggering both bugs. Hopefully our study of this in the other thread will get us somewhere quickly.

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:
© 2021 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000