mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
Java: report void not allowed as embedded string template expression (IJ-CR-113878)
GitOrigin-RevId: 74934fab80465cf05acf28108c38d4c4c119fffa
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0aebe230e8
commit
049e116d27
@@ -948,6 +948,18 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
if (!myHolder.hasErrorResults()) add(HighlightUtil.checkUnhandledExceptions(expression));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTemplate(@NotNull PsiTemplate template) {
|
||||
super.visitTemplate(template);
|
||||
|
||||
for (PsiExpression embeddedExpression : template.getEmbeddedExpressions()) {
|
||||
if (PsiTypes.voidType().equals(embeddedExpression.getType())) {
|
||||
String message = JavaErrorBundle.message("expression.with.type.void.not.allowed.as.string.template.embedded.expression");
|
||||
add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(embeddedExpression).descriptionAndTooltip(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitFragment(@NotNull PsiFragment fragment) {
|
||||
super.visitFragment(fragment);
|
||||
|
||||
@@ -362,6 +362,7 @@ illegal.underscore=Illegal underscore
|
||||
text.block.new.line=Illegal text block start: missing new line after opening quotes
|
||||
text.block.unclosed=Unclosed text block
|
||||
processor.missing.from.string.template.expression=Processor missing from string template expression
|
||||
expression.with.type.void.not.allowed.as.string.template.embedded.expression=Expression with type 'void' not allowed as string template embedded expression
|
||||
|
||||
# suppress inspection "UnusedProperty"
|
||||
expected.identifier=Identifier expected
|
||||
|
||||
@@ -108,4 +108,9 @@ class X {
|
||||
public static void noNewlineAfterTextBlockOpeningQuotes() {
|
||||
System.out.println(STR.<error descr="Illegal text block start: missing new line after opening quotes">"""</error>\{}""");
|
||||
}
|
||||
|
||||
public static void voidExpression() {
|
||||
String a = STR."\{<error descr="Expression with type 'void' not allowed as string template embedded expression">voidExpression()</error>}";
|
||||
System.out.println(a);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user