Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/previewfeature/FieldsWithPreviewFeature.java
T
Nikita Eshkeev ef90c9f857 [codeInsight] IDEA-238740 Support the jdk.internal.PreviewFeature annotation
This patch fixes the problems according to the code review, it includes:

- moving extractHighlightingFeature to HighlightingFeature and renaming it to fromPreviewFeatureAnnotation
- assuring the PreviewFeature annotation name by calling PsiAnnotation#hasQualifiedName instead of comparing the name by equals
- moving JDK_INTERNAL_PREVIEW_FEATURE to HighlightingFeature
- extracting repeating part of checking the language level to HighlightUtil#checkPreviewFeatureElement
- adding a new case "SEALED_CLASSES" to HighlightFeature#fromPreviewAnnotationName

In addition to that there is also more robust solution to detect invalid contexts in references and static imports. The test data updated accordingly.

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

GitOrigin-RevId: 999d43ec5d9315d0881d08ce9341433707de96a0
2020-06-18 23:18:40 +03:00

23 lines
975 B
Java

import jdk.internal.PreviewFeature;
import jdk.internal.PreviewFeature.Feature;
class Main {
@PreviewFeature(feature=Feature.PATTERN_MATCHING_IN_INSTANCEOF)
static String instanceOf;
@PreviewFeature(feature=Feature.RECORDS)
static long records;
@PreviewFeature(feature=Feature.TEXT_BLOCKS)
String textBlocks;
int i;
<error descr="Patterns in 'instanceof' are not supported at language level '9'">org.myorg.preview.FromPreview</error> preview;
static {
String s = <error descr="Text block literals are not supported at language level '9'">new Main().textBlocks</error>;
String o = <error descr="Patterns in 'instanceof' are not supported at language level '9'">Main.instanceOf</error>;
long l = <error descr="Records are not supported at language level '9'">records</error>;
int k = new Main().i;
<error descr="Patterns in 'instanceof' are not supported at language level '9'">org.myorg.preview.FromPreview</error> local = null;
}
}