modifiers are an enum
This commit is contained in:
committed by
Pavel V. Talanov
parent
e33f66f4b9
commit
9e2e23c757
@@ -130,7 +130,7 @@ public open class Converter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun classToClass(psiClass: PsiClass): Class {
|
private fun classToClass(psiClass: PsiClass): Class {
|
||||||
val modifiers: Set<String> = modifiersListToModifiersSet(psiClass.getModifierList())
|
val modifiers: Set<Modifier> = modifiersListToModifiersSet(psiClass.getModifierList())
|
||||||
val fields: List<Field> = fieldsToFieldList(psiClass.getFields(), psiClass)
|
val fields: List<Field> = fieldsToFieldList(psiClass.getFields(), psiClass)
|
||||||
val typeParameters: List<Element> = elementsToElementList(psiClass.getTypeParameters())
|
val typeParameters: List<Element> = elementsToElementList(psiClass.getTypeParameters())
|
||||||
val implementsTypes: List<Type> = typesToNotNullableTypeList(psiClass.getImplementsListTypes())
|
val implementsTypes: List<Type> = typesToNotNullableTypeList(psiClass.getImplementsListTypes())
|
||||||
@@ -186,7 +186,7 @@ public open class Converter() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
members.add(Constructor(Identifier.EMPTY_IDENTIFIER, arrayList(), Collections.emptySet<String>()!!,
|
members.add(Constructor(Identifier.EMPTY_IDENTIFIER, arrayList(), Collections.emptySet<Modifier>()!!,
|
||||||
ClassType(name, Collections.emptyList<Element>()!!, false),
|
ClassType(name, Collections.emptyList<Element>()!!, false),
|
||||||
Collections.emptyList<Element>()!!,
|
Collections.emptyList<Element>()!!,
|
||||||
ParameterList(createParametersFromFields(finalOrWithEmptyInitializer)),
|
ParameterList(createParametersFromFields(finalOrWithEmptyInitializer)),
|
||||||
@@ -214,7 +214,7 @@ public open class Converter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun fieldToField(field: PsiField, psiClass: PsiClass?): Field {
|
private fun fieldToField(field: PsiField, psiClass: PsiClass?): Field {
|
||||||
val modifiers: Set<String> = modifiersListToModifiersSet(field.getModifierList())
|
val modifiers = modifiersListToModifiersSet(field.getModifierList())
|
||||||
val docComments = getDocComments(field)
|
val docComments = getDocComments(field)
|
||||||
if (field is PsiEnumConstant) {
|
if (field is PsiEnumConstant) {
|
||||||
return EnumConstant(Identifier(field.getName()!!),
|
return EnumConstant(Identifier(field.getName()!!),
|
||||||
@@ -584,7 +584,7 @@ public open class Converter() {
|
|||||||
val parent = method.getParent()
|
val parent = method.getParent()
|
||||||
if (parent is PsiClass) {
|
if (parent is PsiClass) {
|
||||||
val parentModifierList: PsiModifierList? = parent.getModifierList()
|
val parentModifierList: PsiModifierList? = parent.getModifierList()
|
||||||
if ((parentModifierList != null && parentModifierList.hasExplicitModifier(Modifier.FINAL)) || parent.isEnum()) {
|
if ((parentModifierList != null && parentModifierList.hasExplicitModifier(PsiModifier.FINAL)) || parent.isEnum()) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,8 +677,8 @@ public open class Converter() {
|
|||||||
return Identifier(identifier.getText()!!)
|
return Identifier(identifier.getText()!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
public open fun modifiersListToModifiersSet(modifierList: PsiModifierList?): Set<String> {
|
public open fun modifiersListToModifiersSet(modifierList: PsiModifierList?): Set<Modifier> {
|
||||||
val modifiersSet: HashSet<String> = hashSet()
|
val modifiersSet: HashSet<Modifier> = hashSet()
|
||||||
if (modifierList != null) {
|
if (modifierList != null) {
|
||||||
if (modifierList.hasExplicitModifier(PsiModifier.ABSTRACT))
|
if (modifierList.hasExplicitModifier(PsiModifier.ABSTRACT))
|
||||||
modifiersSet.add(Modifier.ABSTRACT)
|
modifiersSet.add(Modifier.ABSTRACT)
|
||||||
@@ -704,6 +704,7 @@ public open class Converter() {
|
|||||||
|
|
||||||
return modifiersSet
|
return modifiersSet
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isConversionNeeded(actual: PsiType?, expected: PsiType?): Boolean {
|
private fun isConversionNeeded(actual: PsiType?, expected: PsiType?): Boolean {
|
||||||
if (actual == null || expected == null) {
|
if (actual == null || expected == null) {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public open class AnonymousClass(converter : Converter, members : List<Node>)
|
|||||||
: Class(converter,
|
: Class(converter,
|
||||||
Identifier("anonClass"),
|
Identifier("anonClass"),
|
||||||
arrayList(),
|
arrayList(),
|
||||||
Collections.emptySet<String>()!!,
|
Collections.emptySet<Modifier>()!!,
|
||||||
Collections.emptyList<Element>()!!,
|
Collections.emptyList<Element>()!!,
|
||||||
Collections.emptyList<Type>()!!,
|
Collections.emptyList<Type>()!!,
|
||||||
Collections.emptyList<Expression>()!!,
|
Collections.emptyList<Expression>()!!,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import java.util.ArrayList
|
|||||||
public open class Class(converter : Converter,
|
public open class Class(converter : Converter,
|
||||||
val name : Identifier,
|
val name : Identifier,
|
||||||
val docComments: List<Node>,
|
val docComments: List<Node>,
|
||||||
modifiers : Set<String>,
|
modifiers : Set<Modifier>,
|
||||||
val typeParameters : List<Element>,
|
val typeParameters : List<Element>,
|
||||||
val extendsTypes : List<Type>,
|
val extendsTypes : List<Type>,
|
||||||
val baseClassParams : List<Expression>,
|
val baseClassParams : List<Expression>,
|
||||||
@@ -60,7 +60,7 @@ public open class Class(converter : Converter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun constructorToInit(f: Function): Function {
|
private fun constructorToInit(f: Function): Function {
|
||||||
val modifiers : Set<String> = HashSet<String>(f.getModifiers())
|
val modifiers : Set<Modifier> = HashSet<Modifier>(f.modifiers)
|
||||||
modifiers.add(Modifier.STATIC)
|
modifiers.add(Modifier.STATIC)
|
||||||
val statements : List<Element> = f.block?.statements ?: arrayList()
|
val statements : List<Element> = f.block?.statements ?: arrayList()
|
||||||
statements.add(ReturnStatement(Identifier("__")))
|
statements.add(ReturnStatement(Identifier("__")))
|
||||||
@@ -93,8 +93,11 @@ public open class Class(converter : Converter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
open fun modifiersToKotlin() : String {
|
open fun modifiersToKotlin() : String {
|
||||||
val modifierList : List<String> = arrayList()
|
val modifierList : List<Modifier> = arrayList()
|
||||||
modifierList.add(accessModifier())
|
val modifier = accessModifier()
|
||||||
|
if (modifier != null) {
|
||||||
|
modifierList.add(modifier)
|
||||||
|
}
|
||||||
if (needAbstractModifier()) {
|
if (needAbstractModifier()) {
|
||||||
modifierList.add(Modifier.ABSTRACT)
|
modifierList.add(Modifier.ABSTRACT)
|
||||||
}
|
}
|
||||||
@@ -102,15 +105,10 @@ public open class Class(converter : Converter,
|
|||||||
if (needOpenModifier()) {
|
if (needOpenModifier()) {
|
||||||
modifierList.add(Modifier.OPEN)
|
modifierList.add(Modifier.OPEN)
|
||||||
}
|
}
|
||||||
|
return modifierList.toKotlin()
|
||||||
if (modifierList.size() > 0) {
|
|
||||||
return modifierList.makeString(" ") + " "
|
|
||||||
}
|
|
||||||
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun needOpenModifier() = !myModifiers.contains(Modifier.FINAL) && !myModifiers.contains(Modifier.ABSTRACT)
|
open fun needOpenModifier() = !modifiers.contains(Modifier.FINAL) && !modifiers.contains(Modifier.ABSTRACT)
|
||||||
|
|
||||||
open fun needAbstractModifier() = isAbstract()
|
open fun needAbstractModifier() = isAbstract()
|
||||||
|
|
||||||
@@ -139,8 +137,8 @@ public open class Class(converter : Converter,
|
|||||||
open fun getMembers(members : List<Node>, converter : Converter) : List<Node> {
|
open fun getMembers(members : List<Node>, converter : Converter) : List<Node> {
|
||||||
if (converter.hasFlag(J2KConverterFlags.SKIP_NON_PUBLIC_MEMBERS)) {
|
if (converter.hasFlag(J2KConverterFlags.SKIP_NON_PUBLIC_MEMBERS)) {
|
||||||
return members.filter { it is Comment ||
|
return members.filter { it is Comment ||
|
||||||
(it as Member).accessModifier() == "public" ||
|
(it as Member).accessModifier() == Modifier.PUBLIC ||
|
||||||
(it as Member).accessModifier() == "protected" }
|
(it as Member).accessModifier() == Modifier.PROTECTED }
|
||||||
}
|
}
|
||||||
return members
|
return members
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.jetbrains.jet.j2k.ast.types.Type
|
|||||||
|
|
||||||
public open class Constructor(identifier : Identifier,
|
public open class Constructor(identifier : Identifier,
|
||||||
docComments: List<Node>,
|
docComments: List<Node>,
|
||||||
modifiers : Set<String>,
|
modifiers : Set<Modifier>,
|
||||||
`type` : Type,
|
`type` : Type,
|
||||||
typeParameters : List<Element>,
|
typeParameters : List<Element>,
|
||||||
params : Element,
|
params : Element,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.Set
|
|||||||
public open class Enum(converter : Converter,
|
public open class Enum(converter : Converter,
|
||||||
name : Identifier,
|
name : Identifier,
|
||||||
docComments: List<Node>,
|
docComments: List<Node>,
|
||||||
modifiers : Set<String>,
|
modifiers : Set<Modifier>,
|
||||||
typeParameters : List<Element>,
|
typeParameters : List<Element>,
|
||||||
extendsTypes : List<Type>,
|
extendsTypes : List<Type>,
|
||||||
baseClassParams : List<Expression>,
|
baseClassParams : List<Expression>,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import java.util.List
|
|||||||
|
|
||||||
public open class EnumConstant(identifier : Identifier,
|
public open class EnumConstant(identifier : Identifier,
|
||||||
docComments: List<Node>,
|
docComments: List<Node>,
|
||||||
modifiers : Set<String>,
|
modifiers : Set<Modifier>,
|
||||||
`type` : Type,
|
`type` : Type,
|
||||||
params : Element) : Field(identifier, docComments, modifiers, `type`.convertedToNotNull(), params, 0) {
|
params : Element) : Field(identifier, docComments, modifiers, `type`.convertedToNotNull(), params, 0) {
|
||||||
|
|
||||||
|
|||||||
@@ -8,34 +8,27 @@ import org.jetbrains.jet.j2k.Converter
|
|||||||
|
|
||||||
public open class Field(val identifier : Identifier,
|
public open class Field(val identifier : Identifier,
|
||||||
val docComments: List<Node>,
|
val docComments: List<Node>,
|
||||||
modifiers : Set<String>,
|
modifiers : Set<Modifier>,
|
||||||
val `type` : Type,
|
val `type` : Type,
|
||||||
val initializer : Element,
|
val initializer : Element,
|
||||||
val writingAccesses : Int) : Member(modifiers) {
|
val writingAccesses : Int) : Member(modifiers) {
|
||||||
|
|
||||||
open fun modifiersToKotlin() : String {
|
open fun modifiersToKotlin() : String {
|
||||||
val modifierList : List<String> = arrayList()
|
val modifierList : List<Modifier> = arrayList()
|
||||||
if (isAbstract()) {
|
if (isAbstract()) {
|
||||||
modifierList.add(Modifier.ABSTRACT)
|
modifierList.add(Modifier.ABSTRACT)
|
||||||
}
|
}
|
||||||
|
|
||||||
modifierList.add(accessModifier())
|
val modifier = accessModifier()
|
||||||
modifierList.add(if (isVal()) "val" else "var")
|
if (modifier != null) {
|
||||||
if (modifierList.size() > 0)
|
modifierList.add(modifier)
|
||||||
{
|
|
||||||
return modifierList.makeString(" ") + " "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return modifierList.toKotlin() + (if (isVal()) "val " else "var ")
|
||||||
}
|
}
|
||||||
|
|
||||||
public open fun isVal() : Boolean {
|
public open fun isVal() : Boolean = modifiers.contains(Modifier.FINAL)
|
||||||
return myModifiers.contains(Modifier.FINAL)
|
public override fun isStatic() : Boolean = modifiers.contains(Modifier.STATIC)
|
||||||
}
|
|
||||||
|
|
||||||
public override fun isStatic() : Boolean {
|
|
||||||
return myModifiers.contains(Modifier.STATIC)
|
|
||||||
}
|
|
||||||
|
|
||||||
public override fun toKotlin() : String {
|
public override fun toKotlin() : String {
|
||||||
val declaration : String = docComments.toKotlin("\n", "", "\n") +
|
val declaration : String = docComments.toKotlin("\n", "", "\n") +
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.jetbrains.jet.j2k.ast.types.Type
|
|||||||
|
|
||||||
public open class Function(val name : Identifier,
|
public open class Function(val name : Identifier,
|
||||||
val docComments: List<Node>,
|
val docComments: List<Node>,
|
||||||
modifiers : Set<String>,
|
modifiers : Set<Modifier>,
|
||||||
val `type` : Type,
|
val `type` : Type,
|
||||||
val typeParameters : List<Element>,
|
val typeParameters : List<Element>,
|
||||||
val params : Element,
|
val params : Element,
|
||||||
@@ -32,9 +32,9 @@ public open class Function(val name : Identifier,
|
|||||||
}
|
}
|
||||||
|
|
||||||
open fun modifiersToKotlin() : String {
|
open fun modifiersToKotlin() : String {
|
||||||
val modifierList: List<String> = arrayList()
|
val modifierList: List<Modifier> = arrayList()
|
||||||
val accessModifier : String = accessModifier()
|
val accessModifier = accessModifier()
|
||||||
if (!accessModifier.isEmpty()) {
|
if (accessModifier != null) {
|
||||||
modifierList.add(accessModifier)
|
modifierList.add(accessModifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,27 +42,22 @@ public open class Function(val name : Identifier,
|
|||||||
modifierList.add(Modifier.ABSTRACT)
|
modifierList.add(Modifier.ABSTRACT)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myModifiers.contains(Modifier.OVERRIDE)) {
|
if (modifiers.contains(Modifier.OVERRIDE)) {
|
||||||
modifierList.add(Modifier.OVERRIDE)
|
modifierList.add(Modifier.OVERRIDE)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!myModifiers.contains(Modifier.ABSTRACT) &&
|
if (!modifiers.contains(Modifier.ABSTRACT) &&
|
||||||
!myModifiers.contains(Modifier.OVERRIDE) &&
|
!modifiers.contains(Modifier.OVERRIDE) &&
|
||||||
!myModifiers.contains(Modifier.FINAL) &&
|
!modifiers.contains(Modifier.FINAL) &&
|
||||||
!myModifiers.contains(Modifier.PRIVATE))
|
!modifiers.contains(Modifier.PRIVATE)) {
|
||||||
{
|
|
||||||
modifierList.add(Modifier.OPEN)
|
modifierList.add(Modifier.OPEN)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myModifiers.contains(Modifier.NOT_OPEN)) {
|
if (modifiers.contains(Modifier.NOT_OPEN)) {
|
||||||
modifierList.remove(Modifier.OPEN)
|
modifierList.remove(Modifier.OPEN)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modifierList.size() > 0) {
|
return modifierList.toKotlin()
|
||||||
return modifierList.makeString(" ") + " "
|
|
||||||
}
|
|
||||||
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override fun toKotlin() : String {
|
public override fun toKotlin() : String {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package org.jetbrains.jet.j2k.ast
|
|||||||
|
|
||||||
import java.util.Set
|
import java.util.Set
|
||||||
|
|
||||||
public open class Initializer(val block : Block, modifiers : Set<String>) : Member(modifiers) {
|
public open class Initializer(val block : Block, modifiers : Set<Modifier>) : Member(modifiers) {
|
||||||
public override fun toKotlin() : String {
|
public override fun toKotlin() : String {
|
||||||
return block.toKotlin()
|
return block.toKotlin()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,11 @@ import org.jetbrains.jet.j2k.ast.types.Type
|
|||||||
import java.util.Set
|
import java.util.Set
|
||||||
|
|
||||||
public open class LocalVariable(val identifier: Identifier,
|
public open class LocalVariable(val identifier: Identifier,
|
||||||
val modifiersSet: Set<String>,
|
val modifiersSet: Set<Modifier>,
|
||||||
val `type`: Type,
|
val `type`: Type,
|
||||||
val initializer: Expression): Expression() {
|
val initializer: Expression): Expression() {
|
||||||
|
|
||||||
public open fun hasModifier(modifier: String): Boolean {
|
public open fun hasModifier(modifier: Modifier): Boolean = modifiersSet.contains(modifier)
|
||||||
return modifiersSet.contains(modifier)
|
|
||||||
}
|
|
||||||
|
|
||||||
public override fun toKotlin(): String {
|
public override fun toKotlin(): String {
|
||||||
if (initializer.isEmpty()) {
|
if (initializer.isEmpty()) {
|
||||||
|
|||||||
@@ -2,12 +2,11 @@ package org.jetbrains.jet.j2k.ast
|
|||||||
|
|
||||||
import java.util.Set
|
import java.util.Set
|
||||||
|
|
||||||
public abstract class Member(val myModifiers : Set<String>) : Node() {
|
public abstract class Member(val modifiers : Set<Modifier>) : Node() {
|
||||||
open fun accessModifier() : String {
|
open fun accessModifier() : Modifier? {
|
||||||
return myModifiers.find { m -> m == Modifier.PUBLIC || m == Modifier.PROTECTED || m == Modifier.PRIVATE } ?: ""
|
return modifiers.find { m -> m == Modifier.PUBLIC || m == Modifier.PROTECTED || m == Modifier.PRIVATE }
|
||||||
}
|
}
|
||||||
|
|
||||||
public open fun isAbstract() : Boolean = myModifiers.contains(Modifier.ABSTRACT)
|
public open fun isAbstract() : Boolean = modifiers.contains(Modifier.ABSTRACT)
|
||||||
public open fun isStatic() : Boolean = myModifiers.contains(Modifier.STATIC)
|
public open fun isStatic() : Boolean = modifiers.contains(Modifier.STATIC)
|
||||||
public open fun getModifiers() : Set<String> = myModifiers
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +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 Modifier {
|
|
||||||
@NotNull
|
|
||||||
public static final String PUBLIC = "public";
|
|
||||||
@NotNull
|
|
||||||
public static final String PROTECTED = "protected";
|
|
||||||
@NotNull
|
|
||||||
public static final String PRIVATE = "private";
|
|
||||||
@NotNull
|
|
||||||
public static final String INTERNAL = "internal";
|
|
||||||
@NotNull
|
|
||||||
public static final String STATIC = "static";
|
|
||||||
@NotNull
|
|
||||||
public static final String ABSTRACT = "abstract";
|
|
||||||
@NotNull
|
|
||||||
public static final String FINAL = "final";
|
|
||||||
@NotNull
|
|
||||||
public static final String OPEN = "open";
|
|
||||||
@NotNull
|
|
||||||
public static final String NOT_OPEN = "not open";
|
|
||||||
@NotNull
|
|
||||||
public static final String OVERRIDE = "override";
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.jetbrains.jet.j2k.ast
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @author ignatov
|
||||||
|
*/
|
||||||
|
public enum class Modifier(val name: String) {
|
||||||
|
PUBLIC: Modifier("public")
|
||||||
|
PROTECTED: Modifier("protected")
|
||||||
|
PRIVATE: Modifier("private")
|
||||||
|
INTERNAL: Modifier("internal")
|
||||||
|
STATIC: Modifier("static")
|
||||||
|
ABSTRACT: Modifier("abstract")
|
||||||
|
FINAL: Modifier("final")
|
||||||
|
OPEN: Modifier("open")
|
||||||
|
NOT_OPEN: Modifier("not open")
|
||||||
|
OVERRIDE: Modifier("override")
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ import java.util.Set
|
|||||||
public open class Trait(converter : Converter,
|
public open class Trait(converter : Converter,
|
||||||
name : Identifier,
|
name : Identifier,
|
||||||
docComments: List<Node>,
|
docComments: List<Node>,
|
||||||
modifiers : Set<String>,
|
modifiers : Set<Modifier>,
|
||||||
typeParameters : List<Element>,
|
typeParameters : List<Element>,
|
||||||
extendsTypes : List<Type>,
|
extendsTypes : List<Type>,
|
||||||
baseClassParams : List<Expression>,
|
baseClassParams : List<Expression>,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.jetbrains.jet.j2k.ast
|
package org.jetbrains.jet.j2k.ast
|
||||||
|
|
||||||
import java.util.List
|
import java.util.List
|
||||||
|
import java.util.Collection
|
||||||
|
|
||||||
fun List<out Node>.toKotlin(separator: String, prefix: String = "", suffix: String = ""): String {
|
fun List<out Node>.toKotlin(separator: String, prefix: String = "", suffix: String = ""): String {
|
||||||
val result = StringBuilder()
|
val result = StringBuilder()
|
||||||
@@ -17,5 +18,14 @@ fun List<out Node>.toKotlin(separator: String, prefix: String = "", suffix: Stri
|
|||||||
return result.toString()!!
|
return result.toString()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Collection<Modifier>.toKotlin(separator: String = " "): String {
|
||||||
|
val result = StringBuilder()
|
||||||
|
for(x in this) {
|
||||||
|
result.append(x.name)
|
||||||
|
result.append(separator)
|
||||||
|
}
|
||||||
|
return result.toString()!!
|
||||||
|
}
|
||||||
|
|
||||||
fun String.withPrefix(prefix: String) = if (isEmpty()) "" else prefix + this
|
fun String.withPrefix(prefix: String) = if (isEmpty()) "" else prefix + this
|
||||||
fun Expression.withPrefix(prefix: String) = if (isEmpty()) "" else prefix + toKotlin()
|
fun Expression.withPrefix(prefix: String) = if (isEmpty()) "" else prefix + toKotlin()
|
||||||
|
|||||||
Reference in New Issue
Block a user