mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
[java-intentions] IDEA-340601 allow creating methods in ImplicitClass
GitOrigin-RevId: 1e0cd613359f27e889df5cf03ce535c1a1a99ca7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5f0d1d84ae
commit
45b4e8e23c
@@ -1,5 +1,6 @@
|
||||
0.is.not.an.identifier=''{0}'' is not an identifier.
|
||||
annotation.name.is.missing=Annotation attribute must be of the form 'name=value'
|
||||
implicit.class.context.display=Implicit class
|
||||
anonymous.class.context.display=Anonymous in {0}
|
||||
anonymous.class.derived.display=Anonymous class derived from {0}
|
||||
aux.context.display=of {0}
|
||||
|
||||
@@ -135,7 +135,15 @@ private class JavaMethodRenderer(
|
||||
setupTypeElement(method.returnTypeElement, returnType)
|
||||
setupParameters(method, request.expectedParameters)
|
||||
}
|
||||
builder.setEndVariableAfter(method.body ?: method)
|
||||
if (method.containingClass?.rBrace == null) {
|
||||
val codeBlock = method.body
|
||||
if (codeBlock != null) {
|
||||
builder.setEndVariableBefore(codeBlock.lBrace ?: codeBlock)
|
||||
}
|
||||
}
|
||||
else {
|
||||
builder.setEndVariableAfter(method.body ?: method)
|
||||
}
|
||||
return builder
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ internal fun JvmModifier.toPsiModifier(): String = when (this) {
|
||||
* @return Java PsiClass or `null` if the receiver is not a Java PsiClass
|
||||
*/
|
||||
internal fun JvmClass.toJavaClassOrNull(): PsiClass? {
|
||||
if (this is PsiClassImpl || this is JspClass) {
|
||||
if (this is PsiClassImpl || this is JspClass || this is PsiImplicitClass) {
|
||||
// `is JspClass` check should be removed when JSP will define its own action factory,
|
||||
// since Java should know nothing about JSP.
|
||||
if ((this as PsiClass).language == JavaLanguage.INSTANCE) {
|
||||
|
||||
@@ -16,6 +16,13 @@ public final class ClassPresentationUtil {
|
||||
}
|
||||
|
||||
public static @Nls String getNameForClass(@NotNull PsiClass aClass, boolean qualified) {
|
||||
if (aClass instanceof PsiImplicitClass) {
|
||||
String name = aClass.getQualifiedName();
|
||||
if (name != null) {
|
||||
return name;
|
||||
}
|
||||
return JavaPsiBundle.message("implicit.class.context.display");
|
||||
}
|
||||
if (aClass instanceof PsiAnonymousClass) {
|
||||
if (aClass instanceof PsiEnumConstantInitializer) {
|
||||
PsiEnumConstant enumConstant = ((PsiEnumConstantInitializer)aClass).getEnumConstant();
|
||||
@@ -24,11 +31,10 @@ public final class ClassPresentationUtil {
|
||||
}
|
||||
return JavaPsiBundle.message("anonymous.class.context.display", getContextName(aClass, qualified, false));
|
||||
}
|
||||
if (qualified){
|
||||
if (qualified) {
|
||||
String qName = aClass.getQualifiedName();
|
||||
if (qName != null) return qName;
|
||||
}
|
||||
|
||||
String className = aClass.getName();
|
||||
String contextName = getContextName(aClass, qualified);
|
||||
return contextName != null ? JavaPsiBundle.message("class.context.display", className, contextName) : className;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Create method 'asd'" "true-preview"
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
asd("a", 1);
|
||||
}
|
||||
|
||||
private static void asd(String a, int i) {
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Create method 'asd'" "true-preview"
|
||||
|
||||
public void main(String[] args) {
|
||||
asd("a", 1);
|
||||
}
|
||||
|
||||
private void asd(String a, int i) {
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Create method 'asd'" "true-preview"
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
as<caret>d("a", 1);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Create method 'asd'" "true-preview"
|
||||
|
||||
public void main(String[] args) {
|
||||
a<caret>sd("a", 1);
|
||||
}
|
||||
Reference in New Issue
Block a user