to kotlin

This commit is contained in:
Dmitry Jemerov
2012-05-31 20:53:51 +02:00
committed by Pavel V. Talanov
parent 0e2d0a4a5b
commit 8bcc51f6c2
5 changed files with 30 additions and 116 deletions
@@ -1,47 +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;
/**
* @author ignatov
*/
public abstract class Element extends Node {
@NotNull
public static final Element EMPTY_ELEMENT = new EmptyElement();
public boolean isEmpty() {
return false;
}
/**
* @author ignatov
*/
private static class EmptyElement extends Element {
@NotNull
@Override
public String toKotlin() {
return EMPTY;
}
@Override
public boolean isEmpty() {
return true;
}
}
}
+15
View File
@@ -0,0 +1,15 @@
package org.jetbrains.jet.j2k.ast
public abstract class Element(): Node() {
public open fun isEmpty(): Boolean {
return false
}
class object {
public val EMPTY_ELEMENT: Element = object : Element() {
override fun toKotlin() = ""
override fun isEmpty() = true
}
}
}
-68
View File
@@ -1,68 +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.eclipse.jdt.internal.core.search.StringOperation;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* @author ignatov
*/
public abstract class Node {
@NotNull
public final static Set<String> PRIMITIVE_TYPES = new HashSet<String>(Arrays.asList(
"double", "float", "long", "int", "short", "byte", "boolean", "char"
));
static final String N = "\n";
@NotNull
static final String N2 = N + N;
@NotNull
static final String SPACE = " ";
@NotNull
static final String EQUAL = "=";
@NotNull
static final String EMPTY = "";
@NotNull
static final String DOT = ".";
@NotNull
static final String QUESTDOT = "?.";
@NotNull
static final String COLON = ":";
@NotNull
static final String IN = "in";
@NotNull
static final String AT = "@";
@NotNull
static final String BACKTICK = "`";
@NotNull
static final String QUEST = "?";
@NotNull
public static final String COMMA_WITH_SPACE = "," + SPACE;
@NotNull
static final String STAR = "*";
@NotNull
protected static final String ZERO = "0";
@NotNull
public abstract String toKotlin();
}
+15
View File
@@ -0,0 +1,15 @@
package org.jetbrains.jet.j2k.ast
import org.eclipse.jdt.internal.core.search.StringOperation
import java.util.Arrays
import java.util.HashSet
import java.util.Set
public abstract class Node() {
public abstract fun toKotlin(): String
class object {
public val PRIMITIVE_TYPES: Set<String> = hashSet(
"double", "float", "long", "int", "short", "byte", "boolean", "char")
}
}
@@ -99,7 +99,6 @@ public open class ExpressionVisitor(converter: Converter): StatementVisitor(conv
public override fun visitLiteralExpression(expression: PsiLiteralExpression?): Unit {
val value: Any? = expression?.getValue()
var text: String = expression?.getText()!!
var isQuotingNeeded: Boolean = true
val `type`: PsiType? = expression?.getType()
if (`type` != null) {
val canonicalTypeStr: String? = `type`.getCanonicalText()