Converter:
Do not generate redundant visibility modifier for overrides
This commit is contained in:
@@ -49,33 +49,34 @@ public open class Function(val converter: Converter,
|
||||
}
|
||||
|
||||
private fun modifiersToKotlin(): String {
|
||||
val modifierList = ArrayList<Modifier>()
|
||||
val resultingModifiers = ArrayList<Modifier>()
|
||||
val isOverride = modifiers.contains(Modifier.OVERRIDE)
|
||||
if (isOverride) {
|
||||
resultingModifiers.add(Modifier.OVERRIDE)
|
||||
}
|
||||
|
||||
val accessModifier = accessModifier()
|
||||
if (accessModifier != null) {
|
||||
modifierList.add(accessModifier)
|
||||
if (accessModifier != null && !isOverride) {
|
||||
resultingModifiers.add(accessModifier)
|
||||
}
|
||||
|
||||
if (isAbstract()) {
|
||||
modifierList.add(Modifier.ABSTRACT)
|
||||
}
|
||||
|
||||
if (modifiers.contains(Modifier.OVERRIDE)) {
|
||||
modifierList.add(Modifier.OVERRIDE)
|
||||
resultingModifiers.add(Modifier.ABSTRACT)
|
||||
}
|
||||
|
||||
if (converter.settings.openByDefault &&
|
||||
!modifiers.contains(Modifier.ABSTRACT) &&
|
||||
!modifiers.contains(Modifier.OVERRIDE) &&
|
||||
!isOverride &&
|
||||
!modifiers.contains(Modifier.FINAL) &&
|
||||
!modifiers.contains(Modifier.PRIVATE)) {
|
||||
modifierList.add(Modifier.OPEN)
|
||||
resultingModifiers.add(Modifier.OPEN)
|
||||
}
|
||||
|
||||
if (modifiers.contains(Modifier.NOT_OPEN)) {
|
||||
modifierList.remove(Modifier.OPEN)
|
||||
resultingModifiers.remove(Modifier.OPEN)
|
||||
}
|
||||
|
||||
return modifierList.toKotlin()
|
||||
return resultingModifiers.toKotlin()
|
||||
}
|
||||
|
||||
private fun returnTypeToKotlin() = if (!`type`.isUnit()) " : " + `type`.toKotlin() + " " else " "
|
||||
|
||||
@@ -4,7 +4,7 @@ BLACK
|
||||
RED
|
||||
YELLOW
|
||||
BLUE
|
||||
public override fun run() {
|
||||
override fun run() {
|
||||
System.out.println("name()=" + name() + ", toString()=" + toString())
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ BLACK
|
||||
RED
|
||||
YELLOW
|
||||
BLUE
|
||||
public override fun run() {
|
||||
override fun run() {
|
||||
System.out?.println("name()=" + name() + ", toString()=" + toString())
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package test
|
||||
class Test() : Base() {
|
||||
public override fun hashCode() : Int {
|
||||
override fun hashCode() : Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
public override fun equals(o : Any) : Boolean {
|
||||
override fun equals(o : Any) : Boolean {
|
||||
return super.equals(o)
|
||||
}
|
||||
protected override fun clone() : Any {
|
||||
override fun clone() : Any {
|
||||
return super.clone()
|
||||
}
|
||||
public override fun toString() : String {
|
||||
override fun toString() : String {
|
||||
return super.toString()
|
||||
}
|
||||
protected override fun finalize() {
|
||||
override fun finalize() {
|
||||
super.finalize()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package test
|
||||
open class Test() : Base() {
|
||||
public override fun hashCode() : Int {
|
||||
override fun hashCode() : Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
public override fun equals(o : Any?) : Boolean {
|
||||
override fun equals(o : Any?) : Boolean {
|
||||
return super.equals(o)
|
||||
}
|
||||
protected override fun clone() : Any? {
|
||||
override fun clone() : Any? {
|
||||
return super.clone()
|
||||
}
|
||||
public override fun toString() : String? {
|
||||
override fun toString() : String? {
|
||||
return super.toString()
|
||||
}
|
||||
protected override fun finalize() {
|
||||
override fun finalize() {
|
||||
super.finalize()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ return getJavaClass<Base>.getName() + '@' + Integer.toHexString(hashCode())
|
||||
}
|
||||
}
|
||||
class Child() : Base() {
|
||||
public override fun hashCode() : Int {
|
||||
override fun hashCode() : Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
public override fun equals(o : Any) : Boolean {
|
||||
override fun equals(o : Any) : Boolean {
|
||||
return super.equals(o)
|
||||
}
|
||||
public override fun toString() : String {
|
||||
override fun toString() : String {
|
||||
return super.toString()
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,13 @@ return getJavaClass<Base>.getName() + '@' + Integer.toHexString(hashCode())
|
||||
}
|
||||
}
|
||||
open class Child() : Base() {
|
||||
public override fun hashCode() : Int {
|
||||
override fun hashCode() : Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
public override fun equals(o : Any?) : Boolean {
|
||||
override fun equals(o : Any?) : Boolean {
|
||||
return super.equals(o)
|
||||
}
|
||||
public override fun toString() : String? {
|
||||
override fun toString() : String? {
|
||||
return super.toString()
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.voltvoodoo.saplo4j.model
|
||||
import java.io.Serializable
|
||||
public class Language(code : String) : Serializable {
|
||||
protected var code : String = 0
|
||||
public override fun toString() : String {
|
||||
override fun toString() : String {
|
||||
return this.code
|
||||
}
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.voltvoodoo.saplo4j.model
|
||||
import java.io.Serializable
|
||||
public open class Language(code : String?) : Serializable {
|
||||
protected var code : String? = null
|
||||
public override fun toString() : String? {
|
||||
override fun toString() : String? {
|
||||
return this.code
|
||||
}
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package demo
|
||||
class Test() : java.lang.Iterable<String> {
|
||||
public override fun iterator() : java.util.Iterator<String> {
|
||||
override fun iterator() : java.util.Iterator<String> {
|
||||
return null
|
||||
}
|
||||
public fun push(i : java.util.Iterator<String>) : java.util.Iterator<String> {
|
||||
@@ -9,7 +9,7 @@ return j
|
||||
}
|
||||
}
|
||||
class FullTest() : java.lang.Iterable<String> {
|
||||
public override fun iterator() : java.util.Iterator<String> {
|
||||
override fun iterator() : java.util.Iterator<String> {
|
||||
return null
|
||||
}
|
||||
public fun push(i : java.util.Iterator<String>) : java.util.Iterator<String> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package demo
|
||||
open class Test() : java.lang.Iterable<String?> {
|
||||
public override fun iterator() : java.util.Iterator<String?>? {
|
||||
override fun iterator() : java.util.Iterator<String?>? {
|
||||
return null
|
||||
}
|
||||
public open fun push(i : java.util.Iterator<String?>?) : java.util.Iterator<String?>? {
|
||||
@@ -9,7 +9,7 @@ return j
|
||||
}
|
||||
}
|
||||
open class FullTest() : java.lang.Iterable<String?> {
|
||||
public override fun iterator() : java.util.Iterator<String?>? {
|
||||
override fun iterator() : java.util.Iterator<String?>? {
|
||||
return null
|
||||
}
|
||||
public open fun push(i : java.util.Iterator<String?>?) : java.util.Iterator<String?>? {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
object : Runnable() {
|
||||
public override fun run() {
|
||||
override fun run() {
|
||||
System.out.println("Run")
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
object : Runnable() {
|
||||
public override fun run() {
|
||||
override fun run() {
|
||||
System.out?.println("Run")
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,12 @@ public fun windowClosing() {
|
||||
public class Client() : Frame() {
|
||||
{
|
||||
val a = object : WindowAdapter() {
|
||||
public override fun windowClosing() {
|
||||
override fun windowClosing() {
|
||||
}
|
||||
}
|
||||
addWindowListener(a)
|
||||
addWindowListener(object : WindowAdapter() {
|
||||
public override fun windowClosing() {
|
||||
override fun windowClosing() {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ public open fun windowClosing() {
|
||||
public class Client() : Frame() {
|
||||
{
|
||||
var a : WindowAdapter? = object : WindowAdapter() {
|
||||
public override fun windowClosing() {
|
||||
override fun windowClosing() {
|
||||
}
|
||||
}
|
||||
addWindowListener(a)
|
||||
addWindowListener(object : WindowAdapter() {
|
||||
public override fun windowClosing() {
|
||||
override fun windowClosing() {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user