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
 Feature Requests
 == enum
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sitnduck
Senior Member

45 Posts

Posted - Jan 18 2007 :  12:53:52 PM  Show Profile  Reply with Quote
Hi!
It would be great if whenever == is typed against en "enum" variable (or in a SWITCH statement, etc), we could autocomplete with the members of the enum.

Did that make sense??! :)

Thank you so much for a great product!!!

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Jan 18 2007 :  2:14:58 PM  Show Profile  Reply with Quote
Doing something line this for "=" or "==" on an enum variable is an interesting idea, but I am a little wary about doing it on a switch statement, given some of the code examples I have seen here.

If you are referencing the enum via a class or namespace are you aware you can filter the completion listbox to only show enum items?

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

sitnduck
Senior Member

45 Posts

Posted - Jan 18 2007 :  2:33:07 PM  Show Profile  Reply with Quote
Yes thank you, I am using it with namespace, but use it w/o namespaces quite a bit... :)

For "switch" I meant the "case" statements if that helps...
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Jan 19 2007 :  07:12:22 AM  Show Profile  Reply with Quote
I have put in a feature request for this, but it is unlikely to be something we will try any time soon.

case=4622

personally I always used to type the enum name, which would then produce a list of the enum value's. This is how it works in C#, but for some reason the C++ specification suggests you should not do this, and VS2005 produces a warning *sigh*

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

lac
Senior Member

30 Posts

Posted - Jun 25 2010 :  06:27:04 AM  Show Profile  Reply with Quote
Better completion on enum qualifiers and members is something I sorely miss in VAX; both in expressions and case statements. For example, this is very common for me:
namespace Foo {
  class Bar {
  public:
    enum Baz {
      BAZ_RED, BAZ_GREEN, BAZ_BLUE
    };
  };
};

It's very tedious to type out the qualifier and enum prefix. VAX is not much help... it doesn't suggest anything relevant after the 'case' keyword or after comparison operators with the enum type.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Jun 29 2010 :  12:12:40 PM  Show Profile  Reply with Quote
I am getting VA suggestions for the enum on its own, and the enum inside the class, but not when the class is inside the namespace. I have put in a feature request for this situation:

case=46540

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

sean
Whole Tomato Software

USA
2817 Posts

Posted - Jul 01 2010 :  6:40:30 PM  Show Profile  Reply with Quote
@lac: given that namespace/class/enum defintion, can you please give an example where you are seeing this problem most? That is, are you using the enums in global functions, free functions in namespace Foo or methods in class Bar?
Go to Top of Page

lac
Senior Member

30 Posts

Posted - Jul 02 2010 :  02:26:29 AM  Show Profile  Reply with Quote
Due to the API I'm currently using, its 100% from outside the namespace (The API even has nested namespaces, e.g. Ns1::Ns2::Ns3::Class1::Enum). I use 'using namespace' statements to reduce the amount of qualifiers needed, but the class qualifier is still required. However, in headers and some source files, the full namespace qualifiers are required.

The QT API is good example of this style. It has everything wrapped in the 'Qt' namespace, and commonly has public enum types inside classes, e.g. QFrame::Shape.

Since any enum type may require a scope qualifier to access its members, and the required qualifier is given from the context (considering 'using namespace' statements would be extra cool).

Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Jul 02 2010 :  11:02:47 AM  Show Profile  Reply with Quote
Thanks for the followup.
Go to Top of Page

lac
Senior Member

30 Posts

Posted - Dec 22 2011 :  04:30:11 AM  Show Profile  Reply with Quote
Completion on enum values with their scoping namespace & class, where they are expected, is a feature I sorely miss on a daily basis. Any chance for this feature?

I seems like VAX is already aware of the enum type, as it suggests the enum values, but it never suggests the *required* scope of the enum value (namespace and/or class name(s)). Shouldn't be too hard to fix?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Dec 24 2011 :  7:50:27 PM  Show Profile  Reply with Quote
Which version of VA are you using?

case=46540

is marked as being fixed in VA 1837, apologies for this thread not being updated to mark this as fixed, it must have been overlooked.

Using VS2010 and VA 1862 I have set up the following C++ test, to try and emulate the problem you are seeing with Qt and the enum inside the Shape class. I have this code in a header file:

namespace QtFelineVA
{
	class QFelineVaShape
	{
	public:
		enum Shape { SQUARE, TRIANGLE, CIRCLE };
		Shape m_shape;
		Shape getShape() const			{ return m_shape; }
		void setShape(Shape newShape)	{ m_shape = newShape; }
	};
}


and this code in the matching cpp file:

using namespace QtFelineVA;

static void testQtLikeEnum()
{
	QFelineVaShape shapeTest;
	// type " = " or " == " at the end of these two lines
	// one of the VA suggestions is always "QFelineVaShape::Shape" for me
	shapeTest.m_shape;
	shapeTest.getShape();
	// type SPACE inside the round brackets on this line
	// one of the VA suggestions is always "QFelineVaShape::Shape" for me
	shapeTest.setShape();
}

Not a very clever example, but it shows that VA is trying to do something helpful in these situations. Are you seeing something similar on your system?

As a sanity check, to make sure I have not overlooked something obvious, if I accept the suggestion "QFelineVaShape::Shape" and add an actual enum item to each of these three lines, the resulting code compiles quite happily for me.

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

lac
Senior Member

30 Posts

Posted - Feb 24 2012 :  03:38:12 AM  Show Profile  Reply with Quote
Thanks for the reply. I am currently using 1849, and I can see that what you say does work, i.e. completion on the enum name. It's still not quite as elegant and convenient as I perhaps naively thought it could be.

1. Unqualified completion is still available, but is meaningless. If I press S in your example, I get the option to complete on "SQUARE", which is great, except that the _required_ scope qualifier (QFelineVaShape::) is not inserted, hence the resulting completion does not compile.

2. If I complete on "QFelineVaShape::Shape" as in your example, I can continue adding "::" and then complete on the enum members. However, using the enum name as a scope qualifier is not permitted by the C++ standard and is really only an extension implemented by some compilers (our code, while developed in Visual Studio, are required to be portable).

3. If I add

switch (shapeTest.m_shape)
{
case
}

and press SPACE after 'case', I don't get any completion suggestions at all.

4. If I add

if (shapeTest.m_shape == )

and press space before the ')', I get the same invalid completions as in (1) and (2).

My wishes:

a) Automatically insert the required scope qualifier (or make it a part of the completion), when you type in "SQ" and chose "SQUARE".

b) I'd love to have a two-staged completion, where you first select "QFelineVaShape::" with "Shape" as the indicated target enum. Then "QFelineVaShape::" should be inserted, and a new completion on only the Shape enum members pops up. Currently all members are listed, which is OK for the general case.

c) Make it work in case statements also :-)
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Feb 28 2012 :  11:09:37 PM  Show Profile  Reply with Quote
Sorry for the slow reply. You make some good points here, and the scoped suggestions not working in the switch case here is definitely a bug. I have put a single bug report in for all of this, since it all appears to be connected:

case=65011

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

support
Whole Tomato Software

5566 Posts

Posted - Apr 11 2012 :  12:43:35 AM  Show Profile  Reply with Quote
case=65011 is fixed in build 1903
Go to Top of Page

lac
Senior Member

30 Posts

Posted - Apr 18 2012 :  08:55:01 AM  Show Profile  Reply with Quote
Fantastic! Works great so far
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Apr 18 2012 :  5:20:06 PM  Show Profile  Reply with Quote
Thank you for the update, it is good to know this is working well for you

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