use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrReflectedMethod in project intellij-community by JetBrains.
the class StubGenerator method writeConstructor.
@Override
public void writeConstructor(final StringBuilder text, PsiMethod constructor, boolean isEnum) {
LOG.assertTrue(constructor.isConstructor());
if (!isEnum) {
text.append("public ");
//writeModifiers(text, constructor.getModifierList(), JAVA_MODIFIERS);
}
/************* name **********/
//append constructor name
text.append(constructor.getName());
/************* parameters **********/
GenerationUtil.writeParameterList(text, constructor.getParameterList().getParameters(), classNameProvider, null);
final Set<String> throwsTypes = collectThrowsTypes(constructor, new THashSet<>());
if (!throwsTypes.isEmpty()) {
text.append("throws ").append(StringUtil.join(throwsTypes, ", ")).append(' ');
}
/************* body **********/
text.append("{\n");
if (constructor instanceof GrReflectedMethod) {
constructor = ((GrReflectedMethod) constructor).getBaseMethod();
}
if (constructor instanceof GrMethod) {
final GrConstructorInvocation invocation = PsiImplUtil.getChainingConstructorInvocation((GrMethod) constructor);
if (invocation != null) {
final GroovyResolveResult resolveResult = resolveChainingConstructor((GrMethod) constructor);
if (resolveResult != null) {
text.append(invocation.isSuperCall() ? "super(" : "this(");
writeStubConstructorInvocation(text, (PsiMethod) resolveResult.getElement(), resolveResult.getSubstitutor(), invocation);
text.append(");");
}
} else if (constructor instanceof LightElement) {
writeStubConstructorInvocation(constructor, text);
}
}
text.append("\n}\n");
}
Aggregations