Search in sources :

Example 6 with GrEnumConstant

use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant in project intellij-community by JetBrains.

the class GrEnumConstantInfo method inferArgTypes.

@Nullable
@Override
protected PsiType[] inferArgTypes() {
    GrEnumConstant call = getCall();
    GrArgumentList argList = call.getArgumentList();
    if (argList != null) {
        return PsiUtil.getArgumentTypes(argList);
    } else {
        return PsiType.EMPTY_ARRAY;
    }
}
Also used : GrArgumentList(org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList) GrEnumConstant(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with GrEnumConstant

use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant in project intellij-community by JetBrains.

the class GrEnumConstantInitializerImpl method getBaseClass.

private PsiClass getBaseClass() {
    PsiElement parent = getParent();
    LOG.assertTrue(parent instanceof GrEnumConstant);
    PsiClass containingClass = ((GrEnumConstant) parent).getContainingClass();
    LOG.assertTrue(containingClass != null);
    return containingClass;
}
Also used : GrEnumConstant(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant) PsiClass(com.intellij.psi.PsiClass) PsiElement(com.intellij.psi.PsiElement)

Example 8 with GrEnumConstant

use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant in project intellij-community by JetBrains.

the class ClassGenerator method writeMembers.

public void writeMembers(StringBuilder text, PsiClass typeDefinition) {
    if (typeDefinition instanceof GrEnumTypeDefinition) {
        final GrEnumConstant[] enumConstants = ((GrEnumTypeDefinition) typeDefinition).getEnumConstants();
        for (GrEnumConstant constant : enumConstants) {
            classItemGenerator.writeEnumConstant(text, constant);
            text.append(',');
        }
        if (enumConstants.length > 0) {
            //text.removeFromTheEnd(1).append(";\n");
            text.delete(text.length() - 1, text.length());
        }
        text.append(";\n");
    }
    writeAllMethods(text, classItemGenerator.collectMethods(typeDefinition), typeDefinition);
    if (typeDefinition instanceof GrTypeDefinition) {
        for (GrMembersDeclaration declaration : ((GrTypeDefinition) typeDefinition).getMemberDeclarations()) {
            if (declaration instanceof GrVariableDeclaration) {
                classItemGenerator.writeVariableDeclarations(text, (GrVariableDeclaration) declaration);
            }
        }
        for (PsiClass inner : typeDefinition.getInnerClasses()) {
            writeTypeDefinition(text, inner, false, false);
            text.append('\n');
        }
    }
    classItemGenerator.writePostponed(text, typeDefinition);
}
Also used : GrVariableDeclaration(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration) GrEnumTypeDefinition(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumTypeDefinition) GrTypeDefinition(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition) GrMembersDeclaration(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration) GrEnumConstant(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant) PsiClass(com.intellij.psi.PsiClass)

Aggregations

GrEnumConstant (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant)8 NotNull (org.jetbrains.annotations.NotNull)3 GrVariableDeclaration (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration)3 GrArgumentList (org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList)3 GrTypeDefinition (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition)3 GrMethod (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod)3 PsiClass (com.intellij.psi.PsiClass)2 Nullable (org.jetbrains.annotations.Nullable)2 GroovyPsiElement (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement)2 GrListOrMap (org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap)2 GrVariable (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable)2 GrOpenBlock (org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock)2 GrExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression)2 GrSafeCastExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrSafeCastExpression)2 QueryExecutorBase (com.intellij.openapi.application.QueryExecutorBase)1 ReadActionProcessor (com.intellij.openapi.application.ReadActionProcessor)1 Key (com.intellij.openapi.util.Key)1 TextRange (com.intellij.openapi.util.TextRange)1 com.intellij.psi (com.intellij.psi)1 PsiElement (com.intellij.psi.PsiElement)1