mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-05 08:06:56 +07:00
[java-core] Move JavaPreviewFeatureUtil to codeserver.core
Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only) GitOrigin-RevId: 79db63637514eef45284a8535d8fa8d9bad129f7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0e57ef0ef0
commit
9b9ed3498f
@@ -17,6 +17,5 @@
|
||||
<orderEntry type="module" module-name="intellij.java.frontback.psi" />
|
||||
<orderEntry type="module" module-name="intellij.java.psi" />
|
||||
<orderEntry type="module" module-name="intellij.java.psi.impl" />
|
||||
<orderEntry type="module" module-name="intellij.java.indexing" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,15 +1,16 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight.daemon.impl.analysis;
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.codeserver.core;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.java.codeserver.core.JavaPsiModuleUtil;
|
||||
import com.intellij.lang.jvm.JvmModifier;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.resolve.JavaResolveUtil;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static com.intellij.util.ObjectUtils.tryCast;
|
||||
import static java.util.Objects.requireNonNullElse;
|
||||
@@ -66,10 +67,6 @@ public final class JavaPreviewFeatureUtil {
|
||||
}
|
||||
return requireNonNullElse(name, ref.getText());
|
||||
}
|
||||
|
||||
public @Nls String description() {
|
||||
return JavaBundle.message("inspection.preview.feature.0.is.preview.api.message", targetName());
|
||||
}
|
||||
}
|
||||
|
||||
public static @Nullable PreviewFeatureUsage getPreviewFeatureUsage(@NotNull PsiElement e) {
|
||||
@@ -9,12 +9,13 @@
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="jetbrains-annotations" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.java.frontback.psi" />
|
||||
<orderEntry type="library" name="StreamEx" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util" />
|
||||
<orderEntry type="module" module-name="intellij.platform.projectModel" />
|
||||
<orderEntry type="module" module-name="intellij.java.frontback.psi" />
|
||||
<orderEntry type="module" module-name="intellij.java.psi" />
|
||||
<orderEntry type="module" module-name="intellij.java.psi.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.projectModel" />
|
||||
<orderEntry type="module" module-name="intellij.java.indexing" />
|
||||
<orderEntry type="library" name="StreamEx" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.java.codeserver.core" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,6 +1,7 @@
|
||||
insufficient.language.level={0} are not supported at language level ''{1}''
|
||||
illegal.unicode.escape=Illegal Unicode escape sequence
|
||||
illegal.character=Illegal character: {0}
|
||||
preview.api.usage={0} is a preview API and may be removed in a future release
|
||||
|
||||
annotation.not.allowed.here=Annotations are not allowed here
|
||||
annotation.not.applicable=''@{0}'' not applicable to {1}
|
||||
|
||||
@@ -4,6 +4,7 @@ package com.intellij.java.codeserver.highlighting.errors;
|
||||
import com.intellij.codeInsight.AnnotationTargetUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil;
|
||||
import com.intellij.core.JavaPsiBundle;
|
||||
import com.intellij.java.codeserver.core.JavaPreviewFeatureUtil;
|
||||
import com.intellij.java.codeserver.highlighting.JavaCompilationErrorBundle;
|
||||
import com.intellij.java.codeserver.highlighting.errors.JavaErrorKind.Parameterized;
|
||||
import com.intellij.java.codeserver.highlighting.errors.JavaErrorKind.Simple;
|
||||
@@ -67,6 +68,9 @@ public final class JavaErrorKinds {
|
||||
@NlsSafe String hex = String.format("U+%04X", (int)c);
|
||||
return message("illegal.character", printable ? c + " (" + hex + ")" : hex);
|
||||
});
|
||||
public static final Parameterized<PsiElement, JavaPreviewFeatureUtil.PreviewFeatureUsage> PREVIEW_API_USAGE =
|
||||
parameterized(PsiElement.class, JavaPreviewFeatureUtil.PreviewFeatureUsage.class, "preview.api.usage")
|
||||
.withRawDescription((e, c) -> message("preview.api.usage", c.targetName()));
|
||||
|
||||
public static final Simple<PsiAnnotation> ANNOTATION_NOT_ALLOWED_HERE = error("annotation.not.allowed.here");
|
||||
public static final Simple<PsiPackageStatement> ANNOTATION_NOT_ALLOWED_ON_PACKAGE =
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.codeInsight.daemon.impl.HighlightVisitor;
|
||||
import com.intellij.codeInsight.intention.CommonIntentionAction;
|
||||
import com.intellij.codeInsight.quickfix.UnresolvedReferenceQuickFixProvider;
|
||||
import com.intellij.codeInspection.ex.GlobalInspectionContextBase;
|
||||
import com.intellij.java.codeserver.core.JavaPreviewFeatureUtil;
|
||||
import com.intellij.java.codeserver.core.JavaPsiModuleUtil;
|
||||
import com.intellij.java.codeserver.highlighting.JavaErrorCollector;
|
||||
import com.intellij.java.codeserver.highlighting.errors.JavaCompilationError;
|
||||
@@ -559,7 +560,8 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
HighlightInfoType type = isReflective ? HighlightInfoType.WARNING : HighlightInfoType.ERROR;
|
||||
|
||||
HighlightInfo.Builder highlightInfo =
|
||||
HighlightUtil.checkFeature(element, usage.feature(), myLanguageLevel, element.getContainingFile(), usage.description(), type);
|
||||
HighlightUtil.checkFeature(element, usage.feature(), myLanguageLevel, element.getContainingFile(),
|
||||
PREVIEW_API_USAGE.description(element, usage).toString(), type);
|
||||
if (highlightInfo != null) {
|
||||
myErrorSink.accept(highlightInfo);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection.preview;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaPreviewFeatureUtil;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.java.codeserver.core.JavaPreviewFeatureUtil;
|
||||
import com.intellij.java.codeserver.highlighting.errors.JavaErrorKinds;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiImportStatementBase;
|
||||
@@ -37,7 +38,7 @@ public final class PreviewFeatureInspection extends LocalInspectionTool {
|
||||
element = nameElement;
|
||||
}
|
||||
}
|
||||
holder.registerProblem(element, usage.description());
|
||||
holder.registerProblem(element, JavaErrorKinds.PREVIEW_API_USAGE.description(element, usage).toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1764,7 +1764,6 @@ label.jvm.method.name=JVM method name
|
||||
label.jvm.field.name=JVM field name
|
||||
label.jvm.class.name=JVM class name
|
||||
link.configure.classes.excluded.from.completion=Configure classes excluded from completion
|
||||
inspection.preview.feature.0.is.preview.api.message={0} is a preview API and may be removed in a future release
|
||||
progress.title.detect.overridden.methods=Check overriding methods
|
||||
intention.name.iterate.over=Iterate over {0}
|
||||
advanced.settings.group.compiler=Compiler
|
||||
|
||||
@@ -15,5 +15,6 @@
|
||||
<orderEntry type="module" module-name="intellij.java" />
|
||||
<orderEntry type="module" module-name="intellij.java.execution.impl" />
|
||||
<orderEntry type="module" module-name="intellij.java.testFramework" />
|
||||
<orderEntry type="module" module-name="intellij.java.codeserver.core" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.intellij.jvm.analysis.internal.testFramework
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaPreviewFeatureUtil
|
||||
import com.intellij.java.codeserver.core.JavaPreviewFeatureUtil
|
||||
import com.intellij.jvm.analysis.internal.testFramework.JavaApiUsageGenerator.Companion.JDK_HOME
|
||||
import com.intellij.jvm.analysis.internal.testFramework.JavaApiUsageGenerator.Companion.LANGUAGE_LEVEL
|
||||
import com.intellij.jvm.analysis.internal.testFramework.JavaApiUsageGenerator.Companion.PREVIEW_JDK_HOME
|
||||
|
||||
Reference in New Issue
Block a user