Files
openide/java/java-tests/testData/refactoring/extractMethod/StringTemplateExceptionJava21Preview.java
Bas Leijdekkers a4cb2b8f6f Java: fix extract method missing throws clause on string template and add test (IJ-CR-115108)
GitOrigin-RevId: 5fcbd8eb55a8f03f1db1ce67daa850964dae63a4
2023-09-21 14:33:12 +00:00

21 lines
592 B
Java

package java.lang;
public interface StringTemplate {
Processor<String, RuntimeException> STR = null;
@PreviewFeature(feature=PreviewFeature.Feature.STRING_TEMPLATES)
@FunctionalInterface
public interface Processor<R, E extends Throwable> {
R process(StringTemplate stringTemplate) throws E;
}
}
class Main {
class FailureException extends Exception {}
public static void x(StringTemplate.Processor<String, FailureException> p, int i, int j) {
try {
String t = <selection>p."\{i} + \{j} = \{i + j}";</selection>
}
catch (FailureException ignore) {}
}
}