mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
IDEA-140043 Predefined Variables in Code Template "Catch Statement Body" not available
This commit is contained in:
@@ -269,7 +269,7 @@ public class JavaPsiImplementationHelperImpl extends JavaPsiImplementationHelper
|
||||
final FileTemplate catchBodyTemplate = FileTemplateManager.getInstance(catchSection.getProject()).getCodeTemplate(JavaTemplateUtil.TEMPLATE_CATCH_BODY);
|
||||
LOG.assertTrue(catchBodyTemplate != null);
|
||||
|
||||
final Properties props = new Properties();
|
||||
Properties props = FileTemplateManager.getInstance(myProject).getDefaultProperties();
|
||||
props.setProperty(FileTemplate.ATTRIBUTE_EXCEPTION, exceptionName);
|
||||
props.setProperty(FileTemplate.ATTRIBUTE_EXCEPTION_TYPE, exceptionType.getCanonicalText());
|
||||
if (context != null && context.isPhysical()) {
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class Test {
|
||||
|
||||
public static void main(String[] args){
|
||||
<selection>I i = ExceptionTest::foo;</selection>
|
||||
}
|
||||
|
||||
class Ex extends Exception {}
|
||||
|
||||
static void foo() throws Ex {}
|
||||
|
||||
interface I {
|
||||
void f();
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
class Test {
|
||||
|
||||
public static void main(String[] args){
|
||||
try {
|
||||
I i = ExceptionTest::foo;
|
||||
} catch (Exception e) {
|
||||
// $
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
class Ex extends Exception {}
|
||||
|
||||
static void foo() throws Ex {}
|
||||
|
||||
interface I {
|
||||
void f();
|
||||
}
|
||||
}
|
||||
+16
@@ -17,6 +17,9 @@ package com.intellij.codeInsight.generation.surroundWith;
|
||||
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager;
|
||||
import com.intellij.ide.fileTemplates.JavaTemplateUtil;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.lang.LanguageSurrounders;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
@@ -174,6 +177,19 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
|
||||
doTest(new JavaWithTryCatchSurrounder());
|
||||
}
|
||||
|
||||
public void testSurroundWithTryCatchProperties() {
|
||||
FileTemplate template = FileTemplateManager.getInstance(getProject()).getCodeTemplate(JavaTemplateUtil.TEMPLATE_CATCH_BODY);
|
||||
String old = template.getText();
|
||||
template.setText("// ${DS} \n" +
|
||||
"${EXCEPTION}.printStackTrace();");
|
||||
try {
|
||||
doTest(new JavaWithTryCatchSurrounder());
|
||||
}
|
||||
finally {
|
||||
template.setText(old);
|
||||
}
|
||||
}
|
||||
|
||||
public void testSurroundIfBranchWithNoBracesAndComment() {
|
||||
doTest(new JavaWithBlockSurrounder());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user