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
 auto keyword support (UE4)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Amimoller
New Member

Denmark
9 Posts

Posted - Dec 15 2020 :  3:27:52 PM  Show Profile  Reply with Quote
Hi,
We are using vs2019 and Unreal (4.25)

For as long as i can remember, using the auto keyword has messed up VA. Both auto completion and "convert . to ->"

Here is a common example of getting a component.



When you type . it does not get converted to ->

if you change the code to be "auto* health" convertion works as normal, but the listbox will not adhere to "List non-inherited entries first"

Both issues makes the use of auto problematic as it slows down your workflow.

Getting this fixed would be great :)
Cheers!

Edited by - Amimoller on Dec 15 2020 3:28:22 PM

feline
Whole Tomato Software

United Kingdom
17095 Posts

Posted - Dec 16 2020 :  06:42:47 AM  Show Profile  Reply with Quote
I am definitely seeing some problems with auto and "FindComponentByClass" here. Do you only see this problem with template functions, or more generally?

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

feline
Whole Tomato Software

United Kingdom
17095 Posts

Posted - Dec 16 2020 :  12:42:46 PM  Show Profile  Reply with Quote
I am still looking, since something odd is going on here, but I have discovered a partial work around, if you are interested. Consider the very simple code example:

ACharacter *simpleCharacter;
auto autoLocal = simpleCharacter->FindComponentByClass<ULightComponentBase>();
autoLocal; // bug seen on this line

go to where the variable "autoLocal" is declared, place the caret into this variable name, and trigger the VA refactoring command "Introduce Variable". You will be prompted for a new variable name, I used "tempByClass" and VA turns this into the code:

ACharacter *simpleCharacter;
ULightComponentBase* tempByClass = simpleCharacter->FindComponentByClass<ULightComponentBase>();
auto autoLocal = tempByClass;
autoLocal; // variable now handled correctly

so you get VA to add the inbetween line that lets VA correctly understand the auto variable. This does make the auto variable redundant, but since you are just adding in a "clearer" definition of the auto variable, the following code that uses the auto variable remains unchanged.

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

feline
Whole Tomato Software

United Kingdom
17095 Posts

Posted - Dec 16 2020 :  1:23:23 PM  Show Profile  Reply with Quote
I have put in a bug report for auto not working out the return type of FindComponentByClass<>()

case=144217

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

feline
Whole Tomato Software

United Kingdom
17095 Posts

Posted - Dec 16 2020 :  1:58:15 PM  Show Profile  Reply with Quote
So far I cannot reproduce the second problem, "List non-inherited entries first".

Either I cannot get a listbox to appear on the auto variable, or when using a temporary variable to "fix" the auto variable then the order of the items in the listbox works correctly for me.

Can you please turn On:

VA Options -> Floating Buttons and Icons -> Denote content from Visual Assist with tomato icons

and see if you get any tomato icons in the listbox when you get this listbox that isn't ordered correctly? I am wondering if the listbox is coming from the IDE instead of from VA, but that still doesn't explain the lack of ordering.

Does the "List non-inherited entries first" work in other listboxes for you?

If you turn On:

VA Options -> Enhanced Listboxes -> Bold non-inherited members

are you seeing any bold entries in the listbox?

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

Amimoller
New Member

Denmark
9 Posts

Posted - Dec 16 2020 :  2:49:00 PM  Show Profile  Reply with Quote
So i tried again, the options you mention where already turned on.

for the case
auto* component = FindComponent...
The listbox items do not have the tomatoe icon and probably come from intellisense

I tried another common case which is Cast<>
auto component = Cast<USomeComponent>(Component);
Here . to -> doesnt work, not even with auto*
But here it does show the correct listbox.



If i manually type -> then it uses the Intellisense suggestions.
Weird that its not the same as FindComponent.
Ill try some more cases, but i have yet to find any use of auto that seems to work correctly.

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17095 Posts

Posted - Dec 17 2020 :  09:34:09 AM  Show Profile  Reply with Quote
In general VA's auto handing should work well, but VA can struggle with template code, since templates are instanciated at compile time, and VA does not get to compile the code. Currently auto does not correctly work out the return type from template functions, which is an open bug report. It's possible the same bug is showing up here.

casting should work correctly, but "Cast" is an unreal engine specific function, and is thus different to "normal" casts.

One place auto does work well in my experience is STL style iterators, which tend to have very long types to write out manually. But I don't know how much of this you will be doing in Unreal Engine.

If you place the caret into "Cast" what are you seeing in VA's context and definition fields? For the simple test code:

ACharacter *simpleCharacter;
APawn* pBaseClass = simpleCharacter;
auto characterCast = Cast<ACharacter>(pBaseClass);

I am seeing:

context field = ACharacter
definition field = class ENGINE_API ACharacter : public APawn{...}

which is not right.

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

Amimoller
New Member

Denmark
9 Posts

Posted - Dec 18 2020 :  03:49:06 AM  Show Profile  Reply with Quote
You are right, it does seem to work pretty well on non-template code. I guess the problem is that most of the places we want to use it in Unreal is templated functions. Mostly Cast and FindComponent and its variations.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
17095 Posts

Posted - Dec 18 2020 :  2:47:03 PM  Show Profile  Reply with Quote
There is something inside Unreal Engine that is confusing our parser with Cast, but so far I cannot find any clues as to what it is. I have put a bug report in for this:

case=144225

if you set up a simple test for the Cast function outside of Unreal Engine then VA handles it correctly, and dot is converted to -> when using it with auto.

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