[codeInsight] IDEA-238740 Support the jdk.internal.PreviewFeature annotation

This patch fixes the problems according to the code review, it includes:

- inlining the trivial wrapper methods checkConstructorPreviewFeature, checkMethodCallPreviewFeatureAnnotation, checkTypePreviewFeatureAnnotation
- applying ObjectUtils#tryCast in HighlightUtil#checkPackagePreviewFeatureAnnotation
- simplifying HighlightVisitorImpl#visitImportStaticStatement by calling directly HighlightUtil#checkPreviewFeatureElement
- generalizing HighlightVisitorImpl#visitReferenceExpression's check if the element is annotated with PreviewFeature

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

GitOrigin-RevId: 954ad1bbb26352d7d98581b3ad95a360569b0636
This commit is contained in:
Nikita Eshkeev
2020-06-19 14:20:28 +03:00
committed by intellij-monorepo-bot
parent 547ebddae3
commit 5e222f56a9
7 changed files with 30 additions and 56 deletions
@@ -3,9 +3,9 @@ import jdk.internal.PreviewFeature.Feature;
class Main {
static {
<error descr="Patterns in 'instanceof' are not supported at language level '9'">requirePatternMatching()</error>;
<error descr="Text block literals are not supported at language level '9'">Main.requireTextBlocks()</error>;
<error descr="Records are not supported at language level '9'">new Main().requireRecords()</error>;
<error descr="Patterns in 'instanceof' are not supported at language level '9'">requirePatternMatching</error>();
<error descr="Text block literals are not supported at language level '9'">Main.requireTextBlocks</error>();
<error descr="Records are not supported at language level '9'">new Main().requireRecords</error>();
}
@PreviewFeature(feature=Feature.PATTERN_MATCHING_IN_INSTANCEOF)
@@ -1,9 +1,10 @@
<error descr="Patterns in 'instanceof' are not supported at language level '9'">import org.myorg.preview.FromPreview;</error>
<error descr="Patterns in 'instanceof' are not supported at language level '9'">import static org.myorg.preview.FromPreview.f;</error>
<error descr="Patterns in 'instanceof' are not supported at language level '9'">import static org.myorg.preview.FromPreview.*;</error>
class Main {
static {
<error descr="Patterns in 'instanceof' are not supported at language level '9'">org.myorg.preview.FromPreview</error>.f();
<error descr="Patterns in 'instanceof' are not supported at language level '9'">f()</error>;
<error descr="Patterns in 'instanceof' are not supported at language level '9'">f</error>();
}
}