Skip to content

Commit

Permalink
Remove Node.TypeArg.type extension
Browse files Browse the repository at this point in the history
  • Loading branch information
orangain committed Jul 9, 2022
1 parent 02e721b commit ea3fe8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import ktast.ast.Node
import ktast.ast.Visitor
import ktast.ast.Writer
import ktcodeshift.*
import ktcodeshift.Api
import ktcodeshift.isDataClass
import ktcodeshift.toSource
import ktcodeshift.transform
import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeSmart
import java.nio.charset.StandardCharsets

Expand Down Expand Up @@ -47,7 +50,7 @@ transform { fileInfo ->
typeArg.copy(
typeRef = typeArg.typeRef?.copy(
type = toFqNameType(
typeArg.type as Node.Type.Simple,
typeArg.typeRef?.type as Node.Type.Simple,
nestedNames
),
),
Expand Down Expand Up @@ -141,7 +144,8 @@ transform { fileInfo ->
val firstParamType = firstParam.typeRef?.type as? Node.Type.Simple
if (firstParamType != null) {
if (firstParamType.pieces.firstOrNull()?.name?.name == "List") {
val listElementType = firstParamType.pieces.first().typeArgs!!.elements[0].type
val listElementType =
firstParamType.pieces.first().typeArgs!!.elements[0].typeRef?.type
if (listElementType != null) {
val varargFunc = functionDeclaration(
name = nameExpression(functionName),
Expand Down
3 changes: 0 additions & 3 deletions ktcodeshift-dsl/src/main/kotlin/ktcodeshift/NodeExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ val Node.WithModifiers.keywordModifiers: List<Node.Modifier.Keyword>

val Node.Declaration.Class.isDataClass: Boolean
get() = isClass && keywordModifiers.contains(Node.Modifier.Keyword(Node.Modifier.Keyword.Token.DATA))

val Node.TypeArg.type: Node.Type?
get() = (this as? Node.TypeArg)?.typeRef?.type

0 comments on commit ea3fe8c

Please sign in to comment.