Skip to content

Commit

Permalink
Spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Dec 21, 2024
1 parent c4f931c commit 3df9933
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ redacted {
// Define custom unredacted annotations.
unredactedAnnotations.add("dev/zacsweers/redacted/annotations/Unredacted") // Default

// Define whether this plugin is enabled on this compilation. Useful if you want to
// Define whether this plugin is enabled on this compilation. Useful if you want to
// gate this behind a dynamic build configuration.
enabled = true // Default

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName

internal class RedactedIrGenerationExtension(
private val messageCollector: MessageCollector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import org.jetbrains.kotlin.ir.util.parentClassOrNull
import org.jetbrains.kotlin.ir.util.primaryConstructor
import org.jetbrains.kotlin.ir.util.properties
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.util.OperatorNameConventions

internal const val LOG_PREFIX = "*** REDACTED (IR):"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ public class RedactedComponentRegistrar : CompilerPluginRegistrar() {
val messageCollector =
configuration.get(CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
val replacementString = checkNotNull(configuration[KEY_REPLACEMENT_STRING])
val redactedAnnotations = checkNotNull(configuration[KEY_REDACTED_ANNOTATIONS])
.splitToSequence(",")
.mapTo(LinkedHashSet()) { ClassId.fromString(it) }
val unRedactedAnnotations = checkNotNull(configuration[KEY_UNREDACTED_ANNOTATION])
.splitToSequence(",")
.mapTo(LinkedHashSet()) { ClassId.fromString(it) }
val redactedAnnotations =
checkNotNull(configuration[KEY_REDACTED_ANNOTATIONS]).splitToSequence(",").mapTo(
LinkedHashSet()
) {
ClassId.fromString(it)
}
val unRedactedAnnotations =
checkNotNull(configuration[KEY_UNREDACTED_ANNOTATION]).splitToSequence(",").mapTo(
LinkedHashSet()
) {
ClassId.fromString(it)
}
val usesK2 = configuration.languageVersionSettings.languageVersion.usesK2

if (usesK2) {
Expand All @@ -57,7 +63,8 @@ public class RedactedComponentRegistrar : CompilerPluginRegistrar() {
RedactedIrGenerationExtension(
messageCollector,
replacementString,
redactedAnnotations, unRedactedAnnotations
redactedAnnotations,
unRedactedAnnotations,
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ internal inline fun <T, R : Any> Iterable<T>.firstNotNullResult(transform: (T) -
if (result != null) return result
}
return null
}
}

0 comments on commit 3df9933

Please sign in to comment.