mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 05:21:29 +07:00
[java] IDEA-372997 Restrict sts template to only JDK 25 preview
GitOrigin-RevId: 40d0c8a18018eaf2d086af82f47298e83204dcec
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1de18cc8e6
commit
abfeff2bff
@@ -1195,6 +1195,8 @@
|
||||
implementation="com.intellij.codeInsight.template.JavaCodeContextType$JavaLangIOStatement"/>
|
||||
<liveTemplateContext contextId="JAVA_NORMAL_CLASS_DECLARATION_WITH_INSTANCE_MAIN" baseContextId="JAVA_CODE"
|
||||
implementation="com.intellij.codeInsight.template.JavaCodeContextType$NormalClassDeclarationAfterShortMainMethod"/>
|
||||
<liveTemplateContext contextId="JAVA_STATEMENT_WITH_STRUCTURED_CONCURRENCY_AVAILABLE_25" baseContextId="JAVA_CODE"
|
||||
implementation="com.intellij.codeInsight.template.JavaCodeContextType$Java25StructuredConcurrency" />
|
||||
<liveTemplateContext contextId="JAVA_COMMENT" baseContextId="JAVA_CODE"
|
||||
implementation="com.intellij.codeInsight.template.JavaCommentContextType"/>
|
||||
<liveTemplateContext contextId="JAVA_STRING" baseContextId="JAVA_CODE"
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -309,4 +310,19 @@ public abstract class JavaCodeContextType extends TemplateContextType {
|
||||
!implicitClassContext.isInContext(element);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Java25StructuredConcurrency extends JavaCodeContextType {
|
||||
private final JavaCodeContextType statementContext = new Statement();
|
||||
|
||||
Java25StructuredConcurrency() {
|
||||
super(JavaBundle.message("live.template.context.statement.java.structured.concurrency.25"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isInContext(@NotNull PsiElement element) {
|
||||
return statementContext.isInContext(element) &&
|
||||
PsiUtil.isAvailable(JavaFeature.STRUCTURED_CONCURRENCY, element) &&
|
||||
PsiUtil.getLanguageLevel(element).equals(LanguageLevel.JDK_25_PREVIEW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1322,6 +1322,7 @@ live.template.context.else='else' position
|
||||
live.template.context.expression=Expression
|
||||
live.template.context.declaration=Declaration
|
||||
live.template.context.statement.java.lang.io=Statement with available java.lang.IO
|
||||
live.template.context.statement.java.structured.concurrency.25=Statement with available Structured Concurrency (Java 25 / JEP 505)
|
||||
live.template.context.normal.class.before.instance.main.declaration=Declaration inside a normal class without instance 'main' method
|
||||
live.template.context.normal.class.after.instance.main.declaration=Declaration inside a normal class with instance 'main' method
|
||||
live.template.context.implicit.class.declaration=Declaration inside a compact source file
|
||||
|
||||
@@ -363,7 +363,7 @@
|
||||
resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.stss" toReformat="true" toShortenFQNames="true">
|
||||
<context>
|
||||
<option name="JAVA_CODE" value="false" />
|
||||
<option name="JAVA_STATEMENT" value="true" />
|
||||
<option name="JAVA_STATEMENT_WITH_STRUCTURED_CONCURRENCY_AVAILABLE_25" value="true" />
|
||||
</context>
|
||||
</template>
|
||||
</templateSet>
|
||||
|
||||
Reference in New Issue
Block a user