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