use of org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock in project intellij-community by JetBrains.
the class ExpressionGenerator method isImplicitlyCastedToArray.
private static boolean isImplicitlyCastedToArray(GrListOrMap list) {
PsiElement parent = list.getParent();
GrControlFlowOwner owner = ControlFlowUtils.findControlFlowOwner(list);
if (!(owner instanceof GrOpenBlock && owner.getParent() instanceof GrMethod))
return false;
if (!(parent instanceof GrReturnStatement || ControlFlowUtils.isReturnValue(list, owner)))
return false;
PsiType type = ((GrMethod) owner.getParent()).getReturnType();
return type instanceof PsiArrayType;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock in project intellij-community by JetBrains.
the class CodeBlockGenerator method visitFinallyClause.
@Override
public void visitFinallyClause(@NotNull GrFinallyClause finallyClause) {
builder.append("finally ");
final GrOpenBlock body = finallyClause.getBody();
if (body != null) {
body.accept(this);
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock in project intellij-community by JetBrains.
the class CodeBlockGenerator method visitCatchClause.
@Override
public void visitCatchClause(@NotNull GrCatchClause catchClause) {
final GrParameter parameter = catchClause.getParameter();
builder.append("catch (");
writeVariableWithoutSemicolonAndInitializer(builder, parameter, context);
builder.append(") ");
final GrOpenBlock body = catchClause.getBody();
if (body != null) {
body.accept(this);
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock in project intellij-community by JetBrains.
the class CodeBlockGenerator method visitTryStatement.
@Override
public void visitTryStatement(@NotNull GrTryCatchStatement tryCatchStatement) {
final GrOpenBlock tryBlock = tryCatchStatement.getTryBlock();
final GrCatchClause[] catchClauses = tryCatchStatement.getCatchClauses();
final GrFinallyClause finallyClause = tryCatchStatement.getFinallyClause();
builder.append("try");
tryBlock.accept(this);
for (GrCatchClause catchClause : catchClauses) {
catchClause.accept(this);
}
if (finallyClause != null) {
finallyClause.accept(this);
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock in project intellij-community by JetBrains.
the class CodeBlockGenerator method generateMethodBody.
public void generateMethodBody(GrMethod method) {
final GrOpenBlock block = method.getBlock();
boolean shouldInsertReturnNull;
myExitPoints.clear();
PsiType returnType = context.typeProvider.getReturnType(method);
if (GroovyObjectTransformationSupport.isGroovyObjectSupportMethod(method)) {
shouldInsertReturnNull = !(returnType instanceof PsiPrimitiveType);
} else if (!method.isConstructor() && !PsiType.VOID.equals(returnType)) {
myExitPoints.addAll(ControlFlowUtils.collectReturns(block));
shouldInsertReturnNull = block != null && !(returnType instanceof PsiPrimitiveType) && MissingReturnInspection.methodMissesSomeReturns(block, MissingReturnInspection.ReturnStatus.getReturnStatus(method));
} else {
shouldInsertReturnNull = false;
}
generateCodeBlock(method.getParameters(), block, shouldInsertReturnNull);
}
Aggregations