mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-117857 Add exception type variable to "Catch Statement Body" template
This commit is contained in:
@@ -258,12 +258,13 @@ public class JavaPsiImplementationHelperImpl extends JavaPsiImplementationHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupCatchBlock(String exceptionName, PsiElement context, PsiCatchSection catchSection) {
|
||||
public void setupCatchBlock(@NotNull String exceptionName, @NotNull PsiType exceptionType, PsiElement context, @NotNull PsiCatchSection catchSection) {
|
||||
final FileTemplate catchBodyTemplate = FileTemplateManager.getInstance().getCodeTemplate(JavaTemplateUtil.TEMPLATE_CATCH_BODY);
|
||||
LOG.assertTrue(catchBodyTemplate != null);
|
||||
|
||||
final Properties props = new Properties();
|
||||
props.setProperty(FileTemplate.ATTRIBUTE_EXCEPTION, exceptionName);
|
||||
props.setProperty(FileTemplate.ATTRIBUTE_EXCEPTION_TYPE, exceptionType.getCanonicalText());
|
||||
if (context != null && context.isPhysical()) {
|
||||
final PsiDirectory directory = context.getContainingFile().getContainingDirectory();
|
||||
if (directory != null) {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class CoreJavaPsiImplementationHelper extends JavaPsiImplementationHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupCatchBlock(String exceptionName, PsiElement context, PsiCatchSection element) {
|
||||
public void setupCatchBlock(@NotNull String exceptionName, @NotNull PsiType exceptionType, PsiElement context, @NotNull PsiCatchSection element) {
|
||||
throw new UnsupportedOperationException("TODO");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,5 +50,6 @@ public abstract class JavaPsiImplementationHelper {
|
||||
@Nullable
|
||||
public abstract PsiElement getDefaultMemberAnchor(@NotNull PsiClass psiClass, @NotNull PsiMember firstPsi);
|
||||
|
||||
public abstract void setupCatchBlock(String exceptionName, PsiElement context, PsiCatchSection element);
|
||||
public abstract void setupCatchBlock(@NotNull String exceptionName, @NotNull PsiType exceptionType,
|
||||
@Nullable PsiElement context, @NotNull PsiCatchSection element);
|
||||
}
|
||||
|
||||
@@ -748,7 +748,7 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
|
||||
|
||||
final Project project = myManager.getProject();
|
||||
final JavaPsiImplementationHelper helper = JavaPsiImplementationHelper.getInstance(project);
|
||||
helper.setupCatchBlock(exceptionName, context, (PsiCatchSection)element);
|
||||
helper.setupCatchBlock(exceptionName, exceptionType, context, (PsiCatchSection)element);
|
||||
final CodeStyleManager styleManager = CodeStyleManager.getInstance(project);
|
||||
final PsiCatchSection catchSection = (PsiCatchSection)styleManager.reformat(element);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ public interface FileTemplate extends Cloneable {
|
||||
FileTemplate[] EMPTY_ARRAY = new FileTemplate[0];
|
||||
|
||||
String ATTRIBUTE_EXCEPTION = "EXCEPTION";
|
||||
String ATTRIBUTE_EXCEPTION_TYPE = "EXCEPTION_TYPE";
|
||||
String ATTRIBUTE_DESCRIPTION = "DESCRIPTION";
|
||||
String ATTRIBUTE_DISPLAY_NAME = "DISPLAY_NAME";
|
||||
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
<td width="10"> </td>
|
||||
<td valign="top"><font face="verdana" size="-1">name of the <b>Exception</b> variable specified as a <b>catch</b> parameter</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><nobr><font face="verdana" size="-2" ><b>${EXCEPTION_TYPE}</b></font></nobr></td>
|
||||
<td width="10"> </td>
|
||||
<td valign="top"><font face="verdana" size="-1">type of the <b>catch</b> parameter</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user