IntelliJ sort enum members - sorting

Is there any way to sort the member variables of an enum alphabetically in IntelliJ? I've been trying a bunch of different settings in the arrangement section but didn't have success. Could anyone maybe help me?

Type Alt+Enter on an enum constant and invoke the sort content intention. This will sort the enum constants in alphabetical order. The intention will only appear if the constants are not alphabetically sorted.

Wasn't able to find the same action for AndroidStuido, instead, I used Menu -> Edit -> Sort Lines
Good thing is that it can be used for anything :)

Related

One sorter function for sort generic collections

In my project I have many collection (slices) of different data types. Any particular collection should define fields it can sort by. I want to write one sort function and call it with user input (sort field and order) whenever collection should be sorted. I came up with the following boilerplate code (described only one type of collection, but for others it will be the same): https://gist.github.com/abonec/f1ee23a38e78ea48d470c39885de47ba
I have an interface Sortable for collections. Sortable should be passed to the sortStats with user input of sort field. If concrete implementation supports this type of sort it should return sort.Interface with corresponding interface.
Problem with many repeated implementations of sort.Interface where Len() and Swap() method is identical. Different is only Less().
Is there any approach to get a rid of Len() and Swap() methods in this case or may be other approach to write generic sort function with dynamic sort field?
You're looking for generics, which Go doesn't currently support. See this FAQ entry.
The Go team is working to add generics to the language - it's a work in progress, and everyone is free to participate in the discussion. Once generics exist, they will provide the solution you seek here.
In the meantime, you could use code generation or think of a slightly different design for your problem. Some code duplication is OK too, Go doesn't frown upon it as badly as some other languages.

Maintaining the order of declaration in NamedDomainObjectContainer

Is there any way for me to maintain the order of declaration when iterating the items in NamedDomainObjectContainer?
As I understand right now NmaedDomainObjectContainer is using SortedSet as its implementation. I'm wondering if there is any LinkedHashSet version of it.
No, there is no way to maintain order of declaration.

Finding a Core Data entity's property values

I have a Core Data entity with four boolean non-optional properties, defaulted to NO. A class gets the entity object when the class is initialized, so this is not a result of an NSFetchResquest, and one of these four properties will be set to YES.
The class needs to know which property is YES.
Of course, I can use nested IF/Else statements (or ternaries) to find out which property is YES, but I'm wondering if there is a better (meaning more cocoa-ish) way to look at the entity and say 'is there a boolean value YES in your properties?'.
also, i can remodel to have the booleans have no value as default, and only look for the boolean that has YES, but that seems the same question.
Well there are several different possibilities. Using four different boolean properties is a clean solution. You then have to use the if ... elsif statements to find out what happened.
A more C way of doing that would be to define bitmasks which can be OR'ed together and stored as an NSUInteger. If this would semantically makes sense you could group them together in an enum, but that is the C way.
You could also define a custom subclass of NSManagedObject and write some convenience methods to check these options. Depends a bit on what they are good for.
You could use reflection (e.g., class_copyPropertyList and class_getProperty) to check what properties the class has, and examine their values, but that's a pretty heavy-handed approach when you already know which four properties are relevant. I wouldn't suggest this approach, and I wouldn't call it more Cocoa-ish, just more abstracted.
If you're looking at specific combinations of states, I think GorillaPatch's suggestion is right: You would turn those four booleans into a single 4-bit integer and compare it against bit masks representing the various combinations you're interested in.

Is it possible to search intellisense in vstudio?

Is it possible to search or filter intellisense in visual studio?
Basically i know there is an enum in the project that contains 'column', but the enum doesnt begin with 'c'.
There has been lots of times where id rather not scroll through the hundreds (if not thousands) of valid objects it gives me.
I wonder if the real answer here is (and I won't be surprised to be voted down for this) that your enum isn't properly named. If it was then I'd expect the name to be obvious in the use context, may be consider renaming the enum?
You can search in Class View. Type "column" and hit enter.
Visual Studio 2010 changes all of this, giving you multiple very easy ways to do this type of search quickly.
If you're using ReSharper, you can use "Go To Symbol..." and type "column", and it will give you all symbols (types, properties, fields, methods, etc) that match.
Otherwise your best bet is to use the Object Browser and search.
I really don't know about doing that in intellisense itself, but assuming the objective is to actually find a member whose name you don't remember, you can write a small utility for that purpose using the underlying mechanism intellisense uses, reflection.
Open the Object Browser under View menu. From there, you can search within all the language constructs available to you.

VS tool to find candidates for expressions

Are there any tools that augment/replace intellisense with a search of for expressions that will result in a given type?
I'm thinking of the case where I need to get some particular object and I known the type and will recognize the name but don't know what sequence of objects to jump thought to get to it. Such a tool would do a breadth first search of all options and list anything that has the correct type.
This is an old question, I know, but I'm giving it a shot in case you didn't find anything. Intellisense has the Resolve option (from at least Visual Studio 2005), with which you type your particular object straight, and then with right-clicking you can choose Resolve, which will add the library required to the list at the top of your class.
Similarly, ReSharper might have something fancier for you.

Resources