mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
groovy create interface in interface's extends clause, more apt name
This commit is contained in:
@@ -167,6 +167,7 @@ import.what=Import ''{0}''
|
||||
import.class=Import Class
|
||||
create.class.family.name=Create Class
|
||||
create.class.text=Create Class ''{0}''
|
||||
create.interface.text=Create Interface ''{0}''
|
||||
dynamize.invalid.interface.text=Dynamize invalid interface instantiation
|
||||
dynamize.invalid.interface.family.name=Dynamize invalid code
|
||||
class.to.import.chooser.title=Choose class to import
|
||||
|
||||
+10
-1
@@ -33,6 +33,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.GroovyBundle;
|
||||
import org.jetbrains.plugins.groovy.actions.GroovyTemplatesFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrInterfaceDefinition;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
@@ -47,7 +50,8 @@ public abstract class CreateClassActionBase implements IntentionAction {
|
||||
|
||||
@NotNull
|
||||
public String getText() {
|
||||
return GroovyBundle.message("create.class.text", myRefElement.getReferenceName());
|
||||
String referenceName = myRefElement.getReferenceName();
|
||||
return shouldCreateInterface() ? GroovyBundle.message("create.interface.text", referenceName) : GroovyBundle.message("create.class.text", referenceName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -63,6 +67,11 @@ public abstract class CreateClassActionBase implements IntentionAction {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean shouldCreateInterface() {
|
||||
PsiElement parent = myRefElement.getParent();
|
||||
return parent instanceof GrImplementsClause || parent instanceof GrExtendsClause && parent.getParent() instanceof GrInterfaceDefinition;
|
||||
}
|
||||
|
||||
public static PsiClass createClassByType(final PsiDirectory directory,
|
||||
final String name,
|
||||
final PsiManager manager,
|
||||
|
||||
+1
-2
@@ -35,7 +35,6 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrMemberOwner;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.SupertypeConstraint;
|
||||
@@ -111,7 +110,7 @@ public abstract class CreateClassFix {
|
||||
PsiDirectory targetDirectory = getTargetDirectory(project, qualifier, name, module);
|
||||
if (targetDirectory == null) return;
|
||||
|
||||
String templateName = myRefElement.getParent() instanceof GrImplementsClause ? NewGroovyClassAction.GROOVY_INTERFACE : NewGroovyClassAction.GROOVY_CLASS;
|
||||
String templateName = shouldCreateInterface() ? NewGroovyClassAction.GROOVY_INTERFACE : NewGroovyClassAction.GROOVY_CLASS;
|
||||
PsiClass targetClass = createClassByType(targetDirectory, name, manager, myRefElement, templateName);
|
||||
if (targetClass != null) {
|
||||
addImportForClass(groovyFile, qualifier, targetClass);
|
||||
|
||||
Reference in New Issue
Block a user