@NotNull private ParameterList createFunctionParameters(@NotNull PsiMethod method) { List<Parameter> result = new LinkedList<Parameter>(); for (PsiParameter parameter : method.getParameterList().getParameters()) { result.add( new Parameter( new IdentifierImpl(parameter.getName()), typeToType( parameter.getType(), ConverterUtil.isAnnotatedAsNotNull(parameter.getModifierList())), ConverterUtil.isReadOnly(parameter, method.getBody()))); } return new ParameterList(result); }
@NotNull private Function methodToFunction(@NotNull PsiMethod method, boolean notEmpty) { if (isOverrideObjectDirect(method)) { dispatcher.setExpressionVisitor(new ExpressionVisitorForDirectObjectInheritors(this)); } else { dispatcher.setExpressionVisitor(new ExpressionVisitor(this)); } methodReturnType = method.getReturnType(); IdentifierImpl identifier = new IdentifierImpl(method.getName()); Type returnType = typeToType( method.getReturnType(), ConverterUtil.isAnnotatedAsNotNull(method.getModifierList())); Block body = hasFlag(J2KConverterFlags.SKIP_BODIES) ? Block.EMPTY_BLOCK : blockToBlock(method.getBody(), notEmpty); // #TODO Element params = createFunctionParameters(method); List<Element> typeParameters = elementsToElementList(method.getTypeParameters()); Set<String> modifiers = modifiersListToModifiersSet(method.getModifierList()); if (isOverrideAnyMethodExceptMethodsFromObject(method)) { modifiers.add(Modifier.OVERRIDE); } if (method.getParent() instanceof PsiClass && ((PsiClass) method.getParent()).isInterface()) { modifiers.remove(Modifier.ABSTRACT); } if (isNotOpenMethod(method)) { modifiers.add(Modifier.NOT_OPEN); } if (method.isConstructor()) { // TODO: simplify boolean isPrimary = isConstructorPrimary(method); return new Constructor( identifier, modifiers, returnType, typeParameters, params, new Block(removeEmpty(body.getStatements()), false), isPrimary); } return new Function(identifier, modifiers, returnType, typeParameters, params, body); }