Using structural substitution in IntelliJ to change the level of protection

I am trying to use the Structural Replace to mark all closed fields as warnings, and then suggest replacing them with protected fields. (I know that many people may not agree with my choice of protection levels, but this is a separate issue)

I have the following:

class $Class$ { @Modifier("private") $FieldType$ $FieldName$ = $Init$; } 

enter image description here

In the "Edit Variables ..." section, I have a "FieldName" for "This variable is a search object."

This correctly allocates variables marked as private. However, the replacement proposal is completely wrong:

enter image description here

How can I change my structural replacement options to suggest making field protection?

UPDATE

I changed the search / replace strings to the following, which work much better:

enter image description here

This allows me to replace field definitions such as private int foo=1 with protected int foo=1 . However, it does not work with private static final int foo=1 , which it replaces with protected int foo=1 Any suggestions?

+4
source share
2 answers

Removable modifiers appear to be an old mistake in structural search and replace. I sent an error report .

+1
source

You can be more successful with replacing regular expressions with grouping.

The SSR is exhaustive - it only works with really formed code segments ... maybe it does not support β€œstatic” as a substitute for wildcards?

0
source

Source: https://habr.com/ru/post/1401296/


All Articles