use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumConstantInitializer in project intellij-community by JetBrains.
the class StubGenerator method writeEnumConstant.
@Override
public void writeEnumConstant(StringBuilder text, GrEnumConstant enumConstant) {
text.append(enumConstant.getName());
PsiMethod constructor = enumConstant.resolveMethod();
if (constructor != null) {
text.append('(');
writeStubConstructorInvocation(text, constructor, PsiSubstitutor.EMPTY, enumConstant);
text.append(')');
}
GrEnumConstantInitializer initializer = enumConstant.getInitializingClass();
if (initializer != null) {
text.append("{\n");
for (PsiMethod method : initializer.getMethods()) {
writeMethod(text, method);
}
text.append('}');
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumConstantInitializer in project intellij-community by JetBrains.
the class ClassItemGeneratorImpl method writeEnumConstant.
@Override
public void writeEnumConstant(StringBuilder builder, GrEnumConstant constant) {
GenerationUtil.writeDocComment(builder, constant, false);
builder.append(constant.getName());
final GrArgumentList argumentList = constant.getArgumentList();
if (argumentList != null) {
final GroovyResolveResult resolveResult = constant.advancedResolve();
GrClosureSignature signature = GrClosureSignatureUtil.createSignature(resolveResult);
new ArgumentListGenerator(builder, context.extend()).generate(signature, argumentList.getExpressionArguments(), argumentList.getNamedArguments(), GrClosableBlock.EMPTY_ARRAY, constant);
}
final GrEnumConstantInitializer anonymousBlock = constant.getInitializingClass();
if (anonymousBlock != null) {
builder.append("{\n");
new ClassGenerator(classNameProvider, this).writeMembers(builder, anonymousBlock);
builder.append("\n}");
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumConstantInitializer in project intellij-community by JetBrains.
the class GrEnumConstantImpl method getOrCreateInitializingClass.
@NotNull
@Override
public PsiEnumConstantInitializer getOrCreateInitializingClass() {
final GrEnumConstantInitializer initializingClass = getInitializingClass();
if (initializingClass != null)
return initializingClass;
final GrEnumConstantInitializer initializer = GroovyPsiElementFactory.getInstance(getProject()).createEnumConstantFromText("foo{}").getInitializingClass();
LOG.assertTrue(initializer != null);
final GrArgumentList argumentList = getArgumentList();
if (argumentList != null) {
return (PsiEnumConstantInitializer) addAfter(initializer, argumentList);
} else {
return (PsiEnumConstantInitializer) addAfter(initializer, getNameIdentifierGroovy());
}
}
Aggregations