remove dollar usages from the whole project

This commit is contained in:
Sergey Ignatov
2011-12-16 15:25:29 +04:00
parent 115a170f5b
commit bb499697fc
19 changed files with 48 additions and 53 deletions
+3 -2
View File
@@ -115,7 +115,8 @@ public class Converter {
@NotNull
private static List<Parameter> createParametersFromFields(@NotNull List<? extends Field> fields) {
List<Parameter> result = new LinkedList<Parameter>();
for (Field f : fields) result.add(new Parameter(f.getIdentifier(), f.getType()));
for (Field f : fields)
result.add(new Parameter(new IdentifierImpl("_" + f.getIdentifier().getName()), f.getType()));
return result;
}
@@ -124,7 +125,7 @@ public class Converter {
List<Statement> result = new LinkedList<Statement>();
for (Field f : fields) {
final String identifierToKotlin = f.getIdentifier().toKotlin();
result.add(new DummyStringExpression("$" + identifierToKotlin + " = " + identifierToKotlin));
result.add(new DummyStringExpression(identifierToKotlin + " = " + "_" + identifierToKotlin));
}
return result;
}
@@ -10,4 +10,6 @@ public interface Identifier extends INode {
public static Identifier EMPTY_IDENTIFIER = new IdentifierImpl("");
public boolean isEmpty();
String getName();
}
@@ -7,7 +7,6 @@ import org.jetbrains.annotations.NotNull;
*/
public class IdentifierImpl extends Expression implements Identifier {
private final String myName;
private boolean myHasDollar = false;
private boolean myIsNullable = true;
private boolean myQuotingNeeded = true;
@@ -20,14 +19,9 @@ public class IdentifierImpl extends Expression implements Identifier {
myIsNullable = isNullable;
}
public IdentifierImpl(String name, boolean hasDollar, boolean isNullable) {
public IdentifierImpl(String name, boolean isNullable, boolean quotingNeeded) {
myName = name;
myHasDollar = hasDollar;
myIsNullable = isNullable;
}
public IdentifierImpl(String name, boolean hasDollar, boolean isNullable, boolean quotingNeeded) {
this(name, hasDollar, isNullable);
myQuotingNeeded = quotingNeeded;
}
@@ -36,6 +30,11 @@ public class IdentifierImpl extends Expression implements Identifier {
return myName.length() == 0;
}
@Override
public String getName() {
return myName;
}
@NotNull
private static String quote(String str) {
return BACKTICK + str + BACKTICK;
@@ -55,8 +54,6 @@ public class IdentifierImpl extends Expression implements Identifier {
@NotNull
@Override
public String toKotlin() {
if (myHasDollar)
return DOLLAR + ifNeedQuote();
return ifNeedQuote();
}
}
-2
View File
@@ -46,8 +46,6 @@ public abstract class Node implements INode {
@NotNull
static final String AT = "@";
@NotNull
static final String DOLLAR = "$";
@NotNull
static final String BACKTICK = "`";
@NotNull
static final String QUEST = "?";
@@ -6,7 +6,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.j2k.ast.*;
import java.util.*;
import java.util.Collections;
import java.util.List;
import static org.jetbrains.jet.j2k.Converter.*;
@@ -188,7 +189,7 @@ public class ExpressionVisitor extends StatementVisitor {
if (canonicalTypeStr.equals("char") || canonicalTypeStr.equals("java.lang.Character"))
isQuotingNeeded = false;
}
myResult = new LiteralExpression(new IdentifierImpl(text, false, false, isQuotingNeeded));
myResult = new LiteralExpression(new IdentifierImpl(text, false, isQuotingNeeded));
}
@Override
@@ -310,15 +311,11 @@ public class ExpressionVisitor extends StatementVisitor {
Expression identifier = new IdentifierImpl(expression.getReferenceName(), isNullable);
if (hasDollar)
identifier = new IdentifierImpl(expression.getReferenceName(), hasDollar, isNullable);
else {
final String temporaryObject = "__";
if (hasReceiver)
identifier = new CallChainExpression(new IdentifierImpl(temporaryObject, false), new IdentifierImpl(expression.getReferenceName(), isNullable));
else if (insideSecondaryConstructor && isThis)
identifier = new IdentifierImpl("val " + temporaryObject + " = " + className); // TODO: hack
}
final String temporaryObject = "__";
if (hasReceiver)
identifier = new CallChainExpression(new IdentifierImpl(temporaryObject, false), new IdentifierImpl(expression.getReferenceName(), isNullable));
else if (insideSecondaryConstructor && isThis)
identifier = new IdentifierImpl("val " + temporaryObject + " = " + className); // TODO: hack
myResult = new CallChainExpression(
expressionToExpression(expression.getQualifierExpression()),
@@ -1,7 +1,7 @@
namespace test
public open class Test(str : String) {
{
$myStr = str
myStr = str
}
var myStr : String? = "String2"
open public fun sout(str : String) : Unit {
@@ -1,8 +1,8 @@
open class C(arg1 : Int) {
{
$myArg1 = arg1
$myArg2 = 0
$myArg3 = 0
myArg1 = arg1
myArg2 = 0
myArg3 = 0
}
val myArg1 : Int = 0
var myArg2 : Int = 0
@@ -2,8 +2,8 @@ namespace org.test.customer
open class Customer(first : String?, last : String?) {
{
doSmthBefore()
$_firstName = first
$_lastName = last
_firstName = first
_lastName = last
doSmthAfter()
}
public val _firstName : String? = null
@@ -1,7 +1,7 @@
public open class Identifier<T>(myName : T?, myHasDollar : Boolean) {
public open class Identifier<T>(_myName : T?, _myHasDollar : Boolean) {
{
$myName = myName
$myHasDollar = myHasDollar
myName = _myName
myHasDollar = _myHasDollar
}
private val myName : T? = null
private var myHasDollar : Boolean = false
+3 -3
View File
@@ -1,7 +1,7 @@
public open class Identifier(myName : String?, myHasDollar : Boolean) {
public open class Identifier(_myName : String?, _myHasDollar : Boolean) {
{
$myName = myName
$myHasDollar = myHasDollar
myName = _myName
myHasDollar = _myHasDollar
}
private val myName : String? = null
private var myHasDollar : Boolean = false
@@ -1,13 +1,13 @@
public open class Test(myName : String?, a : Boolean, b : Double, c : Float, d : Long, e : Int, f : Short, g : Char) {
public open class Test(_myName : String?, _a : Boolean, _b : Double, _c : Float, _d : Long, _e : Int, _f : Short, _g : Char) {
{
$myName = myName
$a = a
$b = b
$c = c
$d = d
$e = e
$f = f
$g = g
myName = _myName
a = _a
b = _b
c = _c
d = _d
e = _e
f = _f
g = _g
}
private val myName : String? = null
private var a : Boolean = false
+1 -1
View File
@@ -1,7 +1,7 @@
namespace demo
enum class MyEnum(_color : Int) {
{
$color = _color
color = _color
}
RED : MyEnum(10)
BLUE : MyEnum(20)
@@ -1,6 +1,6 @@
enum class Color(c : Int) {
{
$code = c
code = c
}
WHITE : Color(21)
BLACK : Color(22)
@@ -1,7 +1,7 @@
namespace demo
enum class Color(c : Int) {
{
$code = c
code = c
}
private var code : Int = 0
public fun getCode() : Int {
@@ -4,7 +4,7 @@ open class `$`() {
}
open class `$$`(`$$$$` : `$$$$$`?) : `$`() {
{
$`$$$` = `$$$$`
`$$$` = `$$$$`
}
val `$$$` : `$$$$$`? = null
open public fun `$$$$$$`() : `$$$$$`? {
@@ -2,7 +2,7 @@ open class Base<T>(name : T?) {
}
open class One<T, K>(name : T?, second : K?) : Base<T?>(name) {
{
$mySecond = second
mySecond = second
}
private var mySecond : K? = null
}
@@ -2,7 +2,7 @@ open class Base(name : String?) {
}
open class One(name : String?, second : String?) : Base(name) {
{
$mySecond = second
mySecond = second
}
private var mySecond : String? = null
}
+1 -1
View File
@@ -2,7 +2,7 @@ namespace com.voltvoodoo.saplo4j.model
import java.io.Serializable
public open class Language(code : String?) : Serializable {
{
this.$code = code
this.code = code
}
protected var code : String? = null
override public fun toString() : String? {
+1 -1
View File
@@ -2,7 +2,7 @@ namespace com.voltvoodoo.saplo4j.model
import java.io.Serializable
public open class Language(code : String?) : Serializable {
{
this.$code = code
this.code = code
}
protected var code : String? = null
open public fun equals(other : Language?) : Boolean {