Commit Graph

2 Commits

Author SHA1 Message Date
Nikita Eshkeev
fd24430a7d [preview] IDEA-259969 Reflective preview APIs are incorrectly reported as errors
This patch extracts PreviewFeatureVisitorBase to the top level class. In the visitor there used to be a special case for the new expression in order to reduce the number of warnings/errors, but it appeared to be useless, since the logic to deduce the preview feature element is too complicated. We might need to circle back to it if users complain about the number of warnings in their code.

GitOrigin-RevId: 3355caedc7eae3de197f652cc6af7ae605f64971
2021-02-12 18:36:52 +00:00
Nikita Eshkeev
735d4f05c1 [preview] IDEA-259969 Reflective preview APIs are incorrectly reported as errors
This patch adds the PreviewFeatureInspection inspection that is enabled only when the language level of the project is a preview one. It allows to register warnings and suppress all the preview warnings as it's done in javac. When the language level of the project is not a preview one, HighlightVisitorImpl runs the same visitor that can report errors instead of warnings. It cannot be suppressed.

A PSI element is considered a preview feature when either:
- it is annotated with PreviewFeature directly
- one of its enclosing classes is annotated with PreviewFeature
- its module is annotated with PreviewFeature
It's worth mentioning that when a package in package-info.java is annotated with PreviewFeature this flag doesn't get to be propagated to the classes that are inside the package.

Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>

GitOrigin-RevId: 5bd22ea2e18ba83303156a2b9665bc54622f6344
2021-02-11 00:50:54 +00:00