Better code in j2k
This commit is contained in:
@@ -265,7 +265,7 @@ class ConstructorConverter(
|
|||||||
if (target is PsiParameter) {
|
if (target is PsiParameter) {
|
||||||
val scope = target.getDeclarationScope()
|
val scope = target.getDeclarationScope()
|
||||||
// we do not check for exactly this constructor because default values reference parameters in other constructors
|
// we do not check for exactly this constructor because default values reference parameters in other constructors
|
||||||
if (scope.isConstructor() && scope.getParent() == psiClass) {
|
if (scope is PsiMember && scope.isConstructor() && scope.getParent() == psiClass) {
|
||||||
return Identifier(replacement, codeConverter.typeConverter.variableNullability(target).isNullable(codeConverter.settings))
|
return Identifier(replacement, codeConverter.typeConverter.variableNullability(target).isNullable(codeConverter.settings))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ fun PsiElement.isInSingleLine(): Boolean {
|
|||||||
|
|
||||||
var child = getFirstChild()
|
var child = getFirstChild()
|
||||||
while (child != null) {
|
while (child != null) {
|
||||||
if (!child!!.isInSingleLine()) return false
|
if (!child.isInSingleLine()) return false
|
||||||
child = child!!.getNextSibling()
|
child = child.getNextSibling()
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ fun PsiElement.isInSingleLine(): Boolean {
|
|||||||
fun PsiElement.getContainingMethod(): PsiMethod? {
|
fun PsiElement.getContainingMethod(): PsiMethod? {
|
||||||
var context = getContext()
|
var context = getContext()
|
||||||
while (context != null) {
|
while (context != null) {
|
||||||
val _context = context!!
|
val _context = context
|
||||||
if (_context is PsiMethod) return _context
|
if (_context is PsiMethod) return _context
|
||||||
context = _context.getContext()
|
context = _context.getContext()
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ fun PsiElement.getContainingConstructor(): PsiMethod? {
|
|||||||
return if (method?.isConstructor() == true) method else null
|
return if (method?.isConstructor() == true) method else null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun PsiElement.isConstructor(): Boolean = this is PsiMethod && this.isConstructor()
|
fun PsiMember.isConstructor(): Boolean = this is PsiMethod && this.isConstructor()
|
||||||
|
|
||||||
fun PsiModifierListOwner.accessModifier(): String = when {
|
fun PsiModifierListOwner.accessModifier(): String = when {
|
||||||
hasModifierProperty(PsiModifier.PUBLIC) -> PsiModifier.PUBLIC
|
hasModifierProperty(PsiModifier.PUBLIC) -> PsiModifier.PUBLIC
|
||||||
|
|||||||
Reference in New Issue
Block a user