Author |
Topic |
|
Mordachai
Tomato Guru
USA
224 Posts |
Posted - May 10 2018 : 10:41:32 AM
|
Commonly I'm finding myself using the `enum class` which requires the classname in order to specify any of its member enum values.
Often there is context which makes it obvious (to a human at least) what an unknown symbol should be from (i.e. when dealing with instances of a given enum, unknown symbols that match that enum's values are - um - that enum's values).
enum class State { Indeterminate, Open, Closed, };
bool IsOpen(State state);
void main() { State state = Open; <-- this would be nice if it could resolve Open and suggest / fill out as State::Open;
if (IsOpen(Closed)) <-- stupid example - but again, should be able to figure out and suggest as a possibility that this is State::Closed Beep(); }
Even less intelligently / more generally - unknown symbols that match things that require a scoping specifier should be something y'all can add as a suggestion / auto-completion / fix for an unknown symbol.
So even just typing Closed - well - what are the possible resolutions for such an unknown symbol? Please suggest those (State::Closed in this example).
Often the enum values are fairly unique - though not always.
`HeightDependsOnWidth` - this is an enum constant that literally has zero other matches in the solution - it can *only* be ItemFlags::HeightDependsOnWidth.
Other things like that too - constants in another scope - doesn't need to be just enums - names that are generally inaccessible and need a scoping qualifier - please suggest those when I look at a squiggly red underlined symbol. |
Edited by - Mordachai on May 10 2018 11:29:27 AM |
|
accord
Whole Tomato Software
United Kingdom
3287 Posts |
Posted - May 10 2018 : 10:53:37 PM
|
Do you have smart suggestions turned on?
You should get suggestions for enum class names as you type (after equality signs, in parameter lists, etc.)
It might not be the same as what you are asking for, but it can be fairly useful, in my experience. |
Edited by - accord on May 10 2018 10:54:43 PM |
|
|
Mordachai
Tomato Guru
USA
224 Posts |
Posted - May 11 2018 : 5:00:14 PM
|
Yep - that one is on for me as well.
I've never seen it suggest a missing context identifier - such as another namespace. I am seeing it work in the example you gave. However, I'm constantly not getting that desired behavior - so I'll grab a screenshot when it fails me next.
Thanks
|
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - May 12 2018 : 09:46:26 AM
|
Having just come from your thread where dot is not being converted to ->, I am starting to wonder if VA is having problems with something in your code files. If so, this might show up in several different ways. The trick will be to track down the root cause, so we can do something about it. So an example of where this fails reliably would be very useful. |
zen is the art of being at one with the two'ness |
|
|
Mordachai
Tomato Guru
USA
224 Posts |
Posted - May 14 2018 : 09:18:52 AM
|
Thanks feline. I'll post when I'm running into one of these issues and I can have more details we can try to sift through. |
|
|
Mordachai
Tomato Guru
USA
224 Posts |
Posted - May 16 2018 : 10:31:58 AM
|
Okay - so here is an example of what I mean, in a different context. This time, I've got an unknown symbol - but VA does know where it comes from, but there is no suggestion capability to fix it...
I would very much appreciate being able to add the Toolbox:: to the front from VA's suggestions or somehow have that appear in that error context...
and if the header is also needed in this context - then the suggestion to add that too... |
Edited by - Mordachai on May 16 2018 10:48:00 AM |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - May 16 2018 : 11:49:49 AM
|
In this situation, place the keyboard caret into the symbol name, and then press Alt-Shift-Q. This will show you a list of available refactoring commands from VA, probably just "Create From Usage" if this really is an unknown symbol.
Or right click the symbol and look at the "Quick Actions and Refactorings (VA)" sub-menu to see which commands are enabled here. This looks like a mouse hover tooltip, which is showing you what is known about this symbol, but not which commands are available here. |
zen is the art of being at one with the two'ness |
|
|
Mordachai
Tomato Guru
USA
224 Posts |
Posted - May 16 2018 : 1:07:19 PM
|
I clicked on the little tomato icon - but I couldn't capture that menu because holding ALT+ in order to get ALT+PRTSCR closes the context menu.
There was no such options - and you can see in my screenshot that the VA go-to indicator shows that it knows this code reference and would work. And I've tested, and it does - go to code jumps to the correct make_substring_container.
But the only thing that VA's refactor menu showed were things like "create from usage" and other unhelpful possibilities.
If you'd like to move this to support - out of features - feel free. I'll go looking for it there. ;) |
|
|
sean
Whole Tomato Software
USA
2817 Posts |
Posted - May 16 2018 : 1:47:53 PM
|
Is make_substring_container a free function inside of the Toolbox namespace?
If so, yeah your request makes sense -- restricted to: free functions from namespaces static methods from class/struct enum values from enum class
I think the word 'suggestion' tends to make us think of suggestion listboxes, but you want a Quick Fix type of suggestion. |
Edited by - sean on May 16 2018 1:50:26 PM |
|
|
sean
Whole Tomato Software
USA
2817 Posts |
Posted - May 16 2018 : 1:54:12 PM
|
VA tries to find unknown symbols in namespaces that have been recently used or have been accessed via a using statement -- that explains why the VA Nav Bar shows the information for make_substring_container you expected.
That logic is not in place for classes/structs or enum classes -- so it's unlikely the VA Nav Bar would be as helpful in similar but non-namespace instances. |
|
|
Mordachai
Tomato Guru
USA
224 Posts |
Posted - May 16 2018 : 2:51:34 PM
|
Sean - yes - that is a free function in namespace Toolbox.
And yes - "quick fix" is indeed what I mean. I just want to be able to fix an unknown reference - where VA does have the ability - it has parsed the needed info - but it is not making a suggestion (quick-fix?) at the point of need (the red squiggly underscored code).
If it did such a suggestion as I was typing - that would be fine too? I mean, if I had partially typed "make_subs" - and it suggested "Toolbox::make_substring_container" - that would be most delicious! |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - May 16 2018 : 3:45:01 PM
|
We are considering adding a refactoring command that would fully qualify the function name here, with the required namespace:
case=99537
I am a little wary of suggesting the namespace along with the function name in the listbox, just from the point of view of duplicate symbol names in different namespaces. |
zen is the art of being at one with the two'ness |
|
|
Mordachai
Tomato Guru
USA
224 Posts |
Posted - May 16 2018 : 4:27:34 PM
|
They'd have to be sorted by proximity - further away - not in current namespace, class, etc., further down the list of suggestions. I dunno if this is practical - but I'd be happy to test drive something if anyone wants feedback for it from someone who would use it constantly (I'm only driven here by some degree of desperation - it takes a fair bit of effort to post something like this - tho nothing compared to implementing it I'm sure) ;)
point being - if you want to say "this is how it works kind of but is a rough draft buggy - but we need to know if this is actually desirable in reality vs. on-paper - I'd be happy to be that test subject.
you could also leave the out-of-scope suggestions as an opt-in feature - so folks who do have tons of name collisions wouldn't see that non-local non-scoped suggestions at all...
|
|
|
accord
Whole Tomato Software
United Kingdom
3287 Posts |
Posted - May 17 2018 : 5:53:34 PM
|
I guess that the usefulness of a quick fix vs. suggestion listbox is really dependent on the situation. You can end up with something which needs to be fixed (e.g. after a copy-paste or typed-out symbol name, etc.) where a quick fix would be more useful, while other times making qualified items in the suggestion listbox could be more handy. But the quick-fix would work in every situation. If it's important to you, you can bind a keyboard shortcut to this quick fix, so you can just press that shortcut after you say accept the suggestion listbox. Also, I think it's easier to implement the quick fix vs. the suggestion listbox. |
|
|
Mordachai
Tomato Guru
USA
224 Posts |
Posted - May 18 2018 : 07:39:35 AM
|
Easy to implement is a great recommendation for any feature choice in my book!
Yes - if I put the slightly wrong thing in - and a quick-fix had the correction - I'd be quite tickled and satisfied. That's a work-flow that is still better than having to goto the symbol to figure out where it is from (what context am I missing), and then copy & come back and paste and add the :: and so on.
As I mentioned initially - I'm finding that I have to correct for namespace or class-namespace quite often now that we're using NS's and enum class's which mandate their use in a lot of contexts - yet VA knows the malformed symbol - so I would love for it to do the mechanical legwork of just allowing me to "fix it" - however that is most easily implemented by VA. :) |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - May 18 2018 : 08:47:05 AM
|
The quick fix route is probably the one that makes most sense, and it seems a logical extension of our current work on Code Inspection, so I have put a note onto the case about these thoughts.
For finding the correct namespace, etc, are you aware that if you select the symbol name in the editor and then press Alt-Shift-S to open VA's Find Symbol dialog the selected text will be used as the default filter? This makes it a bit quicker and easier to search for the symbol name, since this will then list the matching symbols, and you can hopefully quickly pick out the correct match, and thus the correct namespace / scope. |
zen is the art of being at one with the two'ness |
|
|
Mordachai
Tomato Guru
USA
224 Posts |
Posted - May 18 2018 : 10:16:36 AM
|
I've always just used the "go" interface at the top of the editor window - and then copy & paste the needed pieces. Which - since that knows - prompted me to post this request - it knows on some level - so nicer to have it at my fingertips in the first place!
But I'll try the ALT-SHIFT-S and see if I find that better... |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - May 18 2018 : 2:02:03 PM
|
That makes sense. One thing to watch for is that the definition field, the one on the right hand side, has a pull down arrow at the end. Sometimes, when VA identifies more than one possible match, you can see all of the matches by using the pull down list. Normally this would be overloaded functions, showing the different overloads.
Here, especially with your comment about the closest match first, it suggests that some of the time you will have several options to choose from. If this is the case, then the Find Symbol dialog may be easier for you.
Since VA does have the information then inserting the full name isn't to difficult. It's the edge cases you have to watch out for, as always |
zen is the art of being at one with the two'ness |
|
|
|
Topic |
|