From 8bcc51f6c22adc3e48f93379051d60cb5fbba3e2 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 31 May 2012 20:53:51 +0200 Subject: [PATCH] to kotlin --- src/org/jetbrains/jet/j2k/ast/Element.java | 47 ------------- src/org/jetbrains/jet/j2k/ast/Element.kt | 15 ++++ src/org/jetbrains/jet/j2k/ast/Node.java | 68 ------------------- src/org/jetbrains/jet/j2k/ast/Node.kt | 15 ++++ .../jet/j2k/visitors/ExpressionVisitor.kt | 1 - 5 files changed, 30 insertions(+), 116 deletions(-) delete mode 100644 src/org/jetbrains/jet/j2k/ast/Element.java create mode 100644 src/org/jetbrains/jet/j2k/ast/Element.kt delete mode 100644 src/org/jetbrains/jet/j2k/ast/Node.java create mode 100644 src/org/jetbrains/jet/j2k/ast/Node.kt diff --git a/src/org/jetbrains/jet/j2k/ast/Element.java b/src/org/jetbrains/jet/j2k/ast/Element.java deleted file mode 100644 index 18047306a23..00000000000 --- a/src/org/jetbrains/jet/j2k/ast/Element.java +++ /dev/null @@ -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; - } - } -} diff --git a/src/org/jetbrains/jet/j2k/ast/Element.kt b/src/org/jetbrains/jet/j2k/ast/Element.kt new file mode 100644 index 00000000000..55f0c5a7c3a --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Element.kt @@ -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 + } + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Node.java b/src/org/jetbrains/jet/j2k/ast/Node.java deleted file mode 100644 index 622e8d6955a..00000000000 --- a/src/org/jetbrains/jet/j2k/ast/Node.java +++ /dev/null @@ -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 PRIMITIVE_TYPES = new HashSet(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(); -} diff --git a/src/org/jetbrains/jet/j2k/ast/Node.kt b/src/org/jetbrains/jet/j2k/ast/Node.kt new file mode 100644 index 00000000000..ecc2900a76e --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Node.kt @@ -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 = hashSet( + "double", "float", "long", "int", "short", "byte", "boolean", "char") + } +} diff --git a/src/org/jetbrains/jet/j2k/visitors/ExpressionVisitor.kt b/src/org/jetbrains/jet/j2k/visitors/ExpressionVisitor.kt index 2a6d1e49830..d46ce18f1ad 100644 --- a/src/org/jetbrains/jet/j2k/visitors/ExpressionVisitor.kt +++ b/src/org/jetbrains/jet/j2k/visitors/ExpressionVisitor.kt @@ -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()