no more conversions anywhere
This commit is contained in:
committed by
Pavel V. Talanov
parent
dfaa67ab6b
commit
2cd137b0ae
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.j2k.ast;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.j2k.util.AstUtil;
|
||||
|
||||
/**
|
||||
* @author ignatov
|
||||
*/
|
||||
public class ReturnStatement extends Statement {
|
||||
private final Expression myExpression;
|
||||
private String myConversion = EMPTY;
|
||||
|
||||
public ReturnStatement(Expression expression) {
|
||||
myExpression = expression;
|
||||
}
|
||||
|
||||
public ReturnStatement(final Expression expression, final String conversion) {
|
||||
this(expression);
|
||||
myConversion = conversion;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String toKotlin() {
|
||||
return "return" + SPACE + AstUtil.applyConversionForOneItem(myExpression.toKotlin(), myConversion);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
|
||||
public open class ReturnStatement(val expression: Expression): Statement() {
|
||||
public override fun toKotlin() = "return " + expression.toKotlin()
|
||||
}
|
||||
@@ -72,24 +72,6 @@ public class AstUtil {
|
||||
return string.substring(0, 1).toLowerCase() + string.substring(1);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> List<String> createListWithEmptyString(@NotNull final List<T> arguments) {
|
||||
final List<String> conversions = new LinkedList<String>();
|
||||
//noinspection UnusedDeclaration
|
||||
for (T argument : arguments) conversions.add("");
|
||||
return conversions;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String applyConversionForOneItem(@NotNull String f, @NotNull String s) {
|
||||
if (s.isEmpty()) {
|
||||
return f;
|
||||
}
|
||||
else {
|
||||
return "(" + f + ")" + s;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> T getOrElse(@NotNull Map<T, T> map, @NotNull T e, @NotNull T orElse) {
|
||||
if (map.containsKey(e)) {
|
||||
@@ -97,12 +79,4 @@ public class AstUtil {
|
||||
}
|
||||
return orElse;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String replaceLastQuest(@NotNull String str) {
|
||||
if (str.endsWith("?")) {
|
||||
return str.substring(0, str.length() - 1);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user