Refactor converter:
Remove unneeded filtering
This commit is contained in:
committed by
Pavel V. Talanov
parent
04edb3d742
commit
f8c8e59f94
@@ -30,9 +30,6 @@ import java.util.*
|
||||
import com.intellij.psi.CommonClassNames.*
|
||||
import org.jetbrains.jet.lang.types.expressions.OperatorConventions.*
|
||||
import com.intellij.psi.util.PsiUtil
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||
import org.jetbrains.jet.util.QualifiedNamesUtil
|
||||
import org.jetbrains.jet.lang.resolve.java.mapping.JavaToKotlinClassMap
|
||||
import com.intellij.openapi.project.Project
|
||||
|
||||
public class Converter(val project: Project, val settings: ConverterSettings) {
|
||||
@@ -77,11 +74,9 @@ public class Converter(val project: Project, val settings: ConverterSettings) {
|
||||
public fun fileToFile(javaFile: PsiJavaFile): File {
|
||||
val body = ArrayList<Node>()
|
||||
for (element in javaFile.getChildren()) {
|
||||
if (element !is PsiImportStatementBase) {
|
||||
val node = topElementToElement(element)
|
||||
if (node != null) {
|
||||
body.add(node)
|
||||
}
|
||||
val node = topElementToElement(element)
|
||||
if (node != null) {
|
||||
body.add(node)
|
||||
}
|
||||
}
|
||||
return File(quoteKeywords(javaFile.getPackageName()), body, createMainFunction(javaFile))
|
||||
@@ -148,7 +143,7 @@ public class Converter(val project: Project, val settings: ConverterSettings) {
|
||||
for (m in members) {
|
||||
if (m is Constructor) {
|
||||
if (!m.isPrimary) {
|
||||
for (fo in finalOrWithEmptyInitializer){
|
||||
for (fo in finalOrWithEmptyInitializer) {
|
||||
val init = getDefaultInitializer(fo)
|
||||
initializers.put(fo.identifier.toKotlin(), init)
|
||||
}
|
||||
@@ -266,7 +261,7 @@ public class Converter(val project: Project, val settings: ConverterSettings) {
|
||||
|
||||
if (method.isConstructor()) {
|
||||
return Constructor(this, identifier, docComments, modifiers, returnType, typeParameters, params,
|
||||
Block(removeEmpty(body.statements), false), isConstructorPrimary(method))
|
||||
Block(body.statements), isConstructorPrimary(method))
|
||||
}
|
||||
|
||||
return Function(this, identifier, docComments, modifiers, returnType, typeParameters, params, body)
|
||||
@@ -287,7 +282,7 @@ public class Converter(val project: Project, val settings: ConverterSettings) {
|
||||
if (block == null)
|
||||
return Block.EMPTY_BLOCK
|
||||
|
||||
return Block(removeEmpty(statementsToStatementList(block.getChildren())), notEmpty)
|
||||
return Block(statementsToStatementList(block.getChildren()), notEmpty)
|
||||
}
|
||||
|
||||
public fun blockToBlock(block: PsiCodeBlock?): Block {
|
||||
|
||||
Reference in New Issue
Block a user