@NotNull
 private static String createInitializers(
     @NotNull final Type type, @NotNull final List<Expression> initializers) {
   List<String> arguments = new LinkedList<String>();
   for (Expression i : initializers) arguments.add(explicitConvertIfNeeded(type, i));
   return AstUtil.join(arguments, COMMA_WITH_SPACE);
 }
 @NotNull
 private static String createArrayFunction(@NotNull final Type type) {
   String sType = innerTypeStr(type);
   if (PRIMITIVE_TYPES.contains(sType)) {
     return sType + "Array"; // intArray
   }
   return AstUtil.lowerFirstCharacter(type.convertedToNotNull().toKotlin()); // array<Foo?>
 }
示例#3
0
 @NotNull
 @Override
 public String toKotlin() {
   String params =
       myParameters.size() == 0
           ? EMPTY
           : "<" + AstUtil.joinNodes(myParameters, COMMA_WITH_SPACE) + ">";
   return myType.toKotlin() + params + isNullableStr();
 }
示例#4
0
 private static boolean isConversionNeeded(@Nullable PsiType actual, @Nullable PsiType expected) {
   if (actual == null || expected == null) {
     return false;
   }
   Map<String, String> typeMap = new HashMap<String, String>();
   typeMap.put(JAVA_LANG_BYTE, "byte");
   typeMap.put(JAVA_LANG_SHORT, "short");
   typeMap.put(JAVA_LANG_INTEGER, "int");
   typeMap.put(JAVA_LANG_LONG, "long");
   typeMap.put(JAVA_LANG_FLOAT, "float");
   typeMap.put(JAVA_LANG_DOUBLE, "double");
   typeMap.put(JAVA_LANG_CHARACTER, "char");
   String expectedStr = expected.getCanonicalText();
   String actualStr = actual.getCanonicalText();
   boolean o1 = AstUtil.getOrElse(typeMap, actualStr, "").equals(expectedStr);
   boolean o2 = AstUtil.getOrElse(typeMap, expectedStr, "").equals(actualStr);
   return !actualStr.equals(expectedStr) && (!(o1 ^ o2));
 }
示例#5
0
 @NotNull
 private static String createPrimaryConstructorInvocation(
     @NotNull String s,
     @NotNull List<? extends Field> fields,
     @NotNull Map<String, String> initializers) {
   List<String> result = new LinkedList<String>();
   for (Field f : fields) {
     String id = f.getIdentifier().toKotlin();
     result.add(initializers.get(id));
   }
   return s + "(" + AstUtil.join(result, ", ") + ")";
 }
示例#6
0
 @NotNull
 private static String quoteKeywords(@NotNull String packageName) {
   List<String> result = new LinkedList<String>();
   for (String part : packageName.split("\\.")) result.add(new IdentifierImpl(part).toKotlin());
   return AstUtil.join(result, ".");
 }