Type migration issue

已回答

Migrating type annotated as NotNull(javax.validation.constraints.NotNull) the default type to migrate to looks too odd. Removing all and typing new type NotNull goes away. 


If you leave the annotation and change the type then the annotation will appear in all places where this type was used. 

Also, annotations can be many.


Most likely the problem is here https://github.com/JetBrains/intellij-community/blob/master/java/java-impl/src/com/intellij/refactoring/typeMigration/ui/TypeMigrationDialog.java#L146 

Why it's done?

0

The last version of `javax.validation.constraints.NotNull` is applicable for type use, this means that it belongs to the type declaration and can be migrated together.

0

Thanks for answer!

Indeed, javax.validation.constraints.NotNull annotation applies to both FIELD and TYPE_USE. I see several inconveniences:

1. Inconvenient to change the FQN type, it is broken anotations. {target_type_package_name}.[type_use_annotations].{target_type_class_name}

2. After type migration, annotations change their location. 
Before:

@NotNull
protected String extra;

After:

protected @NotNull Integer extra;

I need to change the type without annotations. Can you add the ability to programmatically change this behavior?

I use a TypeMigrationDialog like this:

TypeMigrationDialog dialog = new TypeMigrationDialog.SingleElement(project, psiElements);
dialog.show();
0

请先登录再写评论。