Exemple #1
0
 @NotNull
 public Parameter parameterToParameter(@NotNull PsiParameter parameter) {
   return new Parameter(
       new IdentifierImpl(parameter.getName()),
       typeToType(
           parameter.getType(), ConverterUtil.isAnnotatedAsNotNull(parameter.getModifierList())));
 }
Exemple #2
0
  @NotNull
  public List<String> createConversions(@NotNull PsiCallExpression expression) {
    PsiExpressionList argumentList = expression.getArgumentList();
    PsiExpression[] arguments =
        argumentList != null ? argumentList.getExpressions() : new PsiExpression[] {};
    List<String> conversions = new LinkedList<String>();
    //noinspection UnusedDeclaration
    for (PsiExpression a : arguments) {
      conversions.add("");
    }

    PsiMethod resolve = expression.resolveMethod();
    if (resolve != null) {
      List<PsiType> expectedTypes = new LinkedList<PsiType>();
      List<PsiType> actualTypes = new LinkedList<PsiType>();

      for (PsiParameter p : resolve.getParameterList().getParameters())
        expectedTypes.add(p.getType());

      for (PsiExpression e : arguments) actualTypes.add(e.getType());

      if (conversions.size() == actualTypes.size() && actualTypes.size() == expectedTypes.size()) {
        for (int i = 0; i < actualTypes.size(); i++)
          conversions.set(i, createConversionForExpression(arguments[i], expectedTypes.get(i)));
      }
    }
    return conversions;
  }
Exemple #3
0
 @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);
 }