Member converted; modifiers is a set of non-null strings
This commit is contained in:
committed by
Pavel V. Talanov
parent
b3246f85a4
commit
036df18868
@@ -8,7 +8,7 @@ import java.util.List
|
|||||||
public open class AnonymousClass(converter : Converter, members : List<Member>)
|
public open class AnonymousClass(converter : Converter, members : List<Member>)
|
||||||
: Class(converter,
|
: Class(converter,
|
||||||
IdentifierImpl("anonClass"),
|
IdentifierImpl("anonClass"),
|
||||||
Collections.emptySet<String?>()!!,
|
Collections.emptySet<String>()!!,
|
||||||
Collections.emptyList<Element>()!!,
|
Collections.emptyList<Element>()!!,
|
||||||
Collections.emptyList<Type>()!!,
|
Collections.emptyList<Type>()!!,
|
||||||
Collections.emptyList<Expression>()!!,
|
Collections.emptyList<Expression>()!!,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import java.util.ArrayList
|
|||||||
|
|
||||||
public open class Class(converter : Converter,
|
public open class Class(converter : Converter,
|
||||||
val name : Identifier,
|
val name : Identifier,
|
||||||
modifiers : Set<String?>,
|
modifiers : Set<String>,
|
||||||
val typeParameters : List<Element>,
|
val typeParameters : List<Element>,
|
||||||
val extendsTypes : List<Type>,
|
val extendsTypes : List<Type>,
|
||||||
val baseClassParams : List<Expression>,
|
val baseClassParams : List<Expression>,
|
||||||
@@ -63,7 +63,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<String> = HashSet<String>(f.getModifiers())
|
||||||
modifiers.add(Modifier.STATIC)
|
modifiers.add(Modifier.STATIC)
|
||||||
val statements : List<Statement?> = f.block?.getStatements() ?: arrayList()
|
val statements : List<Statement?> = f.block?.getStatements() ?: arrayList()
|
||||||
statements.add(ReturnStatement(IdentifierImpl("__")))
|
statements.add(ReturnStatement(IdentifierImpl("__")))
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.jetbrains.jet.j2k.ast.INode.Kind
|
|||||||
import org.jetbrains.jet.j2k.ast.types.Type
|
import org.jetbrains.jet.j2k.ast.types.Type
|
||||||
|
|
||||||
public open class Constructor(identifier : Identifier,
|
public open class Constructor(identifier : Identifier,
|
||||||
modifiers : Set<String?>,
|
modifiers : Set<String>,
|
||||||
`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,
|
||||||
modifiers : Set<String?>,
|
modifiers : Set<String>,
|
||||||
typeParameters : List<Element>,
|
typeParameters : List<Element>,
|
||||||
extendsTypes : List<Type>,
|
extendsTypes : List<Type>,
|
||||||
baseClassParams : List<Expression>,
|
baseClassParams : List<Expression>,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import org.jetbrains.jet.j2k.ast.types.Type
|
|||||||
import java.util.Set
|
import java.util.Set
|
||||||
|
|
||||||
public open class EnumConstant(identifier : Identifier,
|
public open class EnumConstant(identifier : Identifier,
|
||||||
modifiers : Set<String?>,
|
modifiers : Set<String>,
|
||||||
`type` : Type,
|
`type` : Type,
|
||||||
params : Element) : Field(identifier, modifiers, `type`.convertedToNotNull(), params, 0) {
|
params : Element) : Field(identifier, modifiers, `type`.convertedToNotNull(), params, 0) {
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.Set
|
|||||||
import org.jetbrains.jet.j2k.Converter.getDefaultInitializer
|
import org.jetbrains.jet.j2k.Converter.getDefaultInitializer
|
||||||
|
|
||||||
public open class Field(val identifier : Identifier,
|
public open class Field(val identifier : Identifier,
|
||||||
modifiers : Set<String?>,
|
modifiers : Set<String>,
|
||||||
val `type` : Type,
|
val `type` : Type,
|
||||||
val initializer : Element,
|
val initializer : Element,
|
||||||
val writingAccesses : Int) : Member(modifiers) {
|
val writingAccesses : Int) : Member(modifiers) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import java.util.Set
|
|||||||
import org.jetbrains.jet.j2k.ast.types.Type
|
import org.jetbrains.jet.j2k.ast.types.Type
|
||||||
|
|
||||||
public open class Function(val name : Identifier,
|
public open class Function(val name : Identifier,
|
||||||
modifiers : Set<String?>,
|
modifiers : Set<String>,
|
||||||
val `type` : Type,
|
val `type` : Type,
|
||||||
val typeParameters : List<Element>,
|
val typeParameters : List<Element>,
|
||||||
val params : Element,
|
val params : Element,
|
||||||
|
|||||||
@@ -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<String>) : Member(modifiers) {
|
||||||
public override fun toKotlin() : String {
|
public override fun toKotlin() : String {
|
||||||
return block.toKotlin()
|
return block.toKotlin()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,54 +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;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ignatov
|
|
||||||
*/
|
|
||||||
public abstract class Member extends Node {
|
|
||||||
@NotNull protected Set<String> myModifiers;
|
|
||||||
|
|
||||||
protected Member(Set<String> modifiers) {
|
|
||||||
myModifiers = modifiers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
String accessModifier() {
|
|
||||||
for (String m : myModifiers)
|
|
||||||
if (m.equals(Modifier.PUBLIC) || m.equals(Modifier.PROTECTED) || m.equals(Modifier.PRIVATE)) {
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
return EMPTY; // package local converted to internal, but we use internal by default
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAbstract() {
|
|
||||||
return myModifiers.contains(Modifier.ABSTRACT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isStatic() {
|
|
||||||
return myModifiers.contains(Modifier.STATIC);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public Set<String> getModifiers() {
|
|
||||||
return myModifiers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package org.jetbrains.jet.j2k.ast
|
||||||
|
|
||||||
|
import java.util.Set
|
||||||
|
|
||||||
|
public abstract class Member(val myModifiers : Set<String>) : Node() {
|
||||||
|
open fun accessModifier() : String {
|
||||||
|
return myModifiers.find { m -> m == Modifier.PUBLIC || m == Modifier.PROTECTED || m == Modifier.PRIVATE } ?: ""
|
||||||
|
}
|
||||||
|
|
||||||
|
public open fun isAbstract() : Boolean = myModifiers.contains(Modifier.ABSTRACT)
|
||||||
|
public open fun isStatic() : Boolean = myModifiers.contains(Modifier.STATIC)
|
||||||
|
public open fun getModifiers() : Set<String> = myModifiers
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ import java.util.Set
|
|||||||
|
|
||||||
public open class Trait(converter : Converter,
|
public open class Trait(converter : Converter,
|
||||||
name : Identifier,
|
name : Identifier,
|
||||||
modifiers : Set<String?>,
|
modifiers : Set<String>,
|
||||||
typeParameters : List<Element>,
|
typeParameters : List<Element>,
|
||||||
extendsTypes : List<Type>,
|
extendsTypes : List<Type>,
|
||||||
baseClassParams : List<Expression>,
|
baseClassParams : List<Expression>,
|
||||||
|
|||||||
Reference in New Issue
Block a user