Collection of useful Structural Replace templates.
- Copy the desired template XML
- In IntelliJ IDEA open
Edit | Find | Replace Structurally...
- Press Ctrl + V (⌘ + V)
- Click
Find
Replaces project references made in string notation with type-safe notation.
dependencies {
- implementation(project(":project-name:subproject-name"))
+ implementation(projects.projectName.subprojectName)
}
Template:
<replaceConfiguration name="Migrate to type-safe project accessors" text="project(":$projectPath$")" recursive="false" type="Kotlin" pattern_context="default" search_injected="false" reformatAccordingToStyle="false" shortenFQN="false" replacement="projects$transformedPath$">
<constraint name="__context__" within="" contains="" />
<constraint name="projectPath" within="" contains="" />
<variableDefinition name="transformedPath" script=""projectPath.text.replace(':', '.').split('[_-]').collect { word -> word.capitalize() }.join('')"" />
</replaceConfiguration>
Reduces nesting level of dependncies declaration block in a KMP project. Requires Kotlin Gradle Plugin 1.9.20+
kotlin {
sourceSets {
- commonTest {
- dependencies {
- implementation(kotlin("test"))
- }
+ commonTest.dependencies {
+ implementation(kotlin("test"))
}
}
}
Template:
<replaceConfiguration name="KMP: Compact sourceSet dependecies block" text="$sourceSet$ { dependencies { $dependencies$ } }" recursive="false" type="Kotlin" pattern_context="default" search_injected="false" reformatAccordingToStyle="false" shortenFQN="false" replacement="$sourceSet$.dependencies { $dependencies$ }">
<constraint name="__context__" within="" contains="" />
<constraint name="dependencies" minCount="0" maxCount="2147483647" within="" contains="" />
<constraint name="sourceSet" within="" contains="" />
</replaceConfiguration>