New J2K: Fix modifiers of local class

This commit is contained in:
Ilya Kirillov
2018-12-24 12:06:14 +03:00
committed by Ilya Kirillov
parent ec1bc35df7
commit 5e6e5bcf8c
3 changed files with 9 additions and 1 deletions
@@ -19,6 +19,7 @@ class InnerClassConversion : RecursiveApplicableConversionBase() {
private fun applyArmed(element: JKTreeElement, outer: JKClass): JKTreeElement { private fun applyArmed(element: JKTreeElement, outer: JKClass): JKTreeElement {
if (element !is JKClass) return recurseArmed(element, outer) if (element !is JKClass) return recurseArmed(element, outer)
if (element.isLocalClass()) return recurseArmed(element, outer)
val static = element.extraModifiers.find { it == ExtraModifier.STATIC } val static = element.extraModifiers.find { it == ExtraModifier.STATIC }
if (static != null) { if (static != null) {
@@ -13,7 +13,11 @@ class JavaModifiersConversion(private val context: ConversionContext) : Recursiv
override fun applyToElement(element: JKTreeElement): JKTreeElement { override fun applyToElement(element: JKTreeElement): JKTreeElement {
if (element is JKVisibilityOwner) { if (element is JKVisibilityOwner) {
if (element.visibility == Visibility.PACKAGE_PRIVATE) { if (element.visibility == Visibility.PACKAGE_PRIVATE) {
element.visibility = Visibility.INTERNAL if (element is JKClass && element.isLocalClass()) {
element.visibility = Visibility.PUBLIC
} else {
element.visibility = Visibility.INTERNAL
}
} }
} }
if (element is JKExtraModifiersOwner && element is JKAnnotationListOwner) { if (element is JKExtraModifiersOwner && element is JKAnnotationListOwner) {
@@ -63,6 +63,9 @@ interface JKClass : JKDeclaration, JKVisibilityOwner, JKExtraModifiersOwner, JKM
} }
} }
fun JKClass.isLocalClass(): Boolean =
parent !is JKClassBody && parent !is JKFile
val JKClass.declarationList: List<JKDeclaration> val JKClass.declarationList: List<JKDeclaration>
get() = classBody.declarations get() = classBody.declarations