mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
provide PLAIN_CALL_SUPER variable to ease custom template creation
This commit is contained in:
@@ -301,8 +301,13 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
|
||||
|
||||
@NotNull
|
||||
public static String callSuper(PsiMethod superMethod, PsiMethod overriding) {
|
||||
return callSuper(superMethod, overriding, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String callSuper(PsiMethod superMethod, PsiMethod overriding, boolean prependReturn) {
|
||||
@NonNls StringBuilder buffer = new StringBuilder();
|
||||
if (!superMethod.isConstructor() && !PsiType.VOID.equals(superMethod.getReturnType())) {
|
||||
if (prependReturn && !superMethod.isConstructor() && !PsiType.VOID.equals(superMethod.getReturnType())) {
|
||||
buffer.append("return ");
|
||||
}
|
||||
buffer.append("super");
|
||||
@@ -350,6 +355,7 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
|
||||
properties.setProperty(FileTemplate.ATTRIBUTE_RETURN_TYPE, returnType.getPresentableText());
|
||||
properties.setProperty(FileTemplate.ATTRIBUTE_DEFAULT_RETURN_VALUE, PsiTypesUtil.getDefaultValueOfType(returnType));
|
||||
properties.setProperty(FileTemplate.ATTRIBUTE_CALL_SUPER, callSuper(originalMethod, result));
|
||||
properties.setProperty(FileTemplate.ATTRIBUTE_PLAIN_CALL_SUPER, callSuper(originalMethod, result, false));
|
||||
JavaTemplateUtil.setClassAndMethodNameProperties(properties, targetClass, result);
|
||||
|
||||
JVMElementFactory factory = JVMElementFactories.getFactory(targetClass.getLanguage(), originalMethod.getProject());
|
||||
|
||||
@@ -42,6 +42,7 @@ public interface FileTemplate extends Cloneable {
|
||||
String ATTRIBUTE_RETURN_TYPE = "RETURN_TYPE";
|
||||
String ATTRIBUTE_DEFAULT_RETURN_VALUE = "DEFAULT_RETURN_VALUE";
|
||||
String ATTRIBUTE_CALL_SUPER = "CALL_SUPER";
|
||||
String ATTRIBUTE_PLAIN_CALL_SUPER = "PLAIN_CALL_SUPER";
|
||||
|
||||
String ATTRIBUTE_CLASS_NAME = "CLASS_NAME";
|
||||
String ATTRIBUTE_SIMPLE_CLASS_NAME = "SIMPLE_CLASS_NAME";
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
for other methods - <code><b>return</b> <b>super</b>.<i>method_name</i>();</code> with or without parameters
|
||||
</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><nobr><font face="verdana" size="-2"><b>${PLAIN_CALL_SUPER}</b></font></nobr></td>
|
||||
<td width="10"> </td>
|
||||
<td width="100%" valign="top"><font face="verdana" size="-1">a super method call, <code><b>super</b>.<i>method_name</i>();</code> with or without parameters;
|
||||
</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><nobr><font face="verdana" size="-2"><b>${RETURN_TYPE}</b></font></nobr></td>
|
||||
<td width="10"> </td>
|
||||
|
||||
Reference in New Issue
Block a user