Skip to content

Commit

Permalink
noname parameter by index on int
Browse files Browse the repository at this point in the history
  • Loading branch information
dnbln committed Jan 1, 2021
1 parent e5d7bd5 commit 8281c79
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/main/kotlin/com/mdrobnak/lalrpop/psi/ext/LpAction.kt
Original file line number Diff line number Diff line change
@@ -25,6 +25,9 @@ import org.rust.lang.core.types.infer.substitute
val LpAction.alternativeParent: LpAlternative
get() = this.parentOfType()!!

val Int.lalrpopNoNameParameterByIndex
get() = "__intellij_lalrpop_noname_$this"

/**
* The action code function header / definition (<code>fn __intellij_lalrpop <type_params>(params) where where_clauses</code>),
* without the opening brace.
@@ -69,7 +72,7 @@ fun LpAction.actionCodeFunctionHeader(withReturnType: Boolean = true): String {
val arguments = inputs.mapIndexed { index, it ->
when (it) {
is LpSelectedType.WithName -> (if (it.isMutable) "mut " else "") + it.name + ": " + it.type
is LpSelectedType.WithoutName -> "__intellij_lalrpop_noname_$index: " + it.type
is LpSelectedType.WithoutName -> "${index.lalrpopNoNameParameterByIndex}: " + it.type
}
}.joinToString(", ")

Original file line number Diff line number Diff line change
@@ -143,7 +143,7 @@ private fun List<LpSelectedType>.replacement(context: Context): String =
Context.Braces -> "${it.name}: ${it.name}"
}
is LpSelectedType.WithoutName -> {
"__intellij_lalrpop_noname_$index"
index.lalrpopNoNameParameterByIndex
}
}
}.joinToString(separator = ", ")

0 comments on commit 8281c79

Please # to comment.