How rules sections work in intellij
Answered
Hello everyone,
I'm writing to you because after several internet searches I haven't found a precise answer.
I'm trying to understand how the rule section works in IntelliJ. I want to put all the "Predicate<T>" objects in one section so that they can be sorted differently, they all have the static and final modifiers but not the same visibility.
I've tried to do it with the "Name" parameter, but to no avail. I don't understand how it works, can I catch these properties by type or by name? If so, how can I do it? I haven't been able to get anything to work in these cases.
Thanks for your help.
Elio.
Please sign in to leave a comment.
Hello Elio M.. Do I understand correctly that you want to set up the Code Style Arrangement rules?

On my side, to collect several methods with a similar name in one section, I set up the section start and end as described here, and set up the matching rule according to this instruction. In the name field, you should place the regexp describing the method name. Please, see the example below:
To group all
f*methods in one section, I used thef.regexp. If the methods you want to group have a similar name pattern, you can use regexp to set up the matching rule.Hello Olga,
Yes, I'm trying to group properties together, but they don't have any naming rules, so this solution is impossible in my case. I wanted to know if it was possible to sort by Type for example or other, because by modifiers it could be complicated given that there are other final static properties that are not predicates and therefore must be sorted.
What's more, I've noticed that there's a marker that lets you cut the formatter on a defined section of code, but this doesn't block the arrangement, which is a pity because that's what I'd have liked.
Elio M., thank you for the clarification. Regrettably, there is no such option for now. I made a feature request in our YouTrack for you; please, consider upvoting it to receive updates and show your interest.
Is there a way to make: the Grouping rules to give priority to the Matching rules ?
Sure, I did a mistake, in previous comment.
Actually what I need is to add a new way of grouping methods:
"public methods first, then protected methods, and finally the private methods", something like:
If I understand it correctly, this can be done in arranging the order of the modifier in “Matching rules”. In my test below, the methods with the same modifier will be put together also respecting the modifier order(priority)